@flemist/mcp-project-tools 3.0.11 → 3.0.13

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
- import re from "express";
2
- import { McpServer as Dt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { randomUUID as Rt } from "crypto";
1
+ import oe from "express";
2
+ import { McpServer as Lt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { randomUUID as Pt } from "crypto";
4
4
  import * as W from "fs";
5
- import * as R from "path";
6
- import Ft from "path";
7
- import { StreamableHTTPServerTransport as Bt } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
- import { spawn as Lt } from "child_process";
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";
9
9
  import { z as p } from "zod";
10
- import fe from "tree-kill";
11
- import { Pool as Pt, poolRunWait as Y } from "@flemist/time-limits";
10
+ import he from "tree-kill";
11
+ import { Pool as qt, poolRunWait as Y } from "@flemist/time-limits";
12
12
  import { priorityCreate as V } from "@flemist/priority-queue";
13
- import { useAbortController as At, combineAbortSignals as zt, Locker as Ut } from "@flemist/async-utils";
14
- import _t from "node:os";
15
- import qt from "picomatch";
16
- import { webkit as Gt, firefox as jt, chromium as Jt } from "playwright";
17
- function Kt(r) {
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) {
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) {
@@ -24,33 +24,33 @@ function Kt(r) {
24
24
  n();
25
25
  };
26
26
  }
27
- async function se(r) {
27
+ async function ne(r) {
28
28
  const { logFilePath: t, message: s, data: o } = r;
29
29
  try {
30
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 W.promises.mkdir(R.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, i);
35
35
  } catch (e) {
36
36
  console.error(`Failed to log "${s}":`, e);
37
37
  }
38
38
  }
39
- const oe = /* @__PURE__ */ new Map();
40
- function Wt(r) {
39
+ const ie = /* @__PURE__ */ new Map();
40
+ function Vt(r) {
41
41
  return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
42
42
  }
43
- async function Ht(r, t) {
44
- const s = r.createMcpServer(), o = new Bt({
45
- sessionIdGenerator: () => t || Rt(),
43
+ async function Zt(r, t) {
44
+ const s = r.createMcpServer(), o = new zt({
45
+ sessionIdGenerator: () => t || Pt(),
46
46
  onsessioninitialized: (n) => {
47
- oe.set(n, o);
47
+ ie.set(n, o);
48
48
  },
49
49
  enableJsonResponse: !0
50
50
  });
51
51
  async function e() {
52
52
  const n = o.sessionId;
53
- n && oe.delete(n);
53
+ n && ie.delete(n);
54
54
  try {
55
55
  await s.close();
56
56
  } catch (i) {
@@ -64,28 +64,28 @@ async function Ht(r, t) {
64
64
  throw await e(), n;
65
65
  }
66
66
  }
67
- async function Qt(r, t, s, o) {
68
- await se({
67
+ async function Xt(r, t, s, o) {
68
+ await ne({
69
69
  logFilePath: s.logFilePath,
70
70
  message: "REQUEST",
71
71
  data: r.body
72
72
  });
73
- let e = o ? oe.get(o) : null;
74
- e || (e = await Ht(s, o)), await e.handleRequest(r, t, r.body);
73
+ let e = o ? ie.get(o) : null;
74
+ e || (e = await Zt(s, o)), await e.handleRequest(r, t, r.body);
75
75
  }
76
- async function Yt(r, t, s) {
77
- const o = s ? oe.get(s) : null;
76
+ async function er(r, t, s) {
77
+ const o = s ? ie.get(s) : null;
78
78
  if (!o) {
79
79
  t.status(400).json({ error: "No valid session found" });
80
80
  return;
81
81
  }
82
82
  await o.handleRequest(r, t);
83
83
  }
84
- function Vt(r) {
84
+ function tr(r) {
85
85
  return async function(s, o) {
86
86
  try {
87
- const e = Wt(s);
88
- s.method === "POST" ? await Qt(s, o, r, e) : s.method === "GET" ? await Yt(s, o, e) : o.status(405).json({ error: "Method not allowed" });
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" });
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 Vt(r) {
94
94
  };
95
95
  }
96
96
  const Q = /* @__PURE__ */ new Map();
97
- let Zt = 0;
98
- const Te = 10, Xt = 1800 * 1e3, F = 1e4, er = 500, tr = 5e3;
99
- function rr(r) {
97
+ let rr = 0;
98
+ const Te = 10, sr = 1800 * 1e3, R = 1e4, or = 500, nr = 5e3;
99
+ function ir(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 rr(r) {
113
113
  }
114
114
  return o;
115
115
  }
116
- function sr() {
117
- return ++Zt;
116
+ function ar() {
117
+ return ++rr;
118
118
  }
119
119
  let Ce = !1;
120
- function or() {
120
+ function lr() {
121
121
  if (Ce)
122
122
  return;
123
123
  Ce = !0;
@@ -126,7 +126,7 @@ function or() {
126
126
  for (const [t, s] of Array.from(Q.entries()))
127
127
  if (s.isRunning && s.pid)
128
128
  try {
129
- fe(s.pid, "SIGKILL");
129
+ he(s.pid, "SIGKILL");
130
130
  } catch (o) {
131
131
  console.error(`Error killing process ${t}:`, o);
132
132
  }
@@ -134,29 +134,29 @@ function or() {
134
134
  };
135
135
  process.on("SIGINT", r), process.on("SIGTERM", r);
136
136
  }
137
- function pe() {
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() > Xt && t.push(s);
140
+ !o.isRunning && o.endTime && r - o.endTime.getTime() > sr && t.push(s);
141
141
  for (const s of t)
142
142
  Q.delete(s);
143
143
  }
144
- function me(r) {
144
+ function ge(r) {
145
145
  const { process: t } = r, s = Date.now();
146
- if (s - t.lastOutputTime.getTime() >= er && (t.output += t.localOutput, t.localOutput = "", t.lastOutputTime = new Date(s), t.output.length > F)) {
146
+ if (s - t.lastOutputTime.getTime() >= or && (t.output += t.localOutput, t.localOutput = "", t.lastOutputTime = new Date(s), t.output.length > R)) {
147
147
  const n = `
148
- ... [${t.output.length - F} characters trimmed] ...
149
- `, i = F - n.length;
148
+ ... [${t.output.length - R} characters trimmed] ...
149
+ `, i = R - n.length;
150
150
  if (i > 0) {
151
151
  const a = Math.floor(i / 2);
152
152
  t.output = t.output.substring(0, a) + n + t.output.substring(
153
153
  t.output.length - (i - a)
154
154
  );
155
155
  } else
156
- t.output = t.output.substring(0, F);
156
+ t.output = t.output.substring(0, R);
157
157
  }
158
158
  }
159
- function nr(r, t) {
159
+ function cr(r, t) {
160
160
  const s = t.limit;
161
161
  if (r.length <= s) return r;
162
162
  const e = `
@@ -176,18 +176,18 @@ const Ze = p.object({
176
176
  id: p.number().describe(
177
177
  "Process ID to get detailed status information for. Get process IDs using process-list. Works for both running and completed processes. Examples: 1, 42, 123"
178
178
  ),
179
- outputLimit: p.number().max(F).default(F).describe(
180
- `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: ${F} characters. Default: ${F}.`
179
+ outputLimit: p.number().max(R).default(R).describe(
180
+ `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}.`
181
181
  )
182
182
  });
183
- async function ge(r, t) {
184
- pe();
183
+ async function we(r, t) {
184
+ me();
185
185
  let s;
186
186
  try {
187
187
  s = Ze.parse(r);
188
- } catch (l) {
188
+ } catch (c) {
189
189
  return {
190
- error: B(l)
190
+ error: B(c)
191
191
  };
192
192
  }
193
193
  const { id: o, outputLimit: e } = s, n = Q.get(o);
@@ -195,11 +195,11 @@ async function ge(r, t) {
195
195
  return {
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
- me({ process: n });
199
- const i = n.output + n.localOutput, a = nr(i, { limit: e });
198
+ ge({ process: n });
199
+ const i = n.output + n.localOutput, a = cr(i, { limit: e });
200
200
  return n.output = "", n.localOutput = "", {
201
201
  id: n.id,
202
- cwd: R.relative(t.workingDir || "", n.cwd),
202
+ cwd: F.relative(t.workingDir || "", n.cwd),
203
203
  commandLine: n.commandLine,
204
204
  pid: n.pid,
205
205
  startTime: n.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
@@ -210,7 +210,7 @@ async function ge(r, t) {
210
210
  error: n.error
211
211
  };
212
212
  }
213
- function ir(r, t) {
213
+ function ur(r, t) {
214
214
  r(
215
215
  "process-status",
216
216
  {
@@ -219,7 +219,7 @@ function ir(r, t) {
219
219
  inputSchema: Ze.shape
220
220
  },
221
221
  async (s) => {
222
- const o = await ge(s, t);
222
+ const o = await we(s, t);
223
223
  if (!("output" in o))
224
224
  return `Method: process-status(${JSON.stringify(s)})
225
225
  ❌ Error: ${o.error}`;
@@ -233,13 +233,13 @@ ${e.trim()}`;
233
233
  );
234
234
  }
235
235
  function Xe(r) {
236
- fe(r, "SIGTERM", (t) => {
236
+ he(r, "SIGTERM", (t) => {
237
237
  t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
238
238
  }), setTimeout(() => {
239
- fe(r, "SIGKILL", (t) => {
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
- }, tr);
242
+ }, nr);
243
243
  }
244
244
  const et = p.object({
245
245
  id: p.number().describe(
@@ -251,8 +251,8 @@ const et = p.object({
251
251
  autoKill: p.boolean().default(!1).describe(
252
252
  "Automatically terminate the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running after timeout). Set to true for processes that should not run indefinitely"
253
253
  ),
254
- outputLimit: p.number().max(F).default(F).describe(
255
- `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: ${F} characters. Default: ${F}.`
254
+ outputLimit: p.number().max(R).default(R).describe(
255
+ `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}.`
256
256
  )
257
257
  });
258
258
  async function tt(r, t) {
@@ -269,22 +269,22 @@ async function tt(r, t) {
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
  };
272
- const l = Date.now();
273
- let c = !1, u = !1;
272
+ const c = Date.now();
273
+ let l = !1, u = !1;
274
274
  e != null && await new Promise((m) => {
275
275
  const g = setInterval(() => {
276
- a.isRunning ? Date.now() - l >= e * 1e3 && (clearInterval(g), c = !0, n && a.pid && (Xe(a.pid), u = !0), m()) : (clearInterval(g), m());
276
+ a.isRunning ? Date.now() - c >= e * 1e3 && (clearInterval(g), l = !0, n && a.pid && (Xe(a.pid), u = !0), m()) : (clearInterval(g), m());
277
277
  }, 100);
278
278
  });
279
- const f = (Date.now() - l) / 1e3;
279
+ const f = (Date.now() - c) / 1e3;
280
280
  return {
281
- ...await ge({ id: o, outputLimit: i }, t),
281
+ ...await we({ id: o, outputLimit: i }, t),
282
282
  waitDuration: f,
283
- waitTimeExceeded: c,
283
+ waitTimeExceeded: l,
284
284
  autoKillExecuted: u
285
285
  };
286
286
  }
287
- function ar(r, t) {
287
+ function dr(r, t) {
288
288
  r(
289
289
  "process-wait",
290
290
  {
@@ -319,12 +319,12 @@ const rt = p.object({
319
319
  autoKill: p.boolean().default(!1).describe(
320
320
  "Automatically kill the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running). Set to true for commands that should not run indefinitely"
321
321
  ),
322
- outputLimit: p.number().max(F).default(F).describe(
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: ${F} characters. Default: ${F}.`
322
+ outputLimit: p.number().max(R).default(R).describe(
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 lr(r, t) {
327
- pe();
326
+ async function fr(r, t) {
327
+ me();
328
328
  let s;
329
329
  try {
330
330
  s = rt.parse(r);
@@ -333,8 +333,8 @@ async function lr(r, t) {
333
333
  error: B(d)
334
334
  };
335
335
  }
336
- const { commandLine: o, waitTime: e, autoKill: n, outputLimit: i } = s, { commandLineRules: a } = t, l = R.resolve(t.workingDir || "", s.cwd || "");
337
- if (!rr({ commandLine: o, commandLineRules: a })) {
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
338
  const d = a.map(
339
339
  (h) => `${h.rule.toUpperCase()}: /${h.regexp}/ (${h.note})`
340
340
  ).join(`
@@ -352,9 +352,9 @@ To use this command line, ask the user to modify the command line rules in the c
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 = sr(), f = {
355
+ const u = ar(), f = {
356
356
  id: u,
357
- cwd: l,
357
+ cwd: c,
358
358
  commandLine: o,
359
359
  startTime: /* @__PURE__ */ new Date(),
360
360
  isRunning: !0,
@@ -364,38 +364,38 @@ To use this command line, ask the user to modify the command line rules in the c
364
364
  };
365
365
  Q.set(u, f);
366
366
  try {
367
- const d = Lt(o, [], {
367
+ const d = Ut(o, [], {
368
368
  shell: !0,
369
- cwd: l,
369
+ cwd: c,
370
370
  stdio: ["pipe", "pipe", "pipe"]
371
371
  });
372
372
  f.pid = d.pid;
373
373
  const h = (m) => {
374
374
  const g = m.toString();
375
- f.localOutput += g, me({ process: f }), console.log(g);
375
+ f.localOutput += g, ge({ process: f }), console.log(g);
376
376
  };
377
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 > F) {
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) {
379
379
  const y = `
380
- ... [${f.output.length - F} characters trimmed] ...
381
- `, w = F - y.length;
380
+ ... [${f.output.length - R} characters trimmed] ...
381
+ `, w = R - y.length;
382
382
  if (w > 0) {
383
383
  const M = Math.floor(w / 2);
384
384
  f.output = f.output.substring(0, M) + y + f.output.substring(
385
385
  f.output.length - (w - M)
386
386
  );
387
387
  } else
388
- f.output = f.output.substring(0, F);
388
+ f.output = f.output.substring(0, R);
389
389
  }
390
390
  console.log(`Process ${u} (${o}) exited with code ${m}`);
391
391
  }), d.on("error", (m) => {
392
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) : ge({ id: u, outputLimit: i }, t);
393
+ }), e != null ? tt({ id: u, waitTime: e, autoKill: n, outputLimit: i }, t) : we({ id: u, outputLimit: i }, t);
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
  }
397
397
  }
398
- function cr(r, t) {
398
+ function hr(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 lr(o, t);
410
+ const e = await fr(o, t);
411
411
  if (!("output" in e))
412
412
  return `Method: process-run(${JSON.stringify(o)})
413
413
  ❌ Error: ${e.error}`;
@@ -434,39 +434,39 @@ 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 ur(r, t) {
438
- pe();
437
+ async function pr(r, t) {
438
+ me();
439
439
  let s;
440
440
  try {
441
441
  s = st.parse(r);
442
- } catch (c) {
442
+ } catch (l) {
443
443
  return {
444
- error: B(c)
444
+ error: B(l)
445
445
  };
446
446
  }
447
447
  const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: i } = s;
448
448
  let a = Array.from(Q.values());
449
449
  if (o) {
450
- const c = new Date(o.replace(/[_\s]/g, "T"));
451
- a = a.filter((u) => u.startTime >= c);
450
+ const l = new Date(o.replace(/[_\s]/g, "T"));
451
+ a = a.filter((u) => u.startTime >= l);
452
452
  }
453
453
  if (e) {
454
- const c = new Date(e.replace(/[_\s]/g, "T"));
455
- a = a.filter((u) => u.endTime && u.endTime >= c);
454
+ const l = new Date(e.replace(/[_\s]/g, "T"));
455
+ a = a.filter((u) => u.endTime && u.endTime >= l);
456
456
  }
457
- return n && (a = a.filter((c) => c.isRunning)), { processes: a.map((c) => {
458
- me({ process: c });
457
+ return n && (a = a.filter((l) => l.isRunning)), { processes: a.map((l) => {
458
+ ge({ process: l });
459
459
  let u = {
460
- id: c.id,
461
- cwd: Ft.relative(t.workingDir || "", c.cwd),
462
- commandLine: c.commandLine,
463
- pid: c.pid,
464
- startTime: c.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
465
- endTime: c.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
466
- exitCode: c.exitCode,
467
- isRunning: c.isRunning,
468
- output: c.output + c.localOutput,
469
- error: c.error
460
+ id: l.id,
461
+ cwd: At.relative(t.workingDir || "", l.cwd),
462
+ commandLine: l.commandLine,
463
+ pid: l.pid,
464
+ startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
465
+ endTime: l.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
466
+ exitCode: l.exitCode,
467
+ isRunning: l.isRunning,
468
+ output: l.output + l.localOutput,
469
+ error: l.error
470
470
  };
471
471
  if (i) {
472
472
  const f = {};
@@ -477,7 +477,7 @@ async function ur(r, t) {
477
477
  return u;
478
478
  }) };
479
479
  }
480
- function dr(r, t) {
480
+ function mr(r, t) {
481
481
  r(
482
482
  "process-list",
483
483
  {
@@ -486,7 +486,7 @@ function dr(r, t) {
486
486
  inputSchema: st.shape
487
487
  },
488
488
  async (s) => {
489
- const o = await ur(s, t);
489
+ const o = await pr(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 fr(r) {
508
+ function gr(r) {
509
509
  let t;
510
510
  try {
511
511
  t = ot.parse(r);
@@ -535,7 +535,7 @@ function fr(r) {
535
535
  };
536
536
  }
537
537
  }
538
- function hr(r, t) {
538
+ function wr(r, t) {
539
539
  r(
540
540
  "process-kill",
541
541
  {
@@ -544,45 +544,45 @@ function hr(r, t) {
544
544
  inputSchema: ot.shape
545
545
  },
546
546
  async (s) => {
547
- const o = fr(s);
547
+ const o = gr(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 pr(r, t) {
555
- or(), t.run && cr(r, t), t.status && ir(r, t), t.wait && ar(r, t), t.list && dr(r, t), t.kill && hr(r);
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);
556
556
  const s = t.commandLineRules?.map(
557
557
  (o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
558
558
  ) || [];
559
559
  console.log(
560
560
  `Process manager:
561
- - Working directory: ${R.resolve(t.workingDir || "")}
561
+ - Working directory: ${F.resolve(t.workingDir || "")}
562
562
  - Command line rules: ${t.commandLineRules?.length || 0} rules configured:
563
563
  ${s.map((o) => `- ${o}`).join(`
564
564
  `)}
565
565
  `
566
566
  );
567
567
  }
568
- function mr(r, t) {
568
+ function br(r, t) {
569
569
  return function(o, e, n) {
570
570
  const i = async (...a) => {
571
- await se({
571
+ await ne({
572
572
  logFilePath: t.logFilePath,
573
573
  message: "REQUEST",
574
574
  data: { name: o, args: a }
575
575
  });
576
- const l = await n(...a);
577
- return await se({
576
+ const c = await n(...a);
577
+ return await ne({
578
578
  logFilePath: t.logFilePath,
579
579
  message: "RESPONSE",
580
- data: l
580
+ data: c
581
581
  }), {
582
582
  content: [
583
583
  {
584
584
  type: "text",
585
- text: l
585
+ text: c
586
586
  }
587
587
  ]
588
588
  };
@@ -594,23 +594,23 @@ function mr(r, t) {
594
594
  );
595
595
  };
596
596
  }
597
- function gr(r) {
597
+ function Sr(r) {
598
598
  return r.match(/^[/\\]?[^/\\]+/)[0];
599
599
  }
600
- function wr(r, t) {
601
- return gr(r) + "|" + t.ino;
600
+ function xr(r, t) {
601
+ return Sr(r) + "|" + t.ino;
602
602
  }
603
- function yr(r) {
604
- return r.endsWith(":") && (r += "/"), R.resolve(r);
603
+ function $r(r) {
604
+ return r.endsWith(":") && (r += "/"), F.resolve(r);
605
605
  }
606
- const we = new Pt(_t.cpus().length);
606
+ const ye = new qt(jt.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 br = function(t) {
613
+ const Ir = 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 ?? we, i = r.handleError, a = r.priority ?? V(0), l = r.walkLinks ?? !1, c = r.log, u = r.handlePath, f = r.matchPath;
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
627
  async function d(m) {
628
- if (!(i && await i(m)) && !br(m))
628
+ if (!(i && await i(m)) && !Ir(m))
629
629
  throw m;
630
630
  }
631
631
  function h(m) {
632
- return !(!c || c.minTotalContentSize != null && m < c.minTotalContentSize || c.maxNestedLevel != null && s > c.maxNestedLevel);
632
+ return !(!l || l.minTotalContentSize != null && m < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
633
633
  }
634
- return At(async (m) => {
635
- const g = zt(e, m), y = {
634
+ return _t(async (m) => {
635
+ const g = Gt(e, m), y = {
636
636
  totalSize: 0,
637
637
  maxFileDateModified: 0,
638
638
  countFiles: 0,
@@ -642,7 +642,7 @@ function nt(r) {
642
642
  function w($, S) {
643
643
  if (h(S.totalSize)) {
644
644
  const T = `${S.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${$}`;
645
- c?.handleLog ? c.handleLog(T) : console.log(T);
645
+ l?.handleLog ? l.handleLog(T) : console.log(T);
646
646
  }
647
647
  }
648
648
  async function M($, S, x, T) {
@@ -667,7 +667,7 @@ function nt(r) {
667
667
  abortSignal: g
668
668
  }) : !0;
669
669
  }
670
- async function E($, S, x, T) {
670
+ async function N($, S, x, T) {
671
671
  T || (T = $);
672
672
  const v = await Y({
673
673
  pool: n,
@@ -678,7 +678,7 @@ function nt(r) {
678
678
  });
679
679
  if (!v || !x && v.isFile())
680
680
  return null;
681
- const L = wr($, v);
681
+ const L = xr($, v);
682
682
  if (o.has(L))
683
683
  return null;
684
684
  o.add(L);
@@ -694,17 +694,17 @@ function nt(r) {
694
694
  V(v.isDirectory() ? 2 : 3, a)
695
695
  );
696
696
  if (v.isSymbolicLink()) {
697
- if (l) {
697
+ if (c) {
698
698
  const C = await Y({
699
699
  pool: n,
700
- func: () => W.promises.readlink($).catch(d).then((N) => N ?? null),
700
+ func: () => W.promises.readlink($).catch(d).then((E) => E ?? null),
701
701
  count: 1,
702
702
  priority: I,
703
703
  abortSignal: g
704
704
  });
705
705
  if (C) {
706
- const N = R.isAbsolute(C) ? C : R.resolve(R.dirname(T), C), O = await E(
707
- N,
706
+ const E = F.isAbsolute(C) ? C : F.resolve(F.dirname(T), C), O = await N(
707
+ E,
708
708
  S,
709
709
  x,
710
710
  T
@@ -727,8 +727,8 @@ function nt(r) {
727
727
  abortSignal: g
728
728
  });
729
729
  if (C) {
730
- for (let N = 0, O = C.length; N < O; N++)
731
- C[N] = R.join(T, C[N]);
730
+ for (let E = 0, O = C.length; E < O; E++)
731
+ C[E] = F.join(T, C[E]);
732
732
  k = await nt({
733
733
  ...r,
734
734
  paths: C,
@@ -748,8 +748,8 @@ function nt(r) {
748
748
  }
749
749
  const b = [];
750
750
  for (let $ = 0, S = t.length; $ < S; $++) {
751
- const x = yr(t[$]), T = f ? f(x) : !0;
752
- T !== !1 && b.push(E(x, $, T));
751
+ const x = $r(t[$]), T = f ? f(x) : !0;
752
+ T !== !1 && b.push(N(x, $, T));
753
753
  }
754
754
  return await Promise.all(b), y;
755
755
  });
@@ -760,22 +760,22 @@ function it(r) {
760
760
  function H(r) {
761
761
  return r.replace(/\\/g, "/");
762
762
  }
763
- function Sr(r, t) {
763
+ function Mr(r, t) {
764
764
  if (!t || t === ".")
765
765
  return r;
766
766
  const s = r.startsWith("^");
767
767
  s && (r = r.substring(1));
768
768
  const o = r.startsWith("!");
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(R.normalize(r)), o && (r = "!" + r), s && (r = "^" + r), r;
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 xr(r) {
771
+ function Tr(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
- function Ee(r) {
775
+ function Ne(r) {
776
776
  return "^" + r;
777
777
  }
778
- async function $r(r) {
778
+ async function Cr(r) {
779
779
  const s = (await W.promises.readFile(r, "utf-8")).split(`
780
780
  `), o = [];
781
781
  return s.forEach((e) => {
@@ -788,16 +788,16 @@ async function at(r) {
788
788
  return s;
789
789
  const o = [];
790
790
  return r.globs.forEach((e) => {
791
- e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Ee(e.value) : e.value));
791
+ e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Ne(e.value) : e.value));
792
792
  }), o.length && await Promise.all(
793
793
  o.map(async (e) => {
794
794
  await Y({
795
- pool: we,
795
+ pool: ye,
796
796
  count: 1,
797
797
  func: async () => {
798
- const n = R.resolve(t, e.value), i = await $r(n), a = R.relative(t, R.dirname(n));
799
- i.forEach((l) => {
800
- l = xr(l), l = Sr(l, a), s.push(e.exclude ? Ee(l) : l);
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);
801
801
  });
802
802
  }
803
803
  });
@@ -820,39 +820,39 @@ function lt({
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 ? R.resolve(t, e) : e);
823
+ const a = H(t ? F.resolve(t, e) : e);
824
824
  if (!a)
825
825
  return;
826
- let l;
826
+ let c;
827
827
  try {
828
- l = qt(a, {
828
+ c = Kt(a, {
829
829
  nocase: s ?? !1,
830
830
  dot: !0,
831
831
  strictBrackets: !0
832
832
  // Validate bracket balance for patterns like "["
833
833
  });
834
- } catch (c) {
834
+ } catch (l) {
835
835
  throw new Error(
836
- `Invalid glob pattern: "${e}". ${c instanceof Error ? c.message : "Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`
836
+ `Invalid glob pattern: "${e}". ${l instanceof Error ? l.message : "Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`
837
837
  );
838
838
  }
839
839
  o.push({
840
840
  exclude: n,
841
841
  negative: i,
842
842
  debugInfo: a,
843
- match: l
843
+ match: c
844
844
  });
845
845
  }), function(n) {
846
846
  n = H(n);
847
847
  let i = null, a = !1;
848
- for (let l = 0, c = o.length; l < c; l++) {
849
- const u = o[l];
848
+ for (let c = 0, l = o.length; c < l; c++) {
849
+ const u = o[c];
850
850
  u.match(n) && (u.exclude ? a = !u.negative : (i = !u.negative, a = !1));
851
851
  }
852
852
  return a ? !1 : i;
853
853
  };
854
854
  }
855
- async function Ir(r) {
855
+ async function vr(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({
@@ -868,10 +868,10 @@ async function Ir(r) {
868
868
  noCase: !0
869
869
  }),
870
870
  handlePath: async ({ path: n, stat: i, itemStat: a }) => {
871
- const l = R.relative(t, n), c = i.isDirectory(), u = i.isFile();
872
- if (!c && !u)
871
+ const c = F.relative(t, n), l = i.isDirectory(), u = i.isFile();
872
+ if (!l && !u)
873
873
  return !0;
874
- const f = H(l || "."), d = c ? "dir" : "file", h = c ? a.maxFileDateModified || null : i.mtimeMs, m = c ? a.totalSize : i.size, g = c ? a.countFiles : null, y = {
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
875
  path: f,
876
876
  type: d
877
877
  };
@@ -885,62 +885,62 @@ async function Ir(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), c && !r.result.dirs || u && !r.result.files || s.push(y), !0;
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;
889
889
  }
890
890
  }), { items: s, totals: o };
891
891
  }
892
- const Ne = ["B", "KB", "MB", "GB", "TB"], ke = 1024;
892
+ const Ee = ["B", "KB", "MB", "GB", "TB"], ke = 1024;
893
893
  function Oe(r) {
894
894
  if (r == null) return "-";
895
895
  let t = r ?? 0, s = 0;
896
- for (; t >= ke && s < Ne.length - 1; )
896
+ for (; t >= ke && s < Ee.length - 1; )
897
897
  t /= ke, s++;
898
- return `${s === 0 ? t.toString() : t.toFixed(2)}${Ne[s]}`;
898
+ return `${s === 0 ? t.toString() : t.toFixed(2)}${Ee[s]}`;
899
899
  }
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), l = Math.floor(i / 30), c = Math.floor(i / 365);
904
- return c > 0 ? `${c}Y` : l > 0 ? `${l}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), 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`;
905
905
  }
906
- function Mr(r, t) {
906
+ function Nr(r, t) {
907
907
  return t?.length ? [...r].sort((s, o) => {
908
908
  for (let e = 0, n = t.length; e < n; e++) {
909
909
  const i = t[e];
910
- let a, l;
910
+ let a, c;
911
911
  switch (i.field) {
912
912
  case "type":
913
- a = s.type, l = o.type;
913
+ a = s.type, c = o.type;
914
914
  break;
915
915
  case "path":
916
- a = s.path, l = o.path;
916
+ a = s.path, c = o.path;
917
917
  break;
918
918
  case "dateModified":
919
- a = s.dateModified, l = o.dateModified;
919
+ a = s.dateModified, c = o.dateModified;
920
920
  break;
921
921
  case "size":
922
- a = s.size, l = o.size;
922
+ a = s.size, c = o.size;
923
923
  break;
924
924
  case "countFiles":
925
- a = s.countFiles, l = o.countFiles;
925
+ a = s.countFiles, c = o.countFiles;
926
926
  break;
927
927
  }
928
928
  if (a == null) {
929
- if (l == null)
929
+ if (c == null)
930
930
  continue;
931
931
  return 1;
932
932
  }
933
- if (l == null)
933
+ if (c == null)
934
934
  return -1;
935
- const c = a > l ? 1 : a < l ? -1 : 0;
936
- if (c !== 0)
937
- return i.desc ? -c : c;
935
+ const l = a > c ? 1 : a < c ? -1 : 0;
936
+ if (l !== 0)
937
+ return i.desc ? -l : l;
938
938
  }
939
939
  return 0;
940
940
  }) : r;
941
941
  }
942
- function Tr(r, t) {
943
- const s = Mr(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
942
+ function Er(r, t) {
943
+ const s = Nr(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
946
  for (let n = 0, i = o.length; n < i; n++) {
@@ -967,9 +967,9 @@ function Tr(r, t) {
967
967
  const a = s[n];
968
968
  e += `
969
969
  `;
970
- for (let l = 0, c = o.length; l < c; l++) {
971
- const u = o[l];
972
- switch (l > 0 && (e += " | "), u) {
970
+ for (let c = 0, l = o.length; c < l; c++) {
971
+ const u = o[c];
972
+ switch (c > 0 && (e += " | "), u) {
973
973
  case "dateModified":
974
974
  e += a.dateModified ? De(a.dateModified) : "-";
975
975
  break;
@@ -998,9 +998,9 @@ function Tr(r, t) {
998
998
  }
999
999
  return e;
1000
1000
  }
1001
- const Cr = "3.0.11", vr = {
1002
- version: Cr
1003
- }, ao = "Project Tools", lo = "project-tools", co = vr.version, uo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Re = 25e3;
1001
+ const kr = "3.0.13", Or = {
1002
+ version: kr
1003
+ }, fo = "Project Tools", ho = "project-tools", po = Or.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 Er(r, t) {
1098
+ async function Dr(r, t) {
1099
1099
  let s;
1100
1100
  try {
1101
1101
  s = ct.parse(r);
@@ -1110,8 +1110,8 @@ async function Er(r, t) {
1110
1110
  showDirs: n,
1111
1111
  sortBy: i,
1112
1112
  minTimeAgo: a,
1113
- maxTimeAgo: l,
1114
- minTotalSize: c,
1113
+ maxTimeAgo: c,
1114
+ minTotalSize: l,
1115
1115
  maxTotalSize: u
1116
1116
  } = s;
1117
1117
  if (s.fields && s.fields.length > 0 && !s.fields.includes("path"))
@@ -1128,7 +1128,7 @@ async function Er(r, t) {
1128
1128
  };
1129
1129
  }) ?? null;
1130
1130
  (!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
1131
- const h = d?.map((g) => g.field) || [], m = R.resolve(
1131
+ const h = d?.map((g) => g.field) || [], m = F.resolve(
1132
1132
  t.workingDir || "",
1133
1133
  s.rootDir || ""
1134
1134
  );
@@ -1153,36 +1153,36 @@ async function Er(r, t) {
1153
1153
  size: f.includes("size") || h.includes("size"),
1154
1154
  countFiles: f.includes("countFiles") || h.includes("countFiles")
1155
1155
  };
1156
- let E = null, b = null;
1157
- if (a || l)
1156
+ let N = null, b = null;
1157
+ if (a || c)
1158
1158
  try {
1159
- const x = Date.now(), T = l ? x - Fe(l) : null, v = a ? x - Fe(a) : null;
1160
- E = [T, v];
1159
+ const x = Date.now(), T = c ? x - Fe(c) : null, v = a ? x - Fe(a) : null;
1160
+ N = [T, v];
1161
1161
  } catch (x) {
1162
1162
  return {
1163
1163
  error: x instanceof Error ? x.message : "Unknown error parsing time ago filter"
1164
1164
  };
1165
1165
  }
1166
- if (c || u)
1166
+ if (l || u)
1167
1167
  try {
1168
- const x = c ? Be(c) : null, T = u ? Be(u) : null;
1168
+ const x = l ? Be(l) : null, T = u ? Be(u) : null;
1169
1169
  b = [x, T];
1170
1170
  } catch (x) {
1171
1171
  return {
1172
1172
  error: x instanceof Error ? x.message : "Unknown error parsing size filter"
1173
1173
  };
1174
1174
  }
1175
- const $ = await Ir({
1175
+ const $ = await vr({
1176
1176
  rootDir: m || null,
1177
1177
  globs: w,
1178
1178
  result: M,
1179
- dateModified: E,
1179
+ dateModified: N,
1180
1180
  totalSize: b
1181
1181
  });
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: Tr($, {
1185
+ output: Er($, {
1186
1186
  sort: d,
1187
1187
  fields: f,
1188
1188
  totals: !0
@@ -1192,7 +1192,7 @@ async function Er(r, t) {
1192
1192
  return { error: g instanceof Error ? g.message : "Unknown error" };
1193
1193
  }
1194
1194
  }
1195
- function Nr(r, t) {
1195
+ function Rr(r, t) {
1196
1196
  r(
1197
1197
  "fs-list",
1198
1198
  {
@@ -1201,19 +1201,19 @@ function Nr(r, t) {
1201
1201
  inputSchema: ct.shape
1202
1202
  },
1203
1203
  async (s) => {
1204
- const o = await Er(s, t);
1204
+ const o = await Dr(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)}`;
1208
1208
  }
1209
1209
  );
1210
1210
  }
1211
- const le = /* @__PURE__ */ new Map();
1212
- function ie(r) {
1213
- return le.has(r) || le.set(r, {
1211
+ const ce = /* @__PURE__ */ new Map();
1212
+ function Z(r) {
1213
+ return ce.has(r) || ce.set(r, {
1214
1214
  fsSnapshotQueries: /* @__PURE__ */ new Map(),
1215
1215
  fsSnapshots: /* @__PURE__ */ new Map()
1216
- }), le.get(r);
1216
+ }), ce.get(r);
1217
1217
  }
1218
1218
  function Le(r) {
1219
1219
  const t = r.match(
@@ -1270,7 +1270,7 @@ function Pe(r) {
1270
1270
  );
1271
1271
  }
1272
1272
  }
1273
- const ye = p.object({
1273
+ const be = p.object({
1274
1274
  name: p.string().describe(
1275
1275
  "Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
1276
1276
  ),
@@ -1307,14 +1307,14 @@ const ye = p.object({
1307
1307
  "dateModified"
1308
1308
  ].map((r, t) => [r, t])
1309
1309
  );
1310
- function kr(r, t) {
1310
+ function Fr(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
  }
1314
1314
  async function ut(r, t, s) {
1315
1315
  let o;
1316
1316
  try {
1317
- o = ye.parse(r);
1317
+ o = be.parse(r);
1318
1318
  } catch (h) {
1319
1319
  return {
1320
1320
  error: B(h)
@@ -1325,16 +1325,16 @@ async function ut(r, t, s) {
1325
1325
  globs: n,
1326
1326
  types: i,
1327
1327
  minTimeAgo: a,
1328
- maxTimeAgo: l,
1329
- minTotalSize: c,
1328
+ maxTimeAgo: c,
1329
+ minTotalSize: l,
1330
1330
  maxTotalSize: u
1331
1331
  } = o;
1332
1332
  if (!s.sessionId)
1333
1333
  return {
1334
1334
  error: "Session ID is required"
1335
1335
  };
1336
- const f = ie(s.sessionId), d = H(
1337
- R.resolve(t.workingDir || "", o.rootDir || "")
1336
+ const f = Z(s.sessionId), d = H(
1337
+ F.resolve(t.workingDir || "", o.rootDir || "")
1338
1338
  );
1339
1339
  try {
1340
1340
  try {
@@ -1347,36 +1347,36 @@ async function ut(r, t, s) {
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(kr);
1350
+ h.includes("name") || h.push("name"), h.sort(Fr);
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 || l)
1357
+ if (a || c)
1358
1358
  try {
1359
- const S = Date.now(), x = l ? S - Le(l) : null, T = a ? S - Le(a) : null;
1359
+ const S = Date.now(), x = c ? S - Le(c) : null, T = a ? S - Le(a) : null;
1360
1360
  w = [x, T];
1361
1361
  } catch (S) {
1362
1362
  return {
1363
1363
  error: S instanceof Error ? S.message : "Unknown error parsing time ago filter"
1364
1364
  };
1365
1365
  }
1366
- if (c || u)
1366
+ if (l || u)
1367
1367
  try {
1368
- const S = c ? Pe(c) : null, x = u ? Pe(u) : null;
1368
+ const S = l ? Pe(l) : null, x = u ? Pe(u) : null;
1369
1369
  M = [S, x];
1370
1370
  } catch (S) {
1371
1371
  return {
1372
1372
  error: S instanceof Error ? S.message : "Unknown error parsing size filter"
1373
1373
  };
1374
1374
  }
1375
- const E = i ? i.includes("file") : !0, b = i ? i.includes("dir") : !0, $ = {
1375
+ const N = i ? i.includes("file") : !0, b = i ? i.includes("dir") : !0, $ = {
1376
1376
  name: e,
1377
1377
  rootDir: d,
1378
1378
  globs: y,
1379
- matchFiles: E,
1379
+ matchFiles: N,
1380
1380
  matchDirs: b,
1381
1381
  dateModified: w,
1382
1382
  totalSize: M,
@@ -1391,13 +1391,13 @@ async function ut(r, t, s) {
1391
1391
  };
1392
1392
  }
1393
1393
  }
1394
- function Or(r, t) {
1394
+ function Br(r, t) {
1395
1395
  r(
1396
1396
  "fs-snapshot-query-create",
1397
1397
  {
1398
1398
  title: "Create Filesystem Snapshot Query",
1399
1399
  description: "Create a filesystem snapshot query. Prefer fs-snapshot-browse if you need to immediately create a query, snapshot and browse it",
1400
- inputSchema: ye.shape
1400
+ inputSchema: be.shape
1401
1401
  },
1402
1402
  async (s, o) => {
1403
1403
  const e = await ut(s, t, o);
@@ -1407,7 +1407,7 @@ function Or(r, t) {
1407
1407
  }
1408
1408
  );
1409
1409
  }
1410
- function ne(r) {
1410
+ function ae(r) {
1411
1411
  const { idToNode: t, idToChildIds: s } = r, o = t.get(null);
1412
1412
  if (o == null)
1413
1413
  throw new Error(
@@ -1436,13 +1436,13 @@ function ne(r) {
1436
1436
  else
1437
1437
  throw new Error("Impossible behavior: node not found in idToNode");
1438
1438
  const a = s.get(i);
1439
- return a == null ? null : a.map((l) => {
1440
- const c = t.get(l);
1441
- if (c == null)
1439
+ return a == null ? null : a.map((c) => {
1440
+ const l = t.get(c);
1441
+ if (l == null)
1442
1442
  throw new Error(
1443
- `Child node with id '${l}' not found in idToNode`
1443
+ `Child node with id '${c}' not found in idToNode`
1444
1444
  );
1445
- return c;
1445
+ return l;
1446
1446
  });
1447
1447
  }
1448
1448
  };
@@ -1450,13 +1450,13 @@ function ne(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), l = a == null ? null : dt(r, a, s), c = s(i, l);
1454
- c != null && (o == null && (o = []), o.push(c));
1453
+ const i = t[e], a = r(i), c = a == null ? null : dt(r, a, s), l = s(i, c);
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(), l = dt(
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(
1460
1460
  s,
1461
1461
  o,
1462
1462
  (u, f) => {
@@ -1470,24 +1470,24 @@ function ft(r) {
1470
1470
  f.map((h) => i.get(h))
1471
1471
  ), d;
1472
1472
  }
1473
- ), c = e(null, l);
1474
- if (c == null)
1473
+ ), l = e(null, c);
1474
+ if (l == null)
1475
1475
  throw new Error("Impossible behavior: rootNode == null");
1476
- return n.set(null, c), l != null && a.set(
1476
+ return n.set(null, l), c != null && a.set(
1477
1477
  null,
1478
- l.map((u) => i.get(u))
1478
+ c.map((u) => i.get(u))
1479
1479
  ), {
1480
1480
  idToNode: n,
1481
1481
  idToChildIds: a
1482
1482
  };
1483
1483
  }
1484
- function he(r) {
1484
+ function pe(r) {
1485
1485
  return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
1486
1486
  }
1487
- async function Dr(r) {
1488
- const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = R.resolve(r.rootDir || "."), n = {
1487
+ async function Lr(r) {
1488
+ const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = F.resolve(r.rootDir || "."), n = {
1489
1489
  path: ".",
1490
- name: R.basename(o),
1490
+ name: F.basename(o),
1491
1491
  type: "dir",
1492
1492
  isMatched: !1,
1493
1493
  dateModified: null,
@@ -1506,11 +1506,11 @@ async function Dr(r) {
1506
1506
  rootDir: o,
1507
1507
  noCase: !0
1508
1508
  }),
1509
- handlePath: async ({ path: a, stat: l, itemStat: c }) => {
1510
- const u = R.relative(o, a), f = l.isDirectory(), d = l.isFile();
1509
+ handlePath: async ({ path: a, stat: c, itemStat: l }) => {
1510
+ const u = F.relative(o, a), f = c.isDirectory(), d = c.isFile();
1511
1511
  if (!f && !d)
1512
1512
  return !0;
1513
- const h = he(u || "."), m = f ? "dir" : "file", g = f ? null : l.mtimeMs, y = l.size;
1513
+ const h = pe(u || "."), m = f ? "dir" : "file", g = f ? null : c.mtimeMs, y = c.size;
1514
1514
  let w = !0;
1515
1515
  if (d && !r.matchFiles && (w = !1), f && !r.matchDirs && (w = !1), w && d && r.dateModified && g != null) {
1516
1516
  const [$, S] = r.dateModified;
@@ -1521,12 +1521,12 @@ async function Dr(r) {
1521
1521
  ($ != null && y < $ || S != null && y > S) && (w = !1);
1522
1522
  }
1523
1523
  if (f && !w) {
1524
- if (!(c.countFiles && c.countFiles > 0)) return !1;
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: R.basename(a),
1529
+ name: F.basename(a),
1530
1530
  type: m,
1531
1531
  dateModified: g,
1532
1532
  size: y,
@@ -1535,16 +1535,16 @@ async function Dr(r) {
1535
1535
  if (h == null)
1536
1536
  return n.dateModified = g, n.size = y, n.isMatched = w, !0;
1537
1537
  t.set(h, M);
1538
- const E = he(H(R.dirname(h)));
1539
- let b = s.get(E);
1540
- return b || (b = [], s.set(E, b)), b.push(h), !0;
1538
+ const N = pe(H(F.dirname(h)));
1539
+ let b = s.get(N);
1540
+ return b || (b = [], s.set(N, b)), b.push(h), !0;
1541
1541
  }
1542
1542
  }), {
1543
1543
  idToNode: t,
1544
1544
  idToChildIds: s
1545
1545
  };
1546
1546
  }
1547
- const Rr = [
1547
+ const Pr = [
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 Rr = [
1567
1567
  // max: 2,
1568
1568
  // },
1569
1569
  ];
1570
- function ze(r, t = Rr) {
1570
+ function ze(r, t = Pr) {
1571
1571
  const s = r.length;
1572
1572
  if (s === 0) return 0;
1573
1573
  const o = t.length;
@@ -1577,13 +1577,13 @@ function ze(r, t = Rr) {
1577
1577
  for (; n < s; ) {
1578
1578
  const i = r.charCodeAt(n);
1579
1579
  let a = !1;
1580
- for (let l = 0; l < o; l++) {
1581
- const c = t[l];
1582
- if (c.match(i)) {
1580
+ for (let c = 0; c < o; c++) {
1581
+ const l = t[c];
1582
+ if (l.match(i)) {
1583
1583
  let u = 1;
1584
- for (; ++n < s && c.match(r.charCodeAt(n)) && u < c.max; )
1584
+ for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
1585
1585
  u++;
1586
- if (u >= c.min) {
1586
+ if (u >= l.min) {
1587
1587
  e++, a = !0;
1588
1588
  break;
1589
1589
  }
@@ -1597,21 +1597,21 @@ function ht(r) {
1597
1597
  let t = 0;
1598
1598
  return t += ze(r.textOpen) + 1, r.textClose != null && (t += ze(r.textClose) + 1), r.indent && (t += 1), t;
1599
1599
  }
1600
- const Ue = ["B", "KB", "MB", "GB", "TB"], _e = 1024;
1601
- function Fr(r) {
1600
+ const Ue = ["B", "KB", "MB", "GB", "TB"], qe = 1024;
1601
+ function Ar(r) {
1602
1602
  if (r == null) return "-";
1603
1603
  let t = r ?? 0, s = 0;
1604
- for (; t >= _e && s < Ue.length - 1; )
1605
- t /= _e, s++;
1604
+ for (; t >= qe && s < Ue.length - 1; )
1605
+ t /= qe, s++;
1606
1606
  return `${s === 0 ? t.toString() : t.toFixed(2)}${Ue[s]}`;
1607
1607
  }
1608
- function Br(r) {
1608
+ function zr(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), l = Math.floor(i / 30), c = Math.floor(i / 365);
1612
- return c > 0 ? `${c}Y` : l > 0 ? `${l}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), 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`;
1613
1613
  }
1614
- function Lr(r) {
1614
+ function Ur(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)
@@ -1624,26 +1624,26 @@ function Lr(r) {
1624
1624
  }
1625
1625
  };
1626
1626
  }
1627
- function Pr(r) {
1627
+ function qr(r) {
1628
1628
  const t = r.fields ?? [];
1629
1629
  return function(o, e) {
1630
1630
  let n = "", i, a = 0;
1631
- const l = e ? e.length : 0;
1632
- let c = 1, u, f = 0, d = 0, h = 0, m = 0, g = null, y, w, M;
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;
1633
1633
  if (e)
1634
1634
  for (let b = 0; b < e.length; b++) {
1635
1635
  const $ = e[b];
1636
- a += $.countMatched, c += $.countTotal, f += $.tokens, d += $.tokensTotal, h += $.size, m += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1636
+ a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, h += $.size, m += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1637
1637
  }
1638
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);
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 ? Br(g) : "-";
1643
+ n += g ? zr(g) : "-";
1644
1644
  break;
1645
1645
  case "size":
1646
- n += Fr(h);
1646
+ n += Ar(h);
1647
1647
  break;
1648
1648
  case "type":
1649
1649
  n += y;
@@ -1656,31 +1656,31 @@ function Pr(r) {
1656
1656
  break;
1657
1657
  }
1658
1658
  }
1659
- const E = {
1659
+ const N = {
1660
1660
  indent: !0,
1661
1661
  textOpen: n,
1662
1662
  textClose: null
1663
1663
  };
1664
- return u = ht(E), d += u, {
1664
+ return u = ht(N), d += u, {
1665
1665
  type: y,
1666
1666
  name: w,
1667
1667
  path: M,
1668
1668
  isMatched: i,
1669
1669
  countMatched: a,
1670
- countChilds: l,
1671
- countTotal: c,
1670
+ countChilds: c,
1671
+ countTotal: l,
1672
1672
  tokens: u,
1673
1673
  tokensChilds: f,
1674
1674
  tokensTotal: d,
1675
- text: E,
1675
+ text: N,
1676
1676
  size: h,
1677
1677
  countFiles: m,
1678
1678
  dateModified: g
1679
1679
  };
1680
1680
  };
1681
1681
  }
1682
- async function Ar(r) {
1683
- const t = await Dr(r), s = ne(t), o = s.getChilds(s.root), e = ft({
1682
+ async function _r(r) {
1683
+ const t = await Lr(r), s = ae(t), o = s.getChilds(s.root), e = ft({
1684
1684
  getId: (i) => {
1685
1685
  const a = s.getId(i);
1686
1686
  if (a == null)
@@ -1690,26 +1690,26 @@ async function Ar(r) {
1690
1690
  return a;
1691
1691
  },
1692
1692
  getChilds: (i) => s.getChilds(i),
1693
- createSnapshotNode: Pr(r),
1693
+ createSnapshotNode: qr(r),
1694
1694
  rootNodes: o ?? []
1695
- }), n = Lr(e.idToNode);
1695
+ }), n = Ur(e.idToNode);
1696
1696
  return e.idToChildIds.forEach((i) => {
1697
1697
  i.sort(n);
1698
- }), ne(e);
1698
+ }), ae(e);
1699
1699
  }
1700
- const ae = p.object({
1700
+ const X = p.object({
1701
1701
  queryName: p.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
1702
- query: ye.optional().describe(
1702
+ query: be.optional().describe(
1703
1703
  "Filesystem snapshot query creation options JSON to automatically create query"
1704
1704
  ),
1705
1705
  name: p.string().describe(
1706
1706
  "Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
1707
1707
  )
1708
1708
  });
1709
- async function be(r, t, s) {
1709
+ async function le(r, t, s) {
1710
1710
  let o;
1711
1711
  try {
1712
- o = ae.parse(r);
1712
+ o = X.parse(r);
1713
1713
  } catch (u) {
1714
1714
  return {
1715
1715
  error: B(u)
@@ -1720,19 +1720,19 @@ async function be(r, t, s) {
1720
1720
  return {
1721
1721
  error: "Session ID is required"
1722
1722
  };
1723
- const a = ie(s.sessionId);
1723
+ const a = Z(s.sessionId);
1724
1724
  if (n && i)
1725
1725
  return {
1726
1726
  error: "Either queryName or query must be provided, not both"
1727
1727
  };
1728
- let l, c = !1;
1728
+ let c, l = !1;
1729
1729
  if (n) {
1730
1730
  const u = a.fsSnapshotQueries.get(n);
1731
1731
  if (!u)
1732
1732
  return {
1733
1733
  error: `Filesystem snapshot query "${n}" not found`
1734
1734
  };
1735
- l = u;
1735
+ c = u;
1736
1736
  } else if (i) {
1737
1737
  const u = await ut(
1738
1738
  i,
@@ -1743,20 +1743,20 @@ async function be(r, t, s) {
1743
1743
  return {
1744
1744
  error: u.error
1745
1745
  };
1746
- l = u.snapshotQuery, c = !0;
1746
+ c = u.snapshotQuery, l = !0;
1747
1747
  } else
1748
1748
  return {
1749
1749
  error: "Either queryName or query must be provided"
1750
1750
  };
1751
1751
  try {
1752
- const u = await Ar(l), f = {
1752
+ const u = await _r(c), f = {
1753
1753
  name: e,
1754
- query: l,
1754
+ query: c,
1755
1755
  tree: u
1756
1756
  };
1757
1757
  return a.fsSnapshots.set(e, f), {
1758
1758
  fsSnapshot: f,
1759
- queryCreated: c
1759
+ queryCreated: l
1760
1760
  };
1761
1761
  } catch (u) {
1762
1762
  return {
@@ -1764,16 +1764,16 @@ async function be(r, t, s) {
1764
1764
  };
1765
1765
  }
1766
1766
  }
1767
- function zr(r, t) {
1767
+ function Gr(r, t) {
1768
1768
  r(
1769
1769
  "fs-snapshot-create",
1770
1770
  {
1771
1771
  title: "Create Filesystem Snapshot",
1772
1772
  description: "Create a filesystem snapshot. Use this to capture filesystem state for later browsing. Prefer fs-snapshot-browse if you need to immediately create and browse a snapshot",
1773
- inputSchema: ae.shape
1773
+ inputSchema: X.shape
1774
1774
  },
1775
1775
  async (s, o) => {
1776
- const e = await be(s, t, o);
1776
+ const e = await le(s, t, o);
1777
1777
  if (e.error != null)
1778
1778
  return `Method: fs-snapshot-create(${JSON.stringify(s)})
1779
1779
  ❌ Error: ${e.error}`;
@@ -1784,7 +1784,7 @@ function zr(r, t) {
1784
1784
  }
1785
1785
  );
1786
1786
  }
1787
- class Ur {
1787
+ class Jr {
1788
1788
  _first = null;
1789
1789
  _last = null;
1790
1790
  _size = 0;
@@ -1807,17 +1807,17 @@ class Ur {
1807
1807
  return this._size;
1808
1808
  }
1809
1809
  }
1810
- function _r(r) {
1811
- const t = new Ur(), {
1810
+ function jr(r) {
1811
+ const t = new Jr(), {
1812
1812
  tree: s,
1813
1813
  limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
1814
1814
  indexRangeGroupStrategy: a
1815
- } = r, l = s.getChilds(s.root);
1816
- l != null && l.length > 0 && t.enqueue({
1815
+ } = r, c = s.getChilds(s.root);
1816
+ c != null && c.length > 0 && t.enqueue({
1817
1817
  reportNode: null,
1818
1818
  node: s.root
1819
1819
  });
1820
- let c = null, u = 0, f = 0;
1820
+ let l = null, u = 0, f = 0;
1821
1821
  for (; !t.isEmpty(); ) {
1822
1822
  const { reportNode: d, node: h } = t.dequeue(), m = s.getChilds(h);
1823
1823
  if (m == null || h.countChilds === 0 || m.length !== h.countChilds)
@@ -1830,11 +1830,11 @@ function _r(r) {
1830
1830
  const y = g * a.tokens;
1831
1831
  if (o != null && u + h.countChilds + g > o || e != null && f + h.tokensChilds + y > e) {
1832
1832
  const w = [];
1833
- let M = null, E = 0;
1833
+ let M = null, N = 0;
1834
1834
  for (let $ = 0, S = m.length; $ < S; $++) {
1835
- const x = m[$], T = E * a.tokens;
1835
+ const x = m[$], T = N * a.tokens;
1836
1836
  M != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
1837
- !(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null && M.countGrouped + 1 + E > n || i != null && M.tokensGrouped + x.tokens + T > i) && (w.push(M), u += 1, f += a.tokens, M = null, E = 0), M = a.add(M, x, $), x.countChilds > 0 && (E += 1);
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);
1838
1838
  }
1839
1839
  M != null && (w.push(M), u += 1, f += a.tokens);
1840
1840
  const b = w.map(($) => ({
@@ -1845,22 +1845,22 @@ function _r(r) {
1845
1845
  throw new Error("Impossible behavior: reportNode.childs != null");
1846
1846
  d.childs = b;
1847
1847
  } else {
1848
- if (c != null)
1848
+ if (l != null)
1849
1849
  throw new Error("Impossible behavior: reportRootNodes != null");
1850
- c = b;
1850
+ l = b;
1851
1851
  }
1852
1852
  } else {
1853
1853
  u += h.countChilds, f += h.tokensChilds;
1854
1854
  const w = [];
1855
1855
  for (let M = 0; M < m.length; M++) {
1856
- const E = m[M], b = {
1857
- text: E.text
1856
+ const N = m[M], b = {
1857
+ text: N.text
1858
1858
  };
1859
1859
  w.push(b);
1860
- const $ = s.getChilds(E);
1860
+ const $ = s.getChilds(N);
1861
1861
  $ != null && $.length > 0 && t.enqueue({
1862
1862
  reportNode: b,
1863
- node: E
1863
+ node: N
1864
1864
  });
1865
1865
  }
1866
1866
  if (d != null) {
@@ -1868,13 +1868,13 @@ function _r(r) {
1868
1868
  throw new Error("Impossible behavior: reportNode.childs != null");
1869
1869
  d.childs = w;
1870
1870
  } else {
1871
- if (c != null)
1871
+ if (l != null)
1872
1872
  throw new Error("Impossible behavior: reportRootNodes != null");
1873
- c = w;
1873
+ l = w;
1874
1874
  }
1875
1875
  }
1876
1876
  }
1877
- return c ?? [];
1877
+ return l ?? [];
1878
1878
  }
1879
1879
  function pt(r) {
1880
1880
  const {
@@ -1891,36 +1891,36 @@ function pt(r) {
1891
1891
  a = d;
1892
1892
  } else
1893
1893
  a = t.root;
1894
- let l, c = t.getChilds(a) ?? [];
1894
+ let c, l = t.getChilds(a) ?? [];
1895
1895
  if (o != null) {
1896
1896
  const [d, h] = o;
1897
- if (d < 0 || h <= d || h >= c.length)
1897
+ if (d < 0 || h <= d || h >= l.length)
1898
1898
  throw new Error(
1899
- `Invalid index range: ${d}-${h} for root nodes length ${c.length}`
1899
+ `Invalid index range: ${d}-${h} for root nodes length ${l.length}`
1900
1900
  );
1901
1901
  const m = [];
1902
1902
  let g = null;
1903
1903
  for (let y = d; y <= h; y++) {
1904
- const w = c[y];
1904
+ const w = l[y];
1905
1905
  m.push(w), g = n.add(g, w, y);
1906
1906
  }
1907
- c = m, l = {
1907
+ l = m, c = {
1908
1908
  ...a,
1909
1909
  text: n.getReportText(g),
1910
1910
  countChilds: g.countGrouped,
1911
1911
  tokensChilds: g.tokensGrouped
1912
1912
  };
1913
1913
  } else
1914
- l = a;
1914
+ c = a;
1915
1915
  const u = {
1916
1916
  countChilds: 1,
1917
- tokensChilds: l.tokens
1917
+ tokensChilds: c.tokens
1918
1918
  }, f = {
1919
1919
  ...t,
1920
1920
  root: u,
1921
- getChilds: (d) => d === u ? [l] : d === l ? c : t.getChilds(d)
1921
+ getChilds: (d) => d === u ? [c] : d === c ? l : t.getChilds(d)
1922
1922
  };
1923
- return _r({
1923
+ return jr({
1924
1924
  tree: f,
1925
1925
  limits: e,
1926
1926
  indexRangeGroupStrategy: n,
@@ -1933,18 +1933,18 @@ function mt(r, t) {
1933
1933
  let s = "";
1934
1934
  function o(e, n) {
1935
1935
  for (let i = 0, a = e.length; i < a; i++) {
1936
- const l = e[i];
1937
- s += n, s += l.text.textOpen + `
1938
- `, l.childs != null && l.childs.length > 0 && o(
1939
- l.childs,
1940
- l.text.indent ? n + " " : n
1941
- ), l.text.textClose != null && (s += n, s += l.text.textClose + `
1936
+ const c = e[i];
1937
+ s += n, s += c.text.textOpen + `
1938
+ `, c.childs != null && c.childs.length > 0 && o(
1939
+ c.childs,
1940
+ c.text.indent ? n + " " : n
1941
+ ), c.text.textClose != null && (s += n, s += c.text.textClose + `
1942
1942
  `);
1943
1943
  }
1944
1944
  }
1945
1945
  return o(r, ""), s;
1946
1946
  }
1947
- class qr {
1947
+ class Kr {
1948
1948
  tokens = 16;
1949
1949
  // +1 indent, +1 for line break
1950
1950
  getReportText = (t) => ({
@@ -1961,7 +1961,7 @@ class qr {
1961
1961
  }
1962
1962
  const gt = p.object({
1963
1963
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
1964
- snapshot: ae.optional().describe(
1964
+ snapshot: X.optional().describe(
1965
1965
  "Filesystem snapshot creation options JSON to automatically create snapshot"
1966
1966
  ),
1967
1967
  parentPath: p.string().optional().describe(
@@ -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 Gr(r, t, s) {
1984
+ async function Wr(r, t, s) {
1985
1985
  let o;
1986
1986
  try {
1987
1987
  o = gt.parse(r);
@@ -1998,12 +1998,12 @@ async function Gr(r, t, s) {
1998
1998
  // maxTokensTotal,
1999
1999
  // maxCountGroup,
2000
2000
  // maxTokensGroup,
2001
- } = o, a = 60, l = 1e3, c = 25, u = 900;
2001
+ } = o, a = 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 = ie(s.sessionId);
2006
+ const f = Z(s.sessionId);
2007
2007
  if (e && n)
2008
2008
  return {
2009
2009
  error: "Either snapshotName or snapshot must be provided, not both"
@@ -2015,7 +2015,7 @@ async function Gr(r, t, s) {
2015
2015
  error: `Filesystem snapshot "${e}" not found`
2016
2016
  };
2017
2017
  } else if (n) {
2018
- const g = await be(
2018
+ const g = await le(
2019
2019
  n,
2020
2020
  t,
2021
2021
  s
@@ -2030,19 +2030,19 @@ async function Gr(r, t, s) {
2030
2030
  error: "Either snapshotName or snapshot must be provided"
2031
2031
  };
2032
2032
  try {
2033
- const g = he(o.parentPath), y = pt({
2033
+ const g = pe(o.parentPath), y = pt({
2034
2034
  tree: d.tree,
2035
2035
  request: {
2036
2036
  parentNodeId: g,
2037
2037
  childsIndexRange: i,
2038
2038
  limits: {
2039
2039
  maxCountTotal: a,
2040
- maxTokensTotal: l,
2041
- maxCountGroup: c,
2040
+ maxTokensTotal: c,
2041
+ maxCountGroup: l,
2042
2042
  maxTokensGroup: u
2043
2043
  }
2044
2044
  },
2045
- indexRangeGroupStrategy: new qr()
2045
+ indexRangeGroupStrategy: new Kr()
2046
2046
  }), w = mt(y);
2047
2047
  return {
2048
2048
  fsSnapshot: d,
@@ -2058,7 +2058,7 @@ async function Gr(r, t, s) {
2058
2058
  };
2059
2059
  }
2060
2060
  }
2061
- function jr(r, t) {
2061
+ function Hr(r, t) {
2062
2062
  r(
2063
2063
  "fs-snapshot-browse",
2064
2064
  {
@@ -2067,7 +2067,7 @@ function jr(r, t) {
2067
2067
  inputSchema: gt.shape
2068
2068
  },
2069
2069
  async (s, o) => {
2070
- const e = await Gr(s, t, o);
2070
+ const e = await Wr(s, t, o);
2071
2071
  if (e.error != null)
2072
2072
  return `Method: fs-snapshot-browse(${JSON.stringify(s)})
2073
2073
  ❌ Error: ${e.error}`;
@@ -2080,8 +2080,8 @@ function jr(r, t) {
2080
2080
  `, n += `Parent path: ${"./" + (e.parentPath ?? "")}
2081
2081
  `, n += `Fields: ${e.fsSnapshot.query.fields.map((i) => i === "dateModified" ? "lastModified" : i).join(" ")}
2082
2082
  `, e.childsIndexRange) {
2083
- const [i, a] = e.childsIndexRange, c = (e.parentPath ? e.fsSnapshot.tree.getNode(e.parentPath) : e.fsSnapshot.tree.root).countChilds;
2084
- n += ` Showing indexes: ${i}-${a} of ${c}
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}
2085
2085
  `;
2086
2086
  }
2087
2087
  return n += `
@@ -2089,7 +2089,7 @@ ${e.report}`, n;
2089
2089
  }
2090
2090
  );
2091
2091
  }
2092
- function Jr(r) {
2092
+ 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);
@@ -2100,34 +2100,34 @@ function Jr(r) {
2100
2100
  }
2101
2101
  return e(s.root), t;
2102
2102
  }
2103
- const qe = /* @__PURE__ */ new Map();
2104
- function Kr(r) {
2103
+ const _e = /* @__PURE__ */ new Map();
2104
+ function Qr(r) {
2105
2105
  const t = H(r);
2106
- let s = qe.get(t);
2107
- return s == null && (s = new Ut(), qe.set(t, s)), s;
2106
+ let s = _e.get(t);
2107
+ return s == null && (s = new Jt(), _e.set(t, s)), s;
2108
2108
  }
2109
- async function Wr(r) {
2109
+ async function Yr(r) {
2110
2110
  const { filePath: t, func: s } = r;
2111
- return Kr(t).lock(
2111
+ return Qr(t).lock(
2112
2112
  () => Y({
2113
- pool: we,
2113
+ pool: ye,
2114
2114
  count: 1,
2115
2115
  func: s
2116
2116
  })
2117
2117
  );
2118
2118
  }
2119
- const Ge = 10, X = 48, je = 57, ce = 36, Hr = 38, Qr = 39, Yr = 60, Vr = 62, Zr = 96, ee = 0, Je = 1, Ke = 2, We = 3, He = 4, Xr = 5;
2120
- function es(r) {
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) {
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 = [], l = [];
2125
- let c = null, u = null, f = null, d = 0;
2124
+ const i = n.length, a = [], c = [];
2125
+ let l = null, u = null, f = null, d = 0;
2126
2126
  if (o != null) {
2127
2127
  const b = o.length;
2128
2128
  let $ = !1;
2129
2129
  for (let S = 0; S < b; S++)
2130
- if (o.charCodeAt(S) === ce) {
2130
+ if (o.charCodeAt(S) === ue) {
2131
2131
  $ = !0;
2132
2132
  break;
2133
2133
  }
@@ -2135,39 +2135,39 @@ function es(r) {
2135
2135
  u = [], f = [];
2136
2136
  let S = 0, x = 0;
2137
2137
  for (; x < b; ) {
2138
- if (o.charCodeAt(x) !== ce || x + 1 >= b) {
2138
+ if (o.charCodeAt(x) !== ue || x + 1 >= b) {
2139
2139
  x++;
2140
2140
  continue;
2141
2141
  }
2142
2142
  const T = o.charCodeAt(x + 1);
2143
2143
  let v = -1, L = 0, k = 2;
2144
- if (T === ce)
2145
- v = ee, L = "$";
2146
- else if (T === Hr)
2147
- v = Je;
2148
- else if (T === Zr)
2144
+ if (T === ue)
2145
+ v = re, L = "$";
2146
+ else if (T === Vr)
2147
+ v = je;
2148
+ else if (T === ts)
2149
2149
  v = Ke;
2150
- else if (T === Qr)
2150
+ else if (T === Zr)
2151
2151
  v = We;
2152
- else if (T >= X && T <= je) {
2152
+ else if (T >= te && T <= Je) {
2153
2153
  let I = x + 2;
2154
2154
  for (; I < b; ) {
2155
2155
  const C = o.charCodeAt(I);
2156
- if (C < X || C > je) break;
2156
+ if (C < te || C > Je) break;
2157
2157
  I++;
2158
2158
  }
2159
2159
  v = He, L = o.substring(x + 1, I), k = I - x;
2160
- } else if (T === Yr) {
2160
+ } else if (T === Xr) {
2161
2161
  let I = x + 2;
2162
- for (; I < b && o.charCodeAt(I) !== Vr; )
2162
+ for (; I < b && o.charCodeAt(I) !== es; )
2163
2163
  I++;
2164
- I < b && I > x + 2 && (v = Xr, L = o.substring(x + 2, I), k = I + 1 - x);
2164
+ I < b && I > x + 2 && (v = rs, L = o.substring(x + 2, I), k = I + 1 - x);
2165
2165
  }
2166
- v >= 0 ? (x > S && (u.push(ee), 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), f.push(o.substring(S, x))), u.push(v), f.push(L), x += k, S = x) : x++;
2167
2167
  }
2168
- S < b && (u.push(ee), f.push(o.substring(S))), d = u.length;
2168
+ S < b && (u.push(re), f.push(o.substring(S))), d = u.length;
2169
2169
  } else
2170
- c = o;
2170
+ l = o;
2171
2171
  }
2172
2172
  let h = "", m = 0, g = 0;
2173
2173
  s.lastIndex = 0;
@@ -2180,14 +2180,14 @@ function es(r) {
2180
2180
  else {
2181
2181
  let I = 0, C = i - 1;
2182
2182
  for (; I < C; ) {
2183
- const N = I + C + 1 >> 1;
2184
- n[N] <= b ? I = N : C = N - 1;
2183
+ const E = I + C + 1 >> 1;
2184
+ n[E] <= b ? I = E : C = E - 1;
2185
2185
  }
2186
2186
  if (T = I, S > 0) {
2187
- const N = x - 1;
2187
+ const E = x - 1;
2188
2188
  for (C = i - 1; I < C; ) {
2189
2189
  const O = I + C + 1 >> 1;
2190
- n[O] <= N ? I = O : C = O - 1;
2190
+ n[O] <= E ? I = O : C = O - 1;
2191
2191
  }
2192
2192
  v = I + 1;
2193
2193
  } else
@@ -2201,18 +2201,18 @@ function es(r) {
2201
2201
  }), o != null) {
2202
2202
  h += t.substring(m, b);
2203
2203
  let I;
2204
- if (c != null)
2205
- I = c;
2204
+ if (l != null)
2205
+ I = l;
2206
2206
  else {
2207
2207
  I = "";
2208
- const N = y.groups, O = y.length - 1;
2208
+ const E = y.groups, O = y.length - 1;
2209
2209
  for (let K = 0; K < d; K++) {
2210
- const _ = u[K], A = f[K];
2211
- switch (_) {
2212
- case ee:
2210
+ const q = u[K], A = f[K];
2211
+ switch (q) {
2212
+ case re:
2213
2213
  I += A;
2214
2214
  break;
2215
- case Je:
2215
+ case je:
2216
2216
  I += $;
2217
2217
  break;
2218
2218
  case Ke:
@@ -2222,9 +2222,9 @@ function es(r) {
2222
2222
  I += t.substring(x);
2223
2223
  break;
2224
2224
  case He: {
2225
- const P = A, U = P.length, z = P.charCodeAt(0) - X;
2225
+ const P = A, U = P.length, z = P.charCodeAt(0) - te;
2226
2226
  if (U >= 2) {
2227
- const q = P.charCodeAt(1) - X, D = z * 10 + q;
2227
+ const _ = P.charCodeAt(1) - te, D = z * 10 + _;
2228
2228
  if (D >= 1 && D <= O) {
2229
2229
  I += y[D] ?? "", U > 2 && (I += P.substring(2));
2230
2230
  break;
@@ -2234,13 +2234,13 @@ function es(r) {
2234
2234
  break;
2235
2235
  }
2236
2236
  default:
2237
- N != null ? I += N[A] ?? "" : I += "$<" + A + ">";
2237
+ E != null ? I += E[A] ?? "" : I += "$<" + A + ">";
2238
2238
  }
2239
2239
  }
2240
2240
  }
2241
2241
  h += I;
2242
2242
  const C = b + g;
2243
- l.push({
2243
+ c.push({
2244
2244
  offset: [C, C + I.length],
2245
2245
  lines: [0, 0],
2246
2246
  linesOffset: [0, 0]
@@ -2255,106 +2255,106 @@ function es(r) {
2255
2255
  const w = h.length, M = [0];
2256
2256
  for (let b = 0; b < w; b++)
2257
2257
  h.charCodeAt(b) === Ge && b + 1 < w && M.push(b + 1);
2258
- const E = M.length;
2259
- for (let b = 0, $ = l.length; b < $; b++) {
2260
- const S = l[b], x = S.offset[0], T = S.offset[1];
2258
+ const N = M.length;
2259
+ for (let b = 0, $ = c.length; b < $; b++) {
2260
+ const S = c[b], x = S.offset[0], T = S.offset[1];
2261
2261
  let v, L, k, I;
2262
- if (E === 1)
2262
+ if (N === 1)
2263
2263
  v = 0, L = 1, k = 0, I = w;
2264
2264
  else {
2265
- let C = 0, N = E - 1;
2266
- for (; C < N; ) {
2267
- const O = C + N + 1 >> 1;
2268
- M[O] <= x ? C = O : N = O - 1;
2265
+ let C = 0, E = N - 1;
2266
+ for (; C < E; ) {
2267
+ const O = C + E + 1 >> 1;
2268
+ M[O] <= x ? C = O : E = O - 1;
2269
2269
  }
2270
2270
  if (v = C, T > x) {
2271
2271
  const O = T - 1;
2272
- for (N = E - 1; C < N; ) {
2273
- const K = C + N + 1 >> 1;
2274
- M[K] <= O ? C = K : N = K - 1;
2272
+ for (E = N - 1; C < E; ) {
2273
+ const K = C + E + 1 >> 1;
2274
+ M[K] <= O ? C = K : E = K - 1;
2275
2275
  }
2276
2276
  L = C + 1;
2277
2277
  } else
2278
2278
  L = v + 1;
2279
- k = M[v], I = L < E ? M[L] : w;
2279
+ k = M[v], I = L < N ? M[L] : w;
2280
2280
  }
2281
2281
  S.lines[0] = v, S.lines[1] = L, S.linesOffset[0] = k, S.linesOffset[1] = I;
2282
2282
  }
2283
2283
  return {
2284
2284
  search: { content: t, matches: a },
2285
- replace: { content: h, matches: l }
2285
+ replace: { content: h, matches: c }
2286
2286
  };
2287
2287
  }
2288
- function te(r, t, s, o) {
2288
+ function se(r, t, s, o) {
2289
2289
  let e = 0, n = 0;
2290
2290
  for (let u = 0; u < s; u++)
2291
2291
  r.charCodeAt(u) === 10 && (n = u + 1, e++);
2292
2292
  const i = e, a = n;
2293
- let l = s;
2294
- for (; l < o; l++)
2295
- r.charCodeAt(l) === 10 && e++;
2296
- const c = e + 1;
2297
- for (; l < t; l++)
2298
- if (r.charCodeAt(l) === 10)
2299
- return { startLine: i, endLine: c, startLineOfs: a, endLineOfs: l + 1 };
2300
- return { startLine: i, endLine: c, startLineOfs: a, endLineOfs: t };
2301
- }
2302
- function ts(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, l = r.search.matches, c = s.matches, u = t.search.matches, f = o.matches, d = c.length, h = u.length, m = [], g = [];
2304
- let y = 0, w = 0, M = 0, E = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, L = 0, k = 0, I = 0, C = 0, N = 0, O = 0, K = 0, _ = 0, A = 0, P = 0, U = 0, z = 0, q = 0, D = 0;
2293
+ let c = s;
2294
+ for (; c < o; c++)
2295
+ r.charCodeAt(c) === 10 && e++;
2296
+ const l = e + 1;
2297
+ for (; c < t; c++)
2298
+ 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
2305
  for (; y < d || w < h; )
2306
- if (y < d && (b = c[y].offset[0], $ = c[y].offset[1]), w < h && (S = u[w].offset[0], x = u[w].offset[1]), y < d && w < h && b < x && S < $) {
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 < $) {
2307
2307
  K = b < S ? b : S, T = $ > x ? $ : x, L = y, k = w, y++, w++;
2308
2308
  do {
2309
- for (v = T; y < d && c[y].offset[0] < T; )
2310
- $ = c[y].offset[1], $ > T && (T = $), y++;
2309
+ for (v = T; y < d && l[y].offset[0] < T; )
2310
+ $ = l[y].offset[1], $ > T && (T = $), y++;
2311
2311
  for (; w < h && u[w].offset[0] < T; )
2312
2312
  x = u[w].offset[1], x > T && (T = x), w++;
2313
2313
  } while (T !== v);
2314
- I = 1 / 0, C = -1 / 0, _ = K, A = M;
2315
- for (let j = L; j < y; j++)
2316
- P = l[j].offset[0], U = l[j].offset[1], z = c[j].offset[0], q = c[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 - q + z, _ = q;
2317
- _ < T && (D = _ + A, D < I && (I = D), D = T + A, D > C && (C = D)), M = A, N = 1 / 0, O = -1 / 0, _ = K, A = E;
2318
- for (let j = k; j < w; j++)
2319
- P = u[j].offset[0], U = u[j].offset[1], z = f[j].offset[0], q = f[j].offset[1], _ < P && (D = _ + A, D < N && (N = D), D = P + A, D > O && (O = D)), z < N && (N = z), q > O && (O = q), A += q - z - U + P, _ = U;
2320
- _ < T && (D = _ + A, D < N && (N = D), D = T + A, D > O && (O = D)), E = A;
2321
- const G = te(e, i, I, C);
2314
+ I = 1 / 0, C = -1 / 0, q = K, A = M;
2315
+ 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;
2318
+ 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);
2322
2322
  m.push({
2323
2323
  offset: [I, C],
2324
2324
  lines: [G.startLine, G.endLine],
2325
2325
  linesOffset: [G.startLineOfs, G.endLineOfs]
2326
2326
  });
2327
- const Z = te(n, a, N, O);
2327
+ const ee = se(n, a, E, O);
2328
2328
  g.push({
2329
- offset: [N, O],
2330
- lines: [Z.startLine, Z.endLine],
2331
- linesOffset: [Z.startLineOfs, Z.endLineOfs]
2329
+ offset: [E, O],
2330
+ lines: [ee.startLine, ee.endLine],
2331
+ linesOffset: [ee.startLineOfs, ee.endLineOfs]
2332
2332
  });
2333
2333
  } else if (w >= h || y < d && b <= S) {
2334
- P = l[y].offset[0], U = l[y].offset[1], z = c[y].offset[0], q = c[y].offset[1], N = z + E, O = q + E;
2335
- const G = te(n, a, N, O);
2336
- m.push(l[y]), g.push({
2337
- offset: [N, O],
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);
2336
+ m.push(c[y]), g.push({
2337
+ offset: [E, O],
2338
2338
  lines: [G.startLine, G.endLine],
2339
2339
  linesOffset: [G.startLineOfs, G.endLineOfs]
2340
- }), M += U - P - q + z, y++;
2340
+ }), M += U - P - _ + z, y++;
2341
2341
  } else {
2342
- P = u[w].offset[0], U = u[w].offset[1], z = f[w].offset[0], q = f[w].offset[1], I = P + M, C = U + M;
2343
- const G = te(e, i, I, C);
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);
2344
2344
  m.push({
2345
2345
  offset: [I, C],
2346
2346
  lines: [G.startLine, G.endLine],
2347
2347
  linesOffset: [G.startLineOfs, G.endLineOfs]
2348
- }), g.push(f[w]), E += q - z - U + P, w++;
2348
+ }), g.push(f[w]), N += _ - z - U + P, w++;
2349
2349
  }
2350
2350
  return {
2351
2351
  search: { content: e, matches: m },
2352
2352
  replace: { content: n, matches: g }
2353
2353
  };
2354
2354
  }
2355
- async function rs(r) {
2355
+ async function ns(r) {
2356
2356
  const { filePath: t, operations: s, dryRun: o } = r;
2357
- return s.length === 0 ? { filePath: t, result: null } : Wr({
2357
+ return s.length === 0 ? { filePath: t, result: null } : Yr({
2358
2358
  filePath: t,
2359
2359
  func: async () => {
2360
2360
  let e;
@@ -2369,34 +2369,34 @@ async function rs(r) {
2369
2369
  }
2370
2370
  let n = null, i = !1;
2371
2371
  for (let a = 0; a < s.length; a++) {
2372
- const l = s[a];
2373
- let c;
2372
+ const c = s[a];
2373
+ let l;
2374
2374
  try {
2375
- c = new RegExp(l.pattern, l.flags ?? "");
2375
+ l = new RegExp(c.pattern, c.flags ?? "");
2376
2376
  } catch (d) {
2377
2377
  return {
2378
2378
  filePath: t,
2379
2379
  result: null,
2380
- error: `Invalid RegExp pattern "${l.pattern}": ${d instanceof Error ? d.message : d + ""}`
2380
+ error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
2381
2381
  };
2382
2382
  }
2383
- const u = n?.replace?.content ?? e, f = es({
2383
+ const u = n?.replace?.content ?? e, f = ss({
2384
2384
  content: u,
2385
- pattern: c,
2386
- replacement: l.replacement
2385
+ pattern: l,
2386
+ replacement: c.replacement
2387
2387
  });
2388
- l.replacement != null && (i = !0), n == null ? n = f : n = ts(n, f);
2388
+ c.replacement != null && (i = !0), n == null ? n = f : n = os(n, f);
2389
2389
  }
2390
2390
  if (i && n?.replace != null && !o) {
2391
2391
  const a = n.replace.content;
2392
2392
  if (a !== e)
2393
2393
  try {
2394
2394
  await W.promises.writeFile(t, a, "utf-8");
2395
- } catch (l) {
2395
+ } catch (c) {
2396
2396
  return {
2397
2397
  filePath: t,
2398
2398
  result: n,
2399
- error: `Failed to write file: ${l instanceof Error ? l.message : l + ""}`
2399
+ error: `Failed to write file: ${c instanceof Error ? c.message : c + ""}`
2400
2400
  };
2401
2401
  }
2402
2402
  }
@@ -2404,23 +2404,23 @@ async function rs(r) {
2404
2404
  }
2405
2405
  });
2406
2406
  }
2407
- async function ss(r) {
2407
+ async function yt(r) {
2408
2408
  const { filePaths: t, operations: s, dryRun: o } = r;
2409
2409
  return { results: await Promise.all(
2410
2410
  t.map(
2411
- (n) => rs({ filePath: n, operations: s, dryRun: o })
2411
+ (n) => ns({ filePath: n, operations: s, dryRun: o })
2412
2412
  )
2413
2413
  ) };
2414
2414
  }
2415
- function os(r) {
2415
+ function is(r) {
2416
2416
  if (r.length === 0)
2417
2417
  return [];
2418
2418
  const t = [...r].sort((n, i) => {
2419
- const a = n.lines[0], l = i.lines[0];
2420
- if (a > l) return 1;
2421
- if (a < l) return -1;
2422
- const c = n.lines[1], u = i.lines[1];
2423
- return c > u ? 1 : c < u ? -1 : 0;
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
2424
  }), s = [];
2425
2425
  let o = [...t[0].lines], e = [...t[0].linesOffset];
2426
2426
  for (let n = 1; n < t.length; n++) {
@@ -2435,32 +2435,32 @@ function os(r) {
2435
2435
  linesOffset: e
2436
2436
  }), s;
2437
2437
  }
2438
- const ns = 6;
2439
- function is(r) {
2440
- const { content: t, startLine: s } = r, o = r.padWidth ?? ns;
2438
+ const as = 6;
2439
+ function ls(r) {
2440
+ const { content: t, startLine: s } = r, o = r.padWidth ?? as;
2441
2441
  let e = "", n = 0, i = 0;
2442
2442
  for (; n < t.length; ) {
2443
2443
  const a = t.indexOf(`
2444
- `, n), l = a === -1 ? t.length : a + 1;
2445
- e += String(s + i + 1).padStart(o) + "→" + t.substring(n, l), n = l, i++;
2444
+ `, n), c = a === -1 ? t.length : a + 1;
2445
+ e += String(s + i + 1).padStart(o) + "→" + t.substring(n, c), n = c, i++;
2446
2446
  }
2447
2447
  return e.length > 0 && !e.endsWith(`
2448
2448
  `) && (e += `
2449
2449
  `), e;
2450
2450
  }
2451
- function ue(r) {
2451
+ function de(r) {
2452
2452
  const { content: t, matches: s, outputLimit: o } = r;
2453
2453
  if (s.length === 0)
2454
2454
  return { output: "", truncated: !1 };
2455
- const e = os(s);
2455
+ const e = is(s);
2456
2456
  let n = "", i = !1;
2457
2457
  for (let a = 0; a < e.length; a++) {
2458
- const l = e[a], c = t.substring(
2459
- l.linesOffset[0],
2460
- l.linesOffset[1]
2461
- ), u = is({
2462
- content: c,
2463
- startLine: l.lines[0]
2458
+ const c = e[a], l = t.substring(
2459
+ c.linesOffset[0],
2460
+ c.linesOffset[1]
2461
+ ), u = ls({
2462
+ content: l,
2463
+ startLine: c.lines[0]
2464
2464
  }), f = a > 0 ? 2 : 0;
2465
2465
  if (o != null && n.length + f + u.length > o) {
2466
2466
  i = !0;
@@ -2472,10 +2472,10 @@ function ue(r) {
2472
2472
  return { output: n, truncated: i };
2473
2473
  }
2474
2474
  const Qe = "BEFORE", Ye = "AFTER";
2475
- function as(r) {
2475
+ function cs(r) {
2476
2476
  const { result: t, outputLimit: s } = r;
2477
2477
  if (t.replace == null) {
2478
- const m = ue({
2478
+ const m = de({
2479
2479
  content: t.search.content,
2480
2480
  matches: t.search.matches,
2481
2481
  outputLimit: s
@@ -2489,11 +2489,11 @@ function as(r) {
2489
2489
  `, a = o.length + e.length + n.length + i.length;
2490
2490
  if (s != null && s < a)
2491
2491
  return { output: "", truncated: !0 };
2492
- const l = s != null ? s - a : void 0, c = l != null ? Math.floor(l / 2) : void 0, u = ue({
2492
+ const c = s != null ? s - a : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = de({
2493
2493
  content: t.search.content,
2494
2494
  matches: t.search.matches,
2495
- outputLimit: c
2496
- }), f = l != null ? l - u.output.length : void 0, d = ue({
2495
+ outputLimit: l
2496
+ }), f = c != null ? c - u.output.length : void 0, d = de({
2497
2497
  content: t.replace.content,
2498
2498
  matches: t.replace.matches,
2499
2499
  outputLimit: f
@@ -2501,16 +2501,16 @@ function as(r) {
2501
2501
  return { output: o + u.output + e + n + d.output + i, truncated: u.truncated || d.truncated };
2502
2502
  }
2503
2503
  const Ve = `
2504
- ... [output truncated] ...
2504
+ ... [truncated, too much output, use more specific search patterns] ...
2505
2505
  `;
2506
- function ls(r) {
2506
+ function bt(r) {
2507
2507
  const { result: t, rootDir: s, outputLimit: o } = r, e = o - Ve.length;
2508
2508
  let n = "", i = !1;
2509
2509
  for (let a = 0; a < t.results.length; a++) {
2510
- const l = t.results[a], c = R.relative(s, l.filePath), u = n.length > 0 ? 1 : 0;
2511
- if (l.error != null) {
2512
- const h = c + `
2513
- ❌ ` + l.error + `
2510
+ const c = t.results[a], l = F.relative(s, c.filePath), u = n.length > 0 ? 1 : 0;
2511
+ if (c.error != null) {
2512
+ const h = l + `
2513
+ ❌ ` + c.error + `
2514
2514
  `;
2515
2515
  if (n.length + u + h.length > e) {
2516
2516
  i = !0;
@@ -2520,68 +2520,159 @@ function ls(r) {
2520
2520
  `), n += h;
2521
2521
  continue;
2522
2522
  }
2523
- if (l.result == null || l.result.search.matches.length === 0)
2523
+ if (c.result == null || c.result.search.matches.length === 0)
2524
2524
  continue;
2525
- const f = e - n.length - u - c.length - 1;
2525
+ const f = e - n.length - u - l.length - 1;
2526
2526
  if (f <= 0) {
2527
2527
  i = !0;
2528
2528
  break;
2529
2529
  }
2530
- const d = as({
2531
- result: l.result,
2530
+ const d = cs({
2531
+ result: c.result,
2532
2532
  outputLimit: f
2533
2533
  });
2534
2534
  if (i = i || d.truncated, d.output.length > 0 && (u > 0 && (n += `
2535
- `), n += c + `
2535
+ `), n += l + `
2536
2536
  ` + d.output), i)
2537
2537
  break;
2538
2538
  }
2539
2539
  return i && (n += Ve), n;
2540
2540
  }
2541
- const cs = p.object({
2541
+ const us = p.object({
2542
+ pattern: p.string().describe("JS RegExp pattern"),
2543
+ flags: p.string().optional().describe("JS RegExp flags")
2544
+ }), St = p.object({
2545
+ snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2546
+ snapshot: X.optional().describe(
2547
+ "Filesystem snapshot creation options JSON to automatically create snapshot"
2548
+ ),
2549
+ operations: p.array(us).describe("Search operations to execute sequentially on each file"),
2550
+ outputLimit: p.number().max(R).default(R).describe(
2551
+ `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${R}. Default: ${R}`
2552
+ )
2553
+ });
2554
+ async function ds(r, t, s) {
2555
+ let o;
2556
+ try {
2557
+ o = St.parse(r);
2558
+ } catch (y) {
2559
+ return {
2560
+ error: B(y)
2561
+ };
2562
+ }
2563
+ const { snapshotName: e, snapshot: n, operations: i, outputLimit: a } = o;
2564
+ if (!s.sessionId)
2565
+ return {
2566
+ error: "Session ID is required"
2567
+ };
2568
+ const c = Z(s.sessionId);
2569
+ if (e && n)
2570
+ return {
2571
+ error: "Either snapshotName or snapshot must be provided, not both"
2572
+ };
2573
+ let l, u = !1, f = !1;
2574
+ if (e) {
2575
+ if (l = c.fsSnapshots.get(e), l == null)
2576
+ return {
2577
+ error: `Filesystem snapshot "${e}" not found`
2578
+ };
2579
+ } else if (n) {
2580
+ const y = await le(
2581
+ n,
2582
+ t,
2583
+ s
2584
+ );
2585
+ if (y.error != null)
2586
+ return {
2587
+ error: y.error
2588
+ };
2589
+ l = y.fsSnapshot, u = y.queryCreated, f = !0;
2590
+ } else
2591
+ return {
2592
+ error: "Either snapshotName or snapshot must be provided"
2593
+ };
2594
+ const d = wt(l), h = l.query.rootDir ?? ".", m = await yt({
2595
+ filePaths: d,
2596
+ operations: i
2597
+ });
2598
+ return { output: bt({
2599
+ result: m,
2600
+ rootDir: h,
2601
+ outputLimit: a
2602
+ }), rootDir: h, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2603
+ }
2604
+ function fs(r, t) {
2605
+ r(
2606
+ "fs-snapshot-search",
2607
+ {
2608
+ title: "Search File Contents in Snapshot",
2609
+ 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
2611
+ },
2612
+ async (s, o) => {
2613
+ const e = await ds(
2614
+ s,
2615
+ t,
2616
+ o
2617
+ );
2618
+ if (e.error != null)
2619
+ return `Method: fs-snapshot-search(${JSON.stringify(s)})
2620
+ ❌ Error: ${e.error}`;
2621
+ let n = `Method: fs-snapshot-search(${JSON.stringify(s)})
2622
+ `;
2623
+ return e.queryCreated && (n += `✅ Filesystem snapshot query "${e.fsSnapshot.query.name}" created successfully
2624
+ `), e.snapshotCreated && (n += `✅ Filesystem snapshot "${e.fsSnapshot.name}" created successfully
2625
+ `), n += `✅ Search in snapshot "${e.fsSnapshot.name}":
2626
+ `, n += `Root directory (<root>/): ${e.rootDir}
2627
+ `, n += `
2628
+ ${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` array in one tool call; never split patterns across multiple tool calls", n;
2629
+ }
2630
+ );
2631
+ }
2632
+ const hs = p.object({
2542
2633
  pattern: p.string().describe("JS RegExp pattern"),
2543
2634
  flags: p.string().optional().describe("JS RegExp flags"),
2544
- replacement: p.string().optional().describe("JS replacement pattern. If omitted, search only")
2545
- }), wt = p.object({
2635
+ replacement: p.string().describe("JS replacement pattern")
2636
+ }), xt = p.object({
2546
2637
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2547
- snapshot: ae.optional().describe(
2638
+ snapshot: X.optional().describe(
2548
2639
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2549
2640
  ),
2550
- operations: p.array(cs).describe("Search/replace operations to execute sequentially on each file"),
2551
- outputLimit: p.number().max(F).default(F).describe(
2552
- `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${F}. Default: ${F}`
2641
+ operations: p.array(hs).describe("Replace operations to execute sequentially on each file"),
2642
+ outputLimit: p.number().max(R).default(R).describe(
2643
+ `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${R}. Default: ${R}`
2553
2644
  ),
2554
2645
  dryRun: p.boolean().optional().describe(
2555
2646
  "Preview changes without writing files. When true, shows what would be replaced but does not modify files"
2556
2647
  )
2557
2648
  });
2558
- async function us(r, t, s) {
2649
+ async function ps(r, t, s) {
2559
2650
  let o;
2560
2651
  try {
2561
- o = wt.parse(r);
2652
+ o = xt.parse(r);
2562
2653
  } catch (w) {
2563
2654
  return {
2564
2655
  error: B(w)
2565
2656
  };
2566
2657
  }
2567
- const { snapshotName: e, snapshot: n, operations: i, outputLimit: a, dryRun: l } = o;
2658
+ const { snapshotName: e, snapshot: n, operations: i, outputLimit: a, dryRun: c } = o;
2568
2659
  if (!s.sessionId)
2569
2660
  return {
2570
2661
  error: "Session ID is required"
2571
2662
  };
2572
- const c = ie(s.sessionId);
2663
+ const l = Z(s.sessionId);
2573
2664
  if (e && n)
2574
2665
  return {
2575
2666
  error: "Either snapshotName or snapshot must be provided, not both"
2576
2667
  };
2577
2668
  let u, f = !1, d = !1;
2578
2669
  if (e) {
2579
- if (u = c.fsSnapshots.get(e), u == null)
2670
+ if (u = l.fsSnapshots.get(e), u == null)
2580
2671
  return {
2581
2672
  error: `Filesystem snapshot "${e}" not found`
2582
2673
  };
2583
2674
  } else if (n) {
2584
- const w = await be(
2675
+ const w = await le(
2585
2676
  n,
2586
2677
  t,
2587
2678
  s
@@ -2595,58 +2686,58 @@ async function us(r, t, s) {
2595
2686
  return {
2596
2687
  error: "Either snapshotName or snapshot must be provided"
2597
2688
  };
2598
- const h = Jr(u), m = u.query.rootDir ?? ".", g = await ss({
2689
+ const h = wt(u), m = u.query.rootDir ?? ".", g = await yt({
2599
2690
  filePaths: h,
2600
2691
  operations: i,
2601
- dryRun: l
2692
+ dryRun: c
2602
2693
  });
2603
- return { output: ls({
2694
+ return { output: bt({
2604
2695
  result: g,
2605
2696
  rootDir: m,
2606
2697
  outputLimit: a
2607
2698
  }), rootDir: m, fsSnapshot: u, queryCreated: f, snapshotCreated: d };
2608
2699
  }
2609
- function ds(r, t) {
2700
+ function ms(r, t) {
2610
2701
  r(
2611
- "fs-snapshot-search-or-replace",
2702
+ "fs-snapshot-replace",
2612
2703
  {
2613
- title: "Search/Replace File Contents in Snapshot",
2614
- description: "Search/replace file contents using JS RegExp. Use this to find text patterns or perform bulk replacements across snapshot files",
2615
- inputSchema: wt.shape
2704
+ title: "Replace File Contents in Snapshot",
2705
+ 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
2616
2707
  },
2617
2708
  async (s, o) => {
2618
- const e = await us(
2709
+ const e = await ps(
2619
2710
  s,
2620
2711
  t,
2621
2712
  o
2622
2713
  );
2623
2714
  if (e.error != null)
2624
- return `Method: fs-snapshot-search-or-replace(${JSON.stringify(s)})
2715
+ return `Method: fs-snapshot-replace(${JSON.stringify(s)})
2625
2716
  ❌ Error: ${e.error}`;
2626
- let n = `Method: fs-snapshot-search-or-replace(${JSON.stringify(s)})
2717
+ let n = `Method: fs-snapshot-replace(${JSON.stringify(s)})
2627
2718
  `;
2628
2719
  return e.queryCreated && (n += `✅ Filesystem snapshot query "${e.fsSnapshot.query.name}" created successfully
2629
2720
  `), e.snapshotCreated && (n += `✅ Filesystem snapshot "${e.fsSnapshot.name}" created successfully
2630
- `), n += `✅ Search/replace in snapshot "${e.fsSnapshot.name}":
2721
+ `), n += `✅ Replace in snapshot "${e.fsSnapshot.name}":
2631
2722
  `, n += `Root directory (<root>/): ${e.rootDir}
2632
2723
  `, n += `
2633
- ${e.output}`, n;
2724
+ ${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` array in one tool call; never split patterns across multiple tool calls", n;
2634
2725
  }
2635
2726
  );
2636
2727
  }
2637
- function fs(r, t) {
2638
- t.list && Nr(r, t), t.snapshotQueryCreate && Or(r, t), t.snapshotCreate && zr(r, t), t.snapshotBrowse && jr(r, t), t.snapshotSearchOrReplace && ds(r, t), console.log(
2728
+ 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(
2639
2730
  `File manager:
2640
- - Working directory: ${R.resolve(t.workingDir || "")}
2731
+ - Working directory: ${F.resolve(t.workingDir || "")}
2641
2732
  `
2642
2733
  );
2643
2734
  }
2644
- const de = /* @__PURE__ */ new Map();
2645
- function J(r) {
2646
- return de.has(r) || de.set(r, {
2735
+ const fe = /* @__PURE__ */ new Map();
2736
+ function j(r) {
2737
+ return fe.has(r) || fe.set(r, {
2647
2738
  browsers: /* @__PURE__ */ new Map(),
2648
2739
  domSnapshotQueries: /* @__PURE__ */ new Map()
2649
- }), de.get(r);
2740
+ }), fe.get(r);
2650
2741
  }
2651
2742
  const Se = p.object({
2652
2743
  name: p.string().describe(
@@ -2656,13 +2747,13 @@ const Se = p.object({
2656
2747
  muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
2657
2748
  devTools: p.boolean().optional().describe("Open browser with dev tools")
2658
2749
  });
2659
- async function yt(r, t, s) {
2750
+ async function $t(r, t, s) {
2660
2751
  let o;
2661
2752
  try {
2662
2753
  o = Se.parse(r);
2663
- } catch (c) {
2754
+ } catch (l) {
2664
2755
  return {
2665
- error: B(c)
2756
+ error: B(l)
2666
2757
  };
2667
2758
  }
2668
2759
  const { name: e, browserType: n, muteAudio: i, devTools: a } = o;
@@ -2670,12 +2761,12 @@ async function yt(r, t, s) {
2670
2761
  return {
2671
2762
  error: "Session ID is required"
2672
2763
  };
2673
- const l = J(s.sessionId);
2764
+ const c = j(s.sessionId);
2674
2765
  try {
2675
2766
  const u = await {
2676
- chromium: Jt,
2677
- firefox: jt,
2678
- webkit: Gt
2767
+ chromium: Qt,
2768
+ firefox: Ht,
2769
+ webkit: Wt
2679
2770
  }[n].launch({
2680
2771
  headless: !1,
2681
2772
  devtools: a,
@@ -2686,14 +2777,14 @@ async function yt(r, t, s) {
2686
2777
  browser: u,
2687
2778
  contexts: /* @__PURE__ */ new Map()
2688
2779
  };
2689
- return l.browsers.set(e, f), { browserInfo: f };
2690
- } catch (c) {
2780
+ return c.browsers.set(e, f), { browserInfo: f };
2781
+ } catch (l) {
2691
2782
  return {
2692
- error: `Failed to create browser: ${c instanceof Error ? c.message : "Unknown error"}`
2783
+ error: `Failed to create browser: ${l instanceof Error ? l.message : "Unknown error"}`
2693
2784
  };
2694
2785
  }
2695
2786
  }
2696
- function hs(r, t) {
2787
+ function ws(r, t) {
2697
2788
  r(
2698
2789
  "playwright-browser-create",
2699
2790
  {
@@ -2702,17 +2793,17 @@ function hs(r, t) {
2702
2793
  inputSchema: Se.shape
2703
2794
  },
2704
2795
  async (s, o) => {
2705
- const e = await yt(s, t, o);
2796
+ const e = await $t(s, t, o);
2706
2797
  return `Method: playwright-browser-create(${JSON.stringify(s)})
2707
2798
  ${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
2708
2799
  }
2709
2800
  );
2710
2801
  }
2711
- const bt = p.object({});
2712
- async function ps(r, t, s) {
2802
+ const It = p.object({});
2803
+ async function ys(r, t, s) {
2713
2804
  let o;
2714
2805
  try {
2715
- o = bt.parse(r);
2806
+ o = It.parse(r);
2716
2807
  } catch (i) {
2717
2808
  return {
2718
2809
  error: B(i)
@@ -2722,21 +2813,21 @@ async function ps(r, t, s) {
2722
2813
  return {
2723
2814
  error: "Session ID is required"
2724
2815
  };
2725
- const e = J(s.sessionId);
2816
+ const e = j(s.sessionId);
2726
2817
  return {
2727
2818
  browserInfos: Array.from(e.browsers.values())
2728
2819
  };
2729
2820
  }
2730
- function ms(r, t) {
2821
+ function bs(r, t) {
2731
2822
  r(
2732
2823
  "playwright-browser-list",
2733
2824
  {
2734
2825
  title: "List Browsers",
2735
2826
  description: "List active browser instances",
2736
- inputSchema: bt.shape
2827
+ inputSchema: It.shape
2737
2828
  },
2738
2829
  async (s, o) => {
2739
- const e = await ps(s, t, o);
2830
+ const e = await ys(s, t, o);
2740
2831
  if (e.error != null)
2741
2832
  return `Method: playwright-browser-list(${JSON.stringify(s)})
2742
2833
  ❌ Error: ${e.error}`;
@@ -2748,18 +2839,18 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
2748
2839
  }
2749
2840
  );
2750
2841
  }
2751
- const St = p.object({
2842
+ const Mt = p.object({
2752
2843
  names: p.array(p.string()).optional().describe(
2753
2844
  "Names of browsers to close. If not specified, closes all browsers"
2754
2845
  )
2755
2846
  });
2756
- async function gs(r, t, s) {
2847
+ async function Ss(r, t, s) {
2757
2848
  let o;
2758
2849
  try {
2759
- o = St.parse(r);
2760
- } catch (c) {
2850
+ o = Mt.parse(r);
2851
+ } catch (l) {
2761
2852
  return {
2762
- error: B(c)
2853
+ error: B(l)
2763
2854
  };
2764
2855
  }
2765
2856
  const { names: e } = o;
@@ -2767,18 +2858,18 @@ async function gs(r, t, s) {
2767
2858
  return {
2768
2859
  error: "Session ID is required"
2769
2860
  };
2770
- const n = J(s.sessionId), i = [], a = [];
2771
- let l = [];
2772
- return e ? e.forEach((c) => {
2773
- const u = n.browsers.get(c);
2774
- u ? l.push(u) : a.push(`Browser "${c}" not found`);
2775
- }) : l = Array.from(n.browsers.values()), await Promise.all(
2776
- l.map(async (c) => {
2861
+ const n = j(s.sessionId), i = [], a = [];
2862
+ let c = [];
2863
+ return e ? e.forEach((l) => {
2864
+ const u = n.browsers.get(l);
2865
+ u ? c.push(u) : a.push(`Browser "${l}" not found`);
2866
+ }) : c = Array.from(n.browsers.values()), await Promise.all(
2867
+ c.map(async (l) => {
2777
2868
  try {
2778
- await c.browser.close(), n.browsers.delete(c.name), i.push(c);
2869
+ await l.browser.close(), n.browsers.delete(l.name), i.push(l);
2779
2870
  } catch (u) {
2780
2871
  a.push(
2781
- `Failed to close browser "${c.name}" (${c.browserType}): ${u instanceof Error ? u.message : "Unknown error"}`
2872
+ `Failed to close browser "${l.name}" (${l.browserType}): ${u instanceof Error ? u.message : "Unknown error"}`
2782
2873
  );
2783
2874
  }
2784
2875
  })
@@ -2787,16 +2878,16 @@ async function gs(r, t, s) {
2787
2878
  ...a.length > 0 && { errors: a }
2788
2879
  };
2789
2880
  }
2790
- function ws(r, t) {
2881
+ function xs(r, t) {
2791
2882
  r(
2792
2883
  "playwright-browser-close",
2793
2884
  {
2794
2885
  title: "Close Browsers",
2795
2886
  description: "Close browsers. Automatically closes all contexts and pages within the browsers",
2796
- inputSchema: St.shape
2887
+ inputSchema: Mt.shape
2797
2888
  },
2798
2889
  async (s, o) => {
2799
- const e = await gs(s, t, o);
2890
+ const e = await Ss(s, t, o);
2800
2891
  if (e.error != null)
2801
2892
  return `Method: playwright-browser-close(${JSON.stringify(s)})
2802
2893
  ❌ Error: ${e.error}`;
@@ -2828,7 +2919,7 @@ const xe = p.object({
2828
2919
  height: p.number()
2829
2920
  }).optional().describe("Viewport size configuration")
2830
2921
  });
2831
- async function xt(r, t, s) {
2922
+ async function Tt(r, t, s) {
2832
2923
  let o;
2833
2924
  try {
2834
2925
  o = xe.parse(r);
@@ -2837,12 +2928,12 @@ async function xt(r, t, s) {
2837
2928
  error: B(h)
2838
2929
  };
2839
2930
  }
2840
- const { name: e, browserName: n, browser: i, isMobile: a, hasTouch: l, viewport: c } = o;
2931
+ const { name: e, browserName: n, browser: i, isMobile: a, hasTouch: c, viewport: l } = o;
2841
2932
  if (!s.sessionId)
2842
2933
  return {
2843
2934
  error: "Session ID is required"
2844
2935
  };
2845
- const u = J(s.sessionId);
2936
+ const u = j(s.sessionId);
2846
2937
  if (n && i)
2847
2938
  return {
2848
2939
  error: "Either browserName or browser must be provided, not both"
@@ -2854,7 +2945,7 @@ async function xt(r, t, s) {
2854
2945
  error: `Browser "${n}" not found`
2855
2946
  };
2856
2947
  } else if (i) {
2857
- const h = await yt(i, t, s);
2948
+ const h = await $t(i, t, s);
2858
2949
  if (h.error != null)
2859
2950
  return {
2860
2951
  error: h.error
@@ -2867,8 +2958,8 @@ async function xt(r, t, s) {
2867
2958
  try {
2868
2959
  const h = await d.browser.newContext({
2869
2960
  isMobile: a,
2870
- hasTouch: l,
2871
- viewport: c
2961
+ hasTouch: c,
2962
+ viewport: l
2872
2963
  }), m = {
2873
2964
  browserInfo: d,
2874
2965
  name: e,
@@ -2886,7 +2977,7 @@ async function xt(r, t, s) {
2886
2977
  };
2887
2978
  }
2888
2979
  }
2889
- function ys(r, t) {
2980
+ function $s(r, t) {
2890
2981
  r(
2891
2982
  "playwright-context-create",
2892
2983
  {
@@ -2895,7 +2986,7 @@ function ys(r, t) {
2895
2986
  inputSchema: xe.shape
2896
2987
  },
2897
2988
  async (s, o) => {
2898
- const e = await xt(s, t, o);
2989
+ const e = await Tt(s, t, o);
2899
2990
  if (e.error != null)
2900
2991
  return `Method: playwright-context-create(${JSON.stringify(s)})
2901
2992
  ❌ Error: ${e.error}`;
@@ -2906,15 +2997,15 @@ function ys(r, t) {
2906
2997
  }
2907
2998
  );
2908
2999
  }
2909
- const $t = p.object({
3000
+ const Ct = p.object({
2910
3001
  browserName: p.string().optional().describe(
2911
3002
  "Name of browser to list contexts from. If not specified, lists contexts from all browsers"
2912
3003
  )
2913
3004
  });
2914
- async function bs(r, t, s) {
3005
+ async function Is(r, t, s) {
2915
3006
  let o;
2916
3007
  try {
2917
- o = $t.parse(r);
3008
+ o = Ct.parse(r);
2918
3009
  } catch (a) {
2919
3010
  return {
2920
3011
  error: B(a)
@@ -2925,7 +3016,7 @@ async function bs(r, t, s) {
2925
3016
  return {
2926
3017
  error: "Session ID is required"
2927
3018
  };
2928
- const n = J(s.sessionId), i = [];
3019
+ const n = j(s.sessionId), i = [];
2929
3020
  if (e) {
2930
3021
  const a = n.browsers.get(e);
2931
3022
  if (!a)
@@ -2938,39 +3029,39 @@ async function bs(r, t, s) {
2938
3029
  });
2939
3030
  } else
2940
3031
  for (const a of n.browsers.values()) {
2941
- const l = Array.from(a.contexts.values());
2942
- l.length > 0 && i.push({
3032
+ const c = Array.from(a.contexts.values());
3033
+ c.length > 0 && i.push({
2943
3034
  browserInfo: a,
2944
- contexts: l
3035
+ contexts: c
2945
3036
  });
2946
3037
  }
2947
3038
  return {
2948
3039
  contextsByBrowser: i
2949
3040
  };
2950
3041
  }
2951
- function Ss(r, t) {
3042
+ function Ms(r, t) {
2952
3043
  r(
2953
3044
  "playwright-context-list",
2954
3045
  {
2955
3046
  title: "List Browser Contexts",
2956
3047
  description: "List active browser contexts",
2957
- inputSchema: $t.shape
3048
+ inputSchema: Ct.shape
2958
3049
  },
2959
3050
  async (s, o) => {
2960
- const e = await bs(s, t, o);
3051
+ const e = await Is(s, t, o);
2961
3052
  if ("error" in e)
2962
3053
  return `Method: playwright-context-list(${JSON.stringify(s)})
2963
3054
  ❌ Error: ${e.error}`;
2964
3055
  let n = `Method: playwright-context-list(${JSON.stringify(s)})
2965
3056
  `;
2966
3057
  return e.contextsByBrowser.length === 0 ? n += "No contexts found" : n += e.contextsByBrowser.map(
2967
- ({ browserInfo: i, contexts: a }) => `${i.name} (${i.browserType}): ${a.map((l) => l.name).join(", ")}`
3058
+ ({ browserInfo: i, contexts: a }) => `${i.name} (${i.browserType}): ${a.map((c) => c.name).join(", ")}`
2968
3059
  ).join(`
2969
3060
  `), n;
2970
3061
  }
2971
3062
  );
2972
3063
  }
2973
- const It = p.object({
3064
+ const vt = p.object({
2974
3065
  names: p.array(p.string()).optional().describe(
2975
3066
  "Names of contexts to close. If not specified, closes all contexts"
2976
3067
  ),
@@ -2978,10 +3069,10 @@ const It = p.object({
2978
3069
  "Name of browser to close contexts from. If not specified, searches all browsers"
2979
3070
  )
2980
3071
  });
2981
- async function xs(r, t, s) {
3072
+ async function Ts(r, t, s) {
2982
3073
  let o;
2983
3074
  try {
2984
- o = It.parse(r);
3075
+ o = vt.parse(r);
2985
3076
  } catch (u) {
2986
3077
  return {
2987
3078
  error: B(u)
@@ -2992,8 +3083,8 @@ async function xs(r, t, s) {
2992
3083
  return {
2993
3084
  error: "Session ID is required"
2994
3085
  };
2995
- const i = J(s.sessionId), a = [], l = [];
2996
- let c = [];
3086
+ const i = j(s.sessionId), a = [], c = [];
3087
+ let l = [];
2997
3088
  if (n) {
2998
3089
  const u = i.browsers.get(n);
2999
3090
  if (!u)
@@ -3002,46 +3093,46 @@ async function xs(r, t, s) {
3002
3093
  };
3003
3094
  e ? e.forEach((f) => {
3004
3095
  const d = u.contexts.get(f);
3005
- d ? c.push(d) : l.push(
3096
+ d ? l.push(d) : c.push(
3006
3097
  `Context "${f}" not found in browser "${u.name}" (${u.browserType})`
3007
3098
  );
3008
- }) : c = Array.from(u.contexts.values());
3099
+ }) : l = Array.from(u.contexts.values());
3009
3100
  } else if (e)
3010
3101
  for (const u of i.browsers.values())
3011
3102
  e.forEach((f) => {
3012
3103
  const d = u.contexts.get(f);
3013
- d ? c.push(d) : l.push(
3104
+ d ? l.push(d) : c.push(
3014
3105
  `Context "${f}" not found in browser "${u.name}" (${u.browserType})`
3015
3106
  );
3016
3107
  });
3017
3108
  else
3018
3109
  for (const u of i.browsers.values())
3019
- c.push(...Array.from(u.contexts.values()));
3110
+ l.push(...Array.from(u.contexts.values()));
3020
3111
  return await Promise.all(
3021
- c.map(async (u) => {
3112
+ l.map(async (u) => {
3022
3113
  try {
3023
3114
  await u.context.close(), u.browserInfo.contexts.delete(u.name), a.push(u);
3024
3115
  } catch (f) {
3025
- l.push(
3116
+ c.push(
3026
3117
  `Failed to close context "${u.name}" (${u.browserInfo.name}) (${u.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
3027
3118
  );
3028
3119
  }
3029
3120
  })
3030
3121
  ), {
3031
3122
  closedContextInfos: a,
3032
- ...l.length > 0 && { errors: l }
3123
+ ...c.length > 0 && { errors: c }
3033
3124
  };
3034
3125
  }
3035
- function $s(r, t) {
3126
+ function Cs(r, t) {
3036
3127
  r(
3037
3128
  "playwright-context-close",
3038
3129
  {
3039
3130
  title: "Close Browser Contexts",
3040
3131
  description: "Close browser contexts. Automatically closes all pages within the contexts",
3041
- inputSchema: It.shape
3132
+ inputSchema: vt.shape
3042
3133
  },
3043
3134
  async (s, o) => {
3044
- const e = await xs(s, t, o);
3135
+ const e = await Ts(s, t, o);
3045
3136
  if ("error" in e)
3046
3137
  return `Method: playwright-context-close(${JSON.stringify(s)})
3047
3138
  ❌ Error: ${e.error}`;
@@ -3058,51 +3149,51 @@ ${n.join(`
3058
3149
  }
3059
3150
  );
3060
3151
  }
3061
- function Is() {
3152
+ function vs() {
3062
3153
  class r {
3063
3154
  prevId = 0;
3064
3155
  objectToId = /* @__PURE__ */ new WeakMap();
3065
3156
  idToObject = /* @__PURE__ */ new Map();
3066
3157
  cleanupRegistry;
3067
3158
  constructor() {
3068
- this.cleanupRegistry = new FinalizationRegistry((l) => {
3069
- this.idToObject.delete(l);
3159
+ this.cleanupRegistry = new FinalizationRegistry((c) => {
3160
+ this.idToObject.delete(c);
3070
3161
  });
3071
3162
  }
3072
- getOrCreateId(l) {
3073
- let c = this.objectToId.get(l);
3074
- return c == null && (c = ++this.prevId, this.objectToId.set(l, c), this.idToObject.set(c, new WeakRef(l)), this.cleanupRegistry.register(l, c)), c;
3163
+ getOrCreateId(c) {
3164
+ let l = this.objectToId.get(c);
3165
+ return l == null && (l = ++this.prevId, this.objectToId.set(c, l), this.idToObject.set(l, new WeakRef(c)), this.cleanupRegistry.register(c, l)), l;
3075
3166
  }
3076
- getObject(l) {
3077
- const c = this.idToObject.get(l);
3078
- if (!c)
3167
+ getObject(c) {
3168
+ const l = this.idToObject.get(c);
3169
+ if (!l)
3079
3170
  return null;
3080
- const u = c.deref();
3081
- return u ?? (this.idToObject.delete(l), null);
3171
+ const u = l.deref();
3172
+ return u ?? (this.idToObject.delete(c), null);
3082
3173
  }
3083
3174
  }
3084
- function t(a, l, c) {
3175
+ function t(a, c, l) {
3085
3176
  let u = null;
3086
- for (let f = 0, d = l.length; f < d; f++) {
3087
- const h = l[f], m = a(h), g = m == null ? null : t(a, m, c), y = c(h, g);
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);
3088
3179
  y != null && (u == null && (u = []), u.push(y));
3089
3180
  }
3090
3181
  return u;
3091
3182
  }
3092
3183
  function s(a) {
3093
- const { getId: l, getChilds: c, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = t(
3094
- c,
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(
3185
+ l,
3095
3186
  u,
3096
3187
  (w, M) => {
3097
- const E = f(w, M);
3098
- if (w != null && E != null) {
3099
- const b = l(w);
3100
- d.set(b, E), h.set(E, b);
3188
+ const N = f(w, M);
3189
+ if (w != null && N != null) {
3190
+ const b = c(w);
3191
+ d.set(b, N), h.set(N, b);
3101
3192
  }
3102
- return E != null && M != null && m.set(
3103
- h.get(E),
3193
+ return N != null && M != null && m.set(
3194
+ h.get(N),
3104
3195
  M.map((b) => h.get(b))
3105
- ), E;
3196
+ ), N;
3106
3197
  }
3107
3198
  ), y = f(null, g);
3108
3199
  if (y == null)
@@ -3117,13 +3208,13 @@ function Is() {
3117
3208
  }
3118
3209
  const o = (a) => a instanceof HTMLElement ? a.childNodes : null;
3119
3210
  function e(a) {
3120
- return function(c, u) {
3211
+ return function(l, u) {
3121
3212
  const f = u != null && u.length > 0;
3122
3213
  let d = !1, h = null, m = null;
3123
- if (c instanceof HTMLElement) {
3124
- if (h = n.getOrCreateId(c), m = c.tagName.toLowerCase(), d = c.matches(a.cssSelector), !d && !f)
3214
+ if (l instanceof HTMLElement) {
3215
+ if (h = n.getOrCreateId(l), m = l.tagName.toLowerCase(), d = l.matches(a.cssSelector), !d && !f)
3125
3216
  return null;
3126
- } else if (c == null)
3217
+ } else if (l == null)
3127
3218
  h = null, m = null, d = !1;
3128
3219
  else
3129
3220
  return null;
@@ -3136,17 +3227,17 @@ function Is() {
3136
3227
  }
3137
3228
  const n = new r();
3138
3229
  function i(a) {
3139
- const l = e(a);
3230
+ const c = e(a);
3140
3231
  return s({
3141
- getId: (c) => n.getOrCreateId(c),
3232
+ getId: (l) => n.getOrCreateId(l),
3142
3233
  getChilds: o,
3143
- createSnapshotNode: l,
3234
+ createSnapshotNode: c,
3144
3235
  rootNodes: [window.document.documentElement]
3145
3236
  });
3146
3237
  }
3147
3238
  window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
3148
3239
  }
3149
- const Ms = `(function (){function __name(fn){return fn};${Is.toString()}; setupPageGlobals();})()`, $e = p.object({
3240
+ const Ns = `(function (){function __name(fn){return fn};${vs.toString()}; setupPageGlobals();})()`, $e = p.object({
3150
3241
  contextName: p.string().optional().describe("Name of previously created context, to use"),
3151
3242
  context: xe.optional().describe(
3152
3243
  "Context creation options JSON to automatically create context"
@@ -3155,7 +3246,7 @@ const Ms = `(function (){function __name(fn){return fn};${Is.toString()}; setupP
3155
3246
  "Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
3156
3247
  )
3157
3248
  });
3158
- async function Mt(r, t, s) {
3249
+ async function Nt(r, t, s) {
3159
3250
  let o;
3160
3251
  try {
3161
3252
  o = $e.parse(r);
@@ -3169,12 +3260,12 @@ async function Mt(r, t, s) {
3169
3260
  return {
3170
3261
  error: "Session ID is required"
3171
3262
  };
3172
- const a = J(s.sessionId);
3263
+ const a = j(s.sessionId);
3173
3264
  if (n && i)
3174
3265
  return {
3175
3266
  error: "Either contextName or context must be provided, not both"
3176
3267
  };
3177
- let l = !1, c = !1, u;
3268
+ let c = !1, l = !1, u;
3178
3269
  if (n) {
3179
3270
  for (const f of a.browsers.values())
3180
3271
  if (f.contexts.has(n)) {
@@ -3186,19 +3277,19 @@ async function Mt(r, t, s) {
3186
3277
  error: `Context "${n}" not found`
3187
3278
  };
3188
3279
  } else if (i) {
3189
- const f = await xt(i, t, s);
3280
+ const f = await Tt(i, t, s);
3190
3281
  if (f.error != null)
3191
3282
  return {
3192
3283
  error: f.error
3193
3284
  };
3194
- u = f.contextInfo, l = f.browserInfoCreated, c = !0;
3285
+ u = f.contextInfo, c = f.browserInfoCreated, l = !0;
3195
3286
  } else
3196
3287
  return {
3197
3288
  error: "Either contextName or context must be provided"
3198
3289
  };
3199
3290
  try {
3200
3291
  const f = await u.context.newPage();
3201
- await f.addInitScript(Ms), await f.goto("about:blank");
3292
+ await f.addInitScript(Ns), await f.goto("about:blank");
3202
3293
  const d = {
3203
3294
  contextInfo: u,
3204
3295
  name: e,
@@ -3206,8 +3297,8 @@ async function Mt(r, t, s) {
3206
3297
  domSnapshots: /* @__PURE__ */ new Map()
3207
3298
  };
3208
3299
  return u.pages.set(e, d), {
3209
- browserInfoCreated: l,
3210
- contextInfoCreated: c,
3300
+ browserInfoCreated: c,
3301
+ contextInfoCreated: l,
3211
3302
  pageInfo: d
3212
3303
  };
3213
3304
  } catch (f) {
@@ -3216,7 +3307,7 @@ async function Mt(r, t, s) {
3216
3307
  };
3217
3308
  }
3218
3309
  }
3219
- function Ts(r, t) {
3310
+ function Es(r, t) {
3220
3311
  r(
3221
3312
  "playwright-page-create",
3222
3313
  {
@@ -3225,7 +3316,7 @@ function Ts(r, t) {
3225
3316
  inputSchema: $e.shape
3226
3317
  },
3227
3318
  async (s, o) => {
3228
- const e = await Mt(s, t, o);
3319
+ const e = await Nt(s, t, o);
3229
3320
  if (e.error != null)
3230
3321
  return `Method: playwright-page-create(${JSON.stringify(s)})
3231
3322
  ❌ Error: ${e.error}`;
@@ -3237,7 +3328,7 @@ function Ts(r, t) {
3237
3328
  }
3238
3329
  );
3239
3330
  }
3240
- const Tt = p.object({
3331
+ const Et = p.object({
3241
3332
  contextName: p.string().optional().describe(
3242
3333
  "Name of context to list pages from. If not specified, lists pages from all contexts"
3243
3334
  ),
@@ -3245,13 +3336,13 @@ const Tt = p.object({
3245
3336
  "Name of browser to search in. If not specified, searches all browsers"
3246
3337
  )
3247
3338
  });
3248
- async function Cs(r, t, s) {
3339
+ async function ks(r, t, s) {
3249
3340
  let o;
3250
3341
  try {
3251
- o = Tt.parse(r);
3252
- } catch (l) {
3342
+ o = Et.parse(r);
3343
+ } catch (c) {
3253
3344
  return {
3254
- error: B(l)
3345
+ error: B(c)
3255
3346
  };
3256
3347
  }
3257
3348
  const { contextName: e, browserName: n } = o;
@@ -3259,49 +3350,49 @@ async function Cs(r, t, s) {
3259
3350
  return {
3260
3351
  error: "Session ID is required"
3261
3352
  };
3262
- const i = J(s.sessionId), a = [];
3353
+ const i = j(s.sessionId), a = [];
3263
3354
  if (n) {
3264
- const l = i.browsers.get(n);
3265
- if (!l)
3355
+ const c = i.browsers.get(n);
3356
+ if (!c)
3266
3357
  return {
3267
3358
  error: `Browser "${n}" not found`
3268
3359
  };
3269
3360
  if (e) {
3270
- const c = l.contexts.get(e);
3271
- if (!c)
3361
+ const l = c.contexts.get(e);
3362
+ if (!l)
3272
3363
  return {
3273
- error: `Context "${e}" not found in browser "${l.name}" (${l.browserType})`
3364
+ error: `Context "${e}" not found in browser "${c.name}" (${c.browserType})`
3274
3365
  };
3275
- const u = Array.from(c.pages.values());
3366
+ const u = Array.from(l.pages.values());
3276
3367
  u.length > 0 && a.push({
3277
- contextInfo: c,
3368
+ contextInfo: l,
3278
3369
  pages: u
3279
3370
  });
3280
3371
  } else
3281
- for (const c of l.contexts.values()) {
3282
- const u = Array.from(c.pages.values());
3372
+ for (const l of c.contexts.values()) {
3373
+ const u = Array.from(l.pages.values());
3283
3374
  u.length > 0 && a.push({
3284
- contextInfo: c,
3375
+ contextInfo: l,
3285
3376
  pages: u
3286
3377
  });
3287
3378
  }
3288
3379
  } else if (e)
3289
- for (const l of i.browsers.values()) {
3290
- const c = l.contexts.get(e);
3291
- if (c) {
3292
- const u = Array.from(c.pages.values());
3380
+ for (const c of i.browsers.values()) {
3381
+ const l = c.contexts.get(e);
3382
+ if (l) {
3383
+ const u = Array.from(l.pages.values());
3293
3384
  u.length > 0 && a.push({
3294
- contextInfo: c,
3385
+ contextInfo: l,
3295
3386
  pages: u
3296
3387
  });
3297
3388
  }
3298
3389
  }
3299
3390
  else
3300
- for (const l of i.browsers.values())
3301
- for (const c of l.contexts.values()) {
3302
- const u = Array.from(c.pages.values());
3391
+ for (const c of i.browsers.values())
3392
+ for (const l of c.contexts.values()) {
3393
+ const u = Array.from(l.pages.values());
3303
3394
  u.length > 0 && a.push({
3304
- contextInfo: c,
3395
+ contextInfo: l,
3305
3396
  pages: u
3306
3397
  });
3307
3398
  }
@@ -3309,29 +3400,29 @@ async function Cs(r, t, s) {
3309
3400
  pagesByContext: a
3310
3401
  };
3311
3402
  }
3312
- function vs(r, t) {
3403
+ function Os(r, t) {
3313
3404
  r(
3314
3405
  "playwright-page-list",
3315
3406
  {
3316
3407
  title: "List Pages",
3317
3408
  description: "List active pages",
3318
- inputSchema: Tt.shape
3409
+ inputSchema: Et.shape
3319
3410
  },
3320
3411
  async (s, o) => {
3321
- const e = await Cs(s, t, o);
3412
+ const e = await ks(s, t, o);
3322
3413
  if ("error" in e)
3323
3414
  return `Method: playwright-page-list(${JSON.stringify(s)})
3324
3415
  ❌ Error: ${e.error}`;
3325
3416
  let n = `Method: playwright-page-list(${JSON.stringify(s)})
3326
3417
  `;
3327
3418
  return e.pagesByContext.length === 0 ? n += "No pages found" : n += e.pagesByContext.map(
3328
- ({ contextInfo: i, pages: a }) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType}): ${a.map((l) => l.name).join(", ")}`
3419
+ ({ contextInfo: i, pages: a }) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType}): ${a.map((c) => c.name).join(", ")}`
3329
3420
  ).join(`
3330
3421
  `), n;
3331
3422
  }
3332
3423
  );
3333
3424
  }
3334
- const Ct = p.object({
3425
+ const kt = p.object({
3335
3426
  names: p.array(p.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
3336
3427
  contextName: p.string().optional().describe(
3337
3428
  "Name of context to close pages from. If not specified, searches all contexts"
@@ -3340,10 +3431,10 @@ const Ct = p.object({
3340
3431
  "Name of browser to search in. If not specified, searches all browsers"
3341
3432
  )
3342
3433
  });
3343
- async function Es(r, t, s) {
3434
+ async function Ds(r, t, s) {
3344
3435
  let o;
3345
3436
  try {
3346
- o = Ct.parse(r);
3437
+ o = kt.parse(r);
3347
3438
  } catch (f) {
3348
3439
  return {
3349
3440
  error: B(f)
@@ -3354,7 +3445,7 @@ async function Es(r, t, s) {
3354
3445
  return {
3355
3446
  error: "Session ID is required"
3356
3447
  };
3357
- const a = J(s.sessionId), l = [], c = [];
3448
+ const a = j(s.sessionId), c = [], l = [];
3358
3449
  let u = [];
3359
3450
  if (i) {
3360
3451
  const f = a.browsers.get(i);
@@ -3370,7 +3461,7 @@ async function Es(r, t, s) {
3370
3461
  };
3371
3462
  e ? e.forEach((h) => {
3372
3463
  const m = d.pages.get(h);
3373
- m ? u.push(m) : c.push(
3464
+ m ? u.push(m) : l.push(
3374
3465
  `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3375
3466
  );
3376
3467
  }) : u = Array.from(d.pages.values());
@@ -3378,7 +3469,7 @@ async function Es(r, t, s) {
3378
3469
  for (const d of f.contexts.values())
3379
3470
  e ? e.forEach((h) => {
3380
3471
  const m = d.pages.get(h);
3381
- m ? u.push(m) : c.push(
3472
+ m ? u.push(m) : l.push(
3382
3473
  `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3383
3474
  );
3384
3475
  }) : u.push(...Array.from(d.pages.values()));
@@ -3387,7 +3478,7 @@ async function Es(r, t, s) {
3387
3478
  const d = f.contexts.get(n);
3388
3479
  d && (e ? e.forEach((h) => {
3389
3480
  const m = d.pages.get(h);
3390
- m ? u.push(m) : c.push(
3481
+ m ? u.push(m) : l.push(
3391
3482
  `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3392
3483
  );
3393
3484
  }) : u.push(...Array.from(d.pages.values())));
@@ -3397,37 +3488,37 @@ async function Es(r, t, s) {
3397
3488
  for (const d of f.contexts.values())
3398
3489
  e ? e.forEach((h) => {
3399
3490
  const m = d.pages.get(h);
3400
- m ? u.push(m) : c.push(
3491
+ m ? u.push(m) : l.push(
3401
3492
  `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3402
3493
  );
3403
3494
  }) : u.push(...Array.from(d.pages.values()));
3404
3495
  return await Promise.all(
3405
3496
  u.map(async (f) => {
3406
3497
  try {
3407
- await f.page.close(), f.contextInfo.pages.delete(f.name), l.push(
3498
+ await f.page.close(), f.contextInfo.pages.delete(f.name), c.push(
3408
3499
  `${f.name} (${f.contextInfo.name}) (${f.contextInfo.browserInfo.name}) (${f.contextInfo.browserInfo.browserType})`
3409
3500
  );
3410
3501
  } catch (d) {
3411
- c.push(
3502
+ l.push(
3412
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"}`
3413
3504
  );
3414
3505
  }
3415
3506
  })
3416
3507
  ), {
3417
- closedPages: l,
3418
- ...c.length > 0 && { errors: c }
3508
+ closedPages: c,
3509
+ ...l.length > 0 && { errors: l }
3419
3510
  };
3420
3511
  }
3421
- function Ns(r, t) {
3512
+ function Rs(r, t) {
3422
3513
  r(
3423
3514
  "playwright-page-close",
3424
3515
  {
3425
3516
  title: "Close Pages",
3426
3517
  description: "Close pages",
3427
- inputSchema: Ct.shape
3518
+ inputSchema: kt.shape
3428
3519
  },
3429
3520
  async (s, o) => {
3430
- const e = await Es(s, t, o);
3521
+ const e = await Ds(s, t, o);
3431
3522
  if ("error" in e)
3432
3523
  return `Method: playwright-page-close(${JSON.stringify(s)})
3433
3524
  ❌ Error: ${e.error}`;
@@ -3438,7 +3529,7 @@ ${n.join(`
3438
3529
  }
3439
3530
  );
3440
3531
  }
3441
- const vt = p.object({
3532
+ const Ot = p.object({
3442
3533
  pageName: p.string().optional().describe("Name of previously created page to navigate"),
3443
3534
  page: $e.optional().describe(
3444
3535
  "Page creation options JSON to automatically create page"
@@ -3453,28 +3544,28 @@ const vt = p.object({
3453
3544
  - 'commit': network response received and document started loading`
3454
3545
  )
3455
3546
  });
3456
- async function ks(r, t, s) {
3547
+ async function Fs(r, t, s) {
3457
3548
  let o;
3458
3549
  try {
3459
- o = vt.parse(r);
3550
+ o = Ot.parse(r);
3460
3551
  } catch (m) {
3461
3552
  return {
3462
3553
  error: B(m)
3463
3554
  };
3464
3555
  }
3465
- const { pageName: e, page: n, url: i, timeout: a, waitUntil: l } = o;
3556
+ const { pageName: e, page: n, url: i, timeout: a, waitUntil: c } = o;
3466
3557
  if (!s.sessionId)
3467
3558
  return {
3468
3559
  error: "Session ID is required"
3469
3560
  };
3470
- const c = J(s.sessionId);
3561
+ const l = j(s.sessionId);
3471
3562
  if (e && n)
3472
3563
  return {
3473
3564
  error: "Either pageName or page must be provided, not both"
3474
3565
  };
3475
3566
  let u = !1, f = !1, d = !1, h;
3476
3567
  if (e) {
3477
- for (const m of c.browsers.values()) {
3568
+ for (const m of l.browsers.values()) {
3478
3569
  for (const g of m.contexts.values())
3479
3570
  if (g.pages.has(e)) {
3480
3571
  h = g.pages.get(e);
@@ -3487,7 +3578,7 @@ async function ks(r, t, s) {
3487
3578
  error: `Page "${e}" not found`
3488
3579
  };
3489
3580
  } else if (n) {
3490
- const m = await Mt(n, t, s);
3581
+ const m = await Nt(n, t, s);
3491
3582
  if (m.error != null)
3492
3583
  return {
3493
3584
  error: m.error
@@ -3500,7 +3591,7 @@ async function ks(r, t, s) {
3500
3591
  try {
3501
3592
  const m = await h.page.goto(i, {
3502
3593
  timeout: a * 1e3,
3503
- waitUntil: l
3594
+ waitUntil: c
3504
3595
  });
3505
3596
  return m ? {
3506
3597
  browserInfoCreated: u,
@@ -3521,16 +3612,16 @@ async function ks(r, t, s) {
3521
3612
  };
3522
3613
  }
3523
3614
  }
3524
- function Os(r, t) {
3615
+ function Bs(r, t) {
3525
3616
  r(
3526
3617
  "playwright-page-goto",
3527
3618
  {
3528
3619
  title: "Navigate Page",
3529
3620
  description: "Navigate page to URL. Use for manual browser interaction",
3530
- inputSchema: vt.shape
3621
+ inputSchema: Ot.shape
3531
3622
  },
3532
3623
  async (s, o) => {
3533
- const e = await ks(s, t, o);
3624
+ const e = await Fs(s, t, o);
3534
3625
  if (e.error != null)
3535
3626
  return `Method: playwright-page-goto(${JSON.stringify(s)})
3536
3627
  ❌ Error: ${e.error}`;
@@ -3549,13 +3640,13 @@ const Ie = p.object({
3549
3640
  ),
3550
3641
  cssSelector: p.string().describe("CSS selector to capture page content")
3551
3642
  });
3552
- async function Et(r, t, s) {
3643
+ async function Dt(r, t, s) {
3553
3644
  let o;
3554
3645
  try {
3555
3646
  o = Ie.parse(r);
3556
- } catch (l) {
3647
+ } catch (c) {
3557
3648
  return {
3558
- error: B(l)
3649
+ error: B(c)
3559
3650
  };
3560
3651
  }
3561
3652
  const { name: e, cssSelector: n } = o;
@@ -3563,7 +3654,7 @@ async function Et(r, t, s) {
3563
3654
  return {
3564
3655
  error: "Session ID is required"
3565
3656
  };
3566
- const i = J(s.sessionId), a = {
3657
+ const i = j(s.sessionId), a = {
3567
3658
  name: e,
3568
3659
  cssSelector: n
3569
3660
  };
@@ -3571,7 +3662,7 @@ async function Et(r, t, s) {
3571
3662
  snapshotQuery: a
3572
3663
  };
3573
3664
  }
3574
- function Ds(r, t) {
3665
+ function Ls(r, t) {
3575
3666
  r(
3576
3667
  "playwright-dom-snapshot-query-create",
3577
3668
  {
@@ -3580,22 +3671,22 @@ function Ds(r, t) {
3580
3671
  inputSchema: Ie.shape
3581
3672
  },
3582
3673
  async (s, o) => {
3583
- const e = await Et(s, t, o);
3674
+ const e = await Dt(s, t, o);
3584
3675
  return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3585
3676
  ❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3586
3677
  ✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
3587
3678
  }
3588
3679
  );
3589
3680
  }
3590
- function Rs(r) {
3681
+ function Ps(r) {
3591
3682
  return function(s, o) {
3592
3683
  let e, n = 0;
3593
3684
  const i = o ? o.length : 0;
3594
- let a = 1, l = 0, c = 0, u, f;
3685
+ let a = 1, c = 0, l = 0, u, f;
3595
3686
  if (o)
3596
3687
  for (let m = 0; m < o.length; m++) {
3597
3688
  const g = o[m];
3598
- n += g.countMatched, a += g.countTotal, l += g.tokens, c += g.tokensTotal;
3689
+ n += g.countMatched, a += g.countTotal, c += g.tokens, l += g.tokensTotal;
3599
3690
  }
3600
3691
  s ? (u = s.uid, f = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, f = null, e = !1);
3601
3692
  let d;
@@ -3609,7 +3700,7 @@ function Rs(r) {
3609
3700
  textClose: "</root>"
3610
3701
  };
3611
3702
  const h = ht(d);
3612
- return c += h, {
3703
+ return l += h, {
3613
3704
  uid: u,
3614
3705
  tagName: f,
3615
3706
  isMatched: e,
@@ -3617,14 +3708,14 @@ function Rs(r) {
3617
3708
  countChilds: i,
3618
3709
  countTotal: a,
3619
3710
  tokens: h,
3620
- tokensChilds: l,
3621
- tokensTotal: c,
3711
+ tokensChilds: c,
3712
+ tokensTotal: l,
3622
3713
  text: d
3623
3714
  };
3624
3715
  };
3625
3716
  }
3626
- function Fs(r, t) {
3627
- const s = ne(t), o = s.getChilds(s.root), e = ft({
3717
+ function As(r, t) {
3718
+ const s = ae(t), o = s.getChilds(s.root), e = ft({
3628
3719
  getId: (n) => {
3629
3720
  const i = s.getId(n);
3630
3721
  if (i == null)
@@ -3634,10 +3725,10 @@ function Fs(r, t) {
3634
3725
  return i;
3635
3726
  },
3636
3727
  getChilds: (n) => s.getChilds(n),
3637
- createSnapshotNode: Rs(),
3728
+ createSnapshotNode: Ps(),
3638
3729
  rootNodes: o ?? []
3639
3730
  });
3640
- return ne(e);
3731
+ return ae(e);
3641
3732
  }
3642
3733
  const Me = p.object({
3643
3734
  pageName: p.string().describe("Name of previously created page, to create snapshot from"),
@@ -3649,7 +3740,7 @@ const Me = p.object({
3649
3740
  "Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
3650
3741
  )
3651
3742
  });
3652
- async function Nt(r, t, s) {
3743
+ async function Rt(r, t, s) {
3653
3744
  let o;
3654
3745
  try {
3655
3746
  o = Me.parse(r);
@@ -3663,17 +3754,17 @@ async function Nt(r, t, s) {
3663
3754
  return {
3664
3755
  error: "Session ID is required"
3665
3756
  };
3666
- const l = J(s.sessionId);
3667
- let c;
3668
- for (const d of l.browsers.values()) {
3757
+ const c = j(s.sessionId);
3758
+ let l;
3759
+ for (const d of c.browsers.values()) {
3669
3760
  for (const h of d.contexts.values())
3670
3761
  if (h.pages.has(e)) {
3671
- c = h.pages.get(e);
3762
+ l = h.pages.get(e);
3672
3763
  break;
3673
3764
  }
3674
- if (c) break;
3765
+ if (l) break;
3675
3766
  }
3676
- if (!c)
3767
+ if (!l)
3677
3768
  return {
3678
3769
  error: `Page "${e}" not found`
3679
3770
  };
@@ -3683,14 +3774,14 @@ async function Nt(r, t, s) {
3683
3774
  };
3684
3775
  let u, f = !1;
3685
3776
  if (n) {
3686
- const d = l.domSnapshotQueries.get(n);
3777
+ const d = c.domSnapshotQueries.get(n);
3687
3778
  if (!d)
3688
3779
  return {
3689
3780
  error: `DOM snapshot query "${n}" not found`
3690
3781
  };
3691
3782
  u = d;
3692
3783
  } else if (i) {
3693
- const d = await Et(
3784
+ const d = await Dt(
3694
3785
  i,
3695
3786
  t,
3696
3787
  s
@@ -3705,7 +3796,7 @@ async function Nt(r, t, s) {
3705
3796
  error: "Either queryName or query must be provided"
3706
3797
  };
3707
3798
  try {
3708
- const d = await c.page.evaluate(
3799
+ const d = await l.page.evaluate(
3709
3800
  (y) => {
3710
3801
  const w = window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom;
3711
3802
  if (!w)
@@ -3720,12 +3811,12 @@ async function Nt(r, t, s) {
3720
3811
  ), h = {
3721
3812
  idToNode: new Map(d.idToNode),
3722
3813
  idToChildIds: new Map(d.idToChildIds)
3723
- }, m = Fs(u, h), g = {
3814
+ }, m = As(u, h), g = {
3724
3815
  name: a,
3725
3816
  query: u,
3726
3817
  tree: m
3727
3818
  };
3728
- return c.domSnapshots.set(a, g), {
3819
+ return l.domSnapshots.set(a, g), {
3729
3820
  domSnapshot: g,
3730
3821
  queryCreated: f
3731
3822
  };
@@ -3735,7 +3826,7 @@ async function Nt(r, t, s) {
3735
3826
  };
3736
3827
  }
3737
3828
  }
3738
- function Bs(r, t) {
3829
+ function zs(r, t) {
3739
3830
  r(
3740
3831
  "playwright-dom-snapshot-create",
3741
3832
  {
@@ -3744,7 +3835,7 @@ function Bs(r, t) {
3744
3835
  inputSchema: Me.shape
3745
3836
  },
3746
3837
  async (s, o) => {
3747
- const e = await Nt(s, t, o);
3838
+ const e = await Rt(s, t, o);
3748
3839
  if (e.error != null)
3749
3840
  return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
3750
3841
  ❌ Error: ${e.error}`;
@@ -3755,7 +3846,7 @@ function Bs(r, t) {
3755
3846
  }
3756
3847
  );
3757
3848
  }
3758
- class Ls {
3849
+ class Us {
3759
3850
  tokens = 20;
3760
3851
  getReportText = (t) => ({
3761
3852
  indent: !0,
@@ -3769,7 +3860,7 @@ class Ls {
3769
3860
  tokensGrouped: s.tokens
3770
3861
  } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
3771
3862
  }
3772
- const kt = p.object({
3863
+ const Ft = p.object({
3773
3864
  snapshotName: p.string().optional().describe("Name of previously created DOM snapshot, to use"),
3774
3865
  snapshot: Me.optional().describe(
3775
3866
  "DOM snapshot creation options JSON to automatically create snapshot"
@@ -3789,10 +3880,10 @@ const kt = p.object({
3789
3880
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
3790
3881
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
3791
3882
  });
3792
- async function Ps(r, t, s) {
3883
+ async function qs(r, t, s) {
3793
3884
  let o;
3794
3885
  try {
3795
- o = kt.parse(r);
3886
+ o = Ft.parse(r);
3796
3887
  } catch (g) {
3797
3888
  return {
3798
3889
  error: B(g)
@@ -3806,12 +3897,12 @@ async function Ps(r, t, s) {
3806
3897
  // maxTokensTotal,
3807
3898
  // maxCountGroup,
3808
3899
  // maxTokensGroup,
3809
- } = o, a = 60, l = 1e3, c = 25, u = 900;
3900
+ } = o, a = 60, c = 1e3, l = 25, u = 900;
3810
3901
  if (!s.sessionId)
3811
3902
  return {
3812
3903
  error: "Session ID is required"
3813
3904
  };
3814
- const f = J(s.sessionId);
3905
+ const f = j(s.sessionId);
3815
3906
  if (e && n)
3816
3907
  return {
3817
3908
  error: "Either snapshotName or snapshot must be provided, not both"
@@ -3834,7 +3925,7 @@ async function Ps(r, t, s) {
3834
3925
  error: `DOM snapshot "${e}" not found`
3835
3926
  };
3836
3927
  } else if (n) {
3837
- const g = await Nt(
3928
+ const g = await Rt(
3838
3929
  n,
3839
3930
  t,
3840
3931
  s
@@ -3856,12 +3947,12 @@ async function Ps(r, t, s) {
3856
3947
  childsIndexRange: i,
3857
3948
  limits: {
3858
3949
  maxCountTotal: a,
3859
- maxTokensTotal: l,
3860
- maxCountGroup: c,
3950
+ maxTokensTotal: c,
3951
+ maxCountGroup: l,
3861
3952
  maxTokensGroup: u
3862
3953
  }
3863
3954
  },
3864
- indexRangeGroupStrategy: new Ls()
3955
+ indexRangeGroupStrategy: new Us()
3865
3956
  }), w = mt(y);
3866
3957
  return {
3867
3958
  domSnapshot: d,
@@ -3877,16 +3968,16 @@ async function Ps(r, t, s) {
3877
3968
  };
3878
3969
  }
3879
3970
  }
3880
- function As(r, t) {
3971
+ function _s(r, t) {
3881
3972
  r(
3882
3973
  "playwright-dom-snapshot-browse",
3883
3974
  {
3884
3975
  title: "Browse DOM Snapshot",
3885
3976
  description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
3886
- inputSchema: kt.shape
3977
+ inputSchema: Ft.shape
3887
3978
  },
3888
3979
  async (s, o) => {
3889
- const e = await Ps(s, t, o);
3980
+ const e = await qs(s, t, o);
3890
3981
  if (e.error != null)
3891
3982
  return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
3892
3983
  ❌ Error: ${e.error}`;
@@ -3898,8 +3989,8 @@ function As(r, t) {
3898
3989
  `, n += `CSS Selector: ${e.domSnapshot.query.cssSelector}
3899
3990
  `, n += `Parent UID: ${e.parentUid ?? "null (root node)"}
3900
3991
  `, e.childsIndexRange) {
3901
- const [i, a] = e.childsIndexRange, c = (e.parentUid ? e.domSnapshot.tree.getNode(e.parentUid) : e.domSnapshot.tree.root).countChilds;
3902
- n += ` Showing indexes: ${i}-${a} of ${c}
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}
3903
3994
  `;
3904
3995
  }
3905
3996
  return n += `
@@ -3907,13 +3998,13 @@ ${e.report}`, n;
3907
3998
  }
3908
3999
  );
3909
4000
  }
3910
- function zs(r, t) {
3911
- t.browserCreate && hs(r, t), t.browserList && ms(r, t), t.browserClose && ws(r, t), t.contextCreate && ys(r, t), t.contextList && Ss(r, t), t.contextClose && $s(r, t), t.pageCreate && Ts(r, t), t.pageList && vs(r, t), t.pageClose && Ns(r, t), t.pageGoto && Os(r, t), t.domSnapshotQueryCreate && Ds(r, t), t.domSnapshotCreate && Bs(r, t), t.domSnapshotBrowse && As(r, t), console.log("Playwright manager");
4001
+ function Gs(r, t) {
4002
+ t.browserCreate && ws(r, t), t.browserList && bs(r, t), t.browserClose && xs(r, t), t.contextCreate && $s(r, t), t.contextList && Ms(r, t), t.contextClose && Cs(r, t), t.pageCreate && Es(r, t), t.pageList && Os(r, t), t.pageClose && Rs(r, t), t.pageGoto && Bs(r, t), t.domSnapshotQueryCreate && Ls(r, t), t.domSnapshotCreate && zs(r, t), t.domSnapshotBrowse && _s(r, t), console.log("Playwright manager");
3912
4003
  }
3913
- function Us(r) {
4004
+ function Js(r) {
3914
4005
  const { logFilePath: t } = r;
3915
4006
  return async function(o, e, n, i) {
3916
- await se({
4007
+ await ne({
3917
4008
  logFilePath: t,
3918
4009
  message: "ERROR",
3919
4010
  data: {
@@ -3932,25 +4023,25 @@ function Us(r) {
3932
4023
  });
3933
4024
  };
3934
4025
  }
3935
- function Ot() {
4026
+ function Bt() {
3936
4027
  return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
3937
4028
  }
3938
- function _s(r) {
3939
- const t = re(), s = qs();
4029
+ function js(r) {
4030
+ const t = oe(), s = Ks();
3940
4031
  return t.use(s), t;
3941
4032
  }
3942
- function qs(r) {
3943
- const t = re.Router();
4033
+ function Ks(r) {
4034
+ const t = oe.Router();
3944
4035
  return t.use((s, o, e) => {
3945
4036
  s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
3946
- }), t.use(re.json()), t;
4037
+ }), t.use(oe.json()), t;
3947
4038
  }
3948
- function Gs(r) {
3949
- const t = re.Router();
3950
- return t.use(Kt({ authToken: r.authToken })), t.all("/mcp", Vt(r)), t;
4039
+ function Ws(r) {
4040
+ const t = oe.Router();
4041
+ return t.use(Yt({ authToken: r.authToken })), t.all("/mcp", tr(r)), t;
3951
4042
  }
3952
- function js(r, t) {
3953
- return r.use(Us({ logFilePath: t.logFilePath })), new Promise((s, o) => {
4043
+ function Hs(r, t) {
4044
+ return r.use(Js({ logFilePath: t.logFilePath })), new Promise((s, o) => {
3954
4045
  let e;
3955
4046
  const n = () => {
3956
4047
  s(e);
@@ -3964,7 +4055,7 @@ function js(r, t) {
3964
4055
  }
3965
4056
  });
3966
4057
  }
3967
- function Js(r, t) {
4058
+ function Qs(r, t) {
3968
4059
  if (!r.address())
3969
4060
  throw new Error("Server address is not available. Check your DNS and host configuration.");
3970
4061
  const o = r.address().family, e = r.address().port;
@@ -3978,37 +4069,37 @@ Server Version: ${t.version}
3978
4069
  Server URL: ${i}/mcp
3979
4070
  SSE Endpoint: ${i}/sse
3980
4071
 
3981
- Log File: ${R.resolve(t.logFilePath)}`;
4072
+ Log File: ${F.resolve(t.logFilePath)}`;
3982
4073
  }
3983
- function Ks(r, t) {
3984
- const s = R.join(t.logDir, Ot()), o = mr(r, {
4074
+ function Ys(r, t) {
4075
+ const s = F.join(t.logDir, Bt()), o = br(r, {
3985
4076
  logFilePath: s
3986
4077
  });
3987
- t.tools.processManager && pr(o, t.tools.processManager), t.tools.fsManager && fs(o, t.tools.fsManager), t.tools.playwrightManager && zs(o, {
4078
+ t.tools.processManager && yr(o, t.tools.processManager), t.tools.fsManager && gs(o, t.tools.fsManager), t.tools.playwrightManager && Gs(o, {
3988
4079
  ...t.tools.playwrightManager
3989
4080
  });
3990
4081
  }
3991
- async function fo(r) {
3992
- const t = R.join(r.logDir, Ot()), s = _s(), o = Gs({
4082
+ async function go(r) {
4083
+ const t = F.join(r.logDir, Bt()), s = js(), o = Ws({
3993
4084
  ...r,
3994
4085
  logFilePath: t,
3995
4086
  createMcpServer: () => {
3996
- const n = new Dt({
4087
+ const n = new Lt({
3997
4088
  title: r.title,
3998
4089
  name: r.name,
3999
4090
  version: r.version
4000
4091
  });
4001
- return Ks(n, r), n;
4092
+ return Ys(n, r), n;
4002
4093
  }
4003
4094
  });
4004
4095
  s.use(o);
4005
- const e = await js(s, {
4096
+ const e = await Hs(s, {
4006
4097
  host: r.host,
4007
4098
  port: r.port,
4008
4099
  logFilePath: t
4009
4100
  });
4010
4101
  return console.log(
4011
- Js(e, {
4102
+ Qs(e, {
4012
4103
  title: r.title,
4013
4104
  name: r.name,
4014
4105
  version: r.version,
@@ -4017,10 +4108,10 @@ async function fo(r) {
4017
4108
  ), e;
4018
4109
  }
4019
4110
  export {
4020
- uo as A,
4021
- co as S,
4022
- lo as a,
4023
- ao as b,
4024
- vr as p,
4025
- fo as s
4111
+ mo as A,
4112
+ po as S,
4113
+ ho as a,
4114
+ fo as b,
4115
+ Or as p,
4116
+ go as s
4026
4117
  };