@flemist/mcp-project-tools 3.0.8 → 3.0.9

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.
@@ -24,19 +24,19 @@ function wt(t) {
24
24
  n();
25
25
  };
26
26
  }
27
- async function q(t) {
27
+ async function G(t) {
28
28
  const { logFilePath: r, message: s, data: o } = t;
29
29
  try {
30
- const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), a = `[${e}] ${s}
30
+ const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), i = `[${e}] ${s}
31
31
  ${n}
32
32
 
33
33
  `;
34
- await B.promises.mkdir(T.dirname(r), { recursive: !0 }), await B.promises.appendFile(r, a);
34
+ await B.promises.mkdir(T.dirname(r), { recursive: !0 }), await B.promises.appendFile(r, i);
35
35
  } catch (e) {
36
36
  console.error(`Failed to log "${s}":`, e);
37
37
  }
38
38
  }
39
- const G = /* @__PURE__ */ new Map();
39
+ const q = /* @__PURE__ */ new Map();
40
40
  function yt(t) {
41
41
  return t.headers["mcp-session-id"] || t.headers["x-session-id"] || t.query.token;
42
42
  }
@@ -44,17 +44,17 @@ async function bt(t, r) {
44
44
  const s = t.createMcpServer(), o = new at({
45
45
  sessionIdGenerator: () => r || nt(),
46
46
  onsessioninitialized: (n) => {
47
- G.set(n, o);
47
+ q.set(n, o);
48
48
  },
49
49
  enableJsonResponse: !0
50
50
  });
51
51
  async function e() {
52
52
  const n = o.sessionId;
53
- n && G.delete(n);
53
+ n && q.delete(n);
54
54
  try {
55
55
  await s.close();
56
- } catch (a) {
57
- console.error("Failed to close session", a);
56
+ } catch (i) {
57
+ console.error("Failed to close session", i);
58
58
  }
59
59
  }
60
60
  o.onclose = e;
@@ -65,16 +65,16 @@ async function bt(t, r) {
65
65
  }
66
66
  }
67
67
  async function St(t, r, s, o) {
68
- await q({
68
+ await G({
69
69
  logFilePath: s.logFilePath,
70
70
  message: "REQUEST",
71
71
  data: t.body
72
72
  });
73
- let e = o ? G.get(o) : null;
73
+ let e = o ? q.get(o) : null;
74
74
  e || (e = await bt(s, o)), await e.handleRequest(t, r, t.body);
75
75
  }
76
76
  async function xt(t, r, s) {
77
- const o = s ? G.get(s) : null;
77
+ const o = s ? q.get(s) : null;
78
78
  if (!o) {
79
79
  r.status(400).json({ error: "No valid session found" });
80
80
  return;
@@ -146,11 +146,11 @@ function H(t) {
146
146
  if (s - r.lastOutputTime.getTime() >= Tt && (r.output += r.localOutput, r.localOutput = "", r.lastOutputTime = new Date(s), r.output.length > k)) {
147
147
  const n = `
148
148
  ... [${r.output.length - k} characters trimmed] ...
149
- `, a = k - n.length;
150
- if (a > 0) {
151
- const i = Math.floor(a / 2);
152
- r.output = r.output.substring(0, i) + n + r.output.substring(
153
- r.output.length - (a - i)
149
+ `, i = k - n.length;
150
+ if (i > 0) {
151
+ const a = Math.floor(i / 2);
152
+ r.output = r.output.substring(0, a) + n + r.output.substring(
153
+ r.output.length - (i - a)
154
154
  );
155
155
  } else
156
156
  r.output = r.output.substring(0, k);
@@ -164,8 +164,8 @@ function Et(t, r) {
164
164
  `, n = s - e.length;
165
165
  if (n <= 0)
166
166
  return t.substring(0, s);
167
- const a = Math.floor(n / 2);
168
- return t.substring(0, a) + e + t.substring(t.length - (n - a));
167
+ const i = Math.floor(n / 2);
168
+ return t.substring(0, i) + e + t.substring(t.length - (n - i));
169
169
  }
170
170
  function C(t) {
171
171
  return `Invalid arguments: ${t instanceof Error ? t.message : "Unknown error"}.
@@ -196,7 +196,7 @@ async function Y(t, r) {
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
  H({ process: n });
199
- const a = n.output + n.localOutput, i = Et(a, { limit: e });
199
+ const i = n.output + n.localOutput, a = Et(i, { limit: e });
200
200
  return n.output = "", n.localOutput = "", {
201
201
  id: n.id,
202
202
  cwd: T.relative(r.workingDir || "", n.cwd),
@@ -206,7 +206,7 @@ async function Y(t, r) {
206
206
  endTime: n.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
207
207
  exitCode: n.exitCode,
208
208
  isRunning: n.isRunning,
209
- output: i,
209
+ output: a,
210
210
  error: n.error
211
211
  };
212
212
  }
@@ -264,8 +264,8 @@ async function ve(t, r) {
264
264
  error: C(m)
265
265
  };
266
266
  }
267
- const { id: o, waitTime: e, autoKill: n, outputLimit: a } = s, i = O.get(o);
268
- if (!i)
267
+ const { id: o, waitTime: e, autoKill: n, outputLimit: i } = s, a = O.get(o);
268
+ if (!a)
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,12 +273,12 @@ async function ve(t, r) {
273
273
  let c = !1, l = !1;
274
274
  e != null && await new Promise((g) => {
275
275
  const p = setInterval(() => {
276
- i.isRunning ? Date.now() - u >= e * 1e3 && (clearInterval(p), c = !0, n && i.pid && (Me(i.pid), l = !0), g()) : (clearInterval(p), g());
276
+ a.isRunning ? Date.now() - u >= e * 1e3 && (clearInterval(p), c = !0, n && a.pid && (Me(a.pid), l = !0), g()) : (clearInterval(p), g());
277
277
  }, 100);
278
278
  });
279
279
  const f = (Date.now() - u) / 1e3;
280
280
  return {
281
- ...await Y({ id: o, outputLimit: a }, r),
281
+ ...await Y({ id: o, outputLimit: i }, r),
282
282
  waitDuration: f,
283
283
  waitTimeExceeded: c,
284
284
  autoKillExecuted: l
@@ -333,9 +333,9 @@ async function Bt(t, r) {
333
333
  error: C(d)
334
334
  };
335
335
  }
336
- const { commandLine: o, waitTime: e, autoKill: n, outputLimit: a } = s, { commandLineRules: i } = r, u = T.resolve(r.workingDir || "", s.cwd || "");
337
- if (!Ct({ commandLine: o, commandLineRules: i })) {
338
- const d = i.map(
336
+ const { commandLine: o, waitTime: e, autoKill: n, outputLimit: i } = s, { commandLineRules: a } = r, u = T.resolve(r.workingDir || "", s.cwd || "");
337
+ if (!Ct({ commandLine: o, commandLineRules: a })) {
338
+ const d = a.map(
339
339
  (m) => `${m.rule.toUpperCase()}: /${m.regexp}/ (${m.note})`
340
340
  ).join(`
341
341
  `);
@@ -390,7 +390,7 @@ To use this command line, ask the user to modify the command line rules in the c
390
390
  console.log(`Process ${l} (${o}) exited with code ${g}`);
391
391
  }), d.on("error", (g) => {
392
392
  f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = g.message, console.error(`Process ${l} error:`, g.message);
393
- }), e != null ? ve({ id: l, waitTime: e, autoKill: n, outputLimit: a }, r) : Y({ id: l, outputLimit: a }, r);
393
+ }), e != null ? ve({ id: l, waitTime: e, autoKill: n, outputLimit: i }, r) : Y({ id: l, outputLimit: i }, r);
394
394
  } catch (d) {
395
395
  return f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = d instanceof Error ? d.message : "Unknown error", { error: f.error };
396
396
  }
@@ -444,17 +444,17 @@ async function Rt(t, r) {
444
444
  error: C(c)
445
445
  };
446
446
  }
447
- const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: a } = s;
448
- let i = Array.from(O.values());
447
+ const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: i } = s;
448
+ let a = Array.from(O.values());
449
449
  if (o) {
450
450
  const c = new Date(o.replace(/[_\s]/g, "T"));
451
- i = i.filter((l) => l.startTime >= c);
451
+ a = a.filter((l) => l.startTime >= c);
452
452
  }
453
453
  if (e) {
454
454
  const c = new Date(e.replace(/[_\s]/g, "T"));
455
- i = i.filter((l) => l.endTime && l.endTime >= c);
455
+ a = a.filter((l) => l.endTime && l.endTime >= c);
456
456
  }
457
- return n && (i = i.filter((c) => c.isRunning)), { processes: i.map((c) => {
457
+ return n && (a = a.filter((c) => c.isRunning)), { processes: a.map((c) => {
458
458
  H({ process: c });
459
459
  let l = {
460
460
  id: c.id,
@@ -468,9 +468,9 @@ async function Rt(t, r) {
468
468
  output: c.output + c.localOutput,
469
469
  error: c.error
470
470
  };
471
- if (a) {
471
+ if (i) {
472
472
  const f = {};
473
- for (const d of a)
473
+ for (const d of i)
474
474
  d in l && (f[d] = l[d]);
475
475
  l = f;
476
476
  }
@@ -567,14 +567,14 @@ ${s.map((o) => `- ${o}`).join(`
567
567
  }
568
568
  function At(t, r) {
569
569
  return function(o, e, n) {
570
- const a = async (...i) => {
571
- await q({
570
+ const i = async (...a) => {
571
+ await G({
572
572
  logFilePath: r.logFilePath,
573
573
  message: "REQUEST",
574
- data: { name: o, args: i }
574
+ data: { name: o, args: a }
575
575
  });
576
- const u = await n(...i);
577
- return await q({
576
+ const u = await n(...a);
577
+ return await G({
578
578
  logFilePath: r.logFilePath,
579
579
  message: "RESPONSE",
580
580
  data: u
@@ -590,15 +590,15 @@ function At(t, r) {
590
590
  return t.registerTool(
591
591
  o,
592
592
  e,
593
- a
593
+ i
594
594
  );
595
595
  };
596
596
  }
597
- function qt(t) {
597
+ function Gt(t) {
598
598
  return t.match(/^[/\\]?[^/\\]+/)[0];
599
599
  }
600
- function Gt(t, r) {
601
- return qt(t) + "|" + r.ino;
600
+ function qt(t, r) {
601
+ return Gt(t) + "|" + r.ino;
602
602
  }
603
603
  function jt(t) {
604
604
  return t.endsWith(":") && (t += "/"), T.resolve(t);
@@ -623,9 +623,9 @@ function De(t) {
623
623
  countDirs: 0,
624
624
  countLinks: 0
625
625
  });
626
- const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? Ee, a = t.handleError, i = t.priority ?? P(0), u = t.walkLinks ?? !1, c = t.log, l = t.handlePath, f = t.matchPath;
626
+ const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? Ee, i = t.handleError, a = t.priority ?? P(0), u = t.walkLinks ?? !1, c = t.log, l = t.handlePath, f = t.matchPath;
627
627
  async function d(g) {
628
- if (!(a && await a(g)) && !_t(g))
628
+ if (!(i && await i(g)) && !_t(g))
629
629
  throw g;
630
630
  }
631
631
  function m(g) {
@@ -673,12 +673,12 @@ function De(t) {
673
673
  pool: n,
674
674
  func: () => B.promises.lstat(b).catch(d),
675
675
  count: 1,
676
- priority: P(x, P(1, i)),
676
+ priority: P(x, P(1, a)),
677
677
  abortSignal: p
678
678
  });
679
679
  if (!E || !$ && E.isFile())
680
680
  return null;
681
- const ne = Gt(b, E);
681
+ const ne = qt(b, E);
682
682
  if (o.has(ne))
683
683
  return null;
684
684
  o.add(ne);
@@ -691,7 +691,7 @@ function De(t) {
691
691
  };
692
692
  const L = P(
693
693
  x,
694
- P(E.isDirectory() ? 2 : 3, i)
694
+ P(E.isDirectory() ? 2 : 3, a)
695
695
  );
696
696
  if (E.isSymbolicLink()) {
697
697
  if (u) {
@@ -723,7 +723,7 @@ function De(t) {
723
723
  pool: n,
724
724
  func: () => B.promises.readdir(b).catch(d),
725
725
  count: 1,
726
- priority: i,
726
+ priority: a,
727
727
  abortSignal: p
728
728
  });
729
729
  if (F) {
@@ -792,9 +792,9 @@ async function Be(t) {
792
792
  pool: Ee,
793
793
  count: 1,
794
794
  func: async () => {
795
- const n = T.resolve(r, e.value), a = await Wt(n), i = T.relative(r, T.dirname(n));
796
- a.forEach((u) => {
797
- u = Kt(u), u = Jt(u, i), s.push(e.exclude ? le(u) : u);
795
+ const n = T.resolve(r, e.value), i = await Wt(n), a = T.relative(r, T.dirname(n));
796
+ i.forEach((u) => {
797
+ u = Kt(u), u = Jt(u, a), s.push(e.exclude ? le(u) : u);
798
798
  });
799
799
  }
800
800
  });
@@ -811,18 +811,18 @@ function Oe({
811
811
  e = e.replace(/\\/g, "/").trim();
812
812
  const n = e.startsWith("^");
813
813
  n && (e = e.substring(1).trim());
814
- const a = e.startsWith("!");
815
- if (a && (e = e.substring(1).trim()), e.startsWith("!") || e.startsWith("^"))
814
+ const i = e.startsWith("!");
815
+ if (i && (e = e.substring(1).trim()), e.startsWith("!") || e.startsWith("^"))
816
816
  throw new Error(
817
817
  `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.`
818
818
  );
819
819
  e.startsWith("/") && (e = "." + e);
820
- const i = r ? T.resolve(r, e).replace(/\\/g, "/") : e.replace(/\\/g, "/");
821
- if (!i)
820
+ const a = r ? T.resolve(r, e).replace(/\\/g, "/") : e.replace(/\\/g, "/");
821
+ if (!a)
822
822
  return;
823
823
  let u;
824
824
  try {
825
- u = mt(i, {
825
+ u = mt(a, {
826
826
  nocase: s ?? !1,
827
827
  dot: !0,
828
828
  strictBrackets: !0
@@ -835,18 +835,18 @@ function Oe({
835
835
  }
836
836
  o.push({
837
837
  exclude: n,
838
- negative: a,
839
- debugInfo: i,
838
+ negative: i,
839
+ debugInfo: a,
840
840
  match: u
841
841
  });
842
842
  }), function(n) {
843
843
  n = n.replace(/\\/g, "/");
844
- let a = null, i = !1;
844
+ let i = null, a = !1;
845
845
  for (let u = 0, c = o.length; u < c; u++) {
846
846
  const l = o[u];
847
- l.match(n) && (l.exclude ? i = !l.negative : (a = !l.negative, i = !1));
847
+ l.match(n) && (l.exclude ? a = !l.negative : (i = !l.negative, a = !1));
848
848
  }
849
- return i ? !1 : a;
849
+ return a ? !1 : i;
850
850
  };
851
851
  }
852
852
  async function Qt(t) {
@@ -864,11 +864,11 @@ async function Qt(t) {
864
864
  rootDir: r,
865
865
  noCase: !0
866
866
  }),
867
- handlePath: async ({ path: n, stat: a, itemStat: i }) => {
868
- const u = T.relative(r, n), c = a.isDirectory(), l = a.isFile();
867
+ handlePath: async ({ path: n, stat: i, itemStat: a }) => {
868
+ const u = T.relative(r, n), c = i.isDirectory(), l = i.isFile();
869
869
  if (!c && !l)
870
870
  return !0;
871
- const f = (u || ".").replace(/\\/g, "/"), d = c ? "dir" : "file", m = c ? i.maxFileDateModified || null : a.mtimeMs, g = c ? i.totalSize : a.size, p = c ? i.countFiles : null, y = {
871
+ const f = (u || ".").replace(/\\/g, "/"), d = c ? "dir" : "file", m = c ? a.maxFileDateModified || null : i.mtimeMs, g = c ? a.totalSize : i.size, p = c ? a.countFiles : null, y = {
872
872
  path: f,
873
873
  type: d
874
874
  };
@@ -897,41 +897,41 @@ function fe(t) {
897
897
  function me(t) {
898
898
  const s = Date.now() - t;
899
899
  if (s < 0) return "0s";
900
- 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), u = Math.floor(a / 30), c = Math.floor(a / 365);
901
- return c > 0 ? `${c}Y` : u > 0 ? `${u}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
900
+ 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), u = Math.floor(i / 30), c = Math.floor(i / 365);
901
+ return c > 0 ? `${c}Y` : u > 0 ? `${u}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
902
902
  }
903
903
  function Ht(t, r) {
904
904
  return r?.length ? [...t].sort((s, o) => {
905
905
  for (let e = 0, n = r.length; e < n; e++) {
906
- const a = r[e];
907
- let i, u;
908
- switch (a.field) {
906
+ const i = r[e];
907
+ let a, u;
908
+ switch (i.field) {
909
909
  case "type":
910
- i = s.type, u = o.type;
910
+ a = s.type, u = o.type;
911
911
  break;
912
912
  case "path":
913
- i = s.path, u = o.path;
913
+ a = s.path, u = o.path;
914
914
  break;
915
915
  case "dateModified":
916
- i = s.dateModified, u = o.dateModified;
916
+ a = s.dateModified, u = o.dateModified;
917
917
  break;
918
918
  case "size":
919
- i = s.size, u = o.size;
919
+ a = s.size, u = o.size;
920
920
  break;
921
921
  case "countFiles":
922
- i = s.countFiles, u = o.countFiles;
922
+ a = s.countFiles, u = o.countFiles;
923
923
  break;
924
924
  }
925
- if (i == null) {
925
+ if (a == null) {
926
926
  if (u == null)
927
927
  continue;
928
928
  return 1;
929
929
  }
930
930
  if (u == null)
931
931
  return -1;
932
- const c = i > u ? 1 : i < u ? -1 : 0;
932
+ const c = a > u ? 1 : a < u ? -1 : 0;
933
933
  if (c !== 0)
934
- return a.desc ? -c : c;
934
+ return i.desc ? -c : c;
935
935
  }
936
936
  return 0;
937
937
  }) : t;
@@ -940,9 +940,9 @@ function Yt(t, r) {
940
940
  const s = Ht(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
941
941
  let e = "";
942
942
  if (s.length > 0 && o.length > 0) {
943
- for (let n = 0, a = o.length; n < a; n++) {
944
- const i = o[n];
945
- switch (n > 0 && (e += " | "), i) {
943
+ for (let n = 0, i = o.length; n < i; n++) {
944
+ const a = o[n];
945
+ switch (n > 0 && (e += " | "), a) {
946
946
  case "dateModified":
947
947
  e += "Time ago (s/m/h/d/w/M/Y)";
948
948
  break;
@@ -960,27 +960,27 @@ function Yt(t, r) {
960
960
  break;
961
961
  }
962
962
  }
963
- for (let n = 0, a = s.length; n < a; n++) {
964
- const i = s[n];
963
+ for (let n = 0, i = s.length; n < i; n++) {
964
+ const a = s[n];
965
965
  e += `
966
966
  `;
967
967
  for (let u = 0, c = o.length; u < c; u++) {
968
968
  const l = o[u];
969
969
  switch (u > 0 && (e += " | "), l) {
970
970
  case "dateModified":
971
- e += i.dateModified ? me(i.dateModified) : "-";
971
+ e += a.dateModified ? me(a.dateModified) : "-";
972
972
  break;
973
973
  case "size":
974
- e += fe(i.size);
974
+ e += fe(a.size);
975
975
  break;
976
976
  case "type":
977
- e += i.type;
977
+ e += a.type;
978
978
  break;
979
979
  case "path":
980
- e += i.type === "dir" ? `${i.path}/` : i.path;
980
+ e += a.type === "dir" ? `${a.path}/` : a.path;
981
981
  break;
982
982
  case "countFiles":
983
- i.type === "dir" ? e += i.countFiles != null ? i.countFiles.toString() : "-" : e += "-";
983
+ a.type === "dir" ? e += a.countFiles != null ? a.countFiles.toString() : "-" : e += "-";
984
984
  break;
985
985
  }
986
986
  }
@@ -990,12 +990,12 @@ function Yt(t, r) {
990
990
  e.length > 0 && (e += `
991
991
  ---
992
992
  `);
993
- const n = fe(t.totals.size ?? 0), a = t.totals.dateModified ? `, last modified ${me(t.totals.dateModified)} ago` : "";
994
- e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${a}`;
993
+ const n = fe(t.totals.size ?? 0), i = t.totals.dateModified ? `, last modified ${me(t.totals.dateModified)} ago` : "";
994
+ e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
995
995
  }
996
996
  return e;
997
997
  }
998
- const Vt = "3.0.8", Zt = {
998
+ const Vt = "3.0.9", Zt = {
999
999
  version: Vt
1000
1000
  }, ds = "Project Tools", fs = "project-tools", ms = Zt.version, hs = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", he = 25e3;
1001
1001
  function pe(t) {
@@ -1105,8 +1105,8 @@ async function Xt(t, r) {
1105
1105
  globs: o,
1106
1106
  showFiles: e,
1107
1107
  showDirs: n,
1108
- sortBy: a,
1109
- minTimeAgo: i,
1108
+ sortBy: i,
1109
+ minTimeAgo: a,
1110
1110
  maxTimeAgo: u,
1111
1111
  minTotalSize: c,
1112
1112
  maxTotalSize: l
@@ -1116,7 +1116,7 @@ async function Xt(t, r) {
1116
1116
  error: 'Fields array must include "path" field when fields are specified. The "path" field is required to identify files and directories in the output'
1117
1117
  };
1118
1118
  const f = s.fields ? s.fields.map((p) => p === "totalCountFiles" ? "countFiles" : p === "lastModified" ? "dateModified" : p) : [];
1119
- let d = a?.map((p) => {
1119
+ let d = i?.map((p) => {
1120
1120
  let y = p.field;
1121
1121
  return y === "totalCountFiles" && (y = "countFiles"), y === "lastModified" && (y = "dateModified"), {
1122
1122
  field: y,
@@ -1151,9 +1151,9 @@ async function Xt(t, r) {
1151
1151
  countFiles: f.includes("countFiles") || m.includes("countFiles")
1152
1152
  };
1153
1153
  let M = null, I = null;
1154
- if (i || u)
1154
+ if (a || u)
1155
1155
  try {
1156
- const $ = Date.now(), v = u ? $ - pe(u) : null, E = i ? $ - pe(i) : null;
1156
+ const $ = Date.now(), v = u ? $ - pe(u) : null, E = a ? $ - pe(a) : null;
1157
1157
  M = [v, E];
1158
1158
  } catch ($) {
1159
1159
  return {
@@ -1320,8 +1320,8 @@ async function Pe(t, r, s) {
1320
1320
  const {
1321
1321
  name: e,
1322
1322
  globs: n,
1323
- types: a,
1324
- minTimeAgo: i,
1323
+ types: i,
1324
+ minTimeAgo: a,
1325
1325
  maxTimeAgo: u,
1326
1326
  minTotalSize: c,
1327
1327
  maxTotalSize: l
@@ -1330,12 +1330,7 @@ async function Pe(t, r, s) {
1330
1330
  return {
1331
1331
  error: "Session ID is required"
1332
1332
  };
1333
- const f = V(s.sessionId);
1334
- if (f.fsSnapshotQueries.has(e))
1335
- return {
1336
- error: `Filesystem snapshot query "${e}" already exists`
1337
- };
1338
- const d = T.resolve(r.workingDir || "", o.rootDir || "").replace(/\\/g, "/");
1333
+ const f = V(s.sessionId), d = T.resolve(r.workingDir || "", o.rootDir || "").replace(/\\/g, "/");
1339
1334
  try {
1340
1335
  try {
1341
1336
  await B.promises.access(d, B.constants.F_OK);
@@ -1354,9 +1349,9 @@ async function Pe(t, r, s) {
1354
1349
  exclude: !1
1355
1350
  })) : [{ value: "**", valueType: "pattern", exclude: !1 }], p = r.globsExclude || [], y = [...g, ...p];
1356
1351
  let w = null, S = null;
1357
- if (i || u)
1352
+ if (a || u)
1358
1353
  try {
1359
- const x = Date.now(), $ = u ? x - we(u) : null, v = i ? x - we(i) : null;
1354
+ const x = Date.now(), $ = u ? x - we(u) : null, v = a ? x - we(a) : null;
1360
1355
  w = [$, v];
1361
1356
  } catch (x) {
1362
1357
  return {
@@ -1372,7 +1367,7 @@ async function Pe(t, r, s) {
1372
1367
  error: x instanceof Error ? x.message : "Unknown error parsing size filter"
1373
1368
  };
1374
1369
  }
1375
- const M = a ? a.includes("file") : !0, I = a ? a.includes("dir") : !0, b = {
1370
+ const M = i ? i.includes("file") : !0, I = i ? i.includes("dir") : !0, b = {
1376
1371
  name: e,
1377
1372
  rootDir: d,
1378
1373
  globs: y,
@@ -1414,29 +1409,29 @@ function j(t) {
1414
1409
  "Impossible behavior: root node (id: null) not found in idToNode"
1415
1410
  );
1416
1411
  const e = /* @__PURE__ */ new Map();
1417
- return r.forEach((n, a) => {
1412
+ return r.forEach((n, i) => {
1418
1413
  if (n != null) {
1419
1414
  if (e.has(n)) {
1420
- const i = e.get(n);
1415
+ const a = e.get(n);
1421
1416
  throw new Error(
1422
- `Impossible behavior: node appears with multiple IDs (existing: ${i}, new: ${a})`
1417
+ `Impossible behavior: node appears with multiple IDs (existing: ${a}, new: ${i})`
1423
1418
  );
1424
1419
  }
1425
- e.set(n, a);
1420
+ e.set(n, i);
1426
1421
  }
1427
1422
  }), {
1428
1423
  root: o,
1429
1424
  getNode: (n) => r.get(n) ?? null,
1430
1425
  getId: (n) => e.get(n) ?? null,
1431
1426
  getChilds: (n) => {
1432
- let a = e.get(n);
1433
- if (a == null)
1427
+ let i = e.get(n);
1428
+ if (i == null)
1434
1429
  if (n === r.get(null))
1435
- a = null;
1430
+ i = null;
1436
1431
  else
1437
1432
  throw new Error("Impossible behavior: node not found in idToNode");
1438
- const i = s.get(a);
1439
- return i == null ? null : i.map((u) => {
1433
+ const a = s.get(i);
1434
+ return a == null ? null : a.map((u) => {
1440
1435
  const c = r.get(u);
1441
1436
  if (c == null)
1442
1437
  throw new Error(
@@ -1450,35 +1445,35 @@ function j(t) {
1450
1445
  function ze(t, r, s) {
1451
1446
  let o = null;
1452
1447
  for (let e = 0, n = r.length; e < n; e++) {
1453
- const a = r[e], i = t(a), u = i == null ? null : ze(t, i, s), c = s(a, u);
1448
+ const i = r[e], a = t(i), u = a == null ? null : ze(t, a, s), c = s(i, u);
1454
1449
  c != null && (o == null && (o = []), o.push(c));
1455
1450
  }
1456
1451
  return o;
1457
1452
  }
1458
1453
  function Le(t) {
1459
- const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), u = ze(
1454
+ const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = ze(
1460
1455
  s,
1461
1456
  o,
1462
1457
  (l, f) => {
1463
1458
  const d = e(l, f);
1464
1459
  if (l != null && d != null) {
1465
1460
  const m = r(l);
1466
- n.set(m, d), a.set(d, m);
1461
+ n.set(m, d), i.set(d, m);
1467
1462
  }
1468
- return d != null && f != null && i.set(
1469
- a.get(d),
1470
- f.map((m) => a.get(m))
1463
+ return d != null && f != null && a.set(
1464
+ i.get(d),
1465
+ f.map((m) => i.get(m))
1471
1466
  ), d;
1472
1467
  }
1473
1468
  ), c = e(null, u);
1474
1469
  if (c == null)
1475
1470
  throw new Error("Impossible behavior: rootNode == null");
1476
- return n.set(null, c), u != null && i.set(
1471
+ return n.set(null, c), u != null && a.set(
1477
1472
  null,
1478
- u.map((l) => a.get(l))
1473
+ u.map((l) => i.get(l))
1479
1474
  ), {
1480
1475
  idToNode: n,
1481
- idToChildIds: i
1476
+ idToChildIds: a
1482
1477
  };
1483
1478
  }
1484
1479
  function W(t) {
@@ -1494,7 +1489,7 @@ async function sr(t) {
1494
1489
  size: 0
1495
1490
  };
1496
1491
  r.set(null, n);
1497
- const a = await Be({
1492
+ const i = await Be({
1498
1493
  rootDir: o,
1499
1494
  globs: t.globs
1500
1495
  });
@@ -1502,12 +1497,12 @@ async function sr(t) {
1502
1497
  paths: [o],
1503
1498
  walkLinks: !0,
1504
1499
  matchPath: Oe({
1505
- globs: a,
1500
+ globs: i,
1506
1501
  rootDir: o,
1507
1502
  noCase: !0
1508
1503
  }),
1509
- handlePath: async ({ path: i, stat: u, itemStat: c }) => {
1510
- const l = T.relative(o, i), f = u.isDirectory(), d = u.isFile();
1504
+ handlePath: async ({ path: a, stat: u, itemStat: c }) => {
1505
+ const l = T.relative(o, a), f = u.isDirectory(), d = u.isFile();
1511
1506
  if (!f && !d)
1512
1507
  return !0;
1513
1508
  const m = W(l || "."), g = f ? "dir" : "file", p = f ? null : u.mtimeMs, y = u.size;
@@ -1526,7 +1521,7 @@ async function sr(t) {
1526
1521
  return !1;
1527
1522
  const S = {
1528
1523
  path: m ?? ".",
1529
- name: T.basename(i),
1524
+ name: T.basename(a),
1530
1525
  type: g,
1531
1526
  dateModified: p,
1532
1527
  size: y,
@@ -1575,21 +1570,21 @@ function Se(t, r = or) {
1575
1570
  return s;
1576
1571
  let e = 0, n = 0;
1577
1572
  for (; n < s; ) {
1578
- const a = t.charCodeAt(n);
1579
- let i = !1;
1573
+ const i = t.charCodeAt(n);
1574
+ let a = !1;
1580
1575
  for (let u = 0; u < o; u++) {
1581
1576
  const c = r[u];
1582
- if (c.match(a)) {
1577
+ if (c.match(i)) {
1583
1578
  let l = 1;
1584
1579
  for (; ++n < s && c.match(t.charCodeAt(n)) && l < c.max; )
1585
1580
  l++;
1586
1581
  if (l >= c.min) {
1587
- e++, i = !0;
1582
+ e++, a = !0;
1588
1583
  break;
1589
1584
  }
1590
1585
  }
1591
1586
  }
1592
- i || (n++, e++);
1587
+ a || (n++, e++);
1593
1588
  }
1594
1589
  return e;
1595
1590
  }
@@ -1608,8 +1603,8 @@ function nr(t) {
1608
1603
  function ir(t) {
1609
1604
  const s = Date.now() - t;
1610
1605
  if (s < 0) return "0s";
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), u = Math.floor(a / 30), c = Math.floor(a / 365);
1612
- return c > 0 ? `${c}Y` : u > 0 ? `${u}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1606
+ 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), u = Math.floor(i / 30), c = Math.floor(i / 365);
1607
+ return c > 0 ? `${c}Y` : u > 0 ? `${u}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1613
1608
  }
1614
1609
  function ar(t) {
1615
1610
  return function(s, o) {
@@ -1619,23 +1614,23 @@ function ar(t) {
1619
1614
  if (e.type === "file")
1620
1615
  return e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
1621
1616
  {
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;
1617
+ const i = e.countFiles || 0, a = n.countFiles || 0;
1618
+ return i < a ? -1 : i > a ? 1 : e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
1624
1619
  }
1625
1620
  };
1626
1621
  }
1627
1622
  function cr(t) {
1628
1623
  const r = t.fields ?? [];
1629
1624
  return function(o, e) {
1630
- let n = "", a, i = 0;
1625
+ let n = "", i, a = 0;
1631
1626
  const u = e ? e.length : 0;
1632
1627
  let c = 1, l, f = 0, d = 0, m = 0, g = 0, p = null, y, w, S;
1633
1628
  if (e)
1634
1629
  for (let I = 0; I < e.length; I++) {
1635
1630
  const b = e[I];
1636
- i += b.countMatched, c += b.countTotal, f += b.tokens, d += b.tokensTotal, m += b.size, g += b.countFiles, b.dateModified != null && (p == null || b.dateModified > p) && (p = b.dateModified);
1631
+ a += b.countMatched, c += b.countTotal, f += b.tokens, d += b.tokensTotal, m += b.size, g += b.countFiles, b.dateModified != null && (p == null || b.dateModified > p) && (p = b.dateModified);
1637
1632
  }
1638
- o ? (y = o.type, w = o.name, S = o.path, a = o.isMatched, a && (i += 1), o.type === "file" ? (m = o.size || 0, g = 1, p = o.dateModified || null) : o.dateModified != null && (p == null || o.dateModified > p) && (p = o.dateModified)) : (y = "dir", w = "<root>", S = ".", a = !0);
1633
+ o ? (y = o.type, w = o.name, S = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (m = o.size || 0, g = 1, p = o.dateModified || null) : o.dateModified != null && (p == null || o.dateModified > p) && (p = o.dateModified)) : (y = "dir", w = "<root>", S = ".", i = !0);
1639
1634
  for (let I = 0, b = r.length; I < b; I++) {
1640
1635
  const x = r[I];
1641
1636
  switch (I > 0 && (n += " "), x) {
@@ -1652,7 +1647,7 @@ function cr(t) {
1652
1647
  n += y === "dir" ? `${w}/` : w;
1653
1648
  break;
1654
1649
  case "countMatched":
1655
- n += i.toString();
1650
+ n += a.toString();
1656
1651
  break;
1657
1652
  }
1658
1653
  }
@@ -1665,8 +1660,8 @@ function cr(t) {
1665
1660
  type: y,
1666
1661
  name: w,
1667
1662
  path: S,
1668
- isMatched: a,
1669
- countMatched: i,
1663
+ isMatched: i,
1664
+ countMatched: a,
1670
1665
  countChilds: u,
1671
1666
  countTotal: c,
1672
1667
  tokens: l,
@@ -1681,20 +1676,20 @@ function cr(t) {
1681
1676
  }
1682
1677
  async function lr(t) {
1683
1678
  const r = await sr(t), s = j(r), o = s.getChilds(s.root), e = Le({
1684
- getId: (a) => {
1685
- const i = s.getId(a);
1686
- if (i == null)
1679
+ getId: (i) => {
1680
+ const a = s.getId(i);
1681
+ if (a == null)
1687
1682
  throw new Error(
1688
- `Invalid tree structure: node ID is null for node ${JSON.stringify(a)}`
1683
+ `Invalid tree structure: node ID is null for node ${JSON.stringify(i)}`
1689
1684
  );
1690
- return i;
1685
+ return a;
1691
1686
  },
1692
- getChilds: (a) => s.getChilds(a),
1687
+ getChilds: (i) => s.getChilds(i),
1693
1688
  createSnapshotNode: cr(t),
1694
1689
  rootNodes: o ?? []
1695
1690
  }), n = ar(e.idToNode);
1696
- return e.idToChildIds.forEach((a) => {
1697
- a.sort(n);
1691
+ return e.idToChildIds.forEach((i) => {
1692
+ i.sort(n);
1698
1693
  }), j(e);
1699
1694
  }
1700
1695
  const X = h.object({
@@ -1715,31 +1710,27 @@ async function Ae(t, r, s) {
1715
1710
  error: C(l)
1716
1711
  };
1717
1712
  }
1718
- const { name: e, queryName: n, query: a } = o;
1713
+ const { name: e, queryName: n, query: i } = o;
1719
1714
  if (!s.sessionId)
1720
1715
  return {
1721
1716
  error: "Session ID is required"
1722
1717
  };
1723
- const i = V(s.sessionId);
1724
- if (i.fsSnapshots.has(e))
1725
- return {
1726
- error: `Filesystem snapshot "${e}" already exists`
1727
- };
1728
- if (n && a)
1718
+ const a = V(s.sessionId);
1719
+ if (n && i)
1729
1720
  return {
1730
1721
  error: "Either queryName or query must be provided, not both"
1731
1722
  };
1732
1723
  let u, c = !1;
1733
1724
  if (n) {
1734
- const l = i.fsSnapshotQueries.get(n);
1725
+ const l = a.fsSnapshotQueries.get(n);
1735
1726
  if (!l)
1736
1727
  return {
1737
1728
  error: `Filesystem snapshot query "${n}" not found`
1738
1729
  };
1739
1730
  u = l;
1740
- } else if (a) {
1731
+ } else if (i) {
1741
1732
  const l = await Pe(
1742
- a,
1733
+ i,
1743
1734
  r,
1744
1735
  s
1745
1736
  );
@@ -1758,7 +1749,7 @@ async function Ae(t, r, s) {
1758
1749
  query: u,
1759
1750
  tree: l
1760
1751
  };
1761
- return i.fsSnapshots.set(e, f), {
1752
+ return a.fsSnapshots.set(e, f), {
1762
1753
  fsSnapshot: f,
1763
1754
  queryCreated: c
1764
1755
  };
@@ -1814,8 +1805,8 @@ class dr {
1814
1805
  function fr(t) {
1815
1806
  const r = new dr(), {
1816
1807
  tree: s,
1817
- limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: a },
1818
- indexRangeGroupStrategy: i
1808
+ limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
1809
+ indexRangeGroupStrategy: a
1819
1810
  } = t, u = s.getChilds(s.root);
1820
1811
  u != null && u.length > 0 && r.enqueue({
1821
1812
  reportNode: null,
@@ -1831,18 +1822,18 @@ function fr(t) {
1831
1822
  let p = r.size();
1832
1823
  for (let w = 0; w < g.length; w++)
1833
1824
  g[w].countChilds > 0 && (p += 1);
1834
- const y = p * i.tokens;
1825
+ const y = p * a.tokens;
1835
1826
  if (o != null && l + m.countChilds + p > o || e != null && f + m.tokensChilds + y > e) {
1836
1827
  const w = [];
1837
1828
  let S = null, M = 0;
1838
1829
  for (let b = 0, x = g.length; b < x; b++) {
1839
- const $ = g[b], v = M * i.tokens;
1830
+ const $ = g[b], v = M * a.tokens;
1840
1831
  S != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
1841
- !(o != null && l + 1 > o || e != null && f + i.tokens > e) && (n != null && S.countGrouped + 1 + M > n || a != null && S.tokensGrouped + $.tokens + v > a) && (w.push(S), l += 1, f += i.tokens, S = null, M = 0), S = i.add(S, $, b), $.countChilds > 0 && (M += 1);
1832
+ !(o != null && l + 1 > o || e != null && f + a.tokens > e) && (n != null && S.countGrouped + 1 + M > n || i != null && S.tokensGrouped + $.tokens + v > i) && (w.push(S), l += 1, f += a.tokens, S = null, M = 0), S = a.add(S, $, b), $.countChilds > 0 && (M += 1);
1842
1833
  }
1843
- S != null && (w.push(S), l += 1, f += i.tokens);
1834
+ S != null && (w.push(S), l += 1, f += a.tokens);
1844
1835
  const I = w.map((b) => ({
1845
- text: i.getReportText(b)
1836
+ text: a.getReportText(b)
1846
1837
  }));
1847
1838
  if (d != null) {
1848
1839
  if (d.childs != null)
@@ -1880,22 +1871,22 @@ function fr(t) {
1880
1871
  }
1881
1872
  return c ?? [];
1882
1873
  }
1883
- function qe(t) {
1874
+ function Ge(t) {
1884
1875
  const {
1885
1876
  tree: r,
1886
1877
  request: { parentNodeId: s, childsIndexRange: o, limits: e },
1887
1878
  indexRangeGroupStrategy: n,
1888
- ...a
1879
+ ...i
1889
1880
  } = t;
1890
- let i;
1881
+ let a;
1891
1882
  if (s != null) {
1892
1883
  const d = r.getNode(s);
1893
1884
  if (d == null)
1894
1885
  throw new Error(`Parent node "${s}" not found`);
1895
- i = d;
1886
+ a = d;
1896
1887
  } else
1897
- i = r.root;
1898
- let u, c = r.getChilds(i) ?? [];
1888
+ a = r.root;
1889
+ let u, c = r.getChilds(a) ?? [];
1899
1890
  if (o != null) {
1900
1891
  const [d, m] = o;
1901
1892
  if (d < 0 || m <= d || m >= c.length)
@@ -1909,13 +1900,13 @@ function qe(t) {
1909
1900
  g.push(w), p = n.add(p, w, y);
1910
1901
  }
1911
1902
  c = g, u = {
1912
- ...i,
1903
+ ...a,
1913
1904
  text: n.getReportText(p),
1914
1905
  countChilds: p.countGrouped,
1915
1906
  tokensChilds: p.tokensGrouped
1916
1907
  };
1917
1908
  } else
1918
- u = i;
1909
+ u = a;
1919
1910
  const l = {
1920
1911
  countChilds: 1,
1921
1912
  tokensChilds: u.tokens
@@ -1928,16 +1919,16 @@ function qe(t) {
1928
1919
  tree: f,
1929
1920
  limits: e,
1930
1921
  indexRangeGroupStrategy: n,
1931
- ...a
1922
+ ...i
1932
1923
  });
1933
1924
  }
1934
- function Ge(t, r) {
1925
+ function qe(t, r) {
1935
1926
  if (t == null || t.length === 0)
1936
1927
  return "No results found";
1937
1928
  let s = "";
1938
1929
  function o(e, n) {
1939
- for (let a = 0, i = e.length; a < i; a++) {
1940
- const u = e[a];
1930
+ for (let i = 0, a = e.length; i < a; i++) {
1931
+ const u = e[i];
1941
1932
  s += n, s += u.text.textOpen + `
1942
1933
  `, u.childs != null && u.childs.length > 0 && o(
1943
1934
  u.childs,
@@ -1997,12 +1988,12 @@ async function hr(t, r, s) {
1997
1988
  const {
1998
1989
  snapshotName: e,
1999
1990
  snapshot: n,
2000
- childsIndexRange: a
1991
+ childsIndexRange: i
2001
1992
  // maxCountTotal,
2002
1993
  // maxTokensTotal,
2003
1994
  // maxCountGroup,
2004
1995
  // maxTokensGroup,
2005
- } = o, i = 60, u = 1e3, c = 25, l = 900;
1996
+ } = o, a = 60, u = 1e3, c = 25, l = 900;
2006
1997
  if (!s.sessionId)
2007
1998
  return {
2008
1999
  error: "Session ID is required"
@@ -2034,26 +2025,26 @@ async function hr(t, r, s) {
2034
2025
  error: "Either snapshotName or snapshot must be provided"
2035
2026
  };
2036
2027
  try {
2037
- const p = W(o.parentPath), y = qe({
2028
+ const p = W(o.parentPath), y = Ge({
2038
2029
  tree: d.tree,
2039
2030
  request: {
2040
2031
  parentNodeId: p,
2041
- childsIndexRange: a,
2032
+ childsIndexRange: i,
2042
2033
  limits: {
2043
- maxCountTotal: i,
2034
+ maxCountTotal: a,
2044
2035
  maxTokensTotal: u,
2045
2036
  maxCountGroup: c,
2046
2037
  maxTokensGroup: l
2047
2038
  }
2048
2039
  },
2049
2040
  indexRangeGroupStrategy: new mr()
2050
- }), w = Ge(y);
2041
+ }), w = qe(y);
2051
2042
  return {
2052
2043
  fsSnapshot: d,
2053
2044
  queryCreated: m,
2054
2045
  snapshotCreated: g,
2055
2046
  parentPath: p,
2056
- childsIndexRange: a,
2047
+ childsIndexRange: i,
2057
2048
  report: w
2058
2049
  };
2059
2050
  } catch (p) {
@@ -2082,10 +2073,10 @@ function pr(t, r) {
2082
2073
  `), n += `✅ Browsing filesystem snapshot "${e.fsSnapshot.name}":
2083
2074
  `, n += `Root directory (<root>/): ${e.fsSnapshot.query.rootDir || "./"}
2084
2075
  `, n += `Parent path: ${"./" + (e.parentPath ?? "")}
2085
- `, n += `Fields: ${e.fsSnapshot.query.fields.map((a) => a === "dateModified" ? "lastModified" : a).join(" ")}
2076
+ `, n += `Fields: ${e.fsSnapshot.query.fields.map((i) => i === "dateModified" ? "lastModified" : i).join(" ")}
2086
2077
  `, e.childsIndexRange) {
2087
- const [a, i] = e.childsIndexRange, c = (e.parentPath ? e.fsSnapshot.tree.getNode(e.parentPath) : e.fsSnapshot.tree.root).countChilds;
2088
- n += ` Showing indexes: ${a}-${i} of ${c}
2078
+ const [i, a] = e.childsIndexRange, c = (e.parentPath ? e.fsSnapshot.tree.getNode(e.parentPath) : e.fsSnapshot.tree.root).countChilds;
2079
+ n += ` Showing indexes: ${i}-${a} of ${c}
2089
2080
  `;
2090
2081
  }
2091
2082
  return n += `
@@ -2119,40 +2110,36 @@ async function _e(t, r, s) {
2119
2110
  let o;
2120
2111
  try {
2121
2112
  o = ee.parse(t);
2122
- } catch (l) {
2113
+ } catch (c) {
2123
2114
  return {
2124
- error: C(l)
2115
+ error: C(c)
2125
2116
  };
2126
2117
  }
2127
- const { name: e, browserType: n, muteAudio: a, devTools: i } = o;
2118
+ const { name: e, browserType: n, muteAudio: i, devTools: a } = o;
2128
2119
  if (!s.sessionId)
2129
2120
  return {
2130
2121
  error: "Session ID is required"
2131
2122
  };
2132
- const u = D(s.sessionId), c = u.browsers.get(e);
2133
- if (c)
2134
- return {
2135
- error: `Browser "${c.name}" (${c.browserType}) already exists`
2136
- };
2123
+ const u = D(s.sessionId);
2137
2124
  try {
2138
- const f = await {
2125
+ const l = await {
2139
2126
  chromium: gt,
2140
2127
  firefox: pt,
2141
2128
  webkit: ht
2142
2129
  }[n].launch({
2143
2130
  headless: !1,
2144
- devtools: i,
2145
- args: a ? ["--mute-audio"] : void 0
2146
- }), d = {
2131
+ devtools: a,
2132
+ args: i ? ["--mute-audio"] : void 0
2133
+ }), f = {
2147
2134
  name: e,
2148
2135
  browserType: n,
2149
- browser: f,
2136
+ browser: l,
2150
2137
  contexts: /* @__PURE__ */ new Map()
2151
2138
  };
2152
- return u.browsers.set(e, d), { browserInfo: d };
2153
- } catch (l) {
2139
+ return u.browsers.set(e, f), { browserInfo: f };
2140
+ } catch (c) {
2154
2141
  return {
2155
- error: `Failed to create browser: ${l instanceof Error ? l.message : "Unknown error"}`
2142
+ error: `Failed to create browser: ${c instanceof Error ? c.message : "Unknown error"}`
2156
2143
  };
2157
2144
  }
2158
2145
  }
@@ -2176,9 +2163,9 @@ async function yr(t, r, s) {
2176
2163
  let o;
2177
2164
  try {
2178
2165
  o = Je.parse(t);
2179
- } catch (a) {
2166
+ } catch (i) {
2180
2167
  return {
2181
- error: C(a)
2168
+ error: C(i)
2182
2169
  };
2183
2170
  }
2184
2171
  if (!s.sessionId)
@@ -2204,7 +2191,7 @@ function br(t, r) {
2204
2191
  return `Method: playwright-browser-list(${JSON.stringify(s)})
2205
2192
  ❌ Error: ${e.error}`;
2206
2193
  const n = e.browserInfos.map(
2207
- (a) => `${a.name} (${a.browserType})`
2194
+ (i) => `${i.name} (${i.browserType})`
2208
2195
  );
2209
2196
  return `Method: playwright-browser-list(${JSON.stringify(s)})
2210
2197
  ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
@@ -2230,24 +2217,24 @@ async function Sr(t, r, s) {
2230
2217
  return {
2231
2218
  error: "Session ID is required"
2232
2219
  };
2233
- const n = D(s.sessionId), a = [], i = [];
2220
+ const n = D(s.sessionId), i = [], a = [];
2234
2221
  let u = [];
2235
2222
  return e ? e.forEach((c) => {
2236
2223
  const l = n.browsers.get(c);
2237
- l ? u.push(l) : i.push(`Browser "${c}" not found`);
2224
+ l ? u.push(l) : a.push(`Browser "${c}" not found`);
2238
2225
  }) : u = Array.from(n.browsers.values()), await Promise.all(
2239
2226
  u.map(async (c) => {
2240
2227
  try {
2241
- await c.browser.close(), n.browsers.delete(c.name), a.push(c);
2228
+ await c.browser.close(), n.browsers.delete(c.name), i.push(c);
2242
2229
  } catch (l) {
2243
- i.push(
2230
+ a.push(
2244
2231
  `Failed to close browser "${c.name}" (${c.browserType}): ${l instanceof Error ? l.message : "Unknown error"}`
2245
2232
  );
2246
2233
  }
2247
2234
  })
2248
2235
  ), {
2249
- closedBrowserInfos: a,
2250
- ...i.length > 0 && { errors: i }
2236
+ closedBrowserInfos: i,
2237
+ ...a.length > 0 && { errors: a }
2251
2238
  };
2252
2239
  }
2253
2240
  function xr(t, r) {
@@ -2265,12 +2252,12 @@ function xr(t, r) {
2265
2252
  ❌ Error: ${e.error}`;
2266
2253
  const n = [];
2267
2254
  if (e.closedBrowserInfos.length > 0) {
2268
- const a = e.closedBrowserInfos.map(
2269
- (i) => `${i.name} (${i.browserType})`
2255
+ const i = e.closedBrowserInfos.map(
2256
+ (a) => `${a.name} (${a.browserType})`
2270
2257
  );
2271
- n.push(`✅ Closed browsers: ${a.join(", ")}`);
2258
+ n.push(`✅ Closed browsers: ${i.join(", ")}`);
2272
2259
  }
2273
- 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)})
2260
+ 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)})
2274
2261
  ${n.join(`
2275
2262
  `)}`;
2276
2263
  }
@@ -2300,13 +2287,13 @@ async function We(t, r, s) {
2300
2287
  error: C(m)
2301
2288
  };
2302
2289
  }
2303
- const { name: e, browserName: n, browser: a, isMobile: i, hasTouch: u, viewport: c } = o;
2290
+ const { name: e, browserName: n, browser: i, isMobile: a, hasTouch: u, viewport: c } = o;
2304
2291
  if (!s.sessionId)
2305
2292
  return {
2306
2293
  error: "Session ID is required"
2307
2294
  };
2308
2295
  const l = D(s.sessionId);
2309
- if (n && a)
2296
+ if (n && i)
2310
2297
  return {
2311
2298
  error: "Either browserName or browser must be provided, not both"
2312
2299
  };
@@ -2316,8 +2303,8 @@ async function We(t, r, s) {
2316
2303
  return {
2317
2304
  error: `Browser "${n}" not found`
2318
2305
  };
2319
- } else if (a) {
2320
- const m = await _e(a, r, s);
2306
+ } else if (i) {
2307
+ const m = await _e(i, r, s);
2321
2308
  if (m.error != null)
2322
2309
  return {
2323
2310
  error: m.error
@@ -2327,13 +2314,9 @@ async function We(t, r, s) {
2327
2314
  return {
2328
2315
  error: "Either browserName or browser must be provided"
2329
2316
  };
2330
- if (d.contexts.has(e))
2331
- return {
2332
- error: `Context "${e}" already exists in browser "${d.name}" (${d.browserType})`
2333
- };
2334
2317
  try {
2335
2318
  const m = await d.browser.newContext({
2336
- isMobile: i,
2319
+ isMobile: a,
2337
2320
  hasTouch: u,
2338
2321
  viewport: c
2339
2322
  }), g = {
@@ -2382,9 +2365,9 @@ async function Ir(t, r, s) {
2382
2365
  let o;
2383
2366
  try {
2384
2367
  o = Qe.parse(t);
2385
- } catch (i) {
2368
+ } catch (a) {
2386
2369
  return {
2387
- error: C(i)
2370
+ error: C(a)
2388
2371
  };
2389
2372
  }
2390
2373
  const { browserName: e } = o;
@@ -2392,27 +2375,27 @@ async function Ir(t, r, s) {
2392
2375
  return {
2393
2376
  error: "Session ID is required"
2394
2377
  };
2395
- const n = D(s.sessionId), a = [];
2378
+ const n = D(s.sessionId), i = [];
2396
2379
  if (e) {
2397
- const i = n.browsers.get(e);
2398
- if (!i)
2380
+ const a = n.browsers.get(e);
2381
+ if (!a)
2399
2382
  return {
2400
2383
  error: `Browser "${e}" not found`
2401
2384
  };
2402
- Array.from(i.contexts.values()).length > 0 && a.push({
2403
- browserInfo: i,
2404
- contexts: Array.from(i.contexts.values())
2385
+ Array.from(a.contexts.values()).length > 0 && i.push({
2386
+ browserInfo: a,
2387
+ contexts: Array.from(a.contexts.values())
2405
2388
  });
2406
2389
  } else
2407
- for (const i of n.browsers.values()) {
2408
- const u = Array.from(i.contexts.values());
2409
- u.length > 0 && a.push({
2410
- browserInfo: i,
2390
+ for (const a of n.browsers.values()) {
2391
+ const u = Array.from(a.contexts.values());
2392
+ u.length > 0 && i.push({
2393
+ browserInfo: a,
2411
2394
  contexts: u
2412
2395
  });
2413
2396
  }
2414
2397
  return {
2415
- contextsByBrowser: a
2398
+ contextsByBrowser: i
2416
2399
  };
2417
2400
  }
2418
2401
  function Mr(t, r) {
@@ -2431,7 +2414,7 @@ function Mr(t, r) {
2431
2414
  let n = `Method: playwright-context-list(${JSON.stringify(s)})
2432
2415
  `;
2433
2416
  return e.contextsByBrowser.length === 0 ? n += "No contexts found" : n += e.contextsByBrowser.map(
2434
- ({ browserInfo: a, contexts: i }) => `${a.name} (${a.browserType}): ${i.map((u) => u.name).join(", ")}`
2417
+ ({ browserInfo: i, contexts: a }) => `${i.name} (${i.browserType}): ${a.map((u) => u.name).join(", ")}`
2435
2418
  ).join(`
2436
2419
  `), n;
2437
2420
  }
@@ -2459,10 +2442,10 @@ async function Tr(t, r, s) {
2459
2442
  return {
2460
2443
  error: "Session ID is required"
2461
2444
  };
2462
- const a = D(s.sessionId), i = [], u = [];
2445
+ const i = D(s.sessionId), a = [], u = [];
2463
2446
  let c = [];
2464
2447
  if (n) {
2465
- const l = a.browsers.get(n);
2448
+ const l = i.browsers.get(n);
2466
2449
  if (!l)
2467
2450
  return {
2468
2451
  error: `Browser "${n}" not found`
@@ -2474,7 +2457,7 @@ async function Tr(t, r, s) {
2474
2457
  );
2475
2458
  }) : c = Array.from(l.contexts.values());
2476
2459
  } else if (e)
2477
- for (const l of a.browsers.values())
2460
+ for (const l of i.browsers.values())
2478
2461
  e.forEach((f) => {
2479
2462
  const d = l.contexts.get(f);
2480
2463
  d ? c.push(d) : u.push(
@@ -2482,12 +2465,12 @@ async function Tr(t, r, s) {
2482
2465
  );
2483
2466
  });
2484
2467
  else
2485
- for (const l of a.browsers.values())
2468
+ for (const l of i.browsers.values())
2486
2469
  c.push(...Array.from(l.contexts.values()));
2487
2470
  return await Promise.all(
2488
2471
  c.map(async (l) => {
2489
2472
  try {
2490
- await l.context.close(), l.browserInfo.contexts.delete(l.name), i.push(l);
2473
+ await l.context.close(), l.browserInfo.contexts.delete(l.name), a.push(l);
2491
2474
  } catch (f) {
2492
2475
  u.push(
2493
2476
  `Failed to close context "${l.name}" (${l.browserInfo.name}) (${l.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
@@ -2495,7 +2478,7 @@ async function Tr(t, r, s) {
2495
2478
  }
2496
2479
  })
2497
2480
  ), {
2498
- closedContextInfos: i,
2481
+ closedContextInfos: a,
2499
2482
  ...u.length > 0 && { errors: u }
2500
2483
  };
2501
2484
  }
@@ -2514,12 +2497,12 @@ function vr(t, r) {
2514
2497
  ❌ Error: ${e.error}`;
2515
2498
  const n = [];
2516
2499
  if (e.closedContextInfos.length > 0) {
2517
- const a = e.closedContextInfos.map(
2518
- (i) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType})`
2500
+ const i = e.closedContextInfos.map(
2501
+ (a) => `${a.name} (${a.browserInfo.name}) (${a.browserInfo.browserType})`
2519
2502
  );
2520
- n.push(`✅ Closed contexts: ${a.join(", ")}`);
2503
+ n.push(`✅ Closed contexts: ${i.join(", ")}`);
2521
2504
  }
2522
- 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)})
2505
+ 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)})
2523
2506
  ${n.join(`
2524
2507
  `)}`;
2525
2508
  }
@@ -2548,16 +2531,16 @@ function Cr() {
2548
2531
  return l ?? (this.idToObject.delete(u), null);
2549
2532
  }
2550
2533
  }
2551
- function r(i, u, c) {
2534
+ function r(a, u, c) {
2552
2535
  let l = null;
2553
2536
  for (let f = 0, d = u.length; f < d; f++) {
2554
- const m = u[f], g = i(m), p = g == null ? null : r(i, g, c), y = c(m, p);
2537
+ const m = u[f], g = a(m), p = g == null ? null : r(a, g, c), y = c(m, p);
2555
2538
  y != null && (l == null && (l = []), l.push(y));
2556
2539
  }
2557
2540
  return l;
2558
2541
  }
2559
- function s(i) {
2560
- const { getId: u, getChilds: c, rootNodes: l, createSnapshotNode: f } = i, d = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = r(
2542
+ function s(a) {
2543
+ const { getId: u, getChilds: c, rootNodes: l, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = r(
2561
2544
  c,
2562
2545
  l,
2563
2546
  (w, S) => {
@@ -2582,13 +2565,13 @@ function Cr() {
2582
2565
  idToChildIds: g
2583
2566
  };
2584
2567
  }
2585
- const o = (i) => i instanceof HTMLElement ? i.childNodes : null;
2586
- function e(i) {
2568
+ const o = (a) => a instanceof HTMLElement ? a.childNodes : null;
2569
+ function e(a) {
2587
2570
  return function(c, l) {
2588
2571
  const f = l != null && l.length > 0;
2589
2572
  let d = !1, m = null, g = null;
2590
2573
  if (c instanceof HTMLElement) {
2591
- if (m = n.getOrCreateId(c), g = c.tagName.toLowerCase(), d = c.matches(i.cssSelector), !d && !f)
2574
+ if (m = n.getOrCreateId(c), g = c.tagName.toLowerCase(), d = c.matches(a.cssSelector), !d && !f)
2592
2575
  return null;
2593
2576
  } else if (c == null)
2594
2577
  m = null, g = null, d = !1;
@@ -2602,8 +2585,8 @@ function Cr() {
2602
2585
  };
2603
2586
  }
2604
2587
  const n = new t();
2605
- function a(i) {
2606
- const u = e(i);
2588
+ function i(a) {
2589
+ const u = e(a);
2607
2590
  return s({
2608
2591
  getId: (c) => n.getOrCreateId(c),
2609
2592
  getChilds: o,
@@ -2611,7 +2594,7 @@ function Cr() {
2611
2594
  rootNodes: [window.document.documentElement]
2612
2595
  });
2613
2596
  }
2614
- window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = a;
2597
+ window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
2615
2598
  }
2616
2599
  const kr = `(function (){function __name(fn){return fn};${Cr.toString()}; setupPageGlobals();})()`, re = h.object({
2617
2600
  contextName: h.string().optional().describe("Name of previously created context, to use"),
@@ -2631,19 +2614,19 @@ async function Ye(t, r, s) {
2631
2614
  error: C(f)
2632
2615
  };
2633
2616
  }
2634
- const { name: e, contextName: n, context: a } = o;
2617
+ const { name: e, contextName: n, context: i } = o;
2635
2618
  if (!s.sessionId)
2636
2619
  return {
2637
2620
  error: "Session ID is required"
2638
2621
  };
2639
- const i = D(s.sessionId);
2640
- if (n && a)
2622
+ const a = D(s.sessionId);
2623
+ if (n && i)
2641
2624
  return {
2642
2625
  error: "Either contextName or context must be provided, not both"
2643
2626
  };
2644
2627
  let u = !1, c = !1, l;
2645
2628
  if (n) {
2646
- for (const f of i.browsers.values())
2629
+ for (const f of a.browsers.values())
2647
2630
  if (f.contexts.has(n)) {
2648
2631
  l = f.contexts.get(n);
2649
2632
  break;
@@ -2652,8 +2635,8 @@ async function Ye(t, r, s) {
2652
2635
  return {
2653
2636
  error: `Context "${n}" not found`
2654
2637
  };
2655
- } else if (a) {
2656
- const f = await We(a, r, s);
2638
+ } else if (i) {
2639
+ const f = await We(i, r, s);
2657
2640
  if (f.error != null)
2658
2641
  return {
2659
2642
  error: f.error
@@ -2663,10 +2646,6 @@ async function Ye(t, r, s) {
2663
2646
  return {
2664
2647
  error: "Either contextName or context must be provided"
2665
2648
  };
2666
- if (l.pages.has(e))
2667
- return {
2668
- error: `Page "${e}" already exists in context "${l.name}" in browser "${l.browserInfo.name}" (${l.browserInfo.browserType})`
2669
- };
2670
2649
  try {
2671
2650
  const f = await l.context.newPage();
2672
2651
  await f.addInitScript(kr), await f.goto("about:blank");
@@ -2730,9 +2709,9 @@ async function Er(t, r, s) {
2730
2709
  return {
2731
2710
  error: "Session ID is required"
2732
2711
  };
2733
- const a = D(s.sessionId), i = [];
2712
+ const i = D(s.sessionId), a = [];
2734
2713
  if (n) {
2735
- const u = a.browsers.get(n);
2714
+ const u = i.browsers.get(n);
2736
2715
  if (!u)
2737
2716
  return {
2738
2717
  error: `Browser "${n}" not found`
@@ -2744,40 +2723,40 @@ async function Er(t, r, s) {
2744
2723
  error: `Context "${e}" not found in browser "${u.name}" (${u.browserType})`
2745
2724
  };
2746
2725
  const l = Array.from(c.pages.values());
2747
- l.length > 0 && i.push({
2726
+ l.length > 0 && a.push({
2748
2727
  contextInfo: c,
2749
2728
  pages: l
2750
2729
  });
2751
2730
  } else
2752
2731
  for (const c of u.contexts.values()) {
2753
2732
  const l = Array.from(c.pages.values());
2754
- l.length > 0 && i.push({
2733
+ l.length > 0 && a.push({
2755
2734
  contextInfo: c,
2756
2735
  pages: l
2757
2736
  });
2758
2737
  }
2759
2738
  } else if (e)
2760
- for (const u of a.browsers.values()) {
2739
+ for (const u of i.browsers.values()) {
2761
2740
  const c = u.contexts.get(e);
2762
2741
  if (c) {
2763
2742
  const l = Array.from(c.pages.values());
2764
- l.length > 0 && i.push({
2743
+ l.length > 0 && a.push({
2765
2744
  contextInfo: c,
2766
2745
  pages: l
2767
2746
  });
2768
2747
  }
2769
2748
  }
2770
2749
  else
2771
- for (const u of a.browsers.values())
2750
+ for (const u of i.browsers.values())
2772
2751
  for (const c of u.contexts.values()) {
2773
2752
  const l = Array.from(c.pages.values());
2774
- l.length > 0 && i.push({
2753
+ l.length > 0 && a.push({
2775
2754
  contextInfo: c,
2776
2755
  pages: l
2777
2756
  });
2778
2757
  }
2779
2758
  return {
2780
- pagesByContext: i
2759
+ pagesByContext: a
2781
2760
  };
2782
2761
  }
2783
2762
  function Dr(t, r) {
@@ -2796,7 +2775,7 @@ function Dr(t, r) {
2796
2775
  let n = `Method: playwright-page-list(${JSON.stringify(s)})
2797
2776
  `;
2798
2777
  return e.pagesByContext.length === 0 ? n += "No pages found" : n += e.pagesByContext.map(
2799
- ({ contextInfo: a, pages: i }) => `${a.name} (${a.browserInfo.name}) (${a.browserInfo.browserType}): ${i.map((u) => u.name).join(", ")}`
2778
+ ({ contextInfo: i, pages: a }) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType}): ${a.map((u) => u.name).join(", ")}`
2800
2779
  ).join(`
2801
2780
  `), n;
2802
2781
  }
@@ -2820,18 +2799,18 @@ async function Fr(t, r, s) {
2820
2799
  error: C(f)
2821
2800
  };
2822
2801
  }
2823
- const { names: e, contextName: n, browserName: a } = o;
2802
+ const { names: e, contextName: n, browserName: i } = o;
2824
2803
  if (!s.sessionId)
2825
2804
  return {
2826
2805
  error: "Session ID is required"
2827
2806
  };
2828
- const i = D(s.sessionId), u = [], c = [];
2807
+ const a = D(s.sessionId), u = [], c = [];
2829
2808
  let l = [];
2830
- if (a) {
2831
- const f = i.browsers.get(a);
2809
+ if (i) {
2810
+ const f = a.browsers.get(i);
2832
2811
  if (!f)
2833
2812
  return {
2834
- error: `Browser "${a}" not found`
2813
+ error: `Browser "${i}" not found`
2835
2814
  };
2836
2815
  if (n) {
2837
2816
  const d = f.contexts.get(n);
@@ -2854,7 +2833,7 @@ async function Fr(t, r, s) {
2854
2833
  );
2855
2834
  }) : l.push(...Array.from(d.pages.values()));
2856
2835
  } else if (n)
2857
- for (const f of i.browsers.values()) {
2836
+ for (const f of a.browsers.values()) {
2858
2837
  const d = f.contexts.get(n);
2859
2838
  d && (e ? e.forEach((m) => {
2860
2839
  const g = d.pages.get(m);
@@ -2864,7 +2843,7 @@ async function Fr(t, r, s) {
2864
2843
  }) : l.push(...Array.from(d.pages.values())));
2865
2844
  }
2866
2845
  else
2867
- for (const f of i.browsers.values())
2846
+ for (const f of a.browsers.values())
2868
2847
  for (const d of f.contexts.values())
2869
2848
  e ? e.forEach((m) => {
2870
2849
  const g = d.pages.get(m);
@@ -2903,7 +2882,7 @@ function Br(t, r) {
2903
2882
  return `Method: playwright-page-close(${JSON.stringify(s)})
2904
2883
  ❌ Error: ${e.error}`;
2905
2884
  const n = [];
2906
- 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)})
2885
+ 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)})
2907
2886
  ${n.join(`
2908
2887
  `)}`;
2909
2888
  }
@@ -2933,7 +2912,7 @@ async function Or(t, r, s) {
2933
2912
  error: C(g)
2934
2913
  };
2935
2914
  }
2936
- const { pageName: e, page: n, url: a, timeout: i, waitUntil: u } = o;
2915
+ const { pageName: e, page: n, url: i, timeout: a, waitUntil: u } = o;
2937
2916
  if (!s.sessionId)
2938
2917
  return {
2939
2918
  error: "Session ID is required"
@@ -2969,8 +2948,8 @@ async function Or(t, r, s) {
2969
2948
  error: "Either pageName or page must be provided"
2970
2949
  };
2971
2950
  try {
2972
- const g = await m.page.goto(a, {
2973
- timeout: i * 1e3,
2951
+ const g = await m.page.goto(i, {
2952
+ timeout: a * 1e3,
2974
2953
  waitUntil: u
2975
2954
  });
2976
2955
  return g ? {
@@ -2988,7 +2967,7 @@ async function Or(t, r, s) {
2988
2967
  };
2989
2968
  } catch (g) {
2990
2969
  return {
2991
- error: `Failed to navigate to "${a}": ${g instanceof Error ? g.message : "Unknown error"}`
2970
+ error: `Failed to navigate to "${i}": ${g instanceof Error ? g.message : "Unknown error"}`
2992
2971
  };
2993
2972
  }
2994
2973
  }
@@ -3034,17 +3013,12 @@ async function et(t, r, s) {
3034
3013
  return {
3035
3014
  error: "Session ID is required"
3036
3015
  };
3037
- const a = D(s.sessionId);
3038
- if (a.domSnapshotQueries.has(e))
3039
- return {
3040
- error: `DOM snapshot query "${e}" already exists`
3041
- };
3042
- const i = {
3016
+ const i = D(s.sessionId), a = {
3043
3017
  name: e,
3044
3018
  cssSelector: n
3045
3019
  };
3046
- return a.domSnapshotQueries.set(e, i), {
3047
- snapshotQuery: i
3020
+ return i.domSnapshotQueries.set(e, a), {
3021
+ snapshotQuery: a
3048
3022
  };
3049
3023
  }
3050
3024
  function Pr(t, r) {
@@ -3066,12 +3040,12 @@ function Pr(t, r) {
3066
3040
  function zr(t) {
3067
3041
  return function(s, o) {
3068
3042
  let e, n = 0;
3069
- const a = o ? o.length : 0;
3070
- let i = 1, u = 0, c = 0, l, f;
3043
+ const i = o ? o.length : 0;
3044
+ let a = 1, u = 0, c = 0, l, f;
3071
3045
  if (o)
3072
3046
  for (let g = 0; g < o.length; g++) {
3073
3047
  const p = o[g];
3074
- n += p.countMatched, i += p.countTotal, u += p.tokens, c += p.tokensTotal;
3048
+ n += p.countMatched, a += p.countTotal, u += p.tokens, c += p.tokensTotal;
3075
3049
  }
3076
3050
  s ? (l = s.uid, f = s.tagName, e = s.isMatched, e && (n += 1)) : (l = null, f = null, e = !1);
3077
3051
  let d;
@@ -3090,8 +3064,8 @@ function zr(t) {
3090
3064
  tagName: f,
3091
3065
  isMatched: e,
3092
3066
  countMatched: n,
3093
- countChilds: a,
3094
- countTotal: i,
3067
+ countChilds: i,
3068
+ countTotal: a,
3095
3069
  tokens: m,
3096
3070
  tokensChilds: u,
3097
3071
  tokensTotal: c,
@@ -3102,12 +3076,12 @@ function zr(t) {
3102
3076
  function Lr(t, r) {
3103
3077
  const s = j(r), o = s.getChilds(s.root), e = Le({
3104
3078
  getId: (n) => {
3105
- const a = s.getId(n);
3106
- if (a == null)
3079
+ const i = s.getId(n);
3080
+ if (i == null)
3107
3081
  throw new Error(
3108
3082
  `Invalid tree structure: node ID is null for node ${JSON.stringify(n)}`
3109
3083
  );
3110
- return a;
3084
+ return i;
3111
3085
  },
3112
3086
  getChilds: (n) => s.getChilds(n),
3113
3087
  createSnapshotNode: zr(),
@@ -3134,7 +3108,7 @@ async function tt(t, r, s) {
3134
3108
  error: C(d)
3135
3109
  };
3136
3110
  }
3137
- const { pageName: e, queryName: n, query: a, name: i } = o;
3111
+ const { pageName: e, queryName: n, query: i, name: a } = o;
3138
3112
  if (!s.sessionId)
3139
3113
  return {
3140
3114
  error: "Session ID is required"
@@ -3153,11 +3127,7 @@ async function tt(t, r, s) {
3153
3127
  return {
3154
3128
  error: `Page "${e}" not found`
3155
3129
  };
3156
- if (c.domSnapshots.has(i))
3157
- return {
3158
- error: `DOM snapshot "${i}" already exists in page "${e}"`
3159
- };
3160
- if (n && a)
3130
+ if (n && i)
3161
3131
  return {
3162
3132
  error: "Either queryName or query must be provided, not both"
3163
3133
  };
@@ -3169,9 +3139,9 @@ async function tt(t, r, s) {
3169
3139
  error: `DOM snapshot query "${n}" not found`
3170
3140
  };
3171
3141
  l = d;
3172
- } else if (a) {
3142
+ } else if (i) {
3173
3143
  const d = await et(
3174
- a,
3144
+ i,
3175
3145
  r,
3176
3146
  s
3177
3147
  );
@@ -3201,11 +3171,11 @@ async function tt(t, r, s) {
3201
3171
  idToNode: new Map(d.idToNode),
3202
3172
  idToChildIds: new Map(d.idToChildIds)
3203
3173
  }, g = Lr(l, m), p = {
3204
- name: i,
3174
+ name: a,
3205
3175
  query: l,
3206
3176
  tree: g
3207
3177
  };
3208
- return c.domSnapshots.set(i, p), {
3178
+ return c.domSnapshots.set(a, p), {
3209
3179
  domSnapshot: p,
3210
3180
  queryCreated: f
3211
3181
  };
@@ -3269,7 +3239,7 @@ const rt = h.object({
3269
3239
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
3270
3240
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
3271
3241
  });
3272
- async function qr(t, r, s) {
3242
+ async function Gr(t, r, s) {
3273
3243
  let o;
3274
3244
  try {
3275
3245
  o = rt.parse(t);
@@ -3281,12 +3251,12 @@ async function qr(t, r, s) {
3281
3251
  const {
3282
3252
  snapshotName: e,
3283
3253
  snapshot: n,
3284
- childsIndexRange: a
3254
+ childsIndexRange: i
3285
3255
  // maxCountTotal,
3286
3256
  // maxTokensTotal,
3287
3257
  // maxCountGroup,
3288
3258
  // maxTokensGroup,
3289
- } = o, i = 60, u = 1e3, c = 25, l = 900;
3259
+ } = o, a = 60, u = 1e3, c = 25, l = 900;
3290
3260
  if (!s.sessionId)
3291
3261
  return {
3292
3262
  error: "Session ID is required"
@@ -3329,26 +3299,26 @@ async function qr(t, r, s) {
3329
3299
  error: "Either snapshotName or snapshot must be provided"
3330
3300
  };
3331
3301
  try {
3332
- const p = o.parentUid, y = qe({
3302
+ const p = o.parentUid, y = Ge({
3333
3303
  tree: d.tree,
3334
3304
  request: {
3335
3305
  parentNodeId: p,
3336
- childsIndexRange: a,
3306
+ childsIndexRange: i,
3337
3307
  limits: {
3338
- maxCountTotal: i,
3308
+ maxCountTotal: a,
3339
3309
  maxTokensTotal: u,
3340
3310
  maxCountGroup: c,
3341
3311
  maxTokensGroup: l
3342
3312
  }
3343
3313
  },
3344
3314
  indexRangeGroupStrategy: new Ar()
3345
- }), w = Ge(y);
3315
+ }), w = qe(y);
3346
3316
  return {
3347
3317
  domSnapshot: d,
3348
3318
  queryCreated: m,
3349
3319
  snapshotCreated: g,
3350
3320
  parentUid: p,
3351
- childsIndexRange: a,
3321
+ childsIndexRange: i,
3352
3322
  report: w
3353
3323
  };
3354
3324
  } catch (p) {
@@ -3357,7 +3327,7 @@ async function qr(t, r, s) {
3357
3327
  };
3358
3328
  }
3359
3329
  }
3360
- function Gr(t, r) {
3330
+ function qr(t, r) {
3361
3331
  t(
3362
3332
  "playwright-dom-snapshot-browse",
3363
3333
  {
@@ -3366,7 +3336,7 @@ function Gr(t, r) {
3366
3336
  inputSchema: rt.shape
3367
3337
  },
3368
3338
  async (s, o) => {
3369
- const e = await qr(s, r, o);
3339
+ const e = await Gr(s, r, o);
3370
3340
  if (e.error != null)
3371
3341
  return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
3372
3342
  ❌ Error: ${e.error}`;
@@ -3378,8 +3348,8 @@ function Gr(t, r) {
3378
3348
  `, n += `CSS Selector: ${e.domSnapshot.query.cssSelector}
3379
3349
  `, n += `Parent UID: ${e.parentUid ?? "null (root node)"}
3380
3350
  `, e.childsIndexRange) {
3381
- const [a, i] = e.childsIndexRange, c = (e.parentUid ? e.domSnapshot.tree.getNode(e.parentUid) : e.domSnapshot.tree.root).countChilds;
3382
- n += ` Showing indexes: ${a}-${i} of ${c}
3351
+ const [i, a] = e.childsIndexRange, c = (e.parentUid ? e.domSnapshot.tree.getNode(e.parentUid) : e.domSnapshot.tree.root).countChilds;
3352
+ n += ` Showing indexes: ${i}-${a} of ${c}
3383
3353
  `;
3384
3354
  }
3385
3355
  return n += `
@@ -3388,12 +3358,12 @@ ${e.report}`, n;
3388
3358
  );
3389
3359
  }
3390
3360
  function jr(t, r) {
3391
- r.browserCreate && wr(t, r), r.browserList && br(t, r), r.browserClose && xr(t, r), r.contextCreate && $r(t, r), r.contextList && Mr(t, r), r.contextClose && vr(t, r), r.pageCreate && Nr(t, r), r.pageList && Dr(t, r), r.pageClose && Br(t, r), r.pageGoto && Rr(t, r), r.domSnapshotQueryCreate && Pr(t, r), r.domSnapshotCreate && Ur(t, r), r.domSnapshotBrowse && Gr(t, r), console.log("Playwright manager");
3361
+ r.browserCreate && wr(t, r), r.browserList && br(t, r), r.browserClose && xr(t, r), r.contextCreate && $r(t, r), r.contextList && Mr(t, r), r.contextClose && vr(t, r), r.pageCreate && Nr(t, r), r.pageList && Dr(t, r), r.pageClose && Br(t, r), r.pageGoto && Rr(t, r), r.domSnapshotQueryCreate && Pr(t, r), r.domSnapshotCreate && Ur(t, r), r.domSnapshotBrowse && qr(t, r), console.log("Playwright manager");
3392
3362
  }
3393
3363
  function _r(t) {
3394
3364
  const { logFilePath: r } = t;
3395
- return async function(o, e, n, a) {
3396
- await q({
3365
+ return async function(o, e, n, i) {
3366
+ await G({
3397
3367
  logFilePath: r,
3398
3368
  message: "ERROR",
3399
3369
  data: {
@@ -3436,11 +3406,11 @@ function Qr(t, r) {
3436
3406
  s(e);
3437
3407
  };
3438
3408
  try {
3439
- e = r.host ? t.listen(r.port ?? 0, r.host, n) : t.listen(r.port ?? 0, n), e.addListener("error", (a) => {
3440
- o(a);
3409
+ e = r.host ? t.listen(r.port ?? 0, r.host, n) : t.listen(r.port ?? 0, n), e.addListener("error", (i) => {
3410
+ o(i);
3441
3411
  });
3442
- } catch (a) {
3443
- o(a);
3412
+ } catch (i) {
3413
+ o(i);
3444
3414
  }
3445
3415
  });
3446
3416
  }
@@ -3450,13 +3420,13 @@ function Hr(t, r) {
3450
3420
  const o = t.address().family, e = t.address().port;
3451
3421
  let n = t.address().address;
3452
3422
  n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
3453
- const a = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
3423
+ const i = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
3454
3424
  return `Project Tools - MCP Server Started
3455
3425
 
3456
3426
  Server Name: ${r.name}
3457
3427
  Server Version: ${r.version}
3458
- Server URL: ${a}/mcp
3459
- SSE Endpoint: ${a}/sse
3428
+ Server URL: ${i}/mcp
3429
+ SSE Endpoint: ${i}/sse
3460
3430
 
3461
3431
  Log File: ${T.resolve(r.logFilePath)}`;
3462
3432
  }