@flemist/mcp-project-tools 3.0.4 → 3.0.5

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,21 +1,20 @@
1
- import G from "express";
2
- import * as ot from "cors";
3
- import { McpServer as nt } from "@modelcontextprotocol/sdk/server/mcp.js";
4
- import { randomBytes as it } from "crypto";
5
- import { StreamableHTTPServerTransport as at } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1
+ import A from "express";
2
+ import { McpServer as ot } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { randomUUID as nt } from "crypto";
6
4
  import * as B from "fs";
7
5
  import * as T from "path";
8
- import lt from "path";
9
- import { spawn as ct } from "child_process";
6
+ import it from "path";
7
+ import { StreamableHTTPServerTransport as at } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
+ import { spawn as lt } from "child_process";
10
9
  import { z as p } from "zod";
11
10
  import K from "tree-kill";
12
- import { Pool as ut, poolRunWait as L } from "@flemist/time-limits";
13
- import { priorityCreate as z } from "@flemist/priority-queue";
14
- import { useAbortController as dt, combineAbortSignals as ft } from "@flemist/async-utils";
15
- import ht from "node:os";
16
- import mt from "picomatch";
17
- import { webkit as pt, firefox as gt, chromium as wt } from "playwright";
18
- function yt(t) {
11
+ import { Pool as ct, poolRunWait as z } from "@flemist/time-limits";
12
+ import { priorityCreate as P } from "@flemist/priority-queue";
13
+ import { useAbortController as ut, combineAbortSignals as dt } from "@flemist/async-utils";
14
+ import ft from "node:os";
15
+ import ht from "picomatch";
16
+ import { webkit as mt, firefox as pt, chromium as gt } from "playwright";
17
+ function wt(t) {
19
18
  const { authToken: r } = t;
20
19
  return function(o, e, n) {
21
20
  if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== r) {
@@ -37,48 +36,67 @@ ${n}
37
36
  console.error(`Failed to log "${s}":`, e);
38
37
  }
39
38
  }
40
- const P = /* @__PURE__ */ new Map();
41
- function bt(t) {
39
+ const G = /* @__PURE__ */ new Map();
40
+ function yt(t) {
41
+ return t.headers["mcp-session-id"] || t.headers["x-session-id"] || t.query.token;
42
+ }
43
+ async function bt(t, r) {
44
+ const s = t.createMcpServer(), o = new at({
45
+ sessionIdGenerator: () => r || nt(),
46
+ onsessioninitialized: (n) => {
47
+ G.set(n, o);
48
+ },
49
+ enableJsonResponse: !0
50
+ });
51
+ async function e() {
52
+ const n = o.sessionId;
53
+ n && G.delete(n);
54
+ try {
55
+ await s.close();
56
+ } catch (a) {
57
+ console.error("Failed to close session", a);
58
+ }
59
+ }
60
+ o.onclose = e;
61
+ try {
62
+ return await s.connect(o), o;
63
+ } catch (n) {
64
+ throw await e(), n;
65
+ }
66
+ }
67
+ async function xt(t, r, s, o) {
68
+ await q({
69
+ logFilePath: s.logFilePath,
70
+ message: "REQUEST",
71
+ data: t.body
72
+ });
73
+ let e = o ? G.get(o) : null;
74
+ e || (e = await bt(s, o)), await e.handleRequest(t, r, t.body);
75
+ }
76
+ async function St(t, r, s) {
77
+ const o = s ? G.get(s) : null;
78
+ if (!o) {
79
+ r.status(400).json({ error: "No valid session found" });
80
+ return;
81
+ }
82
+ await o.handleRequest(t, r);
83
+ }
84
+ function $t(t) {
42
85
  return async function(s, o) {
43
- const e = s.headers["mcp-session-id"] || s.headers["x-session-id"] || s.query.token;
44
- if (s.method === "POST") {
45
- await q({
46
- logFilePath: t.logFilePath,
47
- message: "REQUEST",
48
- data: s.body
86
+ try {
87
+ const e = yt(s);
88
+ s.method === "POST" ? await xt(s, o, t, e) : s.method === "GET" ? await St(s, o, e) : o.status(405).json({ error: "Method not allowed" });
89
+ } catch (e) {
90
+ console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
91
+ error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
49
92
  });
50
- let n = e ? P.get(e) : null;
51
- if (!n) {
52
- const a = new at({
53
- sessionIdGenerator: () => e || it(16).toString("hex"),
54
- onsessioninitialized: (u) => {
55
- const l = {
56
- transport: a,
57
- server: i
58
- };
59
- P.set(u, l), console.log(`Session initialized: ${u}`);
60
- },
61
- enableJsonResponse: !0
62
- }), i = t.createMcpServer();
63
- n = {
64
- transport: a,
65
- server: i
66
- }, a.onclose = () => {
67
- a.sessionId && (P.delete(a.sessionId), console.log(`Session closed: ${a.sessionId}`));
68
- }, await i.connect(a), e && P.set(e, n);
69
- }
70
- await n.transport.handleRequest(s, o, s.body);
71
- } else if (s.method === "GET") {
72
- const n = e ? P.get(e) : null;
73
- n ? await n.transport.handleRequest(s, o) : o.status(400).json({ error: "No valid session" });
74
- } else
75
- o.status(405).json({ error: "Method not allowed" });
93
+ }
76
94
  };
77
95
  }
78
96
  const O = /* @__PURE__ */ new Map();
79
- let xt = 0;
80
- const ie = 10, St = 1800 * 1e3, k = 2e3, $t = 500, It = 5e3;
81
- function Mt(t) {
97
+ let It = 0;
98
+ const ie = 10, Mt = 1800 * 1e3, k = 2e3, Tt = 500, vt = 5e3;
99
+ function Ct(t) {
82
100
  const { commandLine: r, commandLineRules: s } = t;
83
101
  let o = !1;
84
102
  for (const e of s)
@@ -95,11 +113,11 @@ function Mt(t) {
95
113
  }
96
114
  return o;
97
115
  }
98
- function Tt() {
99
- return ++xt;
116
+ function kt() {
117
+ return ++It;
100
118
  }
101
119
  let ae = !1;
102
- function vt() {
120
+ function Nt() {
103
121
  if (ae)
104
122
  return;
105
123
  ae = !0;
@@ -119,13 +137,13 @@ function vt() {
119
137
  function Q() {
120
138
  const t = Date.now(), r = [];
121
139
  for (const [s, o] of Array.from(O.entries()))
122
- !o.isRunning && o.endTime && t - o.endTime.getTime() > St && r.push(s);
140
+ !o.isRunning && o.endTime && t - o.endTime.getTime() > Mt && r.push(s);
123
141
  for (const s of r)
124
142
  O.delete(s);
125
143
  }
126
144
  function H(t) {
127
145
  const { process: r } = t, s = Date.now();
128
- if (s - r.lastOutputTime.getTime() >= $t && (r.output += r.localOutput, r.localOutput = "", r.lastOutputTime = new Date(s), r.output.length > k)) {
146
+ if (s - r.lastOutputTime.getTime() >= Tt && (r.output += r.localOutput, r.localOutput = "", r.lastOutputTime = new Date(s), r.output.length > k)) {
129
147
  const n = `
130
148
  ... [${r.output.length - k} characters trimmed] ...
131
149
  `, a = k - n.length;
@@ -138,7 +156,7 @@ function H(t) {
138
156
  r.output = r.output.substring(0, k);
139
157
  }
140
158
  }
141
- function Ct(t, r) {
159
+ function Dt(t, r) {
142
160
  const s = r.limit;
143
161
  if (t.length <= s) return t;
144
162
  const e = `
@@ -178,7 +196,7 @@ async function Y(t, r) {
178
196
  error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
179
197
  };
180
198
  H({ process: n });
181
- const a = n.output + n.localOutput, i = Ct(a, { limit: e });
199
+ const a = n.output + n.localOutput, i = Dt(a, { limit: e });
182
200
  return n.output = "", n.localOutput = "", {
183
201
  id: n.id,
184
202
  cwd: T.relative(r.workingDir || "", n.cwd),
@@ -192,7 +210,7 @@ async function Y(t, r) {
192
210
  error: n.error
193
211
  };
194
212
  }
195
- function kt(t, r) {
213
+ function Et(t, r) {
196
214
  t(
197
215
  "process-status",
198
216
  {
@@ -221,7 +239,7 @@ function Me(t) {
221
239
  K(t, "SIGKILL", (r) => {
222
240
  r && !r.message.includes("not found") && console.error(`Error sending SIGKILL to process ${t}:`, r);
223
241
  });
224
- }, It);
242
+ }, vt);
225
243
  }
226
244
  const Te = p.object({
227
245
  id: p.number().describe(
@@ -266,7 +284,7 @@ async function ve(t, r) {
266
284
  autoKillExecuted: c
267
285
  };
268
286
  }
269
- function Nt(t, r) {
287
+ function Ft(t, r) {
270
288
  t(
271
289
  "process-wait",
272
290
  {
@@ -305,7 +323,7 @@ const Ce = p.object({
305
323
  `Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${k} characters. Default: ${k}.`
306
324
  )
307
325
  });
308
- async function Dt(t, r) {
326
+ async function Bt(t, r) {
309
327
  Q();
310
328
  let s;
311
329
  try {
@@ -316,7 +334,7 @@ async function Dt(t, r) {
316
334
  };
317
335
  }
318
336
  const { commandLine: o, waitTime: e, autoKill: n, outputLimit: a } = s, { commandLineRules: i } = r, u = T.resolve(r.workingDir || "", s.cwd || "");
319
- if (!Mt({ commandLine: o, commandLineRules: i })) {
337
+ if (!Ct({ commandLine: o, commandLineRules: i })) {
320
338
  const d = i.map(
321
339
  (h) => `${h.rule.toUpperCase()}: /${h.regexp}/ (${h.note})`
322
340
  ).join(`
@@ -334,7 +352,7 @@ To use this command line, ask the user to modify the command line rules in the c
334
352
  return {
335
353
  error: `Maximum concurrent process limit reached (${ie} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
336
354
  };
337
- const c = Tt(), f = {
355
+ const c = kt(), f = {
338
356
  id: c,
339
357
  cwd: u,
340
358
  commandLine: o,
@@ -346,7 +364,7 @@ To use this command line, ask the user to modify the command line rules in the c
346
364
  };
347
365
  O.set(c, f);
348
366
  try {
349
- const d = ct(o, [], {
367
+ const d = lt(o, [], {
350
368
  shell: !0,
351
369
  cwd: u,
352
370
  stdio: ["pipe", "pipe", "pipe"]
@@ -377,7 +395,7 @@ To use this command line, ask the user to modify the command line rules in the c
377
395
  return f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = d instanceof Error ? d.message : "Unknown error", { error: f.error };
378
396
  }
379
397
  }
380
- function Et(t, r) {
398
+ function Ot(t, r) {
381
399
  const s = r.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
382
400
  `);
383
401
  t(
@@ -389,7 +407,7 @@ ${s}`,
389
407
  inputSchema: Ce.shape
390
408
  },
391
409
  async (o) => {
392
- const e = await Dt(o, r);
410
+ const e = await Bt(o, r);
393
411
  if (!("output" in e))
394
412
  return `Method: process-run(${JSON.stringify(o)})
395
413
  ❌ Error: ${e.error}`;
@@ -416,7 +434,7 @@ const ke = p.object({
416
434
  'Specific process data fields to include in the response. If omitted, returns all available fields. Available fields: id, cwd, commandLine, pid, startTime, endTime, exitCode, isRunning, output, error. Examples: ["id", "commandLine", "isRunning"] for minimal info, ["id", "output", "exitCode"] for execution results'
417
435
  )
418
436
  });
419
- async function Ft(t, r) {
437
+ async function Rt(t, r) {
420
438
  Q();
421
439
  let s;
422
440
  try {
@@ -440,7 +458,7 @@ async function Ft(t, r) {
440
458
  H({ process: l });
441
459
  let c = {
442
460
  id: l.id,
443
- cwd: lt.relative(r.workingDir || "", l.cwd),
461
+ cwd: it.relative(r.workingDir || "", l.cwd),
444
462
  commandLine: l.commandLine,
445
463
  pid: l.pid,
446
464
  startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
@@ -459,7 +477,7 @@ async function Ft(t, r) {
459
477
  return c;
460
478
  }) };
461
479
  }
462
- function Bt(t, r) {
480
+ function Pt(t, r) {
463
481
  t(
464
482
  "process-list",
465
483
  {
@@ -468,7 +486,7 @@ function Bt(t, r) {
468
486
  inputSchema: ke.shape
469
487
  },
470
488
  async (s) => {
471
- const o = await Ft(s, r);
489
+ const o = await Rt(s, r);
472
490
  if (o.error != null)
473
491
  return `Method: process-list(${JSON.stringify(s)})
474
492
  ❌ Error: ${o.error}`;
@@ -487,7 +505,7 @@ const Ne = p.object({
487
505
  "Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
488
506
  )
489
507
  });
490
- function Ot(t) {
508
+ function zt(t) {
491
509
  let r;
492
510
  try {
493
511
  r = Ne.parse(t);
@@ -517,7 +535,7 @@ function Ot(t) {
517
535
  };
518
536
  }
519
537
  }
520
- function Rt(t, r) {
538
+ function Lt(t, r) {
521
539
  t(
522
540
  "process-kill",
523
541
  {
@@ -526,15 +544,15 @@ function Rt(t, r) {
526
544
  inputSchema: Ne.shape
527
545
  },
528
546
  async (s) => {
529
- const o = Ot(s);
547
+ const o = zt(s);
530
548
  return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
531
549
  ❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
532
550
  ${JSON.stringify(o, null, 2)}`;
533
551
  }
534
552
  );
535
553
  }
536
- function zt(t, r) {
537
- vt(), r.run && Et(t, r), r.status && kt(t, r), r.wait && Nt(t, r), r.list && Bt(t, r), r.kill && Rt(t);
554
+ function Ut(t, r) {
555
+ Nt(), r.run && Ot(t, r), r.status && Et(t, r), r.wait && Ft(t, r), r.list && Pt(t, r), r.kill && Lt(t);
538
556
  const s = r.commandLineRules?.map(
539
557
  (o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
540
558
  ) || [];
@@ -547,7 +565,7 @@ ${s.map((o) => `- ${o}`).join(`
547
565
  `
548
566
  );
549
567
  }
550
- function Pt(t, r) {
568
+ function At(t, r) {
551
569
  return function(o, e, n) {
552
570
  const a = async (...i) => {
553
571
  await q({
@@ -576,23 +594,23 @@ function Pt(t, r) {
576
594
  );
577
595
  };
578
596
  }
579
- function Lt(t) {
597
+ function qt(t) {
580
598
  return t.match(/^[/\\]?[^/\\]+/)[0];
581
599
  }
582
- function Ut(t, r) {
583
- return Lt(t) + "|" + r.ino;
600
+ function Gt(t, r) {
601
+ return qt(t) + "|" + r.ino;
584
602
  }
585
- function At(t) {
603
+ function jt(t) {
586
604
  return t.endsWith(":") && (t += "/"), T.resolve(t);
587
605
  }
588
- const De = new ut(ht.cpus().length);
606
+ const De = new ct(ft.cpus().length);
589
607
  function le(t, r) {
590
608
  t.totalSize += r.totalSize, t.maxFileDateModified = Math.max(
591
609
  t.maxFileDateModified,
592
610
  r.maxFileDateModified
593
611
  ), t.countFiles += r.countFiles, t.countDirs += r.countDirs, t.countLinks += r.countLinks;
594
612
  }
595
- const Gt = function(r) {
613
+ const _t = function(r) {
596
614
  return r.code === "ENOENT";
597
615
  };
598
616
  function Ee(t) {
@@ -605,16 +623,16 @@ function Ee(t) {
605
623
  countDirs: 0,
606
624
  countLinks: 0
607
625
  });
608
- const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? De, a = t.handleError, i = t.priority ?? z(0), u = t.walkLinks ?? !1, l = t.log, c = t.handlePath, f = t.matchPath;
626
+ const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? De, a = t.handleError, i = t.priority ?? P(0), u = t.walkLinks ?? !1, l = t.log, c = t.handlePath, f = t.matchPath;
609
627
  async function d(m) {
610
- if (!(a && await a(m)) && !Gt(m))
628
+ if (!(a && await a(m)) && !_t(m))
611
629
  throw m;
612
630
  }
613
631
  function h(m) {
614
632
  return !(!l || l.minTotalContentSize != null && m < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
615
633
  }
616
- return dt(async (m) => {
617
- const g = ft(e, m), b = {
634
+ return ut(async (m) => {
635
+ const g = dt(e, m), b = {
618
636
  totalSize: 0,
619
637
  maxFileDateModified: 0,
620
638
  countFiles: 0,
@@ -628,7 +646,7 @@ function Ee(t) {
628
646
  }
629
647
  }
630
648
  async function x(w, M, $, v) {
631
- return c ? await L({
649
+ return c ? await z({
632
650
  pool: n,
633
651
  func: async () => {
634
652
  try {
@@ -651,16 +669,16 @@ function Ee(t) {
651
669
  }
652
670
  async function I(w, M, $, v) {
653
671
  v || (v = w);
654
- const D = await L({
672
+ const D = await z({
655
673
  pool: n,
656
674
  func: () => B.promises.lstat(w).catch(d),
657
675
  count: 1,
658
- priority: z(M, z(1, i)),
676
+ priority: P(M, P(1, i)),
659
677
  abortSignal: g
660
678
  });
661
679
  if (!D || !$ && D.isFile())
662
680
  return null;
663
- const ne = Ut(w, D);
681
+ const ne = Gt(w, D);
664
682
  if (o.has(ne))
665
683
  return null;
666
684
  o.add(ne);
@@ -671,37 +689,37 @@ function Ee(t) {
671
689
  countDirs: 0,
672
690
  countLinks: 0
673
691
  };
674
- const U = z(
692
+ const L = P(
675
693
  M,
676
- z(D.isDirectory() ? 2 : 3, i)
694
+ P(D.isDirectory() ? 2 : 3, i)
677
695
  );
678
696
  if (D.isSymbolicLink()) {
679
697
  if (u) {
680
- const F = await L({
698
+ const F = await z({
681
699
  pool: n,
682
700
  func: () => B.promises.readlink(w).catch(d).then((R) => R ?? null),
683
701
  count: 1,
684
- priority: U,
702
+ priority: L,
685
703
  abortSignal: g
686
704
  });
687
705
  if (F) {
688
- const R = T.isAbsolute(F) ? F : T.resolve(T.dirname(v), F), A = await I(
706
+ const R = T.isAbsolute(F) ? F : T.resolve(T.dirname(v), F), U = await I(
689
707
  R,
690
708
  M,
691
709
  $,
692
710
  v
693
711
  );
694
- A && (N = A);
712
+ U && (N = U);
695
713
  }
696
714
  }
697
715
  return ($ || N.countFiles + N.countDirs + N.countLinks > 1) && (N.countLinks += 1, await x(
698
716
  v,
699
717
  D,
700
718
  N,
701
- U
719
+ L
702
720
  ) && (le(b, N), y(v, N))), N;
703
721
  } else if (D.isDirectory()) {
704
- const F = await L({
722
+ const F = await z({
705
723
  pool: n,
706
724
  func: () => B.promises.readdir(w).catch(d),
707
725
  count: 1,
@@ -709,13 +727,13 @@ function Ee(t) {
709
727
  abortSignal: g
710
728
  });
711
729
  if (F) {
712
- for (let R = 0, A = F.length; R < A; R++)
730
+ for (let R = 0, U = F.length; R < U; R++)
713
731
  F[R] = T.join(v, F[R]);
714
732
  N = await Ee({
715
733
  ...t,
716
734
  paths: F,
717
735
  abortSignal: g,
718
- priority: U,
736
+ priority: L,
719
737
  level: s + 1,
720
738
  walkedIds: o
721
739
  });
@@ -725,12 +743,12 @@ function Ee(t) {
725
743
  v,
726
744
  D,
727
745
  N,
728
- U
746
+ L
729
747
  ) && (le(b, N), y(v, N))), N;
730
748
  }
731
749
  const S = [];
732
750
  for (let w = 0, M = r.length; w < M; w++) {
733
- const $ = At(r[w]), v = f ? f($) : !0;
751
+ const $ = jt(r[w]), v = f ? f($) : !0;
734
752
  v !== !1 && S.push(I($, w, v));
735
753
  }
736
754
  return await Promise.all(S), b;
@@ -739,7 +757,7 @@ function Ee(t) {
739
757
  function Fe(t) {
740
758
  return Ee(t);
741
759
  }
742
- function qt(t, r) {
760
+ function Jt(t, r) {
743
761
  if (!r || r === ".")
744
762
  return t;
745
763
  const s = t.startsWith("^");
@@ -747,14 +765,14 @@ function qt(t, r) {
747
765
  const o = t.startsWith("!");
748
766
  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 = T.normalize(t).replace(/\\/g, "/"), o && (t = "!" + t), s && (t = "^" + t), t;
749
767
  }
750
- function _t(t) {
768
+ function Kt(t) {
751
769
  const r = t.startsWith("!");
752
770
  return r && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), r && (t = "!" + t), t;
753
771
  }
754
772
  function ce(t) {
755
773
  return "^" + t;
756
774
  }
757
- async function jt(t) {
775
+ async function Wt(t) {
758
776
  const s = (await B.promises.readFile(t, "utf-8")).split(`
759
777
  `), o = [];
760
778
  return s.forEach((e) => {
@@ -770,13 +788,13 @@ async function Be(t) {
770
788
  e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? ce(e.value) : e.value));
771
789
  }), o.length && await Promise.all(
772
790
  o.map(async (e) => {
773
- await L({
791
+ await z({
774
792
  pool: De,
775
793
  count: 1,
776
794
  func: async () => {
777
- const n = T.resolve(r, e.value), a = await jt(n), i = T.relative(r, T.dirname(n));
795
+ const n = T.resolve(r, e.value), a = await Wt(n), i = T.relative(r, T.dirname(n));
778
796
  a.forEach((u) => {
779
- u = _t(u), u = qt(u, i), s.push(e.exclude ? ce(u) : u);
797
+ u = Kt(u), u = Jt(u, i), s.push(e.exclude ? ce(u) : u);
780
798
  });
781
799
  }
782
800
  });
@@ -804,7 +822,7 @@ function Oe({
804
822
  return;
805
823
  let u;
806
824
  try {
807
- u = mt(i, {
825
+ u = ht(i, {
808
826
  nocase: s ?? !1,
809
827
  dot: !0,
810
828
  strictBrackets: !0
@@ -831,7 +849,7 @@ function Oe({
831
849
  return i ? !1 : a;
832
850
  };
833
851
  }
834
- async function Jt(t) {
852
+ async function Qt(t) {
835
853
  const r = t.rootDir ?? ".", s = [], o = {};
836
854
  t.result.countFiles && (o.countFiles = 0), t.result.size && (o.size = 0);
837
855
  const e = await Be({
@@ -882,7 +900,7 @@ function he(t) {
882
900
  const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), u = Math.floor(a / 30), l = Math.floor(a / 365);
883
901
  return l > 0 ? `${l}Y` : u > 0 ? `${u}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
884
902
  }
885
- function Kt(t, r) {
903
+ function Ht(t, r) {
886
904
  return r?.length ? [...t].sort((s, o) => {
887
905
  for (let e = 0, n = r.length; e < n; e++) {
888
906
  const a = r[e];
@@ -918,8 +936,8 @@ function Kt(t, r) {
918
936
  return 0;
919
937
  }) : t;
920
938
  }
921
- function Wt(t, r) {
922
- const s = Kt(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
939
+ function Yt(t, r) {
940
+ const s = Ht(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
923
941
  let e = "";
924
942
  if (s.length > 0 && o.length > 0) {
925
943
  for (let n = 0, a = o.length; n < a; n++) {
@@ -977,7 +995,9 @@ function Wt(t, r) {
977
995
  }
978
996
  return e;
979
997
  }
980
- const is = "project-tools", as = "1.0.0", ls = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", me = 25e3;
998
+ const Vt = "3.0.5", Zt = {
999
+ version: Vt
1000
+ }, ds = "Project Tools", fs = "project-tools", hs = Zt.version, ms = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", me = 25e3;
981
1001
  function pe(t) {
982
1002
  const r = t.match(
983
1003
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
@@ -1072,7 +1092,7 @@ const Re = p.object({
1072
1092
  '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'
1073
1093
  )
1074
1094
  });
1075
- async function Qt(t, r) {
1095
+ async function Xt(t, r) {
1076
1096
  let s;
1077
1097
  try {
1078
1098
  s = Re.parse(t);
@@ -1149,7 +1169,7 @@ async function Qt(t, r) {
1149
1169
  error: $ instanceof Error ? $.message : "Unknown error parsing size filter"
1150
1170
  };
1151
1171
  }
1152
- const w = await Jt({
1172
+ const w = await Qt({
1153
1173
  rootDir: m || null,
1154
1174
  globs: y,
1155
1175
  result: x,
@@ -1159,7 +1179,7 @@ async function Qt(t, r) {
1159
1179
  return w.items.length > me ? {
1160
1180
  error: `Number of paths (${w.items.length}) exceeds maximum allowed (${me}). Consider using more specific glob patterns or filters to reduce the result set.`
1161
1181
  } : {
1162
- output: Wt(w, {
1182
+ output: Yt(w, {
1163
1183
  sort: d,
1164
1184
  fields: f,
1165
1185
  totals: !0
@@ -1169,7 +1189,7 @@ async function Qt(t, r) {
1169
1189
  return { error: g instanceof Error ? g.message : "Unknown error" };
1170
1190
  }
1171
1191
  }
1172
- function Ht(t, r) {
1192
+ function er(t, r) {
1173
1193
  t(
1174
1194
  "fs-list",
1175
1195
  {
@@ -1178,19 +1198,19 @@ function Ht(t, r) {
1178
1198
  inputSchema: Re.shape
1179
1199
  },
1180
1200
  async (s) => {
1181
- const o = await Qt(s, r);
1201
+ const o = await Xt(s, r);
1182
1202
  return o.error ? `Method: fs-list(${JSON.stringify(s)})
1183
1203
  ❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
1184
1204
  ${o.output || JSON.stringify(o, null, 2)}`;
1185
1205
  }
1186
1206
  );
1187
1207
  }
1188
- const j = /* @__PURE__ */ new Map();
1208
+ const _ = /* @__PURE__ */ new Map();
1189
1209
  function V(t) {
1190
- return j.has(t) || j.set(t, {
1210
+ return _.has(t) || _.set(t, {
1191
1211
  fsSnapshotQueries: /* @__PURE__ */ new Map(),
1192
1212
  fsSnapshots: /* @__PURE__ */ new Map()
1193
- }), j.get(t);
1213
+ }), _.get(t);
1194
1214
  }
1195
1215
  function we(t) {
1196
1216
  const r = t.match(
@@ -1287,11 +1307,11 @@ const Z = p.object({
1287
1307
  "dateModified"
1288
1308
  ].map((t, r) => [t, r])
1289
1309
  );
1290
- function Yt(t, r) {
1310
+ function tr(t, r) {
1291
1311
  const s = be.get(t) ?? 1 / 0, o = be.get(r) ?? 1 / 0;
1292
1312
  return s > o ? 1 : s < o ? -1 : 0;
1293
1313
  }
1294
- async function ze(t, r, s) {
1314
+ async function Pe(t, r, s) {
1295
1315
  let o;
1296
1316
  try {
1297
1317
  o = Z.parse(t);
@@ -1331,7 +1351,7 @@ async function ze(t, r, s) {
1331
1351
  throw w;
1332
1352
  }
1333
1353
  const m = o.extraFields ? o.extraFields.map((w) => w === "lastModified" ? "dateModified" : w) : [];
1334
- m.includes("name") || m.push("name"), m.sort(Yt);
1354
+ m.includes("name") || m.push("name"), m.sort(tr);
1335
1355
  const g = n && n.length > 0 ? n.map((w) => ({
1336
1356
  value: w,
1337
1357
  valueType: "pattern",
@@ -1375,7 +1395,7 @@ async function ze(t, r, s) {
1375
1395
  };
1376
1396
  }
1377
1397
  }
1378
- function Vt(t, r) {
1398
+ function rr(t, r) {
1379
1399
  t(
1380
1400
  "fs-snapshot-query-create",
1381
1401
  {
@@ -1384,14 +1404,14 @@ function Vt(t, r) {
1384
1404
  inputSchema: Z.shape
1385
1405
  },
1386
1406
  async (s, o) => {
1387
- const e = await ze(s, r, o);
1407
+ const e = await Pe(s, r, o);
1388
1408
  return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1389
1409
  ❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1390
1410
  ✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
1391
1411
  }
1392
1412
  );
1393
1413
  }
1394
- function _(t) {
1414
+ function j(t) {
1395
1415
  const { idToNode: r, idToChildIds: s } = t, o = r.get(null);
1396
1416
  if (o == null)
1397
1417
  throw new Error(
@@ -1431,16 +1451,16 @@ function _(t) {
1431
1451
  }
1432
1452
  };
1433
1453
  }
1434
- function Pe(t, r, s) {
1454
+ function ze(t, r, s) {
1435
1455
  let o = null;
1436
1456
  for (let e = 0, n = r.length; e < n; e++) {
1437
- const a = r[e], i = t(a), u = i == null ? null : Pe(t, i, s), l = s(a, u);
1457
+ const a = r[e], i = t(a), u = i == null ? null : ze(t, i, s), l = s(a, u);
1438
1458
  l != null && (o == null && (o = []), o.push(l));
1439
1459
  }
1440
1460
  return o;
1441
1461
  }
1442
1462
  function Le(t) {
1443
- const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), u = Pe(
1463
+ const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), u = ze(
1444
1464
  s,
1445
1465
  o,
1446
1466
  (c, f) => {
@@ -1468,7 +1488,7 @@ function Le(t) {
1468
1488
  function W(t) {
1469
1489
  return t = t?.replace(/\\/g, "/").replace(/\/$/, ""), !t || t === "." ? null : t;
1470
1490
  }
1471
- async function Zt(t) {
1491
+ async function sr(t) {
1472
1492
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = T.resolve(t.rootDir || "."), n = {
1473
1493
  path: ".",
1474
1494
  name: T.basename(o),
@@ -1528,7 +1548,7 @@ async function Zt(t) {
1528
1548
  idToChildIds: s
1529
1549
  };
1530
1550
  }
1531
- const Xt = [
1551
+ const or = [
1532
1552
  { name: "[ ]", match: (t) => t === 32, min: 2, max: 81 },
1533
1553
  { name: "[\\t]", match: (t) => t === 9, min: 2, max: 20 },
1534
1554
  { name: "[\\n]", match: (t) => t === 10, min: 2, max: 14 },
@@ -1551,7 +1571,7 @@ const Xt = [
1551
1571
  // max: 2,
1552
1572
  // },
1553
1573
  ];
1554
- function xe(t, r = Xt) {
1574
+ function xe(t, r = or) {
1555
1575
  const s = t.length;
1556
1576
  if (s === 0) return 0;
1557
1577
  const o = r.length;
@@ -1582,20 +1602,20 @@ function Ue(t) {
1582
1602
  return r += xe(t.textOpen) + 1, t.textClose != null && (r += xe(t.textClose) + 1), t.indent && (r += 1), r;
1583
1603
  }
1584
1604
  const Se = ["B", "KB", "MB", "GB", "TB"], $e = 1024;
1585
- function er(t) {
1605
+ function nr(t) {
1586
1606
  if (t == null) return "-";
1587
1607
  let r = t ?? 0, s = 0;
1588
1608
  for (; r >= $e && s < Se.length - 1; )
1589
1609
  r /= $e, s++;
1590
1610
  return `${s === 0 ? r.toString() : r.toFixed(2)}${Se[s]}`;
1591
1611
  }
1592
- function tr(t) {
1612
+ function ir(t) {
1593
1613
  const s = Date.now() - t;
1594
1614
  if (s < 0) return "0s";
1595
1615
  const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), u = Math.floor(a / 30), l = Math.floor(a / 365);
1596
1616
  return l > 0 ? `${l}Y` : u > 0 ? `${u}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1597
1617
  }
1598
- function rr(t) {
1618
+ function ar(t) {
1599
1619
  return function(s, o) {
1600
1620
  const e = t.get(s), n = t.get(o);
1601
1621
  if (e.type !== n.type)
@@ -1608,7 +1628,7 @@ function rr(t) {
1608
1628
  }
1609
1629
  };
1610
1630
  }
1611
- function sr(t) {
1631
+ function lr(t) {
1612
1632
  const r = t.fields ?? [];
1613
1633
  return function(o, e) {
1614
1634
  let n = "", a, i = 0;
@@ -1624,10 +1644,10 @@ function sr(t) {
1624
1644
  const M = r[S];
1625
1645
  switch (S > 0 && (n += " "), M) {
1626
1646
  case "dateModified":
1627
- n += g ? tr(g) : "-";
1647
+ n += g ? ir(g) : "-";
1628
1648
  break;
1629
1649
  case "size":
1630
- n += er(h);
1650
+ n += nr(h);
1631
1651
  break;
1632
1652
  case "type":
1633
1653
  n += b;
@@ -1663,8 +1683,8 @@ function sr(t) {
1663
1683
  };
1664
1684
  };
1665
1685
  }
1666
- async function or(t) {
1667
- const r = await Zt(t), s = _(r), o = s.getChilds(s.root), e = Le({
1686
+ async function cr(t) {
1687
+ const r = await sr(t), s = j(r), o = s.getChilds(s.root), e = Le({
1668
1688
  getId: (a) => {
1669
1689
  const i = s.getId(a);
1670
1690
  if (i == null)
@@ -1674,12 +1694,12 @@ async function or(t) {
1674
1694
  return i;
1675
1695
  },
1676
1696
  getChilds: (a) => s.getChilds(a),
1677
- createSnapshotNode: sr(t),
1697
+ createSnapshotNode: lr(t),
1678
1698
  rootNodes: o ?? []
1679
- }), n = rr(e.idToNode);
1699
+ }), n = ar(e.idToNode);
1680
1700
  return e.idToChildIds.forEach((a) => {
1681
1701
  a.sort(n);
1682
- }), _(e);
1702
+ }), j(e);
1683
1703
  }
1684
1704
  const X = p.object({
1685
1705
  queryName: p.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
@@ -1722,7 +1742,7 @@ async function Ae(t, r, s) {
1722
1742
  };
1723
1743
  u = c;
1724
1744
  } else if (a) {
1725
- const c = await ze(
1745
+ const c = await Pe(
1726
1746
  a,
1727
1747
  r,
1728
1748
  s
@@ -1737,7 +1757,7 @@ async function Ae(t, r, s) {
1737
1757
  error: "Either queryName or query must be provided"
1738
1758
  };
1739
1759
  try {
1740
- const c = await or(u), f = {
1760
+ const c = await cr(u), f = {
1741
1761
  name: e,
1742
1762
  query: u,
1743
1763
  tree: c
@@ -1752,7 +1772,7 @@ async function Ae(t, r, s) {
1752
1772
  };
1753
1773
  }
1754
1774
  }
1755
- function nr(t, r) {
1775
+ function ur(t, r) {
1756
1776
  t(
1757
1777
  "fs-snapshot-create",
1758
1778
  {
@@ -1772,7 +1792,7 @@ function nr(t, r) {
1772
1792
  }
1773
1793
  );
1774
1794
  }
1775
- class ir {
1795
+ class dr {
1776
1796
  _first = null;
1777
1797
  _last = null;
1778
1798
  _size = 0;
@@ -1795,8 +1815,8 @@ class ir {
1795
1815
  return this._size;
1796
1816
  }
1797
1817
  }
1798
- function ar(t) {
1799
- const r = new ir(), {
1818
+ function fr(t) {
1819
+ const r = new dr(), {
1800
1820
  tree: s,
1801
1821
  limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: a },
1802
1822
  indexRangeGroupStrategy: i
@@ -1864,7 +1884,7 @@ function ar(t) {
1864
1884
  }
1865
1885
  return l ?? [];
1866
1886
  }
1867
- function Ge(t) {
1887
+ function qe(t) {
1868
1888
  const {
1869
1889
  tree: r,
1870
1890
  request: { parentNodeId: s, childsIndexRange: o, limits: e },
@@ -1908,14 +1928,14 @@ function Ge(t) {
1908
1928
  root: c,
1909
1929
  getChilds: (d) => d === c ? [u] : d === u ? l : r.getChilds(d)
1910
1930
  };
1911
- return ar({
1931
+ return fr({
1912
1932
  tree: f,
1913
1933
  limits: e,
1914
1934
  indexRangeGroupStrategy: n,
1915
1935
  ...a
1916
1936
  });
1917
1937
  }
1918
- function qe(t, r) {
1938
+ function Ge(t, r) {
1919
1939
  if (t == null || t.length === 0)
1920
1940
  return "No results found";
1921
1941
  let s = "";
@@ -1932,7 +1952,7 @@ function qe(t, r) {
1932
1952
  }
1933
1953
  return o(t, ""), s;
1934
1954
  }
1935
- class lr {
1955
+ class hr {
1936
1956
  tokens = 16;
1937
1957
  // +1 indent, +1 for line break
1938
1958
  getReportText = (r) => ({
@@ -1947,7 +1967,7 @@ class lr {
1947
1967
  tokensGrouped: s.tokens
1948
1968
  } : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
1949
1969
  }
1950
- const _e = p.object({
1970
+ const je = p.object({
1951
1971
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
1952
1972
  snapshot: X.optional().describe(
1953
1973
  "Filesystem snapshot creation options JSON to automatically create snapshot"
@@ -1969,10 +1989,10 @@ const _e = p.object({
1969
1989
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
1970
1990
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
1971
1991
  });
1972
- async function cr(t, r, s) {
1992
+ async function mr(t, r, s) {
1973
1993
  let o;
1974
1994
  try {
1975
- o = _e.parse(t);
1995
+ o = je.parse(t);
1976
1996
  } catch (g) {
1977
1997
  return {
1978
1998
  error: C(g)
@@ -2018,7 +2038,7 @@ async function cr(t, r, s) {
2018
2038
  error: "Either snapshotName or snapshot must be provided"
2019
2039
  };
2020
2040
  try {
2021
- const g = W(o.parentPath), b = Ge({
2041
+ const g = W(o.parentPath), b = qe({
2022
2042
  tree: d.tree,
2023
2043
  request: {
2024
2044
  parentNodeId: g,
@@ -2030,8 +2050,8 @@ async function cr(t, r, s) {
2030
2050
  maxTokensGroup: c
2031
2051
  }
2032
2052
  },
2033
- indexRangeGroupStrategy: new lr()
2034
- }), y = qe(b);
2053
+ indexRangeGroupStrategy: new hr()
2054
+ }), y = Ge(b);
2035
2055
  return {
2036
2056
  fsSnapshot: d,
2037
2057
  queryCreated: h,
@@ -2046,16 +2066,16 @@ async function cr(t, r, s) {
2046
2066
  };
2047
2067
  }
2048
2068
  }
2049
- function ur(t, r) {
2069
+ function pr(t, r) {
2050
2070
  t(
2051
2071
  "fs-snapshot-browse",
2052
2072
  {
2053
2073
  title: "Browse Filesystem Snapshot",
2054
2074
  description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
2055
- inputSchema: _e.shape
2075
+ inputSchema: je.shape
2056
2076
  },
2057
2077
  async (s, o) => {
2058
- const e = await cr(s, r, o);
2078
+ const e = await mr(s, r, o);
2059
2079
  if (e.error != null)
2060
2080
  return `Method: fs-snapshot-browse(${JSON.stringify(s)})
2061
2081
  ❌ Error: ${e.error}`;
@@ -2077,8 +2097,8 @@ ${e.report}`, n;
2077
2097
  }
2078
2098
  );
2079
2099
  }
2080
- function dr(t, r) {
2081
- r.list && Ht(t, r), r.snapshotQueryCreate && Vt(t, r), r.snapshotCreate && nr(t, r), r.snapshotBrowse && ur(t, r), console.log(
2100
+ function gr(t, r) {
2101
+ r.list && er(t, r), r.snapshotQueryCreate && rr(t, r), r.snapshotCreate && ur(t, r), r.snapshotBrowse && pr(t, r), console.log(
2082
2102
  `File manager:
2083
2103
  - Working directory: ${T.resolve(r.workingDir || "")}
2084
2104
  `
@@ -2099,7 +2119,7 @@ const ee = p.object({
2099
2119
  muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
2100
2120
  devTools: p.boolean().optional().describe("Open browser with dev tools")
2101
2121
  });
2102
- async function je(t, r, s) {
2122
+ async function _e(t, r, s) {
2103
2123
  let o;
2104
2124
  try {
2105
2125
  o = ee.parse(t);
@@ -2120,9 +2140,9 @@ async function je(t, r, s) {
2120
2140
  };
2121
2141
  try {
2122
2142
  const f = await {
2123
- chromium: wt,
2124
- firefox: gt,
2125
- webkit: pt
2143
+ chromium: gt,
2144
+ firefox: pt,
2145
+ webkit: mt
2126
2146
  }[n].launch({
2127
2147
  headless: !1,
2128
2148
  devtools: i,
@@ -2140,7 +2160,7 @@ async function je(t, r, s) {
2140
2160
  };
2141
2161
  }
2142
2162
  }
2143
- function fr(t, r) {
2163
+ function wr(t, r) {
2144
2164
  t(
2145
2165
  "playwright-browser-create",
2146
2166
  {
@@ -2149,14 +2169,14 @@ function fr(t, r) {
2149
2169
  inputSchema: ee.shape
2150
2170
  },
2151
2171
  async (s, o) => {
2152
- const e = await je(s, r, o);
2172
+ const e = await _e(s, r, o);
2153
2173
  return `Method: playwright-browser-create(${JSON.stringify(s)})
2154
2174
  ${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
2155
2175
  }
2156
2176
  );
2157
2177
  }
2158
2178
  const Je = p.object({});
2159
- async function hr(t, r, s) {
2179
+ async function yr(t, r, s) {
2160
2180
  let o;
2161
2181
  try {
2162
2182
  o = Je.parse(t);
@@ -2174,7 +2194,7 @@ async function hr(t, r, s) {
2174
2194
  browserInfos: Array.from(e.browsers.values())
2175
2195
  };
2176
2196
  }
2177
- function mr(t, r) {
2197
+ function br(t, r) {
2178
2198
  t(
2179
2199
  "playwright-browser-list",
2180
2200
  {
@@ -2183,7 +2203,7 @@ function mr(t, r) {
2183
2203
  inputSchema: Je.shape
2184
2204
  },
2185
2205
  async (s, o) => {
2186
- const e = await hr(s, r, o);
2206
+ const e = await yr(s, r, o);
2187
2207
  if (e.error != null)
2188
2208
  return `Method: playwright-browser-list(${JSON.stringify(s)})
2189
2209
  ❌ Error: ${e.error}`;
@@ -2200,7 +2220,7 @@ const Ke = p.object({
2200
2220
  "Names of browsers to close. If not specified, closes all browsers"
2201
2221
  )
2202
2222
  });
2203
- async function pr(t, r, s) {
2223
+ async function xr(t, r, s) {
2204
2224
  let o;
2205
2225
  try {
2206
2226
  o = Ke.parse(t);
@@ -2234,7 +2254,7 @@ async function pr(t, r, s) {
2234
2254
  ...i.length > 0 && { errors: i }
2235
2255
  };
2236
2256
  }
2237
- function gr(t, r) {
2257
+ function Sr(t, r) {
2238
2258
  t(
2239
2259
  "playwright-browser-close",
2240
2260
  {
@@ -2243,7 +2263,7 @@ function gr(t, r) {
2243
2263
  inputSchema: Ke.shape
2244
2264
  },
2245
2265
  async (s, o) => {
2246
- const e = await pr(s, r, o);
2266
+ const e = await xr(s, r, o);
2247
2267
  if (e.error != null)
2248
2268
  return `Method: playwright-browser-close(${JSON.stringify(s)})
2249
2269
  ❌ Error: ${e.error}`;
@@ -2301,7 +2321,7 @@ async function We(t, r, s) {
2301
2321
  error: `Browser "${n}" not found`
2302
2322
  };
2303
2323
  } else if (a) {
2304
- const h = await je(a, r, s);
2324
+ const h = await _e(a, r, s);
2305
2325
  if (h.error != null)
2306
2326
  return {
2307
2327
  error: h.error
@@ -2337,7 +2357,7 @@ async function We(t, r, s) {
2337
2357
  };
2338
2358
  }
2339
2359
  }
2340
- function wr(t, r) {
2360
+ function $r(t, r) {
2341
2361
  t(
2342
2362
  "playwright-context-create",
2343
2363
  {
@@ -2362,7 +2382,7 @@ const Qe = p.object({
2362
2382
  "Name of browser to list contexts from. If not specified, lists contexts from all browsers"
2363
2383
  )
2364
2384
  });
2365
- async function yr(t, r, s) {
2385
+ async function Ir(t, r, s) {
2366
2386
  let o;
2367
2387
  try {
2368
2388
  o = Qe.parse(t);
@@ -2399,7 +2419,7 @@ async function yr(t, r, s) {
2399
2419
  contextsByBrowser: a
2400
2420
  };
2401
2421
  }
2402
- function br(t, r) {
2422
+ function Mr(t, r) {
2403
2423
  t(
2404
2424
  "playwright-context-list",
2405
2425
  {
@@ -2408,7 +2428,7 @@ function br(t, r) {
2408
2428
  inputSchema: Qe.shape
2409
2429
  },
2410
2430
  async (s, o) => {
2411
- const e = await yr(s, r, o);
2431
+ const e = await Ir(s, r, o);
2412
2432
  if ("error" in e)
2413
2433
  return `Method: playwright-context-list(${JSON.stringify(s)})
2414
2434
  ❌ Error: ${e.error}`;
@@ -2429,7 +2449,7 @@ const He = p.object({
2429
2449
  "Name of browser to close contexts from. If not specified, searches all browsers"
2430
2450
  )
2431
2451
  });
2432
- async function xr(t, r, s) {
2452
+ async function Tr(t, r, s) {
2433
2453
  let o;
2434
2454
  try {
2435
2455
  o = He.parse(t);
@@ -2483,7 +2503,7 @@ async function xr(t, r, s) {
2483
2503
  ...u.length > 0 && { errors: u }
2484
2504
  };
2485
2505
  }
2486
- function Sr(t, r) {
2506
+ function vr(t, r) {
2487
2507
  t(
2488
2508
  "playwright-context-close",
2489
2509
  {
@@ -2492,7 +2512,7 @@ function Sr(t, r) {
2492
2512
  inputSchema: He.shape
2493
2513
  },
2494
2514
  async (s, o) => {
2495
- const e = await xr(s, r, o);
2515
+ const e = await Tr(s, r, o);
2496
2516
  if ("error" in e)
2497
2517
  return `Method: playwright-context-close(${JSON.stringify(s)})
2498
2518
  ❌ Error: ${e.error}`;
@@ -2509,7 +2529,7 @@ ${n.join(`
2509
2529
  }
2510
2530
  );
2511
2531
  }
2512
- function $r() {
2532
+ function Cr() {
2513
2533
  class t {
2514
2534
  prevId = 0;
2515
2535
  objectToId = /* @__PURE__ */ new WeakMap();
@@ -2597,7 +2617,7 @@ function $r() {
2597
2617
  }
2598
2618
  window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = a;
2599
2619
  }
2600
- const Ir = `(function (){function __name(fn){return fn};${$r.toString()}; setupPageGlobals();})()`, re = p.object({
2620
+ const kr = `(function (){function __name(fn){return fn};${Cr.toString()}; setupPageGlobals();})()`, re = p.object({
2601
2621
  contextName: p.string().optional().describe("Name of previously created context, to use"),
2602
2622
  context: te.optional().describe(
2603
2623
  "Context creation options JSON to automatically create context"
@@ -2653,7 +2673,7 @@ async function Ye(t, r, s) {
2653
2673
  };
2654
2674
  try {
2655
2675
  const f = await c.context.newPage();
2656
- await f.addInitScript(Ir), await f.goto("about:blank");
2676
+ await f.addInitScript(kr), await f.goto("about:blank");
2657
2677
  const d = {
2658
2678
  contextInfo: c,
2659
2679
  name: e,
@@ -2671,7 +2691,7 @@ async function Ye(t, r, s) {
2671
2691
  };
2672
2692
  }
2673
2693
  }
2674
- function Mr(t, r) {
2694
+ function Nr(t, r) {
2675
2695
  t(
2676
2696
  "playwright-page-create",
2677
2697
  {
@@ -2700,7 +2720,7 @@ const Ve = p.object({
2700
2720
  "Name of browser to search in. If not specified, searches all browsers"
2701
2721
  )
2702
2722
  });
2703
- async function Tr(t, r, s) {
2723
+ async function Dr(t, r, s) {
2704
2724
  let o;
2705
2725
  try {
2706
2726
  o = Ve.parse(t);
@@ -2764,7 +2784,7 @@ async function Tr(t, r, s) {
2764
2784
  pagesByContext: i
2765
2785
  };
2766
2786
  }
2767
- function vr(t, r) {
2787
+ function Er(t, r) {
2768
2788
  t(
2769
2789
  "playwright-page-list",
2770
2790
  {
@@ -2773,7 +2793,7 @@ function vr(t, r) {
2773
2793
  inputSchema: Ve.shape
2774
2794
  },
2775
2795
  async (s, o) => {
2776
- const e = await Tr(s, r, o);
2796
+ const e = await Dr(s, r, o);
2777
2797
  if ("error" in e)
2778
2798
  return `Method: playwright-page-list(${JSON.stringify(s)})
2779
2799
  ❌ Error: ${e.error}`;
@@ -2795,7 +2815,7 @@ const Ze = p.object({
2795
2815
  "Name of browser to search in. If not specified, searches all browsers"
2796
2816
  )
2797
2817
  });
2798
- async function Cr(t, r, s) {
2818
+ async function Fr(t, r, s) {
2799
2819
  let o;
2800
2820
  try {
2801
2821
  o = Ze.parse(t);
@@ -2873,7 +2893,7 @@ async function Cr(t, r, s) {
2873
2893
  ...l.length > 0 && { errors: l }
2874
2894
  };
2875
2895
  }
2876
- function kr(t, r) {
2896
+ function Br(t, r) {
2877
2897
  t(
2878
2898
  "playwright-page-close",
2879
2899
  {
@@ -2882,7 +2902,7 @@ function kr(t, r) {
2882
2902
  inputSchema: Ze.shape
2883
2903
  },
2884
2904
  async (s, o) => {
2885
- const e = await Cr(s, r, o);
2905
+ const e = await Fr(s, r, o);
2886
2906
  if ("error" in e)
2887
2907
  return `Method: playwright-page-close(${JSON.stringify(s)})
2888
2908
  ❌ Error: ${e.error}`;
@@ -2908,7 +2928,7 @@ const Xe = p.object({
2908
2928
  - 'commit': network response received and document started loading`
2909
2929
  )
2910
2930
  });
2911
- async function Nr(t, r, s) {
2931
+ async function Or(t, r, s) {
2912
2932
  let o;
2913
2933
  try {
2914
2934
  o = Xe.parse(t);
@@ -2976,7 +2996,7 @@ async function Nr(t, r, s) {
2976
2996
  };
2977
2997
  }
2978
2998
  }
2979
- function Dr(t, r) {
2999
+ function Rr(t, r) {
2980
3000
  t(
2981
3001
  "playwright-page-goto",
2982
3002
  {
@@ -2985,7 +3005,7 @@ function Dr(t, r) {
2985
3005
  inputSchema: Xe.shape
2986
3006
  },
2987
3007
  async (s, o) => {
2988
- const e = await Nr(s, r, o);
3008
+ const e = await Or(s, r, o);
2989
3009
  if (e.error != null)
2990
3010
  return `Method: playwright-page-goto(${JSON.stringify(s)})
2991
3011
  ❌ Error: ${e.error}`;
@@ -3031,7 +3051,7 @@ async function et(t, r, s) {
3031
3051
  snapshotQuery: i
3032
3052
  };
3033
3053
  }
3034
- function Er(t, r) {
3054
+ function Pr(t, r) {
3035
3055
  t(
3036
3056
  "playwright-dom-snapshot-query-create",
3037
3057
  {
@@ -3047,7 +3067,7 @@ function Er(t, r) {
3047
3067
  }
3048
3068
  );
3049
3069
  }
3050
- function Fr(t) {
3070
+ function zr(t) {
3051
3071
  return function(s, o) {
3052
3072
  let e, n = 0;
3053
3073
  const a = o ? o.length : 0;
@@ -3083,8 +3103,8 @@ function Fr(t) {
3083
3103
  };
3084
3104
  };
3085
3105
  }
3086
- function Br(t, r) {
3087
- const s = _(r), o = s.getChilds(s.root), e = Le({
3106
+ function Lr(t, r) {
3107
+ const s = j(r), o = s.getChilds(s.root), e = Le({
3088
3108
  getId: (n) => {
3089
3109
  const a = s.getId(n);
3090
3110
  if (a == null)
@@ -3094,10 +3114,10 @@ function Br(t, r) {
3094
3114
  return a;
3095
3115
  },
3096
3116
  getChilds: (n) => s.getChilds(n),
3097
- createSnapshotNode: Fr(),
3117
+ createSnapshotNode: zr(),
3098
3118
  rootNodes: o ?? []
3099
3119
  });
3100
- return _(e);
3120
+ return j(e);
3101
3121
  }
3102
3122
  const oe = p.object({
3103
3123
  pageName: p.string().describe("Name of previously created page, to create snapshot from"),
@@ -3184,7 +3204,7 @@ async function tt(t, r, s) {
3184
3204
  ), h = {
3185
3205
  idToNode: new Map(d.idToNode),
3186
3206
  idToChildIds: new Map(d.idToChildIds)
3187
- }, m = Br(c, h), g = {
3207
+ }, m = Lr(c, h), g = {
3188
3208
  name: i,
3189
3209
  query: c,
3190
3210
  tree: m
@@ -3199,7 +3219,7 @@ async function tt(t, r, s) {
3199
3219
  };
3200
3220
  }
3201
3221
  }
3202
- function Or(t, r) {
3222
+ function Ur(t, r) {
3203
3223
  t(
3204
3224
  "playwright-dom-snapshot-create",
3205
3225
  {
@@ -3219,7 +3239,7 @@ function Or(t, r) {
3219
3239
  }
3220
3240
  );
3221
3241
  }
3222
- class Rr {
3242
+ class Ar {
3223
3243
  tokens = 16;
3224
3244
  getReportText = (r) => ({
3225
3245
  indent: !0,
@@ -3253,7 +3273,7 @@ const rt = p.object({
3253
3273
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
3254
3274
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
3255
3275
  });
3256
- async function zr(t, r, s) {
3276
+ async function qr(t, r, s) {
3257
3277
  let o;
3258
3278
  try {
3259
3279
  o = rt.parse(t);
@@ -3313,7 +3333,7 @@ async function zr(t, r, s) {
3313
3333
  error: "Either snapshotName or snapshot must be provided"
3314
3334
  };
3315
3335
  try {
3316
- const g = o.parentUid, b = Ge({
3336
+ const g = o.parentUid, b = qe({
3317
3337
  tree: d.tree,
3318
3338
  request: {
3319
3339
  parentNodeId: g,
@@ -3325,8 +3345,8 @@ async function zr(t, r, s) {
3325
3345
  maxTokensGroup: c
3326
3346
  }
3327
3347
  },
3328
- indexRangeGroupStrategy: new Rr()
3329
- }), y = qe(b);
3348
+ indexRangeGroupStrategy: new Ar()
3349
+ }), y = Ge(b);
3330
3350
  return {
3331
3351
  domSnapshot: d,
3332
3352
  queryCreated: h,
@@ -3341,7 +3361,7 @@ async function zr(t, r, s) {
3341
3361
  };
3342
3362
  }
3343
3363
  }
3344
- function Pr(t, r) {
3364
+ function Gr(t, r) {
3345
3365
  t(
3346
3366
  "playwright-dom-snapshot-browse",
3347
3367
  {
@@ -3350,7 +3370,7 @@ function Pr(t, r) {
3350
3370
  inputSchema: rt.shape
3351
3371
  },
3352
3372
  async (s, o) => {
3353
- const e = await zr(s, r, o);
3373
+ const e = await qr(s, r, o);
3354
3374
  if (e.error != null)
3355
3375
  return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
3356
3376
  ❌ Error: ${e.error}`;
@@ -3371,10 +3391,10 @@ ${e.report}`, n;
3371
3391
  }
3372
3392
  );
3373
3393
  }
3374
- function Lr(t, r) {
3375
- r.browserCreate && fr(t, r), r.browserList && mr(t, r), r.browserClose && gr(t, r), r.contextCreate && wr(t, r), r.contextList && br(t, r), r.contextClose && Sr(t, r), r.pageCreate && Mr(t, r), r.pageList && vr(t, r), r.pageClose && kr(t, r), r.pageGoto && Dr(t, r), r.domSnapshotQueryCreate && Er(t, r), r.domSnapshotCreate && Or(t, r), r.domSnapshotBrowse && Pr(t, r), console.log("Playwright manager");
3394
+ function jr(t, r) {
3395
+ r.browserCreate && wr(t, r), r.browserList && br(t, r), r.browserClose && Sr(t, r), r.contextCreate && $r(t, r), r.contextList && Mr(t, r), r.contextClose && vr(t, r), r.pageCreate && Nr(t, r), r.pageList && Er(t, r), r.pageClose && Br(t, r), r.pageGoto && Rr(t, r), r.domSnapshotQueryCreate && Pr(t, r), r.domSnapshotCreate && Ur(t, r), r.domSnapshotBrowse && Gr(t, r), console.log("Playwright manager");
3376
3396
  }
3377
- function Ur(t) {
3397
+ function _r(t) {
3378
3398
  const { logFilePath: r } = t;
3379
3399
  return async function(o, e, n, a) {
3380
3400
  await q({
@@ -3399,35 +3419,22 @@ function Ur(t) {
3399
3419
  function st() {
3400
3420
  return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
3401
3421
  }
3402
- function Ar(t) {
3403
- const r = G(), s = Gr();
3422
+ function Jr(t) {
3423
+ const r = A(), s = Kr();
3404
3424
  return r.use(s), r;
3405
3425
  }
3406
- function Gr(t) {
3407
- const r = G.Router();
3408
- return r.use(
3409
- ot.default({
3410
- origin: "*",
3411
- credentials: !0,
3412
- allowedHeaders: [
3413
- "Content-Type",
3414
- "Authorization",
3415
- "X-Session-Id",
3416
- "mcp-session-id"
3417
- ],
3418
- exposedHeaders: ["mcp-session-id"]
3419
- })
3420
- ), r.use(G.json()), r;
3426
+ function Kr(t) {
3427
+ const r = A.Router();
3428
+ return r.use((s, o, e) => {
3429
+ s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
3430
+ }), r.use(A.json()), r;
3421
3431
  }
3422
- function qr(t) {
3423
- const r = G.Router();
3424
- return r.use(yt({ authToken: t.authToken })), r.all(
3425
- "/mcp",
3426
- bt(t)
3427
- ), r;
3432
+ function Wr(t) {
3433
+ const r = A.Router();
3434
+ return r.use(wt({ authToken: t.authToken })), r.all("/mcp", $t(t)), r;
3428
3435
  }
3429
- function _r(t, r) {
3430
- return t.use(Ur({ logFilePath: r.logFilePath })), new Promise((s, o) => {
3436
+ function Qr(t, r) {
3437
+ return t.use(_r({ logFilePath: r.logFilePath })), new Promise((s, o) => {
3431
3438
  let e;
3432
3439
  const n = () => {
3433
3440
  s(e);
@@ -3441,7 +3448,7 @@ function _r(t, r) {
3441
3448
  }
3442
3449
  });
3443
3450
  }
3444
- function jr(t, r) {
3451
+ function Hr(t, r) {
3445
3452
  const s = t.address().family, o = t.address().port;
3446
3453
  let e = t.address().address;
3447
3454
  e === "::" ? e = "localhost" : s === "IPv6" && (e = `[${e}]`);
@@ -3455,47 +3462,47 @@ SSE Endpoint: ${n}/sse
3455
3462
 
3456
3463
  Log File: ${T.resolve(r.logFilePath)}`;
3457
3464
  }
3458
- function Jr(t, r) {
3459
- const s = T.join(r.logDir, st()), o = Pt(t, {
3465
+ function Yr(t, r) {
3466
+ const s = T.join(r.logDir, st()), o = At(t, {
3460
3467
  logFilePath: s
3461
3468
  });
3462
- r.tools.processManager && zt(o, r.tools.processManager), r.tools.fsManager && dr(o, r.tools.fsManager), r.tools.playwrightManager && Lr(o, {
3469
+ r.tools.processManager && Ut(o, r.tools.processManager), r.tools.fsManager && gr(o, r.tools.fsManager), r.tools.playwrightManager && jr(o, {
3463
3470
  ...r.tools.playwrightManager
3464
3471
  });
3465
3472
  }
3466
- async function cs(t) {
3467
- const r = T.join(t.logDir, st()), s = Ar(), o = qr({
3473
+ async function ps(t) {
3474
+ const r = T.join(t.logDir, st()), s = Jr(), o = Wr({
3468
3475
  ...t,
3469
3476
  logFilePath: r,
3470
3477
  createMcpServer: () => {
3471
- const n = new nt({
3472
- title: t.name,
3478
+ const n = new ot({
3479
+ title: t.title,
3473
3480
  name: t.name,
3474
- version: t.version,
3475
- authToken: t.authToken,
3476
- enableJsonResponse: !0
3481
+ version: t.version
3477
3482
  });
3478
- return Jr(n, t), n;
3483
+ return Yr(n, t), n;
3479
3484
  }
3480
3485
  });
3481
3486
  s.use(o);
3482
- const e = await _r(s, {
3487
+ const e = await Qr(s, {
3483
3488
  host: t.host,
3484
3489
  port: t.port,
3485
3490
  logFilePath: r
3486
3491
  });
3487
3492
  return console.log(
3488
- jr(e, {
3493
+ Hr(e, {
3494
+ title: t.title,
3489
3495
  name: t.name,
3490
3496
  version: t.version,
3491
- authToken: t.authToken,
3492
3497
  logFilePath: r
3493
3498
  })
3494
3499
  ), e;
3495
3500
  }
3496
3501
  export {
3497
- ls as A,
3498
- as as S,
3499
- is as a,
3500
- cs as s
3502
+ ms as A,
3503
+ hs as S,
3504
+ fs as a,
3505
+ ds as b,
3506
+ Zt as p,
3507
+ ps as s
3501
3508
  };