@flemist/mcp-project-tools 3.0.3 → 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.
- package/build/cli.js +25 -27
- package/build/index.d.ts +9 -3
- package/build/index.js +1 -1
- package/build/{startMcpServer-rxCDTISO.js → startMcpServer-B-t6kivp.js} +698 -670
- package/package.json +2 -2
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as st from "cors";
|
|
1
|
+
import A from "express";
|
|
3
2
|
import { McpServer as ot } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import * as F from "fs";
|
|
3
|
+
import { randomUUID as nt } from "crypto";
|
|
4
|
+
import * as B from "fs";
|
|
7
5
|
import * as T from "path";
|
|
8
|
-
import
|
|
6
|
+
import it from "path";
|
|
7
|
+
import { StreamableHTTPServerTransport as at } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
9
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 ct, poolRunWait as
|
|
11
|
+
import { Pool as ct, poolRunWait as z } from "@flemist/time-limits";
|
|
13
12
|
import { priorityCreate as P } from "@flemist/priority-queue";
|
|
14
13
|
import { useAbortController as ut, combineAbortSignals as dt } from "@flemist/async-utils";
|
|
15
14
|
import ft from "node:os";
|
|
16
|
-
import
|
|
17
|
-
import { webkit as
|
|
15
|
+
import ht from "picomatch";
|
|
16
|
+
import { webkit as mt, firefox as pt, chromium as gt } from "playwright";
|
|
18
17
|
function wt(t) {
|
|
19
18
|
const { authToken: r } = t;
|
|
20
19
|
return function(o, e, n) {
|
|
@@ -28,39 +27,76 @@ function wt(t) {
|
|
|
28
27
|
async function q(t) {
|
|
29
28
|
const { logFilePath: r, message: s, data: o } = t;
|
|
30
29
|
try {
|
|
31
|
-
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2),
|
|
30
|
+
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), a = `[${e}] ${s}
|
|
32
31
|
${n}
|
|
33
32
|
|
|
34
33
|
`;
|
|
35
|
-
await
|
|
34
|
+
await B.promises.mkdir(T.dirname(r), { recursive: !0 }), await B.promises.appendFile(r, a);
|
|
36
35
|
} catch (e) {
|
|
37
36
|
console.error(`Failed to log "${s}":`, e);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
const
|
|
41
|
-
function yt(t
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
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) {
|
|
85
|
+
return async function(s, o) {
|
|
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")
|
|
92
|
+
});
|
|
93
|
+
}
|
|
58
94
|
};
|
|
59
95
|
}
|
|
60
96
|
const O = /* @__PURE__ */ new Map();
|
|
61
|
-
let
|
|
62
|
-
const ie = 10,
|
|
63
|
-
function
|
|
97
|
+
let It = 0;
|
|
98
|
+
const ie = 10, Mt = 1800 * 1e3, k = 2e3, Tt = 500, vt = 5e3;
|
|
99
|
+
function Ct(t) {
|
|
64
100
|
const { commandLine: r, commandLineRules: s } = t;
|
|
65
101
|
let o = !1;
|
|
66
102
|
for (const e of s)
|
|
@@ -77,11 +113,11 @@ function It(t) {
|
|
|
77
113
|
}
|
|
78
114
|
return o;
|
|
79
115
|
}
|
|
80
|
-
function
|
|
81
|
-
return ++
|
|
116
|
+
function kt() {
|
|
117
|
+
return ++It;
|
|
82
118
|
}
|
|
83
119
|
let ae = !1;
|
|
84
|
-
function
|
|
120
|
+
function Nt() {
|
|
85
121
|
if (ae)
|
|
86
122
|
return;
|
|
87
123
|
ae = !0;
|
|
@@ -101,26 +137,26 @@ function Tt() {
|
|
|
101
137
|
function Q() {
|
|
102
138
|
const t = Date.now(), r = [];
|
|
103
139
|
for (const [s, o] of Array.from(O.entries()))
|
|
104
|
-
!o.isRunning && o.endTime && t - o.endTime.getTime() >
|
|
140
|
+
!o.isRunning && o.endTime && t - o.endTime.getTime() > Mt && r.push(s);
|
|
105
141
|
for (const s of r)
|
|
106
142
|
O.delete(s);
|
|
107
143
|
}
|
|
108
144
|
function H(t) {
|
|
109
145
|
const { process: r } = t, s = Date.now();
|
|
110
|
-
if (s - r.lastOutputTime.getTime() >=
|
|
146
|
+
if (s - r.lastOutputTime.getTime() >= Tt && (r.output += r.localOutput, r.localOutput = "", r.lastOutputTime = new Date(s), r.output.length > k)) {
|
|
111
147
|
const n = `
|
|
112
148
|
... [${r.output.length - k} characters trimmed] ...
|
|
113
|
-
`,
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
r.output = r.output.substring(0,
|
|
117
|
-
r.output.length - (
|
|
149
|
+
`, a = k - n.length;
|
|
150
|
+
if (a > 0) {
|
|
151
|
+
const i = Math.floor(a / 2);
|
|
152
|
+
r.output = r.output.substring(0, i) + n + r.output.substring(
|
|
153
|
+
r.output.length - (a - i)
|
|
118
154
|
);
|
|
119
155
|
} else
|
|
120
156
|
r.output = r.output.substring(0, k);
|
|
121
157
|
}
|
|
122
158
|
}
|
|
123
|
-
function
|
|
159
|
+
function Dt(t, r) {
|
|
124
160
|
const s = r.limit;
|
|
125
161
|
if (t.length <= s) return t;
|
|
126
162
|
const e = `
|
|
@@ -128,8 +164,8 @@ function vt(t, r) {
|
|
|
128
164
|
`, n = s - e.length;
|
|
129
165
|
if (n <= 0)
|
|
130
166
|
return t.substring(0, s);
|
|
131
|
-
const
|
|
132
|
-
return t.substring(0,
|
|
167
|
+
const a = Math.floor(n / 2);
|
|
168
|
+
return t.substring(0, a) + e + t.substring(t.length - (n - a));
|
|
133
169
|
}
|
|
134
170
|
function C(t) {
|
|
135
171
|
return `Invalid arguments: ${t instanceof Error ? t.message : "Unknown error"}.
|
|
@@ -160,7 +196,7 @@ async function Y(t, r) {
|
|
|
160
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.`
|
|
161
197
|
};
|
|
162
198
|
H({ process: n });
|
|
163
|
-
const
|
|
199
|
+
const a = n.output + n.localOutput, i = Dt(a, { limit: e });
|
|
164
200
|
return n.output = "", n.localOutput = "", {
|
|
165
201
|
id: n.id,
|
|
166
202
|
cwd: T.relative(r.workingDir || "", n.cwd),
|
|
@@ -170,11 +206,11 @@ async function Y(t, r) {
|
|
|
170
206
|
endTime: n.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
171
207
|
exitCode: n.exitCode,
|
|
172
208
|
isRunning: n.isRunning,
|
|
173
|
-
output:
|
|
209
|
+
output: i,
|
|
174
210
|
error: n.error
|
|
175
211
|
};
|
|
176
212
|
}
|
|
177
|
-
function
|
|
213
|
+
function Et(t, r) {
|
|
178
214
|
t(
|
|
179
215
|
"process-status",
|
|
180
216
|
{
|
|
@@ -203,7 +239,7 @@ function Me(t) {
|
|
|
203
239
|
K(t, "SIGKILL", (r) => {
|
|
204
240
|
r && !r.message.includes("not found") && console.error(`Error sending SIGKILL to process ${t}:`, r);
|
|
205
241
|
});
|
|
206
|
-
},
|
|
242
|
+
}, vt);
|
|
207
243
|
}
|
|
208
244
|
const Te = p.object({
|
|
209
245
|
id: p.number().describe(
|
|
@@ -223,32 +259,32 @@ async function ve(t, r) {
|
|
|
223
259
|
let s;
|
|
224
260
|
try {
|
|
225
261
|
s = Te.parse(t);
|
|
226
|
-
} catch (
|
|
262
|
+
} catch (h) {
|
|
227
263
|
return {
|
|
228
|
-
error: C(
|
|
264
|
+
error: C(h)
|
|
229
265
|
};
|
|
230
266
|
}
|
|
231
|
-
const { id: o, waitTime: e, autoKill: n, outputLimit:
|
|
232
|
-
if (!
|
|
267
|
+
const { id: o, waitTime: e, autoKill: n, outputLimit: a } = s, i = O.get(o);
|
|
268
|
+
if (!i)
|
|
233
269
|
return {
|
|
234
270
|
error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
235
271
|
};
|
|
236
272
|
const u = Date.now();
|
|
237
273
|
let l = !1, c = !1;
|
|
238
|
-
e != null && await new Promise((
|
|
274
|
+
e != null && await new Promise((m) => {
|
|
239
275
|
const g = setInterval(() => {
|
|
240
|
-
|
|
276
|
+
i.isRunning ? Date.now() - u >= e * 1e3 && (clearInterval(g), l = !0, n && i.pid && (Me(i.pid), c = !0), m()) : (clearInterval(g), m());
|
|
241
277
|
}, 100);
|
|
242
278
|
});
|
|
243
279
|
const f = (Date.now() - u) / 1e3;
|
|
244
280
|
return {
|
|
245
|
-
...await Y({ id: o, outputLimit:
|
|
281
|
+
...await Y({ id: o, outputLimit: a }, r),
|
|
246
282
|
waitDuration: f,
|
|
247
283
|
waitTimeExceeded: l,
|
|
248
284
|
autoKillExecuted: c
|
|
249
285
|
};
|
|
250
286
|
}
|
|
251
|
-
function
|
|
287
|
+
function Ft(t, r) {
|
|
252
288
|
t(
|
|
253
289
|
"process-wait",
|
|
254
290
|
{
|
|
@@ -287,7 +323,7 @@ const Ce = p.object({
|
|
|
287
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}.`
|
|
288
324
|
)
|
|
289
325
|
});
|
|
290
|
-
async function
|
|
326
|
+
async function Bt(t, r) {
|
|
291
327
|
Q();
|
|
292
328
|
let s;
|
|
293
329
|
try {
|
|
@@ -297,10 +333,10 @@ async function Nt(t, r) {
|
|
|
297
333
|
error: C(d)
|
|
298
334
|
};
|
|
299
335
|
}
|
|
300
|
-
const { commandLine: o, waitTime: e, autoKill: n, outputLimit:
|
|
301
|
-
if (!
|
|
302
|
-
const d =
|
|
303
|
-
(
|
|
336
|
+
const { commandLine: o, waitTime: e, autoKill: n, outputLimit: a } = s, { commandLineRules: i } = r, u = T.resolve(r.workingDir || "", s.cwd || "");
|
|
337
|
+
if (!Ct({ commandLine: o, commandLineRules: i })) {
|
|
338
|
+
const d = i.map(
|
|
339
|
+
(h) => `${h.rule.toUpperCase()}: /${h.regexp}/ (${h.note})`
|
|
304
340
|
).join(`
|
|
305
341
|
`);
|
|
306
342
|
return {
|
|
@@ -316,7 +352,7 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
316
352
|
return {
|
|
317
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.`
|
|
318
354
|
};
|
|
319
|
-
const c =
|
|
355
|
+
const c = kt(), f = {
|
|
320
356
|
id: c,
|
|
321
357
|
cwd: u,
|
|
322
358
|
commandLine: o,
|
|
@@ -334,12 +370,12 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
334
370
|
stdio: ["pipe", "pipe", "pipe"]
|
|
335
371
|
});
|
|
336
372
|
f.pid = d.pid;
|
|
337
|
-
const
|
|
338
|
-
const g =
|
|
373
|
+
const h = (m) => {
|
|
374
|
+
const g = m.toString();
|
|
339
375
|
f.localOutput += g, H({ process: f }), console.log(g);
|
|
340
376
|
};
|
|
341
|
-
return d.stdout?.on("data",
|
|
342
|
-
if (f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.exitCode =
|
|
377
|
+
return d.stdout?.on("data", h), d.stderr?.on("data", h), d.on("close", (m) => {
|
|
378
|
+
if (f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.exitCode = m !== null ? m : void 0, f.output += f.localOutput, f.localOutput = "", f.output.length > k) {
|
|
343
379
|
const b = `
|
|
344
380
|
... [${f.output.length - k} characters trimmed] ...
|
|
345
381
|
`, y = k - b.length;
|
|
@@ -351,15 +387,15 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
351
387
|
} else
|
|
352
388
|
f.output = f.output.substring(0, k);
|
|
353
389
|
}
|
|
354
|
-
console.log(`Process ${c} (${o}) exited with code ${
|
|
355
|
-
}), d.on("error", (
|
|
356
|
-
f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error =
|
|
357
|
-
}), e != null ? ve({ id: c, waitTime: e, autoKill: n, outputLimit:
|
|
390
|
+
console.log(`Process ${c} (${o}) exited with code ${m}`);
|
|
391
|
+
}), d.on("error", (m) => {
|
|
392
|
+
f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = m.message, console.error(`Process ${c} error:`, m.message);
|
|
393
|
+
}), e != null ? ve({ id: c, waitTime: e, autoKill: n, outputLimit: a }, r) : Y({ id: c, outputLimit: a }, r);
|
|
358
394
|
} catch (d) {
|
|
359
395
|
return f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = d instanceof Error ? d.message : "Unknown error", { error: f.error };
|
|
360
396
|
}
|
|
361
397
|
}
|
|
362
|
-
function
|
|
398
|
+
function Ot(t, r) {
|
|
363
399
|
const s = r.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
|
|
364
400
|
`);
|
|
365
401
|
t(
|
|
@@ -371,7 +407,7 @@ ${s}`,
|
|
|
371
407
|
inputSchema: Ce.shape
|
|
372
408
|
},
|
|
373
409
|
async (o) => {
|
|
374
|
-
const e = await
|
|
410
|
+
const e = await Bt(o, r);
|
|
375
411
|
if (!("output" in e))
|
|
376
412
|
return `Method: process-run(${JSON.stringify(o)})
|
|
377
413
|
❌ Error: ${e.error}`;
|
|
@@ -398,7 +434,7 @@ const ke = p.object({
|
|
|
398
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'
|
|
399
435
|
)
|
|
400
436
|
});
|
|
401
|
-
async function
|
|
437
|
+
async function Rt(t, r) {
|
|
402
438
|
Q();
|
|
403
439
|
let s;
|
|
404
440
|
try {
|
|
@@ -408,21 +444,21 @@ async function Et(t, r) {
|
|
|
408
444
|
error: C(l)
|
|
409
445
|
};
|
|
410
446
|
}
|
|
411
|
-
const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields:
|
|
412
|
-
let
|
|
447
|
+
const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: a } = s;
|
|
448
|
+
let i = Array.from(O.values());
|
|
413
449
|
if (o) {
|
|
414
450
|
const l = new Date(o.replace(/[_\s]/g, "T"));
|
|
415
|
-
|
|
451
|
+
i = i.filter((c) => c.startTime >= l);
|
|
416
452
|
}
|
|
417
453
|
if (e) {
|
|
418
454
|
const l = new Date(e.replace(/[_\s]/g, "T"));
|
|
419
|
-
|
|
455
|
+
i = i.filter((c) => c.endTime && c.endTime >= l);
|
|
420
456
|
}
|
|
421
|
-
return n && (
|
|
457
|
+
return n && (i = i.filter((l) => l.isRunning)), { processes: i.map((l) => {
|
|
422
458
|
H({ process: l });
|
|
423
459
|
let c = {
|
|
424
460
|
id: l.id,
|
|
425
|
-
cwd:
|
|
461
|
+
cwd: it.relative(r.workingDir || "", l.cwd),
|
|
426
462
|
commandLine: l.commandLine,
|
|
427
463
|
pid: l.pid,
|
|
428
464
|
startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
@@ -432,16 +468,16 @@ async function Et(t, r) {
|
|
|
432
468
|
output: l.output + l.localOutput,
|
|
433
469
|
error: l.error
|
|
434
470
|
};
|
|
435
|
-
if (
|
|
471
|
+
if (a) {
|
|
436
472
|
const f = {};
|
|
437
|
-
for (const d of
|
|
473
|
+
for (const d of a)
|
|
438
474
|
d in c && (f[d] = c[d]);
|
|
439
475
|
c = f;
|
|
440
476
|
}
|
|
441
477
|
return c;
|
|
442
478
|
}) };
|
|
443
479
|
}
|
|
444
|
-
function
|
|
480
|
+
function Pt(t, r) {
|
|
445
481
|
t(
|
|
446
482
|
"process-list",
|
|
447
483
|
{
|
|
@@ -450,7 +486,7 @@ function Bt(t, r) {
|
|
|
450
486
|
inputSchema: ke.shape
|
|
451
487
|
},
|
|
452
488
|
async (s) => {
|
|
453
|
-
const o = await
|
|
489
|
+
const o = await Rt(s, r);
|
|
454
490
|
if (o.error != null)
|
|
455
491
|
return `Method: process-list(${JSON.stringify(s)})
|
|
456
492
|
❌ Error: ${o.error}`;
|
|
@@ -469,7 +505,7 @@ const Ne = p.object({
|
|
|
469
505
|
"Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
|
|
470
506
|
)
|
|
471
507
|
});
|
|
472
|
-
function
|
|
508
|
+
function zt(t) {
|
|
473
509
|
let r;
|
|
474
510
|
try {
|
|
475
511
|
r = Ne.parse(t);
|
|
@@ -499,7 +535,7 @@ function Ft(t) {
|
|
|
499
535
|
};
|
|
500
536
|
}
|
|
501
537
|
}
|
|
502
|
-
function
|
|
538
|
+
function Lt(t, r) {
|
|
503
539
|
t(
|
|
504
540
|
"process-kill",
|
|
505
541
|
{
|
|
@@ -508,15 +544,15 @@ function Ot(t, r) {
|
|
|
508
544
|
inputSchema: Ne.shape
|
|
509
545
|
},
|
|
510
546
|
async (s) => {
|
|
511
|
-
const o =
|
|
547
|
+
const o = zt(s);
|
|
512
548
|
return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
|
|
513
549
|
❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
|
|
514
550
|
${JSON.stringify(o, null, 2)}`;
|
|
515
551
|
}
|
|
516
552
|
);
|
|
517
553
|
}
|
|
518
|
-
function
|
|
519
|
-
|
|
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);
|
|
520
556
|
const s = r.commandLineRules?.map(
|
|
521
557
|
(o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
|
|
522
558
|
) || [];
|
|
@@ -529,15 +565,15 @@ ${s.map((o) => `- ${o}`).join(`
|
|
|
529
565
|
`
|
|
530
566
|
);
|
|
531
567
|
}
|
|
532
|
-
function
|
|
568
|
+
function At(t, r) {
|
|
533
569
|
return function(o, e, n) {
|
|
534
|
-
const
|
|
570
|
+
const a = async (...i) => {
|
|
535
571
|
await q({
|
|
536
572
|
logFilePath: r.logFilePath,
|
|
537
573
|
message: "REQUEST",
|
|
538
|
-
data: { name: o, args:
|
|
574
|
+
data: { name: o, args: i }
|
|
539
575
|
});
|
|
540
|
-
const u = await n(...
|
|
576
|
+
const u = await n(...i);
|
|
541
577
|
return await q({
|
|
542
578
|
logFilePath: r.logFilePath,
|
|
543
579
|
message: "RESPONSE",
|
|
@@ -554,17 +590,17 @@ function zt(t, r) {
|
|
|
554
590
|
return t.registerTool(
|
|
555
591
|
o,
|
|
556
592
|
e,
|
|
557
|
-
|
|
593
|
+
a
|
|
558
594
|
);
|
|
559
595
|
};
|
|
560
596
|
}
|
|
561
|
-
function
|
|
597
|
+
function qt(t) {
|
|
562
598
|
return t.match(/^[/\\]?[^/\\]+/)[0];
|
|
563
599
|
}
|
|
564
|
-
function
|
|
565
|
-
return
|
|
600
|
+
function Gt(t, r) {
|
|
601
|
+
return qt(t) + "|" + r.ino;
|
|
566
602
|
}
|
|
567
|
-
function
|
|
603
|
+
function jt(t) {
|
|
568
604
|
return t.endsWith(":") && (t += "/"), T.resolve(t);
|
|
569
605
|
}
|
|
570
606
|
const De = new ct(ft.cpus().length);
|
|
@@ -574,7 +610,7 @@ function le(t, r) {
|
|
|
574
610
|
r.maxFileDateModified
|
|
575
611
|
), t.countFiles += r.countFiles, t.countDirs += r.countDirs, t.countLinks += r.countLinks;
|
|
576
612
|
}
|
|
577
|
-
const
|
|
613
|
+
const _t = function(r) {
|
|
578
614
|
return r.code === "ENOENT";
|
|
579
615
|
};
|
|
580
616
|
function Ee(t) {
|
|
@@ -587,16 +623,16 @@ function Ee(t) {
|
|
|
587
623
|
countDirs: 0,
|
|
588
624
|
countLinks: 0
|
|
589
625
|
});
|
|
590
|
-
const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? De,
|
|
591
|
-
async function d(
|
|
592
|
-
if (!(
|
|
593
|
-
throw
|
|
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;
|
|
627
|
+
async function d(m) {
|
|
628
|
+
if (!(a && await a(m)) && !_t(m))
|
|
629
|
+
throw m;
|
|
594
630
|
}
|
|
595
|
-
function m
|
|
596
|
-
return !(!l || l.minTotalContentSize != null &&
|
|
631
|
+
function h(m) {
|
|
632
|
+
return !(!l || l.minTotalContentSize != null && m < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
|
|
597
633
|
}
|
|
598
|
-
return ut(async (
|
|
599
|
-
const g = dt(e,
|
|
634
|
+
return ut(async (m) => {
|
|
635
|
+
const g = dt(e, m), b = {
|
|
600
636
|
totalSize: 0,
|
|
601
637
|
maxFileDateModified: 0,
|
|
602
638
|
countFiles: 0,
|
|
@@ -604,13 +640,13 @@ function Ee(t) {
|
|
|
604
640
|
countLinks: 0
|
|
605
641
|
};
|
|
606
642
|
function y(w, M) {
|
|
607
|
-
if (
|
|
643
|
+
if (h(M.totalSize)) {
|
|
608
644
|
const v = `${M.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${w}`;
|
|
609
645
|
l?.handleLog ? l.handleLog(v) : console.log(v);
|
|
610
646
|
}
|
|
611
647
|
}
|
|
612
648
|
async function x(w, M, $, v) {
|
|
613
|
-
return c ? await
|
|
649
|
+
return c ? await z({
|
|
614
650
|
pool: n,
|
|
615
651
|
func: async () => {
|
|
616
652
|
try {
|
|
@@ -633,16 +669,16 @@ function Ee(t) {
|
|
|
633
669
|
}
|
|
634
670
|
async function I(w, M, $, v) {
|
|
635
671
|
v || (v = w);
|
|
636
|
-
const D = await
|
|
672
|
+
const D = await z({
|
|
637
673
|
pool: n,
|
|
638
|
-
func: () =>
|
|
674
|
+
func: () => B.promises.lstat(w).catch(d),
|
|
639
675
|
count: 1,
|
|
640
|
-
priority: P(M, P(1,
|
|
676
|
+
priority: P(M, P(1, i)),
|
|
641
677
|
abortSignal: g
|
|
642
678
|
});
|
|
643
679
|
if (!D || !$ && D.isFile())
|
|
644
680
|
return null;
|
|
645
|
-
const ne =
|
|
681
|
+
const ne = Gt(w, D);
|
|
646
682
|
if (o.has(ne))
|
|
647
683
|
return null;
|
|
648
684
|
o.add(ne);
|
|
@@ -653,51 +689,51 @@ function Ee(t) {
|
|
|
653
689
|
countDirs: 0,
|
|
654
690
|
countLinks: 0
|
|
655
691
|
};
|
|
656
|
-
const
|
|
692
|
+
const L = P(
|
|
657
693
|
M,
|
|
658
|
-
P(D.isDirectory() ? 2 : 3,
|
|
694
|
+
P(D.isDirectory() ? 2 : 3, i)
|
|
659
695
|
);
|
|
660
696
|
if (D.isSymbolicLink()) {
|
|
661
697
|
if (u) {
|
|
662
|
-
const
|
|
698
|
+
const F = await z({
|
|
663
699
|
pool: n,
|
|
664
|
-
func: () =>
|
|
700
|
+
func: () => B.promises.readlink(w).catch(d).then((R) => R ?? null),
|
|
665
701
|
count: 1,
|
|
666
|
-
priority:
|
|
702
|
+
priority: L,
|
|
667
703
|
abortSignal: g
|
|
668
704
|
});
|
|
669
|
-
if (
|
|
670
|
-
const R = T.isAbsolute(
|
|
705
|
+
if (F) {
|
|
706
|
+
const R = T.isAbsolute(F) ? F : T.resolve(T.dirname(v), F), U = await I(
|
|
671
707
|
R,
|
|
672
708
|
M,
|
|
673
709
|
$,
|
|
674
710
|
v
|
|
675
711
|
);
|
|
676
|
-
|
|
712
|
+
U && (N = U);
|
|
677
713
|
}
|
|
678
714
|
}
|
|
679
715
|
return ($ || N.countFiles + N.countDirs + N.countLinks > 1) && (N.countLinks += 1, await x(
|
|
680
716
|
v,
|
|
681
717
|
D,
|
|
682
718
|
N,
|
|
683
|
-
|
|
719
|
+
L
|
|
684
720
|
) && (le(b, N), y(v, N))), N;
|
|
685
721
|
} else if (D.isDirectory()) {
|
|
686
|
-
const
|
|
722
|
+
const F = await z({
|
|
687
723
|
pool: n,
|
|
688
|
-
func: () =>
|
|
724
|
+
func: () => B.promises.readdir(w).catch(d),
|
|
689
725
|
count: 1,
|
|
690
|
-
priority:
|
|
726
|
+
priority: i,
|
|
691
727
|
abortSignal: g
|
|
692
728
|
});
|
|
693
|
-
if (
|
|
694
|
-
for (let R = 0,
|
|
695
|
-
|
|
729
|
+
if (F) {
|
|
730
|
+
for (let R = 0, U = F.length; R < U; R++)
|
|
731
|
+
F[R] = T.join(v, F[R]);
|
|
696
732
|
N = await Ee({
|
|
697
733
|
...t,
|
|
698
|
-
paths:
|
|
734
|
+
paths: F,
|
|
699
735
|
abortSignal: g,
|
|
700
|
-
priority:
|
|
736
|
+
priority: L,
|
|
701
737
|
level: s + 1,
|
|
702
738
|
walkedIds: o
|
|
703
739
|
});
|
|
@@ -707,21 +743,21 @@ function Ee(t) {
|
|
|
707
743
|
v,
|
|
708
744
|
D,
|
|
709
745
|
N,
|
|
710
|
-
|
|
746
|
+
L
|
|
711
747
|
) && (le(b, N), y(v, N))), N;
|
|
712
748
|
}
|
|
713
749
|
const S = [];
|
|
714
750
|
for (let w = 0, M = r.length; w < M; w++) {
|
|
715
|
-
const $ =
|
|
751
|
+
const $ = jt(r[w]), v = f ? f($) : !0;
|
|
716
752
|
v !== !1 && S.push(I($, w, v));
|
|
717
753
|
}
|
|
718
754
|
return await Promise.all(S), b;
|
|
719
755
|
});
|
|
720
756
|
}
|
|
721
|
-
function
|
|
757
|
+
function Fe(t) {
|
|
722
758
|
return Ee(t);
|
|
723
759
|
}
|
|
724
|
-
function
|
|
760
|
+
function Jt(t, r) {
|
|
725
761
|
if (!r || r === ".")
|
|
726
762
|
return t;
|
|
727
763
|
const s = t.startsWith("^");
|
|
@@ -729,21 +765,21 @@ function Gt(t, r) {
|
|
|
729
765
|
const o = t.startsWith("!");
|
|
730
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;
|
|
731
767
|
}
|
|
732
|
-
function
|
|
768
|
+
function Kt(t) {
|
|
733
769
|
const r = t.startsWith("!");
|
|
734
770
|
return r && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), r && (t = "!" + t), t;
|
|
735
771
|
}
|
|
736
772
|
function ce(t) {
|
|
737
773
|
return "^" + t;
|
|
738
774
|
}
|
|
739
|
-
async function
|
|
740
|
-
const s = (await
|
|
775
|
+
async function Wt(t) {
|
|
776
|
+
const s = (await B.promises.readFile(t, "utf-8")).split(`
|
|
741
777
|
`), o = [];
|
|
742
778
|
return s.forEach((e) => {
|
|
743
779
|
e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
|
|
744
780
|
}), o;
|
|
745
781
|
}
|
|
746
|
-
async function
|
|
782
|
+
async function Be(t) {
|
|
747
783
|
const r = t.rootDir ?? ".", s = [];
|
|
748
784
|
if (!t.globs?.length)
|
|
749
785
|
return s;
|
|
@@ -752,13 +788,13 @@ async function Fe(t) {
|
|
|
752
788
|
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? ce(e.value) : e.value));
|
|
753
789
|
}), o.length && await Promise.all(
|
|
754
790
|
o.map(async (e) => {
|
|
755
|
-
await
|
|
791
|
+
await z({
|
|
756
792
|
pool: De,
|
|
757
793
|
count: 1,
|
|
758
794
|
func: async () => {
|
|
759
|
-
const n = T.resolve(r, e.value),
|
|
760
|
-
|
|
761
|
-
u =
|
|
795
|
+
const n = T.resolve(r, e.value), a = await Wt(n), i = T.relative(r, T.dirname(n));
|
|
796
|
+
a.forEach((u) => {
|
|
797
|
+
u = Kt(u), u = Jt(u, i), s.push(e.exclude ? ce(u) : u);
|
|
762
798
|
});
|
|
763
799
|
}
|
|
764
800
|
});
|
|
@@ -775,18 +811,18 @@ function Oe({
|
|
|
775
811
|
e = e.replace(/\\/g, "/").trim();
|
|
776
812
|
const n = e.startsWith("^");
|
|
777
813
|
n && (e = e.substring(1).trim());
|
|
778
|
-
const
|
|
779
|
-
if (
|
|
814
|
+
const a = e.startsWith("!");
|
|
815
|
+
if (a && (e = e.substring(1).trim()), e.startsWith("!") || e.startsWith("^"))
|
|
780
816
|
throw new Error(
|
|
781
817
|
`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.`
|
|
782
818
|
);
|
|
783
819
|
e.startsWith("/") && (e = "." + e);
|
|
784
|
-
const
|
|
785
|
-
if (!
|
|
820
|
+
const i = r ? T.resolve(r, e).replace(/\\/g, "/") : e;
|
|
821
|
+
if (!i)
|
|
786
822
|
return;
|
|
787
823
|
let u;
|
|
788
824
|
try {
|
|
789
|
-
u =
|
|
825
|
+
u = ht(i, {
|
|
790
826
|
nocase: s ?? !1,
|
|
791
827
|
dot: !0,
|
|
792
828
|
strictBrackets: !0
|
|
@@ -799,28 +835,28 @@ function Oe({
|
|
|
799
835
|
}
|
|
800
836
|
o.push({
|
|
801
837
|
exclude: n,
|
|
802
|
-
negative:
|
|
803
|
-
debugInfo:
|
|
838
|
+
negative: a,
|
|
839
|
+
debugInfo: i,
|
|
804
840
|
match: u
|
|
805
841
|
});
|
|
806
842
|
}), function(n) {
|
|
807
843
|
n = n.replace(/\\/g, "/");
|
|
808
|
-
let
|
|
844
|
+
let a = null, i = !1;
|
|
809
845
|
for (let u = 0, l = o.length; u < l; u++) {
|
|
810
846
|
const c = o[u];
|
|
811
|
-
c.match(n) && (c.exclude ?
|
|
847
|
+
c.match(n) && (c.exclude ? i = !c.negative : (a = !c.negative, i = !1));
|
|
812
848
|
}
|
|
813
|
-
return
|
|
849
|
+
return i ? !1 : a;
|
|
814
850
|
};
|
|
815
851
|
}
|
|
816
|
-
async function
|
|
852
|
+
async function Qt(t) {
|
|
817
853
|
const r = t.rootDir ?? ".", s = [], o = {};
|
|
818
854
|
t.result.countFiles && (o.countFiles = 0), t.result.size && (o.size = 0);
|
|
819
|
-
const e = await
|
|
855
|
+
const e = await Be({
|
|
820
856
|
rootDir: r,
|
|
821
857
|
globs: t.globs
|
|
822
858
|
});
|
|
823
|
-
return await
|
|
859
|
+
return await Fe({
|
|
824
860
|
paths: [r],
|
|
825
861
|
walkLinks: !0,
|
|
826
862
|
matchPath: Oe({
|
|
@@ -828,25 +864,25 @@ async function jt(t) {
|
|
|
828
864
|
rootDir: r,
|
|
829
865
|
noCase: !0
|
|
830
866
|
}),
|
|
831
|
-
handlePath: async ({ path: n, stat:
|
|
832
|
-
const u = T.relative(r, n), l =
|
|
867
|
+
handlePath: async ({ path: n, stat: a, itemStat: i }) => {
|
|
868
|
+
const u = T.relative(r, n), l = a.isDirectory(), c = a.isFile();
|
|
833
869
|
if (!l && !c)
|
|
834
870
|
return !0;
|
|
835
|
-
const f = (u || ".").replace(/\\/g, "/"), d = l ? "dir" : "file",
|
|
871
|
+
const f = (u || ".").replace(/\\/g, "/"), d = l ? "dir" : "file", h = l ? i.maxFileDateModified || null : a.mtimeMs, m = l ? i.totalSize : a.size, g = l ? i.countFiles : null, b = {
|
|
836
872
|
path: f,
|
|
837
873
|
type: d
|
|
838
874
|
};
|
|
839
|
-
if (t.result.dateModified && (b.dateModified =
|
|
875
|
+
if (t.result.dateModified && (b.dateModified = h), t.result.size && (b.size = m), t.result.countFiles && (b.countFiles = g), t.dateModified && h != null) {
|
|
840
876
|
const [y, x] = t.dateModified;
|
|
841
|
-
if (y != null &&
|
|
877
|
+
if (y != null && h < y || x != null && h > x)
|
|
842
878
|
return !1;
|
|
843
879
|
}
|
|
844
|
-
if (t.totalSize &&
|
|
880
|
+
if (t.totalSize && m != null) {
|
|
845
881
|
const [y, x] = t.totalSize;
|
|
846
|
-
if (y != null &&
|
|
882
|
+
if (y != null && m < y || x != null && m > x)
|
|
847
883
|
return !1;
|
|
848
884
|
}
|
|
849
|
-
return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" &&
|
|
885
|
+
return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && m != null && (o.size = (o.size ?? 0) + m), h != null && (o.dateModified == null || h > o.dateModified) && (o.dateModified = h), l && !t.result.dirs || c && !t.result.files || s.push(b), !0;
|
|
850
886
|
}
|
|
851
887
|
}), { items: s, totals: o };
|
|
852
888
|
}
|
|
@@ -858,55 +894,55 @@ function fe(t) {
|
|
|
858
894
|
r /= de, s++;
|
|
859
895
|
return `${s === 0 ? r.toString() : r.toFixed(2)}${ue[s]}`;
|
|
860
896
|
}
|
|
861
|
-
function
|
|
897
|
+
function he(t) {
|
|
862
898
|
const s = Date.now() - t;
|
|
863
899
|
if (s < 0) return "0s";
|
|
864
|
-
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60),
|
|
865
|
-
return l > 0 ? `${l}Y` : u > 0 ? `${u}M` :
|
|
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);
|
|
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`;
|
|
866
902
|
}
|
|
867
|
-
function
|
|
903
|
+
function Ht(t, r) {
|
|
868
904
|
return r?.length ? [...t].sort((s, o) => {
|
|
869
905
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
870
|
-
const
|
|
871
|
-
let
|
|
872
|
-
switch (
|
|
906
|
+
const a = r[e];
|
|
907
|
+
let i, u;
|
|
908
|
+
switch (a.field) {
|
|
873
909
|
case "type":
|
|
874
|
-
|
|
910
|
+
i = s.type, u = o.type;
|
|
875
911
|
break;
|
|
876
912
|
case "path":
|
|
877
|
-
|
|
913
|
+
i = s.path, u = o.path;
|
|
878
914
|
break;
|
|
879
915
|
case "dateModified":
|
|
880
|
-
|
|
916
|
+
i = s.dateModified, u = o.dateModified;
|
|
881
917
|
break;
|
|
882
918
|
case "size":
|
|
883
|
-
|
|
919
|
+
i = s.size, u = o.size;
|
|
884
920
|
break;
|
|
885
921
|
case "countFiles":
|
|
886
|
-
|
|
922
|
+
i = s.countFiles, u = o.countFiles;
|
|
887
923
|
break;
|
|
888
924
|
}
|
|
889
|
-
if (
|
|
925
|
+
if (i == null) {
|
|
890
926
|
if (u == null)
|
|
891
927
|
continue;
|
|
892
928
|
return 1;
|
|
893
929
|
}
|
|
894
930
|
if (u == null)
|
|
895
931
|
return -1;
|
|
896
|
-
const l =
|
|
932
|
+
const l = i > u ? 1 : i < u ? -1 : 0;
|
|
897
933
|
if (l !== 0)
|
|
898
|
-
return
|
|
934
|
+
return a.desc ? -l : l;
|
|
899
935
|
}
|
|
900
936
|
return 0;
|
|
901
937
|
}) : t;
|
|
902
938
|
}
|
|
903
|
-
function
|
|
904
|
-
const s =
|
|
939
|
+
function Yt(t, r) {
|
|
940
|
+
const s = Ht(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
|
|
905
941
|
let e = "";
|
|
906
942
|
if (s.length > 0 && o.length > 0) {
|
|
907
|
-
for (let n = 0,
|
|
908
|
-
const
|
|
909
|
-
switch (n > 0 && (e += " | "),
|
|
943
|
+
for (let n = 0, a = o.length; n < a; n++) {
|
|
944
|
+
const i = o[n];
|
|
945
|
+
switch (n > 0 && (e += " | "), i) {
|
|
910
946
|
case "dateModified":
|
|
911
947
|
e += "Time ago (s/m/h/d/w/M/Y)";
|
|
912
948
|
break;
|
|
@@ -924,27 +960,27 @@ function Kt(t, r) {
|
|
|
924
960
|
break;
|
|
925
961
|
}
|
|
926
962
|
}
|
|
927
|
-
for (let n = 0,
|
|
928
|
-
const
|
|
963
|
+
for (let n = 0, a = s.length; n < a; n++) {
|
|
964
|
+
const i = s[n];
|
|
929
965
|
e += `
|
|
930
966
|
`;
|
|
931
967
|
for (let u = 0, l = o.length; u < l; u++) {
|
|
932
968
|
const c = o[u];
|
|
933
969
|
switch (u > 0 && (e += " | "), c) {
|
|
934
970
|
case "dateModified":
|
|
935
|
-
e +=
|
|
971
|
+
e += i.dateModified ? he(i.dateModified) : "-";
|
|
936
972
|
break;
|
|
937
973
|
case "size":
|
|
938
|
-
e += fe(
|
|
974
|
+
e += fe(i.size);
|
|
939
975
|
break;
|
|
940
976
|
case "type":
|
|
941
|
-
e +=
|
|
977
|
+
e += i.type;
|
|
942
978
|
break;
|
|
943
979
|
case "path":
|
|
944
|
-
e +=
|
|
980
|
+
e += i.type === "dir" ? `${i.path}/` : i.path;
|
|
945
981
|
break;
|
|
946
982
|
case "countFiles":
|
|
947
|
-
|
|
983
|
+
i.type === "dir" ? e += i.countFiles != null ? i.countFiles.toString() : "-" : e += "-";
|
|
948
984
|
break;
|
|
949
985
|
}
|
|
950
986
|
}
|
|
@@ -954,12 +990,14 @@ function Kt(t, r) {
|
|
|
954
990
|
e.length > 0 && (e += `
|
|
955
991
|
---
|
|
956
992
|
`);
|
|
957
|
-
const n = fe(t.totals.size ?? 0),
|
|
958
|
-
e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${
|
|
993
|
+
const n = fe(t.totals.size ?? 0), a = t.totals.dateModified ? `, last modified ${he(t.totals.dateModified)} ago` : "";
|
|
994
|
+
e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${a}`;
|
|
959
995
|
}
|
|
960
996
|
return e;
|
|
961
997
|
}
|
|
962
|
-
const
|
|
998
|
+
const Vt = "3.0.5", Zt = {
|
|
999
|
+
version: Vt
|
|
1000
|
+
}, ds = "Project Tools", fs = "project-tools", hs = Zt.version, ms = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", me = 25e3;
|
|
963
1001
|
function pe(t) {
|
|
964
1002
|
const r = t.match(
|
|
965
1003
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
@@ -1054,7 +1092,7 @@ const Re = p.object({
|
|
|
1054
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'
|
|
1055
1093
|
)
|
|
1056
1094
|
});
|
|
1057
|
-
async function
|
|
1095
|
+
async function Xt(t, r) {
|
|
1058
1096
|
let s;
|
|
1059
1097
|
try {
|
|
1060
1098
|
s = Re.parse(t);
|
|
@@ -1067,8 +1105,8 @@ async function Wt(t, r) {
|
|
|
1067
1105
|
globs: o,
|
|
1068
1106
|
showFiles: e,
|
|
1069
1107
|
showDirs: n,
|
|
1070
|
-
sortBy:
|
|
1071
|
-
minTimeAgo:
|
|
1108
|
+
sortBy: a,
|
|
1109
|
+
minTimeAgo: i,
|
|
1072
1110
|
maxTimeAgo: u,
|
|
1073
1111
|
minTotalSize: l,
|
|
1074
1112
|
maxTotalSize: c
|
|
@@ -1078,7 +1116,7 @@ async function Wt(t, r) {
|
|
|
1078
1116
|
error: 'Fields array must include "path" field when fields are specified. The "path" field is required to identify files and directories in the output'
|
|
1079
1117
|
};
|
|
1080
1118
|
const f = s.fields ? s.fields.map((g) => g === "totalCountFiles" ? "countFiles" : g === "lastModified" ? "dateModified" : g) : [];
|
|
1081
|
-
let d =
|
|
1119
|
+
let d = a?.map((g) => {
|
|
1082
1120
|
let b = g.field;
|
|
1083
1121
|
return b === "totalCountFiles" && (b = "countFiles"), b === "lastModified" && (b = "dateModified"), {
|
|
1084
1122
|
field: b,
|
|
@@ -1087,17 +1125,17 @@ async function Wt(t, r) {
|
|
|
1087
1125
|
};
|
|
1088
1126
|
}) ?? null;
|
|
1089
1127
|
(!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
|
|
1090
|
-
const
|
|
1128
|
+
const h = d?.map((g) => g.field) || [], m = T.resolve(
|
|
1091
1129
|
r.workingDir || "",
|
|
1092
1130
|
s.rootDir || ""
|
|
1093
1131
|
);
|
|
1094
1132
|
try {
|
|
1095
1133
|
try {
|
|
1096
|
-
await
|
|
1134
|
+
await B.promises.access(m, B.constants.F_OK);
|
|
1097
1135
|
} catch ($) {
|
|
1098
1136
|
if ($.code === "ENOENT")
|
|
1099
1137
|
return {
|
|
1100
|
-
error: `Directory does not exist: "${
|
|
1138
|
+
error: `Directory does not exist: "${m}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-list without rootDir to list the current directory, or check parent directories first.`
|
|
1101
1139
|
};
|
|
1102
1140
|
throw $;
|
|
1103
1141
|
}
|
|
@@ -1108,14 +1146,14 @@ async function Wt(t, r) {
|
|
|
1108
1146
|
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], b = r.globsExclude || [], y = [...g, ...b], x = {
|
|
1109
1147
|
files: e ?? !1,
|
|
1110
1148
|
dirs: n ?? !1,
|
|
1111
|
-
dateModified: f.includes("dateModified") ||
|
|
1112
|
-
size: f.includes("size") ||
|
|
1113
|
-
countFiles: f.includes("countFiles") ||
|
|
1149
|
+
dateModified: f.includes("dateModified") || h.includes("dateModified"),
|
|
1150
|
+
size: f.includes("size") || h.includes("size"),
|
|
1151
|
+
countFiles: f.includes("countFiles") || h.includes("countFiles")
|
|
1114
1152
|
};
|
|
1115
1153
|
let I = null, S = null;
|
|
1116
|
-
if (
|
|
1154
|
+
if (i || u)
|
|
1117
1155
|
try {
|
|
1118
|
-
const $ = Date.now(), v = u ? $ - pe(u) : null, D =
|
|
1156
|
+
const $ = Date.now(), v = u ? $ - pe(u) : null, D = i ? $ - pe(i) : null;
|
|
1119
1157
|
I = [v, D];
|
|
1120
1158
|
} catch ($) {
|
|
1121
1159
|
return {
|
|
@@ -1131,17 +1169,17 @@ async function Wt(t, r) {
|
|
|
1131
1169
|
error: $ instanceof Error ? $.message : "Unknown error parsing size filter"
|
|
1132
1170
|
};
|
|
1133
1171
|
}
|
|
1134
|
-
const w = await
|
|
1135
|
-
rootDir:
|
|
1172
|
+
const w = await Qt({
|
|
1173
|
+
rootDir: m || null,
|
|
1136
1174
|
globs: y,
|
|
1137
1175
|
result: x,
|
|
1138
1176
|
dateModified: I,
|
|
1139
1177
|
totalSize: S
|
|
1140
1178
|
});
|
|
1141
|
-
return w.items.length >
|
|
1142
|
-
error: `Number of paths (${w.items.length}) exceeds maximum allowed (${
|
|
1179
|
+
return w.items.length > me ? {
|
|
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.`
|
|
1143
1181
|
} : {
|
|
1144
|
-
output:
|
|
1182
|
+
output: Yt(w, {
|
|
1145
1183
|
sort: d,
|
|
1146
1184
|
fields: f,
|
|
1147
1185
|
totals: !0
|
|
@@ -1151,7 +1189,7 @@ async function Wt(t, r) {
|
|
|
1151
1189
|
return { error: g instanceof Error ? g.message : "Unknown error" };
|
|
1152
1190
|
}
|
|
1153
1191
|
}
|
|
1154
|
-
function
|
|
1192
|
+
function er(t, r) {
|
|
1155
1193
|
t(
|
|
1156
1194
|
"fs-list",
|
|
1157
1195
|
{
|
|
@@ -1160,19 +1198,19 @@ function Qt(t, r) {
|
|
|
1160
1198
|
inputSchema: Re.shape
|
|
1161
1199
|
},
|
|
1162
1200
|
async (s) => {
|
|
1163
|
-
const o = await
|
|
1201
|
+
const o = await Xt(s, r);
|
|
1164
1202
|
return o.error ? `Method: fs-list(${JSON.stringify(s)})
|
|
1165
1203
|
❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
|
|
1166
1204
|
${o.output || JSON.stringify(o, null, 2)}`;
|
|
1167
1205
|
}
|
|
1168
1206
|
);
|
|
1169
1207
|
}
|
|
1170
|
-
const
|
|
1208
|
+
const _ = /* @__PURE__ */ new Map();
|
|
1171
1209
|
function V(t) {
|
|
1172
|
-
return
|
|
1210
|
+
return _.has(t) || _.set(t, {
|
|
1173
1211
|
fsSnapshotQueries: /* @__PURE__ */ new Map(),
|
|
1174
1212
|
fsSnapshots: /* @__PURE__ */ new Map()
|
|
1175
|
-
}),
|
|
1213
|
+
}), _.get(t);
|
|
1176
1214
|
}
|
|
1177
1215
|
function we(t) {
|
|
1178
1216
|
const r = t.match(
|
|
@@ -1269,24 +1307,24 @@ const Z = p.object({
|
|
|
1269
1307
|
"dateModified"
|
|
1270
1308
|
].map((t, r) => [t, r])
|
|
1271
1309
|
);
|
|
1272
|
-
function
|
|
1310
|
+
function tr(t, r) {
|
|
1273
1311
|
const s = be.get(t) ?? 1 / 0, o = be.get(r) ?? 1 / 0;
|
|
1274
1312
|
return s > o ? 1 : s < o ? -1 : 0;
|
|
1275
1313
|
}
|
|
1276
|
-
async function
|
|
1314
|
+
async function Pe(t, r, s) {
|
|
1277
1315
|
let o;
|
|
1278
1316
|
try {
|
|
1279
1317
|
o = Z.parse(t);
|
|
1280
|
-
} catch (
|
|
1318
|
+
} catch (m) {
|
|
1281
1319
|
return {
|
|
1282
|
-
error: C(
|
|
1320
|
+
error: C(m)
|
|
1283
1321
|
};
|
|
1284
1322
|
}
|
|
1285
1323
|
const {
|
|
1286
1324
|
name: e,
|
|
1287
1325
|
globs: n,
|
|
1288
|
-
matchFiles:
|
|
1289
|
-
matchDirs:
|
|
1326
|
+
matchFiles: a,
|
|
1327
|
+
matchDirs: i,
|
|
1290
1328
|
minTimeAgo: u,
|
|
1291
1329
|
maxTimeAgo: l,
|
|
1292
1330
|
minTotalSize: c,
|
|
@@ -1301,19 +1339,19 @@ async function ze(t, r, s) {
|
|
|
1301
1339
|
return {
|
|
1302
1340
|
error: `Filesystem snapshot query "${e}" already exists`
|
|
1303
1341
|
};
|
|
1304
|
-
const
|
|
1342
|
+
const h = T.resolve(r.workingDir || "", o.rootDir || "").replace(/\\/g, "/");
|
|
1305
1343
|
try {
|
|
1306
1344
|
try {
|
|
1307
|
-
await
|
|
1345
|
+
await B.promises.access(h, B.constants.F_OK);
|
|
1308
1346
|
} catch (w) {
|
|
1309
1347
|
if (w.code === "ENOENT")
|
|
1310
1348
|
return {
|
|
1311
|
-
error: `Directory does not exist: "${
|
|
1349
|
+
error: `Directory does not exist: "${h}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
|
|
1312
1350
|
};
|
|
1313
1351
|
throw w;
|
|
1314
1352
|
}
|
|
1315
|
-
const
|
|
1316
|
-
|
|
1353
|
+
const m = o.extraFields ? o.extraFields.map((w) => w === "lastModified" ? "dateModified" : w) : [];
|
|
1354
|
+
m.includes("name") || m.push("name"), m.sort(tr);
|
|
1317
1355
|
const g = n && n.length > 0 ? n.map((w) => ({
|
|
1318
1356
|
value: w,
|
|
1319
1357
|
valueType: "pattern",
|
|
@@ -1340,24 +1378,24 @@ async function ze(t, r, s) {
|
|
|
1340
1378
|
}
|
|
1341
1379
|
const S = {
|
|
1342
1380
|
name: e,
|
|
1343
|
-
rootDir:
|
|
1381
|
+
rootDir: h,
|
|
1344
1382
|
globs: y,
|
|
1345
|
-
matchFiles:
|
|
1346
|
-
matchDirs:
|
|
1383
|
+
matchFiles: a ?? null,
|
|
1384
|
+
matchDirs: i ?? null,
|
|
1347
1385
|
dateModified: x,
|
|
1348
1386
|
totalSize: I,
|
|
1349
|
-
fields:
|
|
1387
|
+
fields: m
|
|
1350
1388
|
};
|
|
1351
1389
|
return d.fsSnapshotQueries.set(e, S), {
|
|
1352
1390
|
snapshotQuery: S
|
|
1353
1391
|
};
|
|
1354
|
-
} catch (
|
|
1392
|
+
} catch (m) {
|
|
1355
1393
|
return {
|
|
1356
|
-
error:
|
|
1394
|
+
error: m instanceof Error ? m.message : "Unknown error"
|
|
1357
1395
|
};
|
|
1358
1396
|
}
|
|
1359
1397
|
}
|
|
1360
|
-
function
|
|
1398
|
+
function rr(t, r) {
|
|
1361
1399
|
t(
|
|
1362
1400
|
"fs-snapshot-query-create",
|
|
1363
1401
|
{
|
|
@@ -1366,43 +1404,43 @@ function Yt(t, r) {
|
|
|
1366
1404
|
inputSchema: Z.shape
|
|
1367
1405
|
},
|
|
1368
1406
|
async (s, o) => {
|
|
1369
|
-
const e = await
|
|
1407
|
+
const e = await Pe(s, r, o);
|
|
1370
1408
|
return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1371
1409
|
❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1372
1410
|
✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
1373
1411
|
}
|
|
1374
1412
|
);
|
|
1375
1413
|
}
|
|
1376
|
-
function
|
|
1414
|
+
function j(t) {
|
|
1377
1415
|
const { idToNode: r, idToChildIds: s } = t, o = r.get(null);
|
|
1378
1416
|
if (o == null)
|
|
1379
1417
|
throw new Error(
|
|
1380
1418
|
"Impossible behavior: root node (id: null) not found in idToNode"
|
|
1381
1419
|
);
|
|
1382
1420
|
const e = /* @__PURE__ */ new Map();
|
|
1383
|
-
return r.forEach((n,
|
|
1421
|
+
return r.forEach((n, a) => {
|
|
1384
1422
|
if (n != null) {
|
|
1385
1423
|
if (e.has(n)) {
|
|
1386
|
-
const
|
|
1424
|
+
const i = e.get(n);
|
|
1387
1425
|
throw new Error(
|
|
1388
|
-
`Impossible behavior: node appears with multiple IDs (existing: ${
|
|
1426
|
+
`Impossible behavior: node appears with multiple IDs (existing: ${i}, new: ${a})`
|
|
1389
1427
|
);
|
|
1390
1428
|
}
|
|
1391
|
-
e.set(n,
|
|
1429
|
+
e.set(n, a);
|
|
1392
1430
|
}
|
|
1393
1431
|
}), {
|
|
1394
1432
|
root: o,
|
|
1395
1433
|
getNode: (n) => r.get(n) ?? null,
|
|
1396
1434
|
getId: (n) => e.get(n) ?? null,
|
|
1397
1435
|
getChilds: (n) => {
|
|
1398
|
-
let
|
|
1399
|
-
if (
|
|
1436
|
+
let a = e.get(n);
|
|
1437
|
+
if (a == null)
|
|
1400
1438
|
if (n === r.get(null))
|
|
1401
|
-
|
|
1439
|
+
a = null;
|
|
1402
1440
|
else
|
|
1403
1441
|
throw new Error("Impossible behavior: node not found in idToNode");
|
|
1404
|
-
const
|
|
1405
|
-
return
|
|
1442
|
+
const i = s.get(a);
|
|
1443
|
+
return i == null ? null : i.map((u) => {
|
|
1406
1444
|
const l = r.get(u);
|
|
1407
1445
|
if (l == null)
|
|
1408
1446
|
throw new Error(
|
|
@@ -1413,44 +1451,44 @@ function _(t) {
|
|
|
1413
1451
|
}
|
|
1414
1452
|
};
|
|
1415
1453
|
}
|
|
1416
|
-
function
|
|
1454
|
+
function ze(t, r, s) {
|
|
1417
1455
|
let o = null;
|
|
1418
1456
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
1419
|
-
const
|
|
1457
|
+
const a = r[e], i = t(a), u = i == null ? null : ze(t, i, s), l = s(a, u);
|
|
1420
1458
|
l != null && (o == null && (o = []), o.push(l));
|
|
1421
1459
|
}
|
|
1422
1460
|
return o;
|
|
1423
1461
|
}
|
|
1424
1462
|
function Le(t) {
|
|
1425
|
-
const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(),
|
|
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(
|
|
1426
1464
|
s,
|
|
1427
1465
|
o,
|
|
1428
1466
|
(c, f) => {
|
|
1429
1467
|
const d = e(c, f);
|
|
1430
1468
|
if (c != null && d != null) {
|
|
1431
|
-
const
|
|
1432
|
-
n.set(
|
|
1469
|
+
const h = r(c);
|
|
1470
|
+
n.set(h, d), a.set(d, h);
|
|
1433
1471
|
}
|
|
1434
|
-
return d != null && f != null &&
|
|
1435
|
-
|
|
1436
|
-
f.map((
|
|
1472
|
+
return d != null && f != null && i.set(
|
|
1473
|
+
a.get(d),
|
|
1474
|
+
f.map((h) => a.get(h))
|
|
1437
1475
|
), d;
|
|
1438
1476
|
}
|
|
1439
1477
|
), l = e(null, u);
|
|
1440
1478
|
if (l == null)
|
|
1441
1479
|
throw new Error("Impossible behavior: rootNode == null");
|
|
1442
|
-
return n.set(null, l), u != null &&
|
|
1480
|
+
return n.set(null, l), u != null && i.set(
|
|
1443
1481
|
null,
|
|
1444
|
-
u.map((c) =>
|
|
1482
|
+
u.map((c) => a.get(c))
|
|
1445
1483
|
), {
|
|
1446
1484
|
idToNode: n,
|
|
1447
|
-
idToChildIds:
|
|
1485
|
+
idToChildIds: i
|
|
1448
1486
|
};
|
|
1449
1487
|
}
|
|
1450
1488
|
function W(t) {
|
|
1451
1489
|
return t = t?.replace(/\\/g, "/").replace(/\/$/, ""), !t || t === "." ? null : t;
|
|
1452
1490
|
}
|
|
1453
|
-
async function
|
|
1491
|
+
async function sr(t) {
|
|
1454
1492
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = T.resolve(t.rootDir || "."), n = {
|
|
1455
1493
|
path: ".",
|
|
1456
1494
|
name: T.basename(o),
|
|
@@ -1460,23 +1498,23 @@ async function Vt(t) {
|
|
|
1460
1498
|
size: 0
|
|
1461
1499
|
};
|
|
1462
1500
|
r.set(null, n);
|
|
1463
|
-
const
|
|
1501
|
+
const a = await Be({
|
|
1464
1502
|
rootDir: o,
|
|
1465
1503
|
globs: t.globs
|
|
1466
1504
|
});
|
|
1467
|
-
return await
|
|
1505
|
+
return await Fe({
|
|
1468
1506
|
paths: [o],
|
|
1469
1507
|
walkLinks: !0,
|
|
1470
1508
|
matchPath: Oe({
|
|
1471
|
-
globs:
|
|
1509
|
+
globs: a,
|
|
1472
1510
|
rootDir: o,
|
|
1473
1511
|
noCase: !0
|
|
1474
1512
|
}),
|
|
1475
|
-
handlePath: async ({ path:
|
|
1476
|
-
const c = T.relative(o,
|
|
1513
|
+
handlePath: async ({ path: i, stat: u, itemStat: l }) => {
|
|
1514
|
+
const c = T.relative(o, i), f = u.isDirectory(), d = u.isFile();
|
|
1477
1515
|
if (!f && !d)
|
|
1478
1516
|
return !0;
|
|
1479
|
-
const
|
|
1517
|
+
const h = W(c || "."), m = f ? "dir" : "file", g = f ? null : u.mtimeMs, b = u.size;
|
|
1480
1518
|
let y = !0;
|
|
1481
1519
|
if (d && !t.matchFiles && (y = !1), f && !t.matchDirs && (y = !1), y && d && t.dateModified && g != null) {
|
|
1482
1520
|
const [w, M] = t.dateModified;
|
|
@@ -1491,26 +1529,26 @@ async function Vt(t) {
|
|
|
1491
1529
|
} else if (!y)
|
|
1492
1530
|
return !1;
|
|
1493
1531
|
const x = {
|
|
1494
|
-
path:
|
|
1495
|
-
name: T.basename(
|
|
1496
|
-
type:
|
|
1532
|
+
path: h ?? ".",
|
|
1533
|
+
name: T.basename(i),
|
|
1534
|
+
type: m,
|
|
1497
1535
|
dateModified: g,
|
|
1498
1536
|
size: b,
|
|
1499
1537
|
isMatched: y
|
|
1500
1538
|
};
|
|
1501
|
-
if (
|
|
1539
|
+
if (h == null)
|
|
1502
1540
|
return n.dateModified = g, n.size = b, n.isMatched = y, !0;
|
|
1503
|
-
r.set(
|
|
1504
|
-
const I = W(T.dirname(
|
|
1541
|
+
r.set(h, x);
|
|
1542
|
+
const I = W(T.dirname(h).replace(/\\/g, "/"));
|
|
1505
1543
|
let S = s.get(I);
|
|
1506
|
-
return S || (S = [], s.set(I, S)), S.push(
|
|
1544
|
+
return S || (S = [], s.set(I, S)), S.push(h), !0;
|
|
1507
1545
|
}
|
|
1508
1546
|
}), {
|
|
1509
1547
|
idToNode: r,
|
|
1510
1548
|
idToChildIds: s
|
|
1511
1549
|
};
|
|
1512
1550
|
}
|
|
1513
|
-
const
|
|
1551
|
+
const or = [
|
|
1514
1552
|
{ name: "[ ]", match: (t) => t === 32, min: 2, max: 81 },
|
|
1515
1553
|
{ name: "[\\t]", match: (t) => t === 9, min: 2, max: 20 },
|
|
1516
1554
|
{ name: "[\\n]", match: (t) => t === 10, min: 2, max: 14 },
|
|
@@ -1533,7 +1571,7 @@ const Zt = [
|
|
|
1533
1571
|
// max: 2,
|
|
1534
1572
|
// },
|
|
1535
1573
|
];
|
|
1536
|
-
function xe(t, r =
|
|
1574
|
+
function xe(t, r = or) {
|
|
1537
1575
|
const s = t.length;
|
|
1538
1576
|
if (s === 0) return 0;
|
|
1539
1577
|
const o = r.length;
|
|
@@ -1541,21 +1579,21 @@ function xe(t, r = Zt) {
|
|
|
1541
1579
|
return s;
|
|
1542
1580
|
let e = 0, n = 0;
|
|
1543
1581
|
for (; n < s; ) {
|
|
1544
|
-
const
|
|
1545
|
-
let
|
|
1582
|
+
const a = t.charCodeAt(n);
|
|
1583
|
+
let i = !1;
|
|
1546
1584
|
for (let u = 0; u < o; u++) {
|
|
1547
1585
|
const l = r[u];
|
|
1548
|
-
if (l.match(
|
|
1586
|
+
if (l.match(a)) {
|
|
1549
1587
|
let c = 1;
|
|
1550
1588
|
for (; ++n < s && l.match(t.charCodeAt(n)) && c < l.max; )
|
|
1551
1589
|
c++;
|
|
1552
1590
|
if (c >= l.min) {
|
|
1553
|
-
e++,
|
|
1591
|
+
e++, i = !0;
|
|
1554
1592
|
break;
|
|
1555
1593
|
}
|
|
1556
1594
|
}
|
|
1557
1595
|
}
|
|
1558
|
-
|
|
1596
|
+
i || (n++, e++);
|
|
1559
1597
|
}
|
|
1560
1598
|
return e;
|
|
1561
1599
|
}
|
|
@@ -1564,20 +1602,20 @@ function Ue(t) {
|
|
|
1564
1602
|
return r += xe(t.textOpen) + 1, t.textClose != null && (r += xe(t.textClose) + 1), t.indent && (r += 1), r;
|
|
1565
1603
|
}
|
|
1566
1604
|
const Se = ["B", "KB", "MB", "GB", "TB"], $e = 1024;
|
|
1567
|
-
function
|
|
1605
|
+
function nr(t) {
|
|
1568
1606
|
if (t == null) return "-";
|
|
1569
1607
|
let r = t ?? 0, s = 0;
|
|
1570
1608
|
for (; r >= $e && s < Se.length - 1; )
|
|
1571
1609
|
r /= $e, s++;
|
|
1572
1610
|
return `${s === 0 ? r.toString() : r.toFixed(2)}${Se[s]}`;
|
|
1573
1611
|
}
|
|
1574
|
-
function
|
|
1612
|
+
function ir(t) {
|
|
1575
1613
|
const s = Date.now() - t;
|
|
1576
1614
|
if (s < 0) return "0s";
|
|
1577
|
-
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60),
|
|
1578
|
-
return l > 0 ? `${l}Y` : u > 0 ? `${u}M` :
|
|
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);
|
|
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`;
|
|
1579
1617
|
}
|
|
1580
|
-
function
|
|
1618
|
+
function ar(t) {
|
|
1581
1619
|
return function(s, o) {
|
|
1582
1620
|
const e = t.get(s), n = t.get(o);
|
|
1583
1621
|
if (e.type !== n.type)
|
|
@@ -1585,31 +1623,31 @@ function tr(t) {
|
|
|
1585
1623
|
if (e.type === "file")
|
|
1586
1624
|
return e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
|
|
1587
1625
|
{
|
|
1588
|
-
const
|
|
1589
|
-
return
|
|
1626
|
+
const a = e.countFiles || 0, i = n.countFiles || 0;
|
|
1627
|
+
return a < i ? -1 : a > i ? 1 : e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
|
|
1590
1628
|
}
|
|
1591
1629
|
};
|
|
1592
1630
|
}
|
|
1593
|
-
function
|
|
1631
|
+
function lr(t) {
|
|
1594
1632
|
const r = t.fields ?? [];
|
|
1595
1633
|
return function(o, e) {
|
|
1596
|
-
let n = "",
|
|
1634
|
+
let n = "", a, i = 0;
|
|
1597
1635
|
const u = e ? e.length : 0;
|
|
1598
|
-
let l = 1, c, f = 0, d = 0,
|
|
1636
|
+
let l = 1, c, f = 0, d = 0, h = 0, m = 0, g = null, b, y, x;
|
|
1599
1637
|
if (e)
|
|
1600
1638
|
for (let S = 0; S < e.length; S++) {
|
|
1601
1639
|
const w = e[S];
|
|
1602
|
-
|
|
1640
|
+
i += w.countMatched, l += w.countTotal, f += w.tokens, d += w.tokensTotal, h += w.size, m += w.countFiles, w.dateModified != null && (g == null || w.dateModified > g) && (g = w.dateModified);
|
|
1603
1641
|
}
|
|
1604
|
-
o ? (b = o.type, y = o.name, x = o.path,
|
|
1642
|
+
o ? (b = o.type, y = o.name, x = o.path, a = o.isMatched, a && (i += 1), o.type === "file" ? (h = o.size || 0, m = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (b = "dir", y = "<root>", x = ".", a = !0);
|
|
1605
1643
|
for (let S = 0, w = r.length; S < w; S++) {
|
|
1606
1644
|
const M = r[S];
|
|
1607
1645
|
switch (S > 0 && (n += " "), M) {
|
|
1608
1646
|
case "dateModified":
|
|
1609
|
-
n += g ?
|
|
1647
|
+
n += g ? ir(g) : "-";
|
|
1610
1648
|
break;
|
|
1611
1649
|
case "size":
|
|
1612
|
-
n +=
|
|
1650
|
+
n += nr(h);
|
|
1613
1651
|
break;
|
|
1614
1652
|
case "type":
|
|
1615
1653
|
n += b;
|
|
@@ -1618,7 +1656,7 @@ function rr(t) {
|
|
|
1618
1656
|
n += b === "dir" ? `${y}/` : y;
|
|
1619
1657
|
break;
|
|
1620
1658
|
case "countMatched":
|
|
1621
|
-
n +=
|
|
1659
|
+
n += i.toString();
|
|
1622
1660
|
break;
|
|
1623
1661
|
}
|
|
1624
1662
|
}
|
|
@@ -1631,37 +1669,37 @@ function rr(t) {
|
|
|
1631
1669
|
type: b,
|
|
1632
1670
|
name: y,
|
|
1633
1671
|
path: x,
|
|
1634
|
-
isMatched:
|
|
1635
|
-
countMatched:
|
|
1672
|
+
isMatched: a,
|
|
1673
|
+
countMatched: i,
|
|
1636
1674
|
countChilds: u,
|
|
1637
1675
|
countTotal: l,
|
|
1638
1676
|
tokens: c,
|
|
1639
1677
|
tokensChilds: f,
|
|
1640
1678
|
tokensTotal: d,
|
|
1641
1679
|
text: I,
|
|
1642
|
-
size:
|
|
1643
|
-
countFiles:
|
|
1680
|
+
size: h,
|
|
1681
|
+
countFiles: m,
|
|
1644
1682
|
dateModified: g
|
|
1645
1683
|
};
|
|
1646
1684
|
};
|
|
1647
1685
|
}
|
|
1648
|
-
async function
|
|
1649
|
-
const r = await
|
|
1650
|
-
getId: (
|
|
1651
|
-
const
|
|
1652
|
-
if (
|
|
1686
|
+
async function cr(t) {
|
|
1687
|
+
const r = await sr(t), s = j(r), o = s.getChilds(s.root), e = Le({
|
|
1688
|
+
getId: (a) => {
|
|
1689
|
+
const i = s.getId(a);
|
|
1690
|
+
if (i == null)
|
|
1653
1691
|
throw new Error(
|
|
1654
|
-
`Invalid tree structure: node ID is null for node ${JSON.stringify(
|
|
1692
|
+
`Invalid tree structure: node ID is null for node ${JSON.stringify(a)}`
|
|
1655
1693
|
);
|
|
1656
|
-
return
|
|
1694
|
+
return i;
|
|
1657
1695
|
},
|
|
1658
|
-
getChilds: (
|
|
1659
|
-
createSnapshotNode:
|
|
1696
|
+
getChilds: (a) => s.getChilds(a),
|
|
1697
|
+
createSnapshotNode: lr(t),
|
|
1660
1698
|
rootNodes: o ?? []
|
|
1661
|
-
}), n =
|
|
1662
|
-
return e.idToChildIds.forEach((
|
|
1663
|
-
|
|
1664
|
-
}),
|
|
1699
|
+
}), n = ar(e.idToNode);
|
|
1700
|
+
return e.idToChildIds.forEach((a) => {
|
|
1701
|
+
a.sort(n);
|
|
1702
|
+
}), j(e);
|
|
1665
1703
|
}
|
|
1666
1704
|
const X = p.object({
|
|
1667
1705
|
queryName: p.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
|
|
@@ -1681,31 +1719,31 @@ async function Ae(t, r, s) {
|
|
|
1681
1719
|
error: C(c)
|
|
1682
1720
|
};
|
|
1683
1721
|
}
|
|
1684
|
-
const { name: e, queryName: n, query:
|
|
1722
|
+
const { name: e, queryName: n, query: a } = o;
|
|
1685
1723
|
if (!s.sessionId)
|
|
1686
1724
|
return {
|
|
1687
1725
|
error: "Session ID is required"
|
|
1688
1726
|
};
|
|
1689
|
-
const
|
|
1690
|
-
if (
|
|
1727
|
+
const i = V(s.sessionId);
|
|
1728
|
+
if (i.fsSnapshots.has(e))
|
|
1691
1729
|
return {
|
|
1692
1730
|
error: `Filesystem snapshot "${e}" already exists`
|
|
1693
1731
|
};
|
|
1694
|
-
if (n &&
|
|
1732
|
+
if (n && a)
|
|
1695
1733
|
return {
|
|
1696
1734
|
error: "Either queryName or query must be provided, not both"
|
|
1697
1735
|
};
|
|
1698
1736
|
let u, l = !1;
|
|
1699
1737
|
if (n) {
|
|
1700
|
-
const c =
|
|
1738
|
+
const c = i.fsSnapshotQueries.get(n);
|
|
1701
1739
|
if (!c)
|
|
1702
1740
|
return {
|
|
1703
1741
|
error: `Filesystem snapshot query "${n}" not found`
|
|
1704
1742
|
};
|
|
1705
1743
|
u = c;
|
|
1706
|
-
} else if (
|
|
1707
|
-
const c = await
|
|
1708
|
-
|
|
1744
|
+
} else if (a) {
|
|
1745
|
+
const c = await Pe(
|
|
1746
|
+
a,
|
|
1709
1747
|
r,
|
|
1710
1748
|
s
|
|
1711
1749
|
);
|
|
@@ -1719,12 +1757,12 @@ async function Ae(t, r, s) {
|
|
|
1719
1757
|
error: "Either queryName or query must be provided"
|
|
1720
1758
|
};
|
|
1721
1759
|
try {
|
|
1722
|
-
const c = await
|
|
1760
|
+
const c = await cr(u), f = {
|
|
1723
1761
|
name: e,
|
|
1724
1762
|
query: u,
|
|
1725
1763
|
tree: c
|
|
1726
1764
|
};
|
|
1727
|
-
return
|
|
1765
|
+
return i.fsSnapshots.set(e, f), {
|
|
1728
1766
|
fsSnapshot: f,
|
|
1729
1767
|
queryCreated: l
|
|
1730
1768
|
};
|
|
@@ -1734,7 +1772,7 @@ async function Ae(t, r, s) {
|
|
|
1734
1772
|
};
|
|
1735
1773
|
}
|
|
1736
1774
|
}
|
|
1737
|
-
function
|
|
1775
|
+
function ur(t, r) {
|
|
1738
1776
|
t(
|
|
1739
1777
|
"fs-snapshot-create",
|
|
1740
1778
|
{
|
|
@@ -1754,7 +1792,7 @@ function or(t, r) {
|
|
|
1754
1792
|
}
|
|
1755
1793
|
);
|
|
1756
1794
|
}
|
|
1757
|
-
class
|
|
1795
|
+
class dr {
|
|
1758
1796
|
_first = null;
|
|
1759
1797
|
_last = null;
|
|
1760
1798
|
_size = 0;
|
|
@@ -1777,11 +1815,11 @@ class nr {
|
|
|
1777
1815
|
return this._size;
|
|
1778
1816
|
}
|
|
1779
1817
|
}
|
|
1780
|
-
function
|
|
1781
|
-
const r = new
|
|
1818
|
+
function fr(t) {
|
|
1819
|
+
const r = new dr(), {
|
|
1782
1820
|
tree: s,
|
|
1783
|
-
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup:
|
|
1784
|
-
indexRangeGroupStrategy:
|
|
1821
|
+
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: a },
|
|
1822
|
+
indexRangeGroupStrategy: i
|
|
1785
1823
|
} = t, u = s.getChilds(s.root);
|
|
1786
1824
|
u != null && u.length > 0 && r.enqueue({
|
|
1787
1825
|
reportNode: null,
|
|
@@ -1789,26 +1827,26 @@ function ir(t) {
|
|
|
1789
1827
|
});
|
|
1790
1828
|
let l = null, c = 0, f = 0;
|
|
1791
1829
|
for (; !r.isEmpty(); ) {
|
|
1792
|
-
const { reportNode: d, node:
|
|
1793
|
-
if (
|
|
1830
|
+
const { reportNode: d, node: h } = r.dequeue(), m = s.getChilds(h);
|
|
1831
|
+
if (m == null || h.countChilds === 0 || m.length !== h.countChilds)
|
|
1794
1832
|
throw new Error(
|
|
1795
1833
|
"Impossible behavior: nodeChilds is null or length mismatch"
|
|
1796
1834
|
);
|
|
1797
1835
|
let g = r.size();
|
|
1798
|
-
for (let y = 0; y <
|
|
1799
|
-
|
|
1800
|
-
const b = g *
|
|
1801
|
-
if (o != null && c +
|
|
1836
|
+
for (let y = 0; y < m.length; y++)
|
|
1837
|
+
m[y].countChilds > 0 && (g += 1);
|
|
1838
|
+
const b = g * i.tokens;
|
|
1839
|
+
if (o != null && c + h.countChilds + g > o || e != null && f + h.tokensChilds + b > e) {
|
|
1802
1840
|
const y = [];
|
|
1803
1841
|
let x = null, I = 0;
|
|
1804
|
-
for (let w = 0, M =
|
|
1805
|
-
const $ =
|
|
1842
|
+
for (let w = 0, M = m.length; w < M; w++) {
|
|
1843
|
+
const $ = m[w], v = I * i.tokens;
|
|
1806
1844
|
x != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
|
|
1807
|
-
!(o != null && c + 1 > o || e != null && f +
|
|
1845
|
+
!(o != null && c + 1 > o || e != null && f + i.tokens > e) && (n != null && x.countGrouped + 1 + I > n || a != null && x.tokensGrouped + $.tokens + v > a) && (y.push(x), c += 1, f += i.tokens, x = null, I = 0), x = i.add(x, $, w), $.countChilds > 0 && (I += 1);
|
|
1808
1846
|
}
|
|
1809
|
-
x != null && (y.push(x), c += 1, f +=
|
|
1847
|
+
x != null && (y.push(x), c += 1, f += i.tokens);
|
|
1810
1848
|
const S = y.map((w) => ({
|
|
1811
|
-
text:
|
|
1849
|
+
text: i.getReportText(w)
|
|
1812
1850
|
}));
|
|
1813
1851
|
if (d != null) {
|
|
1814
1852
|
if (d.childs != null)
|
|
@@ -1820,10 +1858,10 @@ function ir(t) {
|
|
|
1820
1858
|
l = S;
|
|
1821
1859
|
}
|
|
1822
1860
|
} else {
|
|
1823
|
-
c +=
|
|
1861
|
+
c += h.countChilds, f += h.tokensChilds;
|
|
1824
1862
|
const y = [];
|
|
1825
|
-
for (let x = 0; x <
|
|
1826
|
-
const I =
|
|
1863
|
+
for (let x = 0; x < m.length; x++) {
|
|
1864
|
+
const I = m[x], S = {
|
|
1827
1865
|
text: I.text
|
|
1828
1866
|
};
|
|
1829
1867
|
y.push(S);
|
|
@@ -1846,42 +1884,42 @@ function ir(t) {
|
|
|
1846
1884
|
}
|
|
1847
1885
|
return l ?? [];
|
|
1848
1886
|
}
|
|
1849
|
-
function
|
|
1887
|
+
function qe(t) {
|
|
1850
1888
|
const {
|
|
1851
1889
|
tree: r,
|
|
1852
1890
|
request: { parentNodeId: s, childsIndexRange: o, limits: e },
|
|
1853
1891
|
indexRangeGroupStrategy: n,
|
|
1854
|
-
...
|
|
1892
|
+
...a
|
|
1855
1893
|
} = t;
|
|
1856
|
-
let
|
|
1894
|
+
let i;
|
|
1857
1895
|
if (s != null) {
|
|
1858
1896
|
const d = r.getNode(s);
|
|
1859
1897
|
if (d == null)
|
|
1860
1898
|
throw new Error(`Parent node "${s}" not found`);
|
|
1861
|
-
|
|
1899
|
+
i = d;
|
|
1862
1900
|
} else
|
|
1863
|
-
|
|
1864
|
-
let u, l = r.getChilds(
|
|
1901
|
+
i = r.root;
|
|
1902
|
+
let u, l = r.getChilds(i) ?? [];
|
|
1865
1903
|
if (o != null) {
|
|
1866
|
-
const [d,
|
|
1867
|
-
if (d < 0 ||
|
|
1904
|
+
const [d, h] = o;
|
|
1905
|
+
if (d < 0 || h <= d || h >= l.length)
|
|
1868
1906
|
throw new Error(
|
|
1869
|
-
`Invalid index range: ${d}-${
|
|
1907
|
+
`Invalid index range: ${d}-${h} for root nodes length ${l.length}`
|
|
1870
1908
|
);
|
|
1871
|
-
const
|
|
1909
|
+
const m = [];
|
|
1872
1910
|
let g = null;
|
|
1873
|
-
for (let b = d; b <=
|
|
1911
|
+
for (let b = d; b <= h; b++) {
|
|
1874
1912
|
const y = l[b];
|
|
1875
|
-
|
|
1913
|
+
m.push(y), g = n.add(g, y, b);
|
|
1876
1914
|
}
|
|
1877
|
-
l =
|
|
1878
|
-
...
|
|
1915
|
+
l = m, u = {
|
|
1916
|
+
...i,
|
|
1879
1917
|
text: n.getReportText(g),
|
|
1880
1918
|
countChilds: g.countGrouped,
|
|
1881
1919
|
tokensChilds: g.tokensGrouped
|
|
1882
1920
|
};
|
|
1883
1921
|
} else
|
|
1884
|
-
u =
|
|
1922
|
+
u = i;
|
|
1885
1923
|
const c = {
|
|
1886
1924
|
countChilds: 1,
|
|
1887
1925
|
tokensChilds: u.tokens
|
|
@@ -1890,20 +1928,20 @@ function Ge(t) {
|
|
|
1890
1928
|
root: c,
|
|
1891
1929
|
getChilds: (d) => d === c ? [u] : d === u ? l : r.getChilds(d)
|
|
1892
1930
|
};
|
|
1893
|
-
return
|
|
1931
|
+
return fr({
|
|
1894
1932
|
tree: f,
|
|
1895
1933
|
limits: e,
|
|
1896
1934
|
indexRangeGroupStrategy: n,
|
|
1897
|
-
...
|
|
1935
|
+
...a
|
|
1898
1936
|
});
|
|
1899
1937
|
}
|
|
1900
|
-
function
|
|
1938
|
+
function Ge(t, r) {
|
|
1901
1939
|
if (t == null || t.length === 0)
|
|
1902
1940
|
return "No results found";
|
|
1903
1941
|
let s = "";
|
|
1904
1942
|
function o(e, n) {
|
|
1905
|
-
for (let
|
|
1906
|
-
const u = e[
|
|
1943
|
+
for (let a = 0, i = e.length; a < i; a++) {
|
|
1944
|
+
const u = e[a];
|
|
1907
1945
|
s += n, s += u.text.textOpen + `
|
|
1908
1946
|
`, u.childs != null && u.childs.length > 0 && o(
|
|
1909
1947
|
u.childs,
|
|
@@ -1914,7 +1952,7 @@ function qe(t, r) {
|
|
|
1914
1952
|
}
|
|
1915
1953
|
return o(t, ""), s;
|
|
1916
1954
|
}
|
|
1917
|
-
class
|
|
1955
|
+
class hr {
|
|
1918
1956
|
tokens = 16;
|
|
1919
1957
|
// +1 indent, +1 for line break
|
|
1920
1958
|
getReportText = (r) => ({
|
|
@@ -1929,7 +1967,7 @@ class ar {
|
|
|
1929
1967
|
tokensGrouped: s.tokens
|
|
1930
1968
|
} : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
|
|
1931
1969
|
}
|
|
1932
|
-
const
|
|
1970
|
+
const je = p.object({
|
|
1933
1971
|
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
1934
1972
|
snapshot: X.optional().describe(
|
|
1935
1973
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
@@ -1951,10 +1989,10 @@ const _e = p.object({
|
|
|
1951
1989
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
1952
1990
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
1953
1991
|
});
|
|
1954
|
-
async function
|
|
1992
|
+
async function mr(t, r, s) {
|
|
1955
1993
|
let o;
|
|
1956
1994
|
try {
|
|
1957
|
-
o =
|
|
1995
|
+
o = je.parse(t);
|
|
1958
1996
|
} catch (g) {
|
|
1959
1997
|
return {
|
|
1960
1998
|
error: C(g)
|
|
@@ -1963,18 +2001,18 @@ async function lr(t, r, s) {
|
|
|
1963
2001
|
const {
|
|
1964
2002
|
snapshotName: e,
|
|
1965
2003
|
snapshot: n,
|
|
1966
|
-
childsIndexRange:
|
|
2004
|
+
childsIndexRange: a
|
|
1967
2005
|
// maxCountTotal,
|
|
1968
2006
|
// maxTokensTotal,
|
|
1969
2007
|
// maxCountGroup,
|
|
1970
2008
|
// maxTokensGroup,
|
|
1971
|
-
} = o,
|
|
2009
|
+
} = o, i = 60, u = 1e3, l = 25, c = 900;
|
|
1972
2010
|
if (!s.sessionId)
|
|
1973
2011
|
return {
|
|
1974
2012
|
error: "Session ID is required"
|
|
1975
2013
|
};
|
|
1976
2014
|
const f = V(s.sessionId);
|
|
1977
|
-
let d,
|
|
2015
|
+
let d, h = !1, m = !1;
|
|
1978
2016
|
if (e && n)
|
|
1979
2017
|
return {
|
|
1980
2018
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
@@ -1994,32 +2032,32 @@ async function lr(t, r, s) {
|
|
|
1994
2032
|
return {
|
|
1995
2033
|
error: g.error
|
|
1996
2034
|
};
|
|
1997
|
-
d = g.fsSnapshot,
|
|
2035
|
+
d = g.fsSnapshot, h = g.queryCreated, m = !0;
|
|
1998
2036
|
} else
|
|
1999
2037
|
return {
|
|
2000
2038
|
error: "Either snapshotName or snapshot must be provided"
|
|
2001
2039
|
};
|
|
2002
2040
|
try {
|
|
2003
|
-
const g = W(o.parentPath), b =
|
|
2041
|
+
const g = W(o.parentPath), b = qe({
|
|
2004
2042
|
tree: d.tree,
|
|
2005
2043
|
request: {
|
|
2006
2044
|
parentNodeId: g,
|
|
2007
|
-
childsIndexRange:
|
|
2045
|
+
childsIndexRange: a,
|
|
2008
2046
|
limits: {
|
|
2009
|
-
maxCountTotal:
|
|
2047
|
+
maxCountTotal: i,
|
|
2010
2048
|
maxTokensTotal: u,
|
|
2011
2049
|
maxCountGroup: l,
|
|
2012
2050
|
maxTokensGroup: c
|
|
2013
2051
|
}
|
|
2014
2052
|
},
|
|
2015
|
-
indexRangeGroupStrategy: new
|
|
2016
|
-
}), y =
|
|
2053
|
+
indexRangeGroupStrategy: new hr()
|
|
2054
|
+
}), y = Ge(b);
|
|
2017
2055
|
return {
|
|
2018
2056
|
fsSnapshot: d,
|
|
2019
|
-
queryCreated:
|
|
2020
|
-
snapshotCreated:
|
|
2057
|
+
queryCreated: h,
|
|
2058
|
+
snapshotCreated: m,
|
|
2021
2059
|
parentPath: g,
|
|
2022
|
-
childsIndexRange:
|
|
2060
|
+
childsIndexRange: a,
|
|
2023
2061
|
report: y
|
|
2024
2062
|
};
|
|
2025
2063
|
} catch (g) {
|
|
@@ -2028,16 +2066,16 @@ async function lr(t, r, s) {
|
|
|
2028
2066
|
};
|
|
2029
2067
|
}
|
|
2030
2068
|
}
|
|
2031
|
-
function
|
|
2069
|
+
function pr(t, r) {
|
|
2032
2070
|
t(
|
|
2033
2071
|
"fs-snapshot-browse",
|
|
2034
2072
|
{
|
|
2035
2073
|
title: "Browse Filesystem Snapshot",
|
|
2036
2074
|
description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
|
|
2037
|
-
inputSchema:
|
|
2075
|
+
inputSchema: je.shape
|
|
2038
2076
|
},
|
|
2039
2077
|
async (s, o) => {
|
|
2040
|
-
const e = await
|
|
2078
|
+
const e = await mr(s, r, o);
|
|
2041
2079
|
if (e.error != null)
|
|
2042
2080
|
return `Method: fs-snapshot-browse(${JSON.stringify(s)})
|
|
2043
2081
|
❌ Error: ${e.error}`;
|
|
@@ -2048,10 +2086,10 @@ function cr(t, r) {
|
|
|
2048
2086
|
`), n += `✅ Browsing filesystem snapshot "${e.fsSnapshot.name}":
|
|
2049
2087
|
`, n += `Root directory: ${e.fsSnapshot.query.rootDir || "./"}
|
|
2050
2088
|
`, n += `Parent path: ${"./" + (e.parentPath ?? "")}
|
|
2051
|
-
`, n += `Fields: ${e.fsSnapshot.query.fields.map((
|
|
2089
|
+
`, n += `Fields: ${e.fsSnapshot.query.fields.map((a) => a === "dateModified" ? "lastModified" : a).join(" ")}
|
|
2052
2090
|
`, e.childsIndexRange) {
|
|
2053
|
-
const [
|
|
2054
|
-
n += ` Showing indexes: ${
|
|
2091
|
+
const [a, i] = e.childsIndexRange, l = (e.parentPath ? e.fsSnapshot.tree.getNode(e.parentPath) : e.fsSnapshot.tree.root).countChilds;
|
|
2092
|
+
n += ` Showing indexes: ${a}-${i} of ${l}
|
|
2055
2093
|
`;
|
|
2056
2094
|
}
|
|
2057
2095
|
return n += `
|
|
@@ -2059,8 +2097,8 @@ ${e.report}`, n;
|
|
|
2059
2097
|
}
|
|
2060
2098
|
);
|
|
2061
2099
|
}
|
|
2062
|
-
function
|
|
2063
|
-
r.list &&
|
|
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(
|
|
2064
2102
|
`File manager:
|
|
2065
2103
|
- Working directory: ${T.resolve(r.workingDir || "")}
|
|
2066
2104
|
`
|
|
@@ -2081,7 +2119,7 @@ const ee = p.object({
|
|
|
2081
2119
|
muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
|
|
2082
2120
|
devTools: p.boolean().optional().describe("Open browser with dev tools")
|
|
2083
2121
|
});
|
|
2084
|
-
async function
|
|
2122
|
+
async function _e(t, r, s) {
|
|
2085
2123
|
let o;
|
|
2086
2124
|
try {
|
|
2087
2125
|
o = ee.parse(t);
|
|
@@ -2090,7 +2128,7 @@ async function je(t, r, s) {
|
|
|
2090
2128
|
error: C(c)
|
|
2091
2129
|
};
|
|
2092
2130
|
}
|
|
2093
|
-
const { name: e, browserType: n, muteAudio:
|
|
2131
|
+
const { name: e, browserType: n, muteAudio: a, devTools: i } = o;
|
|
2094
2132
|
if (!s.sessionId)
|
|
2095
2133
|
return {
|
|
2096
2134
|
error: "Session ID is required"
|
|
@@ -2104,11 +2142,11 @@ async function je(t, r, s) {
|
|
|
2104
2142
|
const f = await {
|
|
2105
2143
|
chromium: gt,
|
|
2106
2144
|
firefox: pt,
|
|
2107
|
-
webkit:
|
|
2145
|
+
webkit: mt
|
|
2108
2146
|
}[n].launch({
|
|
2109
2147
|
headless: !1,
|
|
2110
|
-
devtools:
|
|
2111
|
-
args:
|
|
2148
|
+
devtools: i,
|
|
2149
|
+
args: a ? ["--mute-audio"] : void 0
|
|
2112
2150
|
}), d = {
|
|
2113
2151
|
name: e,
|
|
2114
2152
|
browserType: n,
|
|
@@ -2122,7 +2160,7 @@ async function je(t, r, s) {
|
|
|
2122
2160
|
};
|
|
2123
2161
|
}
|
|
2124
2162
|
}
|
|
2125
|
-
function
|
|
2163
|
+
function wr(t, r) {
|
|
2126
2164
|
t(
|
|
2127
2165
|
"playwright-browser-create",
|
|
2128
2166
|
{
|
|
@@ -2131,20 +2169,20 @@ function dr(t, r) {
|
|
|
2131
2169
|
inputSchema: ee.shape
|
|
2132
2170
|
},
|
|
2133
2171
|
async (s, o) => {
|
|
2134
|
-
const e = await
|
|
2172
|
+
const e = await _e(s, r, o);
|
|
2135
2173
|
return `Method: playwright-browser-create(${JSON.stringify(s)})
|
|
2136
2174
|
${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
|
|
2137
2175
|
}
|
|
2138
2176
|
);
|
|
2139
2177
|
}
|
|
2140
2178
|
const Je = p.object({});
|
|
2141
|
-
async function
|
|
2179
|
+
async function yr(t, r, s) {
|
|
2142
2180
|
let o;
|
|
2143
2181
|
try {
|
|
2144
2182
|
o = Je.parse(t);
|
|
2145
|
-
} catch (
|
|
2183
|
+
} catch (a) {
|
|
2146
2184
|
return {
|
|
2147
|
-
error: C(
|
|
2185
|
+
error: C(a)
|
|
2148
2186
|
};
|
|
2149
2187
|
}
|
|
2150
2188
|
if (!s.sessionId)
|
|
@@ -2156,7 +2194,7 @@ async function fr(t, r, s) {
|
|
|
2156
2194
|
browserInfos: Array.from(e.browsers.values())
|
|
2157
2195
|
};
|
|
2158
2196
|
}
|
|
2159
|
-
function
|
|
2197
|
+
function br(t, r) {
|
|
2160
2198
|
t(
|
|
2161
2199
|
"playwright-browser-list",
|
|
2162
2200
|
{
|
|
@@ -2165,12 +2203,12 @@ function mr(t, r) {
|
|
|
2165
2203
|
inputSchema: Je.shape
|
|
2166
2204
|
},
|
|
2167
2205
|
async (s, o) => {
|
|
2168
|
-
const e = await
|
|
2206
|
+
const e = await yr(s, r, o);
|
|
2169
2207
|
if (e.error != null)
|
|
2170
2208
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
2171
2209
|
❌ Error: ${e.error}`;
|
|
2172
2210
|
const n = e.browserInfos.map(
|
|
2173
|
-
(
|
|
2211
|
+
(a) => `${a.name} (${a.browserType})`
|
|
2174
2212
|
);
|
|
2175
2213
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
2176
2214
|
${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
|
|
@@ -2182,7 +2220,7 @@ const Ke = p.object({
|
|
|
2182
2220
|
"Names of browsers to close. If not specified, closes all browsers"
|
|
2183
2221
|
)
|
|
2184
2222
|
});
|
|
2185
|
-
async function
|
|
2223
|
+
async function xr(t, r, s) {
|
|
2186
2224
|
let o;
|
|
2187
2225
|
try {
|
|
2188
2226
|
o = Ke.parse(t);
|
|
@@ -2196,27 +2234,27 @@ async function hr(t, r, s) {
|
|
|
2196
2234
|
return {
|
|
2197
2235
|
error: "Session ID is required"
|
|
2198
2236
|
};
|
|
2199
|
-
const n = E(s.sessionId),
|
|
2237
|
+
const n = E(s.sessionId), a = [], i = [];
|
|
2200
2238
|
let u = [];
|
|
2201
2239
|
return e ? e.forEach((l) => {
|
|
2202
2240
|
const c = n.browsers.get(l);
|
|
2203
|
-
c ? u.push(c) :
|
|
2241
|
+
c ? u.push(c) : i.push(`Browser "${l}" not found`);
|
|
2204
2242
|
}) : u = Array.from(n.browsers.values()), await Promise.all(
|
|
2205
2243
|
u.map(async (l) => {
|
|
2206
2244
|
try {
|
|
2207
|
-
await l.browser.close(), n.browsers.delete(l.name),
|
|
2245
|
+
await l.browser.close(), n.browsers.delete(l.name), a.push(l);
|
|
2208
2246
|
} catch (c) {
|
|
2209
|
-
|
|
2247
|
+
i.push(
|
|
2210
2248
|
`Failed to close browser "${l.name}" (${l.browserType}): ${c instanceof Error ? c.message : "Unknown error"}`
|
|
2211
2249
|
);
|
|
2212
2250
|
}
|
|
2213
2251
|
})
|
|
2214
2252
|
), {
|
|
2215
|
-
closedBrowserInfos:
|
|
2216
|
-
...
|
|
2253
|
+
closedBrowserInfos: a,
|
|
2254
|
+
...i.length > 0 && { errors: i }
|
|
2217
2255
|
};
|
|
2218
2256
|
}
|
|
2219
|
-
function
|
|
2257
|
+
function Sr(t, r) {
|
|
2220
2258
|
t(
|
|
2221
2259
|
"playwright-browser-close",
|
|
2222
2260
|
{
|
|
@@ -2225,18 +2263,18 @@ function pr(t, r) {
|
|
|
2225
2263
|
inputSchema: Ke.shape
|
|
2226
2264
|
},
|
|
2227
2265
|
async (s, o) => {
|
|
2228
|
-
const e = await
|
|
2266
|
+
const e = await xr(s, r, o);
|
|
2229
2267
|
if (e.error != null)
|
|
2230
2268
|
return `Method: playwright-browser-close(${JSON.stringify(s)})
|
|
2231
2269
|
❌ Error: ${e.error}`;
|
|
2232
2270
|
const n = [];
|
|
2233
2271
|
if (e.closedBrowserInfos.length > 0) {
|
|
2234
|
-
const
|
|
2235
|
-
(
|
|
2272
|
+
const a = e.closedBrowserInfos.map(
|
|
2273
|
+
(i) => `${i.name} (${i.browserType})`
|
|
2236
2274
|
);
|
|
2237
|
-
n.push(`✅ Closed browsers: ${
|
|
2275
|
+
n.push(`✅ Closed browsers: ${a.join(", ")}`);
|
|
2238
2276
|
}
|
|
2239
|
-
return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((
|
|
2277
|
+
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)})
|
|
2240
2278
|
${n.join(`
|
|
2241
2279
|
`)}`;
|
|
2242
2280
|
}
|
|
@@ -2261,18 +2299,18 @@ async function We(t, r, s) {
|
|
|
2261
2299
|
let o;
|
|
2262
2300
|
try {
|
|
2263
2301
|
o = te.parse(t);
|
|
2264
|
-
} catch (
|
|
2302
|
+
} catch (h) {
|
|
2265
2303
|
return {
|
|
2266
|
-
error: C(
|
|
2304
|
+
error: C(h)
|
|
2267
2305
|
};
|
|
2268
2306
|
}
|
|
2269
|
-
const { name: e, browserName: n, browser:
|
|
2307
|
+
const { name: e, browserName: n, browser: a, isMobile: i, hasTouch: u, viewport: l } = o;
|
|
2270
2308
|
if (!s.sessionId)
|
|
2271
2309
|
return {
|
|
2272
2310
|
error: "Session ID is required"
|
|
2273
2311
|
};
|
|
2274
2312
|
const c = E(s.sessionId);
|
|
2275
|
-
if (n &&
|
|
2313
|
+
if (n && a)
|
|
2276
2314
|
return {
|
|
2277
2315
|
error: "Either browserName or browser must be provided, not both"
|
|
2278
2316
|
};
|
|
@@ -2282,13 +2320,13 @@ async function We(t, r, s) {
|
|
|
2282
2320
|
return {
|
|
2283
2321
|
error: `Browser "${n}" not found`
|
|
2284
2322
|
};
|
|
2285
|
-
} else if (
|
|
2286
|
-
const
|
|
2287
|
-
if (
|
|
2323
|
+
} else if (a) {
|
|
2324
|
+
const h = await _e(a, r, s);
|
|
2325
|
+
if (h.error != null)
|
|
2288
2326
|
return {
|
|
2289
|
-
error:
|
|
2327
|
+
error: h.error
|
|
2290
2328
|
};
|
|
2291
|
-
d =
|
|
2329
|
+
d = h.browserInfo, f = !0;
|
|
2292
2330
|
} else
|
|
2293
2331
|
return {
|
|
2294
2332
|
error: "Either browserName or browser must be provided"
|
|
@@ -2298,28 +2336,28 @@ async function We(t, r, s) {
|
|
|
2298
2336
|
error: `Context "${e}" already exists in browser "${d.name}" (${d.browserType})`
|
|
2299
2337
|
};
|
|
2300
2338
|
try {
|
|
2301
|
-
const
|
|
2302
|
-
isMobile:
|
|
2339
|
+
const h = await d.browser.newContext({
|
|
2340
|
+
isMobile: i,
|
|
2303
2341
|
hasTouch: u,
|
|
2304
2342
|
viewport: l
|
|
2305
|
-
}),
|
|
2343
|
+
}), m = {
|
|
2306
2344
|
browserInfo: d,
|
|
2307
2345
|
name: e,
|
|
2308
|
-
context:
|
|
2346
|
+
context: h,
|
|
2309
2347
|
pages: /* @__PURE__ */ new Map()
|
|
2310
2348
|
};
|
|
2311
|
-
return d.contexts.set(e,
|
|
2349
|
+
return d.contexts.set(e, m), {
|
|
2312
2350
|
browserInfoCreated: f,
|
|
2313
2351
|
browserInfo: d,
|
|
2314
|
-
contextInfo:
|
|
2352
|
+
contextInfo: m
|
|
2315
2353
|
};
|
|
2316
|
-
} catch (
|
|
2354
|
+
} catch (h) {
|
|
2317
2355
|
return {
|
|
2318
|
-
error: `Failed to create context: ${
|
|
2356
|
+
error: `Failed to create context: ${h instanceof Error ? h.message : "Unknown error"} in browser "${d.name}" (${d.browserType})`
|
|
2319
2357
|
};
|
|
2320
2358
|
}
|
|
2321
2359
|
}
|
|
2322
|
-
function
|
|
2360
|
+
function $r(t, r) {
|
|
2323
2361
|
t(
|
|
2324
2362
|
"playwright-context-create",
|
|
2325
2363
|
{
|
|
@@ -2344,13 +2382,13 @@ const Qe = p.object({
|
|
|
2344
2382
|
"Name of browser to list contexts from. If not specified, lists contexts from all browsers"
|
|
2345
2383
|
)
|
|
2346
2384
|
});
|
|
2347
|
-
async function
|
|
2385
|
+
async function Ir(t, r, s) {
|
|
2348
2386
|
let o;
|
|
2349
2387
|
try {
|
|
2350
2388
|
o = Qe.parse(t);
|
|
2351
|
-
} catch (
|
|
2389
|
+
} catch (i) {
|
|
2352
2390
|
return {
|
|
2353
|
-
error: C(
|
|
2391
|
+
error: C(i)
|
|
2354
2392
|
};
|
|
2355
2393
|
}
|
|
2356
2394
|
const { browserName: e } = o;
|
|
@@ -2358,30 +2396,30 @@ async function wr(t, r, s) {
|
|
|
2358
2396
|
return {
|
|
2359
2397
|
error: "Session ID is required"
|
|
2360
2398
|
};
|
|
2361
|
-
const n = E(s.sessionId),
|
|
2399
|
+
const n = E(s.sessionId), a = [];
|
|
2362
2400
|
if (e) {
|
|
2363
|
-
const
|
|
2364
|
-
if (!
|
|
2401
|
+
const i = n.browsers.get(e);
|
|
2402
|
+
if (!i)
|
|
2365
2403
|
return {
|
|
2366
2404
|
error: `Browser "${e}" not found`
|
|
2367
2405
|
};
|
|
2368
|
-
Array.from(
|
|
2369
|
-
browserInfo:
|
|
2370
|
-
contexts: Array.from(
|
|
2406
|
+
Array.from(i.contexts.values()).length > 0 && a.push({
|
|
2407
|
+
browserInfo: i,
|
|
2408
|
+
contexts: Array.from(i.contexts.values())
|
|
2371
2409
|
});
|
|
2372
2410
|
} else
|
|
2373
|
-
for (const
|
|
2374
|
-
const u = Array.from(
|
|
2375
|
-
u.length > 0 &&
|
|
2376
|
-
browserInfo:
|
|
2411
|
+
for (const i of n.browsers.values()) {
|
|
2412
|
+
const u = Array.from(i.contexts.values());
|
|
2413
|
+
u.length > 0 && a.push({
|
|
2414
|
+
browserInfo: i,
|
|
2377
2415
|
contexts: u
|
|
2378
2416
|
});
|
|
2379
2417
|
}
|
|
2380
2418
|
return {
|
|
2381
|
-
contextsByBrowser:
|
|
2419
|
+
contextsByBrowser: a
|
|
2382
2420
|
};
|
|
2383
2421
|
}
|
|
2384
|
-
function
|
|
2422
|
+
function Mr(t, r) {
|
|
2385
2423
|
t(
|
|
2386
2424
|
"playwright-context-list",
|
|
2387
2425
|
{
|
|
@@ -2390,14 +2428,14 @@ function yr(t, r) {
|
|
|
2390
2428
|
inputSchema: Qe.shape
|
|
2391
2429
|
},
|
|
2392
2430
|
async (s, o) => {
|
|
2393
|
-
const e = await
|
|
2431
|
+
const e = await Ir(s, r, o);
|
|
2394
2432
|
if ("error" in e)
|
|
2395
2433
|
return `Method: playwright-context-list(${JSON.stringify(s)})
|
|
2396
2434
|
❌ Error: ${e.error}`;
|
|
2397
2435
|
let n = `Method: playwright-context-list(${JSON.stringify(s)})
|
|
2398
2436
|
`;
|
|
2399
2437
|
return e.contextsByBrowser.length === 0 ? n += "No contexts found" : n += e.contextsByBrowser.map(
|
|
2400
|
-
({ browserInfo:
|
|
2438
|
+
({ browserInfo: a, contexts: i }) => `${a.name} (${a.browserType}): ${i.map((u) => u.name).join(", ")}`
|
|
2401
2439
|
).join(`
|
|
2402
2440
|
`), n;
|
|
2403
2441
|
}
|
|
@@ -2411,7 +2449,7 @@ const He = p.object({
|
|
|
2411
2449
|
"Name of browser to close contexts from. If not specified, searches all browsers"
|
|
2412
2450
|
)
|
|
2413
2451
|
});
|
|
2414
|
-
async function
|
|
2452
|
+
async function Tr(t, r, s) {
|
|
2415
2453
|
let o;
|
|
2416
2454
|
try {
|
|
2417
2455
|
o = He.parse(t);
|
|
@@ -2425,10 +2463,10 @@ async function br(t, r, s) {
|
|
|
2425
2463
|
return {
|
|
2426
2464
|
error: "Session ID is required"
|
|
2427
2465
|
};
|
|
2428
|
-
const
|
|
2466
|
+
const a = E(s.sessionId), i = [], u = [];
|
|
2429
2467
|
let l = [];
|
|
2430
2468
|
if (n) {
|
|
2431
|
-
const c =
|
|
2469
|
+
const c = a.browsers.get(n);
|
|
2432
2470
|
if (!c)
|
|
2433
2471
|
return {
|
|
2434
2472
|
error: `Browser "${n}" not found`
|
|
@@ -2440,7 +2478,7 @@ async function br(t, r, s) {
|
|
|
2440
2478
|
);
|
|
2441
2479
|
}) : l = Array.from(c.contexts.values());
|
|
2442
2480
|
} else if (e)
|
|
2443
|
-
for (const c of
|
|
2481
|
+
for (const c of a.browsers.values())
|
|
2444
2482
|
e.forEach((f) => {
|
|
2445
2483
|
const d = c.contexts.get(f);
|
|
2446
2484
|
d ? l.push(d) : u.push(
|
|
@@ -2448,12 +2486,12 @@ async function br(t, r, s) {
|
|
|
2448
2486
|
);
|
|
2449
2487
|
});
|
|
2450
2488
|
else
|
|
2451
|
-
for (const c of
|
|
2489
|
+
for (const c of a.browsers.values())
|
|
2452
2490
|
l.push(...Array.from(c.contexts.values()));
|
|
2453
2491
|
return await Promise.all(
|
|
2454
2492
|
l.map(async (c) => {
|
|
2455
2493
|
try {
|
|
2456
|
-
await c.context.close(), c.browserInfo.contexts.delete(c.name),
|
|
2494
|
+
await c.context.close(), c.browserInfo.contexts.delete(c.name), i.push(c);
|
|
2457
2495
|
} catch (f) {
|
|
2458
2496
|
u.push(
|
|
2459
2497
|
`Failed to close context "${c.name}" (${c.browserInfo.name}) (${c.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
|
|
@@ -2461,11 +2499,11 @@ async function br(t, r, s) {
|
|
|
2461
2499
|
}
|
|
2462
2500
|
})
|
|
2463
2501
|
), {
|
|
2464
|
-
closedContextInfos:
|
|
2502
|
+
closedContextInfos: i,
|
|
2465
2503
|
...u.length > 0 && { errors: u }
|
|
2466
2504
|
};
|
|
2467
2505
|
}
|
|
2468
|
-
function
|
|
2506
|
+
function vr(t, r) {
|
|
2469
2507
|
t(
|
|
2470
2508
|
"playwright-context-close",
|
|
2471
2509
|
{
|
|
@@ -2474,24 +2512,24 @@ function xr(t, r) {
|
|
|
2474
2512
|
inputSchema: He.shape
|
|
2475
2513
|
},
|
|
2476
2514
|
async (s, o) => {
|
|
2477
|
-
const e = await
|
|
2515
|
+
const e = await Tr(s, r, o);
|
|
2478
2516
|
if ("error" in e)
|
|
2479
2517
|
return `Method: playwright-context-close(${JSON.stringify(s)})
|
|
2480
2518
|
❌ Error: ${e.error}`;
|
|
2481
2519
|
const n = [];
|
|
2482
2520
|
if (e.closedContextInfos.length > 0) {
|
|
2483
|
-
const
|
|
2484
|
-
(
|
|
2521
|
+
const a = e.closedContextInfos.map(
|
|
2522
|
+
(i) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType})`
|
|
2485
2523
|
);
|
|
2486
|
-
n.push(`✅ Closed contexts: ${
|
|
2524
|
+
n.push(`✅ Closed contexts: ${a.join(", ")}`);
|
|
2487
2525
|
}
|
|
2488
|
-
return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((
|
|
2526
|
+
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)})
|
|
2489
2527
|
${n.join(`
|
|
2490
2528
|
`)}`;
|
|
2491
2529
|
}
|
|
2492
2530
|
);
|
|
2493
2531
|
}
|
|
2494
|
-
function
|
|
2532
|
+
function Cr() {
|
|
2495
2533
|
class t {
|
|
2496
2534
|
prevId = 0;
|
|
2497
2535
|
objectToId = /* @__PURE__ */ new WeakMap();
|
|
@@ -2514,62 +2552,62 @@ function Sr() {
|
|
|
2514
2552
|
return c ?? (this.idToObject.delete(u), null);
|
|
2515
2553
|
}
|
|
2516
2554
|
}
|
|
2517
|
-
function r(
|
|
2555
|
+
function r(i, u, l) {
|
|
2518
2556
|
let c = null;
|
|
2519
2557
|
for (let f = 0, d = u.length; f < d; f++) {
|
|
2520
|
-
const
|
|
2558
|
+
const h = u[f], m = i(h), g = m == null ? null : r(i, m, l), b = l(h, g);
|
|
2521
2559
|
b != null && (c == null && (c = []), c.push(b));
|
|
2522
2560
|
}
|
|
2523
2561
|
return c;
|
|
2524
2562
|
}
|
|
2525
|
-
function s(
|
|
2526
|
-
const { getId: u, getChilds: l, rootNodes: c, createSnapshotNode: f } =
|
|
2563
|
+
function s(i) {
|
|
2564
|
+
const { getId: u, getChilds: l, rootNodes: c, createSnapshotNode: f } = i, d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = r(
|
|
2527
2565
|
l,
|
|
2528
2566
|
c,
|
|
2529
2567
|
(y, x) => {
|
|
2530
2568
|
const I = f(y, x);
|
|
2531
2569
|
if (y != null && I != null) {
|
|
2532
2570
|
const S = u(y);
|
|
2533
|
-
d.set(S, I),
|
|
2571
|
+
d.set(S, I), h.set(I, S);
|
|
2534
2572
|
}
|
|
2535
|
-
return I != null && x != null &&
|
|
2536
|
-
|
|
2537
|
-
x.map((S) =>
|
|
2573
|
+
return I != null && x != null && m.set(
|
|
2574
|
+
h.get(I),
|
|
2575
|
+
x.map((S) => h.get(S))
|
|
2538
2576
|
), I;
|
|
2539
2577
|
}
|
|
2540
2578
|
), b = f(null, g);
|
|
2541
2579
|
if (b == null)
|
|
2542
2580
|
throw new Error("Impossible behavior: rootNode == null");
|
|
2543
|
-
return d.set(null, b), g != null &&
|
|
2581
|
+
return d.set(null, b), g != null && m.set(
|
|
2544
2582
|
null,
|
|
2545
|
-
g.map((y) =>
|
|
2583
|
+
g.map((y) => h.get(y))
|
|
2546
2584
|
), {
|
|
2547
2585
|
idToNode: d,
|
|
2548
|
-
idToChildIds:
|
|
2586
|
+
idToChildIds: m
|
|
2549
2587
|
};
|
|
2550
2588
|
}
|
|
2551
|
-
const o = (
|
|
2552
|
-
function e(
|
|
2589
|
+
const o = (i) => i instanceof HTMLElement ? i.childNodes : null;
|
|
2590
|
+
function e(i) {
|
|
2553
2591
|
return function(l, c) {
|
|
2554
2592
|
const f = c != null && c.length > 0;
|
|
2555
|
-
let d = !1,
|
|
2593
|
+
let d = !1, h = null, m = null;
|
|
2556
2594
|
if (l instanceof HTMLElement) {
|
|
2557
|
-
if (
|
|
2595
|
+
if (h = n.getOrCreateId(l), m = l.tagName.toLowerCase(), d = l.matches(i.cssSelector), !d && !f)
|
|
2558
2596
|
return null;
|
|
2559
2597
|
} else if (l == null)
|
|
2560
|
-
|
|
2598
|
+
h = null, m = null, d = !1;
|
|
2561
2599
|
else
|
|
2562
2600
|
return null;
|
|
2563
2601
|
return {
|
|
2564
|
-
uid:
|
|
2565
|
-
tagName:
|
|
2602
|
+
uid: h,
|
|
2603
|
+
tagName: m,
|
|
2566
2604
|
isMatched: d
|
|
2567
2605
|
};
|
|
2568
2606
|
};
|
|
2569
2607
|
}
|
|
2570
2608
|
const n = new t();
|
|
2571
|
-
function i
|
|
2572
|
-
const u = e(
|
|
2609
|
+
function a(i) {
|
|
2610
|
+
const u = e(i);
|
|
2573
2611
|
return s({
|
|
2574
2612
|
getId: (l) => n.getOrCreateId(l),
|
|
2575
2613
|
getChilds: o,
|
|
@@ -2577,9 +2615,9 @@ function Sr() {
|
|
|
2577
2615
|
rootNodes: [window.document.documentElement]
|
|
2578
2616
|
});
|
|
2579
2617
|
}
|
|
2580
|
-
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom =
|
|
2618
|
+
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = a;
|
|
2581
2619
|
}
|
|
2582
|
-
const
|
|
2620
|
+
const kr = `(function (){function __name(fn){return fn};${Cr.toString()}; setupPageGlobals();})()`, re = p.object({
|
|
2583
2621
|
contextName: p.string().optional().describe("Name of previously created context, to use"),
|
|
2584
2622
|
context: te.optional().describe(
|
|
2585
2623
|
"Context creation options JSON to automatically create context"
|
|
@@ -2597,19 +2635,19 @@ async function Ye(t, r, s) {
|
|
|
2597
2635
|
error: C(f)
|
|
2598
2636
|
};
|
|
2599
2637
|
}
|
|
2600
|
-
const { name: e, contextName: n, context:
|
|
2638
|
+
const { name: e, contextName: n, context: a } = o;
|
|
2601
2639
|
if (!s.sessionId)
|
|
2602
2640
|
return {
|
|
2603
2641
|
error: "Session ID is required"
|
|
2604
2642
|
};
|
|
2605
|
-
const
|
|
2606
|
-
if (n &&
|
|
2643
|
+
const i = E(s.sessionId);
|
|
2644
|
+
if (n && a)
|
|
2607
2645
|
return {
|
|
2608
2646
|
error: "Either contextName or context must be provided, not both"
|
|
2609
2647
|
};
|
|
2610
2648
|
let u = !1, l = !1, c;
|
|
2611
2649
|
if (n) {
|
|
2612
|
-
for (const f of
|
|
2650
|
+
for (const f of i.browsers.values())
|
|
2613
2651
|
if (f.contexts.has(n)) {
|
|
2614
2652
|
c = f.contexts.get(n);
|
|
2615
2653
|
break;
|
|
@@ -2618,8 +2656,8 @@ async function Ye(t, r, s) {
|
|
|
2618
2656
|
return {
|
|
2619
2657
|
error: `Context "${n}" not found`
|
|
2620
2658
|
};
|
|
2621
|
-
} else if (
|
|
2622
|
-
const f = await We(
|
|
2659
|
+
} else if (a) {
|
|
2660
|
+
const f = await We(a, r, s);
|
|
2623
2661
|
if (f.error != null)
|
|
2624
2662
|
return {
|
|
2625
2663
|
error: f.error
|
|
@@ -2635,7 +2673,7 @@ async function Ye(t, r, s) {
|
|
|
2635
2673
|
};
|
|
2636
2674
|
try {
|
|
2637
2675
|
const f = await c.context.newPage();
|
|
2638
|
-
await f.addInitScript(
|
|
2676
|
+
await f.addInitScript(kr), await f.goto("about:blank");
|
|
2639
2677
|
const d = {
|
|
2640
2678
|
contextInfo: c,
|
|
2641
2679
|
name: e,
|
|
@@ -2653,7 +2691,7 @@ async function Ye(t, r, s) {
|
|
|
2653
2691
|
};
|
|
2654
2692
|
}
|
|
2655
2693
|
}
|
|
2656
|
-
function
|
|
2694
|
+
function Nr(t, r) {
|
|
2657
2695
|
t(
|
|
2658
2696
|
"playwright-page-create",
|
|
2659
2697
|
{
|
|
@@ -2682,7 +2720,7 @@ const Ve = p.object({
|
|
|
2682
2720
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
2683
2721
|
)
|
|
2684
2722
|
});
|
|
2685
|
-
async function
|
|
2723
|
+
async function Dr(t, r, s) {
|
|
2686
2724
|
let o;
|
|
2687
2725
|
try {
|
|
2688
2726
|
o = Ve.parse(t);
|
|
@@ -2696,9 +2734,9 @@ async function Mr(t, r, s) {
|
|
|
2696
2734
|
return {
|
|
2697
2735
|
error: "Session ID is required"
|
|
2698
2736
|
};
|
|
2699
|
-
const
|
|
2737
|
+
const a = E(s.sessionId), i = [];
|
|
2700
2738
|
if (n) {
|
|
2701
|
-
const u =
|
|
2739
|
+
const u = a.browsers.get(n);
|
|
2702
2740
|
if (!u)
|
|
2703
2741
|
return {
|
|
2704
2742
|
error: `Browser "${n}" not found`
|
|
@@ -2710,43 +2748,43 @@ async function Mr(t, r, s) {
|
|
|
2710
2748
|
error: `Context "${e}" not found in browser "${u.name}" (${u.browserType})`
|
|
2711
2749
|
};
|
|
2712
2750
|
const c = Array.from(l.pages.values());
|
|
2713
|
-
c.length > 0 &&
|
|
2751
|
+
c.length > 0 && i.push({
|
|
2714
2752
|
contextInfo: l,
|
|
2715
2753
|
pages: c
|
|
2716
2754
|
});
|
|
2717
2755
|
} else
|
|
2718
2756
|
for (const l of u.contexts.values()) {
|
|
2719
2757
|
const c = Array.from(l.pages.values());
|
|
2720
|
-
c.length > 0 &&
|
|
2758
|
+
c.length > 0 && i.push({
|
|
2721
2759
|
contextInfo: l,
|
|
2722
2760
|
pages: c
|
|
2723
2761
|
});
|
|
2724
2762
|
}
|
|
2725
2763
|
} else if (e)
|
|
2726
|
-
for (const u of
|
|
2764
|
+
for (const u of a.browsers.values()) {
|
|
2727
2765
|
const l = u.contexts.get(e);
|
|
2728
2766
|
if (l) {
|
|
2729
2767
|
const c = Array.from(l.pages.values());
|
|
2730
|
-
c.length > 0 &&
|
|
2768
|
+
c.length > 0 && i.push({
|
|
2731
2769
|
contextInfo: l,
|
|
2732
2770
|
pages: c
|
|
2733
2771
|
});
|
|
2734
2772
|
}
|
|
2735
2773
|
}
|
|
2736
2774
|
else
|
|
2737
|
-
for (const u of
|
|
2775
|
+
for (const u of a.browsers.values())
|
|
2738
2776
|
for (const l of u.contexts.values()) {
|
|
2739
2777
|
const c = Array.from(l.pages.values());
|
|
2740
|
-
c.length > 0 &&
|
|
2778
|
+
c.length > 0 && i.push({
|
|
2741
2779
|
contextInfo: l,
|
|
2742
2780
|
pages: c
|
|
2743
2781
|
});
|
|
2744
2782
|
}
|
|
2745
2783
|
return {
|
|
2746
|
-
pagesByContext:
|
|
2784
|
+
pagesByContext: i
|
|
2747
2785
|
};
|
|
2748
2786
|
}
|
|
2749
|
-
function
|
|
2787
|
+
function Er(t, r) {
|
|
2750
2788
|
t(
|
|
2751
2789
|
"playwright-page-list",
|
|
2752
2790
|
{
|
|
@@ -2755,14 +2793,14 @@ function Tr(t, r) {
|
|
|
2755
2793
|
inputSchema: Ve.shape
|
|
2756
2794
|
},
|
|
2757
2795
|
async (s, o) => {
|
|
2758
|
-
const e = await
|
|
2796
|
+
const e = await Dr(s, r, o);
|
|
2759
2797
|
if ("error" in e)
|
|
2760
2798
|
return `Method: playwright-page-list(${JSON.stringify(s)})
|
|
2761
2799
|
❌ Error: ${e.error}`;
|
|
2762
2800
|
let n = `Method: playwright-page-list(${JSON.stringify(s)})
|
|
2763
2801
|
`;
|
|
2764
2802
|
return e.pagesByContext.length === 0 ? n += "No pages found" : n += e.pagesByContext.map(
|
|
2765
|
-
({ contextInfo:
|
|
2803
|
+
({ contextInfo: a, pages: i }) => `${a.name} (${a.browserInfo.name}) (${a.browserInfo.browserType}): ${i.map((u) => u.name).join(", ")}`
|
|
2766
2804
|
).join(`
|
|
2767
2805
|
`), n;
|
|
2768
2806
|
}
|
|
@@ -2777,7 +2815,7 @@ const Ze = p.object({
|
|
|
2777
2815
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
2778
2816
|
)
|
|
2779
2817
|
});
|
|
2780
|
-
async function
|
|
2818
|
+
async function Fr(t, r, s) {
|
|
2781
2819
|
let o;
|
|
2782
2820
|
try {
|
|
2783
2821
|
o = Ze.parse(t);
|
|
@@ -2786,18 +2824,18 @@ async function vr(t, r, s) {
|
|
|
2786
2824
|
error: C(f)
|
|
2787
2825
|
};
|
|
2788
2826
|
}
|
|
2789
|
-
const { names: e, contextName: n, browserName:
|
|
2827
|
+
const { names: e, contextName: n, browserName: a } = o;
|
|
2790
2828
|
if (!s.sessionId)
|
|
2791
2829
|
return {
|
|
2792
2830
|
error: "Session ID is required"
|
|
2793
2831
|
};
|
|
2794
|
-
const
|
|
2832
|
+
const i = E(s.sessionId), u = [], l = [];
|
|
2795
2833
|
let c = [];
|
|
2796
|
-
if (
|
|
2797
|
-
const f =
|
|
2834
|
+
if (a) {
|
|
2835
|
+
const f = i.browsers.get(a);
|
|
2798
2836
|
if (!f)
|
|
2799
2837
|
return {
|
|
2800
|
-
error: `Browser "${
|
|
2838
|
+
error: `Browser "${a}" not found`
|
|
2801
2839
|
};
|
|
2802
2840
|
if (n) {
|
|
2803
2841
|
const d = f.contexts.get(n);
|
|
@@ -2805,37 +2843,37 @@ async function vr(t, r, s) {
|
|
|
2805
2843
|
return {
|
|
2806
2844
|
error: `Context "${n}" not found in browser "${f.name}" (${f.browserType})`
|
|
2807
2845
|
};
|
|
2808
|
-
e ? e.forEach((
|
|
2809
|
-
const
|
|
2810
|
-
|
|
2811
|
-
`Page "${
|
|
2846
|
+
e ? e.forEach((h) => {
|
|
2847
|
+
const m = d.pages.get(h);
|
|
2848
|
+
m ? c.push(m) : l.push(
|
|
2849
|
+
`Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
|
|
2812
2850
|
);
|
|
2813
2851
|
}) : c = Array.from(d.pages.values());
|
|
2814
2852
|
} else
|
|
2815
2853
|
for (const d of f.contexts.values())
|
|
2816
|
-
e ? e.forEach((
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2819
|
-
`Page "${
|
|
2854
|
+
e ? e.forEach((h) => {
|
|
2855
|
+
const m = d.pages.get(h);
|
|
2856
|
+
m ? c.push(m) : l.push(
|
|
2857
|
+
`Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
|
|
2820
2858
|
);
|
|
2821
2859
|
}) : c.push(...Array.from(d.pages.values()));
|
|
2822
2860
|
} else if (n)
|
|
2823
|
-
for (const f of
|
|
2861
|
+
for (const f of i.browsers.values()) {
|
|
2824
2862
|
const d = f.contexts.get(n);
|
|
2825
|
-
d && (e ? e.forEach((
|
|
2826
|
-
const
|
|
2827
|
-
|
|
2828
|
-
`Page "${
|
|
2863
|
+
d && (e ? e.forEach((h) => {
|
|
2864
|
+
const m = d.pages.get(h);
|
|
2865
|
+
m ? c.push(m) : l.push(
|
|
2866
|
+
`Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
|
|
2829
2867
|
);
|
|
2830
2868
|
}) : c.push(...Array.from(d.pages.values())));
|
|
2831
2869
|
}
|
|
2832
2870
|
else
|
|
2833
|
-
for (const f of
|
|
2871
|
+
for (const f of i.browsers.values())
|
|
2834
2872
|
for (const d of f.contexts.values())
|
|
2835
|
-
e ? e.forEach((
|
|
2836
|
-
const
|
|
2837
|
-
|
|
2838
|
-
`Page "${
|
|
2873
|
+
e ? e.forEach((h) => {
|
|
2874
|
+
const m = d.pages.get(h);
|
|
2875
|
+
m ? c.push(m) : l.push(
|
|
2876
|
+
`Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
|
|
2839
2877
|
);
|
|
2840
2878
|
}) : c.push(...Array.from(d.pages.values()));
|
|
2841
2879
|
return await Promise.all(
|
|
@@ -2855,7 +2893,7 @@ async function vr(t, r, s) {
|
|
|
2855
2893
|
...l.length > 0 && { errors: l }
|
|
2856
2894
|
};
|
|
2857
2895
|
}
|
|
2858
|
-
function
|
|
2896
|
+
function Br(t, r) {
|
|
2859
2897
|
t(
|
|
2860
2898
|
"playwright-page-close",
|
|
2861
2899
|
{
|
|
@@ -2864,12 +2902,12 @@ function Cr(t, r) {
|
|
|
2864
2902
|
inputSchema: Ze.shape
|
|
2865
2903
|
},
|
|
2866
2904
|
async (s, o) => {
|
|
2867
|
-
const e = await
|
|
2905
|
+
const e = await Fr(s, r, o);
|
|
2868
2906
|
if ("error" in e)
|
|
2869
2907
|
return `Method: playwright-page-close(${JSON.stringify(s)})
|
|
2870
2908
|
❌ Error: ${e.error}`;
|
|
2871
2909
|
const n = [];
|
|
2872
|
-
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((
|
|
2910
|
+
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)})
|
|
2873
2911
|
${n.join(`
|
|
2874
2912
|
`)}`;
|
|
2875
2913
|
}
|
|
@@ -2890,16 +2928,16 @@ const Xe = p.object({
|
|
|
2890
2928
|
- 'commit': network response received and document started loading`
|
|
2891
2929
|
)
|
|
2892
2930
|
});
|
|
2893
|
-
async function
|
|
2931
|
+
async function Or(t, r, s) {
|
|
2894
2932
|
let o;
|
|
2895
2933
|
try {
|
|
2896
2934
|
o = Xe.parse(t);
|
|
2897
|
-
} catch (
|
|
2935
|
+
} catch (m) {
|
|
2898
2936
|
return {
|
|
2899
|
-
error: C(
|
|
2937
|
+
error: C(m)
|
|
2900
2938
|
};
|
|
2901
2939
|
}
|
|
2902
|
-
const { pageName: e, page: n, url:
|
|
2940
|
+
const { pageName: e, page: n, url: a, timeout: i, waitUntil: u } = o;
|
|
2903
2941
|
if (!s.sessionId)
|
|
2904
2942
|
return {
|
|
2905
2943
|
error: "Session ID is required"
|
|
@@ -2909,56 +2947,56 @@ async function kr(t, r, s) {
|
|
|
2909
2947
|
return {
|
|
2910
2948
|
error: "Either pageName or page must be provided, not both"
|
|
2911
2949
|
};
|
|
2912
|
-
let c = !1, f = !1, d = !1,
|
|
2950
|
+
let c = !1, f = !1, d = !1, h;
|
|
2913
2951
|
if (e) {
|
|
2914
|
-
for (const
|
|
2915
|
-
for (const g of
|
|
2952
|
+
for (const m of l.browsers.values()) {
|
|
2953
|
+
for (const g of m.contexts.values())
|
|
2916
2954
|
if (g.pages.has(e)) {
|
|
2917
|
-
|
|
2955
|
+
h = g.pages.get(e);
|
|
2918
2956
|
break;
|
|
2919
2957
|
}
|
|
2920
|
-
if (
|
|
2958
|
+
if (h) break;
|
|
2921
2959
|
}
|
|
2922
|
-
if (!
|
|
2960
|
+
if (!h)
|
|
2923
2961
|
return {
|
|
2924
2962
|
error: `Page "${e}" not found`
|
|
2925
2963
|
};
|
|
2926
2964
|
} else if (n) {
|
|
2927
|
-
const
|
|
2928
|
-
if (
|
|
2965
|
+
const m = await Ye(n, r, s);
|
|
2966
|
+
if (m.error != null)
|
|
2929
2967
|
return {
|
|
2930
|
-
error:
|
|
2968
|
+
error: m.error
|
|
2931
2969
|
};
|
|
2932
|
-
|
|
2970
|
+
h = m.pageInfo, c = m.browserInfoCreated, f = m.contextInfoCreated, d = !0;
|
|
2933
2971
|
} else
|
|
2934
2972
|
return {
|
|
2935
2973
|
error: "Either pageName or page must be provided"
|
|
2936
2974
|
};
|
|
2937
2975
|
try {
|
|
2938
|
-
const
|
|
2939
|
-
timeout:
|
|
2976
|
+
const m = await h.page.goto(a, {
|
|
2977
|
+
timeout: i * 1e3,
|
|
2940
2978
|
waitUntil: u
|
|
2941
2979
|
});
|
|
2942
|
-
return
|
|
2980
|
+
return m ? {
|
|
2943
2981
|
browserInfoCreated: c,
|
|
2944
2982
|
contextInfoCreated: f,
|
|
2945
2983
|
pageInfoCreated: d,
|
|
2946
|
-
pageInfo:
|
|
2947
|
-
status:
|
|
2984
|
+
pageInfo: h,
|
|
2985
|
+
status: m.status()
|
|
2948
2986
|
} : {
|
|
2949
2987
|
browserInfoCreated: c,
|
|
2950
2988
|
contextInfoCreated: f,
|
|
2951
2989
|
pageInfoCreated: d,
|
|
2952
|
-
pageInfo:
|
|
2990
|
+
pageInfo: h,
|
|
2953
2991
|
status: 200
|
|
2954
2992
|
};
|
|
2955
|
-
} catch (
|
|
2993
|
+
} catch (m) {
|
|
2956
2994
|
return {
|
|
2957
|
-
error: `Failed to navigate to "${
|
|
2995
|
+
error: `Failed to navigate to "${a}": ${m instanceof Error ? m.message : "Unknown error"}`
|
|
2958
2996
|
};
|
|
2959
2997
|
}
|
|
2960
2998
|
}
|
|
2961
|
-
function
|
|
2999
|
+
function Rr(t, r) {
|
|
2962
3000
|
t(
|
|
2963
3001
|
"playwright-page-goto",
|
|
2964
3002
|
{
|
|
@@ -2967,7 +3005,7 @@ function Nr(t, r) {
|
|
|
2967
3005
|
inputSchema: Xe.shape
|
|
2968
3006
|
},
|
|
2969
3007
|
async (s, o) => {
|
|
2970
|
-
const e = await
|
|
3008
|
+
const e = await Or(s, r, o);
|
|
2971
3009
|
if (e.error != null)
|
|
2972
3010
|
return `Method: playwright-page-goto(${JSON.stringify(s)})
|
|
2973
3011
|
❌ Error: ${e.error}`;
|
|
@@ -3000,20 +3038,20 @@ async function et(t, r, s) {
|
|
|
3000
3038
|
return {
|
|
3001
3039
|
error: "Session ID is required"
|
|
3002
3040
|
};
|
|
3003
|
-
const
|
|
3004
|
-
if (
|
|
3041
|
+
const a = E(s.sessionId);
|
|
3042
|
+
if (a.domSnapshotQueries.has(e))
|
|
3005
3043
|
return {
|
|
3006
3044
|
error: `DOM snapshot query "${e}" already exists`
|
|
3007
3045
|
};
|
|
3008
|
-
const
|
|
3046
|
+
const i = {
|
|
3009
3047
|
name: e,
|
|
3010
3048
|
cssSelector: n
|
|
3011
3049
|
};
|
|
3012
|
-
return
|
|
3013
|
-
snapshotQuery:
|
|
3050
|
+
return a.domSnapshotQueries.set(e, i), {
|
|
3051
|
+
snapshotQuery: i
|
|
3014
3052
|
};
|
|
3015
3053
|
}
|
|
3016
|
-
function
|
|
3054
|
+
function Pr(t, r) {
|
|
3017
3055
|
t(
|
|
3018
3056
|
"playwright-dom-snapshot-query-create",
|
|
3019
3057
|
{
|
|
@@ -3029,15 +3067,15 @@ function Dr(t, r) {
|
|
|
3029
3067
|
}
|
|
3030
3068
|
);
|
|
3031
3069
|
}
|
|
3032
|
-
function
|
|
3070
|
+
function zr(t) {
|
|
3033
3071
|
return function(s, o) {
|
|
3034
3072
|
let e, n = 0;
|
|
3035
|
-
const
|
|
3036
|
-
let
|
|
3073
|
+
const a = o ? o.length : 0;
|
|
3074
|
+
let i = 1, u = 0, l = 0, c, f;
|
|
3037
3075
|
if (o)
|
|
3038
|
-
for (let
|
|
3039
|
-
const g = o[
|
|
3040
|
-
n += g.countMatched,
|
|
3076
|
+
for (let m = 0; m < o.length; m++) {
|
|
3077
|
+
const g = o[m];
|
|
3078
|
+
n += g.countMatched, i += g.countTotal, u += g.tokens, l += g.tokensTotal;
|
|
3041
3079
|
}
|
|
3042
3080
|
s ? (c = s.uid, f = s.tagName, e = s.isMatched, e && (n += 1)) : (c = null, f = null, e = !1);
|
|
3043
3081
|
let d;
|
|
@@ -3050,36 +3088,36 @@ function Er(t) {
|
|
|
3050
3088
|
textOpen: `<root uid:${c}>`,
|
|
3051
3089
|
textClose: "</root>"
|
|
3052
3090
|
};
|
|
3053
|
-
const
|
|
3054
|
-
return l +=
|
|
3091
|
+
const h = Ue(d);
|
|
3092
|
+
return l += h, {
|
|
3055
3093
|
uid: c,
|
|
3056
3094
|
tagName: f,
|
|
3057
3095
|
isMatched: e,
|
|
3058
3096
|
countMatched: n,
|
|
3059
|
-
countChilds:
|
|
3060
|
-
countTotal:
|
|
3061
|
-
tokens:
|
|
3097
|
+
countChilds: a,
|
|
3098
|
+
countTotal: i,
|
|
3099
|
+
tokens: h,
|
|
3062
3100
|
tokensChilds: u,
|
|
3063
3101
|
tokensTotal: l,
|
|
3064
3102
|
text: d
|
|
3065
3103
|
};
|
|
3066
3104
|
};
|
|
3067
3105
|
}
|
|
3068
|
-
function
|
|
3069
|
-
const s =
|
|
3106
|
+
function Lr(t, r) {
|
|
3107
|
+
const s = j(r), o = s.getChilds(s.root), e = Le({
|
|
3070
3108
|
getId: (n) => {
|
|
3071
|
-
const
|
|
3072
|
-
if (
|
|
3109
|
+
const a = s.getId(n);
|
|
3110
|
+
if (a == null)
|
|
3073
3111
|
throw new Error(
|
|
3074
3112
|
`Invalid tree structure: node ID is null for node ${JSON.stringify(n)}`
|
|
3075
3113
|
);
|
|
3076
|
-
return
|
|
3114
|
+
return a;
|
|
3077
3115
|
},
|
|
3078
3116
|
getChilds: (n) => s.getChilds(n),
|
|
3079
|
-
createSnapshotNode:
|
|
3117
|
+
createSnapshotNode: zr(),
|
|
3080
3118
|
rootNodes: o ?? []
|
|
3081
3119
|
});
|
|
3082
|
-
return
|
|
3120
|
+
return j(e);
|
|
3083
3121
|
}
|
|
3084
3122
|
const oe = p.object({
|
|
3085
3123
|
pageName: p.string().describe("Name of previously created page, to create snapshot from"),
|
|
@@ -3100,7 +3138,7 @@ async function tt(t, r, s) {
|
|
|
3100
3138
|
error: C(d)
|
|
3101
3139
|
};
|
|
3102
3140
|
}
|
|
3103
|
-
const { pageName: e, queryName: n, query:
|
|
3141
|
+
const { pageName: e, queryName: n, query: a, name: i } = o;
|
|
3104
3142
|
if (!s.sessionId)
|
|
3105
3143
|
return {
|
|
3106
3144
|
error: "Session ID is required"
|
|
@@ -3108,9 +3146,9 @@ async function tt(t, r, s) {
|
|
|
3108
3146
|
const u = E(s.sessionId);
|
|
3109
3147
|
let l;
|
|
3110
3148
|
for (const d of u.browsers.values()) {
|
|
3111
|
-
for (const
|
|
3112
|
-
if (
|
|
3113
|
-
l =
|
|
3149
|
+
for (const h of d.contexts.values())
|
|
3150
|
+
if (h.pages.has(e)) {
|
|
3151
|
+
l = h.pages.get(e);
|
|
3114
3152
|
break;
|
|
3115
3153
|
}
|
|
3116
3154
|
if (l) break;
|
|
@@ -3119,11 +3157,11 @@ async function tt(t, r, s) {
|
|
|
3119
3157
|
return {
|
|
3120
3158
|
error: `Page "${e}" not found`
|
|
3121
3159
|
};
|
|
3122
|
-
if (l.domSnapshots.has(
|
|
3160
|
+
if (l.domSnapshots.has(i))
|
|
3123
3161
|
return {
|
|
3124
|
-
error: `DOM snapshot "${
|
|
3162
|
+
error: `DOM snapshot "${i}" already exists in page "${e}"`
|
|
3125
3163
|
};
|
|
3126
|
-
if (n &&
|
|
3164
|
+
if (n && a)
|
|
3127
3165
|
return {
|
|
3128
3166
|
error: "Either queryName or query must be provided, not both"
|
|
3129
3167
|
};
|
|
@@ -3135,9 +3173,9 @@ async function tt(t, r, s) {
|
|
|
3135
3173
|
error: `DOM snapshot query "${n}" not found`
|
|
3136
3174
|
};
|
|
3137
3175
|
c = d;
|
|
3138
|
-
} else if (
|
|
3176
|
+
} else if (a) {
|
|
3139
3177
|
const d = await et(
|
|
3140
|
-
|
|
3178
|
+
a,
|
|
3141
3179
|
r,
|
|
3142
3180
|
s
|
|
3143
3181
|
);
|
|
@@ -3163,15 +3201,15 @@ async function tt(t, r, s) {
|
|
|
3163
3201
|
};
|
|
3164
3202
|
},
|
|
3165
3203
|
c
|
|
3166
|
-
),
|
|
3204
|
+
), h = {
|
|
3167
3205
|
idToNode: new Map(d.idToNode),
|
|
3168
3206
|
idToChildIds: new Map(d.idToChildIds)
|
|
3169
|
-
},
|
|
3170
|
-
name:
|
|
3207
|
+
}, m = Lr(c, h), g = {
|
|
3208
|
+
name: i,
|
|
3171
3209
|
query: c,
|
|
3172
|
-
tree:
|
|
3210
|
+
tree: m
|
|
3173
3211
|
};
|
|
3174
|
-
return l.domSnapshots.set(
|
|
3212
|
+
return l.domSnapshots.set(i, g), {
|
|
3175
3213
|
domSnapshot: g,
|
|
3176
3214
|
queryCreated: f
|
|
3177
3215
|
};
|
|
@@ -3181,7 +3219,7 @@ async function tt(t, r, s) {
|
|
|
3181
3219
|
};
|
|
3182
3220
|
}
|
|
3183
3221
|
}
|
|
3184
|
-
function
|
|
3222
|
+
function Ur(t, r) {
|
|
3185
3223
|
t(
|
|
3186
3224
|
"playwright-dom-snapshot-create",
|
|
3187
3225
|
{
|
|
@@ -3201,7 +3239,7 @@ function Fr(t, r) {
|
|
|
3201
3239
|
}
|
|
3202
3240
|
);
|
|
3203
3241
|
}
|
|
3204
|
-
class
|
|
3242
|
+
class Ar {
|
|
3205
3243
|
tokens = 16;
|
|
3206
3244
|
getReportText = (r) => ({
|
|
3207
3245
|
indent: !0,
|
|
@@ -3235,7 +3273,7 @@ const rt = p.object({
|
|
|
3235
3273
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
3236
3274
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
3237
3275
|
});
|
|
3238
|
-
async function
|
|
3276
|
+
async function qr(t, r, s) {
|
|
3239
3277
|
let o;
|
|
3240
3278
|
try {
|
|
3241
3279
|
o = rt.parse(t);
|
|
@@ -3247,12 +3285,12 @@ async function Rr(t, r, s) {
|
|
|
3247
3285
|
const {
|
|
3248
3286
|
snapshotName: e,
|
|
3249
3287
|
snapshot: n,
|
|
3250
|
-
childsIndexRange:
|
|
3288
|
+
childsIndexRange: a
|
|
3251
3289
|
// maxCountTotal,
|
|
3252
3290
|
// maxTokensTotal,
|
|
3253
3291
|
// maxCountGroup,
|
|
3254
3292
|
// maxTokensGroup,
|
|
3255
|
-
} = o,
|
|
3293
|
+
} = o, i = 60, u = 1e3, l = 25, c = 900;
|
|
3256
3294
|
if (!s.sessionId)
|
|
3257
3295
|
return {
|
|
3258
3296
|
error: "Session ID is required"
|
|
@@ -3262,7 +3300,7 @@ async function Rr(t, r, s) {
|
|
|
3262
3300
|
return {
|
|
3263
3301
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
3264
3302
|
};
|
|
3265
|
-
let d,
|
|
3303
|
+
let d, h = !1, m = !1;
|
|
3266
3304
|
if (e) {
|
|
3267
3305
|
for (const g of f.browsers.values()) {
|
|
3268
3306
|
for (const b of g.contexts.values()) {
|
|
@@ -3289,32 +3327,32 @@ async function Rr(t, r, s) {
|
|
|
3289
3327
|
return {
|
|
3290
3328
|
error: g.error
|
|
3291
3329
|
};
|
|
3292
|
-
d = g.domSnapshot,
|
|
3330
|
+
d = g.domSnapshot, h = g.queryCreated, m = !0;
|
|
3293
3331
|
} else
|
|
3294
3332
|
return {
|
|
3295
3333
|
error: "Either snapshotName or snapshot must be provided"
|
|
3296
3334
|
};
|
|
3297
3335
|
try {
|
|
3298
|
-
const g = o.parentUid, b =
|
|
3336
|
+
const g = o.parentUid, b = qe({
|
|
3299
3337
|
tree: d.tree,
|
|
3300
3338
|
request: {
|
|
3301
3339
|
parentNodeId: g,
|
|
3302
|
-
childsIndexRange:
|
|
3340
|
+
childsIndexRange: a,
|
|
3303
3341
|
limits: {
|
|
3304
|
-
maxCountTotal:
|
|
3342
|
+
maxCountTotal: i,
|
|
3305
3343
|
maxTokensTotal: u,
|
|
3306
3344
|
maxCountGroup: l,
|
|
3307
3345
|
maxTokensGroup: c
|
|
3308
3346
|
}
|
|
3309
3347
|
},
|
|
3310
|
-
indexRangeGroupStrategy: new
|
|
3311
|
-
}), y =
|
|
3348
|
+
indexRangeGroupStrategy: new Ar()
|
|
3349
|
+
}), y = Ge(b);
|
|
3312
3350
|
return {
|
|
3313
3351
|
domSnapshot: d,
|
|
3314
|
-
queryCreated:
|
|
3315
|
-
snapshotCreated:
|
|
3352
|
+
queryCreated: h,
|
|
3353
|
+
snapshotCreated: m,
|
|
3316
3354
|
parentUid: g,
|
|
3317
|
-
childsIndexRange:
|
|
3355
|
+
childsIndexRange: a,
|
|
3318
3356
|
report: y
|
|
3319
3357
|
};
|
|
3320
3358
|
} catch (g) {
|
|
@@ -3323,7 +3361,7 @@ async function Rr(t, r, s) {
|
|
|
3323
3361
|
};
|
|
3324
3362
|
}
|
|
3325
3363
|
}
|
|
3326
|
-
function
|
|
3364
|
+
function Gr(t, r) {
|
|
3327
3365
|
t(
|
|
3328
3366
|
"playwright-dom-snapshot-browse",
|
|
3329
3367
|
{
|
|
@@ -3332,7 +3370,7 @@ function zr(t, r) {
|
|
|
3332
3370
|
inputSchema: rt.shape
|
|
3333
3371
|
},
|
|
3334
3372
|
async (s, o) => {
|
|
3335
|
-
const e = await
|
|
3373
|
+
const e = await qr(s, r, o);
|
|
3336
3374
|
if (e.error != null)
|
|
3337
3375
|
return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
|
|
3338
3376
|
❌ Error: ${e.error}`;
|
|
@@ -3344,8 +3382,8 @@ function zr(t, r) {
|
|
|
3344
3382
|
`, n += `CSS Selector: ${e.domSnapshot.query.cssSelector}
|
|
3345
3383
|
`, n += `Parent UID: ${e.parentUid ?? "null (root node)"}
|
|
3346
3384
|
`, e.childsIndexRange) {
|
|
3347
|
-
const [
|
|
3348
|
-
n += ` Showing indexes: ${
|
|
3385
|
+
const [a, i] = e.childsIndexRange, l = (e.parentUid ? e.domSnapshot.tree.getNode(e.parentUid) : e.domSnapshot.tree.root).countChilds;
|
|
3386
|
+
n += ` Showing indexes: ${a}-${i} of ${l}
|
|
3349
3387
|
`;
|
|
3350
3388
|
}
|
|
3351
3389
|
return n += `
|
|
@@ -3353,12 +3391,12 @@ ${e.report}`, n;
|
|
|
3353
3391
|
}
|
|
3354
3392
|
);
|
|
3355
3393
|
}
|
|
3356
|
-
function
|
|
3357
|
-
r.browserCreate &&
|
|
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");
|
|
3358
3396
|
}
|
|
3359
|
-
function
|
|
3397
|
+
function _r(t) {
|
|
3360
3398
|
const { logFilePath: r } = t;
|
|
3361
|
-
return async function(o, e, n,
|
|
3399
|
+
return async function(o, e, n, a) {
|
|
3362
3400
|
await q({
|
|
3363
3401
|
logFilePath: r,
|
|
3364
3402
|
message: "ERROR",
|
|
@@ -3378,60 +3416,39 @@ function Lr(t) {
|
|
|
3378
3416
|
});
|
|
3379
3417
|
};
|
|
3380
3418
|
}
|
|
3381
|
-
function
|
|
3419
|
+
function st() {
|
|
3382
3420
|
return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
|
|
3383
3421
|
}
|
|
3384
|
-
function
|
|
3385
|
-
const r =
|
|
3422
|
+
function Jr(t) {
|
|
3423
|
+
const r = A(), s = Kr();
|
|
3386
3424
|
return r.use(s), r;
|
|
3387
3425
|
}
|
|
3388
|
-
function
|
|
3389
|
-
const r =
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
}), s = _r(r, t);
|
|
3394
|
-
return {
|
|
3395
|
-
mcpServer: r,
|
|
3396
|
-
mcpRouter: s
|
|
3397
|
-
};
|
|
3398
|
-
}
|
|
3399
|
-
function qr(t) {
|
|
3400
|
-
const r = G.Router();
|
|
3401
|
-
return r.use(
|
|
3402
|
-
st.default({
|
|
3403
|
-
origin: "*",
|
|
3404
|
-
credentials: !0,
|
|
3405
|
-
allowedHeaders: [
|
|
3406
|
-
"Content-Type",
|
|
3407
|
-
"Authorization",
|
|
3408
|
-
"X-Session-Id",
|
|
3409
|
-
"mcp-session-id"
|
|
3410
|
-
],
|
|
3411
|
-
exposedHeaders: ["mcp-session-id"]
|
|
3412
|
-
})
|
|
3413
|
-
), 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;
|
|
3414
3431
|
}
|
|
3415
|
-
function
|
|
3416
|
-
const
|
|
3417
|
-
return
|
|
3432
|
+
function Wr(t) {
|
|
3433
|
+
const r = A.Router();
|
|
3434
|
+
return r.use(wt({ authToken: t.authToken })), r.all("/mcp", $t(t)), r;
|
|
3418
3435
|
}
|
|
3419
|
-
function
|
|
3420
|
-
return t.use(
|
|
3436
|
+
function Qr(t, r) {
|
|
3437
|
+
return t.use(_r({ logFilePath: r.logFilePath })), new Promise((s, o) => {
|
|
3421
3438
|
let e;
|
|
3422
3439
|
const n = () => {
|
|
3423
3440
|
s(e);
|
|
3424
3441
|
};
|
|
3425
3442
|
try {
|
|
3426
|
-
e = r.host ? t.listen(r.port ?? 0, r.host, n) : t.listen(r.port ?? 0, n), e.addListener("error", (
|
|
3427
|
-
o(
|
|
3443
|
+
e = r.host ? t.listen(r.port ?? 0, r.host, n) : t.listen(r.port ?? 0, n), e.addListener("error", (a) => {
|
|
3444
|
+
o(a);
|
|
3428
3445
|
});
|
|
3429
|
-
} catch (
|
|
3430
|
-
o(
|
|
3446
|
+
} catch (a) {
|
|
3447
|
+
o(a);
|
|
3431
3448
|
}
|
|
3432
3449
|
});
|
|
3433
3450
|
}
|
|
3434
|
-
function
|
|
3451
|
+
function Hr(t, r) {
|
|
3435
3452
|
const s = t.address().family, o = t.address().port;
|
|
3436
3453
|
let e = t.address().address;
|
|
3437
3454
|
e === "::" ? e = "localhost" : s === "IPv6" && (e = `[${e}]`);
|
|
@@ -3445,36 +3462,47 @@ SSE Endpoint: ${n}/sse
|
|
|
3445
3462
|
|
|
3446
3463
|
Log File: ${T.resolve(r.logFilePath)}`;
|
|
3447
3464
|
}
|
|
3448
|
-
|
|
3449
|
-
const
|
|
3450
|
-
|
|
3451
|
-
logFilePath: r
|
|
3465
|
+
function Yr(t, r) {
|
|
3466
|
+
const s = T.join(r.logDir, st()), o = At(t, {
|
|
3467
|
+
logFilePath: s
|
|
3452
3468
|
});
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
logFilePath: r
|
|
3469
|
+
r.tools.processManager && Ut(o, r.tools.processManager), r.tools.fsManager && gr(o, r.tools.fsManager), r.tools.playwrightManager && jr(o, {
|
|
3470
|
+
...r.tools.playwrightManager
|
|
3456
3471
|
});
|
|
3457
|
-
|
|
3458
|
-
|
|
3472
|
+
}
|
|
3473
|
+
async function ps(t) {
|
|
3474
|
+
const r = T.join(t.logDir, st()), s = Jr(), o = Wr({
|
|
3475
|
+
...t,
|
|
3476
|
+
logFilePath: r,
|
|
3477
|
+
createMcpServer: () => {
|
|
3478
|
+
const n = new ot({
|
|
3479
|
+
title: t.title,
|
|
3480
|
+
name: t.name,
|
|
3481
|
+
version: t.version
|
|
3482
|
+
});
|
|
3483
|
+
return Yr(n, t), n;
|
|
3484
|
+
}
|
|
3459
3485
|
});
|
|
3460
|
-
|
|
3486
|
+
s.use(o);
|
|
3487
|
+
const e = await Qr(s, {
|
|
3461
3488
|
host: t.host,
|
|
3462
3489
|
port: t.port,
|
|
3463
3490
|
logFilePath: r
|
|
3464
3491
|
});
|
|
3465
3492
|
return console.log(
|
|
3466
|
-
|
|
3493
|
+
Hr(e, {
|
|
3494
|
+
title: t.title,
|
|
3467
3495
|
name: t.name,
|
|
3468
3496
|
version: t.version,
|
|
3469
|
-
|
|
3470
|
-
logFilePath: r,
|
|
3471
|
-
enableJsonResponse: t.enableJsonResponse
|
|
3497
|
+
logFilePath: r
|
|
3472
3498
|
})
|
|
3473
|
-
),
|
|
3499
|
+
), e;
|
|
3474
3500
|
}
|
|
3475
3501
|
export {
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3502
|
+
ms as A,
|
|
3503
|
+
hs as S,
|
|
3504
|
+
fs as a,
|
|
3505
|
+
ds as b,
|
|
3506
|
+
Zt as p,
|
|
3507
|
+
ps as s
|
|
3480
3508
|
};
|