@flemist/mcp-project-tools 3.0.14 → 3.0.16

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,56 +1,55 @@
1
- import oe from "express";
2
- import { McpServer as Pt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { randomUUID as At } from "crypto";
1
+ import ne from "express";
2
+ import { McpServer as Gt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { randomUUID as Jt } from "crypto";
4
4
  import * as W from "fs";
5
- import * as F from "path";
6
- import zt from "path";
7
- import { StreamableHTTPServerTransport as Ut } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
- import { spawn as qt } from "child_process";
5
+ import * as R from "path";
6
+ import { StreamableHTTPServerTransport as jt } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
+ import { spawn as Kt } from "child_process";
9
8
  import { z as p } from "zod";
10
- import he from "tree-kill";
11
- import { Pool as _t, poolRunWait as Y } from "@flemist/time-limits";
12
- import { priorityCreate as V } from "@flemist/priority-queue";
13
- import { useAbortController as Gt, combineAbortSignals as Jt, Locker as jt } from "@flemist/async-utils";
14
- import Kt from "node:os";
15
- import Wt from "picomatch";
16
- import { webkit as Ht, firefox as Qt, chromium as Yt } from "playwright";
17
- function Vt(r) {
18
- const { authToken: t } = r;
9
+ import pe from "tree-kill";
10
+ import { Pool as Wt, poolRunWait as V } from "@flemist/time-limits";
11
+ import { priorityCreate as Z } from "@flemist/priority-queue";
12
+ import { useAbortController as Ht, combineAbortSignals as Qt, Locker as Yt } from "@flemist/async-utils";
13
+ import Vt from "node:os";
14
+ import Zt from "picomatch";
15
+ import { webkit as Xt, firefox as er, chromium as tr } from "playwright";
16
+ function rr(t) {
17
+ const { authToken: r } = t;
19
18
  return function(o, e, n) {
20
- if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
19
+ if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== r) {
21
20
  e.status(401).json({ error: "Unauthorized" });
22
21
  return;
23
22
  }
24
23
  n();
25
24
  };
26
25
  }
27
- async function ne(r) {
28
- const { logFilePath: t, message: s, data: o } = r;
26
+ async function ie(t) {
27
+ const { logFilePath: r, message: s, data: o } = t;
29
28
  try {
30
29
  const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), a = `[${e}] ${s}
31
30
  ${n}
32
31
 
33
32
  `;
34
- await W.promises.mkdir(F.dirname(t), { recursive: !0 }), await W.promises.appendFile(t, a);
33
+ await W.promises.mkdir(R.dirname(r), { recursive: !0 }), await W.promises.appendFile(r, a);
35
34
  } catch (e) {
36
35
  console.error(`Failed to log "${s}":`, e);
37
36
  }
38
37
  }
39
- const ie = /* @__PURE__ */ new Map();
40
- function Zt(r) {
41
- return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
38
+ const ae = /* @__PURE__ */ new Map();
39
+ function sr(t) {
40
+ return t.headers["mcp-session-id"] || t.headers["x-session-id"] || t.query.token;
42
41
  }
43
- async function Xt(r, t) {
44
- const s = r.createMcpServer(), o = new Ut({
45
- sessionIdGenerator: () => t || At(),
42
+ async function or(t, r) {
43
+ const s = t.createMcpServer(), o = new jt({
44
+ sessionIdGenerator: () => r || Jt(),
46
45
  onsessioninitialized: (n) => {
47
- ie.set(n, o);
46
+ ae.set(n, o);
48
47
  },
49
48
  enableJsonResponse: !0
50
49
  });
51
50
  async function e() {
52
51
  const n = o.sessionId;
53
- n && ie.delete(n);
52
+ n && ae.delete(n);
54
53
  try {
55
54
  await s.close();
56
55
  } catch (a) {
@@ -64,28 +63,28 @@ async function Xt(r, t) {
64
63
  throw await e(), n;
65
64
  }
66
65
  }
67
- async function er(r, t, s, o) {
68
- await ne({
66
+ async function nr(t, r, s, o) {
67
+ await ie({
69
68
  logFilePath: s.logFilePath,
70
69
  message: "REQUEST",
71
- data: r.body
70
+ data: t.body
72
71
  });
73
- let e = o ? ie.get(o) : null;
74
- e || (e = await Xt(s, o)), await e.handleRequest(r, t, r.body);
72
+ let e = o ? ae.get(o) : null;
73
+ e || (e = await or(s, o)), await e.handleRequest(t, r, t.body);
75
74
  }
76
- async function tr(r, t, s) {
77
- const o = s ? ie.get(s) : null;
75
+ async function ir(t, r, s) {
76
+ const o = s ? ae.get(s) : null;
78
77
  if (!o) {
79
- t.status(400).json({ error: "No valid session found" });
78
+ r.status(400).json({ error: "No valid session found" });
80
79
  return;
81
80
  }
82
- await o.handleRequest(r, t);
81
+ await o.handleRequest(t, r);
83
82
  }
84
- function rr(r) {
83
+ function ar(t) {
85
84
  return async function(s, o) {
86
85
  try {
87
- const e = Zt(s);
88
- s.method === "POST" ? await er(s, o, r, e) : s.method === "GET" ? await tr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
86
+ const e = sr(s);
87
+ s.method === "POST" ? await nr(s, o, t, e) : s.method === "GET" ? await ir(s, o, e) : o.status(405).json({ error: "Method not allowed" });
89
88
  } catch (e) {
90
89
  console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
91
90
  error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
@@ -93,14 +92,14 @@ function rr(r) {
93
92
  }
94
93
  };
95
94
  }
96
- const Q = /* @__PURE__ */ new Map();
97
- let sr = 0;
98
- const Te = 10, or = 1800 * 1e3, R = 1e4, nr = 500, ir = 5e3;
99
- function ar(r) {
100
- const { commandLine: t, commandLineRules: s } = r;
95
+ const Y = /* @__PURE__ */ new Map();
96
+ let lr = 0;
97
+ const Ce = 10, cr = 1800 * 1e3, J = 1e4, Q = 2e3, ur = 5e3;
98
+ function dr(t) {
99
+ const { commandLine: r, commandLineRules: s } = t;
101
100
  let o = !1;
102
101
  for (const e of s)
103
- if (new RegExp(e.regexp).test(t))
102
+ if (new RegExp(e.regexp).test(r))
104
103
  switch (e.rule) {
105
104
  case "allow":
106
105
  o = !0;
@@ -113,135 +112,234 @@ function ar(r) {
113
112
  }
114
113
  return o;
115
114
  }
116
- function lr() {
117
- return ++sr;
115
+ function fr() {
116
+ return ++lr;
118
117
  }
119
- let Ce = !1;
120
- function cr() {
121
- if (Ce)
118
+ let Ne = !1;
119
+ function hr() {
120
+ if (Ne)
122
121
  return;
123
- Ce = !0;
124
- const r = () => {
122
+ Ne = !0;
123
+ const t = () => {
125
124
  console.log("Auto-killing all child processes...");
126
- for (const [t, s] of Array.from(Q.entries()))
125
+ for (const [r, s] of Array.from(Y.entries()))
127
126
  if (s.isRunning && s.pid)
128
127
  try {
129
- he(s.pid, "SIGKILL");
128
+ pe(s.pid, "SIGKILL");
130
129
  } catch (o) {
131
- console.error(`Error killing process ${t}:`, o);
130
+ console.error(`Error killing process ${r}:`, o);
132
131
  }
133
132
  process.exit(0);
134
133
  };
135
- process.on("SIGINT", r), process.on("SIGTERM", r);
136
- }
137
- function me() {
138
- const r = Date.now(), t = [];
139
- for (const [s, o] of Array.from(Q.entries()))
140
- !o.isRunning && o.endTime && r - o.endTime.getTime() > or && t.push(s);
141
- for (const s of t)
142
- Q.delete(s);
143
- }
144
- function ge(r) {
145
- const { process: t } = r, s = Date.now();
146
- if (s - t.lastOutputTime.getTime() >= nr && (t.output += t.localOutput, t.localOutput = "", t.lastOutputTime = new Date(s), t.output.length > R)) {
147
- const n = `
148
- ... [${t.output.length - R} characters trimmed] ...
149
- `, a = R - n.length;
150
- if (a > 0) {
151
- const i = Math.floor(a / 2);
152
- t.output = t.output.substring(0, i) + n + t.output.substring(
153
- t.output.length - (a - i)
154
- );
155
- } else
156
- t.output = t.output.substring(0, R);
157
- }
134
+ process.on("SIGINT", t), process.on("SIGTERM", t);
135
+ }
136
+ function ge() {
137
+ const t = Date.now(), r = [];
138
+ for (const [s, o] of Array.from(Y.entries()))
139
+ !o.isRunning && o.endTime && t - o.endTime.getTime() > cr && r.push(s);
140
+ for (const s of r)
141
+ Y.delete(s);
142
+ }
143
+ const pr = 1800 * 1e3, ve = /* @__PURE__ */ new Map();
144
+ let mr = 0;
145
+ function gr() {
146
+ return ++mr;
147
+ }
148
+ function Xe(t) {
149
+ let r = ve.get(t);
150
+ return r == null && (r = {
151
+ storedOutputs: /* @__PURE__ */ new Map()
152
+ }, ve.set(t, r)), r;
153
+ }
154
+ function et(t) {
155
+ return typeof t == "function" ? t() : t;
156
+ }
157
+ function tt(t, r) {
158
+ return setTimeout(() => {
159
+ t.storedOutputs.delete(r);
160
+ }, pr);
161
+ }
162
+ function wr(t, r, s) {
163
+ clearTimeout(s.cleanupTimer), s.cleanupTimer = tt(t, r);
164
+ }
165
+ function yr(t) {
166
+ const { sessionId: r, source: s } = t, o = Xe(r), e = gr(), n = {
167
+ source: s,
168
+ cleanupTimer: tt(o, e)
169
+ };
170
+ return o.storedOutputs.set(e, n), e;
171
+ }
172
+ function rt(t) {
173
+ const { sessionId: r, outputId: s, range: o } = t, [e, n] = o, a = Xe(r), i = a.storedOutputs.get(s);
174
+ if (i == null)
175
+ return {
176
+ content: "",
177
+ total: 0,
178
+ range: [0, 0],
179
+ error: `Stored output with outputId=${s} not found or expired`
180
+ };
181
+ wr(a, s, i);
182
+ const c = et(i.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
183
+ return { content: c.substring(u, f), total: l, range: [u, f] };
184
+ }
185
+ function we(t) {
186
+ const { sessionId: r, source: s, limit: o } = t, e = et(s);
187
+ if (e.length <= o)
188
+ return { content: e, outputId: null };
189
+ const n = yr({ sessionId: r, source: s }), a = rt({
190
+ sessionId: r,
191
+ outputId: n,
192
+ range: [0, o]
193
+ }), i = `
194
+ ... [truncated] showing [0, ${a.content.length}) of ${a.total} chars. To view any range, use output-read with outputId=${n} range=[from, to]`;
195
+ return {
196
+ content: a.content + i,
197
+ outputId: n
198
+ };
158
199
  }
159
- function ur(r, t) {
160
- const s = t.limit;
161
- if (r.length <= s) return r;
162
- const e = `
163
- ... [${r.length - s} characters trimmed] ...
164
- `, n = s - e.length;
165
- if (n <= 0)
166
- return r.substring(0, s);
167
- const a = Math.floor(n / 2);
168
- return r.substring(0, a) + e + r.substring(r.length - (n - a));
169
- }
170
- function B(r) {
171
- return `Invalid arguments: ${r instanceof Error ? r.message : "Unknown error"}.
200
+ function F(t) {
201
+ return `Invalid arguments: ${t instanceof Error ? t.message : "Unknown error"}.
172
202
 
173
203
  Provide valid parameters according to schema.`;
174
204
  }
175
- const Ze = p.object({
205
+ const st = p.object({
206
+ outputId: p.number().int().describe("Output ID from truncation message"),
207
+ range: p.tuple([p.number().int().min(0), p.number().int().min(0)]).describe(
208
+ `Character range [from, to) to retrieve. Maximum range size: ${J}.`
209
+ )
210
+ });
211
+ function br(t, r) {
212
+ let s;
213
+ try {
214
+ s = st.parse(t);
215
+ } catch (a) {
216
+ return {
217
+ error: F(a)
218
+ };
219
+ }
220
+ if (!r.sessionId)
221
+ return {
222
+ error: "Session ID is required"
223
+ };
224
+ const [o, e] = s.range;
225
+ if (e <= o)
226
+ return {
227
+ error: `Invalid range: to (${e}) must be greater than from (${o})`
228
+ };
229
+ if (e - o > J)
230
+ return {
231
+ error: `Range size ${e - o} exceeds maximum ${J}`
232
+ };
233
+ const n = rt({
234
+ sessionId: r.sessionId,
235
+ outputId: s.outputId,
236
+ range: s.range
237
+ });
238
+ return n.error != null ? { error: n.error } : { content: n.content, total: n.total, range: n.range };
239
+ }
240
+ function Sr(t) {
241
+ t(
242
+ "output-read",
243
+ {
244
+ title: "Read Stored Output Range",
245
+ description: "Read any range from stored output. Use outputId from truncation message and specify character range [from, to).",
246
+ inputSchema: st.shape
247
+ },
248
+ async (r, s) => {
249
+ const o = br(r, s);
250
+ if (o.error != null)
251
+ return `Method: output-read(${JSON.stringify(r)})
252
+ ❌ Error: ${o.error}`;
253
+ const [e, n] = o.range, a = o.total;
254
+ let i = `Method: output-read(${JSON.stringify(r)})
255
+ showing [${e}, ${n}) of ${a} chars`;
256
+ return e >= a && (i += `
257
+ ⚠️ Warning: requested range is beyond content (total: ${a} chars)`), i += `
258
+
259
+ ${o.content}`, i;
260
+ }
261
+ );
262
+ }
263
+ function xr(t) {
264
+ Sr(t);
265
+ }
266
+ const ot = p.object({
176
267
  id: p.number().describe(
177
268
  "Process ID to get detailed status information for. Get process IDs using process-list. Works for both running and completed processes. Examples: 1, 42, 123"
178
269
  ),
179
- outputLimit: p.number().max(R).default(R).describe(
180
- `Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${R} characters. Default: ${R}.`
270
+ outputLimit: p.number().int().min(0).max(J).default(Q).describe(
271
+ `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
181
272
  )
182
273
  });
183
- async function we(r, t) {
184
- me();
185
- let s;
274
+ async function ye(t, r, s) {
275
+ ge();
276
+ let o;
186
277
  try {
187
- s = Ze.parse(r);
278
+ o = ot.parse(t);
188
279
  } catch (c) {
189
280
  return {
190
- error: B(c)
281
+ error: F(c)
191
282
  };
192
283
  }
193
- const { id: o, outputLimit: e } = s, n = Q.get(o);
194
- if (!n)
284
+ const { id: e, outputLimit: n } = o, a = Y.get(e);
285
+ if (!a)
195
286
  return {
196
- error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
287
+ error: `Process ${e} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
197
288
  };
198
- ge({ process: n });
199
- const a = n.output + n.localOutput, i = ur(a, { limit: e });
200
- return n.output = "", n.localOutput = "", {
201
- id: n.id,
202
- cwd: F.relative(t.workingDir || "", n.cwd),
203
- commandLine: n.commandLine,
204
- pid: n.pid,
205
- startTime: n.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
206
- endTime: n.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
207
- exitCode: n.exitCode,
208
- isRunning: n.isRunning,
289
+ if (!s.sessionId)
290
+ return {
291
+ error: "Session ID is required"
292
+ };
293
+ const i = we({
294
+ sessionId: s.sessionId,
295
+ source: () => a.output,
296
+ limit: n
297
+ }).content;
298
+ return {
299
+ id: a.id,
300
+ cwd: R.relative(r.workingDir || "", a.cwd),
301
+ commandLine: a.commandLine,
302
+ pid: a.pid,
303
+ startTime: a.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
304
+ endTime: a.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
305
+ exitCode: a.exitCode,
306
+ isRunning: a.isRunning,
209
307
  output: i,
210
- error: n.error
308
+ error: a.error
211
309
  };
212
310
  }
213
- function dr(r, t) {
214
- r(
311
+ function $r(t, r) {
312
+ t(
215
313
  "process-status",
216
314
  {
217
315
  title: "Get Host Machine Process Status",
218
- 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. The output is cleared after retrieval to prevent duplication in subsequent calls",
219
- inputSchema: Ze.shape
316
+ 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",
317
+ inputSchema: ot.shape
220
318
  },
221
- async (s) => {
222
- const o = await we(s, t);
223
- if (!("output" in o))
319
+ async (s, o) => {
320
+ const e = await ye(s, r, o);
321
+ if (!("output" in e))
224
322
  return `Method: process-status(${JSON.stringify(s)})
225
- ❌ Error: ${o.error}`;
226
- const e = o.output || "";
227
- return delete o.output, `Method: process-status(${JSON.stringify(s)})
228
- ${JSON.stringify(o, null, 2)}
323
+ ❌ Error: ${e.error}`;
324
+ const n = e.output || "";
325
+ return delete e.output, `Method: process-status(${JSON.stringify(s)})
326
+ ${JSON.stringify(e, null, 2)}
229
327
 
230
328
  Output:
231
- ${e.trim()}`;
329
+ ${n.trim()}`;
232
330
  }
233
331
  );
234
332
  }
235
- function Xe(r) {
236
- he(r, "SIGTERM", (t) => {
237
- t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
333
+ function nt(t) {
334
+ pe(t, "SIGTERM", (r) => {
335
+ r && !r.message.includes("not found") && console.error(`Error sending SIGTERM to process ${t}:`, r);
238
336
  }), setTimeout(() => {
239
- he(r, "SIGKILL", (t) => {
240
- t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
337
+ pe(t, "SIGKILL", (r) => {
338
+ r && !r.message.includes("not found") && console.error(`Error sending SIGKILL to process ${t}:`, r);
241
339
  });
242
- }, ir);
340
+ }, ur);
243
341
  }
244
- const et = p.object({
342
+ const it = p.object({
245
343
  id: p.number().describe(
246
344
  "Process ID to wait for completion. Get process IDs using process-list. The process can be running or already completed. Examples: 1, 42, 123"
247
345
  ),
@@ -251,62 +349,62 @@ const et = p.object({
251
349
  autoKill: p.boolean().default(!1).describe(
252
350
  "Automatically terminate the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running after timeout). Set to true for processes that should not run indefinitely"
253
351
  ),
254
- outputLimit: p.number().max(R).default(R).describe(
255
- `Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${R} characters. Default: ${R}.`
352
+ outputLimit: p.number().int().min(0).max(J).default(Q).describe(
353
+ `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
256
354
  )
257
355
  });
258
- async function tt(r, t) {
259
- let s;
356
+ async function at(t, r, s) {
357
+ let o;
260
358
  try {
261
- s = et.parse(r);
262
- } catch (h) {
359
+ o = it.parse(t);
360
+ } catch (g) {
263
361
  return {
264
- error: B(h)
362
+ error: F(g)
265
363
  };
266
364
  }
267
- const { id: o, waitTime: e, autoKill: n, outputLimit: a } = s, i = Q.get(o);
268
- if (!i)
365
+ const { id: e, waitTime: n, autoKill: a, outputLimit: i } = o, c = Y.get(e);
366
+ if (!c)
269
367
  return {
270
- error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
368
+ error: `Process ${e} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
271
369
  };
272
- const c = Date.now();
273
- let l = !1, u = !1;
274
- e != null && await new Promise((m) => {
275
- const g = setInterval(() => {
276
- i.isRunning ? Date.now() - c >= e * 1e3 && (clearInterval(g), l = !0, n && i.pid && (Xe(i.pid), u = !0), m()) : (clearInterval(g), m());
370
+ const l = Date.now();
371
+ let u = !1, f = !1;
372
+ n != null && await new Promise((m) => {
373
+ const y = setInterval(() => {
374
+ c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, a && c.pid && (nt(c.pid), f = !0), m()) : (clearInterval(y), m());
277
375
  }, 100);
278
376
  });
279
- const d = (Date.now() - c) / 1e3;
377
+ const d = (Date.now() - l) / 1e3;
280
378
  return {
281
- ...await we({ id: o, outputLimit: a }, t),
379
+ ...await ye({ id: e, outputLimit: i }, r, s),
282
380
  waitDuration: d,
283
- waitTimeExceeded: l,
284
- autoKillExecuted: u
381
+ waitTimeExceeded: u,
382
+ autoKillExecuted: f
285
383
  };
286
384
  }
287
- function fr(r, t) {
288
- r(
385
+ function Ir(t, r) {
386
+ t(
289
387
  "process-wait",
290
388
  {
291
389
  title: "Wait for Host Machine Process",
292
390
  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",
293
- inputSchema: et.shape
391
+ inputSchema: it.shape
294
392
  },
295
- async (s) => {
296
- const o = await tt(s, t);
297
- if (!("output" in o))
393
+ async (s, o) => {
394
+ const e = await at(s, r, o);
395
+ if (!("output" in e))
298
396
  return `Method: process-wait(${JSON.stringify(s)})
299
- ❌ Error: ${o.error}`;
300
- const e = o.output || "";
301
- return delete o.output, `Method: process-wait(${JSON.stringify(s)})
302
- ${JSON.stringify(o, null, 2)}
397
+ ❌ Error: ${e.error}`;
398
+ const n = e.output || "";
399
+ return delete e.output, `Method: process-wait(${JSON.stringify(s)})
400
+ ${JSON.stringify(e, null, 2)}
303
401
 
304
402
  Output:
305
- ${e.trim()}`;
403
+ ${n.trim()}`;
306
404
  }
307
405
  );
308
406
  }
309
- const rt = p.object({
407
+ const lt = p.object({
310
408
  cwd: p.string().optional().describe(
311
409
  'Working directory for command execution, resolved relative to the current working directory. Leave empty to use current directory. Examples: "src" (run in src/ subdirectory), "../parent" (run in parent directory), "build/output" (run in nested subdirectory). Directory must exist'
312
410
  ),
@@ -319,108 +417,98 @@ const rt = p.object({
319
417
  autoKill: p.boolean().default(!1).describe(
320
418
  "Automatically kill the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running). Set to true for commands that should not run indefinitely"
321
419
  ),
322
- outputLimit: p.number().max(R).default(R).describe(
323
- `Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${R} characters. Default: ${R}.`
420
+ outputLimit: p.number().int().min(0).max(J).default(Q).describe(
421
+ `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
324
422
  )
325
423
  });
326
- async function hr(r, t) {
327
- me();
328
- let s;
424
+ async function Mr(t, r, s) {
425
+ ge();
426
+ let o;
329
427
  try {
330
- s = rt.parse(r);
331
- } catch (f) {
428
+ o = lt.parse(t);
429
+ } catch (h) {
332
430
  return {
333
- error: B(f)
431
+ error: F(h)
334
432
  };
335
433
  }
336
- const { commandLine: o, waitTime: e, autoKill: n, outputLimit: a } = s, { commandLineRules: i } = t, c = F.resolve(t.workingDir || "", s.cwd || "");
337
- if (!ar({ commandLine: o, commandLineRules: i })) {
338
- const f = i.map(
339
- (h) => `${h.rule.toUpperCase()}: /${h.regexp}/ (${h.note})`
434
+ const { commandLine: e, waitTime: n, autoKill: a, outputLimit: i } = o, { commandLineRules: c } = r, l = R.resolve(r.workingDir || "", o.cwd || "");
435
+ if (!dr({ commandLine: e, commandLineRules: c })) {
436
+ const h = c.map(
437
+ (g) => `${g.rule.toUpperCase()}: /${g.regexp}/ (${g.note})`
340
438
  ).join(`
341
439
  `);
342
440
  return {
343
- error: `Command line not allowed: "${o}". For security, command lines are validated against configured rules in order. Command line was denied by the rule evaluation. Current command line rules:
344
- ${f}
441
+ 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:
442
+ ${h}
345
443
 
346
444
  To use this command line, ask the user to modify the command line rules in the configuration.`
347
445
  };
348
446
  }
349
- if (Array.from(Q.values()).filter(
350
- (f) => f.isRunning
351
- ).length >= Te)
447
+ if (Array.from(Y.values()).filter(
448
+ (h) => h.isRunning
449
+ ).length >= Ce)
352
450
  return {
353
- error: `Maximum concurrent process limit reached (${Te} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
451
+ error: `Maximum concurrent process limit reached (${Ce} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
354
452
  };
355
- const u = lr(), d = {
356
- id: u,
357
- cwd: c,
358
- commandLine: o,
453
+ const f = fr(), d = {
454
+ id: f,
455
+ cwd: l,
456
+ commandLine: e,
359
457
  startTime: /* @__PURE__ */ new Date(),
360
458
  isRunning: !0,
361
- output: "",
362
- localOutput: "",
363
- lastOutputTime: /* @__PURE__ */ new Date()
459
+ output: ""
364
460
  };
365
- Q.set(u, d);
461
+ Y.set(f, d);
366
462
  try {
367
- const f = qt(o, [], {
463
+ const h = Kt(e, [], {
368
464
  shell: !0,
369
- cwd: c,
465
+ cwd: l,
370
466
  stdio: ["pipe", "pipe", "pipe"]
371
467
  });
372
- d.pid = f.pid;
373
- const h = (m) => {
374
- const g = m.toString();
375
- d.localOutput += g, ge({ process: d }), console.log(g);
468
+ d.pid = h.pid;
469
+ const g = (m) => {
470
+ const y = m.toString();
471
+ d.output += y, console.log(y);
376
472
  };
377
- return f.stdout?.on("data", h), f.stderr?.on("data", h), f.on("close", (m) => {
378
- if (d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.exitCode = m !== null ? m : void 0, d.output += d.localOutput, d.localOutput = "", d.output.length > R) {
379
- const y = `
380
- ... [${d.output.length - R} characters trimmed] ...
381
- `, w = R - y.length;
382
- if (w > 0) {
383
- const M = Math.floor(w / 2);
384
- d.output = d.output.substring(0, M) + y + d.output.substring(
385
- d.output.length - (w - M)
386
- );
387
- } else
388
- d.output = d.output.substring(0, R);
389
- }
390
- console.log(`Process ${u} (${o}) exited with code ${m}`);
391
- }), f.on("error", (m) => {
392
- d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = m.message, console.error(`Process ${u} error:`, m.message);
393
- }), e != null ? tt({ id: u, waitTime: e, autoKill: n, outputLimit: a }, t) : we({ id: u, outputLimit: a }, t);
394
- } catch (f) {
395
- return d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = f instanceof Error ? f.message : "Unknown error", { error: d.error };
473
+ return h.stdout?.on("data", g), h.stderr?.on("data", g), h.on("close", (m) => {
474
+ d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.exitCode = m !== null ? m : void 0, console.log(`Process ${f} (${e}) exited with code ${m}`);
475
+ }), h.on("error", (m) => {
476
+ d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = m.message, console.error(`Process ${f} error:`, m.message);
477
+ }), n != null ? at(
478
+ { id: f, waitTime: n, autoKill: a, outputLimit: i },
479
+ r,
480
+ s
481
+ ) : ye({ id: f, outputLimit: i }, r, s);
482
+ } catch (h) {
483
+ return d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = h instanceof Error ? h.message : "Unknown error", { error: d.error };
396
484
  }
397
485
  }
398
- function pr(r, t) {
399
- const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
486
+ function Tr(t, r) {
487
+ const s = r.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
400
488
  `);
401
- r(
489
+ t(
402
490
  "process-run",
403
491
  {
404
492
  title: "Execute Command Line on Host Machine",
405
493
  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:
406
494
  ${s}`,
407
- inputSchema: rt.shape
495
+ inputSchema: lt.shape
408
496
  },
409
- async (o) => {
410
- const e = await hr(o, t);
411
- if (!("output" in e))
497
+ async (o, e) => {
498
+ const n = await Mr(o, r, e);
499
+ if (!("output" in n))
412
500
  return `Method: process-run(${JSON.stringify(o)})
413
- ❌ Error: ${e.error}`;
414
- const n = e.output || "";
415
- return delete e.output, `Method: process-run(${JSON.stringify(o)})
416
- ${JSON.stringify(e, null, 2)}
501
+ ❌ Error: ${n.error}`;
502
+ const a = n.output || "";
503
+ return delete n.output, `Method: process-run(${JSON.stringify(o)})
504
+ ${JSON.stringify(n, null, 2)}
417
505
 
418
506
  Output:
419
- ${n.trim()}`;
507
+ ${a.trim()}`;
420
508
  }
421
509
  );
422
510
  }
423
- const st = p.object({
511
+ const ct = p.object({
424
512
  minOpenDateTime: p.string().optional().describe(
425
513
  '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'
426
514
  ),
@@ -431,21 +519,21 @@ const st = p.object({
431
519
  "Show only currently running processes. Set to true to exclude completed processes, false to show all processes (running and completed). Default: false (show all)"
432
520
  ),
433
521
  fields: p.array(p.string()).optional().describe(
434
- 'Specific process data fields to include in the response. If omitted, returns all available fields. Available fields: id, cwd, commandLine, pid, startTime, endTime, exitCode, isRunning, output, error. Examples: ["id", "commandLine", "isRunning"] for minimal info, ["id", "output", "exitCode"] for execution results'
522
+ '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'
435
523
  )
436
524
  });
437
- async function mr(r, t) {
438
- me();
525
+ async function Cr(t, r) {
526
+ ge();
439
527
  let s;
440
528
  try {
441
- s = st.parse(r);
529
+ s = ct.parse(t);
442
530
  } catch (l) {
443
531
  return {
444
- error: B(l)
532
+ error: F(l)
445
533
  };
446
534
  }
447
535
  const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: a } = s;
448
- let i = Array.from(Q.values());
536
+ let i = Array.from(Y.values());
449
537
  if (o) {
450
538
  const l = new Date(o.replace(/[_\s]/g, "T"));
451
539
  i = i.filter((u) => u.startTime >= l);
@@ -455,38 +543,38 @@ async function mr(r, t) {
455
543
  i = i.filter((u) => u.endTime && u.endTime >= l);
456
544
  }
457
545
  return n && (i = i.filter((l) => l.isRunning)), { processes: i.map((l) => {
458
- ge({ process: l });
459
546
  let u = {
460
547
  id: l.id,
461
- cwd: zt.relative(t.workingDir || "", l.cwd),
548
+ cwd: R.relative(r.workingDir || "", l.cwd),
462
549
  commandLine: l.commandLine,
463
550
  pid: l.pid,
464
551
  startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
465
552
  endTime: l.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
466
553
  exitCode: l.exitCode,
467
554
  isRunning: l.isRunning,
468
- output: l.output + l.localOutput,
555
+ output: l.output,
469
556
  error: l.error
470
557
  };
471
558
  if (a) {
472
- const d = {};
473
- for (const f of a)
474
- f in u && (d[f] = u[f]);
475
- u = d;
559
+ const f = {};
560
+ f.id = u.id, f.isRunning = u.isRunning, f.commandLine = u.commandLine;
561
+ for (const d of a)
562
+ d in u && (f[d] = u[d]);
563
+ u = f;
476
564
  }
477
565
  return u;
478
566
  }) };
479
567
  }
480
- function gr(r, t) {
481
- r(
568
+ function Nr(t, r) {
569
+ t(
482
570
  "process-list",
483
571
  {
484
572
  title: "List Host Machine Processes",
485
573
  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",
486
- inputSchema: st.shape
574
+ inputSchema: ct.shape
487
575
  },
488
576
  async (s) => {
489
- const o = await mr(s, t);
577
+ const o = await Cr(s, r);
490
578
  if (o.error != null)
491
579
  return `Method: process-list(${JSON.stringify(s)})
492
580
  ❌ Error: ${o.error}`;
@@ -500,21 +588,21 @@ ${e}`;
500
588
  }
501
589
  );
502
590
  }
503
- const ot = p.object({
591
+ const ut = p.object({
504
592
  id: p.number().describe(
505
593
  "Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
506
594
  )
507
595
  });
508
- function wr(r) {
509
- let t;
596
+ function vr(t) {
597
+ let r;
510
598
  try {
511
- t = ot.parse(r);
599
+ r = ut.parse(t);
512
600
  } catch (e) {
513
601
  return {
514
- error: B(e)
602
+ error: F(e)
515
603
  };
516
604
  }
517
- const { id: s } = t, o = Q.get(s);
605
+ const { id: s } = r, o = Y.get(s);
518
606
  if (!o)
519
607
  return {
520
608
  error: `Process ${s} not found. The process may have already completed, been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
@@ -528,54 +616,54 @@ function wr(r) {
528
616
  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.`
529
617
  };
530
618
  try {
531
- return Xe(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
619
+ return nt(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
532
620
  } catch (e) {
533
621
  return {
534
622
  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.`
535
623
  };
536
624
  }
537
625
  }
538
- function yr(r, t) {
539
- r(
626
+ function Er(t, r) {
627
+ t(
540
628
  "process-kill",
541
629
  {
542
630
  title: "Kill Host Machine Process",
543
631
  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",
544
- inputSchema: ot.shape
632
+ inputSchema: ut.shape
545
633
  },
546
634
  async (s) => {
547
- const o = wr(s);
635
+ const o = vr(s);
548
636
  return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
549
637
  ❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
550
638
  ${JSON.stringify(o, null, 2)}`;
551
639
  }
552
640
  );
553
641
  }
554
- function br(r, t) {
555
- cr(), t.run && pr(r, t), t.status && dr(r, t), t.wait && fr(r, t), t.list && gr(r, t), t.kill && yr(r);
556
- const s = t.commandLineRules?.map(
642
+ function kr(t, r) {
643
+ hr(), r.run && Tr(t, r), r.status && $r(t, r), r.wait && Ir(t, r), r.list && Nr(t, r), r.kill && Er(t);
644
+ const s = r.commandLineRules?.map(
557
645
  (o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
558
646
  ) || [];
559
647
  console.log(
560
648
  `Process manager:
561
- - Working directory: ${F.resolve(t.workingDir || "")}
562
- - Command line rules: ${t.commandLineRules?.length || 0} rules configured:
649
+ - Working directory: ${R.resolve(r.workingDir || "")}
650
+ - Command line rules: ${r.commandLineRules?.length || 0} rules configured:
563
651
  ${s.map((o) => `- ${o}`).join(`
564
652
  `)}
565
653
  `
566
654
  );
567
655
  }
568
- function Sr(r, t) {
656
+ function Or(t, r) {
569
657
  return function(o, e, n) {
570
658
  const a = async (...i) => {
571
- await ne({
572
- logFilePath: t.logFilePath,
659
+ await ie({
660
+ logFilePath: r.logFilePath,
573
661
  message: "REQUEST",
574
662
  data: { name: o, args: i }
575
663
  });
576
664
  const c = await n(...i);
577
- return await ne({
578
- logFilePath: t.logFilePath,
665
+ return await ie({
666
+ logFilePath: r.logFilePath,
579
667
  message: "RESPONSE",
580
668
  data: c
581
669
  }), {
@@ -587,35 +675,35 @@ function Sr(r, t) {
587
675
  ]
588
676
  };
589
677
  };
590
- return r.registerTool(
678
+ return t.registerTool(
591
679
  o,
592
680
  e,
593
681
  a
594
682
  );
595
683
  };
596
684
  }
597
- function xr(r) {
598
- return r.match(/^[/\\]?[^/\\]+/)[0];
685
+ function Dr(t) {
686
+ return t.match(/^[/\\]?[^/\\]+/)[0];
599
687
  }
600
- function $r(r, t) {
601
- return xr(r) + "|" + t.ino;
688
+ function Rr(t, r) {
689
+ return Dr(t) + "|" + r.ino;
602
690
  }
603
- function Ir(r) {
604
- return r.endsWith(":") && (r += "/"), F.resolve(r);
691
+ function Fr(t) {
692
+ return t.endsWith(":") && (t += "/"), R.resolve(t);
605
693
  }
606
- const ye = new _t(Kt.cpus().length);
607
- function ve(r, t) {
608
- r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
609
- r.maxFileDateModified,
610
- t.maxFileDateModified
611
- ), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
694
+ const be = new Wt(Vt.cpus().length);
695
+ function Ee(t, r) {
696
+ t.totalSize += r.totalSize, t.maxFileDateModified = Math.max(
697
+ t.maxFileDateModified,
698
+ r.maxFileDateModified
699
+ ), t.countFiles += r.countFiles, t.countDirs += r.countDirs, t.countLinks += r.countLinks;
612
700
  }
613
- const Mr = function(t) {
614
- return t.code === "ENOENT";
701
+ const Br = function(r) {
702
+ return r.code === "ENOENT";
615
703
  };
616
- function nt(r) {
617
- const t = r.paths;
618
- if (!t || t.length === 0)
704
+ function dt(t) {
705
+ const r = t.paths;
706
+ if (!r || r.length === 0)
619
707
  return Promise.resolve({
620
708
  totalSize: 0,
621
709
  maxFileDateModified: 0,
@@ -623,16 +711,16 @@ function nt(r) {
623
711
  countDirs: 0,
624
712
  countLinks: 0
625
713
  });
626
- const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? ye, a = r.handleError, i = r.priority ?? V(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, d = r.matchPath;
627
- async function f(m) {
628
- if (!(a && await a(m)) && !Mr(m))
629
- throw m;
714
+ const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? be, a = t.handleError, i = t.priority ?? Z(0), c = t.walkLinks ?? !1, l = t.log, u = t.handlePath, f = t.matchPath;
715
+ async function d(g) {
716
+ if (!(a && await a(g)) && !Br(g))
717
+ throw g;
630
718
  }
631
- function h(m) {
632
- return !(!l || l.minTotalContentSize != null && m < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
719
+ function h(g) {
720
+ return !(!l || l.minTotalContentSize != null && g < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
633
721
  }
634
- return Gt(async (m) => {
635
- const g = Jt(e, m), y = {
722
+ return Ht(async (g) => {
723
+ const m = Qt(e, g), y = {
636
724
  totalSize: 0,
637
725
  maxFileDateModified: 0,
638
726
  countFiles: 0,
@@ -645,8 +733,8 @@ function nt(r) {
645
733
  l?.handleLog ? l.handleLog(T) : console.log(T);
646
734
  }
647
735
  }
648
- async function M($, S, x, T) {
649
- return u ? await Y({
736
+ async function I($, S, x, T) {
737
+ return u ? await V({
650
738
  pool: n,
651
739
  func: async () => {
652
740
  try {
@@ -656,54 +744,54 @@ function nt(r) {
656
744
  stat: S,
657
745
  itemStat: x,
658
746
  totalStat: y,
659
- abortSignal: g
747
+ abortSignal: m
660
748
  });
661
- } catch (v) {
662
- return await f(v), !1;
749
+ } catch (N) {
750
+ return await d(N), !1;
663
751
  }
664
752
  },
665
753
  count: 1,
666
754
  priority: T,
667
- abortSignal: g
755
+ abortSignal: m
668
756
  }) : !0;
669
757
  }
670
- async function N($, S, x, T) {
758
+ async function v($, S, x, T) {
671
759
  T || (T = $);
672
- const v = await Y({
760
+ const N = await V({
673
761
  pool: n,
674
- func: () => W.promises.lstat($).catch(f),
762
+ func: () => W.promises.lstat($).catch(d),
675
763
  count: 1,
676
- priority: V(S, V(1, i)),
677
- abortSignal: g
764
+ priority: Z(S, Z(1, i)),
765
+ abortSignal: m
678
766
  });
679
- if (!v || !x && v.isFile())
767
+ if (!N || !x && N.isFile())
680
768
  return null;
681
- const L = $r($, v);
682
- if (o.has(L))
769
+ const B = Rr($, N);
770
+ if (o.has(B))
683
771
  return null;
684
- o.add(L);
772
+ o.add(B);
685
773
  let k = {
686
- totalSize: v.size,
687
- maxFileDateModified: v.isDirectory() ? 0 : v.mtimeMs,
774
+ totalSize: N.size,
775
+ maxFileDateModified: N.isDirectory() ? 0 : N.mtimeMs,
688
776
  countFiles: 0,
689
777
  countDirs: 0,
690
778
  countLinks: 0
691
779
  };
692
- const I = V(
780
+ const M = Z(
693
781
  S,
694
- V(v.isDirectory() ? 2 : 3, i)
782
+ Z(N.isDirectory() ? 2 : 3, i)
695
783
  );
696
- if (v.isSymbolicLink()) {
784
+ if (N.isSymbolicLink()) {
697
785
  if (c) {
698
- const C = await Y({
786
+ const C = await V({
699
787
  pool: n,
700
- func: () => W.promises.readlink($).catch(f).then((E) => E ?? null),
788
+ func: () => W.promises.readlink($).catch(d).then((E) => E ?? null),
701
789
  count: 1,
702
- priority: I,
703
- abortSignal: g
790
+ priority: M,
791
+ abortSignal: m
704
792
  });
705
793
  if (C) {
706
- const E = F.isAbsolute(C) ? C : F.resolve(F.dirname(T), C), O = await N(
794
+ const E = R.isAbsolute(C) ? C : R.resolve(R.dirname(T), C), O = await v(
707
795
  E,
708
796
  S,
709
797
  x,
@@ -712,105 +800,105 @@ function nt(r) {
712
800
  O && (k = O);
713
801
  }
714
802
  }
715
- return (x || k.countFiles + k.countDirs + k.countLinks >= 1) && (k.countLinks += 1, await M(
803
+ return (x || k.countFiles + k.countDirs + k.countLinks >= 1) && (k.countLinks += 1, await I(
716
804
  T,
717
- v,
805
+ N,
718
806
  k,
719
- I
720
- ) && (ve(y, k), w(T, k))), k;
721
- } else if (v.isDirectory()) {
722
- const C = await Y({
807
+ M
808
+ ) && (Ee(y, k), w(T, k))), k;
809
+ } else if (N.isDirectory()) {
810
+ const C = await V({
723
811
  pool: n,
724
- func: () => W.promises.readdir($).catch(f),
812
+ func: () => W.promises.readdir($).catch(d),
725
813
  count: 1,
726
814
  priority: i,
727
- abortSignal: g
815
+ abortSignal: m
728
816
  });
729
817
  if (C) {
730
818
  for (let E = 0, O = C.length; E < O; E++)
731
- C[E] = F.join(T, C[E]);
732
- k = await nt({
733
- ...r,
819
+ C[E] = R.join(T, C[E]);
820
+ k = await dt({
821
+ ...t,
734
822
  paths: C,
735
- abortSignal: g,
736
- priority: I,
823
+ abortSignal: m,
824
+ priority: M,
737
825
  level: s + 1,
738
826
  walkedIds: o
739
827
  });
740
828
  }
741
829
  }
742
- return (x || k.countFiles + k.countDirs + k.countLinks >= 1) && (v.isDirectory() ? k.countDirs += 1 : v.isFile() && (k.countFiles += 1), await M(
830
+ return (x || k.countFiles + k.countDirs + k.countLinks >= 1) && (N.isDirectory() ? k.countDirs += 1 : N.isFile() && (k.countFiles += 1), await I(
743
831
  T,
744
- v,
832
+ N,
745
833
  k,
746
- I
747
- ) && (ve(y, k), w(T, k))), k;
834
+ M
835
+ ) && (Ee(y, k), w(T, k))), k;
748
836
  }
749
837
  const b = [];
750
- for (let $ = 0, S = t.length; $ < S; $++) {
751
- const x = Ir(t[$]), T = d ? d(x) : !0;
752
- T !== !1 && b.push(N(x, $, T));
838
+ for (let $ = 0, S = r.length; $ < S; $++) {
839
+ const x = Fr(r[$]), T = f ? f(x) : !0;
840
+ T !== !1 && b.push(v(x, $, T));
753
841
  }
754
842
  return await Promise.all(b), y;
755
843
  });
756
844
  }
757
- function it(r) {
758
- return nt(r);
845
+ function ft(t) {
846
+ return dt(t);
759
847
  }
760
- function H(r) {
761
- return r.replace(/\\/g, "/");
848
+ function H(t) {
849
+ return t.replace(/\\/g, "/");
762
850
  }
763
- function Tr(r, t) {
764
- if (!t || t === ".")
765
- return r;
766
- const s = r.startsWith("^");
767
- s && (r = r.substring(1));
768
- const o = r.startsWith("!");
769
- return o && (r = r.substring(1)), r.startsWith("/") ? (t.endsWith("/") && (t = t.substring(0, t.length - 1)), r = t + r) : (t.endsWith("/") || (t += "/"), r.startsWith("./") ? r = t + r.substring(2) : r.startsWith("../") ? r = t + r : (t.startsWith("..") && (t = ""), r.startsWith("**") ? r = t + r : r = t + "**/" + r)), r = H(F.normalize(r)), o && (r = "!" + r), s && (r = "^" + r), r;
851
+ function Lr(t, r) {
852
+ if (!r || r === ".")
853
+ return t;
854
+ const s = t.startsWith("^");
855
+ s && (t = t.substring(1));
856
+ const o = t.startsWith("!");
857
+ return o && (t = t.substring(1)), t.startsWith("/") ? (r.endsWith("/") && (r = r.substring(0, r.length - 1)), t = r + t) : (r.endsWith("/") || (r += "/"), t.startsWith("./") ? t = r + t.substring(2) : t.startsWith("../") ? t = r + t : (r.startsWith("..") && (r = ""), t.startsWith("**") ? t = r + t : t = r + "**/" + t)), t = H(R.normalize(t)), o && (t = "!" + t), s && (t = "^" + t), t;
770
858
  }
771
- function Cr(r) {
772
- const t = r.startsWith("!");
773
- return t && (r = r.substring(1)), r.startsWith("/") ? r = r.substring(1) : !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
859
+ function Pr(t) {
860
+ const r = t.startsWith("!");
861
+ return r && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), r && (t = "!" + t), t;
774
862
  }
775
- function Ne(r) {
776
- return "^" + r;
863
+ function ke(t) {
864
+ return "^" + t;
777
865
  }
778
- async function vr(r) {
779
- const s = (await W.promises.readFile(r, "utf-8")).split(`
866
+ async function Ar(t) {
867
+ const s = (await W.promises.readFile(t, "utf-8")).split(`
780
868
  `), o = [];
781
869
  return s.forEach((e) => {
782
870
  e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
783
871
  }), o;
784
872
  }
785
- async function at(r) {
786
- const t = r.rootDir ?? ".", s = [];
787
- if (!r.globs?.length)
873
+ async function ht(t) {
874
+ const r = t.rootDir ?? ".", s = [];
875
+ if (!t.globs?.length)
788
876
  return s;
789
877
  const o = [];
790
- return r.globs.forEach((e) => {
791
- e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Ne(e.value) : e.value));
878
+ return t.globs.forEach((e) => {
879
+ e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? ke(e.value) : e.value));
792
880
  }), o.length && await Promise.all(
793
881
  o.map(async (e) => {
794
- await Y({
795
- pool: ye,
882
+ await V({
883
+ pool: be,
796
884
  count: 1,
797
885
  func: async () => {
798
- const n = F.resolve(t, e.value), a = await vr(n), i = F.relative(t, F.dirname(n));
886
+ const n = R.resolve(r, e.value), a = await Ar(n), i = R.relative(r, R.dirname(n));
799
887
  a.forEach((c) => {
800
- c = Cr(c), c = Tr(c, i), s.push(e.exclude ? Ne(c) : c);
888
+ c = Pr(c), c = Lr(c, i), s.push(e.exclude ? ke(c) : c);
801
889
  });
802
890
  }
803
891
  });
804
892
  })
805
893
  ), s;
806
894
  }
807
- function lt({
808
- globs: r,
809
- rootDir: t,
895
+ function pt({
896
+ globs: t,
897
+ rootDir: r,
810
898
  noCase: s
811
899
  }) {
812
900
  const o = [];
813
- return r.forEach((e) => {
901
+ return t.forEach((e) => {
814
902
  e = H(e).trim();
815
903
  const n = e.startsWith("^");
816
904
  n && (e = e.substring(1).trim());
@@ -820,12 +908,12 @@ function lt({
820
908
  `Invalid glob pattern: "${e}". The syntax '${e.substring(0, 2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`
821
909
  );
822
910
  e.startsWith("/") && (e = "." + e);
823
- const i = H(t ? F.resolve(t, e) : e);
911
+ const i = H(r ? R.resolve(r, e) : e);
824
912
  if (!i)
825
913
  return;
826
914
  let c;
827
915
  try {
828
- c = Wt(i, {
916
+ c = Zt(i, {
829
917
  nocase: s ?? !1,
830
918
  dot: !0,
831
919
  strictBrackets: !0
@@ -852,61 +940,61 @@ function lt({
852
940
  return i ? !1 : a;
853
941
  };
854
942
  }
855
- async function Nr(r) {
856
- const t = r.rootDir ?? ".", s = [], o = {};
857
- r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
858
- const e = await at({
859
- rootDir: t,
860
- globs: r.globs
943
+ async function zr(t) {
944
+ const r = t.rootDir ?? ".", s = [], o = {};
945
+ t.result.countFiles && (o.countFiles = 0), t.result.size && (o.size = 0);
946
+ const e = await ht({
947
+ rootDir: r,
948
+ globs: t.globs
861
949
  });
862
- return await it({
863
- paths: [t],
950
+ return await ft({
951
+ paths: [r],
864
952
  walkLinks: !0,
865
- matchPath: lt({
953
+ matchPath: pt({
866
954
  globs: e,
867
- rootDir: t,
955
+ rootDir: r,
868
956
  noCase: !0
869
957
  }),
870
958
  handlePath: async ({ path: n, stat: a, itemStat: i }) => {
871
- const c = F.relative(t, n), l = a.isDirectory(), u = a.isFile();
959
+ const c = R.relative(r, n), l = a.isDirectory(), u = a.isFile();
872
960
  if (!l && !u)
873
961
  return !0;
874
- const d = H(c || "."), f = l ? "dir" : "file", h = l ? i.maxFileDateModified || null : a.mtimeMs, m = l ? i.totalSize : a.size, g = l ? i.countFiles : null, y = {
875
- path: d,
876
- type: f
962
+ const f = H(c || "."), d = l ? "dir" : "file", h = l ? i.maxFileDateModified || null : a.mtimeMs, g = l ? i.totalSize : a.size, m = l ? i.countFiles : null, y = {
963
+ path: f,
964
+ type: d
877
965
  };
878
- if (r.result.dateModified && (y.dateModified = h), r.result.size && (y.size = m), r.result.countFiles && (y.countFiles = g), r.dateModified && h != null) {
879
- const [w, M] = r.dateModified;
880
- if (w != null && h < w || M != null && h > M)
966
+ if (t.result.dateModified && (y.dateModified = h), t.result.size && (y.size = g), t.result.countFiles && (y.countFiles = m), t.dateModified && h != null) {
967
+ const [w, I] = t.dateModified;
968
+ if (w != null && h < w || I != null && h > I)
881
969
  return !1;
882
970
  }
883
- if (r.totalSize && m != null) {
884
- const [w, M] = r.totalSize;
885
- if (w != null && m < w || M != null && m > M)
971
+ if (t.totalSize && g != null) {
972
+ const [w, I] = t.totalSize;
973
+ if (w != null && g < w || I != null && g > I)
886
974
  return !1;
887
975
  }
888
- return f === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), f === "file" && m != null && (o.size = (o.size ?? 0) + m), h != null && (o.dateModified == null || h > o.dateModified) && (o.dateModified = h), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
976
+ return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && g != null && (o.size = (o.size ?? 0) + g), h != null && (o.dateModified == null || h > o.dateModified) && (o.dateModified = h), l && !t.result.dirs || u && !t.result.files || s.push(y), !0;
889
977
  }
890
978
  }), { items: s, totals: o };
891
979
  }
892
- const Ee = ["B", "KB", "MB", "GB", "TB"], ke = 1024;
893
- function Oe(r) {
894
- if (r == null) return "-";
895
- let t = r ?? 0, s = 0;
896
- for (; t >= ke && s < Ee.length - 1; )
897
- t /= ke, s++;
898
- return `${s === 0 ? t.toString() : t.toFixed(2)}${Ee[s]}`;
980
+ const Oe = ["B", "KB", "MB", "GB", "TB"], De = 1024;
981
+ function Re(t) {
982
+ if (t == null) return "-";
983
+ let r = t ?? 0, s = 0;
984
+ for (; r >= De && s < Oe.length - 1; )
985
+ r /= De, s++;
986
+ return `${s === 0 ? r.toString() : r.toFixed(2)}${Oe[s]}`;
899
987
  }
900
- function De(r) {
901
- const s = Date.now() - r;
988
+ function Fe(t) {
989
+ const s = Date.now() - t;
902
990
  if (s < 0) return "0s";
903
991
  const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), c = Math.floor(a / 30), l = Math.floor(a / 365);
904
992
  return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
905
993
  }
906
- function Er(r, t) {
907
- return t?.length ? [...r].sort((s, o) => {
908
- for (let e = 0, n = t.length; e < n; e++) {
909
- const a = t[e];
994
+ function Ur(t, r) {
995
+ return r?.length ? [...t].sort((s, o) => {
996
+ for (let e = 0, n = r.length; e < n; e++) {
997
+ const a = r[e];
910
998
  let i, c;
911
999
  switch (a.field) {
912
1000
  case "type":
@@ -937,10 +1025,10 @@ function Er(r, t) {
937
1025
  return a.desc ? -l : l;
938
1026
  }
939
1027
  return 0;
940
- }) : r;
1028
+ }) : t;
941
1029
  }
942
- function kr(r, t) {
943
- const s = Er(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
1030
+ function qr(t, r) {
1031
+ const s = Ur(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
944
1032
  let e = "";
945
1033
  if (s.length > 0 && o.length > 0) {
946
1034
  for (let n = 0, a = o.length; n < a; n++) {
@@ -971,10 +1059,10 @@ function kr(r, t) {
971
1059
  const u = o[c];
972
1060
  switch (c > 0 && (e += " | "), u) {
973
1061
  case "dateModified":
974
- e += i.dateModified ? De(i.dateModified) : "-";
1062
+ e += i.dateModified ? Fe(i.dateModified) : "-";
975
1063
  break;
976
1064
  case "size":
977
- e += Oe(i.size);
1065
+ e += Re(i.size);
978
1066
  break;
979
1067
  case "type":
980
1068
  e += i.type;
@@ -993,24 +1081,24 @@ function kr(r, t) {
993
1081
  e.length > 0 && (e += `
994
1082
  ---
995
1083
  `);
996
- const n = Oe(r.totals.size ?? 0), a = r.totals.dateModified ? `, last modified ${De(r.totals.dateModified)} ago` : "";
997
- e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${a}`;
1084
+ const n = Re(t.totals.size ?? 0), a = t.totals.dateModified ? `, last modified ${Fe(t.totals.dateModified)} ago` : "";
1085
+ e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${a}`;
998
1086
  }
999
1087
  return e;
1000
1088
  }
1001
- const Or = "3.0.14", Dr = {
1002
- version: Or
1003
- }, fo = "Project Tools", ho = "project-tools", po = Dr.version, mo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Re = 25e3;
1004
- function Fe(r) {
1005
- const t = r.match(
1089
+ const _r = "3.0.16", Gr = {
1090
+ version: _r
1091
+ }, $o = "Project Tools", Io = "project-tools", Mo = Gr.version, To = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Be = 25e3;
1092
+ function Le(t) {
1093
+ const r = t.match(
1006
1094
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1007
1095
  );
1008
- if (!t)
1096
+ if (!r)
1009
1097
  throw new Error(
1010
- `Invalid time ago format: "${r}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1098
+ `Invalid time ago format: "${t}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1011
1099
  );
1012
- const s = parseFloat(t[1]);
1013
- let o = t[2];
1100
+ const s = parseFloat(r[1]);
1101
+ let o = r[2];
1014
1102
  switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
1015
1103
  case "s":
1016
1104
  return s * 1e3;
@@ -1032,13 +1120,13 @@ function Fe(r) {
1032
1120
  );
1033
1121
  }
1034
1122
  }
1035
- function Be(r) {
1036
- const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1037
- if (!t)
1123
+ function Pe(t) {
1124
+ const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1125
+ if (!r)
1038
1126
  throw new Error(
1039
- `Invalid size format: "${r}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1127
+ `Invalid size format: "${t}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1040
1128
  );
1041
- const s = parseFloat(t[1]), o = t[2].toUpperCase();
1129
+ const s = parseFloat(r[1]), o = r[2].toUpperCase();
1042
1130
  switch (o) {
1043
1131
  case "B":
1044
1132
  return s;
@@ -1056,7 +1144,7 @@ function Be(r) {
1056
1144
  );
1057
1145
  }
1058
1146
  }
1059
- const ct = p.object({
1147
+ const mt = p.object({
1060
1148
  rootDir: p.string().optional().describe(
1061
1149
  'Root directory to list files from, resolved relative to the current working directory. Leave empty to use current directory. Examples: "src" (list src/ subdirectory), "../parent" (list parent directory), "docs/api" (list nested subdirectory). Path must exist and be accessible'
1062
1150
  ),
@@ -1095,13 +1183,13 @@ const ct = p.object({
1095
1183
  'Filter files/directories with total size at most this large. Only items with size <= this value will be included. For directories, uses total size of all contents. Format: number + unit (B/KB/MB/GB/TB). Examples: "1MB" (up to 1 megabyte), "500KB" (up to 500 kilobytes), "10GB" (up to 10 gigabytes). Combine with minTotalSize for size ranges'
1096
1184
  )
1097
1185
  });
1098
- async function Rr(r, t) {
1186
+ async function Jr(t, r) {
1099
1187
  let s;
1100
1188
  try {
1101
- s = ct.parse(r);
1102
- } catch (g) {
1189
+ s = mt.parse(t);
1190
+ } catch (m) {
1103
1191
  return {
1104
- error: B(g)
1192
+ error: F(m)
1105
1193
  };
1106
1194
  }
1107
1195
  const {
@@ -1118,46 +1206,46 @@ async function Rr(r, t) {
1118
1206
  return {
1119
1207
  error: 'Fields array must include "path" field when fields are specified. The "path" field is required to identify files and directories in the output'
1120
1208
  };
1121
- const d = s.fields ? s.fields.map((g) => g === "totalCountFiles" ? "countFiles" : g === "lastModified" ? "dateModified" : g) : [];
1122
- let f = a?.map((g) => {
1123
- let y = g.field;
1209
+ const f = s.fields ? s.fields.map((m) => m === "totalCountFiles" ? "countFiles" : m === "lastModified" ? "dateModified" : m) : [];
1210
+ let d = a?.map((m) => {
1211
+ let y = m.field;
1124
1212
  return y === "totalCountFiles" && (y = "countFiles"), y === "lastModified" && (y = "dateModified"), {
1125
1213
  field: y,
1126
- desc: g.desc ?? !1
1214
+ desc: m.desc ?? !1
1127
1215
  // Default to ascending if not specified
1128
1216
  };
1129
1217
  }) ?? null;
1130
- (!f || f.length === 0) && (f = [{ field: "path", desc: !1 }]);
1131
- const h = f?.map((g) => g.field) || [], m = F.resolve(
1132
- t.workingDir || "",
1218
+ (!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
1219
+ const h = d?.map((m) => m.field) || [], g = R.resolve(
1220
+ r.workingDir || "",
1133
1221
  s.rootDir || ""
1134
1222
  );
1135
1223
  try {
1136
1224
  try {
1137
- await W.promises.access(m, W.constants.F_OK);
1225
+ await W.promises.access(g, W.constants.F_OK);
1138
1226
  } catch (x) {
1139
1227
  if (x.code === "ENOENT")
1140
1228
  return {
1141
- error: `Directory does not exist: "${m}". 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.`
1229
+ 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.`
1142
1230
  };
1143
1231
  throw x;
1144
1232
  }
1145
- const g = o && o.length > 0 ? o.map((x) => ({
1233
+ const m = o && o.length > 0 ? o.map((x) => ({
1146
1234
  value: x,
1147
1235
  valueType: "pattern",
1148
1236
  exclude: !1
1149
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...g, ...y], M = {
1237
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = r.globsExclude || [], w = [...m, ...y], I = {
1150
1238
  files: e ?? !1,
1151
1239
  dirs: n ?? !1,
1152
- dateModified: d.includes("dateModified") || h.includes("dateModified"),
1153
- size: d.includes("size") || h.includes("size"),
1154
- countFiles: d.includes("countFiles") || h.includes("countFiles")
1240
+ dateModified: f.includes("dateModified") || h.includes("dateModified"),
1241
+ size: f.includes("size") || h.includes("size"),
1242
+ countFiles: f.includes("countFiles") || h.includes("countFiles")
1155
1243
  };
1156
- let N = null, b = null;
1244
+ let v = null, b = null;
1157
1245
  if (i || c)
1158
1246
  try {
1159
- const x = Date.now(), T = c ? x - Fe(c) : null, v = i ? x - Fe(i) : null;
1160
- N = [T, v];
1247
+ const x = Date.now(), T = c ? x - Le(c) : null, N = i ? x - Le(i) : null;
1248
+ v = [T, N];
1161
1249
  } catch (x) {
1162
1250
  return {
1163
1251
  error: x instanceof Error ? x.message : "Unknown error parsing time ago filter"
@@ -1165,66 +1253,66 @@ async function Rr(r, t) {
1165
1253
  }
1166
1254
  if (l || u)
1167
1255
  try {
1168
- const x = l ? Be(l) : null, T = u ? Be(u) : null;
1256
+ const x = l ? Pe(l) : null, T = u ? Pe(u) : null;
1169
1257
  b = [x, T];
1170
1258
  } catch (x) {
1171
1259
  return {
1172
1260
  error: x instanceof Error ? x.message : "Unknown error parsing size filter"
1173
1261
  };
1174
1262
  }
1175
- const $ = await Nr({
1176
- rootDir: m || null,
1263
+ const $ = await zr({
1264
+ rootDir: g || null,
1177
1265
  globs: w,
1178
- result: M,
1179
- dateModified: N,
1266
+ result: I,
1267
+ dateModified: v,
1180
1268
  totalSize: b
1181
1269
  });
1182
- return $.items.length > Re ? {
1183
- error: `Number of paths (${$.items.length}) exceeds maximum allowed (${Re}). Consider using more specific glob patterns or filters to reduce the result set.`
1270
+ return $.items.length > Be ? {
1271
+ error: `Number of paths (${$.items.length}) exceeds maximum allowed (${Be}). Consider using more specific glob patterns or filters to reduce the result set.`
1184
1272
  } : {
1185
- output: kr($, {
1186
- sort: f,
1187
- fields: d,
1273
+ output: qr($, {
1274
+ sort: d,
1275
+ fields: f,
1188
1276
  totals: !0
1189
1277
  })
1190
1278
  };
1191
- } catch (g) {
1192
- return { error: g instanceof Error ? g.message : "Unknown error" };
1279
+ } catch (m) {
1280
+ return { error: m instanceof Error ? m.message : "Unknown error" };
1193
1281
  }
1194
1282
  }
1195
- function Fr(r, t) {
1196
- r(
1283
+ function jr(t, r) {
1284
+ t(
1197
1285
  "fs-list",
1198
1286
  {
1199
1287
  title: "List Files and Directories",
1200
1288
  description: "List files and directories with advanced filtering, sorting and formatting options. Use this to analyze filesystem structure",
1201
- inputSchema: ct.shape
1289
+ inputSchema: mt.shape
1202
1290
  },
1203
1291
  async (s) => {
1204
- const o = await Rr(s, t);
1292
+ const o = await Jr(s, r);
1205
1293
  return o.error ? `Method: fs-list(${JSON.stringify(s)})
1206
1294
  ❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
1207
1295
  ${o.output || JSON.stringify(o, null, 2)}`;
1208
1296
  }
1209
1297
  );
1210
1298
  }
1211
- const ce = /* @__PURE__ */ new Map();
1212
- function Z(r) {
1213
- return ce.has(r) || ce.set(r, {
1299
+ const ue = /* @__PURE__ */ new Map();
1300
+ function X(t) {
1301
+ return ue.has(t) || ue.set(t, {
1214
1302
  fsSnapshotQueries: /* @__PURE__ */ new Map(),
1215
1303
  fsSnapshots: /* @__PURE__ */ new Map()
1216
- }), ce.get(r);
1304
+ }), ue.get(t);
1217
1305
  }
1218
- function Le(r) {
1219
- const t = r.match(
1306
+ function Ae(t) {
1307
+ const r = t.match(
1220
1308
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1221
1309
  );
1222
- if (!t)
1310
+ if (!r)
1223
1311
  throw new Error(
1224
- `Invalid time ago format: "${r}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1312
+ `Invalid time ago format: "${t}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1225
1313
  );
1226
- const s = parseFloat(t[1]);
1227
- let o = t[2];
1314
+ const s = parseFloat(r[1]);
1315
+ let o = r[2];
1228
1316
  switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
1229
1317
  case "s":
1230
1318
  return s * 1e3;
@@ -1246,13 +1334,13 @@ function Le(r) {
1246
1334
  );
1247
1335
  }
1248
1336
  }
1249
- function Pe(r) {
1250
- const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1251
- if (!t)
1337
+ function ze(t) {
1338
+ const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1339
+ if (!r)
1252
1340
  throw new Error(
1253
- `Invalid size format: "${r}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1341
+ `Invalid size format: "${t}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1254
1342
  );
1255
- const s = parseFloat(t[1]), o = t[2].toUpperCase();
1343
+ const s = parseFloat(r[1]), o = r[2].toUpperCase();
1256
1344
  switch (o) {
1257
1345
  case "B":
1258
1346
  return s;
@@ -1270,7 +1358,7 @@ function Pe(r) {
1270
1358
  );
1271
1359
  }
1272
1360
  }
1273
- const be = p.object({
1361
+ const Se = p.object({
1274
1362
  name: p.string().describe(
1275
1363
  "Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
1276
1364
  ),
@@ -1298,26 +1386,26 @@ const be = p.object({
1298
1386
  maxTotalSize: p.string().optional().describe(
1299
1387
  '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'
1300
1388
  )
1301
- }), Ae = new Map(
1389
+ }), Ue = new Map(
1302
1390
  [
1303
1391
  "name",
1304
1392
  "type",
1305
1393
  "countMatched",
1306
1394
  "size",
1307
1395
  "dateModified"
1308
- ].map((r, t) => [r, t])
1396
+ ].map((t, r) => [t, r])
1309
1397
  );
1310
- function Br(r, t) {
1311
- const s = Ae.get(r) ?? 1 / 0, o = Ae.get(t) ?? 1 / 0;
1398
+ function Kr(t, r) {
1399
+ const s = Ue.get(t) ?? 1 / 0, o = Ue.get(r) ?? 1 / 0;
1312
1400
  return s > o ? 1 : s < o ? -1 : 0;
1313
1401
  }
1314
- async function ut(r, t, s) {
1402
+ async function gt(t, r, s) {
1315
1403
  let o;
1316
1404
  try {
1317
- o = be.parse(r);
1405
+ o = Se.parse(t);
1318
1406
  } catch (h) {
1319
1407
  return {
1320
- error: B(h)
1408
+ error: F(h)
1321
1409
  };
1322
1410
  }
1323
1411
  const {
@@ -1333,30 +1421,30 @@ async function ut(r, t, s) {
1333
1421
  return {
1334
1422
  error: "Session ID is required"
1335
1423
  };
1336
- const d = Z(s.sessionId), f = H(
1337
- F.resolve(t.workingDir || "", o.rootDir || "")
1424
+ const f = X(s.sessionId), d = H(
1425
+ R.resolve(r.workingDir || "", o.rootDir || "")
1338
1426
  );
1339
1427
  try {
1340
1428
  try {
1341
- await W.promises.access(f, W.constants.F_OK);
1429
+ await W.promises.access(d, W.constants.F_OK);
1342
1430
  } catch (S) {
1343
1431
  if (S.code === "ENOENT")
1344
1432
  return {
1345
- error: `Directory does not exist: "${f}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
1433
+ 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.`
1346
1434
  };
1347
1435
  throw S;
1348
1436
  }
1349
1437
  const h = o.extraFields ? o.extraFields.map((S) => S === "lastModified" ? "dateModified" : S) : [];
1350
- h.includes("name") || h.push("name"), h.sort(Br);
1351
- const m = n && n.length > 0 ? n.map((S) => ({
1438
+ h.includes("name") || h.push("name"), h.sort(Kr);
1439
+ const g = n && n.length > 0 ? n.map((S) => ({
1352
1440
  value: S,
1353
1441
  valueType: "pattern",
1354
1442
  exclude: !1
1355
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], g = t.globsExclude || [], y = [...m, ...g];
1356
- let w = null, M = null;
1443
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], m = r.globsExclude || [], y = [...g, ...m];
1444
+ let w = null, I = null;
1357
1445
  if (i || c)
1358
1446
  try {
1359
- const S = Date.now(), x = c ? S - Le(c) : null, T = i ? S - Le(i) : null;
1447
+ const S = Date.now(), x = c ? S - Ae(c) : null, T = i ? S - Ae(i) : null;
1360
1448
  w = [x, T];
1361
1449
  } catch (S) {
1362
1450
  return {
@@ -1365,24 +1453,24 @@ async function ut(r, t, s) {
1365
1453
  }
1366
1454
  if (l || u)
1367
1455
  try {
1368
- const S = l ? Pe(l) : null, x = u ? Pe(u) : null;
1369
- M = [S, x];
1456
+ const S = l ? ze(l) : null, x = u ? ze(u) : null;
1457
+ I = [S, x];
1370
1458
  } catch (S) {
1371
1459
  return {
1372
1460
  error: S instanceof Error ? S.message : "Unknown error parsing size filter"
1373
1461
  };
1374
1462
  }
1375
- const N = a ? a.includes("file") : !0, b = a ? a.includes("dir") : !0, $ = {
1463
+ const v = a ? a.includes("file") : !0, b = a ? a.includes("dir") : !0, $ = {
1376
1464
  name: e,
1377
- rootDir: f,
1465
+ rootDir: d,
1378
1466
  globs: y,
1379
- matchFiles: N,
1467
+ matchFiles: v,
1380
1468
  matchDirs: b,
1381
1469
  dateModified: w,
1382
- totalSize: M,
1470
+ totalSize: I,
1383
1471
  fields: h
1384
1472
  };
1385
- return d.fsSnapshotQueries.set(e, $), {
1473
+ return f.fsSnapshotQueries.set(e, $), {
1386
1474
  snapshotQuery: $
1387
1475
  };
1388
1476
  } catch (h) {
@@ -1391,30 +1479,30 @@ async function ut(r, t, s) {
1391
1479
  };
1392
1480
  }
1393
1481
  }
1394
- function Lr(r, t) {
1395
- r(
1482
+ function Wr(t, r) {
1483
+ t(
1396
1484
  "fs-snapshot-query-create",
1397
1485
  {
1398
1486
  title: "Create Filesystem Snapshot Query",
1399
1487
  description: "Create a filesystem snapshot query. Prefer fs-snapshot-browse if you need to immediately create a query, snapshot and browse it",
1400
- inputSchema: be.shape
1488
+ inputSchema: Se.shape
1401
1489
  },
1402
1490
  async (s, o) => {
1403
- const e = await ut(s, t, o);
1491
+ const e = await gt(s, r, o);
1404
1492
  return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1405
1493
  ❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1406
1494
  ✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
1407
1495
  }
1408
1496
  );
1409
1497
  }
1410
- function ae(r) {
1411
- const { idToNode: t, idToChildIds: s } = r, o = t.get(null);
1498
+ function le(t) {
1499
+ const { idToNode: r, idToChildIds: s } = t, o = r.get(null);
1412
1500
  if (o == null)
1413
1501
  throw new Error(
1414
1502
  "Impossible behavior: root node (id: null) not found in idToNode"
1415
1503
  );
1416
1504
  const e = /* @__PURE__ */ new Map();
1417
- return t.forEach((n, a) => {
1505
+ return r.forEach((n, a) => {
1418
1506
  if (n != null) {
1419
1507
  if (e.has(n)) {
1420
1508
  const i = e.get(n);
@@ -1426,18 +1514,18 @@ function ae(r) {
1426
1514
  }
1427
1515
  }), {
1428
1516
  root: o,
1429
- getNode: (n) => t.get(n) ?? null,
1517
+ getNode: (n) => r.get(n) ?? null,
1430
1518
  getId: (n) => e.get(n) ?? null,
1431
1519
  getChilds: (n) => {
1432
1520
  let a = e.get(n);
1433
1521
  if (a == null)
1434
- if (n === t.get(null))
1522
+ if (n === r.get(null))
1435
1523
  a = null;
1436
1524
  else
1437
1525
  throw new Error("Impossible behavior: node not found in idToNode");
1438
1526
  const i = s.get(a);
1439
1527
  return i == null ? null : i.map((c) => {
1440
- const l = t.get(c);
1528
+ const l = r.get(c);
1441
1529
  if (l == null)
1442
1530
  throw new Error(
1443
1531
  `Child node with id '${c}' not found in idToNode`
@@ -1447,28 +1535,28 @@ function ae(r) {
1447
1535
  }
1448
1536
  };
1449
1537
  }
1450
- function dt(r, t, s) {
1538
+ function wt(t, r, s) {
1451
1539
  let o = null;
1452
- for (let e = 0, n = t.length; e < n; e++) {
1453
- const a = t[e], i = r(a), c = i == null ? null : dt(r, i, s), l = s(a, c);
1540
+ for (let e = 0, n = r.length; e < n; e++) {
1541
+ const a = r[e], i = t(a), c = i == null ? null : wt(t, i, s), l = s(a, c);
1454
1542
  l != null && (o == null && (o = []), o.push(l));
1455
1543
  }
1456
1544
  return o;
1457
1545
  }
1458
- function ft(r) {
1459
- const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = dt(
1546
+ function yt(t) {
1547
+ const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = wt(
1460
1548
  s,
1461
1549
  o,
1462
- (u, d) => {
1463
- const f = e(u, d);
1464
- if (u != null && f != null) {
1465
- const h = t(u);
1466
- n.set(h, f), a.set(f, h);
1550
+ (u, f) => {
1551
+ const d = e(u, f);
1552
+ if (u != null && d != null) {
1553
+ const h = r(u);
1554
+ n.set(h, d), a.set(d, h);
1467
1555
  }
1468
- return f != null && d != null && i.set(
1469
- a.get(f),
1470
- d.map((h) => a.get(h))
1471
- ), f;
1556
+ return d != null && f != null && i.set(
1557
+ a.get(d),
1558
+ f.map((h) => a.get(h))
1559
+ ), d;
1472
1560
  }
1473
1561
  ), l = e(null, c);
1474
1562
  if (l == null)
@@ -1481,79 +1569,79 @@ function ft(r) {
1481
1569
  idToChildIds: i
1482
1570
  };
1483
1571
  }
1484
- function pe(r) {
1485
- return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
1572
+ function me(t) {
1573
+ return t = t != null ? H(t).replace(/\/$/, "") : null, !t || t === "." ? null : t;
1486
1574
  }
1487
- async function Pr(r) {
1488
- const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = F.resolve(r.rootDir || "."), n = {
1575
+ async function Hr(t) {
1576
+ const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = R.resolve(t.rootDir || "."), n = {
1489
1577
  path: ".",
1490
- name: F.basename(o),
1578
+ name: R.basename(o),
1491
1579
  type: "dir",
1492
1580
  isMatched: !1,
1493
1581
  dateModified: null,
1494
1582
  size: 0
1495
1583
  };
1496
- t.set(null, n);
1497
- const a = await at({
1584
+ r.set(null, n);
1585
+ const a = await ht({
1498
1586
  rootDir: o,
1499
- globs: r.globs
1587
+ globs: t.globs
1500
1588
  });
1501
- return await it({
1589
+ return await ft({
1502
1590
  paths: [o],
1503
1591
  walkLinks: !0,
1504
- matchPath: lt({
1592
+ matchPath: pt({
1505
1593
  globs: a,
1506
1594
  rootDir: o,
1507
1595
  noCase: !0
1508
1596
  }),
1509
1597
  handlePath: async ({ path: i, stat: c, itemStat: l }) => {
1510
- const u = F.relative(o, i), d = c.isDirectory(), f = c.isFile();
1511
- if (!d && !f)
1598
+ const u = R.relative(o, i), f = c.isDirectory(), d = c.isFile();
1599
+ if (!f && !d)
1512
1600
  return !0;
1513
- const h = pe(u || "."), m = d ? "dir" : "file", g = d ? null : c.mtimeMs, y = c.size;
1601
+ const h = me(u || "."), g = f ? "dir" : "file", m = f ? null : c.mtimeMs, y = c.size;
1514
1602
  let w = !0;
1515
- if (f && !r.matchFiles && (w = !1), d && !r.matchDirs && (w = !1), w && f && r.dateModified && g != null) {
1516
- const [$, S] = r.dateModified;
1517
- ($ != null && g < $ || S != null && g > S) && (w = !1);
1603
+ if (d && !t.matchFiles && (w = !1), f && !t.matchDirs && (w = !1), w && d && t.dateModified && m != null) {
1604
+ const [$, S] = t.dateModified;
1605
+ ($ != null && m < $ || S != null && m > S) && (w = !1);
1518
1606
  }
1519
- if (w && f && r.totalSize && y != null) {
1520
- const [$, S] = r.totalSize;
1607
+ if (w && d && t.totalSize && y != null) {
1608
+ const [$, S] = t.totalSize;
1521
1609
  ($ != null && y < $ || S != null && y > S) && (w = !1);
1522
1610
  }
1523
- if (d && !w) {
1611
+ if (f && !w) {
1524
1612
  if (!(l.countFiles && l.countFiles > 0)) return !1;
1525
1613
  } else if (!w)
1526
1614
  return !1;
1527
- const M = {
1615
+ const I = {
1528
1616
  path: h ?? ".",
1529
- name: F.basename(i),
1530
- type: m,
1531
- dateModified: g,
1617
+ name: R.basename(i),
1618
+ type: g,
1619
+ dateModified: m,
1532
1620
  size: y,
1533
1621
  isMatched: w
1534
1622
  };
1535
1623
  if (h == null)
1536
- return n.dateModified = g, n.size = y, n.isMatched = w, !0;
1537
- t.set(h, M);
1538
- const N = pe(H(F.dirname(h)));
1539
- let b = s.get(N);
1540
- return b || (b = [], s.set(N, b)), b.push(h), !0;
1624
+ return n.dateModified = m, n.size = y, n.isMatched = w, !0;
1625
+ r.set(h, I);
1626
+ const v = me(H(R.dirname(h)));
1627
+ let b = s.get(v);
1628
+ return b || (b = [], s.set(v, b)), b.push(h), !0;
1541
1629
  }
1542
1630
  }), {
1543
- idToNode: t,
1631
+ idToNode: r,
1544
1632
  idToChildIds: s
1545
1633
  };
1546
1634
  }
1547
- const Ar = [
1548
- { name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
1549
- { name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
1550
- { name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
1551
- { name: "[-]", match: (r) => r === 45, min: 2, max: 16 },
1552
- { name: "[=]", match: (r) => r === 61, min: 2, max: 16 },
1553
- { name: "[_]", match: (r) => r === 95, min: 2, max: 16 },
1554
- { name: "[*]", match: (r) => r === 42, min: 2, max: 16 },
1555
- { name: "[.]", match: (r) => r === 46, min: 2, max: 16 },
1556
- { name: "[0-9]", match: (r) => r >= 48 && r <= 57, min: 2, max: 3 }
1635
+ const Qr = [
1636
+ { name: "[ ]", match: (t) => t === 32, min: 2, max: 81 },
1637
+ { name: "[\\t]", match: (t) => t === 9, min: 2, max: 20 },
1638
+ { name: "[\\n]", match: (t) => t === 10, min: 2, max: 14 },
1639
+ { name: "[-]", match: (t) => t === 45, min: 2, max: 16 },
1640
+ { name: "[=]", match: (t) => t === 61, min: 2, max: 16 },
1641
+ { name: "[_]", match: (t) => t === 95, min: 2, max: 16 },
1642
+ { name: "[*]", match: (t) => t === 42, min: 2, max: 16 },
1643
+ { name: "[.]", match: (t) => t === 46, min: 2, max: 16 },
1644
+ { name: "[0-9]", match: (t) => t >= 48 && t <= 57, min: 2, max: 3 }
1557
1645
  // { name: '[a-z]', match: c => c >= 97 && c <= 122, min: 2, max: 2 },
1558
1646
  // { name: '[A-Z]', match: c => c >= 65 && c <= 90, min: 2, max: 2 },
1559
1647
  // Other ASCII symbols
@@ -1567,21 +1655,21 @@ const Ar = [
1567
1655
  // max: 2,
1568
1656
  // },
1569
1657
  ];
1570
- function ze(r, t = Ar) {
1571
- const s = r.length;
1658
+ function qe(t, r = Qr) {
1659
+ const s = t.length;
1572
1660
  if (s === 0) return 0;
1573
- const o = t.length;
1661
+ const o = r.length;
1574
1662
  if (o === 0)
1575
1663
  return s;
1576
1664
  let e = 0, n = 0;
1577
1665
  for (; n < s; ) {
1578
- const a = r.charCodeAt(n);
1666
+ const a = t.charCodeAt(n);
1579
1667
  let i = !1;
1580
1668
  for (let c = 0; c < o; c++) {
1581
- const l = t[c];
1669
+ const l = r[c];
1582
1670
  if (l.match(a)) {
1583
1671
  let u = 1;
1584
- for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
1672
+ for (; ++n < s && l.match(t.charCodeAt(n)) && u < l.max; )
1585
1673
  u++;
1586
1674
  if (u >= l.min) {
1587
1675
  e++, i = !0;
@@ -1593,27 +1681,27 @@ function ze(r, t = Ar) {
1593
1681
  }
1594
1682
  return e;
1595
1683
  }
1596
- function ht(r) {
1597
- let t = 0;
1598
- return t += ze(r.textOpen) + 1, r.textClose != null && (t += ze(r.textClose) + 1), r.indent && (t += 1), t;
1684
+ function bt(t) {
1685
+ let r = 0;
1686
+ return r += qe(t.textOpen) + 1, t.textClose != null && (r += qe(t.textClose) + 1), t.indent && (r += 1), r;
1599
1687
  }
1600
- const Ue = ["B", "KB", "MB", "GB", "TB"], qe = 1024;
1601
- function zr(r) {
1602
- if (r == null) return "-";
1603
- let t = r ?? 0, s = 0;
1604
- for (; t >= qe && s < Ue.length - 1; )
1605
- t /= qe, s++;
1606
- return `${s === 0 ? t.toString() : t.toFixed(2)}${Ue[s]}`;
1688
+ const _e = ["B", "KB", "MB", "GB", "TB"], Ge = 1024;
1689
+ function Yr(t) {
1690
+ if (t == null) return "-";
1691
+ let r = t ?? 0, s = 0;
1692
+ for (; r >= Ge && s < _e.length - 1; )
1693
+ r /= Ge, s++;
1694
+ return `${s === 0 ? r.toString() : r.toFixed(2)}${_e[s]}`;
1607
1695
  }
1608
- function Ur(r) {
1609
- const s = Date.now() - r;
1696
+ function Vr(t) {
1697
+ const s = Date.now() - t;
1610
1698
  if (s < 0) return "0s";
1611
1699
  const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), c = Math.floor(a / 30), l = Math.floor(a / 365);
1612
1700
  return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1613
1701
  }
1614
- function qr(r) {
1702
+ function Zr(t) {
1615
1703
  return function(s, o) {
1616
- const e = r.get(s), n = r.get(o);
1704
+ const e = t.get(s), n = t.get(o);
1617
1705
  if (e.type !== n.type)
1618
1706
  return e.type === "file" ? -1 : 1;
1619
1707
  if (e.type === "file")
@@ -1624,26 +1712,26 @@ function qr(r) {
1624
1712
  }
1625
1713
  };
1626
1714
  }
1627
- function _r(r) {
1628
- const t = r.fields ?? [];
1715
+ function Xr(t) {
1716
+ const r = t.fields ?? [];
1629
1717
  return function(o, e) {
1630
1718
  let n = "", a, i = 0;
1631
1719
  const c = e ? e.length : 0;
1632
- let l = 1, u, d = 0, f = 0, h = 0, m = 0, g = null, y, w, M;
1720
+ let l = 1, u, f = 0, d = 0, h = 0, g = 0, m = null, y, w, I;
1633
1721
  if (e)
1634
1722
  for (let b = 0; b < e.length; b++) {
1635
1723
  const $ = e[b];
1636
- i += $.countMatched, l += $.countTotal, d += $.tokens, f += $.tokensTotal, h += $.size, m += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1724
+ i += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, h += $.size, g += $.countFiles, $.dateModified != null && (m == null || $.dateModified > m) && (m = $.dateModified);
1637
1725
  }
1638
- o ? (y = o.type, w = o.name, M = o.path, a = o.isMatched, a && (i += 1), o.type === "file" ? (h = o.size || 0, m = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (y = "dir", w = "<root>", M = ".", a = !0);
1639
- for (let b = 0, $ = t.length; b < $; b++) {
1640
- const S = t[b];
1726
+ o ? (y = o.type, w = o.name, I = o.path, a = o.isMatched, a && (i += 1), o.type === "file" ? (h = o.size || 0, g = 1, m = o.dateModified || null) : o.dateModified != null && (m == null || o.dateModified > m) && (m = o.dateModified)) : (y = "dir", w = "<root>", I = ".", a = !0);
1727
+ for (let b = 0, $ = r.length; b < $; b++) {
1728
+ const S = r[b];
1641
1729
  switch (b > 0 && (n += " "), S) {
1642
1730
  case "dateModified":
1643
- n += g ? Ur(g) : "-";
1731
+ n += m ? Vr(m) : "-";
1644
1732
  break;
1645
1733
  case "size":
1646
- n += zr(h);
1734
+ n += Yr(h);
1647
1735
  break;
1648
1736
  case "type":
1649
1737
  n += y;
@@ -1656,31 +1744,31 @@ function _r(r) {
1656
1744
  break;
1657
1745
  }
1658
1746
  }
1659
- const N = {
1747
+ const v = {
1660
1748
  indent: !0,
1661
1749
  textOpen: n,
1662
1750
  textClose: null
1663
1751
  };
1664
- return u = ht(N), f += u, {
1752
+ return u = bt(v), d += u, {
1665
1753
  type: y,
1666
1754
  name: w,
1667
- path: M,
1755
+ path: I,
1668
1756
  isMatched: a,
1669
1757
  countMatched: i,
1670
1758
  countChilds: c,
1671
1759
  countTotal: l,
1672
1760
  tokens: u,
1673
- tokensChilds: d,
1674
- tokensTotal: f,
1675
- text: N,
1761
+ tokensChilds: f,
1762
+ tokensTotal: d,
1763
+ text: v,
1676
1764
  size: h,
1677
- countFiles: m,
1678
- dateModified: g
1765
+ countFiles: g,
1766
+ dateModified: m
1679
1767
  };
1680
1768
  };
1681
1769
  }
1682
- async function Gr(r) {
1683
- const t = await Pr(r), s = ae(t), o = s.getChilds(s.root), e = ft({
1770
+ async function es(t) {
1771
+ const r = await Hr(t), s = le(r), o = s.getChilds(s.root), e = yt({
1684
1772
  getId: (a) => {
1685
1773
  const i = s.getId(a);
1686
1774
  if (i == null)
@@ -1690,29 +1778,29 @@ async function Gr(r) {
1690
1778
  return i;
1691
1779
  },
1692
1780
  getChilds: (a) => s.getChilds(a),
1693
- createSnapshotNode: _r(r),
1781
+ createSnapshotNode: Xr(t),
1694
1782
  rootNodes: o ?? []
1695
- }), n = qr(e.idToNode);
1783
+ }), n = Zr(e.idToNode);
1696
1784
  return e.idToChildIds.forEach((a) => {
1697
1785
  a.sort(n);
1698
- }), ae(e);
1786
+ }), le(e);
1699
1787
  }
1700
- const X = p.object({
1788
+ const ee = p.object({
1701
1789
  queryName: p.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
1702
- query: be.optional().describe(
1790
+ query: Se.optional().describe(
1703
1791
  "Filesystem snapshot query creation options JSON to automatically create query"
1704
1792
  ),
1705
1793
  name: p.string().describe(
1706
1794
  "Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
1707
1795
  )
1708
1796
  });
1709
- async function le(r, t, s) {
1797
+ async function ce(t, r, s) {
1710
1798
  let o;
1711
1799
  try {
1712
- o = X.parse(r);
1800
+ o = ee.parse(t);
1713
1801
  } catch (u) {
1714
1802
  return {
1715
- error: B(u)
1803
+ error: F(u)
1716
1804
  };
1717
1805
  }
1718
1806
  const { name: e, queryName: n, query: a } = o;
@@ -1720,7 +1808,7 @@ async function le(r, t, s) {
1720
1808
  return {
1721
1809
  error: "Session ID is required"
1722
1810
  };
1723
- const i = Z(s.sessionId);
1811
+ const i = X(s.sessionId);
1724
1812
  if (n && a)
1725
1813
  return {
1726
1814
  error: "Either queryName or query must be provided, not both"
@@ -1734,9 +1822,9 @@ async function le(r, t, s) {
1734
1822
  };
1735
1823
  c = u;
1736
1824
  } else if (a) {
1737
- const u = await ut(
1825
+ const u = await gt(
1738
1826
  a,
1739
- t,
1827
+ r,
1740
1828
  s
1741
1829
  );
1742
1830
  if (u.error != null)
@@ -1749,13 +1837,13 @@ async function le(r, t, s) {
1749
1837
  error: "Either queryName or query must be provided"
1750
1838
  };
1751
1839
  try {
1752
- const u = await Gr(c), d = {
1840
+ const u = await es(c), f = {
1753
1841
  name: e,
1754
1842
  query: c,
1755
1843
  tree: u
1756
1844
  };
1757
- return i.fsSnapshots.set(e, d), {
1758
- fsSnapshot: d,
1845
+ return i.fsSnapshots.set(e, f), {
1846
+ fsSnapshot: f,
1759
1847
  queryCreated: l
1760
1848
  };
1761
1849
  } catch (u) {
@@ -1764,16 +1852,16 @@ async function le(r, t, s) {
1764
1852
  };
1765
1853
  }
1766
1854
  }
1767
- function Jr(r, t) {
1768
- r(
1855
+ function ts(t, r) {
1856
+ t(
1769
1857
  "fs-snapshot-create",
1770
1858
  {
1771
1859
  title: "Create Filesystem Snapshot",
1772
1860
  description: "Create a filesystem snapshot. Use this to capture filesystem state for later browsing. Prefer fs-snapshot-browse if you need to immediately create and browse a snapshot",
1773
- inputSchema: X.shape
1861
+ inputSchema: ee.shape
1774
1862
  },
1775
1863
  async (s, o) => {
1776
- const e = await le(s, t, o);
1864
+ const e = await ce(s, r, o);
1777
1865
  if (e.error != null)
1778
1866
  return `Method: fs-snapshot-create(${JSON.stringify(s)})
1779
1867
  ❌ Error: ${e.error}`;
@@ -1784,18 +1872,18 @@ function Jr(r, t) {
1784
1872
  }
1785
1873
  );
1786
1874
  }
1787
- class jr {
1875
+ class rs {
1788
1876
  _first = null;
1789
1877
  _last = null;
1790
1878
  _size = 0;
1791
- enqueue(t) {
1792
- const s = { item: t, next: null };
1879
+ enqueue(r) {
1880
+ const s = { item: r, next: null };
1793
1881
  this._last ? this._last.next = s : this._first = s, this._last = s, this._size += 1;
1794
1882
  }
1795
1883
  dequeue() {
1796
1884
  if (!this._first) return null;
1797
- const t = this._first.item;
1798
- return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, t;
1885
+ const r = this._first.item;
1886
+ return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, r;
1799
1887
  }
1800
1888
  peek() {
1801
1889
  return this._first ? this._first.item : null;
@@ -1807,66 +1895,66 @@ class jr {
1807
1895
  return this._size;
1808
1896
  }
1809
1897
  }
1810
- function Kr(r) {
1811
- const t = new jr(), {
1898
+ function ss(t) {
1899
+ const r = new rs(), {
1812
1900
  tree: s,
1813
1901
  limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: a },
1814
1902
  indexRangeGroupStrategy: i
1815
- } = r, c = s.getChilds(s.root);
1816
- c != null && c.length > 0 && t.enqueue({
1903
+ } = t, c = s.getChilds(s.root);
1904
+ c != null && c.length > 0 && r.enqueue({
1817
1905
  reportNode: null,
1818
1906
  node: s.root
1819
1907
  });
1820
- let l = null, u = 0, d = 0;
1821
- for (; !t.isEmpty(); ) {
1822
- const { reportNode: f, node: h } = t.dequeue(), m = s.getChilds(h);
1823
- if (m == null || h.countChilds === 0 || m.length !== h.countChilds)
1908
+ let l = null, u = 0, f = 0;
1909
+ for (; !r.isEmpty(); ) {
1910
+ const { reportNode: d, node: h } = r.dequeue(), g = s.getChilds(h);
1911
+ if (g == null || h.countChilds === 0 || g.length !== h.countChilds)
1824
1912
  throw new Error(
1825
1913
  "Impossible behavior: nodeChilds is null or length mismatch"
1826
1914
  );
1827
- let g = t.size();
1828
- for (let w = 0; w < m.length; w++)
1829
- m[w].countChilds > 0 && (g += 1);
1830
- const y = g * i.tokens;
1831
- if (o != null && u + h.countChilds + g > o || e != null && d + h.tokensChilds + y > e) {
1915
+ let m = r.size();
1916
+ for (let w = 0; w < g.length; w++)
1917
+ g[w].countChilds > 0 && (m += 1);
1918
+ const y = m * i.tokens;
1919
+ if (o != null && u + h.countChilds + m > o || e != null && f + h.tokensChilds + y > e) {
1832
1920
  const w = [];
1833
- let M = null, N = 0;
1834
- for (let $ = 0, S = m.length; $ < S; $++) {
1835
- const x = m[$], T = N * i.tokens;
1836
- M != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
1837
- !(o != null && u + 1 > o || e != null && d + i.tokens > e) && (n != null && M.countGrouped + 1 + N > n || a != null && M.tokensGrouped + x.tokens + T > a) && (w.push(M), u += 1, d += i.tokens, M = null, N = 0), M = i.add(M, x, $), x.countChilds > 0 && (N += 1);
1921
+ let I = null, v = 0;
1922
+ for (let $ = 0, S = g.length; $ < S; $++) {
1923
+ const x = g[$], T = v * i.tokens;
1924
+ I != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
1925
+ !(o != null && u + 1 > o || e != null && f + i.tokens > e) && (n != null && I.countGrouped + 1 + v > n || a != null && I.tokensGrouped + x.tokens + T > a) && (w.push(I), u += 1, f += i.tokens, I = null, v = 0), I = i.add(I, x, $), x.countChilds > 0 && (v += 1);
1838
1926
  }
1839
- M != null && (w.push(M), u += 1, d += i.tokens);
1927
+ I != null && (w.push(I), u += 1, f += i.tokens);
1840
1928
  const b = w.map(($) => ({
1841
1929
  text: i.getReportText($)
1842
1930
  }));
1843
- if (f != null) {
1844
- if (f.childs != null)
1931
+ if (d != null) {
1932
+ if (d.childs != null)
1845
1933
  throw new Error("Impossible behavior: reportNode.childs != null");
1846
- f.childs = b;
1934
+ d.childs = b;
1847
1935
  } else {
1848
1936
  if (l != null)
1849
1937
  throw new Error("Impossible behavior: reportRootNodes != null");
1850
1938
  l = b;
1851
1939
  }
1852
1940
  } else {
1853
- u += h.countChilds, d += h.tokensChilds;
1941
+ u += h.countChilds, f += h.tokensChilds;
1854
1942
  const w = [];
1855
- for (let M = 0; M < m.length; M++) {
1856
- const N = m[M], b = {
1857
- text: N.text
1943
+ for (let I = 0; I < g.length; I++) {
1944
+ const v = g[I], b = {
1945
+ text: v.text
1858
1946
  };
1859
1947
  w.push(b);
1860
- const $ = s.getChilds(N);
1861
- $ != null && $.length > 0 && t.enqueue({
1948
+ const $ = s.getChilds(v);
1949
+ $ != null && $.length > 0 && r.enqueue({
1862
1950
  reportNode: b,
1863
- node: N
1951
+ node: v
1864
1952
  });
1865
1953
  }
1866
- if (f != null) {
1867
- if (f.childs != null)
1954
+ if (d != null) {
1955
+ if (d.childs != null)
1868
1956
  throw new Error("Impossible behavior: reportNode.childs != null");
1869
- f.childs = w;
1957
+ d.childs = w;
1870
1958
  } else {
1871
1959
  if (l != null)
1872
1960
  throw new Error("Impossible behavior: reportRootNodes != null");
@@ -1876,59 +1964,59 @@ function Kr(r) {
1876
1964
  }
1877
1965
  return l ?? [];
1878
1966
  }
1879
- function pt(r) {
1967
+ function St(t) {
1880
1968
  const {
1881
- tree: t,
1969
+ tree: r,
1882
1970
  request: { parentNodeId: s, childsIndexRange: o, limits: e },
1883
1971
  indexRangeGroupStrategy: n,
1884
1972
  ...a
1885
- } = r;
1973
+ } = t;
1886
1974
  let i;
1887
1975
  if (s != null) {
1888
- const f = t.getNode(s);
1889
- if (f == null)
1976
+ const d = r.getNode(s);
1977
+ if (d == null)
1890
1978
  throw new Error(`Parent node "${s}" not found`);
1891
- i = f;
1979
+ i = d;
1892
1980
  } else
1893
- i = t.root;
1894
- let c, l = t.getChilds(i) ?? [];
1981
+ i = r.root;
1982
+ let c, l = r.getChilds(i) ?? [];
1895
1983
  if (o != null) {
1896
- const [f, h] = o;
1897
- if (f < 0 || h <= f || h >= l.length)
1984
+ const [d, h] = o;
1985
+ if (d < 0 || h <= d || h >= l.length)
1898
1986
  throw new Error(
1899
- `Invalid index range: ${f}-${h} for root nodes length ${l.length}`
1987
+ `Invalid index range: ${d}-${h} for root nodes length ${l.length}`
1900
1988
  );
1901
- const m = [];
1902
- let g = null;
1903
- for (let y = f; y <= h; y++) {
1989
+ const g = [];
1990
+ let m = null;
1991
+ for (let y = d; y <= h; y++) {
1904
1992
  const w = l[y];
1905
- m.push(w), g = n.add(g, w, y);
1993
+ g.push(w), m = n.add(m, w, y);
1906
1994
  }
1907
- l = m, c = {
1995
+ l = g, c = {
1908
1996
  ...i,
1909
- text: n.getReportText(g),
1910
- countChilds: g.countGrouped,
1911
- tokensChilds: g.tokensGrouped
1997
+ text: n.getReportText(m),
1998
+ countChilds: m.countGrouped,
1999
+ tokensChilds: m.tokensGrouped
1912
2000
  };
1913
2001
  } else
1914
2002
  c = i;
1915
2003
  const u = {
1916
2004
  countChilds: 1,
1917
2005
  tokensChilds: c.tokens
1918
- }, d = {
1919
- ...t,
2006
+ }, f = {
2007
+ ...r,
1920
2008
  root: u,
1921
- getChilds: (f) => f === u ? [c] : f === c ? l : t.getChilds(f)
2009
+ getChilds: (d) => d === u ? [c] : d === c ? l : r.getChilds(d)
1922
2010
  };
1923
- return Kr({
1924
- tree: d,
2011
+ return ss({
2012
+ tree: f,
1925
2013
  limits: e,
1926
2014
  indexRangeGroupStrategy: n,
1927
2015
  ...a
1928
2016
  });
1929
2017
  }
1930
- function mt(r, t) {
1931
- if (r == null || r.length === 0)
2018
+ function xt(t, r) {
2019
+ if (t == null || t.length === 0)
1932
2020
  return "No results found";
1933
2021
  let s = "";
1934
2022
  function o(e, n) {
@@ -1942,26 +2030,26 @@ function mt(r, t) {
1942
2030
  `);
1943
2031
  }
1944
2032
  }
1945
- return o(r, ""), s;
2033
+ return o(t, ""), s;
1946
2034
  }
1947
- class Wr {
2035
+ class os {
1948
2036
  tokens = 16;
1949
2037
  // +1 indent, +1 for line break
1950
- getReportText = (t) => ({
2038
+ getReportText = (r) => ({
1951
2039
  indent: !0,
1952
- textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
2040
+ textOpen: `[${r.indexRange[0]}-${r.indexRange[1]}] see more ${r.countMatched} matched ${r.tokensGrouped} tokens`,
1953
2041
  textClose: null
1954
2042
  });
1955
- add = (t, s, o) => t == null ? {
2043
+ add = (r, s, o) => r == null ? {
1956
2044
  indexRange: [o, o],
1957
2045
  countGrouped: 1,
1958
2046
  countMatched: s.countMatched,
1959
2047
  tokensGrouped: s.tokens
1960
- } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
2048
+ } : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
1961
2049
  }
1962
- const gt = p.object({
2050
+ const $t = p.object({
1963
2051
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
1964
- snapshot: X.optional().describe(
2052
+ snapshot: ee.optional().describe(
1965
2053
  "Filesystem snapshot creation options JSON to automatically create snapshot"
1966
2054
  ),
1967
2055
  parentPath: p.string().optional().describe(
@@ -1981,13 +2069,13 @@ const gt = p.object({
1981
2069
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
1982
2070
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
1983
2071
  });
1984
- async function Hr(r, t, s) {
2072
+ async function ns(t, r, s) {
1985
2073
  let o;
1986
2074
  try {
1987
- o = gt.parse(r);
1988
- } catch (g) {
2075
+ o = $t.parse(t);
2076
+ } catch (m) {
1989
2077
  return {
1990
- error: B(g)
2078
+ error: F(m)
1991
2079
  };
1992
2080
  }
1993
2081
  const {
@@ -2003,37 +2091,37 @@ async function Hr(r, t, s) {
2003
2091
  return {
2004
2092
  error: "Session ID is required"
2005
2093
  };
2006
- const d = Z(s.sessionId);
2094
+ const f = X(s.sessionId);
2007
2095
  if (e && n)
2008
2096
  return {
2009
2097
  error: "Either snapshotName or snapshot must be provided, not both"
2010
2098
  };
2011
- let f, h = !1, m = !1;
2099
+ let d, h = !1, g = !1;
2012
2100
  if (e) {
2013
- if (f = d.fsSnapshots.get(e), f == null)
2101
+ if (d = f.fsSnapshots.get(e), d == null)
2014
2102
  return {
2015
2103
  error: `Filesystem snapshot "${e}" not found`
2016
2104
  };
2017
2105
  } else if (n) {
2018
- const g = await le(
2106
+ const m = await ce(
2019
2107
  n,
2020
- t,
2108
+ r,
2021
2109
  s
2022
2110
  );
2023
- if (g.error != null)
2111
+ if (m.error != null)
2024
2112
  return {
2025
- error: g.error
2113
+ error: m.error
2026
2114
  };
2027
- f = g.fsSnapshot, h = g.queryCreated, m = !0;
2115
+ d = m.fsSnapshot, h = m.queryCreated, g = !0;
2028
2116
  } else
2029
2117
  return {
2030
2118
  error: "Either snapshotName or snapshot must be provided"
2031
2119
  };
2032
2120
  try {
2033
- const g = pe(o.parentPath), y = pt({
2034
- tree: f.tree,
2121
+ const m = me(o.parentPath), y = St({
2122
+ tree: d.tree,
2035
2123
  request: {
2036
- parentNodeId: g,
2124
+ parentNodeId: m,
2037
2125
  childsIndexRange: a,
2038
2126
  limits: {
2039
2127
  maxCountTotal: i,
@@ -2042,32 +2130,32 @@ async function Hr(r, t, s) {
2042
2130
  maxTokensGroup: u
2043
2131
  }
2044
2132
  },
2045
- indexRangeGroupStrategy: new Wr()
2046
- }), w = mt(y);
2133
+ indexRangeGroupStrategy: new os()
2134
+ }), w = xt(y);
2047
2135
  return {
2048
- fsSnapshot: f,
2136
+ fsSnapshot: d,
2049
2137
  queryCreated: h,
2050
- snapshotCreated: m,
2051
- parentPath: g,
2138
+ snapshotCreated: g,
2139
+ parentPath: m,
2052
2140
  childsIndexRange: a,
2053
2141
  report: w
2054
2142
  };
2055
- } catch (g) {
2143
+ } catch (m) {
2056
2144
  return {
2057
- error: `Failed to browse filesystem snapshot: ${g instanceof Error ? g.message : "Unknown error"}`
2145
+ error: `Failed to browse filesystem snapshot: ${m instanceof Error ? m.message : "Unknown error"}`
2058
2146
  };
2059
2147
  }
2060
2148
  }
2061
- function Qr(r, t) {
2062
- r(
2149
+ function is(t, r) {
2150
+ t(
2063
2151
  "fs-snapshot-browse",
2064
2152
  {
2065
2153
  title: "Browse Filesystem Snapshot",
2066
2154
  description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
2067
- inputSchema: gt.shape
2155
+ inputSchema: $t.shape
2068
2156
  },
2069
2157
  async (s, o) => {
2070
- const e = await Hr(s, t, o);
2158
+ const e = await ns(s, r, o);
2071
2159
  if (e.error != null)
2072
2160
  return `Method: fs-snapshot-browse(${JSON.stringify(s)})
2073
2161
  ❌ Error: ${e.error}`;
@@ -2089,215 +2177,215 @@ ${e.report}`, n;
2089
2177
  }
2090
2178
  );
2091
2179
  }
2092
- function wt(r) {
2093
- const t = [], s = r.tree, o = r.query.rootDir ?? ".";
2180
+ function It(t) {
2181
+ const r = [], s = t.tree, o = t.query.rootDir ?? ".";
2094
2182
  function e(n) {
2095
- n.type === "file" && n.isMatched && t.push(o + "/" + n.path);
2183
+ n.type === "file" && n.isMatched && r.push(o + "/" + n.path);
2096
2184
  const a = s.getChilds(n);
2097
2185
  if (a != null)
2098
2186
  for (let i = 0; i < a.length; i++)
2099
2187
  e(a[i]);
2100
2188
  }
2101
- return e(s.root), t;
2102
- }
2103
- const _e = /* @__PURE__ */ new Map();
2104
- function Yr(r) {
2105
- const t = H(r);
2106
- let s = _e.get(t);
2107
- return s == null && (s = new jt(), _e.set(t, s)), s;
2108
- }
2109
- async function Vr(r) {
2110
- const { filePath: t, func: s } = r;
2111
- return Yr(t).lock(
2112
- () => Y({
2113
- pool: ye,
2189
+ return e(s.root), r;
2190
+ }
2191
+ const Je = /* @__PURE__ */ new Map();
2192
+ function as(t) {
2193
+ const r = H(t);
2194
+ let s = Je.get(r);
2195
+ return s == null && (s = new Yt(), Je.set(r, s)), s;
2196
+ }
2197
+ async function ls(t) {
2198
+ const { filePath: r, func: s } = t;
2199
+ return as(r).lock(
2200
+ () => V({
2201
+ pool: be,
2114
2202
  count: 1,
2115
2203
  func: s
2116
2204
  })
2117
2205
  );
2118
2206
  }
2119
- const Ge = 10, te = 48, Je = 57, ue = 36, Zr = 38, Xr = 39, es = 60, ts = 62, rs = 96, re = 0, je = 1, Ke = 2, We = 3, He = 4, ss = 5;
2120
- function os(r) {
2121
- const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
2207
+ const je = 10, re = 48, Ke = 57, de = 36, cs = 38, us = 39, ds = 60, fs = 62, hs = 96, se = 0, We = 1, He = 2, Qe = 3, Ye = 4, ps = 5;
2208
+ function ms(t) {
2209
+ const { content: r, pattern: s, replacement: o } = t, e = r.length, n = [0];
2122
2210
  for (let b = 0; b < e; b++)
2123
- t.charCodeAt(b) === Ge && b + 1 < e && n.push(b + 1);
2211
+ r.charCodeAt(b) === je && b + 1 < e && n.push(b + 1);
2124
2212
  const a = n.length, i = [], c = [];
2125
- let l = null, u = null, d = null, f = 0;
2213
+ let l = null, u = null, f = null, d = 0;
2126
2214
  if (o != null) {
2127
2215
  const b = o.length;
2128
2216
  let $ = !1;
2129
2217
  for (let S = 0; S < b; S++)
2130
- if (o.charCodeAt(S) === ue) {
2218
+ if (o.charCodeAt(S) === de) {
2131
2219
  $ = !0;
2132
2220
  break;
2133
2221
  }
2134
2222
  if ($) {
2135
- u = [], d = [];
2223
+ u = [], f = [];
2136
2224
  let S = 0, x = 0;
2137
2225
  for (; x < b; ) {
2138
- if (o.charCodeAt(x) !== ue || x + 1 >= b) {
2226
+ if (o.charCodeAt(x) !== de || x + 1 >= b) {
2139
2227
  x++;
2140
2228
  continue;
2141
2229
  }
2142
2230
  const T = o.charCodeAt(x + 1);
2143
- let v = -1, L = 0, k = 2;
2144
- if (T === ue)
2145
- v = re, L = "$";
2146
- else if (T === Zr)
2147
- v = je;
2148
- else if (T === rs)
2149
- v = Ke;
2150
- else if (T === Xr)
2151
- v = We;
2152
- else if (T >= te && T <= Je) {
2153
- let I = x + 2;
2154
- for (; I < b; ) {
2155
- const C = o.charCodeAt(I);
2156
- if (C < te || C > Je) break;
2157
- I++;
2231
+ let N = -1, B = 0, k = 2;
2232
+ if (T === de)
2233
+ N = se, B = "$";
2234
+ else if (T === cs)
2235
+ N = We;
2236
+ else if (T === hs)
2237
+ N = He;
2238
+ else if (T === us)
2239
+ N = Qe;
2240
+ else if (T >= re && T <= Ke) {
2241
+ let M = x + 2;
2242
+ for (; M < b; ) {
2243
+ const C = o.charCodeAt(M);
2244
+ if (C < re || C > Ke) break;
2245
+ M++;
2158
2246
  }
2159
- v = He, L = o.substring(x + 1, I), k = I - x;
2160
- } else if (T === es) {
2161
- let I = x + 2;
2162
- for (; I < b && o.charCodeAt(I) !== ts; )
2163
- I++;
2164
- I < b && I > x + 2 && (v = ss, L = o.substring(x + 2, I), k = I + 1 - x);
2247
+ N = Ye, B = o.substring(x + 1, M), k = M - x;
2248
+ } else if (T === ds) {
2249
+ let M = x + 2;
2250
+ for (; M < b && o.charCodeAt(M) !== fs; )
2251
+ M++;
2252
+ M < b && M > x + 2 && (N = ps, B = o.substring(x + 2, M), k = M + 1 - x);
2165
2253
  }
2166
- v >= 0 ? (x > S && (u.push(re), d.push(o.substring(S, x))), u.push(v), d.push(L), x += k, S = x) : x++;
2254
+ N >= 0 ? (x > S && (u.push(se), f.push(o.substring(S, x))), u.push(N), f.push(B), x += k, S = x) : x++;
2167
2255
  }
2168
- S < b && (u.push(re), d.push(o.substring(S))), f = u.length;
2256
+ S < b && (u.push(se), f.push(o.substring(S))), d = u.length;
2169
2257
  } else
2170
2258
  l = o;
2171
2259
  }
2172
- let h = "", m = 0, g = 0;
2260
+ let h = "", g = 0, m = 0;
2173
2261
  s.lastIndex = 0;
2174
2262
  let y;
2175
- for (; (y = s.exec(t)) !== null; ) {
2263
+ for (; (y = s.exec(r)) !== null; ) {
2176
2264
  const b = y.index, $ = y[0], S = $.length, x = b + S;
2177
- let T, v, L, k;
2265
+ let T, N, B, k;
2178
2266
  if (a === 1)
2179
- T = 0, v = 1, L = 0, k = e;
2267
+ T = 0, N = 1, B = 0, k = e;
2180
2268
  else {
2181
- let I = 0, C = a - 1;
2182
- for (; I < C; ) {
2183
- const E = I + C + 1 >> 1;
2184
- n[E] <= b ? I = E : C = E - 1;
2269
+ let M = 0, C = a - 1;
2270
+ for (; M < C; ) {
2271
+ const E = M + C + 1 >> 1;
2272
+ n[E] <= b ? M = E : C = E - 1;
2185
2273
  }
2186
- if (T = I, S > 0) {
2274
+ if (T = M, S > 0) {
2187
2275
  const E = x - 1;
2188
- for (C = a - 1; I < C; ) {
2189
- const O = I + C + 1 >> 1;
2190
- n[O] <= E ? I = O : C = O - 1;
2276
+ for (C = a - 1; M < C; ) {
2277
+ const O = M + C + 1 >> 1;
2278
+ n[O] <= E ? M = O : C = O - 1;
2191
2279
  }
2192
- v = I + 1;
2280
+ N = M + 1;
2193
2281
  } else
2194
- v = T + 1;
2195
- L = n[T], k = v < a ? n[v] : e;
2282
+ N = T + 1;
2283
+ B = n[T], k = N < a ? n[N] : e;
2196
2284
  }
2197
2285
  if (i.push({
2198
2286
  offset: [b, x],
2199
- lines: [T, v],
2200
- linesOffset: [L, k]
2287
+ lines: [T, N],
2288
+ linesOffset: [B, k]
2201
2289
  }), o != null) {
2202
- h += t.substring(m, b);
2203
- let I;
2290
+ h += r.substring(g, b);
2291
+ let M;
2204
2292
  if (l != null)
2205
- I = l;
2293
+ M = l;
2206
2294
  else {
2207
- I = "";
2295
+ M = "";
2208
2296
  const E = y.groups, O = y.length - 1;
2209
- for (let K = 0; K < f; K++) {
2210
- const _ = u[K], A = d[K];
2211
- switch (_) {
2212
- case re:
2213
- I += A;
2297
+ for (let K = 0; K < d; K++) {
2298
+ const q = u[K], P = f[K];
2299
+ switch (q) {
2300
+ case se:
2301
+ M += P;
2214
2302
  break;
2215
- case je:
2216
- I += $;
2303
+ case We:
2304
+ M += $;
2217
2305
  break;
2218
- case Ke:
2219
- I += t.substring(0, b);
2306
+ case He:
2307
+ M += r.substring(0, b);
2220
2308
  break;
2221
- case We:
2222
- I += t.substring(x);
2309
+ case Qe:
2310
+ M += r.substring(x);
2223
2311
  break;
2224
- case He: {
2225
- const P = A, U = P.length, z = P.charCodeAt(0) - te;
2226
- if (U >= 2) {
2227
- const G = P.charCodeAt(1) - te, D = z * 10 + G;
2312
+ case Ye: {
2313
+ const L = P, z = L.length, A = L.charCodeAt(0) - re;
2314
+ if (z >= 2) {
2315
+ const _ = L.charCodeAt(1) - re, D = A * 10 + _;
2228
2316
  if (D >= 1 && D <= O) {
2229
- I += y[D] ?? "", U > 2 && (I += P.substring(2));
2317
+ M += y[D] ?? "", z > 2 && (M += L.substring(2));
2230
2318
  break;
2231
2319
  }
2232
2320
  }
2233
- z >= 1 && z <= O ? (I += y[z] ?? "", U > 1 && (I += P.substring(1))) : I += "$" + P;
2321
+ A >= 1 && A <= O ? (M += y[A] ?? "", z > 1 && (M += L.substring(1))) : M += "$" + L;
2234
2322
  break;
2235
2323
  }
2236
2324
  default:
2237
- E != null ? I += E[A] ?? "" : I += "$<" + A + ">";
2325
+ E != null ? M += E[P] ?? "" : M += "$<" + P + ">";
2238
2326
  }
2239
2327
  }
2240
2328
  }
2241
- h += I;
2242
- const C = b + g;
2329
+ h += M;
2330
+ const C = b + m;
2243
2331
  c.push({
2244
- offset: [C, C + I.length],
2332
+ offset: [C, C + M.length],
2245
2333
  lines: [0, 0],
2246
2334
  linesOffset: [0, 0]
2247
- }), g += I.length - S, m = x;
2335
+ }), m += M.length - S, g = x;
2248
2336
  }
2249
2337
  if (S === 0 && s.lastIndex++, !s.global)
2250
2338
  break;
2251
2339
  }
2252
2340
  if (s.lastIndex = 0, o == null)
2253
- return { search: { content: t, matches: i }, replace: null };
2254
- h += t.substring(m);
2255
- const w = h.length, M = [0];
2341
+ return { search: { content: r, matches: i }, replace: null };
2342
+ h += r.substring(g);
2343
+ const w = h.length, I = [0];
2256
2344
  for (let b = 0; b < w; b++)
2257
- h.charCodeAt(b) === Ge && b + 1 < w && M.push(b + 1);
2258
- const N = M.length;
2345
+ h.charCodeAt(b) === je && b + 1 < w && I.push(b + 1);
2346
+ const v = I.length;
2259
2347
  for (let b = 0, $ = c.length; b < $; b++) {
2260
2348
  const S = c[b], x = S.offset[0], T = S.offset[1];
2261
- let v, L, k, I;
2262
- if (N === 1)
2263
- v = 0, L = 1, k = 0, I = w;
2349
+ let N, B, k, M;
2350
+ if (v === 1)
2351
+ N = 0, B = 1, k = 0, M = w;
2264
2352
  else {
2265
- let C = 0, E = N - 1;
2353
+ let C = 0, E = v - 1;
2266
2354
  for (; C < E; ) {
2267
2355
  const O = C + E + 1 >> 1;
2268
- M[O] <= x ? C = O : E = O - 1;
2356
+ I[O] <= x ? C = O : E = O - 1;
2269
2357
  }
2270
- if (v = C, T > x) {
2358
+ if (N = C, T > x) {
2271
2359
  const O = T - 1;
2272
- for (E = N - 1; C < E; ) {
2360
+ for (E = v - 1; C < E; ) {
2273
2361
  const K = C + E + 1 >> 1;
2274
- M[K] <= O ? C = K : E = K - 1;
2362
+ I[K] <= O ? C = K : E = K - 1;
2275
2363
  }
2276
- L = C + 1;
2364
+ B = C + 1;
2277
2365
  } else
2278
- L = v + 1;
2279
- k = M[v], I = L < N ? M[L] : w;
2366
+ B = N + 1;
2367
+ k = I[N], M = B < v ? I[B] : w;
2280
2368
  }
2281
- S.lines[0] = v, S.lines[1] = L, S.linesOffset[0] = k, S.linesOffset[1] = I;
2369
+ S.lines[0] = N, S.lines[1] = B, S.linesOffset[0] = k, S.linesOffset[1] = M;
2282
2370
  }
2283
2371
  return {
2284
- search: { content: t, matches: i },
2372
+ search: { content: r, matches: i },
2285
2373
  replace: { content: h, matches: c }
2286
2374
  };
2287
2375
  }
2288
- function yt(r) {
2289
- if (r.length === 0)
2376
+ function Mt(t) {
2377
+ if (t.length === 0)
2290
2378
  return [];
2291
- const t = [...r].sort((a, i) => {
2379
+ const r = [...t].sort((a, i) => {
2292
2380
  const c = a.lines[0], l = i.lines[0];
2293
2381
  if (c > l) return 1;
2294
2382
  if (c < l) return -1;
2295
- const u = a.lines[1], d = i.lines[1];
2296
- return u > d ? 1 : u < d ? -1 : 0;
2383
+ const u = a.lines[1], f = i.lines[1];
2384
+ return u > f ? 1 : u < f ? -1 : 0;
2297
2385
  }), s = [];
2298
- let o = [...t[0].offset], e = [...t[0].lines], n = [...t[0].linesOffset];
2299
- for (let a = 1; a < t.length; a++) {
2300
- const i = t[a];
2386
+ let o = [...r[0].offset], e = [...r[0].lines], n = [...r[0].linesOffset];
2387
+ for (let a = 1; a < r.length; a++) {
2388
+ const i = r[a];
2301
2389
  i.lines[0] <= e[1] ? (i.offset[0] < o[0] && (o[0] = i.offset[0]), i.offset[1] > o[1] && (o[1] = i.offset[1]), i.lines[1] > e[1] && (e[1] = i.lines[1], n[1] = i.linesOffset[1])) : (s.push({
2302
2390
  offset: o,
2303
2391
  lines: e,
@@ -2310,91 +2398,91 @@ function yt(r) {
2310
2398
  linesOffset: n
2311
2399
  }), s;
2312
2400
  }
2313
- function se(r, t, s, o) {
2401
+ function oe(t, r, s, o) {
2314
2402
  let e = 0, n = 0;
2315
2403
  for (let u = 0; u < s; u++)
2316
- r.charCodeAt(u) === 10 && (n = u + 1, e++);
2404
+ t.charCodeAt(u) === 10 && (n = u + 1, e++);
2317
2405
  const a = e, i = n;
2318
2406
  let c = s;
2319
2407
  for (; c < o; c++)
2320
- r.charCodeAt(c) === 10 && e++;
2408
+ t.charCodeAt(c) === 10 && e++;
2321
2409
  const l = e + 1;
2322
- for (; c < t; c++)
2323
- if (r.charCodeAt(c) === 10)
2410
+ for (; c < r; c++)
2411
+ if (t.charCodeAt(c) === 10)
2324
2412
  return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: c + 1 };
2325
- return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: t };
2413
+ return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: r };
2326
2414
  }
2327
- function ns(r, t) {
2328
- if (r.replace == null && t.replace == null) {
2329
- const q = [...r.search.matches, ...t.search.matches];
2415
+ function gs(t, r) {
2416
+ if (t.replace == null && r.replace == null) {
2417
+ const U = [...t.search.matches, ...r.search.matches];
2330
2418
  return {
2331
- search: { content: r.search.content, matches: yt(q) },
2419
+ search: { content: t.search.content, matches: Mt(U) },
2332
2420
  replace: null
2333
2421
  };
2334
2422
  }
2335
- const s = r.replace ?? r.search, o = t.replace ?? t.search, e = r.search.content, n = o.content, a = e.length, i = n.length, c = r.search.matches, l = s.matches, u = t.search.matches, d = o.matches, f = l.length, h = u.length, m = [], g = [];
2336
- let y = 0, w = 0, M = 0, N = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, L = 0, k = 0, I = 0, C = 0, E = 0, O = 0, K = 0, _ = 0, A = 0, P = 0, U = 0, z = 0, G = 0, D = 0;
2337
- for (; y < f || w < h; )
2338
- if (y < f && (b = l[y].offset[0], $ = l[y].offset[1]), w < h && (S = u[w].offset[0], x = u[w].offset[1]), y < f && w < h && b < x && S < $) {
2339
- K = b < S ? b : S, T = $ > x ? $ : x, L = y, k = w, y++, w++;
2423
+ const s = t.replace ?? t.search, o = r.replace ?? r.search, e = t.search.content, n = o.content, a = e.length, i = n.length, c = t.search.matches, l = s.matches, u = r.search.matches, f = o.matches, d = l.length, h = u.length, g = [], m = [];
2424
+ let y = 0, w = 0, I = 0, v = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, N = 0, B = 0, k = 0, M = 0, C = 0, E = 0, O = 0, K = 0, q = 0, P = 0, L = 0, z = 0, A = 0, _ = 0, D = 0;
2425
+ for (; y < d || w < h; )
2426
+ if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < h && (S = u[w].offset[0], x = u[w].offset[1]), y < d && w < h && b < x && S < $) {
2427
+ K = b < S ? b : S, T = $ > x ? $ : x, B = y, k = w, y++, w++;
2340
2428
  do {
2341
- for (v = T; y < f && l[y].offset[0] < T; )
2429
+ for (N = T; y < d && l[y].offset[0] < T; )
2342
2430
  $ = l[y].offset[1], $ > T && (T = $), y++;
2343
2431
  for (; w < h && u[w].offset[0] < T; )
2344
2432
  x = u[w].offset[1], x > T && (T = x), w++;
2345
- } while (T !== v);
2346
- I = 1 / 0, C = -1 / 0, _ = K, A = M;
2347
- for (let J = L; J < y; J++)
2348
- P = c[J].offset[0], U = c[J].offset[1], z = l[J].offset[0], G = l[J].offset[1], _ < z && (D = _ + A, D < I && (I = D), D = z + A, D > C && (C = D)), P < I && (I = P), U > C && (C = U), A += U - P - G + z, _ = G;
2349
- _ < T && (D = _ + A, D < I && (I = D), D = T + A, D > C && (C = D)), M = A, E = 1 / 0, O = -1 / 0, _ = K, A = N;
2350
- for (let J = k; J < w; J++)
2351
- P = u[J].offset[0], U = u[J].offset[1], z = d[J].offset[0], G = d[J].offset[1], _ < P && (D = _ + A, D < E && (E = D), D = P + A, D > O && (O = D)), z < E && (E = z), G > O && (O = G), A += G - z - U + P, _ = U;
2352
- _ < T && (D = _ + A, D < E && (E = D), D = T + A, D > O && (O = D)), N = A;
2353
- const q = se(e, a, I, C);
2354
- m.push({
2355
- offset: [I, C],
2356
- lines: [q.startLine, q.endLine],
2357
- linesOffset: [q.startLineOfs, q.endLineOfs]
2358
- });
2359
- const ee = se(n, i, E, O);
2433
+ } while (T !== N);
2434
+ M = 1 / 0, C = -1 / 0, q = K, P = I;
2435
+ for (let G = B; G < y; G++)
2436
+ L = c[G].offset[0], z = c[G].offset[1], A = l[G].offset[0], _ = l[G].offset[1], q < A && (D = q + P, D < M && (M = D), D = A + P, D > C && (C = D)), L < M && (M = L), z > C && (C = z), P += z - L - _ + A, q = _;
2437
+ q < T && (D = q + P, D < M && (M = D), D = T + P, D > C && (C = D)), I = P, E = 1 / 0, O = -1 / 0, q = K, P = v;
2438
+ for (let G = k; G < w; G++)
2439
+ L = u[G].offset[0], z = u[G].offset[1], A = f[G].offset[0], _ = f[G].offset[1], q < L && (D = q + P, D < E && (E = D), D = L + P, D > O && (O = D)), A < E && (E = A), _ > O && (O = _), P += _ - A - z + L, q = z;
2440
+ q < T && (D = q + P, D < E && (E = D), D = T + P, D > O && (O = D)), v = P;
2441
+ const U = oe(e, a, M, C);
2360
2442
  g.push({
2443
+ offset: [M, C],
2444
+ lines: [U.startLine, U.endLine],
2445
+ linesOffset: [U.startLineOfs, U.endLineOfs]
2446
+ });
2447
+ const te = oe(n, i, E, O);
2448
+ m.push({
2361
2449
  offset: [E, O],
2362
- lines: [ee.startLine, ee.endLine],
2363
- linesOffset: [ee.startLineOfs, ee.endLineOfs]
2450
+ lines: [te.startLine, te.endLine],
2451
+ linesOffset: [te.startLineOfs, te.endLineOfs]
2364
2452
  });
2365
- } else if (w >= h || y < f && b <= S) {
2366
- P = c[y].offset[0], U = c[y].offset[1], z = l[y].offset[0], G = l[y].offset[1], E = z + N, O = G + N;
2367
- const q = se(n, i, E, O);
2368
- m.push(c[y]), g.push({
2453
+ } else if (w >= h || y < d && b <= S) {
2454
+ L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], _ = l[y].offset[1], E = A + v, O = _ + v;
2455
+ const U = oe(n, i, E, O);
2456
+ g.push(c[y]), m.push({
2369
2457
  offset: [E, O],
2370
- lines: [q.startLine, q.endLine],
2371
- linesOffset: [q.startLineOfs, q.endLineOfs]
2372
- }), M += U - P - G + z, y++;
2458
+ lines: [U.startLine, U.endLine],
2459
+ linesOffset: [U.startLineOfs, U.endLineOfs]
2460
+ }), I += z - L - _ + A, y++;
2373
2461
  } else {
2374
- P = u[w].offset[0], U = u[w].offset[1], z = d[w].offset[0], G = d[w].offset[1], I = P + M, C = U + M;
2375
- const q = se(e, a, I, C);
2376
- m.push({
2377
- offset: [I, C],
2378
- lines: [q.startLine, q.endLine],
2379
- linesOffset: [q.startLineOfs, q.endLineOfs]
2380
- }), g.push(d[w]), N += G - z - U + P, w++;
2462
+ L = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], _ = f[w].offset[1], M = L + I, C = z + I;
2463
+ const U = oe(e, a, M, C);
2464
+ g.push({
2465
+ offset: [M, C],
2466
+ lines: [U.startLine, U.endLine],
2467
+ linesOffset: [U.startLineOfs, U.endLineOfs]
2468
+ }), m.push(f[w]), v += _ - A - z + L, w++;
2381
2469
  }
2382
2470
  return {
2383
- search: { content: e, matches: m },
2384
- replace: { content: n, matches: g }
2471
+ search: { content: e, matches: g },
2472
+ replace: { content: n, matches: m }
2385
2473
  };
2386
2474
  }
2387
- async function is(r) {
2388
- const { filePath: t, operations: s, dryRun: o } = r;
2389
- return s.length === 0 ? { filePath: t, result: null } : Vr({
2390
- filePath: t,
2475
+ async function ws(t) {
2476
+ const { filePath: r, operations: s, dryRun: o } = t;
2477
+ return s.length === 0 ? { filePath: r, result: null } : ls({
2478
+ filePath: r,
2391
2479
  func: async () => {
2392
2480
  let e;
2393
2481
  try {
2394
- e = await W.promises.readFile(t, "utf-8");
2482
+ e = await W.promises.readFile(r, "utf-8");
2395
2483
  } catch (i) {
2396
2484
  return {
2397
- filePath: t,
2485
+ filePath: r,
2398
2486
  result: null,
2399
2487
  error: `Failed to read file: ${i instanceof Error ? i.message : i + ""}`
2400
2488
  };
@@ -2405,73 +2493,73 @@ async function is(r) {
2405
2493
  let l;
2406
2494
  try {
2407
2495
  l = new RegExp(c.pattern, c.flags ?? "");
2408
- } catch (f) {
2496
+ } catch (d) {
2409
2497
  return {
2410
- filePath: t,
2498
+ filePath: r,
2411
2499
  result: null,
2412
- error: `Invalid RegExp pattern "${c.pattern}": ${f instanceof Error ? f.message : f + ""}`
2500
+ error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
2413
2501
  };
2414
2502
  }
2415
- const u = n?.replace?.content ?? e, d = os({
2503
+ const u = n?.replace?.content ?? e, f = ms({
2416
2504
  content: u,
2417
2505
  pattern: l,
2418
2506
  replacement: c.replacement
2419
2507
  });
2420
- c.replacement != null && (a = !0), n == null ? n = d : n = ns(n, d);
2508
+ c.replacement != null && (a = !0), n == null ? n = f : n = gs(n, f);
2421
2509
  }
2422
2510
  if (a && n?.replace != null && !o) {
2423
2511
  const i = n.replace.content;
2424
2512
  if (i !== e)
2425
2513
  try {
2426
- await W.promises.writeFile(t, i, "utf-8");
2514
+ await W.promises.writeFile(r, i, "utf-8");
2427
2515
  } catch (c) {
2428
2516
  return {
2429
- filePath: t,
2517
+ filePath: r,
2430
2518
  result: n,
2431
2519
  error: `Failed to write file: ${c instanceof Error ? c.message : c + ""}`
2432
2520
  };
2433
2521
  }
2434
2522
  }
2435
- return { filePath: t, result: n };
2523
+ return { filePath: r, result: n };
2436
2524
  }
2437
2525
  });
2438
2526
  }
2439
- async function bt(r) {
2440
- const { filePaths: t, operations: s, dryRun: o } = r;
2527
+ async function Tt(t) {
2528
+ const { filePaths: r, operations: s, dryRun: o } = t;
2441
2529
  return { results: await Promise.all(
2442
- t.map(
2443
- (n) => is({ filePath: n, operations: s, dryRun: o })
2530
+ r.map(
2531
+ (n) => ws({ filePath: n, operations: s, dryRun: o })
2444
2532
  )
2445
2533
  ) };
2446
2534
  }
2447
- const as = 6;
2448
- function ls(r) {
2449
- const { content: t, startLine: s } = r, o = r.padWidth ?? as;
2535
+ const ys = 6;
2536
+ function bs(t) {
2537
+ const { content: r, startLine: s } = t, o = t.padWidth ?? ys;
2450
2538
  let e = "", n = 0, a = 0;
2451
- for (; n < t.length; ) {
2452
- const i = t.indexOf(`
2453
- `, n), c = i === -1 ? t.length : i + 1;
2454
- e += String(s + a + 1).padStart(o) + "→" + t.substring(n, c), n = c, a++;
2539
+ for (; n < r.length; ) {
2540
+ const i = r.indexOf(`
2541
+ `, n), c = i === -1 ? r.length : i + 1;
2542
+ e += String(s + a + 1).padStart(o) + "→" + r.substring(n, c), n = c, a++;
2455
2543
  }
2456
2544
  return e.length > 0 && !e.endsWith(`
2457
2545
  `) && (e += `
2458
2546
  `), e;
2459
2547
  }
2460
- function de(r) {
2461
- const { content: t, matches: s, outputLimit: o } = r;
2548
+ function fe(t) {
2549
+ const { content: r, matches: s, outputLimit: o } = t;
2462
2550
  if (s.length === 0)
2463
2551
  return { output: "", truncated: !1 };
2464
- const e = yt(s);
2552
+ const e = Mt(s);
2465
2553
  let n = "", a = !1;
2466
2554
  for (let i = 0; i < e.length; i++) {
2467
- const c = e[i], l = t.substring(
2555
+ const c = e[i], l = r.substring(
2468
2556
  c.linesOffset[0],
2469
2557
  c.linesOffset[1]
2470
- ), u = ls({
2558
+ ), u = bs({
2471
2559
  content: l,
2472
2560
  startLine: c.lines[0]
2473
- }), d = i > 0 ? 2 : 0;
2474
- if (o != null && n.length + d + u.length > o) {
2561
+ }), f = i > 0 ? 2 : 0;
2562
+ if (o != null && n.length + f + u.length > o) {
2475
2563
  a = !0;
2476
2564
  break;
2477
2565
  }
@@ -2480,93 +2568,79 @@ function de(r) {
2480
2568
  }
2481
2569
  return { output: n, truncated: a };
2482
2570
  }
2483
- const Qe = "BEFORE", Ye = "AFTER";
2484
- function cs(r) {
2485
- const { result: t, outputLimit: s } = r;
2486
- if (t.replace == null) {
2487
- const m = de({
2488
- content: t.search.content,
2489
- matches: t.search.matches,
2571
+ const Ve = "BEFORE", Ze = "AFTER";
2572
+ function Ss(t) {
2573
+ const { result: r, outputLimit: s } = t;
2574
+ if (r.replace == null) {
2575
+ const g = fe({
2576
+ content: r.search.content,
2577
+ matches: r.search.matches,
2490
2578
  outputLimit: s
2491
2579
  });
2492
- return { output: m.output, truncated: m.truncated };
2580
+ return { output: g.output, truncated: g.truncated };
2493
2581
  }
2494
- const o = `<${Qe}>
2495
- `, e = `</${Qe}>
2496
- `, n = `<${Ye}>
2497
- `, a = `</${Ye}>
2582
+ const o = `<${Ve}>
2583
+ `, e = `</${Ve}>
2584
+ `, n = `<${Ze}>
2585
+ `, a = `</${Ze}>
2498
2586
  `, i = o.length + e.length + n.length + a.length;
2499
2587
  if (s != null && s < i)
2500
2588
  return { output: "", truncated: !0 };
2501
- const c = s != null ? s - i : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = de({
2502
- content: t.search.content,
2503
- matches: t.search.matches,
2589
+ const c = s != null ? s - i : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = fe({
2590
+ content: r.search.content,
2591
+ matches: r.search.matches,
2504
2592
  outputLimit: l
2505
- }), d = c != null ? c - u.output.length : void 0, f = de({
2506
- content: t.replace.content,
2507
- matches: t.replace.matches,
2508
- outputLimit: d
2593
+ }), f = c != null ? c - u.output.length : void 0, d = fe({
2594
+ content: r.replace.content,
2595
+ matches: r.replace.matches,
2596
+ outputLimit: f
2509
2597
  });
2510
- return { output: o + u.output + e + n + f.output + a, truncated: u.truncated || f.truncated };
2511
- }
2512
- const Ve = `
2513
- ... [truncated, too much output, use more specific search patterns] ...
2514
- `;
2515
- function St(r) {
2516
- const { result: t, rootDir: s, outputLimit: o } = r, e = o - Ve.length;
2517
- let n = "", a = !1;
2518
- for (let i = 0; i < t.results.length; i++) {
2519
- const c = t.results[i], l = F.relative(s, c.filePath), u = n.length > 0 ? 1 : 0;
2520
- if (c.error != null) {
2521
- const h = l + `
2522
- ❌ ` + c.error + `
2598
+ return { output: o + u.output + e + n + d.output + a, truncated: u.truncated || d.truncated };
2599
+ }
2600
+ function Ct(t) {
2601
+ const { result: r, rootDir: s } = t;
2602
+ let o = "";
2603
+ for (let e = 0; e < r.results.length; e++) {
2604
+ const n = r.results[e], a = R.relative(s, n.filePath), i = o.length > 0 ? 1 : 0;
2605
+ if (n.error != null) {
2606
+ const l = a + `
2607
+ ` + n.error + `
2523
2608
  `;
2524
- if (n.length + u + h.length > e) {
2525
- a = !0;
2526
- break;
2527
- }
2528
- u > 0 && (n += `
2529
- `), n += h;
2609
+ i > 0 && (o += `
2610
+ `), o += l;
2530
2611
  continue;
2531
2612
  }
2532
- if (c.result == null || c.result.search.matches.length === 0)
2613
+ if (n.result == null || n.result.search.matches.length === 0)
2533
2614
  continue;
2534
- const d = e - n.length - u - l.length - 1;
2535
- if (d <= 0) {
2536
- a = !0;
2537
- break;
2538
- }
2539
- const f = cs({
2540
- result: c.result,
2541
- outputLimit: d
2615
+ const c = Ss({
2616
+ result: n.result
2542
2617
  });
2543
- if (a = a || f.truncated, f.output.length > 0 && (u > 0 && (n += `
2544
- `), n += l + `
2545
- ` + f.output), a)
2546
- break;
2618
+ c.output.length > 0 && (i > 0 && (o += `
2619
+ `), o += a + `
2620
+ ` + c.output);
2547
2621
  }
2548
- return a && (n += Ve), n;
2622
+ return o;
2549
2623
  }
2550
- const us = p.object({
2624
+ const xs = p.object({
2551
2625
  pattern: p.string().describe("JS RegExp pattern"),
2552
2626
  flags: p.string().optional().describe("JS RegExp flags")
2553
- }), xt = p.object({
2627
+ }), Nt = p.object({
2554
2628
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2555
- snapshot: X.optional().describe(
2629
+ snapshot: ee.optional().describe(
2556
2630
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2557
2631
  ),
2558
- operations: p.array(us).describe("Search operations to execute sequentially on each file"),
2559
- outputLimit: p.number().max(R).default(R).describe(
2560
- `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${R}. Default: ${R}`
2632
+ operations: p.array(xs).describe("Search operations to execute sequentially on each file"),
2633
+ outputLimit: p.number().int().min(0).max(J).default(Q).describe(
2634
+ `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2561
2635
  )
2562
2636
  });
2563
- async function ds(r, t, s) {
2637
+ async function $s(t, r, s) {
2564
2638
  let o;
2565
2639
  try {
2566
- o = xt.parse(r);
2567
- } catch (y) {
2640
+ o = Nt.parse(t);
2641
+ } catch (w) {
2568
2642
  return {
2569
- error: B(y)
2643
+ error: F(w)
2570
2644
  };
2571
2645
  }
2572
2646
  const { snapshotName: e, snapshot: n, operations: a, outputLimit: i } = o;
@@ -2574,54 +2648,57 @@ async function ds(r, t, s) {
2574
2648
  return {
2575
2649
  error: "Session ID is required"
2576
2650
  };
2577
- const c = Z(s.sessionId);
2651
+ const c = X(s.sessionId);
2578
2652
  if (e && n)
2579
2653
  return {
2580
2654
  error: "Either snapshotName or snapshot must be provided, not both"
2581
2655
  };
2582
- let l, u = !1, d = !1;
2656
+ let l, u = !1, f = !1;
2583
2657
  if (e) {
2584
2658
  if (l = c.fsSnapshots.get(e), l == null)
2585
2659
  return {
2586
2660
  error: `Filesystem snapshot "${e}" not found`
2587
2661
  };
2588
2662
  } else if (n) {
2589
- const y = await le(
2663
+ const w = await ce(
2590
2664
  n,
2591
- t,
2665
+ r,
2592
2666
  s
2593
2667
  );
2594
- if (y.error != null)
2668
+ if (w.error != null)
2595
2669
  return {
2596
- error: y.error
2670
+ error: w.error
2597
2671
  };
2598
- l = y.fsSnapshot, u = y.queryCreated, d = !0;
2672
+ l = w.fsSnapshot, u = w.queryCreated, f = !0;
2599
2673
  } else
2600
2674
  return {
2601
2675
  error: "Either snapshotName or snapshot must be provided"
2602
2676
  };
2603
- const f = wt(l), h = l.query.rootDir ?? ".", m = await bt({
2604
- filePaths: f,
2677
+ const d = It(l), h = l.query.rootDir ?? ".", g = await Tt({
2678
+ filePaths: d,
2605
2679
  operations: a
2680
+ }), m = Ct({
2681
+ result: g,
2682
+ rootDir: h
2606
2683
  });
2607
- return { output: St({
2608
- result: m,
2609
- rootDir: h,
2610
- outputLimit: i
2611
- }), rootDir: h, fsSnapshot: l, queryCreated: u, snapshotCreated: d };
2612
- }
2613
- function fs(r, t) {
2614
- r(
2684
+ return { output: we({
2685
+ sessionId: s.sessionId,
2686
+ source: m,
2687
+ limit: i
2688
+ }).content, rootDir: h, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2689
+ }
2690
+ function Is(t, r) {
2691
+ t(
2615
2692
  "fs-snapshot-search",
2616
2693
  {
2617
2694
  title: "Search File Contents in Snapshot",
2618
2695
  description: "Search file contents using JS RegExp. Use this to find text patterns across snapshot files. Combine all patterns into the `operations` array within one tool call; never split patterns across multiple tool calls",
2619
- inputSchema: xt.shape
2696
+ inputSchema: Nt.shape
2620
2697
  },
2621
2698
  async (s, o) => {
2622
- const e = await ds(
2699
+ const e = await $s(
2623
2700
  s,
2624
- t,
2701
+ r,
2625
2702
  o
2626
2703
  );
2627
2704
  if (e.error != null)
@@ -2638,30 +2715,30 @@ ${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` arr
2638
2715
  }
2639
2716
  );
2640
2717
  }
2641
- const hs = p.object({
2718
+ const Ms = p.object({
2642
2719
  pattern: p.string().describe("JS RegExp pattern"),
2643
2720
  flags: p.string().optional().describe("JS RegExp flags"),
2644
2721
  replacement: p.string().describe("JS replacement pattern")
2645
- }), $t = p.object({
2722
+ }), vt = p.object({
2646
2723
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2647
- snapshot: X.optional().describe(
2724
+ snapshot: ee.optional().describe(
2648
2725
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2649
2726
  ),
2650
- operations: p.array(hs).describe("Replace operations to execute sequentially on each file"),
2651
- outputLimit: p.number().max(R).default(R).describe(
2652
- `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${R}. Default: ${R}`
2727
+ operations: p.array(Ms).describe("Replace operations to execute sequentially on each file"),
2728
+ outputLimit: p.number().int().min(0).max(J).default(Q).describe(
2729
+ `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2653
2730
  ),
2654
2731
  dryRun: p.boolean().optional().describe(
2655
2732
  "Preview changes without writing files. When true, shows what would be replaced but does not modify files"
2656
2733
  )
2657
2734
  });
2658
- async function ps(r, t, s) {
2735
+ async function Ts(t, r, s) {
2659
2736
  let o;
2660
2737
  try {
2661
- o = $t.parse(r);
2662
- } catch (w) {
2738
+ o = vt.parse(t);
2739
+ } catch (I) {
2663
2740
  return {
2664
- error: B(w)
2741
+ error: F(I)
2665
2742
  };
2666
2743
  }
2667
2744
  const { snapshotName: e, snapshot: n, operations: a, outputLimit: i, dryRun: c } = o;
@@ -2669,55 +2746,58 @@ async function ps(r, t, s) {
2669
2746
  return {
2670
2747
  error: "Session ID is required"
2671
2748
  };
2672
- const l = Z(s.sessionId);
2749
+ const l = X(s.sessionId);
2673
2750
  if (e && n)
2674
2751
  return {
2675
2752
  error: "Either snapshotName or snapshot must be provided, not both"
2676
2753
  };
2677
- let u, d = !1, f = !1;
2754
+ let u, f = !1, d = !1;
2678
2755
  if (e) {
2679
2756
  if (u = l.fsSnapshots.get(e), u == null)
2680
2757
  return {
2681
2758
  error: `Filesystem snapshot "${e}" not found`
2682
2759
  };
2683
2760
  } else if (n) {
2684
- const w = await le(
2761
+ const I = await ce(
2685
2762
  n,
2686
- t,
2763
+ r,
2687
2764
  s
2688
2765
  );
2689
- if (w.error != null)
2766
+ if (I.error != null)
2690
2767
  return {
2691
- error: w.error
2768
+ error: I.error
2692
2769
  };
2693
- u = w.fsSnapshot, d = w.queryCreated, f = !0;
2770
+ u = I.fsSnapshot, f = I.queryCreated, d = !0;
2694
2771
  } else
2695
2772
  return {
2696
2773
  error: "Either snapshotName or snapshot must be provided"
2697
2774
  };
2698
- const h = wt(u), m = u.query.rootDir ?? ".", g = await bt({
2775
+ const h = It(u), g = u.query.rootDir ?? ".", m = await Tt({
2699
2776
  filePaths: h,
2700
2777
  operations: a,
2701
2778
  dryRun: c
2779
+ }), y = Ct({
2780
+ result: m,
2781
+ rootDir: g
2702
2782
  });
2703
- return { output: St({
2704
- result: g,
2705
- rootDir: m,
2706
- outputLimit: i
2707
- }), rootDir: m, fsSnapshot: u, queryCreated: d, snapshotCreated: f };
2708
- }
2709
- function ms(r, t) {
2710
- r(
2783
+ return { output: we({
2784
+ sessionId: s.sessionId,
2785
+ source: y,
2786
+ limit: i
2787
+ }).content, rootDir: g, fsSnapshot: u, queryCreated: f, snapshotCreated: d };
2788
+ }
2789
+ function Cs(t, r) {
2790
+ t(
2711
2791
  "fs-snapshot-replace",
2712
2792
  {
2713
2793
  title: "Replace File Contents in Snapshot",
2714
2794
  description: "Replace file contents using JS RegExp. Use this to perform bulk replacements across snapshot files. Combine all patterns into the `operations` array within one tool call; never split patterns across multiple tool calls",
2715
- inputSchema: $t.shape
2795
+ inputSchema: vt.shape
2716
2796
  },
2717
2797
  async (s, o) => {
2718
- const e = await ps(
2798
+ const e = await Ts(
2719
2799
  s,
2720
- t,
2800
+ r,
2721
2801
  o
2722
2802
  );
2723
2803
  if (e.error != null)
@@ -2734,21 +2814,21 @@ ${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` arr
2734
2814
  }
2735
2815
  );
2736
2816
  }
2737
- function gs(r, t) {
2738
- t.list && Fr(r, t), t.snapshotQueryCreate && Lr(r, t), t.snapshotCreate && Jr(r, t), t.snapshotBrowse && Qr(r, t), t.snapshotSearch && fs(r, t), t.snapshotReplace && ms(r, t), console.log(
2817
+ function Ns(t, r) {
2818
+ r.list && jr(t, r), r.snapshotQueryCreate && Wr(t, r), r.snapshotCreate && ts(t, r), r.snapshotBrowse && is(t, r), r.snapshotSearch && Is(t, r), r.snapshotReplace && Cs(t, r), console.log(
2739
2819
  `File manager:
2740
- - Working directory: ${F.resolve(t.workingDir || "")}
2820
+ - Working directory: ${R.resolve(r.workingDir || "")}
2741
2821
  `
2742
2822
  );
2743
2823
  }
2744
- const fe = /* @__PURE__ */ new Map();
2745
- function j(r) {
2746
- return fe.has(r) || fe.set(r, {
2824
+ const he = /* @__PURE__ */ new Map();
2825
+ function j(t) {
2826
+ return he.has(t) || he.set(t, {
2747
2827
  browsers: /* @__PURE__ */ new Map(),
2748
2828
  domSnapshotQueries: /* @__PURE__ */ new Map()
2749
- }), fe.get(r);
2829
+ }), he.get(t);
2750
2830
  }
2751
- const Se = p.object({
2831
+ const xe = p.object({
2752
2832
  name: p.string().describe(
2753
2833
  "Unique name for the browser. Recommended format: kebab-case-1, kebab-case-2, ..."
2754
2834
  ),
@@ -2756,13 +2836,13 @@ const Se = p.object({
2756
2836
  muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
2757
2837
  devTools: p.boolean().optional().describe("Open browser with dev tools")
2758
2838
  });
2759
- async function It(r, t, s) {
2839
+ async function Et(t, r, s) {
2760
2840
  let o;
2761
2841
  try {
2762
- o = Se.parse(r);
2842
+ o = xe.parse(t);
2763
2843
  } catch (l) {
2764
2844
  return {
2765
- error: B(l)
2845
+ error: F(l)
2766
2846
  };
2767
2847
  }
2768
2848
  const { name: e, browserType: n, muteAudio: a, devTools: i } = o;
@@ -2773,49 +2853,49 @@ async function It(r, t, s) {
2773
2853
  const c = j(s.sessionId);
2774
2854
  try {
2775
2855
  const u = await {
2776
- chromium: Yt,
2777
- firefox: Qt,
2778
- webkit: Ht
2856
+ chromium: tr,
2857
+ firefox: er,
2858
+ webkit: Xt
2779
2859
  }[n].launch({
2780
2860
  headless: !1,
2781
2861
  devtools: i,
2782
2862
  args: a ? ["--mute-audio"] : void 0
2783
- }), d = {
2863
+ }), f = {
2784
2864
  name: e,
2785
2865
  browserType: n,
2786
2866
  browser: u,
2787
2867
  contexts: /* @__PURE__ */ new Map()
2788
2868
  };
2789
- return c.browsers.set(e, d), { browserInfo: d };
2869
+ return c.browsers.set(e, f), { browserInfo: f };
2790
2870
  } catch (l) {
2791
2871
  return {
2792
2872
  error: `Failed to create browser: ${l instanceof Error ? l.message : "Unknown error"}`
2793
2873
  };
2794
2874
  }
2795
2875
  }
2796
- function ws(r, t) {
2797
- r(
2876
+ function vs(t, r) {
2877
+ t(
2798
2878
  "playwright-browser-create",
2799
2879
  {
2800
2880
  title: "Create Browser",
2801
2881
  description: "Create a new browser. Prefer page-goto if you need to immediately create a browser, context, page and navigate",
2802
- inputSchema: Se.shape
2882
+ inputSchema: xe.shape
2803
2883
  },
2804
2884
  async (s, o) => {
2805
- const e = await It(s, t, o);
2885
+ const e = await Et(s, r, o);
2806
2886
  return `Method: playwright-browser-create(${JSON.stringify(s)})
2807
2887
  ${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
2808
2888
  }
2809
2889
  );
2810
2890
  }
2811
- const Mt = p.object({});
2812
- async function ys(r, t, s) {
2891
+ const kt = p.object({});
2892
+ async function Es(t, r, s) {
2813
2893
  let o;
2814
2894
  try {
2815
- o = Mt.parse(r);
2895
+ o = kt.parse(t);
2816
2896
  } catch (a) {
2817
2897
  return {
2818
- error: B(a)
2898
+ error: F(a)
2819
2899
  };
2820
2900
  }
2821
2901
  if (!s.sessionId)
@@ -2827,16 +2907,16 @@ async function ys(r, t, s) {
2827
2907
  browserInfos: Array.from(e.browsers.values())
2828
2908
  };
2829
2909
  }
2830
- function bs(r, t) {
2831
- r(
2910
+ function ks(t, r) {
2911
+ t(
2832
2912
  "playwright-browser-list",
2833
2913
  {
2834
2914
  title: "List Browsers",
2835
2915
  description: "List active browser instances",
2836
- inputSchema: Mt.shape
2916
+ inputSchema: kt.shape
2837
2917
  },
2838
2918
  async (s, o) => {
2839
- const e = await ys(s, t, o);
2919
+ const e = await Es(s, r, o);
2840
2920
  if (e.error != null)
2841
2921
  return `Method: playwright-browser-list(${JSON.stringify(s)})
2842
2922
  ❌ Error: ${e.error}`;
@@ -2848,18 +2928,18 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
2848
2928
  }
2849
2929
  );
2850
2930
  }
2851
- const Tt = p.object({
2931
+ const Ot = p.object({
2852
2932
  names: p.array(p.string()).optional().describe(
2853
2933
  "Names of browsers to close. If not specified, closes all browsers"
2854
2934
  )
2855
2935
  });
2856
- async function Ss(r, t, s) {
2936
+ async function Os(t, r, s) {
2857
2937
  let o;
2858
2938
  try {
2859
- o = Tt.parse(r);
2939
+ o = Ot.parse(t);
2860
2940
  } catch (l) {
2861
2941
  return {
2862
- error: B(l)
2942
+ error: F(l)
2863
2943
  };
2864
2944
  }
2865
2945
  const { names: e } = o;
@@ -2887,16 +2967,16 @@ async function Ss(r, t, s) {
2887
2967
  ...i.length > 0 && { errors: i }
2888
2968
  };
2889
2969
  }
2890
- function xs(r, t) {
2891
- r(
2970
+ function Ds(t, r) {
2971
+ t(
2892
2972
  "playwright-browser-close",
2893
2973
  {
2894
2974
  title: "Close Browsers",
2895
2975
  description: "Close browsers. Automatically closes all contexts and pages within the browsers",
2896
- inputSchema: Tt.shape
2976
+ inputSchema: Ot.shape
2897
2977
  },
2898
2978
  async (s, o) => {
2899
- const e = await Ss(s, t, o);
2979
+ const e = await Os(s, r, o);
2900
2980
  if (e.error != null)
2901
2981
  return `Method: playwright-browser-close(${JSON.stringify(s)})
2902
2982
  ❌ Error: ${e.error}`;
@@ -2913,9 +2993,9 @@ ${n.join(`
2913
2993
  }
2914
2994
  );
2915
2995
  }
2916
- const xe = p.object({
2996
+ const $e = p.object({
2917
2997
  browserName: p.string().optional().describe("Name of previously created browser, to use"),
2918
- browser: Se.optional().describe(
2998
+ browser: xe.optional().describe(
2919
2999
  "Browser creation options JSON to automatically create browser"
2920
3000
  ),
2921
3001
  name: p.string().describe(
@@ -2928,13 +3008,13 @@ const xe = p.object({
2928
3008
  height: p.number()
2929
3009
  }).optional().describe("Viewport size configuration")
2930
3010
  });
2931
- async function Ct(r, t, s) {
3011
+ async function Dt(t, r, s) {
2932
3012
  let o;
2933
3013
  try {
2934
- o = xe.parse(r);
3014
+ o = $e.parse(t);
2935
3015
  } catch (h) {
2936
3016
  return {
2937
- error: B(h)
3017
+ error: F(h)
2938
3018
  };
2939
3019
  }
2940
3020
  const { name: e, browserName: n, browser: a, isMobile: i, hasTouch: c, viewport: l } = o;
@@ -2947,55 +3027,55 @@ async function Ct(r, t, s) {
2947
3027
  return {
2948
3028
  error: "Either browserName or browser must be provided, not both"
2949
3029
  };
2950
- let d = !1, f;
3030
+ let f = !1, d;
2951
3031
  if (n) {
2952
- if (f = u.browsers.get(n), !f)
3032
+ if (d = u.browsers.get(n), !d)
2953
3033
  return {
2954
3034
  error: `Browser "${n}" not found`
2955
3035
  };
2956
3036
  } else if (a) {
2957
- const h = await It(a, t, s);
3037
+ const h = await Et(a, r, s);
2958
3038
  if (h.error != null)
2959
3039
  return {
2960
3040
  error: h.error
2961
3041
  };
2962
- f = h.browserInfo, d = !0;
3042
+ d = h.browserInfo, f = !0;
2963
3043
  } else
2964
3044
  return {
2965
3045
  error: "Either browserName or browser must be provided"
2966
3046
  };
2967
3047
  try {
2968
- const h = await f.browser.newContext({
3048
+ const h = await d.browser.newContext({
2969
3049
  isMobile: i,
2970
3050
  hasTouch: c,
2971
3051
  viewport: l
2972
- }), m = {
2973
- browserInfo: f,
3052
+ }), g = {
3053
+ browserInfo: d,
2974
3054
  name: e,
2975
3055
  context: h,
2976
3056
  pages: /* @__PURE__ */ new Map()
2977
3057
  };
2978
- return f.contexts.set(e, m), {
2979
- browserInfoCreated: d,
2980
- browserInfo: f,
2981
- contextInfo: m
3058
+ return d.contexts.set(e, g), {
3059
+ browserInfoCreated: f,
3060
+ browserInfo: d,
3061
+ contextInfo: g
2982
3062
  };
2983
3063
  } catch (h) {
2984
3064
  return {
2985
- error: `Failed to create context: ${h instanceof Error ? h.message : "Unknown error"} in browser "${f.name}" (${f.browserType})`
3065
+ error: `Failed to create context: ${h instanceof Error ? h.message : "Unknown error"} in browser "${d.name}" (${d.browserType})`
2986
3066
  };
2987
3067
  }
2988
3068
  }
2989
- function $s(r, t) {
2990
- r(
3069
+ function Rs(t, r) {
3070
+ t(
2991
3071
  "playwright-context-create",
2992
3072
  {
2993
3073
  title: "Create Browser Context",
2994
3074
  description: "Create a new browser context. Prefer page-goto if you need to immediately create a context, page and navigate",
2995
- inputSchema: xe.shape
3075
+ inputSchema: $e.shape
2996
3076
  },
2997
3077
  async (s, o) => {
2998
- const e = await Ct(s, t, o);
3078
+ const e = await Dt(s, r, o);
2999
3079
  if (e.error != null)
3000
3080
  return `Method: playwright-context-create(${JSON.stringify(s)})
3001
3081
  ❌ Error: ${e.error}`;
@@ -3006,18 +3086,18 @@ function $s(r, t) {
3006
3086
  }
3007
3087
  );
3008
3088
  }
3009
- const vt = p.object({
3089
+ const Rt = p.object({
3010
3090
  browserName: p.string().optional().describe(
3011
3091
  "Name of browser to list contexts from. If not specified, lists contexts from all browsers"
3012
3092
  )
3013
3093
  });
3014
- async function Is(r, t, s) {
3094
+ async function Fs(t, r, s) {
3015
3095
  let o;
3016
3096
  try {
3017
- o = vt.parse(r);
3097
+ o = Rt.parse(t);
3018
3098
  } catch (i) {
3019
3099
  return {
3020
- error: B(i)
3100
+ error: F(i)
3021
3101
  };
3022
3102
  }
3023
3103
  const { browserName: e } = o;
@@ -3048,16 +3128,16 @@ async function Is(r, t, s) {
3048
3128
  contextsByBrowser: a
3049
3129
  };
3050
3130
  }
3051
- function Ms(r, t) {
3052
- r(
3131
+ function Bs(t, r) {
3132
+ t(
3053
3133
  "playwright-context-list",
3054
3134
  {
3055
3135
  title: "List Browser Contexts",
3056
3136
  description: "List active browser contexts",
3057
- inputSchema: vt.shape
3137
+ inputSchema: Rt.shape
3058
3138
  },
3059
3139
  async (s, o) => {
3060
- const e = await Is(s, t, o);
3140
+ const e = await Fs(s, r, o);
3061
3141
  if ("error" in e)
3062
3142
  return `Method: playwright-context-list(${JSON.stringify(s)})
3063
3143
  ❌ Error: ${e.error}`;
@@ -3070,7 +3150,7 @@ function Ms(r, t) {
3070
3150
  }
3071
3151
  );
3072
3152
  }
3073
- const Nt = p.object({
3153
+ const Ft = p.object({
3074
3154
  names: p.array(p.string()).optional().describe(
3075
3155
  "Names of contexts to close. If not specified, closes all contexts"
3076
3156
  ),
@@ -3078,13 +3158,13 @@ const Nt = p.object({
3078
3158
  "Name of browser to close contexts from. If not specified, searches all browsers"
3079
3159
  )
3080
3160
  });
3081
- async function Ts(r, t, s) {
3161
+ async function Ls(t, r, s) {
3082
3162
  let o;
3083
3163
  try {
3084
- o = Nt.parse(r);
3164
+ o = Ft.parse(t);
3085
3165
  } catch (u) {
3086
3166
  return {
3087
- error: B(u)
3167
+ error: F(u)
3088
3168
  };
3089
3169
  }
3090
3170
  const { names: e, browserName: n } = o;
@@ -3100,18 +3180,18 @@ async function Ts(r, t, s) {
3100
3180
  return {
3101
3181
  error: `Browser "${n}" not found`
3102
3182
  };
3103
- e ? e.forEach((d) => {
3104
- const f = u.contexts.get(d);
3105
- f ? l.push(f) : c.push(
3106
- `Context "${d}" not found in browser "${u.name}" (${u.browserType})`
3183
+ e ? e.forEach((f) => {
3184
+ const d = u.contexts.get(f);
3185
+ d ? l.push(d) : c.push(
3186
+ `Context "${f}" not found in browser "${u.name}" (${u.browserType})`
3107
3187
  );
3108
3188
  }) : l = Array.from(u.contexts.values());
3109
3189
  } else if (e)
3110
3190
  for (const u of a.browsers.values())
3111
- e.forEach((d) => {
3112
- const f = u.contexts.get(d);
3113
- f ? l.push(f) : c.push(
3114
- `Context "${d}" not found in browser "${u.name}" (${u.browserType})`
3191
+ e.forEach((f) => {
3192
+ const d = u.contexts.get(f);
3193
+ d ? l.push(d) : c.push(
3194
+ `Context "${f}" not found in browser "${u.name}" (${u.browserType})`
3115
3195
  );
3116
3196
  });
3117
3197
  else
@@ -3121,9 +3201,9 @@ async function Ts(r, t, s) {
3121
3201
  l.map(async (u) => {
3122
3202
  try {
3123
3203
  await u.context.close(), u.browserInfo.contexts.delete(u.name), i.push(u);
3124
- } catch (d) {
3204
+ } catch (f) {
3125
3205
  c.push(
3126
- `Failed to close context "${u.name}" (${u.browserInfo.name}) (${u.browserInfo.browserType}): ${d instanceof Error ? d.message : "Unknown error"}`
3206
+ `Failed to close context "${u.name}" (${u.browserInfo.name}) (${u.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
3127
3207
  );
3128
3208
  }
3129
3209
  })
@@ -3132,16 +3212,16 @@ async function Ts(r, t, s) {
3132
3212
  ...c.length > 0 && { errors: c }
3133
3213
  };
3134
3214
  }
3135
- function Cs(r, t) {
3136
- r(
3215
+ function Ps(t, r) {
3216
+ t(
3137
3217
  "playwright-context-close",
3138
3218
  {
3139
3219
  title: "Close Browser Contexts",
3140
3220
  description: "Close browser contexts. Automatically closes all pages within the contexts",
3141
- inputSchema: Nt.shape
3221
+ inputSchema: Ft.shape
3142
3222
  },
3143
3223
  async (s, o) => {
3144
- const e = await Ts(s, t, o);
3224
+ const e = await Ls(s, r, o);
3145
3225
  if ("error" in e)
3146
3226
  return `Method: playwright-context-close(${JSON.stringify(s)})
3147
3227
  ❌ Error: ${e.error}`;
@@ -3158,8 +3238,8 @@ ${n.join(`
3158
3238
  }
3159
3239
  );
3160
3240
  }
3161
- function vs() {
3162
- class r {
3241
+ function As() {
3242
+ class t {
3163
3243
  prevId = 0;
3164
3244
  objectToId = /* @__PURE__ */ new WeakMap();
3165
3245
  idToObject = /* @__PURE__ */ new Map();
@@ -3181,60 +3261,60 @@ function vs() {
3181
3261
  return u ?? (this.idToObject.delete(c), null);
3182
3262
  }
3183
3263
  }
3184
- function t(i, c, l) {
3264
+ function r(i, c, l) {
3185
3265
  let u = null;
3186
- for (let d = 0, f = c.length; d < f; d++) {
3187
- const h = c[d], m = i(h), g = m == null ? null : t(i, m, l), y = l(h, g);
3266
+ for (let f = 0, d = c.length; f < d; f++) {
3267
+ const h = c[f], g = i(h), m = g == null ? null : r(i, g, l), y = l(h, m);
3188
3268
  y != null && (u == null && (u = []), u.push(y));
3189
3269
  }
3190
3270
  return u;
3191
3271
  }
3192
3272
  function s(i) {
3193
- const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: d } = i, f = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = t(
3273
+ const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = i, d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m = r(
3194
3274
  l,
3195
3275
  u,
3196
- (w, M) => {
3197
- const N = d(w, M);
3198
- if (w != null && N != null) {
3276
+ (w, I) => {
3277
+ const v = f(w, I);
3278
+ if (w != null && v != null) {
3199
3279
  const b = c(w);
3200
- f.set(b, N), h.set(N, b);
3280
+ d.set(b, v), h.set(v, b);
3201
3281
  }
3202
- return N != null && M != null && m.set(
3203
- h.get(N),
3204
- M.map((b) => h.get(b))
3205
- ), N;
3282
+ return v != null && I != null && g.set(
3283
+ h.get(v),
3284
+ I.map((b) => h.get(b))
3285
+ ), v;
3206
3286
  }
3207
- ), y = d(null, g);
3287
+ ), y = f(null, m);
3208
3288
  if (y == null)
3209
3289
  throw new Error("Impossible behavior: rootNode == null");
3210
- return f.set(null, y), g != null && m.set(
3290
+ return d.set(null, y), m != null && g.set(
3211
3291
  null,
3212
- g.map((w) => h.get(w))
3292
+ m.map((w) => h.get(w))
3213
3293
  ), {
3214
- idToNode: f,
3215
- idToChildIds: m
3294
+ idToNode: d,
3295
+ idToChildIds: g
3216
3296
  };
3217
3297
  }
3218
3298
  const o = (i) => i instanceof HTMLElement ? i.childNodes : null;
3219
3299
  function e(i) {
3220
3300
  return function(l, u) {
3221
- const d = u != null && u.length > 0;
3222
- let f = !1, h = null, m = null;
3301
+ const f = u != null && u.length > 0;
3302
+ let d = !1, h = null, g = null;
3223
3303
  if (l instanceof HTMLElement) {
3224
- if (h = n.getOrCreateId(l), m = l.tagName.toLowerCase(), f = l.matches(i.cssSelector), !f && !d)
3304
+ if (h = n.getOrCreateId(l), g = l.tagName.toLowerCase(), d = l.matches(i.cssSelector), !d && !f)
3225
3305
  return null;
3226
3306
  } else if (l == null)
3227
- h = null, m = null, f = !1;
3307
+ h = null, g = null, d = !1;
3228
3308
  else
3229
3309
  return null;
3230
3310
  return {
3231
3311
  uid: h,
3232
- tagName: m,
3233
- isMatched: f
3312
+ tagName: g,
3313
+ isMatched: d
3234
3314
  };
3235
3315
  };
3236
3316
  }
3237
- const n = new r();
3317
+ const n = new t();
3238
3318
  function a(i) {
3239
3319
  const c = e(i);
3240
3320
  return s({
@@ -3246,22 +3326,22 @@ function vs() {
3246
3326
  }
3247
3327
  window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = a;
3248
3328
  }
3249
- const Ns = `(function (){function __name(fn){return fn};${vs.toString()}; setupPageGlobals();})()`, $e = p.object({
3329
+ const zs = `(function (){function __name(fn){return fn};${As.toString()}; setupPageGlobals();})()`, Ie = p.object({
3250
3330
  contextName: p.string().optional().describe("Name of previously created context, to use"),
3251
- context: xe.optional().describe(
3331
+ context: $e.optional().describe(
3252
3332
  "Context creation options JSON to automatically create context"
3253
3333
  ),
3254
3334
  name: p.string().describe(
3255
3335
  "Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
3256
3336
  )
3257
3337
  });
3258
- async function Et(r, t, s) {
3338
+ async function Bt(t, r, s) {
3259
3339
  let o;
3260
3340
  try {
3261
- o = $e.parse(r);
3262
- } catch (d) {
3341
+ o = Ie.parse(t);
3342
+ } catch (f) {
3263
3343
  return {
3264
- error: B(d)
3344
+ error: F(f)
3265
3345
  };
3266
3346
  }
3267
3347
  const { name: e, contextName: n, context: a } = o;
@@ -3276,9 +3356,9 @@ async function Et(r, t, s) {
3276
3356
  };
3277
3357
  let c = !1, l = !1, u;
3278
3358
  if (n) {
3279
- for (const d of i.browsers.values())
3280
- if (d.contexts.has(n)) {
3281
- u = d.contexts.get(n);
3359
+ for (const f of i.browsers.values())
3360
+ if (f.contexts.has(n)) {
3361
+ u = f.contexts.get(n);
3282
3362
  break;
3283
3363
  }
3284
3364
  if (!u)
@@ -3286,46 +3366,46 @@ async function Et(r, t, s) {
3286
3366
  error: `Context "${n}" not found`
3287
3367
  };
3288
3368
  } else if (a) {
3289
- const d = await Ct(a, t, s);
3290
- if (d.error != null)
3369
+ const f = await Dt(a, r, s);
3370
+ if (f.error != null)
3291
3371
  return {
3292
- error: d.error
3372
+ error: f.error
3293
3373
  };
3294
- u = d.contextInfo, c = d.browserInfoCreated, l = !0;
3374
+ u = f.contextInfo, c = f.browserInfoCreated, l = !0;
3295
3375
  } else
3296
3376
  return {
3297
3377
  error: "Either contextName or context must be provided"
3298
3378
  };
3299
3379
  try {
3300
- const d = await u.context.newPage();
3301
- await d.addInitScript(Ns), await d.goto("about:blank");
3302
- const f = {
3380
+ const f = await u.context.newPage();
3381
+ await f.addInitScript(zs), await f.goto("about:blank");
3382
+ const d = {
3303
3383
  contextInfo: u,
3304
3384
  name: e,
3305
- page: d,
3385
+ page: f,
3306
3386
  domSnapshots: /* @__PURE__ */ new Map()
3307
3387
  };
3308
- return u.pages.set(e, f), {
3388
+ return u.pages.set(e, d), {
3309
3389
  browserInfoCreated: c,
3310
3390
  contextInfoCreated: l,
3311
- pageInfo: f
3391
+ pageInfo: d
3312
3392
  };
3313
- } catch (d) {
3393
+ } catch (f) {
3314
3394
  return {
3315
- error: `Failed to create page: ${d instanceof Error ? d.message : "Unknown error"} in context "${u.name}" in browser "${u.browserInfo.name}" (${u.browserInfo.browserType})`
3395
+ error: `Failed to create page: ${f instanceof Error ? f.message : "Unknown error"} in context "${u.name}" in browser "${u.browserInfo.name}" (${u.browserInfo.browserType})`
3316
3396
  };
3317
3397
  }
3318
3398
  }
3319
- function Es(r, t) {
3320
- r(
3399
+ function Us(t, r) {
3400
+ t(
3321
3401
  "playwright-page-create",
3322
3402
  {
3323
3403
  title: "Create Page",
3324
3404
  description: "Create a new page. Prefer page-goto if you need to immediately create a page and navigate",
3325
- inputSchema: $e.shape
3405
+ inputSchema: Ie.shape
3326
3406
  },
3327
3407
  async (s, o) => {
3328
- const e = await Et(s, t, o);
3408
+ const e = await Bt(s, r, o);
3329
3409
  if (e.error != null)
3330
3410
  return `Method: playwright-page-create(${JSON.stringify(s)})
3331
3411
  ❌ Error: ${e.error}`;
@@ -3337,7 +3417,7 @@ function Es(r, t) {
3337
3417
  }
3338
3418
  );
3339
3419
  }
3340
- const kt = p.object({
3420
+ const Lt = p.object({
3341
3421
  contextName: p.string().optional().describe(
3342
3422
  "Name of context to list pages from. If not specified, lists pages from all contexts"
3343
3423
  ),
@@ -3345,13 +3425,13 @@ const kt = p.object({
3345
3425
  "Name of browser to search in. If not specified, searches all browsers"
3346
3426
  )
3347
3427
  });
3348
- async function ks(r, t, s) {
3428
+ async function qs(t, r, s) {
3349
3429
  let o;
3350
3430
  try {
3351
- o = kt.parse(r);
3431
+ o = Lt.parse(t);
3352
3432
  } catch (c) {
3353
3433
  return {
3354
- error: B(c)
3434
+ error: F(c)
3355
3435
  };
3356
3436
  }
3357
3437
  const { contextName: e, browserName: n } = o;
@@ -3409,16 +3489,16 @@ async function ks(r, t, s) {
3409
3489
  pagesByContext: i
3410
3490
  };
3411
3491
  }
3412
- function Os(r, t) {
3413
- r(
3492
+ function _s(t, r) {
3493
+ t(
3414
3494
  "playwright-page-list",
3415
3495
  {
3416
3496
  title: "List Pages",
3417
3497
  description: "List active pages",
3418
- inputSchema: kt.shape
3498
+ inputSchema: Lt.shape
3419
3499
  },
3420
3500
  async (s, o) => {
3421
- const e = await ks(s, t, o);
3501
+ const e = await qs(s, r, o);
3422
3502
  if ("error" in e)
3423
3503
  return `Method: playwright-page-list(${JSON.stringify(s)})
3424
3504
  ❌ Error: ${e.error}`;
@@ -3431,7 +3511,7 @@ function Os(r, t) {
3431
3511
  }
3432
3512
  );
3433
3513
  }
3434
- const Ot = p.object({
3514
+ const Pt = p.object({
3435
3515
  names: p.array(p.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
3436
3516
  contextName: p.string().optional().describe(
3437
3517
  "Name of context to close pages from. If not specified, searches all contexts"
@@ -3440,13 +3520,13 @@ const Ot = p.object({
3440
3520
  "Name of browser to search in. If not specified, searches all browsers"
3441
3521
  )
3442
3522
  });
3443
- async function Ds(r, t, s) {
3523
+ async function Gs(t, r, s) {
3444
3524
  let o;
3445
3525
  try {
3446
- o = Ot.parse(r);
3447
- } catch (d) {
3526
+ o = Pt.parse(t);
3527
+ } catch (f) {
3448
3528
  return {
3449
- error: B(d)
3529
+ error: F(f)
3450
3530
  };
3451
3531
  }
3452
3532
  const { names: e, contextName: n, browserName: a } = o;
@@ -3457,59 +3537,59 @@ async function Ds(r, t, s) {
3457
3537
  const i = j(s.sessionId), c = [], l = [];
3458
3538
  let u = [];
3459
3539
  if (a) {
3460
- const d = i.browsers.get(a);
3461
- if (!d)
3540
+ const f = i.browsers.get(a);
3541
+ if (!f)
3462
3542
  return {
3463
3543
  error: `Browser "${a}" not found`
3464
3544
  };
3465
3545
  if (n) {
3466
- const f = d.contexts.get(n);
3467
- if (!f)
3546
+ const d = f.contexts.get(n);
3547
+ if (!d)
3468
3548
  return {
3469
- error: `Context "${n}" not found in browser "${d.name}" (${d.browserType})`
3549
+ error: `Context "${n}" not found in browser "${f.name}" (${f.browserType})`
3470
3550
  };
3471
3551
  e ? e.forEach((h) => {
3472
- const m = f.pages.get(h);
3473
- m ? u.push(m) : l.push(
3474
- `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3552
+ const g = d.pages.get(h);
3553
+ g ? u.push(g) : l.push(
3554
+ `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3475
3555
  );
3476
- }) : u = Array.from(f.pages.values());
3556
+ }) : u = Array.from(d.pages.values());
3477
3557
  } else
3478
- for (const f of d.contexts.values())
3558
+ for (const d of f.contexts.values())
3479
3559
  e ? e.forEach((h) => {
3480
- const m = f.pages.get(h);
3481
- m ? u.push(m) : l.push(
3482
- `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3560
+ const g = d.pages.get(h);
3561
+ g ? u.push(g) : l.push(
3562
+ `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3483
3563
  );
3484
- }) : u.push(...Array.from(f.pages.values()));
3564
+ }) : u.push(...Array.from(d.pages.values()));
3485
3565
  } else if (n)
3486
- for (const d of i.browsers.values()) {
3487
- const f = d.contexts.get(n);
3488
- f && (e ? e.forEach((h) => {
3489
- const m = f.pages.get(h);
3490
- m ? u.push(m) : l.push(
3491
- `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3566
+ for (const f of i.browsers.values()) {
3567
+ const d = f.contexts.get(n);
3568
+ d && (e ? e.forEach((h) => {
3569
+ const g = d.pages.get(h);
3570
+ g ? u.push(g) : l.push(
3571
+ `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3492
3572
  );
3493
- }) : u.push(...Array.from(f.pages.values())));
3573
+ }) : u.push(...Array.from(d.pages.values())));
3494
3574
  }
3495
3575
  else
3496
- for (const d of i.browsers.values())
3497
- for (const f of d.contexts.values())
3576
+ for (const f of i.browsers.values())
3577
+ for (const d of f.contexts.values())
3498
3578
  e ? e.forEach((h) => {
3499
- const m = f.pages.get(h);
3500
- m ? u.push(m) : l.push(
3501
- `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3579
+ const g = d.pages.get(h);
3580
+ g ? u.push(g) : l.push(
3581
+ `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3502
3582
  );
3503
- }) : u.push(...Array.from(f.pages.values()));
3583
+ }) : u.push(...Array.from(d.pages.values()));
3504
3584
  return await Promise.all(
3505
- u.map(async (d) => {
3585
+ u.map(async (f) => {
3506
3586
  try {
3507
- await d.page.close(), d.contextInfo.pages.delete(d.name), c.push(
3508
- `${d.name} (${d.contextInfo.name}) (${d.contextInfo.browserInfo.name}) (${d.contextInfo.browserInfo.browserType})`
3587
+ await f.page.close(), f.contextInfo.pages.delete(f.name), c.push(
3588
+ `${f.name} (${f.contextInfo.name}) (${f.contextInfo.browserInfo.name}) (${f.contextInfo.browserInfo.browserType})`
3509
3589
  );
3510
- } catch (f) {
3590
+ } catch (d) {
3511
3591
  l.push(
3512
- `Failed to close page "${d.name}" (${d.contextInfo.name}) (${d.contextInfo.browserInfo.name}) (${d.contextInfo.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
3592
+ `Failed to close page "${f.name}" (${f.contextInfo.name}) (${f.contextInfo.browserInfo.name}) (${f.contextInfo.browserInfo.browserType}): ${d instanceof Error ? d.message : "Unknown error"}`
3513
3593
  );
3514
3594
  }
3515
3595
  })
@@ -3518,16 +3598,16 @@ async function Ds(r, t, s) {
3518
3598
  ...l.length > 0 && { errors: l }
3519
3599
  };
3520
3600
  }
3521
- function Rs(r, t) {
3522
- r(
3601
+ function Js(t, r) {
3602
+ t(
3523
3603
  "playwright-page-close",
3524
3604
  {
3525
3605
  title: "Close Pages",
3526
3606
  description: "Close pages",
3527
- inputSchema: Ot.shape
3607
+ inputSchema: Pt.shape
3528
3608
  },
3529
3609
  async (s, o) => {
3530
- const e = await Ds(s, t, o);
3610
+ const e = await Gs(s, r, o);
3531
3611
  if ("error" in e)
3532
3612
  return `Method: playwright-page-close(${JSON.stringify(s)})
3533
3613
  ❌ Error: ${e.error}`;
@@ -3538,9 +3618,9 @@ ${n.join(`
3538
3618
  }
3539
3619
  );
3540
3620
  }
3541
- const Dt = p.object({
3621
+ const At = p.object({
3542
3622
  pageName: p.string().optional().describe("Name of previously created page to navigate"),
3543
- page: $e.optional().describe(
3623
+ page: Ie.optional().describe(
3544
3624
  "Page creation options JSON to automatically create page"
3545
3625
  ),
3546
3626
  url: p.string().describe("URL to navigate to"),
@@ -3553,13 +3633,13 @@ const Dt = p.object({
3553
3633
  - 'commit': network response received and document started loading`
3554
3634
  )
3555
3635
  });
3556
- async function Fs(r, t, s) {
3636
+ async function js(t, r, s) {
3557
3637
  let o;
3558
3638
  try {
3559
- o = Dt.parse(r);
3560
- } catch (m) {
3639
+ o = At.parse(t);
3640
+ } catch (g) {
3561
3641
  return {
3562
- error: B(m)
3642
+ error: F(g)
3563
3643
  };
3564
3644
  }
3565
3645
  const { pageName: e, page: n, url: a, timeout: i, waitUntil: c } = o;
@@ -3572,12 +3652,12 @@ async function Fs(r, t, s) {
3572
3652
  return {
3573
3653
  error: "Either pageName or page must be provided, not both"
3574
3654
  };
3575
- let u = !1, d = !1, f = !1, h;
3655
+ let u = !1, f = !1, d = !1, h;
3576
3656
  if (e) {
3577
- for (const m of l.browsers.values()) {
3578
- for (const g of m.contexts.values())
3579
- if (g.pages.has(e)) {
3580
- h = g.pages.get(e);
3657
+ for (const g of l.browsers.values()) {
3658
+ for (const m of g.contexts.values())
3659
+ if (m.pages.has(e)) {
3660
+ h = m.pages.get(e);
3581
3661
  break;
3582
3662
  }
3583
3663
  if (h) break;
@@ -3587,50 +3667,50 @@ async function Fs(r, t, s) {
3587
3667
  error: `Page "${e}" not found`
3588
3668
  };
3589
3669
  } else if (n) {
3590
- const m = await Et(n, t, s);
3591
- if (m.error != null)
3670
+ const g = await Bt(n, r, s);
3671
+ if (g.error != null)
3592
3672
  return {
3593
- error: m.error
3673
+ error: g.error
3594
3674
  };
3595
- h = m.pageInfo, u = m.browserInfoCreated, d = m.contextInfoCreated, f = !0;
3675
+ h = g.pageInfo, u = g.browserInfoCreated, f = g.contextInfoCreated, d = !0;
3596
3676
  } else
3597
3677
  return {
3598
3678
  error: "Either pageName or page must be provided"
3599
3679
  };
3600
3680
  try {
3601
- const m = await h.page.goto(a, {
3681
+ const g = await h.page.goto(a, {
3602
3682
  timeout: i * 1e3,
3603
3683
  waitUntil: c
3604
3684
  });
3605
- return m ? {
3685
+ return g ? {
3606
3686
  browserInfoCreated: u,
3607
- contextInfoCreated: d,
3608
- pageInfoCreated: f,
3687
+ contextInfoCreated: f,
3688
+ pageInfoCreated: d,
3609
3689
  pageInfo: h,
3610
- status: m.status()
3690
+ status: g.status()
3611
3691
  } : {
3612
3692
  browserInfoCreated: u,
3613
- contextInfoCreated: d,
3614
- pageInfoCreated: f,
3693
+ contextInfoCreated: f,
3694
+ pageInfoCreated: d,
3615
3695
  pageInfo: h,
3616
3696
  status: 200
3617
3697
  };
3618
- } catch (m) {
3698
+ } catch (g) {
3619
3699
  return {
3620
- error: `Failed to navigate to "${a}": ${m instanceof Error ? m.message : "Unknown error"}`
3700
+ error: `Failed to navigate to "${a}": ${g instanceof Error ? g.message : "Unknown error"}`
3621
3701
  };
3622
3702
  }
3623
3703
  }
3624
- function Bs(r, t) {
3625
- r(
3704
+ function Ks(t, r) {
3705
+ t(
3626
3706
  "playwright-page-goto",
3627
3707
  {
3628
3708
  title: "Navigate Page",
3629
3709
  description: "Navigate page to URL. Use for manual browser interaction",
3630
- inputSchema: Dt.shape
3710
+ inputSchema: At.shape
3631
3711
  },
3632
3712
  async (s, o) => {
3633
- const e = await Fs(s, t, o);
3713
+ const e = await js(s, r, o);
3634
3714
  if (e.error != null)
3635
3715
  return `Method: playwright-page-goto(${JSON.stringify(s)})
3636
3716
  ❌ Error: ${e.error}`;
@@ -3643,19 +3723,19 @@ function Bs(r, t) {
3643
3723
  }
3644
3724
  );
3645
3725
  }
3646
- const Ie = p.object({
3726
+ const Me = p.object({
3647
3727
  name: p.string().describe(
3648
3728
  "Unique name for the DOM snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
3649
3729
  ),
3650
3730
  cssSelector: p.string().describe("CSS selector to capture page content")
3651
3731
  });
3652
- async function Rt(r, t, s) {
3732
+ async function zt(t, r, s) {
3653
3733
  let o;
3654
3734
  try {
3655
- o = Ie.parse(r);
3735
+ o = Me.parse(t);
3656
3736
  } catch (c) {
3657
3737
  return {
3658
- error: B(c)
3738
+ error: F(c)
3659
3739
  };
3660
3740
  }
3661
3741
  const { name: e, cssSelector: n } = o;
@@ -3671,47 +3751,47 @@ async function Rt(r, t, s) {
3671
3751
  snapshotQuery: i
3672
3752
  };
3673
3753
  }
3674
- function Ls(r, t) {
3675
- r(
3754
+ function Ws(t, r) {
3755
+ t(
3676
3756
  "playwright-dom-snapshot-query-create",
3677
3757
  {
3678
3758
  title: "Create DOM Snapshot Query",
3679
3759
  description: "Create a DOM snapshot query. Prefer dom-snapshot-browse if you need to immediately create a query and snapshot and browse it",
3680
- inputSchema: Ie.shape
3760
+ inputSchema: Me.shape
3681
3761
  },
3682
3762
  async (s, o) => {
3683
- const e = await Rt(s, t, o);
3763
+ const e = await zt(s, r, o);
3684
3764
  return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3685
3765
  ❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3686
3766
  ✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
3687
3767
  }
3688
3768
  );
3689
3769
  }
3690
- function Ps(r) {
3770
+ function Hs(t) {
3691
3771
  return function(s, o) {
3692
3772
  let e, n = 0;
3693
3773
  const a = o ? o.length : 0;
3694
- let i = 1, c = 0, l = 0, u, d;
3774
+ let i = 1, c = 0, l = 0, u, f;
3695
3775
  if (o)
3696
- for (let m = 0; m < o.length; m++) {
3697
- const g = o[m];
3698
- n += g.countMatched, i += g.countTotal, c += g.tokens, l += g.tokensTotal;
3776
+ for (let g = 0; g < o.length; g++) {
3777
+ const m = o[g];
3778
+ n += m.countMatched, i += m.countTotal, c += m.tokens, l += m.tokensTotal;
3699
3779
  }
3700
- s ? (u = s.uid, d = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, d = null, e = !1);
3701
- let f;
3702
- d ? f = {
3780
+ s ? (u = s.uid, f = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, f = null, e = !1);
3781
+ let d;
3782
+ f ? d = {
3703
3783
  indent: !0,
3704
- textOpen: `<${d} uid:${u}>`,
3705
- textClose: `</${d}>`
3706
- } : f = {
3784
+ textOpen: `<${f} uid:${u}>`,
3785
+ textClose: `</${f}>`
3786
+ } : d = {
3707
3787
  indent: !0,
3708
3788
  textOpen: `<root uid:${u}>`,
3709
3789
  textClose: "</root>"
3710
3790
  };
3711
- const h = ht(f);
3791
+ const h = bt(d);
3712
3792
  return l += h, {
3713
3793
  uid: u,
3714
- tagName: d,
3794
+ tagName: f,
3715
3795
  isMatched: e,
3716
3796
  countMatched: n,
3717
3797
  countChilds: a,
@@ -3719,12 +3799,12 @@ function Ps(r) {
3719
3799
  tokens: h,
3720
3800
  tokensChilds: c,
3721
3801
  tokensTotal: l,
3722
- text: f
3802
+ text: d
3723
3803
  };
3724
3804
  };
3725
3805
  }
3726
- function As(r, t) {
3727
- const s = ae(t), o = s.getChilds(s.root), e = ft({
3806
+ function Qs(t, r) {
3807
+ const s = le(r), o = s.getChilds(s.root), e = yt({
3728
3808
  getId: (n) => {
3729
3809
  const a = s.getId(n);
3730
3810
  if (a == null)
@@ -3734,28 +3814,28 @@ function As(r, t) {
3734
3814
  return a;
3735
3815
  },
3736
3816
  getChilds: (n) => s.getChilds(n),
3737
- createSnapshotNode: Ps(),
3817
+ createSnapshotNode: Hs(),
3738
3818
  rootNodes: o ?? []
3739
3819
  });
3740
- return ae(e);
3820
+ return le(e);
3741
3821
  }
3742
- const Me = p.object({
3822
+ const Te = p.object({
3743
3823
  pageName: p.string().describe("Name of previously created page, to create snapshot from"),
3744
3824
  queryName: p.string().optional().describe("Name of previously created DOM snapshot query, to use"),
3745
- query: Ie.optional().describe(
3825
+ query: Me.optional().describe(
3746
3826
  "DOM snapshot query creation options JSON to automatically create query"
3747
3827
  ),
3748
3828
  name: p.string().describe(
3749
3829
  "Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
3750
3830
  )
3751
3831
  });
3752
- async function Ft(r, t, s) {
3832
+ async function Ut(t, r, s) {
3753
3833
  let o;
3754
3834
  try {
3755
- o = Me.parse(r);
3756
- } catch (f) {
3835
+ o = Te.parse(t);
3836
+ } catch (d) {
3757
3837
  return {
3758
- error: B(f)
3838
+ error: F(d)
3759
3839
  };
3760
3840
  }
3761
3841
  const { pageName: e, queryName: n, query: a, name: i } = o;
@@ -3765,8 +3845,8 @@ async function Ft(r, t, s) {
3765
3845
  };
3766
3846
  const c = j(s.sessionId);
3767
3847
  let l;
3768
- for (const f of c.browsers.values()) {
3769
- for (const h of f.contexts.values())
3848
+ for (const d of c.browsers.values()) {
3849
+ for (const h of d.contexts.values())
3770
3850
  if (h.pages.has(e)) {
3771
3851
  l = h.pages.get(e);
3772
3852
  break;
@@ -3781,70 +3861,70 @@ async function Ft(r, t, s) {
3781
3861
  return {
3782
3862
  error: "Either queryName or query must be provided, not both"
3783
3863
  };
3784
- let u, d = !1;
3864
+ let u, f = !1;
3785
3865
  if (n) {
3786
- const f = c.domSnapshotQueries.get(n);
3787
- if (!f)
3866
+ const d = c.domSnapshotQueries.get(n);
3867
+ if (!d)
3788
3868
  return {
3789
3869
  error: `DOM snapshot query "${n}" not found`
3790
3870
  };
3791
- u = f;
3871
+ u = d;
3792
3872
  } else if (a) {
3793
- const f = await Rt(
3873
+ const d = await zt(
3794
3874
  a,
3795
- t,
3875
+ r,
3796
3876
  s
3797
3877
  );
3798
- if (f.error != null)
3878
+ if (d.error != null)
3799
3879
  return {
3800
- error: f.error
3880
+ error: d.error
3801
3881
  };
3802
- u = f.snapshotQuery, d = !0;
3882
+ u = d.snapshotQuery, f = !0;
3803
3883
  } else
3804
3884
  return {
3805
3885
  error: "Either queryName or query must be provided"
3806
3886
  };
3807
3887
  try {
3808
- const f = await l.page.evaluate(
3888
+ const d = await l.page.evaluate(
3809
3889
  (y) => {
3810
3890
  const w = window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom;
3811
3891
  if (!w)
3812
3892
  throw new Error("DOM snapshot global function not initialized");
3813
- const M = w(y);
3893
+ const I = w(y);
3814
3894
  return {
3815
- idToNode: Array.from(M.idToNode.entries()),
3816
- idToChildIds: Array.from(M.idToChildIds.entries())
3895
+ idToNode: Array.from(I.idToNode.entries()),
3896
+ idToChildIds: Array.from(I.idToChildIds.entries())
3817
3897
  };
3818
3898
  },
3819
3899
  u
3820
3900
  ), h = {
3821
- idToNode: new Map(f.idToNode),
3822
- idToChildIds: new Map(f.idToChildIds)
3823
- }, m = As(u, h), g = {
3901
+ idToNode: new Map(d.idToNode),
3902
+ idToChildIds: new Map(d.idToChildIds)
3903
+ }, g = Qs(u, h), m = {
3824
3904
  name: i,
3825
3905
  query: u,
3826
- tree: m
3906
+ tree: g
3827
3907
  };
3828
- return l.domSnapshots.set(i, g), {
3829
- domSnapshot: g,
3830
- queryCreated: d
3908
+ return l.domSnapshots.set(i, m), {
3909
+ domSnapshot: m,
3910
+ queryCreated: f
3831
3911
  };
3832
- } catch (f) {
3912
+ } catch (d) {
3833
3913
  return {
3834
- error: `Failed to create DOM snapshot: ${f instanceof Error ? f.message : "Unknown error"}`
3914
+ error: `Failed to create DOM snapshot: ${d instanceof Error ? d.message : "Unknown error"}`
3835
3915
  };
3836
3916
  }
3837
3917
  }
3838
- function zs(r, t) {
3839
- r(
3918
+ function Ys(t, r) {
3919
+ t(
3840
3920
  "playwright-dom-snapshot-create",
3841
3921
  {
3842
3922
  title: "Create DOM Snapshot",
3843
3923
  description: "Create a DOM snapshot of page. Use this to capture webpage state for later browsing. Prefer dom-snapshot-browse if you need to immediately create and browse a snapshot",
3844
- inputSchema: Me.shape
3924
+ inputSchema: Te.shape
3845
3925
  },
3846
3926
  async (s, o) => {
3847
- const e = await Ft(s, t, o);
3927
+ const e = await Ut(s, r, o);
3848
3928
  if (e.error != null)
3849
3929
  return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
3850
3930
  ❌ Error: ${e.error}`;
@@ -3855,23 +3935,23 @@ function zs(r, t) {
3855
3935
  }
3856
3936
  );
3857
3937
  }
3858
- class Us {
3938
+ class Vs {
3859
3939
  tokens = 20;
3860
- getReportText = (t) => ({
3940
+ getReportText = (r) => ({
3861
3941
  indent: !0,
3862
- textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
3942
+ textOpen: `[${r.indexRange[0]}-${r.indexRange[1]}] see more ${r.countMatched} matched ${r.tokensGrouped} tokens`,
3863
3943
  textClose: null
3864
3944
  });
3865
- add = (t, s, o) => t == null ? {
3945
+ add = (r, s, o) => r == null ? {
3866
3946
  indexRange: [o, o],
3867
3947
  countGrouped: 1,
3868
3948
  countMatched: s.countMatched,
3869
3949
  tokensGrouped: s.tokens
3870
- } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
3950
+ } : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
3871
3951
  }
3872
- const Bt = p.object({
3952
+ const qt = p.object({
3873
3953
  snapshotName: p.string().optional().describe("Name of previously created DOM snapshot, to use"),
3874
- snapshot: Me.optional().describe(
3954
+ snapshot: Te.optional().describe(
3875
3955
  "DOM snapshot creation options JSON to automatically create snapshot"
3876
3956
  ),
3877
3957
  parentUid: p.number().optional().describe("UID of parent node to browse. Omit to browse the root node"),
@@ -3889,13 +3969,13 @@ const Bt = p.object({
3889
3969
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
3890
3970
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
3891
3971
  });
3892
- async function qs(r, t, s) {
3972
+ async function Zs(t, r, s) {
3893
3973
  let o;
3894
3974
  try {
3895
- o = Bt.parse(r);
3896
- } catch (g) {
3975
+ o = qt.parse(t);
3976
+ } catch (m) {
3897
3977
  return {
3898
- error: B(g)
3978
+ error: F(m)
3899
3979
  };
3900
3980
  }
3901
3981
  const {
@@ -3911,48 +3991,48 @@ async function qs(r, t, s) {
3911
3991
  return {
3912
3992
  error: "Session ID is required"
3913
3993
  };
3914
- const d = j(s.sessionId);
3994
+ const f = j(s.sessionId);
3915
3995
  if (e && n)
3916
3996
  return {
3917
3997
  error: "Either snapshotName or snapshot must be provided, not both"
3918
3998
  };
3919
- let f, h = !1, m = !1;
3999
+ let d, h = !1, g = !1;
3920
4000
  if (e) {
3921
- for (const g of d.browsers.values()) {
3922
- for (const y of g.contexts.values()) {
4001
+ for (const m of f.browsers.values()) {
4002
+ for (const y of m.contexts.values()) {
3923
4003
  for (const w of y.pages.values())
3924
4004
  if (w.domSnapshots.has(e)) {
3925
- f = w.domSnapshots.get(e);
4005
+ d = w.domSnapshots.get(e);
3926
4006
  break;
3927
4007
  }
3928
- if (f != null) break;
4008
+ if (d != null) break;
3929
4009
  }
3930
- if (f != null) break;
4010
+ if (d != null) break;
3931
4011
  }
3932
- if (f == null)
4012
+ if (d == null)
3933
4013
  return {
3934
4014
  error: `DOM snapshot "${e}" not found`
3935
4015
  };
3936
4016
  } else if (n) {
3937
- const g = await Ft(
4017
+ const m = await Ut(
3938
4018
  n,
3939
- t,
4019
+ r,
3940
4020
  s
3941
4021
  );
3942
- if (g.error != null)
4022
+ if (m.error != null)
3943
4023
  return {
3944
- error: g.error
4024
+ error: m.error
3945
4025
  };
3946
- f = g.domSnapshot, h = g.queryCreated, m = !0;
4026
+ d = m.domSnapshot, h = m.queryCreated, g = !0;
3947
4027
  } else
3948
4028
  return {
3949
4029
  error: "Either snapshotName or snapshot must be provided"
3950
4030
  };
3951
4031
  try {
3952
- const g = o.parentUid, y = pt({
3953
- tree: f.tree,
4032
+ const m = o.parentUid, y = St({
4033
+ tree: d.tree,
3954
4034
  request: {
3955
- parentNodeId: g,
4035
+ parentNodeId: m,
3956
4036
  childsIndexRange: a,
3957
4037
  limits: {
3958
4038
  maxCountTotal: i,
@@ -3961,32 +4041,32 @@ async function qs(r, t, s) {
3961
4041
  maxTokensGroup: u
3962
4042
  }
3963
4043
  },
3964
- indexRangeGroupStrategy: new Us()
3965
- }), w = mt(y);
4044
+ indexRangeGroupStrategy: new Vs()
4045
+ }), w = xt(y);
3966
4046
  return {
3967
- domSnapshot: f,
4047
+ domSnapshot: d,
3968
4048
  queryCreated: h,
3969
- snapshotCreated: m,
3970
- parentUid: g,
4049
+ snapshotCreated: g,
4050
+ parentUid: m,
3971
4051
  childsIndexRange: a,
3972
4052
  report: w
3973
4053
  };
3974
- } catch (g) {
4054
+ } catch (m) {
3975
4055
  return {
3976
- error: `Failed to browse DOM snapshot: ${g instanceof Error ? g.message : "Unknown error"}`
4056
+ error: `Failed to browse DOM snapshot: ${m instanceof Error ? m.message : "Unknown error"}`
3977
4057
  };
3978
4058
  }
3979
4059
  }
3980
- function _s(r, t) {
3981
- r(
4060
+ function Xs(t, r) {
4061
+ t(
3982
4062
  "playwright-dom-snapshot-browse",
3983
4063
  {
3984
4064
  title: "Browse DOM Snapshot",
3985
4065
  description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
3986
- inputSchema: Bt.shape
4066
+ inputSchema: qt.shape
3987
4067
  },
3988
4068
  async (s, o) => {
3989
- const e = await qs(s, t, o);
4069
+ const e = await Zs(s, r, o);
3990
4070
  if (e.error != null)
3991
4071
  return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
3992
4072
  ❌ Error: ${e.error}`;
@@ -4007,14 +4087,14 @@ ${e.report}`, n;
4007
4087
  }
4008
4088
  );
4009
4089
  }
4010
- function Gs(r, t) {
4011
- t.browserCreate && ws(r, t), t.browserList && bs(r, t), t.browserClose && xs(r, t), t.contextCreate && $s(r, t), t.contextList && Ms(r, t), t.contextClose && Cs(r, t), t.pageCreate && Es(r, t), t.pageList && Os(r, t), t.pageClose && Rs(r, t), t.pageGoto && Bs(r, t), t.domSnapshotQueryCreate && Ls(r, t), t.domSnapshotCreate && zs(r, t), t.domSnapshotBrowse && _s(r, t), console.log("Playwright manager");
4090
+ function eo(t, r) {
4091
+ r.browserCreate && vs(t, r), r.browserList && ks(t, r), r.browserClose && Ds(t, r), r.contextCreate && Rs(t, r), r.contextList && Bs(t, r), r.contextClose && Ps(t, r), r.pageCreate && Us(t, r), r.pageList && _s(t, r), r.pageClose && Js(t, r), r.pageGoto && Ks(t, r), r.domSnapshotQueryCreate && Ws(t, r), r.domSnapshotCreate && Ys(t, r), r.domSnapshotBrowse && Xs(t, r), console.log("Playwright manager");
4012
4092
  }
4013
- function Js(r) {
4014
- const { logFilePath: t } = r;
4093
+ function to(t) {
4094
+ const { logFilePath: r } = t;
4015
4095
  return async function(o, e, n, a) {
4016
- await ne({
4017
- logFilePath: t,
4096
+ await ie({
4097
+ logFilePath: r,
4018
4098
  message: "ERROR",
4019
4099
  data: {
4020
4100
  request: {
@@ -4032,31 +4112,31 @@ function Js(r) {
4032
4112
  });
4033
4113
  };
4034
4114
  }
4035
- function Lt() {
4115
+ function _t() {
4036
4116
  return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
4037
4117
  }
4038
- function js(r) {
4039
- const t = oe(), s = Ks();
4040
- return t.use(s), t;
4118
+ function ro(t) {
4119
+ const r = ne(), s = so();
4120
+ return r.use(s), r;
4041
4121
  }
4042
- function Ks(r) {
4043
- const t = oe.Router();
4044
- return t.use((s, o, e) => {
4122
+ function so(t) {
4123
+ const r = ne.Router();
4124
+ return r.use((s, o, e) => {
4045
4125
  s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
4046
- }), t.use(oe.json()), t;
4126
+ }), r.use(ne.json()), r;
4047
4127
  }
4048
- function Ws(r) {
4049
- const t = oe.Router();
4050
- return t.use(Vt({ authToken: r.authToken })), t.all("/mcp", rr(r)), t;
4128
+ function oo(t) {
4129
+ const r = ne.Router();
4130
+ return r.use(rr({ authToken: t.authToken })), r.all("/mcp", ar(t)), r;
4051
4131
  }
4052
- function Hs(r, t) {
4053
- return r.use(Js({ logFilePath: t.logFilePath })), new Promise((s, o) => {
4132
+ function no(t, r) {
4133
+ return t.use(to({ logFilePath: r.logFilePath })), new Promise((s, o) => {
4054
4134
  let e;
4055
4135
  const n = () => {
4056
4136
  s(e);
4057
4137
  };
4058
4138
  try {
4059
- e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (a) => {
4139
+ e = r.host ? t.listen(r.port ?? 0, r.host, n) : t.listen(r.port ?? 0, n), e.addListener("error", (a) => {
4060
4140
  o(a);
4061
4141
  });
4062
4142
  } catch (a) {
@@ -4064,63 +4144,65 @@ function Hs(r, t) {
4064
4144
  }
4065
4145
  });
4066
4146
  }
4067
- function Qs(r, t) {
4068
- if (!r.address())
4069
- throw new Error("Server address is not available. Check your DNS and host configuration.");
4070
- const o = r.address().family, e = r.address().port;
4071
- let n = r.address().address;
4147
+ function io(t, r) {
4148
+ if (!t.address())
4149
+ throw new Error(
4150
+ "Server address is not available. Check your DNS and host configuration."
4151
+ );
4152
+ const o = t.address().family, e = t.address().port;
4153
+ let n = t.address().address;
4072
4154
  n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
4073
4155
  const a = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
4074
4156
  return `Project Tools - MCP Server Started
4075
4157
 
4076
- Server Name: ${t.name}
4077
- Server Version: ${t.version}
4158
+ Server Name: ${r.name}
4159
+ Server Version: ${r.version}
4078
4160
  Server URL: ${a}/mcp
4079
4161
  SSE Endpoint: ${a}/sse
4080
4162
 
4081
- Log File: ${F.resolve(t.logFilePath)}`;
4163
+ Log File: ${R.resolve(r.logFilePath)}`;
4082
4164
  }
4083
- function Ys(r, t) {
4084
- const s = F.join(t.logDir, Lt()), o = Sr(r, {
4165
+ function ao(t, r) {
4166
+ const s = R.join(r.logDir, _t()), o = Or(t, {
4085
4167
  logFilePath: s
4086
4168
  });
4087
- t.tools.processManager && br(o, t.tools.processManager), t.tools.fsManager && gs(o, t.tools.fsManager), t.tools.playwrightManager && Gs(o, {
4088
- ...t.tools.playwrightManager
4089
- });
4169
+ r.tools.processManager && kr(o, r.tools.processManager), r.tools.fsManager && Ns(o, r.tools.fsManager), r.tools.playwrightManager && eo(o, {
4170
+ ...r.tools.playwrightManager
4171
+ }), xr(o);
4090
4172
  }
4091
- async function go(r) {
4092
- const t = F.join(r.logDir, Lt()), s = js(), o = Ws({
4093
- ...r,
4094
- logFilePath: t,
4173
+ async function Co(t) {
4174
+ const r = R.join(t.logDir, _t()), s = ro(), o = oo({
4175
+ ...t,
4176
+ logFilePath: r,
4095
4177
  createMcpServer: () => {
4096
- const n = new Pt({
4097
- title: r.title,
4098
- name: r.name,
4099
- version: r.version
4178
+ const n = new Gt({
4179
+ title: t.title,
4180
+ name: t.name,
4181
+ version: t.version
4100
4182
  });
4101
- return Ys(n, r), n;
4183
+ return ao(n, t), n;
4102
4184
  }
4103
4185
  });
4104
4186
  s.use(o);
4105
- const e = await Hs(s, {
4106
- host: r.host,
4107
- port: r.port,
4108
- logFilePath: t
4187
+ const e = await no(s, {
4188
+ host: t.host,
4189
+ port: t.port,
4190
+ logFilePath: r
4109
4191
  });
4110
4192
  return console.log(
4111
- Qs(e, {
4112
- title: r.title,
4113
- name: r.name,
4114
- version: r.version,
4115
- logFilePath: t
4193
+ io(e, {
4194
+ title: t.title,
4195
+ name: t.name,
4196
+ version: t.version,
4197
+ logFilePath: r
4116
4198
  })
4117
4199
  ), e;
4118
4200
  }
4119
4201
  export {
4120
- mo as A,
4121
- po as S,
4122
- ho as a,
4123
- fo as b,
4124
- Dr as p,
4125
- go as s
4202
+ To as A,
4203
+ Mo as S,
4204
+ Io as a,
4205
+ $o as b,
4206
+ Gr as p,
4207
+ Co as s
4126
4208
  };