@flemist/mcp-project-tools 3.0.17 → 3.0.19

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