@flemist/mcp-project-tools 4.0.0 → 4.0.2

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,22 +1,22 @@
1
1
  import ne from "express";
2
2
  import { McpServer as Kt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { randomUUID as Wt } from "crypto";
3
+ import { randomUUID as Ht } from "crypto";
4
4
  import * as j from "fs";
5
5
  import * as k from "path";
6
- import { StreamableHTTPServerTransport as Ht } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
- import { spawn as Qt } from "child_process";
8
- import { z as h } from "zod";
6
+ import { StreamableHTTPServerTransport as Qt } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
+ import { spawn as Yt } from "child_process";
8
+ import { z as m } from "zod";
9
9
  import he from "tree-kill";
10
- import { Pool as Yt, poolRunWait as V } from "@flemist/time-limits";
10
+ import { Pool as Vt, poolRunWait as V } from "@flemist/time-limits";
11
11
  import { priorityCreate as X } from "@flemist/priority-queue";
12
- import { useAbortController as Vt, combineAbortSignals as Zt, Locker as Xt } from "@flemist/async-utils";
13
- import er from "node:os";
14
- import tr from "picomatch";
15
- import { webkit as rr, firefox as sr, chromium as or } from "playwright";
16
- import nr from "deepmerge";
17
- import Ee from "json5";
18
- import ir from "js-yaml";
19
- function ar(r) {
12
+ import { useAbortController as Zt, combineAbortSignals as Xt, Locker as er } from "@flemist/async-utils";
13
+ import tr from "node:os";
14
+ import rr from "picomatch";
15
+ import { webkit as sr, firefox as or, chromium as nr } from "playwright";
16
+ import ir from "deepmerge";
17
+ import Ne from "json5";
18
+ import ar from "js-yaml";
19
+ function lr(r) {
20
20
  const { authToken: t } = r;
21
21
  return function(o, e, n) {
22
22
  if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
@@ -39,12 +39,12 @@ ${n}
39
39
  }
40
40
  }
41
41
  const ae = /* @__PURE__ */ new Map();
42
- function lr(r) {
42
+ function cr(r) {
43
43
  return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
44
44
  }
45
- async function cr(r, t) {
46
- const s = await t.createMcpServer(r), o = new Ht({
47
- sessionIdGenerator: Wt,
45
+ async function ur(r, t) {
46
+ const s = await t.createMcpServer(r), o = new Qt({
47
+ sessionIdGenerator: Ht,
48
48
  onsessioninitialized: (n) => {
49
49
  ae.set(n, o);
50
50
  },
@@ -66,16 +66,16 @@ async function cr(r, t) {
66
66
  throw await e(), n;
67
67
  }
68
68
  }
69
- async function ur(r, t, s, o) {
69
+ async function dr(r, t, s, o) {
70
70
  await ie({
71
71
  logFilePath: s.logFilePath,
72
72
  message: "REQUEST",
73
73
  data: r.body
74
74
  });
75
75
  let e = o ? ae.get(o) : null;
76
- e || (e = await cr(r, s)), await e.handleRequest(r, t, r.body);
76
+ e || (e = await ur(r, s)), await e.handleRequest(r, t, r.body);
77
77
  }
78
- async function dr(r, t, s) {
78
+ async function fr(r, t, s) {
79
79
  const o = s ? ae.get(s) : null;
80
80
  if (!o) {
81
81
  t.status(400).json({ error: "No valid session found" });
@@ -83,11 +83,11 @@ async function dr(r, t, s) {
83
83
  }
84
84
  await o.handleRequest(r, t);
85
85
  }
86
- function fr(r) {
86
+ function pr(r) {
87
87
  return async function(s, o) {
88
88
  try {
89
- const e = lr(s);
90
- s.method === "POST" ? await ur(s, o, r, e) : s.method === "GET" ? await dr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
89
+ const e = cr(s);
90
+ s.method === "POST" ? await dr(s, o, r, e) : s.method === "GET" ? await fr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
91
91
  } catch (e) {
92
92
  console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
93
93
  error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
@@ -96,9 +96,9 @@ function fr(r) {
96
96
  };
97
97
  }
98
98
  const Y = /* @__PURE__ */ new Map();
99
- let pr = 0;
100
- const Ne = 10, hr = 1800 * 1e3, J = 1e4, Q = 2e3, mr = 5e3;
101
- function gr(r) {
99
+ let hr = 0;
100
+ const ke = 10, mr = 1800 * 1e3, J = 1e4, Q = 2e3, gr = 5e3;
101
+ function wr(r) {
102
102
  const { commandLine: t, commandLineRules: s } = r;
103
103
  let o = !1;
104
104
  for (const e of s)
@@ -115,14 +115,14 @@ function gr(r) {
115
115
  }
116
116
  return o;
117
117
  }
118
- function wr() {
119
- return ++pr;
120
- }
121
- let ke = !1;
122
118
  function yr() {
123
- if (ke)
119
+ return ++hr;
120
+ }
121
+ let Oe = !1;
122
+ function br() {
123
+ if (Oe)
124
124
  return;
125
- ke = !0;
125
+ Oe = !0;
126
126
  const r = () => {
127
127
  console.log("Auto-killing all child processes...");
128
128
  for (const [t, s] of Array.from(Y.entries()))
@@ -139,41 +139,41 @@ function yr() {
139
139
  function ge() {
140
140
  const r = Date.now(), t = [];
141
141
  for (const [s, o] of Array.from(Y.entries()))
142
- !o.isRunning && o.endTime && r - o.endTime.getTime() > hr && t.push(s);
142
+ !o.isRunning && o.endTime && r - o.endTime.getTime() > mr && t.push(s);
143
143
  for (const s of t)
144
144
  Y.delete(s);
145
145
  }
146
- const br = 1800 * 1e3, Oe = /* @__PURE__ */ new Map();
147
- let Sr = 0;
148
- function xr() {
149
- return ++Sr;
146
+ const Sr = 1800 * 1e3, De = /* @__PURE__ */ new Map();
147
+ let xr = 0;
148
+ function $r() {
149
+ return ++xr;
150
150
  }
151
- function st(r) {
152
- let t = Oe.get(r);
151
+ function ot(r) {
152
+ let t = De.get(r);
153
153
  return t == null && (t = {
154
154
  storedOutputs: /* @__PURE__ */ new Map()
155
- }, Oe.set(r, t)), t;
155
+ }, De.set(r, t)), t;
156
156
  }
157
- function ot(r) {
157
+ function nt(r) {
158
158
  return typeof r == "function" ? r() : r;
159
159
  }
160
- function nt(r, t) {
160
+ function it(r, t) {
161
161
  return setTimeout(() => {
162
162
  r.storedOutputs.delete(t);
163
- }, br);
163
+ }, Sr);
164
164
  }
165
- function $r(r, t, s) {
166
- clearTimeout(s.cleanupTimer), s.cleanupTimer = nt(r, t);
165
+ function Ir(r, t, s) {
166
+ clearTimeout(s.cleanupTimer), s.cleanupTimer = it(r, t);
167
167
  }
168
- function Ir(r) {
169
- const { sessionId: t, source: s } = r, o = st(t), e = xr(), n = {
168
+ function Mr(r) {
169
+ const { sessionId: t, source: s } = r, o = ot(t), e = $r(), n = {
170
170
  source: s,
171
- cleanupTimer: nt(o, e)
171
+ cleanupTimer: it(o, e)
172
172
  };
173
173
  return o.storedOutputs.set(e, n), e;
174
174
  }
175
- function it(r) {
176
- const { sessionId: t, outputId: s, range: o } = r, [e, n] = o, i = st(t), a = i.storedOutputs.get(s);
175
+ function at(r) {
176
+ const { sessionId: t, outputId: s, range: o } = r, [e, n] = o, i = ot(t), a = i.storedOutputs.get(s);
177
177
  if (a == null)
178
178
  return {
179
179
  content: "",
@@ -181,15 +181,15 @@ function it(r) {
181
181
  range: [0, 0],
182
182
  error: `Stored output with outputId=${s} not found or expired`
183
183
  };
184
- $r(i, s, a);
185
- const c = ot(a.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
184
+ Ir(i, s, a);
185
+ const c = nt(a.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
186
186
  return { content: c.substring(u, f), total: l, range: [u, f] };
187
187
  }
188
188
  function we(r) {
189
- const { sessionId: t, source: s, limit: o } = r, e = ot(s);
189
+ const { sessionId: t, source: s, limit: o } = r, e = nt(s);
190
190
  if (e.length <= o)
191
191
  return { content: e, outputId: null };
192
- const n = Ir({ sessionId: t, source: s }), i = it({
192
+ const n = Mr({ sessionId: t, source: s }), i = at({
193
193
  sessionId: t,
194
194
  outputId: n,
195
195
  range: [0, o]
@@ -205,16 +205,16 @@ function F(r) {
205
205
 
206
206
  Provide valid parameters according to schema.`;
207
207
  }
208
- const at = h.object({
209
- outputId: h.number().int().describe("Output ID from truncation message"),
210
- range: h.tuple([h.number().int().min(0), h.number().int().min(0)]).describe(
208
+ const lt = m.object({
209
+ outputId: m.number().int().describe("Output ID from truncation message"),
210
+ range: m.tuple([m.number().int().min(0), m.number().int().min(0)]).describe(
211
211
  `Character range [from, to) to retrieve. Maximum range size: ${J}.`
212
212
  )
213
213
  });
214
- function Mr(r, t) {
214
+ function Tr(r, t) {
215
215
  let s;
216
216
  try {
217
- s = at.parse(r);
217
+ s = lt.parse(r);
218
218
  } catch (i) {
219
219
  return {
220
220
  error: F(i)
@@ -233,23 +233,23 @@ function Mr(r, t) {
233
233
  return {
234
234
  error: `Range size ${e - o} exceeds maximum ${J}`
235
235
  };
236
- const n = it({
236
+ const n = at({
237
237
  sessionId: t.sessionId,
238
238
  outputId: s.outputId,
239
239
  range: s.range
240
240
  });
241
241
  return n.error != null ? { error: n.error } : { content: n.content, total: n.total, range: n.range };
242
242
  }
243
- function Tr(r) {
243
+ function Cr(r) {
244
244
  r(
245
245
  "output-read",
246
246
  {
247
247
  title: "Read Stored Output Range",
248
248
  description: "Read any range from stored output. Use outputId from truncation message and specify character range [from, to).",
249
- inputSchema: at.shape
249
+ inputSchema: lt.shape
250
250
  },
251
251
  async (t, s) => {
252
- const o = Mr(t, s);
252
+ const o = Tr(t, s);
253
253
  if (o.error != null)
254
254
  return `Method: output-read(${JSON.stringify(t)})
255
255
  ❌ Error: ${o.error}`;
@@ -263,14 +263,14 @@ ${o.content}`, a;
263
263
  }
264
264
  );
265
265
  }
266
- function Cr(r) {
267
- Tr(r);
266
+ function Er(r) {
267
+ Cr(r);
268
268
  }
269
- const lt = h.object({
270
- id: h.number().describe(
269
+ const ct = m.object({
270
+ id: m.number().describe(
271
271
  "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"
272
272
  ),
273
- outputLimit: h.number().int().min(0).max(J).default(Q).describe(
273
+ outputLimit: m.number().int().min(0).max(J).default(Q).describe(
274
274
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
275
275
  )
276
276
  });
@@ -278,7 +278,7 @@ async function ye(r, t, s) {
278
278
  ge();
279
279
  let o;
280
280
  try {
281
- o = lt.parse(r);
281
+ o = ct.parse(r);
282
282
  } catch (c) {
283
283
  return {
284
284
  error: F(c)
@@ -317,7 +317,7 @@ function vr(r, t) {
317
317
  {
318
318
  title: "Get Host Machine Process Status",
319
319
  description: "Get detailed status information about a process on the host machine. Use this to check if commands completed successfully, get their output, or monitor running processes",
320
- inputSchema: lt.shape
320
+ inputSchema: ct.shape
321
321
  },
322
322
  async (s, o) => {
323
323
  const e = await ye(s, t, o);
@@ -333,36 +333,36 @@ ${n.trim()}`;
333
333
  }
334
334
  );
335
335
  }
336
- function ct(r) {
336
+ function ut(r) {
337
337
  he(r, "SIGTERM", (t) => {
338
338
  t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
339
339
  }), setTimeout(() => {
340
340
  he(r, "SIGKILL", (t) => {
341
341
  t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
342
342
  });
343
- }, mr);
343
+ }, gr);
344
344
  }
345
- const ut = h.object({
346
- id: h.number().describe(
345
+ const dt = m.object({
346
+ id: m.number().describe(
347
347
  "Process ID to wait for completion. Get process IDs using process-list. The process can be running or already completed. Examples: 1, 42, 123"
348
348
  ),
349
- waitTime: h.number().optional().describe(
349
+ waitTime: m.number().optional().describe(
350
350
  "Maximum time to wait in seconds for process completion. If omitted, waits indefinitely until process completes. If process is already completed, returns immediately. Examples: 30 (wait up to 30 seconds), 300 (wait up to 5 minutes)"
351
351
  ),
352
- autoKill: h.boolean().default(!1).describe(
352
+ autoKill: m.boolean().default(!1).describe(
353
353
  "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"
354
354
  ),
355
- outputLimit: h.number().int().min(0).max(J).default(Q).describe(
355
+ outputLimit: m.number().int().min(0).max(J).default(Q).describe(
356
356
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
357
357
  )
358
358
  });
359
- async function dt(r, t, s) {
359
+ async function ft(r, t, s) {
360
360
  let o;
361
361
  try {
362
- o = ut.parse(r);
363
- } catch (g) {
362
+ o = dt.parse(r);
363
+ } catch (h) {
364
364
  return {
365
- error: F(g)
365
+ error: F(h)
366
366
  };
367
367
  }
368
368
  const { id: e, waitTime: n, autoKill: i, outputLimit: a } = o, c = Y.get(e);
@@ -372,9 +372,9 @@ async function dt(r, t, s) {
372
372
  };
373
373
  const l = Date.now();
374
374
  let u = !1, f = !1;
375
- n != null && await new Promise((m) => {
375
+ n != null && await new Promise((g) => {
376
376
  const y = setInterval(() => {
377
- c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, i && c.pid && (ct(c.pid), f = !0), m()) : (clearInterval(y), m());
377
+ c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, i && c.pid && (ut(c.pid), f = !0), g()) : (clearInterval(y), g());
378
378
  }, 100);
379
379
  });
380
380
  const d = (Date.now() - l) / 1e3;
@@ -385,16 +385,16 @@ async function dt(r, t, s) {
385
385
  autoKillExecuted: f
386
386
  };
387
387
  }
388
- function Er(r, t) {
388
+ function Nr(r, t) {
389
389
  r(
390
390
  "process-wait",
391
391
  {
392
392
  title: "Wait for Host Machine Process",
393
393
  description: "Wait for a host machine process to complete execution, with optional timeout and auto-kill functionality. Use this for long-running commands like builds, installs, or tests when you need final results",
394
- inputSchema: ut.shape
394
+ inputSchema: dt.shape
395
395
  },
396
396
  async (s, o) => {
397
- const e = await dt(s, t, o);
397
+ const e = await ft(s, t, o);
398
398
  if (!("output" in e))
399
399
  return `Method: process-wait(${JSON.stringify(s)})
400
400
  ❌ Error: ${e.error}`;
@@ -407,86 +407,106 @@ ${n.trim()}`;
407
407
  }
408
408
  );
409
409
  }
410
- const ft = h.object({
411
- relativeRootDir: h.string().optional().describe(
410
+ function H(r) {
411
+ return r.replace(/\\/g, "/");
412
+ }
413
+ function be(r, t) {
414
+ const s = H(k.resolve(r)), o = H(
415
+ k.resolve(r, t || "")
416
+ );
417
+ return !o.startsWith(s + "/") && o !== s ? {
418
+ error: `Path "${t}" escapes root directory "${r}". Resolved path: "${o}"`
419
+ } : { path: o };
420
+ }
421
+ const pt = m.object({
422
+ relativeRootDir: m.string().optional().describe(
412
423
  'Relative path from project root to working directory for command execution. Use forward slashes. Leave empty for project root. Examples: "src", "src/tools", "tests/unit". Directory must exist'
413
424
  ),
414
- commandLine: h.string().describe(
425
+ commandLine: m.string().describe(
415
426
  'Complete command line to execute on the host machine. Include all arguments and options. Examples: "npm install", "pnpm build", "node script.js --verbose", "git status". Command must be in the allowed commands list for security'
416
427
  ),
417
- waitTime: h.number().optional().describe(
428
+ waitTime: m.number().optional().describe(
418
429
  "Time to wait in seconds for process completion before returning results. If specified, will wait this long then return final status. If omitted, returns immediately with initial status. Use process-wait or process-status to check progress later. Examples: 30 (wait 30 seconds), 120 (wait 2 minutes)"
419
430
  ),
420
- autoKill: h.boolean().default(!1).describe(
431
+ autoKill: m.boolean().default(!1).describe(
421
432
  "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"
422
433
  ),
423
- outputLimit: h.number().int().min(0).max(J).default(Q).describe(
434
+ outputLimit: m.number().int().min(0).max(J).default(Q).describe(
424
435
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
425
436
  )
426
437
  });
427
- async function Nr(r, t, s) {
438
+ async function kr(r, t, s) {
428
439
  ge();
429
440
  let o;
430
441
  try {
431
- o = ft.parse(r);
432
- } catch (p) {
442
+ o = pt.parse(r);
443
+ } catch (h) {
433
444
  return {
434
- error: F(p)
445
+ error: F(h)
435
446
  };
436
447
  }
437
- const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = t, l = k.resolve(t.workingDir || "", o.relativeRootDir || "");
438
- if (!gr({ commandLine: e, commandLineRules: c })) {
439
- const p = c.map(
448
+ const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = t;
449
+ if (!t.workingDir)
450
+ return { error: "Working directory is not configured" };
451
+ const l = be(
452
+ t.workingDir,
453
+ o.relativeRootDir
454
+ );
455
+ if ("error" in l)
456
+ return { error: l.error };
457
+ const u = l.path;
458
+ if (!wr({ commandLine: e, commandLineRules: c })) {
459
+ const h = c.map(
440
460
  (g) => `${g.rule.toUpperCase()}: /${g.regexp}/ (${g.note})`
441
461
  ).join(`
442
462
  `);
443
463
  return {
444
464
  error: `Command line not allowed: "${e}". For security, command lines are validated against configured rules in order. Command line was denied by the rule evaluation. Current command line rules:
445
- ${p}
465
+ ${h}
446
466
 
447
467
  To use this command line, ask the user to modify the command line rules in the configuration.`
448
468
  };
449
469
  }
450
470
  if (Array.from(Y.values()).filter(
451
- (p) => p.isRunning
452
- ).length >= Ne)
471
+ (h) => h.isRunning
472
+ ).length >= ke)
453
473
  return {
454
- error: `Maximum concurrent process limit reached (${Ne} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
474
+ error: `Maximum concurrent process limit reached (${ke} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
455
475
  };
456
- const f = wr(), d = {
457
- id: f,
458
- cwd: l,
476
+ const d = yr(), p = {
477
+ id: d,
478
+ cwd: u,
459
479
  commandLine: e,
460
480
  startTime: /* @__PURE__ */ new Date(),
461
481
  isRunning: !0,
462
482
  output: ""
463
483
  };
464
- Y.set(f, d);
484
+ Y.set(d, p);
465
485
  try {
466
- const p = Qt(e, [], {
486
+ const h = Yt(e, [], {
467
487
  shell: !0,
468
- cwd: l,
488
+ cwd: u,
469
489
  stdio: ["pipe", "pipe", "pipe"]
470
490
  });
471
- d.pid = p.pid;
472
- const g = (m) => {
473
- const y = m.toString();
474
- d.output += y, console.log(y);
491
+ p.pid = h.pid;
492
+ const g = (y) => {
493
+ const w = y.toString();
494
+ p.output += w, console.log(w);
475
495
  };
476
- return p.stdout?.on("data", g), p.stderr?.on("data", g), p.on("close", (m) => {
477
- d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.exitCode = m !== null ? m : void 0, console.log(`Process ${f} (${e}) exited with code ${m}`);
478
- }), p.on("error", (m) => {
479
- d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = m.message, console.error(`Process ${f} error:`, m.message);
480
- }), n != null ? dt(
481
- { id: f, waitTime: n, autoKill: i, outputLimit: a },
496
+ return h.stdout?.on("data", g), h.stderr?.on("data", g), h.on("close", (y) => {
497
+ p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.exitCode = y !== null ? y : void 0, console.log(`Process ${d} (${e}) exited with code ${y}`);
498
+ }), h.on("error", (y) => {
499
+ p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = y.message, console.error(`Process ${d} error:`, y.message);
500
+ }), n != null ? ft(
501
+ { id: d, waitTime: n, autoKill: i, outputLimit: a },
482
502
  t,
483
503
  s
484
- ) : ye({ id: f, outputLimit: a }, t, s);
485
- } catch (p) {
486
- return d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = p instanceof Error ? p.message : "Unknown error", { error: d.error };
504
+ ) : ye({ id: d, outputLimit: a }, t, s);
505
+ } catch (h) {
506
+ return p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = h instanceof Error ? h.message : "Unknown error", { error: p.error };
487
507
  }
488
508
  }
489
- function kr(r, t) {
509
+ function Or(r, t) {
490
510
  const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
491
511
  `);
492
512
  r(
@@ -495,10 +515,10 @@ function kr(r, t) {
495
515
  title: "Execute Command Line on Host Machine",
496
516
  description: `Execute command lines on the host machine. Use this to build, test, lint, install packages, or run system commands. Prefer process-run with waitTime parameter if you need to immediately execute and wait for completion, instead of separate process-run and process-wait calls. Security: Command lines are validated against configured rules processed in order (later rules override earlier ones). Current command line rules:
497
517
  ${s}`,
498
- inputSchema: ft.shape
518
+ inputSchema: pt.shape
499
519
  },
500
520
  async (o, e) => {
501
- const n = await Nr(o, t, e);
521
+ const n = await kr(o, t, e);
502
522
  if (!("output" in n))
503
523
  return `Method: process-run(${JSON.stringify(o)})
504
524
  ❌ Error: ${n.error}`;
@@ -511,25 +531,25 @@ ${i.trim()}`;
511
531
  }
512
532
  );
513
533
  }
514
- const pt = h.object({
515
- minOpenDateTime: h.string().optional().describe(
534
+ const ht = m.object({
535
+ minOpenDateTime: m.string().optional().describe(
516
536
  'Filter to processes started after this datetime. Accepts ISO format or space-separated format. Examples: "2024-01-15T10:30:00Z", "2024-01-15 10:30:00". Underscores and spaces are converted to standard ISO format internally'
517
537
  ),
518
- minCloseDateTime: h.string().optional().describe(
538
+ minCloseDateTime: m.string().optional().describe(
519
539
  'Filter to processes that finished after this datetime. Only applies to completed processes. Accepts ISO format or space-separated format. Examples: "2024-01-15T14:30:00Z", "2024-01-15 14:30:00". Useful for finding recently completed processes'
520
540
  ),
521
- activeOnly: h.boolean().default(!1).describe(
541
+ activeOnly: m.boolean().default(!1).describe(
522
542
  "Show only currently running processes. Set to true to exclude completed processes, false to show all processes (running and completed). Default: false (show all)"
523
543
  ),
524
- fields: h.array(h.string()).optional().describe(
544
+ fields: m.array(m.string()).optional().describe(
525
545
  'Specific process data fields to include in the response. If omitted, returns all available fields. Fields id, isRunning, and commandLine are always included. 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'
526
546
  )
527
547
  });
528
- async function Or(r, t) {
548
+ async function Dr(r, t) {
529
549
  ge();
530
550
  let s;
531
551
  try {
532
- s = pt.parse(r);
552
+ s = ht.parse(r);
533
553
  } catch (l) {
534
554
  return {
535
555
  error: F(l)
@@ -568,16 +588,16 @@ async function Or(r, t) {
568
588
  return u;
569
589
  }) };
570
590
  }
571
- function Dr(r, t) {
591
+ function Rr(r, t) {
572
592
  r(
573
593
  "process-list",
574
594
  {
575
595
  title: "List Host Machine Processes",
576
596
  description: "List all processes that have been executed on the host machine. Use this to see running processes, check command history, or find process IDs for status/wait operations",
577
- inputSchema: pt.shape
597
+ inputSchema: ht.shape
578
598
  },
579
599
  async (s) => {
580
- const o = await Or(s, t);
600
+ const o = await Dr(s, t);
581
601
  if (o.error != null)
582
602
  return `Method: process-list(${JSON.stringify(s)})
583
603
  ❌ Error: ${o.error}`;
@@ -591,15 +611,15 @@ ${e}`;
591
611
  }
592
612
  );
593
613
  }
594
- const ht = h.object({
595
- id: h.number().describe(
614
+ const mt = m.object({
615
+ id: m.number().describe(
596
616
  "Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
597
617
  )
598
618
  });
599
- function Rr(r) {
619
+ function Fr(r) {
600
620
  let t;
601
621
  try {
602
- t = ht.parse(r);
622
+ t = mt.parse(r);
603
623
  } catch (e) {
604
624
  return {
605
625
  error: F(e)
@@ -619,31 +639,31 @@ function Rr(r) {
619
639
  error: `Process ${s} has no system process ID (PID). This indicates the process failed to start properly or the system was unable to assign a PID. Check process-status for error details.`
620
640
  };
621
641
  try {
622
- return ct(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
642
+ return ut(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
623
643
  } catch (e) {
624
644
  return {
625
645
  error: `Failed to terminate process ${s}: ${e instanceof Error ? e.message : "Unknown error"}. The process may have already exited, be protected by the system, or there may be insufficient permissions. Use process-status to check current process state.`
626
646
  };
627
647
  }
628
648
  }
629
- function Fr(r, t) {
649
+ function Br(r, t) {
630
650
  r(
631
651
  "process-kill",
632
652
  {
633
653
  title: "Kill Host Machine Process",
634
654
  description: "Forcibly terminate a running process on the host machine. Use this to stop runaway processes, hung commands, or long-running tasks that need to be cancelled",
635
- inputSchema: ht.shape
655
+ inputSchema: mt.shape
636
656
  },
637
657
  async (s) => {
638
- const o = Rr(s);
658
+ const o = Fr(s);
639
659
  return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
640
660
  ❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
641
661
  ${JSON.stringify(o, null, 2)}`;
642
662
  }
643
663
  );
644
664
  }
645
- function Br(r, t) {
646
- yr(), t.run && kr(r, t), t.status && vr(r, t), t.wait && Er(r, t), t.list && Dr(r, t), t.kill && Fr(r);
665
+ function Lr(r, t) {
666
+ br(), t.run && Or(r, t), t.status && vr(r, t), t.wait && Nr(r, t), t.list && Rr(r, t), t.kill && Br(r);
647
667
  const s = t.commandLineRules?.map(
648
668
  (o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
649
669
  ) || [];
@@ -656,7 +676,7 @@ ${s.map((o) => `- ${o}`).join(`
656
676
  `
657
677
  );
658
678
  }
659
- function Lr(r, t) {
679
+ function Pr(r, t) {
660
680
  return function(o, e, n) {
661
681
  const i = async (...a) => {
662
682
  await ie({
@@ -685,26 +705,26 @@ function Lr(r, t) {
685
705
  );
686
706
  };
687
707
  }
688
- function Pr(r) {
708
+ function Ar(r) {
689
709
  return r.match(/^[/\\]?[^/\\]+/)[0];
690
710
  }
691
- function Ar(r, t) {
692
- return Pr(r) + "|" + t.ino;
711
+ function zr(r, t) {
712
+ return Ar(r) + "|" + t.ino;
693
713
  }
694
- function zr(r) {
714
+ function Ur(r) {
695
715
  return r.endsWith(":") && (r += "/"), k.resolve(r);
696
716
  }
697
- const be = new Yt(er.cpus().length);
698
- function De(r, t) {
717
+ const Se = new Vt(tr.cpus().length);
718
+ function Re(r, t) {
699
719
  r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
700
720
  r.maxFileDateModified,
701
721
  t.maxFileDateModified
702
722
  ), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
703
723
  }
704
- const Ur = function(t) {
724
+ const jr = function(t) {
705
725
  return t.code === "ENOENT";
706
726
  };
707
- function mt(r) {
727
+ function gt(r) {
708
728
  const t = r.paths;
709
729
  if (!t || t.length === 0)
710
730
  return Promise.resolve({
@@ -714,29 +734,29 @@ function mt(r) {
714
734
  countDirs: 0,
715
735
  countLinks: 0
716
736
  });
717
- const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? be, i = r.handleError, a = r.priority ?? X(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, f = r.matchPath;
718
- async function d(g) {
719
- if (!(i && await i(g)) && !Ur(g))
720
- throw g;
737
+ const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? Se, i = r.handleError, a = r.priority ?? X(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, f = r.matchPath;
738
+ async function d(h) {
739
+ if (!(i && await i(h)) && !jr(h))
740
+ throw h;
721
741
  }
722
- function p(g) {
723
- return !(!l || l.minTotalContentSize != null && g < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
742
+ function p(h) {
743
+ return !(!l || l.minTotalContentSize != null && h < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
724
744
  }
725
- return Vt(async (g) => {
726
- const m = Zt(e, g), y = {
745
+ return Zt(async (h) => {
746
+ const g = Xt(e, h), y = {
727
747
  totalSize: 0,
728
748
  maxFileDateModified: 0,
729
749
  countFiles: 0,
730
750
  countDirs: 0,
731
751
  countLinks: 0
732
752
  };
733
- function w($, S) {
734
- if (p(S.totalSize)) {
735
- const T = `${S.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${$}`;
736
- l?.handleLog ? l.handleLog(T) : console.log(T);
753
+ function w($, T) {
754
+ if (p(T.totalSize)) {
755
+ const S = `${T.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${$}`;
756
+ l?.handleLog ? l.handleLog(S) : console.log(S);
737
757
  }
738
758
  }
739
- async function M($, S, x, T) {
759
+ async function M($, T, x, S) {
740
760
  return u ? await V({
741
761
  pool: n,
742
762
  func: async () => {
@@ -744,114 +764,111 @@ function mt(r) {
744
764
  return await u({
745
765
  level: s,
746
766
  path: $,
747
- stat: S,
767
+ stat: T,
748
768
  itemStat: x,
749
769
  totalStat: y,
750
- abortSignal: m
770
+ abortSignal: g
751
771
  });
752
- } catch (v) {
753
- return await d(v), !1;
772
+ } catch (E) {
773
+ return await d(E), !1;
754
774
  }
755
775
  },
756
776
  count: 1,
757
- priority: T,
758
- abortSignal: m
777
+ priority: S,
778
+ abortSignal: g
759
779
  }) : !0;
760
780
  }
761
- async function E($, S, x, T) {
762
- T || (T = $);
763
- const v = await V({
781
+ async function v($, T, x, S) {
782
+ S || (S = $);
783
+ const E = await V({
764
784
  pool: n,
765
785
  func: () => j.promises.lstat($).catch(d),
766
786
  count: 1,
767
- priority: X(S, X(1, a)),
768
- abortSignal: m
787
+ priority: X(T, X(1, a)),
788
+ abortSignal: g
769
789
  });
770
- if (!v || !x && v.isFile())
790
+ if (!E || !x && E.isFile())
771
791
  return null;
772
- const B = Ar($, v);
792
+ const B = zr($, E);
773
793
  if (o.has(B))
774
794
  return null;
775
795
  o.add(B);
776
796
  let O = {
777
- totalSize: v.size,
778
- maxFileDateModified: v.isDirectory() ? 0 : v.mtimeMs,
797
+ totalSize: E.size,
798
+ maxFileDateModified: E.isDirectory() ? 0 : E.mtimeMs,
779
799
  countFiles: 0,
780
800
  countDirs: 0,
781
801
  countLinks: 0
782
802
  };
783
803
  const I = X(
784
- S,
785
- X(v.isDirectory() ? 2 : 3, a)
804
+ T,
805
+ X(E.isDirectory() ? 2 : 3, a)
786
806
  );
787
- if (v.isSymbolicLink()) {
807
+ if (E.isSymbolicLink()) {
788
808
  if (c) {
789
809
  const C = await V({
790
810
  pool: n,
791
811
  func: () => j.promises.readlink($).catch(d).then((N) => N ?? null),
792
812
  count: 1,
793
813
  priority: I,
794
- abortSignal: m
814
+ abortSignal: g
795
815
  });
796
816
  if (C) {
797
- const N = k.isAbsolute(C) ? C : k.resolve(k.dirname(T), C), D = await E(
817
+ const N = k.isAbsolute(C) ? C : k.resolve(k.dirname(S), C), D = await v(
798
818
  N,
799
- S,
819
+ T,
800
820
  x,
801
- T
821
+ S
802
822
  );
803
823
  D && (O = D);
804
824
  }
805
825
  }
806
826
  return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (O.countLinks += 1, await M(
807
- T,
808
- v,
827
+ S,
828
+ E,
809
829
  O,
810
830
  I
811
- ) && (De(y, O), w(T, O))), O;
812
- } else if (v.isDirectory()) {
831
+ ) && (Re(y, O), w(S, O))), O;
832
+ } else if (E.isDirectory()) {
813
833
  const C = await V({
814
834
  pool: n,
815
835
  func: () => j.promises.readdir($).catch(d),
816
836
  count: 1,
817
837
  priority: a,
818
- abortSignal: m
838
+ abortSignal: g
819
839
  });
820
840
  if (C) {
821
841
  for (let N = 0, D = C.length; N < D; N++)
822
- C[N] = k.join(T, C[N]);
823
- O = await mt({
842
+ C[N] = k.join(S, C[N]);
843
+ O = await gt({
824
844
  ...r,
825
845
  paths: C,
826
- abortSignal: m,
846
+ abortSignal: g,
827
847
  priority: I,
828
848
  level: s + 1,
829
849
  walkedIds: o
830
850
  });
831
851
  }
832
852
  }
833
- return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (v.isDirectory() ? O.countDirs += 1 : v.isFile() && (O.countFiles += 1), await M(
834
- T,
835
- v,
853
+ return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (E.isDirectory() ? O.countDirs += 1 : E.isFile() && (O.countFiles += 1), await M(
854
+ S,
855
+ E,
836
856
  O,
837
857
  I
838
- ) && (De(y, O), w(T, O))), O;
858
+ ) && (Re(y, O), w(S, O))), O;
839
859
  }
840
860
  const b = [];
841
- for (let $ = 0, S = t.length; $ < S; $++) {
842
- const x = zr(t[$]), T = f ? f(x) : !0;
843
- T !== !1 && b.push(E(x, $, T));
861
+ for (let $ = 0, T = t.length; $ < T; $++) {
862
+ const x = Ur(t[$]), S = f ? f(x) : !0;
863
+ S !== !1 && b.push(v(x, $, S));
844
864
  }
845
865
  return await Promise.all(b), y;
846
866
  });
847
867
  }
848
- function gt(r) {
849
- return mt(r);
850
- }
851
- function H(r) {
852
- return r.replace(/\\/g, "/");
868
+ function wt(r) {
869
+ return gt(r);
853
870
  }
854
- function jr(r, t) {
871
+ function qr(r, t) {
855
872
  if (!t || t === ".")
856
873
  return r;
857
874
  const s = r.startsWith("^");
@@ -859,43 +876,43 @@ function jr(r, t) {
859
876
  const o = r.startsWith("!");
860
877
  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(k.normalize(r)), o && (r = "!" + r), s && (r = "^" + r), r;
861
878
  }
862
- function qr(r) {
879
+ function Gr(r) {
863
880
  const t = r.startsWith("!");
864
881
  return t && (r = r.substring(1)), r.startsWith("/") ? r = r.substring(1) : !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
865
882
  }
866
- function Re(r) {
883
+ function Fe(r) {
867
884
  return "^" + r;
868
885
  }
869
- async function Gr(r) {
886
+ async function _r(r) {
870
887
  const s = (await j.promises.readFile(r, "utf-8")).split(`
871
888
  `), o = [];
872
889
  return s.forEach((e) => {
873
890
  e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
874
891
  }), o;
875
892
  }
876
- async function wt(r) {
893
+ async function yt(r) {
877
894
  const t = r.rootDir ?? ".", s = [];
878
895
  if (!r.globs?.length)
879
896
  return s;
880
897
  const o = [];
881
898
  return r.globs.forEach((e) => {
882
- e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Re(e.value) : e.value));
899
+ e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Fe(e.value) : e.value));
883
900
  }), o.length && await Promise.all(
884
901
  o.map(async (e) => {
885
902
  await V({
886
- pool: be,
903
+ pool: Se,
887
904
  count: 1,
888
905
  func: async () => {
889
- const n = k.resolve(t, e.value), i = await Gr(n), a = k.relative(t, k.dirname(n));
906
+ const n = k.resolve(t, e.value), i = await _r(n), a = k.relative(t, k.dirname(n));
890
907
  i.forEach((c) => {
891
- c = qr(c), c = jr(c, a), s.push(e.exclude ? Re(c) : c);
908
+ c = Gr(c), c = qr(c, a), s.push(e.exclude ? Fe(c) : c);
892
909
  });
893
910
  }
894
911
  });
895
912
  })
896
913
  ), s;
897
914
  }
898
- function yt({
915
+ function bt({
899
916
  globs: r,
900
917
  rootDir: t,
901
918
  noCase: s
@@ -916,7 +933,7 @@ function yt({
916
933
  return;
917
934
  let c;
918
935
  try {
919
- c = tr(a, {
936
+ c = rr(a, {
920
937
  nocase: s ?? !1,
921
938
  dot: !0,
922
939
  strictBrackets: !0
@@ -943,17 +960,17 @@ function yt({
943
960
  return a ? !1 : i;
944
961
  };
945
962
  }
946
- async function _r(r) {
963
+ async function Jr(r) {
947
964
  const t = r.rootDir ?? ".", s = [], o = {};
948
965
  r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
949
- const e = await wt({
966
+ const e = await yt({
950
967
  rootDir: t,
951
968
  globs: r.globs
952
969
  });
953
- return await gt({
970
+ return await wt({
954
971
  paths: [t],
955
972
  walkLinks: !0,
956
- matchPath: yt({
973
+ matchPath: bt({
957
974
  globs: e,
958
975
  rootDir: t,
959
976
  noCase: !0
@@ -962,39 +979,39 @@ async function _r(r) {
962
979
  const c = k.relative(t, n), l = i.isDirectory(), u = i.isFile();
963
980
  if (!l && !u)
964
981
  return !0;
965
- const f = H(c || "."), d = l ? "dir" : "file", p = l ? a.maxFileDateModified || null : i.mtimeMs, g = l ? a.totalSize : i.size, m = l ? a.countFiles : null, y = {
982
+ const f = H(c || "."), d = l ? "dir" : "file", p = l ? a.maxFileDateModified || null : i.mtimeMs, h = l ? a.totalSize : i.size, g = l ? a.countFiles : null, y = {
966
983
  path: f,
967
984
  type: d
968
985
  };
969
- if (r.result.dateModified && (y.dateModified = p), r.result.size && (y.size = g), r.result.countFiles && (y.countFiles = m), r.dateModified && p != null) {
986
+ if (r.result.dateModified && (y.dateModified = p), r.result.size && (y.size = h), r.result.countFiles && (y.countFiles = g), r.dateModified && p != null) {
970
987
  const [w, M] = r.dateModified;
971
988
  if (w != null && p < w || M != null && p > M)
972
989
  return !1;
973
990
  }
974
- if (r.totalSize && g != null) {
991
+ if (r.totalSize && h != null) {
975
992
  const [w, M] = r.totalSize;
976
- if (w != null && g < w || M != null && g > M)
993
+ if (w != null && h < w || M != null && h > M)
977
994
  return !1;
978
995
  }
979
- return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && g != null && (o.size = (o.size ?? 0) + g), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
996
+ return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && h != null && (o.size = (o.size ?? 0) + h), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
980
997
  }
981
998
  }), { items: s, totals: o };
982
999
  }
983
- const Fe = ["B", "KB", "MB", "GB", "TB"], Be = 1024;
984
- function Le(r) {
1000
+ const Be = ["B", "KB", "MB", "GB", "TB"], Le = 1024;
1001
+ function Pe(r) {
985
1002
  if (r == null) return "-";
986
1003
  let t = r ?? 0, s = 0;
987
- for (; t >= Be && s < Fe.length - 1; )
988
- t /= Be, s++;
989
- return `${s === 0 ? t.toString() : t.toFixed(2)}${Fe[s]}`;
1004
+ for (; t >= Le && s < Be.length - 1; )
1005
+ t /= Le, s++;
1006
+ return `${s === 0 ? t.toString() : t.toFixed(2)}${Be[s]}`;
990
1007
  }
991
- function Pe(r) {
1008
+ function Ae(r) {
992
1009
  const s = Date.now() - r;
993
1010
  if (s < 0) return "0s";
994
1011
  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);
995
1012
  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`;
996
1013
  }
997
- function Jr(r, t) {
1014
+ function Wr(r, t) {
998
1015
  return t?.length ? [...r].sort((s, o) => {
999
1016
  for (let e = 0, n = t.length; e < n; e++) {
1000
1017
  const i = t[e];
@@ -1031,7 +1048,7 @@ function Jr(r, t) {
1031
1048
  }) : r;
1032
1049
  }
1033
1050
  function Kr(r, t) {
1034
- const s = Jr(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
1051
+ const s = Wr(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
1035
1052
  let e = "";
1036
1053
  if (s.length > 0 && o.length > 0) {
1037
1054
  for (let n = 0, i = o.length; n < i; n++) {
@@ -1062,10 +1079,10 @@ function Kr(r, t) {
1062
1079
  const u = o[c];
1063
1080
  switch (c > 0 && (e += " | "), u) {
1064
1081
  case "dateModified":
1065
- e += a.dateModified ? Pe(a.dateModified) : "-";
1082
+ e += a.dateModified ? Ae(a.dateModified) : "-";
1066
1083
  break;
1067
1084
  case "size":
1068
- e += Le(a.size);
1085
+ e += Pe(a.size);
1069
1086
  break;
1070
1087
  case "type":
1071
1088
  e += a.type;
@@ -1084,15 +1101,15 @@ function Kr(r, t) {
1084
1101
  e.length > 0 && (e += `
1085
1102
  ---
1086
1103
  `);
1087
- const n = Le(r.totals.size ?? 0), i = r.totals.dateModified ? `, last modified ${Pe(r.totals.dateModified)} ago` : "";
1104
+ const n = Pe(r.totals.size ?? 0), i = r.totals.dateModified ? `, last modified ${Ae(r.totals.dateModified)} ago` : "";
1088
1105
  e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
1089
1106
  }
1090
1107
  return e;
1091
1108
  }
1092
- const Wr = "4.0.0", Hr = {
1093
- version: Wr
1094
- }, Po = "Project Tools", Ao = "project-tools", zo = Hr.version, Uo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Ae = 25e3;
1095
- function ze(r) {
1109
+ const Hr = "4.0.2", Qr = {
1110
+ version: Hr
1111
+ }, Ao = "Project Tools", zo = "project-tools", Uo = Qr.version, jo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", ze = 25e3;
1112
+ function Ue(r) {
1096
1113
  const t = r.match(
1097
1114
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1098
1115
  );
@@ -1123,7 +1140,7 @@ function ze(r) {
1123
1140
  );
1124
1141
  }
1125
1142
  }
1126
- function Ue(r) {
1143
+ function je(r) {
1127
1144
  const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1128
1145
  if (!t)
1129
1146
  throw new Error(
@@ -1147,52 +1164,52 @@ function Ue(r) {
1147
1164
  );
1148
1165
  }
1149
1166
  }
1150
- const bt = h.object({
1151
- relativeRootDir: h.string().optional().describe(
1167
+ const St = m.object({
1168
+ relativeRootDir: m.string().optional().describe(
1152
1169
  'Relative path from project root to directory for listing. Use forward slashes. Leave empty for project root. Examples: "src", "src/components", "tests". Path must exist'
1153
1170
  ),
1154
- globs: h.array(h.string()).optional().describe(
1171
+ globs: m.array(m.string()).optional().describe(
1155
1172
  'Glob patterns to filter which files/directories to include. Add leading ** to match files and dirs in subdirectories. Examples: ["**/*.js"] (JavaScript files), ["src/**/*.ts"] (TypeScript files in src), ["**/dir/"] (all directories named "dir"), ["!node_modules"] (exclude {rootDir}/node_modules). If omitted, includes all files matching other criteria. Supports standard glob syntax: * (any chars), ** (any dirs), ? (single char), [abc] (char class)'
1156
1173
  ),
1157
- showFiles: h.boolean().optional().describe(
1174
+ showFiles: m.boolean().optional().describe(
1158
1175
  "Whether to show regular files in the report table. Set to true to show files, false to hide them from the table. When both showFiles and showDirs are false, nothing will be shown in the table. It Does not affect totals. Default is false (do not show files in the table)"
1159
1176
  ),
1160
- showDirs: h.boolean().optional().describe(
1177
+ showDirs: m.boolean().optional().describe(
1161
1178
  "Whether to show directories in the report table. Set to true to show directories, false to hide them from the table. When both showFiles and showDirs are false, nothing will be shown in the table. It Does not affect totals. Default is true (show directories in the table)"
1162
1179
  ),
1163
- sortBy: h.array(
1164
- h.object({
1165
- field: h.enum(["type", "path", "lastModified", "size", "totalCountFiles"]).describe(
1180
+ sortBy: m.array(
1181
+ m.object({
1182
+ field: m.enum(["type", "path", "lastModified", "size", "totalCountFiles"]).describe(
1166
1183
  'Field to sort results by. "type" sorts files before directories. "path" sorts alphabetically by file/directory name. "lastModified" sorts by modification time (newest first when desc=true). "size" sorts by file/directory size (largest first when desc=true). "totalCountFiles" sorts by total files count (highest first when desc=true, directories only)'
1167
1184
  ),
1168
- desc: h.boolean().optional().describe("Sort in descending order (largest/newest first)")
1185
+ desc: m.boolean().optional().describe("Sort in descending order (largest/newest first)")
1169
1186
  })
1170
1187
  ).optional().describe(
1171
1188
  'Multi-level sorting configuration. Sorts are applied in array order - first sort is primary, second is secondary, etc. Example: [{field: "type", desc: false}, {field: "size", desc: true}] sorts by type ascending, then by size descending within each type'
1172
1189
  ),
1173
- fields: h.array(h.enum(["type", "path", "lastModified", "size", "totalCountFiles"])).optional().describe(
1190
+ fields: m.array(m.enum(["type", "path", "lastModified", "size", "totalCountFiles"])).optional().describe(
1174
1191
  'Which data fields to include in the formatted table output. "type" shows file/directory indicator. "path" shows relative file/directory path. "lastModified" shows last modification time as time-ago format (5m, 2h, 3d, etc). "size" shows file/directory size in human-readable format (KB, MB, GB). "totalCountFiles" shows total files count for directories (displays "-" for files). Adding lastModified, size, or totalCountFiles fields increases processing time. Do not set fields if you want to show only totals summary'
1175
1192
  ),
1176
- minTimeAgo: h.string().optional().describe(
1193
+ minTimeAgo: m.string().optional().describe(
1177
1194
  'Filter files/directories modified at least this long ago. Only items older than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified more than 1 hour ago), "7d" (modified more than 7 days ago), "6M" (modified more than 6 months ago)'
1178
1195
  ),
1179
- maxTimeAgo: h.string().optional().describe(
1196
+ maxTimeAgo: m.string().optional().describe(
1180
1197
  'Filter files/directories modified at most this long ago. Only items newer than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified within last hour), "7d" (modified within last 7 days), "1M" (modified within last month). Combine with minTimeAgo for date ranges'
1181
1198
  ),
1182
- minTotalSize: h.string().optional().describe(
1199
+ minTotalSize: m.string().optional().describe(
1183
1200
  'Filter files/directories with total size at least 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: "1KB" (at least 1 kilobyte), "100MB" (at least 100 megabytes), "1.5GB" (at least 1.5 gigabytes)'
1184
1201
  ),
1185
- maxTotalSize: h.string().optional().describe(
1202
+ maxTotalSize: m.string().optional().describe(
1186
1203
  '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'
1187
1204
  )
1188
1205
  });
1189
- async function Qr(r, t) {
1206
+ async function Yr(r, t) {
1190
1207
  let s;
1191
1208
  try {
1192
- s = bt.parse(r);
1193
- } catch (m) {
1209
+ s = St.parse(r);
1210
+ } catch (y) {
1194
1211
  return {
1195
- error: F(m)
1212
+ error: F(y)
1196
1213
  };
1197
1214
  }
1198
1215
  const {
@@ -1209,90 +1226,96 @@ async function Qr(r, t) {
1209
1226
  return {
1210
1227
  error: 'Fields array must include "path" field when fields are specified. The "path" field is required to identify files and directories in the output'
1211
1228
  };
1212
- const f = s.fields ? s.fields.map((m) => m === "totalCountFiles" ? "countFiles" : m === "lastModified" ? "dateModified" : m) : [];
1213
- let d = i?.map((m) => {
1214
- let y = m.field;
1215
- return y === "totalCountFiles" && (y = "countFiles"), y === "lastModified" && (y = "dateModified"), {
1216
- field: y,
1217
- desc: m.desc ?? !1
1229
+ const f = s.fields ? s.fields.map((y) => y === "totalCountFiles" ? "countFiles" : y === "lastModified" ? "dateModified" : y) : [];
1230
+ let d = i?.map((y) => {
1231
+ let w = y.field;
1232
+ return w === "totalCountFiles" && (w = "countFiles"), w === "lastModified" && (w = "dateModified"), {
1233
+ field: w,
1234
+ desc: y.desc ?? !1
1218
1235
  // Default to ascending if not specified
1219
1236
  };
1220
1237
  }) ?? null;
1221
1238
  (!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
1222
- const p = d?.map((m) => m.field) || [], g = k.resolve(
1223
- t.workingDir || "",
1224
- s.relativeRootDir || ""
1239
+ const p = d?.map((y) => y.field) || [];
1240
+ if (!t.workingDir)
1241
+ return { error: "Working directory is not configured" };
1242
+ const h = be(
1243
+ t.workingDir,
1244
+ s.relativeRootDir
1225
1245
  );
1246
+ if ("error" in h)
1247
+ return { error: h.error };
1248
+ const g = h.path;
1226
1249
  try {
1227
1250
  try {
1228
1251
  await j.promises.access(g, j.constants.F_OK);
1229
- } catch (x) {
1230
- if (x.code === "ENOENT")
1252
+ } catch (S) {
1253
+ if (S.code === "ENOENT")
1231
1254
  return {
1232
1255
  error: `Directory does not exist: "${g}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-list without rootDir to list the current directory, or check parent directories first.`
1233
1256
  };
1234
- throw x;
1257
+ throw S;
1235
1258
  }
1236
- const m = o && o.length > 0 ? o.map((x) => ({
1237
- value: x,
1259
+ const y = o && o.length > 0 ? o.map((S) => ({
1260
+ value: S,
1238
1261
  valueType: "pattern",
1239
1262
  exclude: !1
1240
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...m, ...y], M = {
1263
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], w = t.globsExclude || [], M = [...y, ...w], v = {
1241
1264
  files: e ?? !1,
1242
1265
  dirs: n ?? !1,
1243
1266
  dateModified: f.includes("dateModified") || p.includes("dateModified"),
1244
1267
  size: f.includes("size") || p.includes("size"),
1245
1268
  countFiles: f.includes("countFiles") || p.includes("countFiles")
1246
1269
  };
1247
- let E = null, b = null;
1270
+ let b = null, $ = null;
1248
1271
  if (a || c)
1249
1272
  try {
1250
- const x = Date.now(), T = c ? x - ze(c) : null, v = a ? x - ze(a) : null;
1251
- E = [T, v];
1252
- } catch (x) {
1273
+ const S = Date.now(), E = c ? S - Ue(c) : null, B = a ? S - Ue(a) : null;
1274
+ b = [E, B];
1275
+ } catch (S) {
1253
1276
  return {
1254
- error: x instanceof Error ? x.message : "Unknown error parsing time ago filter"
1277
+ error: S instanceof Error ? S.message : "Unknown error parsing time ago filter"
1255
1278
  };
1256
1279
  }
1257
1280
  if (l || u)
1258
1281
  try {
1259
- const x = l ? Ue(l) : null, T = u ? Ue(u) : null;
1260
- b = [x, T];
1261
- } catch (x) {
1282
+ const S = l ? je(l) : null, E = u ? je(u) : null;
1283
+ $ = [S, E];
1284
+ } catch (S) {
1262
1285
  return {
1263
- error: x instanceof Error ? x.message : "Unknown error parsing size filter"
1286
+ error: S instanceof Error ? S.message : "Unknown error parsing size filter"
1264
1287
  };
1265
1288
  }
1266
- const $ = await _r({
1289
+ const T = await Jr({
1267
1290
  rootDir: g || null,
1268
- globs: w,
1269
- result: M,
1270
- dateModified: E,
1271
- totalSize: b
1291
+ globs: M,
1292
+ result: v,
1293
+ dateModified: b,
1294
+ totalSize: $
1272
1295
  });
1273
- return $.items.length > Ae ? {
1274
- error: `Number of paths (${$.items.length}) exceeds maximum allowed (${Ae}). Consider using more specific glob patterns or filters to reduce the result set.`
1296
+ return T.items.length > ze ? {
1297
+ error: `Number of paths (${T.items.length}) exceeds maximum allowed (${ze}). Consider using more specific glob patterns or filters to reduce the result set.`
1275
1298
  } : {
1276
- output: Kr($, {
1299
+ output: Kr(T, {
1277
1300
  sort: d,
1278
1301
  fields: f,
1279
1302
  totals: !0
1280
1303
  })
1281
1304
  };
1282
- } catch (m) {
1283
- return { error: m instanceof Error ? m.message : "Unknown error" };
1305
+ } catch (y) {
1306
+ return { error: y instanceof Error ? y.message : "Unknown error" };
1284
1307
  }
1285
1308
  }
1286
- function Yr(r, t) {
1309
+ function Vr(r, t) {
1287
1310
  r(
1288
1311
  "fs-list",
1289
1312
  {
1290
1313
  title: "List Files and Directories",
1291
1314
  description: "List files and directories with advanced filtering, sorting and formatting options. Use this to analyze filesystem structure",
1292
- inputSchema: bt.shape
1315
+ inputSchema: St.shape
1293
1316
  },
1294
1317
  async (s) => {
1295
- const o = await Qr(s, t);
1318
+ const o = await Yr(s, t);
1296
1319
  return o.error ? `Method: fs-list(${JSON.stringify(s)})
1297
1320
  ❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
1298
1321
  ${o.output || JSON.stringify(o, null, 2)}`;
@@ -1300,9 +1323,9 @@ ${o.output || JSON.stringify(o, null, 2)}`;
1300
1323
  );
1301
1324
  }
1302
1325
  const ue = /* @__PURE__ */ new Map();
1303
- let Vr = 0;
1304
- function Zr() {
1305
- return `${++Vr}-${Math.random().toString(36).slice(2)}`;
1326
+ let Zr = 0;
1327
+ function Xr() {
1328
+ return `${++Zr}-${Math.random().toString(36).slice(2)}`;
1306
1329
  }
1307
1330
  function Z(r) {
1308
1331
  return ue.has(r) || ue.set(r, {
@@ -1311,7 +1334,7 @@ function Z(r) {
1311
1334
  preparedReplace: null
1312
1335
  }), ue.get(r);
1313
1336
  }
1314
- function je(r) {
1337
+ function qe(r) {
1315
1338
  const t = r.match(
1316
1339
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1317
1340
  );
@@ -1342,7 +1365,7 @@ function je(r) {
1342
1365
  );
1343
1366
  }
1344
1367
  }
1345
- function qe(r) {
1368
+ function Ge(r) {
1346
1369
  const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1347
1370
  if (!t)
1348
1371
  throw new Error(
@@ -1366,35 +1389,35 @@ function qe(r) {
1366
1389
  );
1367
1390
  }
1368
1391
  }
1369
- const Se = h.object({
1370
- name: h.string().describe(
1392
+ const xe = m.object({
1393
+ name: m.string().describe(
1371
1394
  "Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
1372
1395
  ),
1373
- relativeRootDir: h.string().optional().describe(
1396
+ relativeRootDir: m.string().optional().describe(
1374
1397
  'Relative path from project root to directory for snapshot. Use forward slashes. Leave empty for project root. Examples: "src", "src/components", "tests". Path must exist'
1375
1398
  ),
1376
- bulkGlobs: h.array(h.string()).optional().describe(
1399
+ bulkGlobs: m.array(m.string()).optional().describe(
1377
1400
  'Glob patterns to filter files/directories. Include all patterns in this single array; never split across multiple tool calls. Add leading ** for recursive matching. Examples: ["**/*.js"], ["src/**/*.ts"], ["**/*.{ts,svelte}"], ["!node_modules"]. If omitted, includes all files matching other criteria. Supports: * (any chars), ** (any dirs), ? (single char), [abc] (char class)'
1378
1401
  ),
1379
- types: h.array(h.enum(["file", "dir"])).optional().describe(
1402
+ types: m.array(m.enum(["file", "dir"])).optional().describe(
1380
1403
  "Types of items to include in the snapshot. If omitted, includes both files and directories"
1381
1404
  ),
1382
- extraFields: h.array(h.enum(["lastModified", "size", "countMatched"])).optional().describe(
1405
+ extraFields: m.array(m.enum(["lastModified", "size", "countMatched"])).optional().describe(
1383
1406
  'Which extra data fields to include in the snapshot tree output. "lastModified" shows last modification time as time-ago format (5m, 2h, 3d, etc). "size" shows file/directory size in human-readable format (KB, MB, GB). "countMatched" shows total matched items count'
1384
1407
  ),
1385
- minTimeAgo: h.string().optional().describe(
1408
+ minTimeAgo: m.string().optional().describe(
1386
1409
  'Filter files/directories modified at least this long ago. Only items older than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified more than 1 hour ago), "7d" (modified more than 7 days ago), "6M" (modified more than 6 months ago)'
1387
1410
  ),
1388
- maxTimeAgo: h.string().optional().describe(
1411
+ maxTimeAgo: m.string().optional().describe(
1389
1412
  'Filter files/directories modified at most this long ago. Only items newer than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified within last hour), "7d" (modified within last 7 days), "1M" (modified within last month). Combine with minTimeAgo for date ranges'
1390
1413
  ),
1391
- minTotalSize: h.string().optional().describe(
1414
+ minTotalSize: m.string().optional().describe(
1392
1415
  'Filter files/directories with total size at least 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: "1KB" (at least 1 kilobyte), "100MB" (at least 100 megabytes), "1.5GB" (at least 1.5 gigabytes)'
1393
1416
  ),
1394
- maxTotalSize: h.string().optional().describe(
1417
+ maxTotalSize: m.string().optional().describe(
1395
1418
  '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'
1396
1419
  )
1397
- }), Ge = new Map(
1420
+ }), _e = new Map(
1398
1421
  [
1399
1422
  "name",
1400
1423
  "type",
@@ -1403,17 +1426,17 @@ const Se = h.object({
1403
1426
  "dateModified"
1404
1427
  ].map((r, t) => [r, t])
1405
1428
  );
1406
- function Xr(r, t) {
1407
- const s = Ge.get(r) ?? 1 / 0, o = Ge.get(t) ?? 1 / 0;
1429
+ function es(r, t) {
1430
+ const s = _e.get(r) ?? 1 / 0, o = _e.get(t) ?? 1 / 0;
1408
1431
  return s > o ? 1 : s < o ? -1 : 0;
1409
1432
  }
1410
- async function St(r, t, s) {
1433
+ async function xt(r, t, s) {
1411
1434
  let o;
1412
1435
  try {
1413
- o = Se.parse(r);
1414
- } catch (p) {
1436
+ o = xe.parse(r);
1437
+ } catch (h) {
1415
1438
  return {
1416
- error: F(p)
1439
+ error: F(h)
1417
1440
  };
1418
1441
  }
1419
1442
  const {
@@ -1429,74 +1452,81 @@ async function St(r, t, s) {
1429
1452
  return {
1430
1453
  error: "Session ID is required"
1431
1454
  };
1432
- const f = Z(s.sessionId), d = H(
1433
- k.resolve(t.workingDir || "", o.relativeRootDir || "")
1455
+ const f = Z(s.sessionId);
1456
+ if (!t.workingDir)
1457
+ return { error: "Working directory is not configured" };
1458
+ const d = be(
1459
+ t.workingDir,
1460
+ o.relativeRootDir
1434
1461
  );
1462
+ if ("error" in d)
1463
+ return { error: d.error };
1464
+ const p = d.path;
1435
1465
  try {
1436
1466
  try {
1437
- await j.promises.access(d, j.constants.F_OK);
1438
- } catch (S) {
1439
- if (S.code === "ENOENT")
1467
+ await j.promises.access(p, j.constants.F_OK);
1468
+ } catch (x) {
1469
+ if (x.code === "ENOENT")
1440
1470
  return {
1441
- error: `Directory does not exist: "${d}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
1471
+ error: `Directory does not exist: "${p}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
1442
1472
  };
1443
- throw S;
1473
+ throw x;
1444
1474
  }
1445
- const p = o.extraFields ? o.extraFields.map((S) => S === "lastModified" ? "dateModified" : S) : [];
1446
- p.includes("name") || p.push("name"), p.sort(Xr);
1447
- const g = n && n.length > 0 ? n.map((S) => ({
1448
- value: S,
1475
+ const h = o.extraFields ? o.extraFields.map((x) => x === "lastModified" ? "dateModified" : x) : [];
1476
+ h.includes("name") || h.push("name"), h.sort(es);
1477
+ const g = n && n.length > 0 ? n.map((x) => ({
1478
+ value: x,
1449
1479
  valueType: "pattern",
1450
1480
  exclude: !1
1451
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], m = t.globsExclude || [], y = [...g, ...m];
1452
- let w = null, M = null;
1481
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...g, ...y];
1482
+ let M = null, v = null;
1453
1483
  if (a || c)
1454
1484
  try {
1455
- const S = Date.now(), x = c ? S - je(c) : null, T = a ? S - je(a) : null;
1456
- w = [x, T];
1457
- } catch (S) {
1485
+ const x = Date.now(), S = c ? x - qe(c) : null, E = a ? x - qe(a) : null;
1486
+ M = [S, E];
1487
+ } catch (x) {
1458
1488
  return {
1459
- error: S instanceof Error ? S.message : "Unknown error parsing time ago filter"
1489
+ error: x instanceof Error ? x.message : "Unknown error parsing time ago filter"
1460
1490
  };
1461
1491
  }
1462
1492
  if (l || u)
1463
1493
  try {
1464
- const S = l ? qe(l) : null, x = u ? qe(u) : null;
1465
- M = [S, x];
1466
- } catch (S) {
1494
+ const x = l ? Ge(l) : null, S = u ? Ge(u) : null;
1495
+ v = [x, S];
1496
+ } catch (x) {
1467
1497
  return {
1468
- error: S instanceof Error ? S.message : "Unknown error parsing size filter"
1498
+ error: x instanceof Error ? x.message : "Unknown error parsing size filter"
1469
1499
  };
1470
1500
  }
1471
- const E = i ? i.includes("file") : !0, b = i ? i.includes("dir") : !0, $ = {
1501
+ const b = i ? i.includes("file") : !0, $ = i ? i.includes("dir") : !0, T = {
1472
1502
  name: e,
1473
- rootDir: d,
1474
- globs: y,
1475
- matchFiles: E,
1476
- matchDirs: b,
1477
- dateModified: w,
1478
- totalSize: M,
1479
- fields: p
1503
+ rootDir: p,
1504
+ globs: w,
1505
+ matchFiles: b,
1506
+ matchDirs: $,
1507
+ dateModified: M,
1508
+ totalSize: v,
1509
+ fields: h
1480
1510
  };
1481
- return f.fsSnapshotQueries.set(e, $), {
1482
- snapshotQuery: $
1511
+ return f.fsSnapshotQueries.set(e, T), {
1512
+ snapshotQuery: T
1483
1513
  };
1484
- } catch (p) {
1514
+ } catch (h) {
1485
1515
  return {
1486
- error: p instanceof Error ? p.message : "Unknown error"
1516
+ error: h instanceof Error ? h.message : "Unknown error"
1487
1517
  };
1488
1518
  }
1489
1519
  }
1490
- function es(r, t) {
1520
+ function ts(r, t) {
1491
1521
  r(
1492
1522
  "fs-snapshot-query-create",
1493
1523
  {
1494
1524
  title: "Create Filesystem Snapshot Query",
1495
1525
  description: "Create a filesystem snapshot query. Include all glob patterns in the bulkGlobs array; never split globs across multiple queries. Prefer fs-snapshot-browse if you need to immediately create a query, snapshot and browse it",
1496
- inputSchema: Se.shape
1526
+ inputSchema: xe.shape
1497
1527
  },
1498
1528
  async (s, o) => {
1499
- const e = await St(s, t, o);
1529
+ const e = await xt(s, t, o);
1500
1530
  return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1501
1531
  ❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1502
1532
  ✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
@@ -1543,16 +1573,16 @@ function le(r) {
1543
1573
  }
1544
1574
  };
1545
1575
  }
1546
- function xt(r, t, s) {
1576
+ function $t(r, t, s) {
1547
1577
  let o = null;
1548
1578
  for (let e = 0, n = t.length; e < n; e++) {
1549
- const i = t[e], a = r(i), c = a == null ? null : xt(r, a, s), l = s(i, c);
1579
+ const i = t[e], a = r(i), c = a == null ? null : $t(r, a, s), l = s(i, c);
1550
1580
  l != null && (o == null && (o = []), o.push(l));
1551
1581
  }
1552
1582
  return o;
1553
1583
  }
1554
- function $t(r) {
1555
- const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = xt(
1584
+ function It(r) {
1585
+ const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = $t(
1556
1586
  s,
1557
1587
  o,
1558
1588
  (u, f) => {
@@ -1580,7 +1610,7 @@ function $t(r) {
1580
1610
  function me(r) {
1581
1611
  return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
1582
1612
  }
1583
- async function ts(r) {
1613
+ async function rs(r) {
1584
1614
  const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = k.resolve(r.rootDir || "."), n = {
1585
1615
  path: ".",
1586
1616
  name: k.basename(o),
@@ -1590,14 +1620,14 @@ async function ts(r) {
1590
1620
  size: 0
1591
1621
  };
1592
1622
  t.set(null, n);
1593
- const i = await wt({
1623
+ const i = await yt({
1594
1624
  rootDir: o,
1595
1625
  globs: r.globs
1596
1626
  });
1597
- return await gt({
1627
+ return await wt({
1598
1628
  paths: [o],
1599
1629
  walkLinks: !0,
1600
- matchPath: yt({
1630
+ matchPath: bt({
1601
1631
  globs: i,
1602
1632
  rootDir: o,
1603
1633
  noCase: !0
@@ -1606,15 +1636,15 @@ async function ts(r) {
1606
1636
  const u = k.relative(o, a), f = c.isDirectory(), d = c.isFile();
1607
1637
  if (!f && !d)
1608
1638
  return !0;
1609
- const p = me(u || "."), g = f ? "dir" : "file", m = f ? null : c.mtimeMs, y = c.size;
1639
+ const p = me(u || "."), h = f ? "dir" : "file", g = f ? null : c.mtimeMs, y = c.size;
1610
1640
  let w = !0;
1611
- if (d && !r.matchFiles && (w = !1), f && !r.matchDirs && (w = !1), w && d && r.dateModified && m != null) {
1612
- const [$, S] = r.dateModified;
1613
- ($ != null && m < $ || S != null && m > S) && (w = !1);
1641
+ if (d && !r.matchFiles && (w = !1), f && !r.matchDirs && (w = !1), w && d && r.dateModified && g != null) {
1642
+ const [$, T] = r.dateModified;
1643
+ ($ != null && g < $ || T != null && g > T) && (w = !1);
1614
1644
  }
1615
1645
  if (w && d && r.totalSize && y != null) {
1616
- const [$, S] = r.totalSize;
1617
- ($ != null && y < $ || S != null && y > S) && (w = !1);
1646
+ const [$, T] = r.totalSize;
1647
+ ($ != null && y < $ || T != null && y > T) && (w = !1);
1618
1648
  }
1619
1649
  if (f && !w) {
1620
1650
  if (!(l.countFiles && l.countFiles > 0)) return !1;
@@ -1623,24 +1653,24 @@ async function ts(r) {
1623
1653
  const M = {
1624
1654
  path: p ?? ".",
1625
1655
  name: k.basename(a),
1626
- type: g,
1627
- dateModified: m,
1656
+ type: h,
1657
+ dateModified: g,
1628
1658
  size: y,
1629
1659
  isMatched: w
1630
1660
  };
1631
1661
  if (p == null)
1632
- return n.dateModified = m, n.size = y, n.isMatched = w, !0;
1662
+ return n.dateModified = g, n.size = y, n.isMatched = w, !0;
1633
1663
  t.set(p, M);
1634
- const E = me(H(k.dirname(p)));
1635
- let b = s.get(E);
1636
- return b || (b = [], s.set(E, b)), b.push(p), !0;
1664
+ const v = me(H(k.dirname(p)));
1665
+ let b = s.get(v);
1666
+ return b || (b = [], s.set(v, b)), b.push(p), !0;
1637
1667
  }
1638
1668
  }), {
1639
1669
  idToNode: t,
1640
1670
  idToChildIds: s
1641
1671
  };
1642
1672
  }
1643
- const rs = [
1673
+ const ss = [
1644
1674
  { name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
1645
1675
  { name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
1646
1676
  { name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
@@ -1663,7 +1693,7 @@ const rs = [
1663
1693
  // max: 2,
1664
1694
  // },
1665
1695
  ];
1666
- function _e(r, t = rs) {
1696
+ function Je(r, t = ss) {
1667
1697
  const s = r.length;
1668
1698
  if (s === 0) return 0;
1669
1699
  const o = t.length;
@@ -1689,25 +1719,25 @@ function _e(r, t = rs) {
1689
1719
  }
1690
1720
  return e;
1691
1721
  }
1692
- function It(r) {
1722
+ function Mt(r) {
1693
1723
  let t = 0;
1694
- return t += _e(r.textOpen) + 1, r.textClose != null && (t += _e(r.textClose) + 1), r.indent && (t += 1), t;
1724
+ return t += Je(r.textOpen) + 1, r.textClose != null && (t += Je(r.textClose) + 1), r.indent && (t += 1), t;
1695
1725
  }
1696
- const Je = ["B", "KB", "MB", "GB", "TB"], Ke = 1024;
1697
- function ss(r) {
1726
+ const We = ["B", "KB", "MB", "GB", "TB"], Ke = 1024;
1727
+ function os(r) {
1698
1728
  if (r == null) return "-";
1699
1729
  let t = r ?? 0, s = 0;
1700
- for (; t >= Ke && s < Je.length - 1; )
1730
+ for (; t >= Ke && s < We.length - 1; )
1701
1731
  t /= Ke, s++;
1702
- return `${s === 0 ? t.toString() : t.toFixed(2)}${Je[s]}`;
1732
+ return `${s === 0 ? t.toString() : t.toFixed(2)}${We[s]}`;
1703
1733
  }
1704
- function os(r) {
1734
+ function ns(r) {
1705
1735
  const s = Date.now() - r;
1706
1736
  if (s < 0) return "0s";
1707
1737
  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);
1708
1738
  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`;
1709
1739
  }
1710
- function ns(r) {
1740
+ function is(r) {
1711
1741
  return function(s, o) {
1712
1742
  const e = r.get(s), n = r.get(o);
1713
1743
  if (e.type !== n.type)
@@ -1720,26 +1750,26 @@ function ns(r) {
1720
1750
  }
1721
1751
  };
1722
1752
  }
1723
- function is(r) {
1753
+ function as(r) {
1724
1754
  const t = r.fields ?? [];
1725
1755
  return function(o, e) {
1726
1756
  let n = "", i, a = 0;
1727
1757
  const c = e ? e.length : 0;
1728
- let l = 1, u, f = 0, d = 0, p = 0, g = 0, m = null, y, w, M;
1758
+ let l = 1, u, f = 0, d = 0, p = 0, h = 0, g = null, y, w, M;
1729
1759
  if (e)
1730
1760
  for (let b = 0; b < e.length; b++) {
1731
1761
  const $ = e[b];
1732
- a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, p += $.size, g += $.countFiles, $.dateModified != null && (m == null || $.dateModified > m) && (m = $.dateModified);
1762
+ a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, p += $.size, h += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1733
1763
  }
1734
- o ? (y = o.type, w = o.name, M = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (p = o.size || 0, g = 1, m = o.dateModified || null) : o.dateModified != null && (m == null || o.dateModified > m) && (m = o.dateModified)) : (y = "dir", w = "<root>", M = ".", i = !0);
1764
+ o ? (y = o.type, w = o.name, M = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (p = o.size || 0, h = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (y = "dir", w = "<root>", M = ".", i = !0);
1735
1765
  for (let b = 0, $ = t.length; b < $; b++) {
1736
- const S = t[b];
1737
- switch (b > 0 && (n += " "), S) {
1766
+ const T = t[b];
1767
+ switch (b > 0 && (n += " "), T) {
1738
1768
  case "dateModified":
1739
- n += m ? os(m) : "-";
1769
+ n += g ? ns(g) : "-";
1740
1770
  break;
1741
1771
  case "size":
1742
- n += ss(p);
1772
+ n += os(p);
1743
1773
  break;
1744
1774
  case "type":
1745
1775
  n += y;
@@ -1752,12 +1782,12 @@ function is(r) {
1752
1782
  break;
1753
1783
  }
1754
1784
  }
1755
- const E = {
1785
+ const v = {
1756
1786
  indent: !0,
1757
1787
  textOpen: n,
1758
1788
  textClose: null
1759
1789
  };
1760
- return u = It(E), d += u, {
1790
+ return u = Mt(v), d += u, {
1761
1791
  type: y,
1762
1792
  name: w,
1763
1793
  path: M,
@@ -1768,15 +1798,15 @@ function is(r) {
1768
1798
  tokens: u,
1769
1799
  tokensChilds: f,
1770
1800
  tokensTotal: d,
1771
- text: E,
1801
+ text: v,
1772
1802
  size: p,
1773
- countFiles: g,
1774
- dateModified: m
1803
+ countFiles: h,
1804
+ dateModified: g
1775
1805
  };
1776
1806
  };
1777
1807
  }
1778
- async function as(r) {
1779
- const t = await ts(r), s = le(t), o = s.getChilds(s.root), e = $t({
1808
+ async function ls(r) {
1809
+ const t = await rs(r), s = le(t), o = s.getChilds(s.root), e = It({
1780
1810
  getId: (i) => {
1781
1811
  const a = s.getId(i);
1782
1812
  if (a == null)
@@ -1786,19 +1816,19 @@ async function as(r) {
1786
1816
  return a;
1787
1817
  },
1788
1818
  getChilds: (i) => s.getChilds(i),
1789
- createSnapshotNode: is(r),
1819
+ createSnapshotNode: as(r),
1790
1820
  rootNodes: o ?? []
1791
- }), n = ns(e.idToNode);
1821
+ }), n = is(e.idToNode);
1792
1822
  return e.idToChildIds.forEach((i) => {
1793
1823
  i.sort(n);
1794
1824
  }), le(e);
1795
1825
  }
1796
- const ee = h.object({
1797
- queryName: h.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
1798
- query: Se.optional().describe(
1826
+ const ee = m.object({
1827
+ queryName: m.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
1828
+ query: xe.optional().describe(
1799
1829
  "Filesystem snapshot query creation options JSON to automatically create query"
1800
1830
  ),
1801
- name: h.string().describe(
1831
+ name: m.string().describe(
1802
1832
  "Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
1803
1833
  )
1804
1834
  });
@@ -1830,7 +1860,7 @@ async function ce(r, t, s) {
1830
1860
  };
1831
1861
  c = u;
1832
1862
  } else if (i) {
1833
- const u = await St(
1863
+ const u = await xt(
1834
1864
  i,
1835
1865
  t,
1836
1866
  s
@@ -1845,7 +1875,7 @@ async function ce(r, t, s) {
1845
1875
  error: "Either queryName or query must be provided"
1846
1876
  };
1847
1877
  try {
1848
- const u = await as(c), f = {
1878
+ const u = await ls(c), f = {
1849
1879
  name: e,
1850
1880
  query: c,
1851
1881
  tree: u
@@ -1860,7 +1890,7 @@ async function ce(r, t, s) {
1860
1890
  };
1861
1891
  }
1862
1892
  }
1863
- function ls(r, t) {
1893
+ function cs(r, t) {
1864
1894
  r(
1865
1895
  "fs-snapshot-create",
1866
1896
  {
@@ -1880,7 +1910,7 @@ function ls(r, t) {
1880
1910
  }
1881
1911
  );
1882
1912
  }
1883
- class cs {
1913
+ class us {
1884
1914
  _first = null;
1885
1915
  _last = null;
1886
1916
  _size = 0;
@@ -1903,8 +1933,8 @@ class cs {
1903
1933
  return this._size;
1904
1934
  }
1905
1935
  }
1906
- function us(r) {
1907
- const t = new cs(), {
1936
+ function ds(r) {
1937
+ const t = new us(), {
1908
1938
  tree: s,
1909
1939
  limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
1910
1940
  indexRangeGroupStrategy: a
@@ -1915,22 +1945,22 @@ function us(r) {
1915
1945
  });
1916
1946
  let l = null, u = 0, f = 0;
1917
1947
  for (; !t.isEmpty(); ) {
1918
- const { reportNode: d, node: p } = t.dequeue(), g = s.getChilds(p);
1919
- if (g == null || p.countChilds === 0 || g.length !== p.countChilds)
1948
+ const { reportNode: d, node: p } = t.dequeue(), h = s.getChilds(p);
1949
+ if (h == null || p.countChilds === 0 || h.length !== p.countChilds)
1920
1950
  throw new Error(
1921
1951
  "Impossible behavior: nodeChilds is null or length mismatch"
1922
1952
  );
1923
- let m = t.size();
1924
- for (let w = 0; w < g.length; w++)
1925
- g[w].countChilds > 0 && (m += 1);
1926
- const y = m * a.tokens;
1927
- if (o != null && u + p.countChilds + m > o || e != null && f + p.tokensChilds + y > e) {
1953
+ let g = t.size();
1954
+ for (let w = 0; w < h.length; w++)
1955
+ h[w].countChilds > 0 && (g += 1);
1956
+ const y = g * a.tokens;
1957
+ if (o != null && u + p.countChilds + g > o || e != null && f + p.tokensChilds + y > e) {
1928
1958
  const w = [];
1929
- let M = null, E = 0;
1930
- for (let $ = 0, S = g.length; $ < S; $++) {
1931
- const x = g[$], T = E * a.tokens;
1959
+ let M = null, v = 0;
1960
+ for (let $ = 0, T = h.length; $ < T; $++) {
1961
+ const x = h[$], S = v * a.tokens;
1932
1962
  M != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
1933
- !(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);
1963
+ !(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null && M.countGrouped + 1 + v > n || i != null && M.tokensGrouped + x.tokens + S > i) && (w.push(M), u += 1, f += a.tokens, M = null, v = 0), M = a.add(M, x, $), x.countChilds > 0 && (v += 1);
1934
1964
  }
1935
1965
  M != null && (w.push(M), u += 1, f += a.tokens);
1936
1966
  const b = w.map(($) => ({
@@ -1948,15 +1978,15 @@ function us(r) {
1948
1978
  } else {
1949
1979
  u += p.countChilds, f += p.tokensChilds;
1950
1980
  const w = [];
1951
- for (let M = 0; M < g.length; M++) {
1952
- const E = g[M], b = {
1953
- text: E.text
1981
+ for (let M = 0; M < h.length; M++) {
1982
+ const v = h[M], b = {
1983
+ text: v.text
1954
1984
  };
1955
1985
  w.push(b);
1956
- const $ = s.getChilds(E);
1986
+ const $ = s.getChilds(v);
1957
1987
  $ != null && $.length > 0 && t.enqueue({
1958
1988
  reportNode: b,
1959
- node: E
1989
+ node: v
1960
1990
  });
1961
1991
  }
1962
1992
  if (d != null) {
@@ -1972,7 +2002,7 @@ function us(r) {
1972
2002
  }
1973
2003
  return l ?? [];
1974
2004
  }
1975
- function Mt(r) {
2005
+ function Tt(r) {
1976
2006
  const {
1977
2007
  tree: t,
1978
2008
  request: { parentNodeId: s, childsIndexRange: o, limits: e },
@@ -1994,17 +2024,17 @@ function Mt(r) {
1994
2024
  throw new Error(
1995
2025
  `Invalid index range: ${d}-${p} for root nodes length ${l.length}`
1996
2026
  );
1997
- const g = [];
1998
- let m = null;
2027
+ const h = [];
2028
+ let g = null;
1999
2029
  for (let y = d; y <= p; y++) {
2000
2030
  const w = l[y];
2001
- g.push(w), m = n.add(m, w, y);
2031
+ h.push(w), g = n.add(g, w, y);
2002
2032
  }
2003
- l = g, c = {
2033
+ l = h, c = {
2004
2034
  ...a,
2005
- text: n.getReportText(m),
2006
- countChilds: m.countGrouped,
2007
- tokensChilds: m.tokensGrouped
2035
+ text: n.getReportText(g),
2036
+ countChilds: g.countGrouped,
2037
+ tokensChilds: g.tokensGrouped
2008
2038
  };
2009
2039
  } else
2010
2040
  c = a;
@@ -2016,14 +2046,14 @@ function Mt(r) {
2016
2046
  root: u,
2017
2047
  getChilds: (d) => d === u ? [c] : d === c ? l : t.getChilds(d)
2018
2048
  };
2019
- return us({
2049
+ return ds({
2020
2050
  tree: f,
2021
2051
  limits: e,
2022
2052
  indexRangeGroupStrategy: n,
2023
2053
  ...i
2024
2054
  });
2025
2055
  }
2026
- function Tt(r, t) {
2056
+ function Ct(r, t) {
2027
2057
  if (r == null || r.length === 0)
2028
2058
  return "No results found";
2029
2059
  let s = "";
@@ -2040,7 +2070,7 @@ function Tt(r, t) {
2040
2070
  }
2041
2071
  return o(r, ""), s;
2042
2072
  }
2043
- class ds {
2073
+ class fs {
2044
2074
  tokens = 16;
2045
2075
  // +1 indent, +1 for line break
2046
2076
  getReportText = (t) => ({
@@ -2055,15 +2085,15 @@ class ds {
2055
2085
  tokensGrouped: s.tokens
2056
2086
  } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
2057
2087
  }
2058
- const Ct = h.object({
2059
- snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2088
+ const Et = m.object({
2089
+ snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2060
2090
  snapshot: ee.optional().describe(
2061
2091
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2062
2092
  ),
2063
- parentPath: h.string().optional().describe(
2093
+ parentPath: m.string().optional().describe(
2064
2094
  "Path relative to snapshot rootDir to browse. Omit to browse the rootDir itself"
2065
2095
  ),
2066
- childsIndexRange: h.tuple([h.number(), h.number()]).optional().describe(
2096
+ childsIndexRange: m.tuple([m.number(), m.number()]).optional().describe(
2067
2097
  "Child index range to show [start, end]. Only use the exact ranges that appeared in previous snapshot results - do not modify, combine, or split them"
2068
2098
  )
2069
2099
  // maxCountTotal: z
@@ -2077,13 +2107,13 @@ const Ct = h.object({
2077
2107
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
2078
2108
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
2079
2109
  });
2080
- async function fs(r, t, s) {
2110
+ async function ps(r, t, s) {
2081
2111
  let o;
2082
2112
  try {
2083
- o = Ct.parse(r);
2084
- } catch (m) {
2113
+ o = Et.parse(r);
2114
+ } catch (g) {
2085
2115
  return {
2086
- error: F(m)
2116
+ error: F(g)
2087
2117
  };
2088
2118
  }
2089
2119
  const {
@@ -2104,32 +2134,32 @@ async function fs(r, t, s) {
2104
2134
  return {
2105
2135
  error: "Either snapshotName or snapshot must be provided, not both"
2106
2136
  };
2107
- let d, p = !1, g = !1;
2137
+ let d, p = !1, h = !1;
2108
2138
  if (e) {
2109
2139
  if (d = f.fsSnapshots.get(e), d == null)
2110
2140
  return {
2111
2141
  error: `Filesystem snapshot "${e}" not found`
2112
2142
  };
2113
2143
  } else if (n) {
2114
- const m = await ce(
2144
+ const g = await ce(
2115
2145
  n,
2116
2146
  t,
2117
2147
  s
2118
2148
  );
2119
- if (m.error != null)
2149
+ if (g.error != null)
2120
2150
  return {
2121
- error: m.error
2151
+ error: g.error
2122
2152
  };
2123
- d = m.fsSnapshot, p = m.queryCreated, g = !0;
2153
+ d = g.fsSnapshot, p = g.queryCreated, h = !0;
2124
2154
  } else
2125
2155
  return {
2126
2156
  error: "Either snapshotName or snapshot must be provided"
2127
2157
  };
2128
2158
  try {
2129
- const m = me(o.parentPath), y = Mt({
2159
+ const g = me(o.parentPath), y = Tt({
2130
2160
  tree: d.tree,
2131
2161
  request: {
2132
- parentNodeId: m,
2162
+ parentNodeId: g,
2133
2163
  childsIndexRange: i,
2134
2164
  limits: {
2135
2165
  maxCountTotal: a,
@@ -2138,32 +2168,32 @@ async function fs(r, t, s) {
2138
2168
  maxTokensGroup: u
2139
2169
  }
2140
2170
  },
2141
- indexRangeGroupStrategy: new ds()
2142
- }), w = Tt(y);
2171
+ indexRangeGroupStrategy: new fs()
2172
+ }), w = Ct(y);
2143
2173
  return {
2144
2174
  fsSnapshot: d,
2145
2175
  queryCreated: p,
2146
- snapshotCreated: g,
2147
- parentPath: m,
2176
+ snapshotCreated: h,
2177
+ parentPath: g,
2148
2178
  childsIndexRange: i,
2149
2179
  report: w
2150
2180
  };
2151
- } catch (m) {
2181
+ } catch (g) {
2152
2182
  return {
2153
- error: `Failed to browse filesystem snapshot: ${m instanceof Error ? m.message : "Unknown error"}`
2183
+ error: `Failed to browse filesystem snapshot: ${g instanceof Error ? g.message : "Unknown error"}`
2154
2184
  };
2155
2185
  }
2156
2186
  }
2157
- function ps(r, t) {
2187
+ function hs(r, t) {
2158
2188
  r(
2159
2189
  "fs-snapshot-browse",
2160
2190
  {
2161
2191
  title: "Browse Filesystem Snapshot",
2162
2192
  description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
2163
- inputSchema: Ct.shape
2193
+ inputSchema: Et.shape
2164
2194
  },
2165
2195
  async (s, o) => {
2166
- const e = await fs(s, t, o);
2196
+ const e = await ps(s, t, o);
2167
2197
  if (e.error != null)
2168
2198
  return `Method: fs-snapshot-browse(${JSON.stringify(s)})
2169
2199
  ❌ Error: ${e.error}`;
@@ -2196,128 +2226,128 @@ function vt(r) {
2196
2226
  }
2197
2227
  return e(s.root), t;
2198
2228
  }
2199
- const We = /* @__PURE__ */ new Map();
2200
- function hs(r) {
2229
+ const He = /* @__PURE__ */ new Map();
2230
+ function ms(r) {
2201
2231
  const t = H(r);
2202
- let s = We.get(t);
2203
- return s == null && (s = new Xt(), We.set(t, s)), s;
2232
+ let s = He.get(t);
2233
+ return s == null && (s = new er(), He.set(t, s)), s;
2204
2234
  }
2205
- async function ms(r) {
2235
+ async function gs(r) {
2206
2236
  const { filePath: t, func: s } = r;
2207
- return hs(t).lock(
2237
+ return ms(t).lock(
2208
2238
  () => V({
2209
- pool: be,
2239
+ pool: Se,
2210
2240
  count: 1,
2211
2241
  func: s
2212
2242
  })
2213
2243
  );
2214
2244
  }
2215
- const He = 10, re = 48, Qe = 57, de = 36, gs = 38, ws = 39, ys = 60, bs = 62, Ss = 96, se = 0, Ye = 1, Ve = 2, Ze = 3, Xe = 4, xs = 5;
2216
- function $s(r) {
2245
+ const Qe = 10, re = 48, Ye = 57, de = 36, ws = 38, ys = 39, bs = 60, Ss = 62, xs = 96, se = 0, Ve = 1, Ze = 2, Xe = 3, et = 4, $s = 5;
2246
+ function Is(r) {
2217
2247
  const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
2218
2248
  for (let b = 0; b < e; b++)
2219
- t.charCodeAt(b) === He && b + 1 < e && n.push(b + 1);
2249
+ t.charCodeAt(b) === Qe && b + 1 < e && n.push(b + 1);
2220
2250
  const i = n.length, a = [], c = [];
2221
2251
  let l = null, u = null, f = null, d = 0;
2222
2252
  if (o != null) {
2223
2253
  const b = o.length;
2224
2254
  let $ = !1;
2225
- for (let S = 0; S < b; S++)
2226
- if (o.charCodeAt(S) === de) {
2255
+ for (let T = 0; T < b; T++)
2256
+ if (o.charCodeAt(T) === de) {
2227
2257
  $ = !0;
2228
2258
  break;
2229
2259
  }
2230
2260
  if ($) {
2231
2261
  u = [], f = [];
2232
- let S = 0, x = 0;
2262
+ let T = 0, x = 0;
2233
2263
  for (; x < b; ) {
2234
2264
  if (o.charCodeAt(x) !== de || x + 1 >= b) {
2235
2265
  x++;
2236
2266
  continue;
2237
2267
  }
2238
- const T = o.charCodeAt(x + 1);
2239
- let v = -1, B = 0, O = 2;
2240
- if (T === de)
2241
- v = se, B = "$";
2242
- else if (T === gs)
2243
- v = Ye;
2244
- else if (T === Ss)
2245
- v = Ve;
2246
- else if (T === ws)
2247
- v = Ze;
2248
- else if (T >= re && T <= Qe) {
2268
+ const S = o.charCodeAt(x + 1);
2269
+ let E = -1, B = 0, O = 2;
2270
+ if (S === de)
2271
+ E = se, B = "$";
2272
+ else if (S === ws)
2273
+ E = Ve;
2274
+ else if (S === xs)
2275
+ E = Ze;
2276
+ else if (S === ys)
2277
+ E = Xe;
2278
+ else if (S >= re && S <= Ye) {
2249
2279
  let I = x + 2;
2250
2280
  for (; I < b; ) {
2251
2281
  const C = o.charCodeAt(I);
2252
- if (C < re || C > Qe) break;
2282
+ if (C < re || C > Ye) break;
2253
2283
  I++;
2254
2284
  }
2255
- v = Xe, B = o.substring(x + 1, I), O = I - x;
2256
- } else if (T === ys) {
2285
+ E = et, B = o.substring(x + 1, I), O = I - x;
2286
+ } else if (S === bs) {
2257
2287
  let I = x + 2;
2258
- for (; I < b && o.charCodeAt(I) !== bs; )
2288
+ for (; I < b && o.charCodeAt(I) !== Ss; )
2259
2289
  I++;
2260
- I < b && I > x + 2 && (v = xs, B = o.substring(x + 2, I), O = I + 1 - x);
2290
+ I < b && I > x + 2 && (E = $s, B = o.substring(x + 2, I), O = I + 1 - x);
2261
2291
  }
2262
- v >= 0 ? (x > S && (u.push(se), f.push(o.substring(S, x))), u.push(v), f.push(B), x += O, S = x) : x++;
2292
+ E >= 0 ? (x > T && (u.push(se), f.push(o.substring(T, x))), u.push(E), f.push(B), x += O, T = x) : x++;
2263
2293
  }
2264
- S < b && (u.push(se), f.push(o.substring(S))), d = u.length;
2294
+ T < b && (u.push(se), f.push(o.substring(T))), d = u.length;
2265
2295
  } else
2266
2296
  l = o;
2267
2297
  }
2268
- let p = "", g = 0, m = 0;
2298
+ let p = "", h = 0, g = 0;
2269
2299
  s.lastIndex = 0;
2270
2300
  let y;
2271
2301
  for (; (y = s.exec(t)) !== null; ) {
2272
- const b = y.index, $ = y[0], S = $.length, x = b + S;
2273
- let T, v, B, O;
2302
+ const b = y.index, $ = y[0], T = $.length, x = b + T;
2303
+ let S, E, B, O;
2274
2304
  if (i === 1)
2275
- T = 0, v = 1, B = 0, O = e;
2305
+ S = 0, E = 1, B = 0, O = e;
2276
2306
  else {
2277
2307
  let I = 0, C = i - 1;
2278
2308
  for (; I < C; ) {
2279
2309
  const N = I + C + 1 >> 1;
2280
2310
  n[N] <= b ? I = N : C = N - 1;
2281
2311
  }
2282
- if (T = I, S > 0) {
2312
+ if (S = I, T > 0) {
2283
2313
  const N = x - 1;
2284
2314
  for (C = i - 1; I < C; ) {
2285
2315
  const D = I + C + 1 >> 1;
2286
2316
  n[D] <= N ? I = D : C = D - 1;
2287
2317
  }
2288
- v = I + 1;
2318
+ E = I + 1;
2289
2319
  } else
2290
- v = T + 1;
2291
- B = n[T], O = v < i ? n[v] : e;
2320
+ E = S + 1;
2321
+ B = n[S], O = E < i ? n[E] : e;
2292
2322
  }
2293
2323
  if (a.push({
2294
2324
  offset: [b, x],
2295
- lines: [T, v],
2325
+ lines: [S, E],
2296
2326
  linesOffset: [B, O]
2297
2327
  }), o != null) {
2298
- p += t.substring(g, b);
2328
+ p += t.substring(h, b);
2299
2329
  let I;
2300
2330
  if (l != null)
2301
2331
  I = l;
2302
2332
  else {
2303
2333
  I = "";
2304
2334
  const N = y.groups, D = y.length - 1;
2305
- for (let W = 0; W < d; W++) {
2306
- const q = u[W], P = f[W];
2335
+ for (let K = 0; K < d; K++) {
2336
+ const q = u[K], P = f[K];
2307
2337
  switch (q) {
2308
2338
  case se:
2309
2339
  I += P;
2310
2340
  break;
2311
- case Ye:
2341
+ case Ve:
2312
2342
  I += $;
2313
2343
  break;
2314
- case Ve:
2344
+ case Ze:
2315
2345
  I += t.substring(0, b);
2316
2346
  break;
2317
- case Ze:
2347
+ case Xe:
2318
2348
  I += t.substring(x);
2319
2349
  break;
2320
- case Xe: {
2350
+ case et: {
2321
2351
  const L = P, z = L.length, A = L.charCodeAt(0) - re;
2322
2352
  if (z >= 2) {
2323
2353
  const G = L.charCodeAt(1) - re, R = A * 10 + G;
@@ -2335,53 +2365,53 @@ function $s(r) {
2335
2365
  }
2336
2366
  }
2337
2367
  p += I;
2338
- const C = b + m;
2368
+ const C = b + g;
2339
2369
  c.push({
2340
2370
  offset: [C, C + I.length],
2341
2371
  lines: [0, 0],
2342
2372
  linesOffset: [0, 0]
2343
- }), m += I.length - S, g = x;
2373
+ }), g += I.length - T, h = x;
2344
2374
  }
2345
- if (S === 0 && s.lastIndex++, !s.global)
2375
+ if (T === 0 && s.lastIndex++, !s.global)
2346
2376
  break;
2347
2377
  }
2348
2378
  if (s.lastIndex = 0, o == null)
2349
2379
  return { search: { content: t, matches: a }, replace: null };
2350
- p += t.substring(g);
2380
+ p += t.substring(h);
2351
2381
  const w = p.length, M = [0];
2352
2382
  for (let b = 0; b < w; b++)
2353
- p.charCodeAt(b) === He && b + 1 < w && M.push(b + 1);
2354
- const E = M.length;
2383
+ p.charCodeAt(b) === Qe && b + 1 < w && M.push(b + 1);
2384
+ const v = M.length;
2355
2385
  for (let b = 0, $ = c.length; b < $; b++) {
2356
- const S = c[b], x = S.offset[0], T = S.offset[1];
2357
- let v, B, O, I;
2358
- if (E === 1)
2359
- v = 0, B = 1, O = 0, I = w;
2386
+ const T = c[b], x = T.offset[0], S = T.offset[1];
2387
+ let E, B, O, I;
2388
+ if (v === 1)
2389
+ E = 0, B = 1, O = 0, I = w;
2360
2390
  else {
2361
- let C = 0, N = E - 1;
2391
+ let C = 0, N = v - 1;
2362
2392
  for (; C < N; ) {
2363
2393
  const D = C + N + 1 >> 1;
2364
2394
  M[D] <= x ? C = D : N = D - 1;
2365
2395
  }
2366
- if (v = C, T > x) {
2367
- const D = T - 1;
2368
- for (N = E - 1; C < N; ) {
2369
- const W = C + N + 1 >> 1;
2370
- M[W] <= D ? C = W : N = W - 1;
2396
+ if (E = C, S > x) {
2397
+ const D = S - 1;
2398
+ for (N = v - 1; C < N; ) {
2399
+ const K = C + N + 1 >> 1;
2400
+ M[K] <= D ? C = K : N = K - 1;
2371
2401
  }
2372
2402
  B = C + 1;
2373
2403
  } else
2374
- B = v + 1;
2375
- O = M[v], I = B < E ? M[B] : w;
2404
+ B = E + 1;
2405
+ O = M[E], I = B < v ? M[B] : w;
2376
2406
  }
2377
- S.lines[0] = v, S.lines[1] = B, S.linesOffset[0] = O, S.linesOffset[1] = I;
2407
+ T.lines[0] = E, T.lines[1] = B, T.linesOffset[0] = O, T.linesOffset[1] = I;
2378
2408
  }
2379
2409
  return {
2380
2410
  search: { content: t, matches: a },
2381
2411
  replace: { content: p, matches: c }
2382
2412
  };
2383
2413
  }
2384
- function Et(r) {
2414
+ function Nt(r) {
2385
2415
  if (r.length === 0)
2386
2416
  return [];
2387
2417
  const t = [...r].sort((i, a) => {
@@ -2420,48 +2450,48 @@ function oe(r, t, s, o) {
2420
2450
  return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: c + 1 };
2421
2451
  return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: t };
2422
2452
  }
2423
- function Is(r, t) {
2453
+ function Ms(r, t) {
2424
2454
  if (r.replace == null && t.replace == null) {
2425
2455
  const U = [...r.search.matches, ...t.search.matches];
2426
2456
  return {
2427
- search: { content: r.search.content, matches: Et(U) },
2457
+ search: { content: r.search.content, matches: Nt(U) },
2428
2458
  replace: null
2429
2459
  };
2430
2460
  }
2431
- 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, p = u.length, g = [], m = [];
2432
- let y = 0, w = 0, M = 0, E = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, B = 0, O = 0, I = 0, C = 0, N = 0, D = 0, W = 0, q = 0, P = 0, L = 0, z = 0, A = 0, G = 0, R = 0;
2461
+ 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, p = u.length, h = [], g = [];
2462
+ let y = 0, w = 0, M = 0, v = 0, b = 0, $ = 0, T = 0, x = 0, S = 0, E = 0, B = 0, O = 0, I = 0, C = 0, N = 0, D = 0, K = 0, q = 0, P = 0, L = 0, z = 0, A = 0, G = 0, R = 0;
2433
2463
  for (; y < d || w < p; )
2434
- if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < p && (S = u[w].offset[0], x = u[w].offset[1]), y < d && w < p && b < x && S < $) {
2435
- W = b < S ? b : S, T = $ > x ? $ : x, B = y, O = w, y++, w++;
2464
+ if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < p && (T = u[w].offset[0], x = u[w].offset[1]), y < d && w < p && b < x && T < $) {
2465
+ K = b < T ? b : T, S = $ > x ? $ : x, B = y, O = w, y++, w++;
2436
2466
  do {
2437
- for (v = T; y < d && l[y].offset[0] < T; )
2438
- $ = l[y].offset[1], $ > T && (T = $), y++;
2439
- for (; w < p && u[w].offset[0] < T; )
2440
- x = u[w].offset[1], x > T && (T = x), w++;
2441
- } while (T !== v);
2442
- I = 1 / 0, C = -1 / 0, q = W, P = M;
2467
+ for (E = S; y < d && l[y].offset[0] < S; )
2468
+ $ = l[y].offset[1], $ > S && (S = $), y++;
2469
+ for (; w < p && u[w].offset[0] < S; )
2470
+ x = u[w].offset[1], x > S && (S = x), w++;
2471
+ } while (S !== E);
2472
+ I = 1 / 0, C = -1 / 0, q = K, P = M;
2443
2473
  for (let _ = B; _ < y; _++)
2444
2474
  L = c[_].offset[0], z = c[_].offset[1], A = l[_].offset[0], G = l[_].offset[1], q < A && (R = q + P, R < I && (I = R), R = A + P, R > C && (C = R)), L < I && (I = L), z > C && (C = z), P += z - L - G + A, q = G;
2445
- q < T && (R = q + P, R < I && (I = R), R = T + P, R > C && (C = R)), M = P, N = 1 / 0, D = -1 / 0, q = W, P = E;
2475
+ q < S && (R = q + P, R < I && (I = R), R = S + P, R > C && (C = R)), M = P, N = 1 / 0, D = -1 / 0, q = K, P = v;
2446
2476
  for (let _ = O; _ < w; _++)
2447
2477
  L = u[_].offset[0], z = u[_].offset[1], A = f[_].offset[0], G = f[_].offset[1], q < L && (R = q + P, R < N && (N = R), R = L + P, R > D && (D = R)), A < N && (N = A), G > D && (D = G), P += G - A - z + L, q = z;
2448
- q < T && (R = q + P, R < N && (N = R), R = T + P, R > D && (D = R)), E = P;
2478
+ q < S && (R = q + P, R < N && (N = R), R = S + P, R > D && (D = R)), v = P;
2449
2479
  const U = oe(e, i, I, C);
2450
- g.push({
2480
+ h.push({
2451
2481
  offset: [I, C],
2452
2482
  lines: [U.startLine, U.endLine],
2453
2483
  linesOffset: [U.startLineOfs, U.endLineOfs]
2454
2484
  });
2455
2485
  const te = oe(n, a, N, D);
2456
- m.push({
2486
+ g.push({
2457
2487
  offset: [N, D],
2458
2488
  lines: [te.startLine, te.endLine],
2459
2489
  linesOffset: [te.startLineOfs, te.endLineOfs]
2460
2490
  });
2461
- } else if (w >= p || y < d && b <= S) {
2462
- L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], G = l[y].offset[1], N = A + E, D = G + E;
2491
+ } else if (w >= p || y < d && b <= T) {
2492
+ L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], G = l[y].offset[1], N = A + v, D = G + v;
2463
2493
  const U = oe(n, a, N, D);
2464
- g.push(c[y]), m.push({
2494
+ h.push(c[y]), g.push({
2465
2495
  offset: [N, D],
2466
2496
  lines: [U.startLine, U.endLine],
2467
2497
  linesOffset: [U.startLineOfs, U.endLineOfs]
@@ -2469,20 +2499,20 @@ function Is(r, t) {
2469
2499
  } else {
2470
2500
  L = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], G = f[w].offset[1], I = L + M, C = z + M;
2471
2501
  const U = oe(e, i, I, C);
2472
- g.push({
2502
+ h.push({
2473
2503
  offset: [I, C],
2474
2504
  lines: [U.startLine, U.endLine],
2475
2505
  linesOffset: [U.startLineOfs, U.endLineOfs]
2476
- }), m.push(f[w]), E += G - A - z + L, w++;
2506
+ }), g.push(f[w]), v += G - A - z + L, w++;
2477
2507
  }
2478
2508
  return {
2479
- search: { content: e, matches: g },
2480
- replace: { content: n, matches: m }
2509
+ search: { content: e, matches: h },
2510
+ replace: { content: n, matches: g }
2481
2511
  };
2482
2512
  }
2483
- async function Ms(r) {
2513
+ async function Ts(r) {
2484
2514
  const { filePath: t, operations: s, dryRun: o } = r;
2485
- return s.length === 0 ? { filePath: t, result: null } : ms({
2515
+ return s.length === 0 ? { filePath: t, result: null } : gs({
2486
2516
  filePath: t,
2487
2517
  func: async () => {
2488
2518
  let e;
@@ -2508,12 +2538,12 @@ async function Ms(r) {
2508
2538
  error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
2509
2539
  };
2510
2540
  }
2511
- const u = n?.replace?.content ?? e, f = $s({
2541
+ const u = n?.replace?.content ?? e, f = Is({
2512
2542
  content: u,
2513
2543
  pattern: l,
2514
2544
  replacement: c.replacement
2515
2545
  });
2516
- c.replacement != null && (i = !0), n == null ? n = f : n = Is(n, f);
2546
+ c.replacement != null && (i = !0), n == null ? n = f : n = Ms(n, f);
2517
2547
  }
2518
2548
  if (i && n?.replace != null && !o) {
2519
2549
  const a = n.replace.content;
@@ -2532,7 +2562,7 @@ async function Ms(r) {
2532
2562
  }
2533
2563
  });
2534
2564
  }
2535
- async function xe(r) {
2565
+ async function $e(r) {
2536
2566
  const { filePaths: t, operations: s, dryRun: o, dateModifiedMax: e } = r;
2537
2567
  return { results: await Promise.all(
2538
2568
  t.map(async (i) => {
@@ -2551,13 +2581,13 @@ async function xe(r) {
2551
2581
  error: "Not replaced, try again"
2552
2582
  };
2553
2583
  }
2554
- return Ms({ filePath: i, operations: s, dryRun: o });
2584
+ return Ts({ filePath: i, operations: s, dryRun: o });
2555
2585
  })
2556
2586
  ) };
2557
2587
  }
2558
- const Ts = 6;
2559
- function Cs(r) {
2560
- const { content: t, startLine: s } = r, o = r.padWidth ?? Ts;
2588
+ const Cs = 6;
2589
+ function Es(r) {
2590
+ const { content: t, startLine: s } = r, o = r.padWidth ?? Cs;
2561
2591
  let e = "", n = 0, i = 0;
2562
2592
  for (; n < t.length; ) {
2563
2593
  const a = t.indexOf(`
@@ -2572,13 +2602,13 @@ function fe(r) {
2572
2602
  const { content: t, matches: s, outputLimit: o } = r;
2573
2603
  if (s.length === 0)
2574
2604
  return { output: "", truncated: !1 };
2575
- const e = Et(s);
2605
+ const e = Nt(s);
2576
2606
  let n = "", i = !1;
2577
2607
  for (let a = 0; a < e.length; a++) {
2578
2608
  const c = e[a], l = t.substring(
2579
2609
  c.linesOffset[0],
2580
2610
  c.linesOffset[1]
2581
- ), u = Cs({
2611
+ ), u = Es({
2582
2612
  content: l,
2583
2613
  startLine: c.lines[0]
2584
2614
  }), f = a > 0 ? 2 : 0;
@@ -2591,21 +2621,21 @@ function fe(r) {
2591
2621
  }
2592
2622
  return { output: n, truncated: i };
2593
2623
  }
2594
- const et = "BEFORE", tt = "AFTER";
2624
+ const tt = "BEFORE", rt = "AFTER";
2595
2625
  function vs(r) {
2596
2626
  const { result: t, outputLimit: s } = r;
2597
2627
  if (t.replace == null) {
2598
- const g = fe({
2628
+ const h = fe({
2599
2629
  content: t.search.content,
2600
2630
  matches: t.search.matches,
2601
2631
  outputLimit: s
2602
2632
  });
2603
- return { output: g.output, truncated: g.truncated };
2633
+ return { output: h.output, truncated: h.truncated };
2604
2634
  }
2605
- const o = `<${et}>
2606
- `, e = `</${et}>
2607
- `, n = `<${tt}>
2608
- `, i = `</${tt}>
2635
+ const o = `<${tt}>
2636
+ `, e = `</${tt}>
2637
+ `, n = `<${rt}>
2638
+ `, i = `</${rt}>
2609
2639
  `, a = o.length + e.length + n.length + i.length;
2610
2640
  if (s != null && s < a)
2611
2641
  return { output: "", truncated: !0 };
@@ -2620,7 +2650,7 @@ function vs(r) {
2620
2650
  });
2621
2651
  return { output: o + u.output + e + n + d.output + i, truncated: u.truncated || d.truncated };
2622
2652
  }
2623
- function $e(r) {
2653
+ function Ie(r) {
2624
2654
  const { result: t, rootDir: s, errorsOnly: o } = r;
2625
2655
  let e = "";
2626
2656
  for (let n = 0; n < t.results.length; n++) {
@@ -2644,25 +2674,25 @@ function $e(r) {
2644
2674
  }
2645
2675
  return e;
2646
2676
  }
2647
- const Es = h.object({
2648
- pattern: h.string().describe("JS RegExp pattern"),
2649
- flags: h.string().default("gm").describe('JS RegExp flags. Default: "gm"')
2650
- }), Nt = h.object({
2651
- snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2677
+ const Ns = m.object({
2678
+ pattern: m.string().describe("JS RegExp pattern"),
2679
+ flags: m.string().default("gm").describe('JS RegExp flags. Default: "gm"')
2680
+ }), kt = m.object({
2681
+ snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2652
2682
  snapshot: ee.optional().describe(
2653
2683
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2654
2684
  ),
2655
- bulkOperations: h.array(Es).describe(
2685
+ bulkOperations: m.array(Ns).describe(
2656
2686
  "All search patterns to execute; include every pattern here; never split across multiple calls"
2657
2687
  ),
2658
- outputLimit: h.number().int().min(0).max(J).default(Q).describe(
2688
+ outputLimit: m.number().int().min(0).max(J).default(Q).describe(
2659
2689
  `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2660
2690
  )
2661
2691
  });
2662
- async function Ns(r, t, s) {
2692
+ async function ks(r, t, s) {
2663
2693
  let o;
2664
2694
  try {
2665
- o = Nt.parse(r);
2695
+ o = kt.parse(r);
2666
2696
  } catch (w) {
2667
2697
  return {
2668
2698
  error: F(w)
@@ -2699,29 +2729,29 @@ async function Ns(r, t, s) {
2699
2729
  return {
2700
2730
  error: "Either snapshotName or snapshot must be provided"
2701
2731
  };
2702
- const d = vt(l), p = l.query.rootDir ?? ".", g = await xe({
2732
+ const d = vt(l), p = l.query.rootDir ?? ".", h = await $e({
2703
2733
  filePaths: d,
2704
2734
  operations: i
2705
- }), m = $e({
2706
- result: g,
2735
+ }), g = Ie({
2736
+ result: h,
2707
2737
  rootDir: p
2708
2738
  });
2709
2739
  return { output: we({
2710
2740
  sessionId: s.sessionId,
2711
- source: m,
2741
+ source: g,
2712
2742
  limit: a
2713
2743
  }).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2714
2744
  }
2715
- function ks(r, t) {
2745
+ function Os(r, t) {
2716
2746
  r(
2717
2747
  "fs-snapshot-search",
2718
2748
  {
2719
2749
  title: "Search File Contents in Snapshot",
2720
2750
  description: "Search file contents using JS RegExp. Use this to find text patterns across snapshot files. Put all search patterns in the bulkOperations array; use one snapshot with rootDir covering all target files; never split into multiple calls based on file locations, directories, or pattern groups",
2721
- inputSchema: Nt.shape
2751
+ inputSchema: kt.shape
2722
2752
  },
2723
2753
  async (s, o) => {
2724
- const e = await Ns(
2754
+ const e = await ks(
2725
2755
  s,
2726
2756
  t,
2727
2757
  o
@@ -2742,26 +2772,26 @@ Reminder: use one snapshot covering all target files; include all patterns in th
2742
2772
  }
2743
2773
  );
2744
2774
  }
2745
- const Os = h.object({
2746
- pattern: h.string().describe("JS RegExp pattern"),
2747
- flags: h.string().default("gm").describe('JS RegExp flags. Default: "gm"'),
2748
- replacement: h.string().describe("JS replacement pattern")
2749
- }), kt = h.object({
2750
- snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2775
+ const Ds = m.object({
2776
+ pattern: m.string().describe("JS RegExp pattern"),
2777
+ flags: m.string().default("gm").describe('JS RegExp flags. Default: "gm"'),
2778
+ replacement: m.string().describe("JS replacement pattern")
2779
+ }), Ot = m.object({
2780
+ snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2751
2781
  snapshot: ee.optional().describe(
2752
2782
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2753
2783
  ),
2754
- bulkOperations: h.array(Os).describe(
2784
+ bulkOperations: m.array(Ds).describe(
2755
2785
  "All replace patterns to execute; include every pattern here; never split across multiple calls"
2756
2786
  ),
2757
- outputLimit: h.number().int().min(0).max(J).default(Q).describe(
2787
+ outputLimit: m.number().int().min(0).max(J).default(Q).describe(
2758
2788
  `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2759
2789
  )
2760
2790
  });
2761
- async function Ds(r, t, s) {
2791
+ async function Rs(r, t, s) {
2762
2792
  let o;
2763
2793
  try {
2764
- o = kt.parse(r);
2794
+ o = Ot.parse(r);
2765
2795
  } catch (b) {
2766
2796
  return {
2767
2797
  error: F(b)
@@ -2798,20 +2828,20 @@ async function Ds(r, t, s) {
2798
2828
  return {
2799
2829
  error: "Either snapshotName or snapshot must be provided"
2800
2830
  };
2801
- const d = vt(l), p = l.query.rootDir ?? ".", g = {
2831
+ const d = vt(l), p = l.query.rootDir ?? ".", h = {
2802
2832
  filePaths: d,
2803
2833
  operations: i
2804
- }, m = Date.now(), y = await xe({
2805
- ...g,
2834
+ }, g = Date.now(), y = await $e({
2835
+ ...h,
2806
2836
  dryRun: !0
2807
- }), w = Zr();
2837
+ }), w = Xr();
2808
2838
  c.preparedReplace = {
2809
2839
  id: w,
2810
- options: g,
2840
+ options: h,
2811
2841
  rootDir: p,
2812
- dateCreated: m
2842
+ dateCreated: g
2813
2843
  };
2814
- const M = $e({
2844
+ const M = Ie({
2815
2845
  result: y,
2816
2846
  rootDir: p
2817
2847
  }) + `
@@ -2823,16 +2853,16 @@ Review the output carefully before executing. Call fs-snapshot-replace-execute w
2823
2853
  limit: a
2824
2854
  }).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2825
2855
  }
2826
- function Rs(r, t) {
2856
+ function Fs(r, t) {
2827
2857
  r(
2828
2858
  "fs-snapshot-replace-prepare",
2829
2859
  {
2830
2860
  title: "Prepare File Content Replacement",
2831
2861
  description: "Prepares text replacement in files using JS RegExp. Use this to perform bulk replacements across snapshot files. Put all replace patterns in the bulkOperations array; use one snapshot with rootDir covering all target files; never split into multiple calls based on file locations, directories, or pattern groups. Read and review full output to the end. If all replacements are valid get replaceId from the end of output and call fs-snapshot-replace-execute to apply it.",
2832
- inputSchema: kt.shape
2862
+ inputSchema: Ot.shape
2833
2863
  },
2834
2864
  async (s, o) => {
2835
- const e = await Ds(
2865
+ const e = await Rs(
2836
2866
  s,
2837
2867
  t,
2838
2868
  o
@@ -2853,13 +2883,13 @@ Reminder: use one snapshot covering all target files; include all patterns in th
2853
2883
  }
2854
2884
  );
2855
2885
  }
2856
- const Ot = h.object({
2857
- replaceId: h.string().describe("Replace ID from fs-snapshot-replace-prepare output")
2886
+ const Dt = m.object({
2887
+ replaceId: m.string().describe("Replace ID from the END of fs-snapshot-replace-prepare output. NEVER fabricate or guess this value.")
2858
2888
  });
2859
- async function Fs(r, t, s) {
2889
+ async function Bs(r, t, s) {
2860
2890
  let o;
2861
2891
  try {
2862
- o = Ot.parse(r);
2892
+ o = Dt.parse(r);
2863
2893
  } catch (l) {
2864
2894
  return {
2865
2895
  error: F(l)
@@ -2877,28 +2907,28 @@ async function Fs(r, t, s) {
2877
2907
  };
2878
2908
  if (i.id !== e)
2879
2909
  return {
2880
- error: `Invalid replaceId "${e}"`
2910
+ error: `Invalid replaceId "${e}". The replaceId is located at the END of fs-snapshot-replace-prepare output. Read the ENTIRE output to find it. NEVER fabricate or guess this value.`
2881
2911
  };
2882
- const a = await xe({
2912
+ const a = await $e({
2883
2913
  ...i.options,
2884
2914
  dateModifiedMax: i.dateCreated
2885
2915
  });
2886
- return n.preparedReplace = null, { output: $e({
2916
+ return n.preparedReplace = null, { output: Ie({
2887
2917
  result: a,
2888
2918
  rootDir: i.rootDir,
2889
2919
  errorsOnly: !0
2890
2920
  }) || null };
2891
2921
  }
2892
- function Bs(r, t) {
2922
+ function Ls(r, t) {
2893
2923
  r(
2894
2924
  "fs-snapshot-replace-execute",
2895
2925
  {
2896
2926
  title: "Execute Prepared Replacement",
2897
2927
  description: "Executes prepared replacement. Requires replaceId from the end of fs-snapshot-replace-prepare output.",
2898
- inputSchema: Ot.shape
2928
+ inputSchema: Dt.shape
2899
2929
  },
2900
2930
  async (s, o) => {
2901
- const e = await Fs(
2931
+ const e = await Bs(
2902
2932
  s,
2903
2933
  t,
2904
2934
  o
@@ -2913,32 +2943,32 @@ ${e.output}`), n;
2913
2943
  }
2914
2944
  );
2915
2945
  }
2916
- function Ls(r, t) {
2917
- t.list && Yr(r, t), t.snapshotQueryCreate && es(r, t), t.snapshotCreate && ls(r, t), t.snapshotBrowse && ps(r, t), t.snapshotSearch && ks(r, t), t.snapshotReplace && (Rs(r, t), Bs(r, t)), console.log(
2946
+ function Ps(r, t) {
2947
+ t.list && Vr(r, t), t.snapshotQueryCreate && ts(r, t), t.snapshotCreate && cs(r, t), t.snapshotBrowse && hs(r, t), t.snapshotSearch && Os(r, t), t.snapshotReplace && (Fs(r, t), Ls(r, t)), console.log(
2918
2948
  `File manager:
2919
2949
  - Working directory: ${k.resolve(t.workingDir || "")}
2920
2950
  `
2921
2951
  );
2922
2952
  }
2923
2953
  const pe = /* @__PURE__ */ new Map();
2924
- function K(r) {
2954
+ function W(r) {
2925
2955
  return pe.has(r) || pe.set(r, {
2926
2956
  browsers: /* @__PURE__ */ new Map(),
2927
2957
  domSnapshotQueries: /* @__PURE__ */ new Map()
2928
2958
  }), pe.get(r);
2929
2959
  }
2930
- const Ie = h.object({
2931
- name: h.string().describe(
2960
+ const Me = m.object({
2961
+ name: m.string().describe(
2932
2962
  "Unique name for the browser. Recommended format: kebab-case-1, kebab-case-2, ..."
2933
2963
  ),
2934
- browserType: h.enum(["chromium", "firefox", "webkit"]).describe("Browser type to launch"),
2935
- muteAudio: h.boolean().optional().describe("Mute audio in the browser"),
2936
- devTools: h.boolean().optional().describe("Open browser with dev tools")
2964
+ browserType: m.enum(["chromium", "firefox", "webkit"]).describe("Browser type to launch"),
2965
+ muteAudio: m.boolean().optional().describe("Mute audio in the browser"),
2966
+ devTools: m.boolean().optional().describe("Open browser with dev tools")
2937
2967
  });
2938
- async function Dt(r, t, s) {
2968
+ async function Rt(r, t, s) {
2939
2969
  let o;
2940
2970
  try {
2941
- o = Ie.parse(r);
2971
+ o = Me.parse(r);
2942
2972
  } catch (l) {
2943
2973
  return {
2944
2974
  error: F(l)
@@ -2949,12 +2979,12 @@ async function Dt(r, t, s) {
2949
2979
  return {
2950
2980
  error: "Session ID is required"
2951
2981
  };
2952
- const c = K(s.sessionId);
2982
+ const c = W(s.sessionId);
2953
2983
  try {
2954
2984
  const u = await {
2955
- chromium: or,
2956
- firefox: sr,
2957
- webkit: rr
2985
+ chromium: nr,
2986
+ firefox: or,
2987
+ webkit: sr
2958
2988
  }[n].launch({
2959
2989
  headless: !1,
2960
2990
  devtools: a,
@@ -2972,26 +3002,26 @@ async function Dt(r, t, s) {
2972
3002
  };
2973
3003
  }
2974
3004
  }
2975
- function Ps(r, t) {
3005
+ function As(r, t) {
2976
3006
  r(
2977
3007
  "playwright-browser-create",
2978
3008
  {
2979
3009
  title: "Create Browser",
2980
3010
  description: "Create a new browser. Prefer page-goto if you need to immediately create a browser, context, page and navigate",
2981
- inputSchema: Ie.shape
3011
+ inputSchema: Me.shape
2982
3012
  },
2983
3013
  async (s, o) => {
2984
- const e = await Dt(s, t, o);
3014
+ const e = await Rt(s, t, o);
2985
3015
  return `Method: playwright-browser-create(${JSON.stringify(s)})
2986
3016
  ${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
2987
3017
  }
2988
3018
  );
2989
3019
  }
2990
- const Rt = h.object({});
2991
- async function As(r, t, s) {
3020
+ const Ft = m.object({});
3021
+ async function zs(r, t, s) {
2992
3022
  let o;
2993
3023
  try {
2994
- o = Rt.parse(r);
3024
+ o = Ft.parse(r);
2995
3025
  } catch (i) {
2996
3026
  return {
2997
3027
  error: F(i)
@@ -3001,21 +3031,21 @@ async function As(r, t, s) {
3001
3031
  return {
3002
3032
  error: "Session ID is required"
3003
3033
  };
3004
- const e = K(s.sessionId);
3034
+ const e = W(s.sessionId);
3005
3035
  return {
3006
3036
  browserInfos: Array.from(e.browsers.values())
3007
3037
  };
3008
3038
  }
3009
- function zs(r, t) {
3039
+ function Us(r, t) {
3010
3040
  r(
3011
3041
  "playwright-browser-list",
3012
3042
  {
3013
3043
  title: "List Browsers",
3014
3044
  description: "List active browser instances",
3015
- inputSchema: Rt.shape
3045
+ inputSchema: Ft.shape
3016
3046
  },
3017
3047
  async (s, o) => {
3018
- const e = await As(s, t, o);
3048
+ const e = await zs(s, t, o);
3019
3049
  if (e.error != null)
3020
3050
  return `Method: playwright-browser-list(${JSON.stringify(s)})
3021
3051
  ❌ Error: ${e.error}`;
@@ -3027,15 +3057,15 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
3027
3057
  }
3028
3058
  );
3029
3059
  }
3030
- const Ft = h.object({
3031
- names: h.array(h.string()).optional().describe(
3060
+ const Bt = m.object({
3061
+ names: m.array(m.string()).optional().describe(
3032
3062
  "Names of browsers to close. If not specified, closes all browsers"
3033
3063
  )
3034
3064
  });
3035
- async function Us(r, t, s) {
3065
+ async function js(r, t, s) {
3036
3066
  let o;
3037
3067
  try {
3038
- o = Ft.parse(r);
3068
+ o = Bt.parse(r);
3039
3069
  } catch (l) {
3040
3070
  return {
3041
3071
  error: F(l)
@@ -3046,7 +3076,7 @@ async function Us(r, t, s) {
3046
3076
  return {
3047
3077
  error: "Session ID is required"
3048
3078
  };
3049
- const n = K(s.sessionId), i = [], a = [];
3079
+ const n = W(s.sessionId), i = [], a = [];
3050
3080
  let c = [];
3051
3081
  return e ? e.forEach((l) => {
3052
3082
  const u = n.browsers.get(l);
@@ -3066,16 +3096,16 @@ async function Us(r, t, s) {
3066
3096
  ...a.length > 0 && { errors: a }
3067
3097
  };
3068
3098
  }
3069
- function js(r, t) {
3099
+ function qs(r, t) {
3070
3100
  r(
3071
3101
  "playwright-browser-close",
3072
3102
  {
3073
3103
  title: "Close Browsers",
3074
3104
  description: "Close browsers. Automatically closes all contexts and pages within the browsers",
3075
- inputSchema: Ft.shape
3105
+ inputSchema: Bt.shape
3076
3106
  },
3077
3107
  async (s, o) => {
3078
- const e = await Us(s, t, o);
3108
+ const e = await js(s, t, o);
3079
3109
  if (e.error != null)
3080
3110
  return `Method: playwright-browser-close(${JSON.stringify(s)})
3081
3111
  ❌ Error: ${e.error}`;
@@ -3092,25 +3122,25 @@ ${n.join(`
3092
3122
  }
3093
3123
  );
3094
3124
  }
3095
- const Me = h.object({
3096
- browserName: h.string().optional().describe("Name of previously created browser, to use"),
3097
- browser: Ie.optional().describe(
3125
+ const Te = m.object({
3126
+ browserName: m.string().optional().describe("Name of previously created browser, to use"),
3127
+ browser: Me.optional().describe(
3098
3128
  "Browser creation options JSON to automatically create browser"
3099
3129
  ),
3100
- name: h.string().describe(
3130
+ name: m.string().describe(
3101
3131
  "Unique name for the context. Recommended format: kebab-case-1, kebab-case-2, ..."
3102
3132
  ),
3103
- isMobile: h.boolean().optional().describe("Configure for mobile device simulation"),
3104
- hasTouch: h.boolean().optional().describe("Enable touch events"),
3105
- viewport: h.object({
3106
- width: h.number(),
3107
- height: h.number()
3133
+ isMobile: m.boolean().optional().describe("Configure for mobile device simulation"),
3134
+ hasTouch: m.boolean().optional().describe("Enable touch events"),
3135
+ viewport: m.object({
3136
+ width: m.number(),
3137
+ height: m.number()
3108
3138
  }).optional().describe("Viewport size configuration")
3109
3139
  });
3110
- async function Bt(r, t, s) {
3140
+ async function Lt(r, t, s) {
3111
3141
  let o;
3112
3142
  try {
3113
- o = Me.parse(r);
3143
+ o = Te.parse(r);
3114
3144
  } catch (p) {
3115
3145
  return {
3116
3146
  error: F(p)
@@ -3121,7 +3151,7 @@ async function Bt(r, t, s) {
3121
3151
  return {
3122
3152
  error: "Session ID is required"
3123
3153
  };
3124
- const u = K(s.sessionId);
3154
+ const u = W(s.sessionId);
3125
3155
  if (n && i)
3126
3156
  return {
3127
3157
  error: "Either browserName or browser must be provided, not both"
@@ -3133,7 +3163,7 @@ async function Bt(r, t, s) {
3133
3163
  error: `Browser "${n}" not found`
3134
3164
  };
3135
3165
  } else if (i) {
3136
- const p = await Dt(i, t, s);
3166
+ const p = await Rt(i, t, s);
3137
3167
  if (p.error != null)
3138
3168
  return {
3139
3169
  error: p.error
@@ -3148,16 +3178,16 @@ async function Bt(r, t, s) {
3148
3178
  isMobile: a,
3149
3179
  hasTouch: c,
3150
3180
  viewport: l
3151
- }), g = {
3181
+ }), h = {
3152
3182
  browserInfo: d,
3153
3183
  name: e,
3154
3184
  context: p,
3155
3185
  pages: /* @__PURE__ */ new Map()
3156
3186
  };
3157
- return d.contexts.set(e, g), {
3187
+ return d.contexts.set(e, h), {
3158
3188
  browserInfoCreated: f,
3159
3189
  browserInfo: d,
3160
- contextInfo: g
3190
+ contextInfo: h
3161
3191
  };
3162
3192
  } catch (p) {
3163
3193
  return {
@@ -3165,16 +3195,16 @@ async function Bt(r, t, s) {
3165
3195
  };
3166
3196
  }
3167
3197
  }
3168
- function qs(r, t) {
3198
+ function Gs(r, t) {
3169
3199
  r(
3170
3200
  "playwright-context-create",
3171
3201
  {
3172
3202
  title: "Create Browser Context",
3173
3203
  description: "Create a new browser context. Prefer page-goto if you need to immediately create a context, page and navigate",
3174
- inputSchema: Me.shape
3204
+ inputSchema: Te.shape
3175
3205
  },
3176
3206
  async (s, o) => {
3177
- const e = await Bt(s, t, o);
3207
+ const e = await Lt(s, t, o);
3178
3208
  if (e.error != null)
3179
3209
  return `Method: playwright-context-create(${JSON.stringify(s)})
3180
3210
  ❌ Error: ${e.error}`;
@@ -3185,15 +3215,15 @@ function qs(r, t) {
3185
3215
  }
3186
3216
  );
3187
3217
  }
3188
- const Lt = h.object({
3189
- browserName: h.string().optional().describe(
3218
+ const Pt = m.object({
3219
+ browserName: m.string().optional().describe(
3190
3220
  "Name of browser to list contexts from. If not specified, lists contexts from all browsers"
3191
3221
  )
3192
3222
  });
3193
- async function Gs(r, t, s) {
3223
+ async function _s(r, t, s) {
3194
3224
  let o;
3195
3225
  try {
3196
- o = Lt.parse(r);
3226
+ o = Pt.parse(r);
3197
3227
  } catch (a) {
3198
3228
  return {
3199
3229
  error: F(a)
@@ -3204,7 +3234,7 @@ async function Gs(r, t, s) {
3204
3234
  return {
3205
3235
  error: "Session ID is required"
3206
3236
  };
3207
- const n = K(s.sessionId), i = [];
3237
+ const n = W(s.sessionId), i = [];
3208
3238
  if (e) {
3209
3239
  const a = n.browsers.get(e);
3210
3240
  if (!a)
@@ -3227,16 +3257,16 @@ async function Gs(r, t, s) {
3227
3257
  contextsByBrowser: i
3228
3258
  };
3229
3259
  }
3230
- function _s(r, t) {
3260
+ function Js(r, t) {
3231
3261
  r(
3232
3262
  "playwright-context-list",
3233
3263
  {
3234
3264
  title: "List Browser Contexts",
3235
3265
  description: "List active browser contexts",
3236
- inputSchema: Lt.shape
3266
+ inputSchema: Pt.shape
3237
3267
  },
3238
3268
  async (s, o) => {
3239
- const e = await Gs(s, t, o);
3269
+ const e = await _s(s, t, o);
3240
3270
  if ("error" in e)
3241
3271
  return `Method: playwright-context-list(${JSON.stringify(s)})
3242
3272
  ❌ Error: ${e.error}`;
@@ -3249,18 +3279,18 @@ function _s(r, t) {
3249
3279
  }
3250
3280
  );
3251
3281
  }
3252
- const Pt = h.object({
3253
- names: h.array(h.string()).optional().describe(
3282
+ const At = m.object({
3283
+ names: m.array(m.string()).optional().describe(
3254
3284
  "Names of contexts to close. If not specified, closes all contexts"
3255
3285
  ),
3256
- browserName: h.string().optional().describe(
3286
+ browserName: m.string().optional().describe(
3257
3287
  "Name of browser to close contexts from. If not specified, searches all browsers"
3258
3288
  )
3259
3289
  });
3260
- async function Js(r, t, s) {
3290
+ async function Ws(r, t, s) {
3261
3291
  let o;
3262
3292
  try {
3263
- o = Pt.parse(r);
3293
+ o = At.parse(r);
3264
3294
  } catch (u) {
3265
3295
  return {
3266
3296
  error: F(u)
@@ -3271,7 +3301,7 @@ async function Js(r, t, s) {
3271
3301
  return {
3272
3302
  error: "Session ID is required"
3273
3303
  };
3274
- const i = K(s.sessionId), a = [], c = [];
3304
+ const i = W(s.sessionId), a = [], c = [];
3275
3305
  let l = [];
3276
3306
  if (n) {
3277
3307
  const u = i.browsers.get(n);
@@ -3317,10 +3347,10 @@ function Ks(r, t) {
3317
3347
  {
3318
3348
  title: "Close Browser Contexts",
3319
3349
  description: "Close browser contexts. Automatically closes all pages within the contexts",
3320
- inputSchema: Pt.shape
3350
+ inputSchema: At.shape
3321
3351
  },
3322
3352
  async (s, o) => {
3323
- const e = await Js(s, t, o);
3353
+ const e = await Ws(s, t, o);
3324
3354
  if ("error" in e)
3325
3355
  return `Method: playwright-context-close(${JSON.stringify(s)})
3326
3356
  ❌ Error: ${e.error}`;
@@ -3337,7 +3367,7 @@ ${n.join(`
3337
3367
  }
3338
3368
  );
3339
3369
  }
3340
- function Ws() {
3370
+ function Hs() {
3341
3371
  class r {
3342
3372
  prevId = 0;
3343
3373
  objectToId = /* @__PURE__ */ new WeakMap();
@@ -3363,52 +3393,52 @@ function Ws() {
3363
3393
  function t(a, c, l) {
3364
3394
  let u = null;
3365
3395
  for (let f = 0, d = c.length; f < d; f++) {
3366
- const p = c[f], g = a(p), m = g == null ? null : t(a, g, l), y = l(p, m);
3396
+ const p = c[f], h = a(p), g = h == null ? null : t(a, h, l), y = l(p, g);
3367
3397
  y != null && (u == null && (u = []), u.push(y));
3368
3398
  }
3369
3399
  return u;
3370
3400
  }
3371
3401
  function s(a) {
3372
- const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m = t(
3402
+ const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = t(
3373
3403
  l,
3374
3404
  u,
3375
3405
  (w, M) => {
3376
- const E = f(w, M);
3377
- if (w != null && E != null) {
3406
+ const v = f(w, M);
3407
+ if (w != null && v != null) {
3378
3408
  const b = c(w);
3379
- d.set(b, E), p.set(E, b);
3409
+ d.set(b, v), p.set(v, b);
3380
3410
  }
3381
- return E != null && M != null && g.set(
3382
- p.get(E),
3411
+ return v != null && M != null && h.set(
3412
+ p.get(v),
3383
3413
  M.map((b) => p.get(b))
3384
- ), E;
3414
+ ), v;
3385
3415
  }
3386
- ), y = f(null, m);
3416
+ ), y = f(null, g);
3387
3417
  if (y == null)
3388
3418
  throw new Error("Impossible behavior: rootNode == null");
3389
- return d.set(null, y), m != null && g.set(
3419
+ return d.set(null, y), g != null && h.set(
3390
3420
  null,
3391
- m.map((w) => p.get(w))
3421
+ g.map((w) => p.get(w))
3392
3422
  ), {
3393
3423
  idToNode: d,
3394
- idToChildIds: g
3424
+ idToChildIds: h
3395
3425
  };
3396
3426
  }
3397
3427
  const o = (a) => a instanceof HTMLElement ? a.childNodes : null;
3398
3428
  function e(a) {
3399
3429
  return function(l, u) {
3400
3430
  const f = u != null && u.length > 0;
3401
- let d = !1, p = null, g = null;
3431
+ let d = !1, p = null, h = null;
3402
3432
  if (l instanceof HTMLElement) {
3403
- if (p = n.getOrCreateId(l), g = l.tagName.toLowerCase(), d = l.matches(a.cssSelector), !d && !f)
3433
+ if (p = n.getOrCreateId(l), h = l.tagName.toLowerCase(), d = l.matches(a.cssSelector), !d && !f)
3404
3434
  return null;
3405
3435
  } else if (l == null)
3406
- p = null, g = null, d = !1;
3436
+ p = null, h = null, d = !1;
3407
3437
  else
3408
3438
  return null;
3409
3439
  return {
3410
3440
  uid: p,
3411
- tagName: g,
3441
+ tagName: h,
3412
3442
  isMatched: d
3413
3443
  };
3414
3444
  };
@@ -3425,19 +3455,19 @@ function Ws() {
3425
3455
  }
3426
3456
  window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
3427
3457
  }
3428
- const Hs = `(function (){function __name(fn){return fn};${Ws.toString()}; setupPageGlobals();})()`, Te = h.object({
3429
- contextName: h.string().optional().describe("Name of previously created context, to use"),
3430
- context: Me.optional().describe(
3458
+ const Qs = `(function (){function __name(fn){return fn};${Hs.toString()}; setupPageGlobals();})()`, Ce = m.object({
3459
+ contextName: m.string().optional().describe("Name of previously created context, to use"),
3460
+ context: Te.optional().describe(
3431
3461
  "Context creation options JSON to automatically create context"
3432
3462
  ),
3433
- name: h.string().describe(
3463
+ name: m.string().describe(
3434
3464
  "Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
3435
3465
  )
3436
3466
  });
3437
- async function At(r, t, s) {
3467
+ async function zt(r, t, s) {
3438
3468
  let o;
3439
3469
  try {
3440
- o = Te.parse(r);
3470
+ o = Ce.parse(r);
3441
3471
  } catch (f) {
3442
3472
  return {
3443
3473
  error: F(f)
@@ -3448,7 +3478,7 @@ async function At(r, t, s) {
3448
3478
  return {
3449
3479
  error: "Session ID is required"
3450
3480
  };
3451
- const a = K(s.sessionId);
3481
+ const a = W(s.sessionId);
3452
3482
  if (n && i)
3453
3483
  return {
3454
3484
  error: "Either contextName or context must be provided, not both"
@@ -3465,7 +3495,7 @@ async function At(r, t, s) {
3465
3495
  error: `Context "${n}" not found`
3466
3496
  };
3467
3497
  } else if (i) {
3468
- const f = await Bt(i, t, s);
3498
+ const f = await Lt(i, t, s);
3469
3499
  if (f.error != null)
3470
3500
  return {
3471
3501
  error: f.error
@@ -3477,7 +3507,7 @@ async function At(r, t, s) {
3477
3507
  };
3478
3508
  try {
3479
3509
  const f = await u.context.newPage();
3480
- await f.addInitScript(Hs), await f.goto("about:blank");
3510
+ await f.addInitScript(Qs), await f.goto("about:blank");
3481
3511
  const d = {
3482
3512
  contextInfo: u,
3483
3513
  name: e,
@@ -3495,16 +3525,16 @@ async function At(r, t, s) {
3495
3525
  };
3496
3526
  }
3497
3527
  }
3498
- function Qs(r, t) {
3528
+ function Ys(r, t) {
3499
3529
  r(
3500
3530
  "playwright-page-create",
3501
3531
  {
3502
3532
  title: "Create Page",
3503
3533
  description: "Create a new page. Prefer page-goto if you need to immediately create a page and navigate",
3504
- inputSchema: Te.shape
3534
+ inputSchema: Ce.shape
3505
3535
  },
3506
3536
  async (s, o) => {
3507
- const e = await At(s, t, o);
3537
+ const e = await zt(s, t, o);
3508
3538
  if (e.error != null)
3509
3539
  return `Method: playwright-page-create(${JSON.stringify(s)})
3510
3540
  ❌ Error: ${e.error}`;
@@ -3516,18 +3546,18 @@ function Qs(r, t) {
3516
3546
  }
3517
3547
  );
3518
3548
  }
3519
- const zt = h.object({
3520
- contextName: h.string().optional().describe(
3549
+ const Ut = m.object({
3550
+ contextName: m.string().optional().describe(
3521
3551
  "Name of context to list pages from. If not specified, lists pages from all contexts"
3522
3552
  ),
3523
- browserName: h.string().optional().describe(
3553
+ browserName: m.string().optional().describe(
3524
3554
  "Name of browser to search in. If not specified, searches all browsers"
3525
3555
  )
3526
3556
  });
3527
- async function Ys(r, t, s) {
3557
+ async function Vs(r, t, s) {
3528
3558
  let o;
3529
3559
  try {
3530
- o = zt.parse(r);
3560
+ o = Ut.parse(r);
3531
3561
  } catch (c) {
3532
3562
  return {
3533
3563
  error: F(c)
@@ -3538,7 +3568,7 @@ async function Ys(r, t, s) {
3538
3568
  return {
3539
3569
  error: "Session ID is required"
3540
3570
  };
3541
- const i = K(s.sessionId), a = [];
3571
+ const i = W(s.sessionId), a = [];
3542
3572
  if (n) {
3543
3573
  const c = i.browsers.get(n);
3544
3574
  if (!c)
@@ -3588,16 +3618,16 @@ async function Ys(r, t, s) {
3588
3618
  pagesByContext: a
3589
3619
  };
3590
3620
  }
3591
- function Vs(r, t) {
3621
+ function Zs(r, t) {
3592
3622
  r(
3593
3623
  "playwright-page-list",
3594
3624
  {
3595
3625
  title: "List Pages",
3596
3626
  description: "List active pages",
3597
- inputSchema: zt.shape
3627
+ inputSchema: Ut.shape
3598
3628
  },
3599
3629
  async (s, o) => {
3600
- const e = await Ys(s, t, o);
3630
+ const e = await Vs(s, t, o);
3601
3631
  if ("error" in e)
3602
3632
  return `Method: playwright-page-list(${JSON.stringify(s)})
3603
3633
  ❌ Error: ${e.error}`;
@@ -3610,19 +3640,19 @@ function Vs(r, t) {
3610
3640
  }
3611
3641
  );
3612
3642
  }
3613
- const Ut = h.object({
3614
- names: h.array(h.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
3615
- contextName: h.string().optional().describe(
3643
+ const jt = m.object({
3644
+ names: m.array(m.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
3645
+ contextName: m.string().optional().describe(
3616
3646
  "Name of context to close pages from. If not specified, searches all contexts"
3617
3647
  ),
3618
- browserName: h.string().optional().describe(
3648
+ browserName: m.string().optional().describe(
3619
3649
  "Name of browser to search in. If not specified, searches all browsers"
3620
3650
  )
3621
3651
  });
3622
- async function Zs(r, t, s) {
3652
+ async function Xs(r, t, s) {
3623
3653
  let o;
3624
3654
  try {
3625
- o = Ut.parse(r);
3655
+ o = jt.parse(r);
3626
3656
  } catch (f) {
3627
3657
  return {
3628
3658
  error: F(f)
@@ -3633,7 +3663,7 @@ async function Zs(r, t, s) {
3633
3663
  return {
3634
3664
  error: "Session ID is required"
3635
3665
  };
3636
- const a = K(s.sessionId), c = [], l = [];
3666
+ const a = W(s.sessionId), c = [], l = [];
3637
3667
  let u = [];
3638
3668
  if (i) {
3639
3669
  const f = a.browsers.get(i);
@@ -3648,16 +3678,16 @@ async function Zs(r, t, s) {
3648
3678
  error: `Context "${n}" not found in browser "${f.name}" (${f.browserType})`
3649
3679
  };
3650
3680
  e ? e.forEach((p) => {
3651
- const g = d.pages.get(p);
3652
- g ? u.push(g) : l.push(
3681
+ const h = d.pages.get(p);
3682
+ h ? u.push(h) : l.push(
3653
3683
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3654
3684
  );
3655
3685
  }) : u = Array.from(d.pages.values());
3656
3686
  } else
3657
3687
  for (const d of f.contexts.values())
3658
3688
  e ? e.forEach((p) => {
3659
- const g = d.pages.get(p);
3660
- g ? u.push(g) : l.push(
3689
+ const h = d.pages.get(p);
3690
+ h ? u.push(h) : l.push(
3661
3691
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3662
3692
  );
3663
3693
  }) : u.push(...Array.from(d.pages.values()));
@@ -3665,8 +3695,8 @@ async function Zs(r, t, s) {
3665
3695
  for (const f of a.browsers.values()) {
3666
3696
  const d = f.contexts.get(n);
3667
3697
  d && (e ? e.forEach((p) => {
3668
- const g = d.pages.get(p);
3669
- g ? u.push(g) : l.push(
3698
+ const h = d.pages.get(p);
3699
+ h ? u.push(h) : l.push(
3670
3700
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3671
3701
  );
3672
3702
  }) : u.push(...Array.from(d.pages.values())));
@@ -3675,8 +3705,8 @@ async function Zs(r, t, s) {
3675
3705
  for (const f of a.browsers.values())
3676
3706
  for (const d of f.contexts.values())
3677
3707
  e ? e.forEach((p) => {
3678
- const g = d.pages.get(p);
3679
- g ? u.push(g) : l.push(
3708
+ const h = d.pages.get(p);
3709
+ h ? u.push(h) : l.push(
3680
3710
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3681
3711
  );
3682
3712
  }) : u.push(...Array.from(d.pages.values()));
@@ -3697,16 +3727,16 @@ async function Zs(r, t, s) {
3697
3727
  ...l.length > 0 && { errors: l }
3698
3728
  };
3699
3729
  }
3700
- function Xs(r, t) {
3730
+ function eo(r, t) {
3701
3731
  r(
3702
3732
  "playwright-page-close",
3703
3733
  {
3704
3734
  title: "Close Pages",
3705
3735
  description: "Close pages",
3706
- inputSchema: Ut.shape
3736
+ inputSchema: jt.shape
3707
3737
  },
3708
3738
  async (s, o) => {
3709
- const e = await Zs(s, t, o);
3739
+ const e = await Xs(s, t, o);
3710
3740
  if ("error" in e)
3711
3741
  return `Method: playwright-page-close(${JSON.stringify(s)})
3712
3742
  ❌ Error: ${e.error}`;
@@ -3717,14 +3747,14 @@ ${n.join(`
3717
3747
  }
3718
3748
  );
3719
3749
  }
3720
- const jt = h.object({
3721
- pageName: h.string().optional().describe("Name of previously created page to navigate"),
3722
- page: Te.optional().describe(
3750
+ const qt = m.object({
3751
+ pageName: m.string().optional().describe("Name of previously created page to navigate"),
3752
+ page: Ce.optional().describe(
3723
3753
  "Page creation options JSON to automatically create page"
3724
3754
  ),
3725
- url: h.string().describe("URL to navigate to"),
3726
- timeout: h.number().describe("Timeout in seconds"),
3727
- waitUntil: h.enum(["load", "domcontentloaded", "networkidle", "commit"]).describe(
3755
+ url: m.string().describe("URL to navigate to"),
3756
+ timeout: m.number().describe("Timeout in seconds"),
3757
+ waitUntil: m.enum(["load", "domcontentloaded", "networkidle", "commit"]).describe(
3728
3758
  `Wait until event:
3729
3759
  - 'domcontentloaded': DOMContentLoaded event is fired
3730
3760
  - 'load': load event is fired
@@ -3732,13 +3762,13 @@ const jt = h.object({
3732
3762
  - 'commit': network response received and document started loading`
3733
3763
  )
3734
3764
  });
3735
- async function eo(r, t, s) {
3765
+ async function to(r, t, s) {
3736
3766
  let o;
3737
3767
  try {
3738
- o = jt.parse(r);
3739
- } catch (g) {
3768
+ o = qt.parse(r);
3769
+ } catch (h) {
3740
3770
  return {
3741
- error: F(g)
3771
+ error: F(h)
3742
3772
  };
3743
3773
  }
3744
3774
  const { pageName: e, page: n, url: i, timeout: a, waitUntil: c } = o;
@@ -3746,17 +3776,17 @@ async function eo(r, t, s) {
3746
3776
  return {
3747
3777
  error: "Session ID is required"
3748
3778
  };
3749
- const l = K(s.sessionId);
3779
+ const l = W(s.sessionId);
3750
3780
  if (e && n)
3751
3781
  return {
3752
3782
  error: "Either pageName or page must be provided, not both"
3753
3783
  };
3754
3784
  let u = !1, f = !1, d = !1, p;
3755
3785
  if (e) {
3756
- for (const g of l.browsers.values()) {
3757
- for (const m of g.contexts.values())
3758
- if (m.pages.has(e)) {
3759
- p = m.pages.get(e);
3786
+ for (const h of l.browsers.values()) {
3787
+ for (const g of h.contexts.values())
3788
+ if (g.pages.has(e)) {
3789
+ p = g.pages.get(e);
3760
3790
  break;
3761
3791
  }
3762
3792
  if (p) break;
@@ -3766,27 +3796,27 @@ async function eo(r, t, s) {
3766
3796
  error: `Page "${e}" not found`
3767
3797
  };
3768
3798
  } else if (n) {
3769
- const g = await At(n, t, s);
3770
- if (g.error != null)
3799
+ const h = await zt(n, t, s);
3800
+ if (h.error != null)
3771
3801
  return {
3772
- error: g.error
3802
+ error: h.error
3773
3803
  };
3774
- p = g.pageInfo, u = g.browserInfoCreated, f = g.contextInfoCreated, d = !0;
3804
+ p = h.pageInfo, u = h.browserInfoCreated, f = h.contextInfoCreated, d = !0;
3775
3805
  } else
3776
3806
  return {
3777
3807
  error: "Either pageName or page must be provided"
3778
3808
  };
3779
3809
  try {
3780
- const g = await p.page.goto(i, {
3810
+ const h = await p.page.goto(i, {
3781
3811
  timeout: a * 1e3,
3782
3812
  waitUntil: c
3783
3813
  });
3784
- return g ? {
3814
+ return h ? {
3785
3815
  browserInfoCreated: u,
3786
3816
  contextInfoCreated: f,
3787
3817
  pageInfoCreated: d,
3788
3818
  pageInfo: p,
3789
- status: g.status()
3819
+ status: h.status()
3790
3820
  } : {
3791
3821
  browserInfoCreated: u,
3792
3822
  contextInfoCreated: f,
@@ -3794,22 +3824,22 @@ async function eo(r, t, s) {
3794
3824
  pageInfo: p,
3795
3825
  status: 200
3796
3826
  };
3797
- } catch (g) {
3827
+ } catch (h) {
3798
3828
  return {
3799
- error: `Failed to navigate to "${i}": ${g instanceof Error ? g.message : "Unknown error"}`
3829
+ error: `Failed to navigate to "${i}": ${h instanceof Error ? h.message : "Unknown error"}`
3800
3830
  };
3801
3831
  }
3802
3832
  }
3803
- function to(r, t) {
3833
+ function ro(r, t) {
3804
3834
  r(
3805
3835
  "playwright-page-goto",
3806
3836
  {
3807
3837
  title: "Navigate Page",
3808
3838
  description: "Navigate page to URL. Use for manual browser interaction",
3809
- inputSchema: jt.shape
3839
+ inputSchema: qt.shape
3810
3840
  },
3811
3841
  async (s, o) => {
3812
- const e = await eo(s, t, o);
3842
+ const e = await to(s, t, o);
3813
3843
  if (e.error != null)
3814
3844
  return `Method: playwright-page-goto(${JSON.stringify(s)})
3815
3845
  ❌ Error: ${e.error}`;
@@ -3822,16 +3852,16 @@ function to(r, t) {
3822
3852
  }
3823
3853
  );
3824
3854
  }
3825
- const Ce = h.object({
3826
- name: h.string().describe(
3855
+ const Ee = m.object({
3856
+ name: m.string().describe(
3827
3857
  "Unique name for the DOM snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
3828
3858
  ),
3829
- cssSelector: h.string().describe("CSS selector to capture page content")
3859
+ cssSelector: m.string().describe("CSS selector to capture page content")
3830
3860
  });
3831
- async function qt(r, t, s) {
3861
+ async function Gt(r, t, s) {
3832
3862
  let o;
3833
3863
  try {
3834
- o = Ce.parse(r);
3864
+ o = Ee.parse(r);
3835
3865
  } catch (c) {
3836
3866
  return {
3837
3867
  error: F(c)
@@ -3842,7 +3872,7 @@ async function qt(r, t, s) {
3842
3872
  return {
3843
3873
  error: "Session ID is required"
3844
3874
  };
3845
- const i = K(s.sessionId), a = {
3875
+ const i = W(s.sessionId), a = {
3846
3876
  name: e,
3847
3877
  cssSelector: n
3848
3878
  };
@@ -3850,31 +3880,31 @@ async function qt(r, t, s) {
3850
3880
  snapshotQuery: a
3851
3881
  };
3852
3882
  }
3853
- function ro(r, t) {
3883
+ function so(r, t) {
3854
3884
  r(
3855
3885
  "playwright-dom-snapshot-query-create",
3856
3886
  {
3857
3887
  title: "Create DOM Snapshot Query",
3858
3888
  description: "Create a DOM snapshot query. Prefer dom-snapshot-browse if you need to immediately create a query and snapshot and browse it",
3859
- inputSchema: Ce.shape
3889
+ inputSchema: Ee.shape
3860
3890
  },
3861
3891
  async (s, o) => {
3862
- const e = await qt(s, t, o);
3892
+ const e = await Gt(s, t, o);
3863
3893
  return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3864
3894
  ❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3865
3895
  ✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
3866
3896
  }
3867
3897
  );
3868
3898
  }
3869
- function so(r) {
3899
+ function oo(r) {
3870
3900
  return function(s, o) {
3871
3901
  let e, n = 0;
3872
3902
  const i = o ? o.length : 0;
3873
3903
  let a = 1, c = 0, l = 0, u, f;
3874
3904
  if (o)
3875
- for (let g = 0; g < o.length; g++) {
3876
- const m = o[g];
3877
- n += m.countMatched, a += m.countTotal, c += m.tokens, l += m.tokensTotal;
3905
+ for (let h = 0; h < o.length; h++) {
3906
+ const g = o[h];
3907
+ n += g.countMatched, a += g.countTotal, c += g.tokens, l += g.tokensTotal;
3878
3908
  }
3879
3909
  s ? (u = s.uid, f = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, f = null, e = !1);
3880
3910
  let d;
@@ -3887,7 +3917,7 @@ function so(r) {
3887
3917
  textOpen: `<root uid:${u}>`,
3888
3918
  textClose: "</root>"
3889
3919
  };
3890
- const p = It(d);
3920
+ const p = Mt(d);
3891
3921
  return l += p, {
3892
3922
  uid: u,
3893
3923
  tagName: f,
@@ -3902,8 +3932,8 @@ function so(r) {
3902
3932
  };
3903
3933
  };
3904
3934
  }
3905
- function oo(r, t) {
3906
- const s = le(t), o = s.getChilds(s.root), e = $t({
3935
+ function no(r, t) {
3936
+ const s = le(t), o = s.getChilds(s.root), e = It({
3907
3937
  getId: (n) => {
3908
3938
  const i = s.getId(n);
3909
3939
  if (i == null)
@@ -3913,22 +3943,22 @@ function oo(r, t) {
3913
3943
  return i;
3914
3944
  },
3915
3945
  getChilds: (n) => s.getChilds(n),
3916
- createSnapshotNode: so(),
3946
+ createSnapshotNode: oo(),
3917
3947
  rootNodes: o ?? []
3918
3948
  });
3919
3949
  return le(e);
3920
3950
  }
3921
- const ve = h.object({
3922
- pageName: h.string().describe("Name of previously created page, to create snapshot from"),
3923
- queryName: h.string().optional().describe("Name of previously created DOM snapshot query, to use"),
3924
- query: Ce.optional().describe(
3951
+ const ve = m.object({
3952
+ pageName: m.string().describe("Name of previously created page, to create snapshot from"),
3953
+ queryName: m.string().optional().describe("Name of previously created DOM snapshot query, to use"),
3954
+ query: Ee.optional().describe(
3925
3955
  "DOM snapshot query creation options JSON to automatically create query"
3926
3956
  ),
3927
- name: h.string().describe(
3957
+ name: m.string().describe(
3928
3958
  "Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
3929
3959
  )
3930
3960
  });
3931
- async function Gt(r, t, s) {
3961
+ async function _t(r, t, s) {
3932
3962
  let o;
3933
3963
  try {
3934
3964
  o = ve.parse(r);
@@ -3942,7 +3972,7 @@ async function Gt(r, t, s) {
3942
3972
  return {
3943
3973
  error: "Session ID is required"
3944
3974
  };
3945
- const c = K(s.sessionId);
3975
+ const c = W(s.sessionId);
3946
3976
  let l;
3947
3977
  for (const d of c.browsers.values()) {
3948
3978
  for (const p of d.contexts.values())
@@ -3969,7 +3999,7 @@ async function Gt(r, t, s) {
3969
3999
  };
3970
4000
  u = d;
3971
4001
  } else if (i) {
3972
- const d = await qt(
4002
+ const d = await Gt(
3973
4003
  i,
3974
4004
  t,
3975
4005
  s
@@ -3999,13 +4029,13 @@ async function Gt(r, t, s) {
3999
4029
  ), p = {
4000
4030
  idToNode: new Map(d.idToNode),
4001
4031
  idToChildIds: new Map(d.idToChildIds)
4002
- }, g = oo(u, p), m = {
4032
+ }, h = no(u, p), g = {
4003
4033
  name: a,
4004
4034
  query: u,
4005
- tree: g
4035
+ tree: h
4006
4036
  };
4007
- return l.domSnapshots.set(a, m), {
4008
- domSnapshot: m,
4037
+ return l.domSnapshots.set(a, g), {
4038
+ domSnapshot: g,
4009
4039
  queryCreated: f
4010
4040
  };
4011
4041
  } catch (d) {
@@ -4014,7 +4044,7 @@ async function Gt(r, t, s) {
4014
4044
  };
4015
4045
  }
4016
4046
  }
4017
- function no(r, t) {
4047
+ function io(r, t) {
4018
4048
  r(
4019
4049
  "playwright-dom-snapshot-create",
4020
4050
  {
@@ -4023,7 +4053,7 @@ function no(r, t) {
4023
4053
  inputSchema: ve.shape
4024
4054
  },
4025
4055
  async (s, o) => {
4026
- const e = await Gt(s, t, o);
4056
+ const e = await _t(s, t, o);
4027
4057
  if (e.error != null)
4028
4058
  return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
4029
4059
  ❌ Error: ${e.error}`;
@@ -4034,7 +4064,7 @@ function no(r, t) {
4034
4064
  }
4035
4065
  );
4036
4066
  }
4037
- class io {
4067
+ class ao {
4038
4068
  tokens = 20;
4039
4069
  getReportText = (t) => ({
4040
4070
  indent: !0,
@@ -4048,13 +4078,13 @@ class io {
4048
4078
  tokensGrouped: s.tokens
4049
4079
  } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
4050
4080
  }
4051
- const _t = h.object({
4052
- snapshotName: h.string().optional().describe("Name of previously created DOM snapshot, to use"),
4081
+ const Jt = m.object({
4082
+ snapshotName: m.string().optional().describe("Name of previously created DOM snapshot, to use"),
4053
4083
  snapshot: ve.optional().describe(
4054
4084
  "DOM snapshot creation options JSON to automatically create snapshot"
4055
4085
  ),
4056
- parentUid: h.number().optional().describe("UID of parent node to browse. Omit to browse the root node"),
4057
- childsIndexRange: h.tuple([h.number(), h.number()]).optional().describe(
4086
+ parentUid: m.number().optional().describe("UID of parent node to browse. Omit to browse the root node"),
4087
+ childsIndexRange: m.tuple([m.number(), m.number()]).optional().describe(
4058
4088
  "Child index range to show [start, end]. Only use the exact ranges that appeared in previous snapshot results - do not modify, combine, or split them"
4059
4089
  )
4060
4090
  // maxCountTotal: z
@@ -4068,13 +4098,13 @@ const _t = h.object({
4068
4098
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
4069
4099
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
4070
4100
  });
4071
- async function ao(r, t, s) {
4101
+ async function lo(r, t, s) {
4072
4102
  let o;
4073
4103
  try {
4074
- o = _t.parse(r);
4075
- } catch (m) {
4104
+ o = Jt.parse(r);
4105
+ } catch (g) {
4076
4106
  return {
4077
- error: F(m)
4107
+ error: F(g)
4078
4108
  };
4079
4109
  }
4080
4110
  const {
@@ -4090,15 +4120,15 @@ async function ao(r, t, s) {
4090
4120
  return {
4091
4121
  error: "Session ID is required"
4092
4122
  };
4093
- const f = K(s.sessionId);
4123
+ const f = W(s.sessionId);
4094
4124
  if (e && n)
4095
4125
  return {
4096
4126
  error: "Either snapshotName or snapshot must be provided, not both"
4097
4127
  };
4098
- let d, p = !1, g = !1;
4128
+ let d, p = !1, h = !1;
4099
4129
  if (e) {
4100
- for (const m of f.browsers.values()) {
4101
- for (const y of m.contexts.values()) {
4130
+ for (const g of f.browsers.values()) {
4131
+ for (const y of g.contexts.values()) {
4102
4132
  for (const w of y.pages.values())
4103
4133
  if (w.domSnapshots.has(e)) {
4104
4134
  d = w.domSnapshots.get(e);
@@ -4113,25 +4143,25 @@ async function ao(r, t, s) {
4113
4143
  error: `DOM snapshot "${e}" not found`
4114
4144
  };
4115
4145
  } else if (n) {
4116
- const m = await Gt(
4146
+ const g = await _t(
4117
4147
  n,
4118
4148
  t,
4119
4149
  s
4120
4150
  );
4121
- if (m.error != null)
4151
+ if (g.error != null)
4122
4152
  return {
4123
- error: m.error
4153
+ error: g.error
4124
4154
  };
4125
- d = m.domSnapshot, p = m.queryCreated, g = !0;
4155
+ d = g.domSnapshot, p = g.queryCreated, h = !0;
4126
4156
  } else
4127
4157
  return {
4128
4158
  error: "Either snapshotName or snapshot must be provided"
4129
4159
  };
4130
4160
  try {
4131
- const m = o.parentUid, y = Mt({
4161
+ const g = o.parentUid, y = Tt({
4132
4162
  tree: d.tree,
4133
4163
  request: {
4134
- parentNodeId: m,
4164
+ parentNodeId: g,
4135
4165
  childsIndexRange: i,
4136
4166
  limits: {
4137
4167
  maxCountTotal: a,
@@ -4140,32 +4170,32 @@ async function ao(r, t, s) {
4140
4170
  maxTokensGroup: u
4141
4171
  }
4142
4172
  },
4143
- indexRangeGroupStrategy: new io()
4144
- }), w = Tt(y);
4173
+ indexRangeGroupStrategy: new ao()
4174
+ }), w = Ct(y);
4145
4175
  return {
4146
4176
  domSnapshot: d,
4147
4177
  queryCreated: p,
4148
- snapshotCreated: g,
4149
- parentUid: m,
4178
+ snapshotCreated: h,
4179
+ parentUid: g,
4150
4180
  childsIndexRange: i,
4151
4181
  report: w
4152
4182
  };
4153
- } catch (m) {
4183
+ } catch (g) {
4154
4184
  return {
4155
- error: `Failed to browse DOM snapshot: ${m instanceof Error ? m.message : "Unknown error"}`
4185
+ error: `Failed to browse DOM snapshot: ${g instanceof Error ? g.message : "Unknown error"}`
4156
4186
  };
4157
4187
  }
4158
4188
  }
4159
- function lo(r, t) {
4189
+ function co(r, t) {
4160
4190
  r(
4161
4191
  "playwright-dom-snapshot-browse",
4162
4192
  {
4163
4193
  title: "Browse DOM Snapshot",
4164
4194
  description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
4165
- inputSchema: _t.shape
4195
+ inputSchema: Jt.shape
4166
4196
  },
4167
4197
  async (s, o) => {
4168
- const e = await ao(s, t, o);
4198
+ const e = await lo(s, t, o);
4169
4199
  if (e.error != null)
4170
4200
  return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
4171
4201
  ❌ Error: ${e.error}`;
@@ -4186,10 +4216,10 @@ ${e.report}`, n;
4186
4216
  }
4187
4217
  );
4188
4218
  }
4189
- function co(r, t) {
4190
- t.browserCreate && Ps(r, t), t.browserList && zs(r, t), t.browserClose && js(r, t), t.contextCreate && qs(r, t), t.contextList && _s(r, t), t.contextClose && Ks(r, t), t.pageCreate && Qs(r, t), t.pageList && Vs(r, t), t.pageClose && Xs(r, t), t.pageGoto && to(r, t), t.domSnapshotQueryCreate && ro(r, t), t.domSnapshotCreate && no(r, t), t.domSnapshotBrowse && lo(r, t), console.log("Playwright manager");
4219
+ function uo(r, t) {
4220
+ t.browserCreate && As(r, t), t.browserList && Us(r, t), t.browserClose && qs(r, t), t.contextCreate && Gs(r, t), t.contextList && Js(r, t), t.contextClose && Ks(r, t), t.pageCreate && Ys(r, t), t.pageList && Zs(r, t), t.pageClose && eo(r, t), t.pageGoto && ro(r, t), t.domSnapshotQueryCreate && so(r, t), t.domSnapshotCreate && io(r, t), t.domSnapshotBrowse && co(r, t), console.log("Playwright manager");
4191
4221
  }
4192
- function uo(r) {
4222
+ function fo(r) {
4193
4223
  const { logFilePath: t } = r;
4194
4224
  return async function(o, e, n, i) {
4195
4225
  await ie({
@@ -4211,15 +4241,15 @@ function uo(r) {
4211
4241
  });
4212
4242
  };
4213
4243
  }
4214
- const rt = [
4244
+ const st = [
4215
4245
  "flemist-mcp.config.json",
4216
4246
  "flemist-mcp.config.json5",
4217
4247
  "flemist-mcp.config.yaml"
4218
4248
  ];
4219
- async function fo(r) {
4249
+ async function po(r) {
4220
4250
  const t = k.resolve(r);
4221
- for (let s = 0, o = rt.length; s < o; s++) {
4222
- const e = rt[s], n = k.join(t, e);
4251
+ for (let s = 0, o = st.length; s < o; s++) {
4252
+ const e = st[s], n = k.join(t, e);
4223
4253
  try {
4224
4254
  await j.promises.stat(n);
4225
4255
  } catch {
@@ -4237,11 +4267,11 @@ ${c instanceof Error ? c.message : String(c)}`);
4237
4267
  const a = k.extname(e);
4238
4268
  try {
4239
4269
  if (a === ".json")
4240
- return Ee.parse(i);
4270
+ return Ne.parse(i);
4241
4271
  if (a === ".json5")
4242
- return Ee.parse(i);
4272
+ return Ne.parse(i);
4243
4273
  if (a === ".yaml")
4244
- return ir.load(i);
4274
+ return ar.load(i);
4245
4275
  } catch (c) {
4246
4276
  throw new Error(`MCP Error: Failed to parse config file: ${n}
4247
4277
 
@@ -4255,7 +4285,7 @@ Expected one of:
4255
4285
  - flemist-mcp.config.json5
4256
4286
  - flemist-mcp.config.yaml`);
4257
4287
  }
4258
- const po = {
4288
+ const ho = {
4259
4289
  logDir: "tmp/mcp-project-tools/logs",
4260
4290
  tools: {
4261
4291
  processManager: {
@@ -4294,8 +4324,8 @@ const po = {
4294
4324
  }
4295
4325
  }
4296
4326
  };
4297
- async function ho(r) {
4298
- const t = k.resolve(r), s = await fo(t), o = k.join(t, ".flemist-mcpignore");
4327
+ async function mo(r) {
4328
+ const t = k.resolve(r), s = await po(t), o = k.join(t, ".flemist-mcpignore");
4299
4329
  try {
4300
4330
  await j.promises.stat(o);
4301
4331
  } catch {
@@ -4305,12 +4335,18 @@ Create .flemist-mcpignore file in: ${t}
4305
4335
 
4306
4336
  This file contains glob patterns for files/directories to exclude from MCP operations.`);
4307
4337
  }
4308
- const e = nr(po, s, {
4338
+ const e = ir(ho, s, {
4309
4339
  arrayMerge(n, i) {
4310
4340
  return i;
4311
4341
  }
4312
4342
  });
4313
- return e.tools?.processManager && !e.tools.processManager.workingDir && (e.tools.processManager.workingDir = t), e.tools?.fsManager && !e.tools.fsManager.workingDir && (e.tools.fsManager.workingDir = t), e.tools?.fsManager && (e.tools.fsManager.globsExclude = [
4343
+ return e.tools?.processManager && (e.tools.processManager.workingDir = k.resolve(
4344
+ t,
4345
+ e.tools.processManager.workingDir || ""
4346
+ )), e.tools?.fsManager && (e.tools.fsManager.workingDir = k.resolve(
4347
+ t,
4348
+ e.tools.fsManager.workingDir || ""
4349
+ )), e.tools?.fsManager && (e.tools.fsManager.globsExclude = [
4314
4350
  {
4315
4351
  value: o,
4316
4352
  valueType: "file-contains-patterns",
@@ -4321,25 +4357,25 @@ This file contains glob patterns for files/directories to exclude from MCP opera
4321
4357
  n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(t, n.value));
4322
4358
  }), e.logDir = k.resolve(t, e.logDir), e;
4323
4359
  }
4324
- function Jt() {
4360
+ function Wt() {
4325
4361
  return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
4326
4362
  }
4327
- function mo(r) {
4328
- const t = ne(), s = go();
4363
+ function go(r) {
4364
+ const t = ne(), s = wo();
4329
4365
  return t.use(s), t;
4330
4366
  }
4331
- function go(r) {
4367
+ function wo(r) {
4332
4368
  const t = ne.Router();
4333
4369
  return t.use((s, o, e) => {
4334
4370
  s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
4335
4371
  }), t.use(ne.json()), t;
4336
4372
  }
4337
- function wo(r) {
4373
+ function yo(r) {
4338
4374
  const t = ne.Router();
4339
- return t.use(ar({ authToken: r.authToken })), t.all("/mcp", fr(r)), t;
4375
+ return t.use(lr({ authToken: r.authToken })), t.all("/mcp", pr(r)), t;
4340
4376
  }
4341
- function yo(r, t) {
4342
- return r.use(uo({ logFilePath: t.logFilePath })), new Promise((s, o) => {
4377
+ function bo(r, t) {
4378
+ return r.use(fo({ logFilePath: t.logFilePath })), new Promise((s, o) => {
4343
4379
  let e;
4344
4380
  const n = () => {
4345
4381
  s(e);
@@ -4353,7 +4389,7 @@ function yo(r, t) {
4353
4389
  }
4354
4390
  });
4355
4391
  }
4356
- function bo(r, t) {
4392
+ function So(r, t) {
4357
4393
  if (!r.address())
4358
4394
  throw new Error(
4359
4395
  "Server address is not available. Check your DNS and host configuration."
@@ -4371,20 +4407,20 @@ SSE Endpoint: ${i}/sse
4371
4407
 
4372
4408
  Log File: ${k.resolve(t.logFilePath)}`;
4373
4409
  }
4374
- function So(r, t) {
4375
- const s = k.join(t.logDir, Jt()), o = Lr(r, {
4410
+ function xo(r, t) {
4411
+ const s = k.join(t.logDir, Wt()), o = Pr(r, {
4376
4412
  logFilePath: s
4377
4413
  });
4378
- t.tools.processManager && Br(
4414
+ t.tools.processManager && Lr(
4379
4415
  o,
4380
4416
  t.tools.processManager
4381
- ), t.tools.fsManager && Ls(o, t.tools.fsManager), t.tools.playwrightManager && co(
4417
+ ), t.tools.fsManager && Ps(o, t.tools.fsManager), t.tools.playwrightManager && uo(
4382
4418
  o,
4383
4419
  t.tools.playwrightManager
4384
- ), Cr(o);
4420
+ ), Er(o);
4385
4421
  }
4386
- async function jo(r) {
4387
- const t = k.join(r.logDir, Jt()), s = mo(), o = wo({
4422
+ async function qo(r) {
4423
+ const t = k.join(r.logDir, Wt()), s = go(), o = yo({
4388
4424
  authToken: r.authToken,
4389
4425
  logFilePath: t,
4390
4426
  createMcpServer: async (n) => {
@@ -4407,22 +4443,22 @@ X-Project-Name header is missing. To configure MCP for this project:
4407
4443
  Ask user to:
4408
4444
  1. Add project to server's projects config: projects: { "${i}": "<project-path>" }
4409
4445
  2. Restart MCP server`);
4410
- const c = await ho(a), l = new Kt({
4446
+ const c = await mo(a), l = new Kt({
4411
4447
  title: r.title,
4412
4448
  name: r.name,
4413
4449
  version: r.version
4414
4450
  });
4415
- return So(l, c), l;
4451
+ return xo(l, c), l;
4416
4452
  }
4417
4453
  });
4418
4454
  s.use(o);
4419
- const e = await yo(s, {
4455
+ const e = await bo(s, {
4420
4456
  host: r.host,
4421
4457
  port: r.port,
4422
4458
  logFilePath: t
4423
4459
  });
4424
4460
  return console.log(
4425
- bo(e, {
4461
+ So(e, {
4426
4462
  title: r.title,
4427
4463
  name: r.name,
4428
4464
  version: r.version,
@@ -4431,11 +4467,11 @@ Ask user to:
4431
4467
  ), e;
4432
4468
  }
4433
4469
  export {
4434
- Uo as A,
4435
- zo as S,
4436
- Ao as a,
4437
- Po as b,
4438
- fo as l,
4439
- Hr as p,
4440
- jo as s
4470
+ jo as A,
4471
+ Uo as S,
4472
+ zo as a,
4473
+ Ao as b,
4474
+ po as l,
4475
+ Qr as p,
4476
+ qo as s
4441
4477
  };