@flemist/mcp-project-tools 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import { McpServer as
|
|
4
|
-
import { randomBytes as
|
|
5
|
-
import { StreamableHTTPServerTransport as
|
|
6
|
-
import * as
|
|
1
|
+
import G from "express";
|
|
2
|
+
import * as st from "cors";
|
|
3
|
+
import { McpServer as ot } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { randomBytes as nt } from "crypto";
|
|
5
|
+
import { StreamableHTTPServerTransport as it } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
6
|
+
import * as F from "fs";
|
|
7
7
|
import * as T from "path";
|
|
8
|
-
import
|
|
9
|
-
import { spawn as
|
|
8
|
+
import at from "path";
|
|
9
|
+
import { spawn as lt } from "child_process";
|
|
10
10
|
import { z as p } from "zod";
|
|
11
|
-
import
|
|
12
|
-
import { Pool as
|
|
13
|
-
import { priorityCreate as
|
|
14
|
-
import { useAbortController as
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { webkit as
|
|
18
|
-
function
|
|
11
|
+
import K from "tree-kill";
|
|
12
|
+
import { Pool as ct, poolRunWait as L } from "@flemist/time-limits";
|
|
13
|
+
import { priorityCreate as P } from "@flemist/priority-queue";
|
|
14
|
+
import { useAbortController as ut, combineAbortSignals as dt } from "@flemist/async-utils";
|
|
15
|
+
import ft from "node:os";
|
|
16
|
+
import mt from "picomatch";
|
|
17
|
+
import { webkit as ht, firefox as pt, chromium as gt } from "playwright";
|
|
18
|
+
function wt(t) {
|
|
19
19
|
const { authToken: r } = t;
|
|
20
20
|
return function(o, e, n) {
|
|
21
21
|
if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== r) {
|
|
@@ -25,42 +25,42 @@ function gt(t) {
|
|
|
25
25
|
n();
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
28
|
+
async function q(t) {
|
|
29
29
|
const { logFilePath: r, message: s, data: o } = t;
|
|
30
30
|
try {
|
|
31
31
|
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), i = `[${e}] ${s}
|
|
32
32
|
${n}
|
|
33
33
|
|
|
34
34
|
`;
|
|
35
|
-
await
|
|
35
|
+
await F.promises.mkdir(T.dirname(r), { recursive: !0 }), await F.promises.appendFile(r, i);
|
|
36
36
|
} catch (e) {
|
|
37
37
|
console.error(`Failed to log "${s}":`, e);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
function
|
|
40
|
+
const z = /* @__PURE__ */ new Map();
|
|
41
|
+
function yt(t, r) {
|
|
42
42
|
return async function(o, e) {
|
|
43
43
|
const n = o.headers["mcp-session-id"] || o.headers["x-session-id"] || o.query.token;
|
|
44
44
|
let i;
|
|
45
|
-
o.method === "POST" ? (await
|
|
45
|
+
o.method === "POST" ? (await q({
|
|
46
46
|
logFilePath: r.logFilePath,
|
|
47
47
|
message: "REQUEST",
|
|
48
48
|
data: o.body
|
|
49
|
-
}), n &&
|
|
50
|
-
sessionIdGenerator: () => n ||
|
|
49
|
+
}), n && z.has(n) ? i = z.get(n) : (i = new it({
|
|
50
|
+
sessionIdGenerator: () => n || nt(16).toString("hex"),
|
|
51
51
|
onsessioninitialized: (a) => {
|
|
52
|
-
|
|
52
|
+
z.set(a, i), console.log(`Session initialized: ${a}`);
|
|
53
53
|
},
|
|
54
54
|
enableJsonResponse: r.enableJsonResponse || !1
|
|
55
55
|
}), i.onclose = () => {
|
|
56
|
-
i.sessionId && (
|
|
57
|
-
}, await t.connect(i), n &&
|
|
56
|
+
i.sessionId && (z.delete(i.sessionId), console.log(`Session closed: ${i.sessionId}`));
|
|
57
|
+
}, await t.connect(i), n && z.set(n, i)), await i.handleRequest(o, e, o.body)) : o.method === "GET" ? n && z.has(n) ? (i = z.get(n), await i.handleRequest(o, e)) : e.status(400).json({ error: "No valid session" }) : e.status(405).json({ error: "Method not allowed" });
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
let
|
|
62
|
-
const
|
|
63
|
-
function
|
|
60
|
+
const O = /* @__PURE__ */ new Map();
|
|
61
|
+
let bt = 0;
|
|
62
|
+
const ie = 10, xt = 1800 * 1e3, k = 2e3, St = 500, $t = 5e3;
|
|
63
|
+
function It(t) {
|
|
64
64
|
const { commandLine: r, commandLineRules: s } = t;
|
|
65
65
|
let o = !1;
|
|
66
66
|
for (const e of s)
|
|
@@ -77,20 +77,20 @@ function St(t) {
|
|
|
77
77
|
}
|
|
78
78
|
return o;
|
|
79
79
|
}
|
|
80
|
-
function It() {
|
|
81
|
-
return ++yt;
|
|
82
|
-
}
|
|
83
|
-
let ie = !1;
|
|
84
80
|
function Mt() {
|
|
85
|
-
|
|
81
|
+
return ++bt;
|
|
82
|
+
}
|
|
83
|
+
let ae = !1;
|
|
84
|
+
function Tt() {
|
|
85
|
+
if (ae)
|
|
86
86
|
return;
|
|
87
|
-
|
|
87
|
+
ae = !0;
|
|
88
88
|
const t = () => {
|
|
89
89
|
console.log("Auto-killing all child processes...");
|
|
90
|
-
for (const [r, s] of Array.from(
|
|
90
|
+
for (const [r, s] of Array.from(O.entries()))
|
|
91
91
|
if (s.isRunning && s.pid)
|
|
92
92
|
try {
|
|
93
|
-
|
|
93
|
+
K(s.pid, "SIGKILL");
|
|
94
94
|
} catch (o) {
|
|
95
95
|
console.error(`Error killing process ${r}:`, o);
|
|
96
96
|
}
|
|
@@ -98,16 +98,16 @@ function Mt() {
|
|
|
98
98
|
};
|
|
99
99
|
process.on("SIGINT", t), process.on("SIGTERM", t);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function Q() {
|
|
102
102
|
const t = Date.now(), r = [];
|
|
103
|
-
for (const [s, o] of Array.from(
|
|
104
|
-
!o.isRunning && o.endTime && t - o.endTime.getTime() >
|
|
103
|
+
for (const [s, o] of Array.from(O.entries()))
|
|
104
|
+
!o.isRunning && o.endTime && t - o.endTime.getTime() > xt && r.push(s);
|
|
105
105
|
for (const s of r)
|
|
106
|
-
|
|
106
|
+
O.delete(s);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function H(t) {
|
|
109
109
|
const { process: r } = t, s = Date.now();
|
|
110
|
-
if (s - r.lastOutputTime.getTime() >=
|
|
110
|
+
if (s - r.lastOutputTime.getTime() >= St && (r.output += r.localOutput, r.localOutput = "", r.lastOutputTime = new Date(s), r.output.length > k)) {
|
|
111
111
|
const n = `
|
|
112
112
|
... [${r.output.length - k} characters trimmed] ...
|
|
113
113
|
`, i = k - n.length;
|
|
@@ -120,7 +120,7 @@ function Q(t) {
|
|
|
120
120
|
r.output = r.output.substring(0, k);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function vt(t, r) {
|
|
124
124
|
const s = r.limit - 35;
|
|
125
125
|
if (t.length <= s) return t;
|
|
126
126
|
const e = `
|
|
@@ -131,7 +131,12 @@ function Tt(t, r) {
|
|
|
131
131
|
const i = Math.floor(n / 2);
|
|
132
132
|
return t.substring(0, i) + e + t.substring(t.length - (n - i));
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
function C(t) {
|
|
135
|
+
return `Invalid arguments: ${t instanceof Error ? t.message : "Unknown error"}.
|
|
136
|
+
|
|
137
|
+
Provide valid parameters according to schema.`;
|
|
138
|
+
}
|
|
139
|
+
const Ie = p.object({
|
|
135
140
|
id: p.number().describe(
|
|
136
141
|
"Process ID to get detailed status information for. Get process IDs using process-list. Works for both running and completed processes. Examples: 1, 42, 123"
|
|
137
142
|
),
|
|
@@ -139,23 +144,23 @@ const Se = p.object({
|
|
|
139
144
|
`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}.`
|
|
140
145
|
)
|
|
141
146
|
});
|
|
142
|
-
async function
|
|
143
|
-
|
|
147
|
+
async function Y(t, r) {
|
|
148
|
+
Q();
|
|
144
149
|
let s;
|
|
145
150
|
try {
|
|
146
|
-
s =
|
|
151
|
+
s = Ie.parse(t);
|
|
147
152
|
} catch (u) {
|
|
148
153
|
return {
|
|
149
|
-
error:
|
|
154
|
+
error: C(u)
|
|
150
155
|
};
|
|
151
156
|
}
|
|
152
|
-
const { id: o, outputLimit: e } = s, n =
|
|
157
|
+
const { id: o, outputLimit: e } = s, n = O.get(o);
|
|
153
158
|
if (!n)
|
|
154
159
|
return {
|
|
155
160
|
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.`
|
|
156
161
|
};
|
|
157
|
-
|
|
158
|
-
const i = n.output + n.localOutput, a =
|
|
162
|
+
H({ process: n });
|
|
163
|
+
const i = n.output + n.localOutput, a = vt(i, { limit: e });
|
|
159
164
|
return n.output = "", n.localOutput = "", {
|
|
160
165
|
id: n.id,
|
|
161
166
|
cwd: T.relative(r.workingDir || "", n.cwd),
|
|
@@ -169,16 +174,16 @@ async function H(t, r) {
|
|
|
169
174
|
error: n.error
|
|
170
175
|
};
|
|
171
176
|
}
|
|
172
|
-
function
|
|
177
|
+
function Ct(t, r) {
|
|
173
178
|
t(
|
|
174
179
|
"process-status",
|
|
175
180
|
{
|
|
176
181
|
title: "Get Host Machine Process Status",
|
|
177
182
|
description: "Get detailed status information about a process on the host machine. Use this to check if commands completed successfully, get their output, or monitor running processes. The output is cleared after retrieval to prevent duplication in subsequent calls",
|
|
178
|
-
inputSchema:
|
|
183
|
+
inputSchema: Ie.shape
|
|
179
184
|
},
|
|
180
185
|
async (s) => {
|
|
181
|
-
const o = await
|
|
186
|
+
const o = await Y(s, r);
|
|
182
187
|
if (!("output" in o))
|
|
183
188
|
return `Method: process-status(${JSON.stringify(s)})
|
|
184
189
|
❌ Error: ${o.error}`;
|
|
@@ -191,16 +196,16 @@ ${e.trim()}`;
|
|
|
191
196
|
}
|
|
192
197
|
);
|
|
193
198
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
199
|
+
function Me(t) {
|
|
200
|
+
K(t, "SIGTERM", (r) => {
|
|
196
201
|
r && !r.message.includes("not found") && console.error(`Error sending SIGTERM to process ${t}:`, r);
|
|
197
202
|
}), setTimeout(() => {
|
|
198
|
-
|
|
203
|
+
K(t, "SIGKILL", (r) => {
|
|
199
204
|
r && !r.message.includes("not found") && console.error(`Error sending SIGKILL to process ${t}:`, r);
|
|
200
205
|
});
|
|
201
|
-
},
|
|
206
|
+
}, $t);
|
|
202
207
|
}
|
|
203
|
-
const
|
|
208
|
+
const Te = p.object({
|
|
204
209
|
id: p.number().describe(
|
|
205
210
|
"Process ID to wait for completion. Get process IDs using process-list. The process can be running or already completed. Examples: 1, 42, 123"
|
|
206
211
|
),
|
|
@@ -214,16 +219,16 @@ const Me = p.object({
|
|
|
214
219
|
`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}.`
|
|
215
220
|
)
|
|
216
221
|
});
|
|
217
|
-
async function
|
|
222
|
+
async function ve(t, r) {
|
|
218
223
|
let s;
|
|
219
224
|
try {
|
|
220
|
-
s =
|
|
225
|
+
s = Te.parse(t);
|
|
221
226
|
} catch (m) {
|
|
222
227
|
return {
|
|
223
|
-
error:
|
|
228
|
+
error: C(m)
|
|
224
229
|
};
|
|
225
230
|
}
|
|
226
|
-
const { id: o, waitTime: e, autoKill: n, outputLimit: i } = s, a =
|
|
231
|
+
const { id: o, waitTime: e, autoKill: n, outputLimit: i } = s, a = O.get(o);
|
|
227
232
|
if (!a)
|
|
228
233
|
return {
|
|
229
234
|
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.`
|
|
@@ -232,12 +237,12 @@ async function Te(t, r) {
|
|
|
232
237
|
let l = !1, c = !1;
|
|
233
238
|
e != null && await new Promise((h) => {
|
|
234
239
|
const g = setInterval(() => {
|
|
235
|
-
a.isRunning ? Date.now() - u >= e * 1e3 && (clearInterval(g), l = !0, n && a.pid && (
|
|
240
|
+
a.isRunning ? Date.now() - u >= e * 1e3 && (clearInterval(g), l = !0, n && a.pid && (Me(a.pid), c = !0), h()) : (clearInterval(g), h());
|
|
236
241
|
}, 100);
|
|
237
242
|
});
|
|
238
243
|
const f = (Date.now() - u) / 1e3;
|
|
239
244
|
return {
|
|
240
|
-
...await
|
|
245
|
+
...await Y({ id: o, outputLimit: i }, r),
|
|
241
246
|
waitDuration: f,
|
|
242
247
|
waitTimeExceeded: l,
|
|
243
248
|
autoKillExecuted: c
|
|
@@ -249,10 +254,10 @@ function kt(t, r) {
|
|
|
249
254
|
{
|
|
250
255
|
title: "Wait for Host Machine Process",
|
|
251
256
|
description: "Wait for a host machine process to complete execution, with optional timeout and auto-kill functionality. Use this for long-running commands like builds, installs, or tests when you need final results",
|
|
252
|
-
inputSchema:
|
|
257
|
+
inputSchema: Te.shape
|
|
253
258
|
},
|
|
254
259
|
async (s) => {
|
|
255
|
-
const o = await
|
|
260
|
+
const o = await ve(s, r);
|
|
256
261
|
if (!("output" in o))
|
|
257
262
|
return `Method: process-wait(${JSON.stringify(s)})
|
|
258
263
|
❌ Error: ${o.error}`;
|
|
@@ -265,7 +270,7 @@ ${e.trim()}`;
|
|
|
265
270
|
}
|
|
266
271
|
);
|
|
267
272
|
}
|
|
268
|
-
const
|
|
273
|
+
const Ce = p.object({
|
|
269
274
|
cwd: p.string().optional().describe(
|
|
270
275
|
'Working directory for command execution, resolved relative to the current working directory. Leave empty to use current directory. Examples: "src" (run in src/ subdirectory), "../parent" (run in parent directory), "build/output" (run in nested subdirectory). Directory must exist'
|
|
271
276
|
),
|
|
@@ -282,18 +287,18 @@ const ve = p.object({
|
|
|
282
287
|
`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}.`
|
|
283
288
|
)
|
|
284
289
|
});
|
|
285
|
-
async function
|
|
286
|
-
|
|
290
|
+
async function Nt(t, r) {
|
|
291
|
+
Q();
|
|
287
292
|
let s;
|
|
288
293
|
try {
|
|
289
|
-
s =
|
|
294
|
+
s = Ce.parse(t);
|
|
290
295
|
} catch (d) {
|
|
291
296
|
return {
|
|
292
|
-
error:
|
|
297
|
+
error: C(d)
|
|
293
298
|
};
|
|
294
299
|
}
|
|
295
300
|
const { commandLine: o, waitTime: e, autoKill: n, outputLimit: i } = s, { commandLineRules: a } = r, u = T.resolve(r.workingDir || "", s.cwd || "");
|
|
296
|
-
if (!
|
|
301
|
+
if (!It({ commandLine: o, commandLineRules: a })) {
|
|
297
302
|
const d = a.map(
|
|
298
303
|
(m) => `${m.rule.toUpperCase()}: /${m.regexp}/ (${m.note})`
|
|
299
304
|
).join(`
|
|
@@ -305,13 +310,13 @@ ${d}
|
|
|
305
310
|
To use this command line, ask the user to modify the command line rules in the configuration.`
|
|
306
311
|
};
|
|
307
312
|
}
|
|
308
|
-
if (Array.from(
|
|
313
|
+
if (Array.from(O.values()).filter(
|
|
309
314
|
(d) => d.isRunning
|
|
310
|
-
).length >=
|
|
315
|
+
).length >= ie)
|
|
311
316
|
return {
|
|
312
|
-
error: `Maximum concurrent process limit reached (${
|
|
317
|
+
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.`
|
|
313
318
|
};
|
|
314
|
-
const c =
|
|
319
|
+
const c = Mt(), f = {
|
|
315
320
|
id: c,
|
|
316
321
|
cwd: u,
|
|
317
322
|
commandLine: o,
|
|
@@ -321,9 +326,9 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
321
326
|
localOutput: "",
|
|
322
327
|
lastOutputTime: /* @__PURE__ */ new Date()
|
|
323
328
|
};
|
|
324
|
-
|
|
329
|
+
O.set(c, f);
|
|
325
330
|
try {
|
|
326
|
-
const d =
|
|
331
|
+
const d = lt(o, [], {
|
|
327
332
|
shell: !0,
|
|
328
333
|
cwd: u,
|
|
329
334
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -331,7 +336,7 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
331
336
|
f.pid = d.pid;
|
|
332
337
|
const m = (h) => {
|
|
333
338
|
const g = h.toString();
|
|
334
|
-
f.localOutput += g,
|
|
339
|
+
f.localOutput += g, H({ process: f }), console.log(g);
|
|
335
340
|
};
|
|
336
341
|
return d.stdout?.on("data", m), d.stderr?.on("data", m), d.on("close", (h) => {
|
|
337
342
|
if (f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.exitCode = h !== null ? h : void 0, f.output += f.localOutput, f.localOutput = "", f.output.length > k) {
|
|
@@ -339,9 +344,9 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
339
344
|
... [${f.output.length - k} characters trimmed] ...
|
|
340
345
|
`, y = k - b.length;
|
|
341
346
|
if (y > 0) {
|
|
342
|
-
const
|
|
343
|
-
f.output = f.output.substring(0,
|
|
344
|
-
f.output.length - (y -
|
|
347
|
+
const x = Math.floor(y / 2);
|
|
348
|
+
f.output = f.output.substring(0, x) + b + f.output.substring(
|
|
349
|
+
f.output.length - (y - x)
|
|
345
350
|
);
|
|
346
351
|
} else
|
|
347
352
|
f.output = f.output.substring(0, k);
|
|
@@ -349,12 +354,12 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
349
354
|
console.log(`Process ${c} (${o}) exited with code ${h}`);
|
|
350
355
|
}), d.on("error", (h) => {
|
|
351
356
|
f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = h.message, console.error(`Process ${c} error:`, h.message);
|
|
352
|
-
}), e != null ?
|
|
357
|
+
}), e != null ? ve({ id: c, waitTime: e, autoKill: n, outputLimit: i }, r) : Y({ id: c, outputLimit: i }, r);
|
|
353
358
|
} catch (d) {
|
|
354
359
|
return f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = d instanceof Error ? d.message : "Unknown error", { error: f.error };
|
|
355
360
|
}
|
|
356
361
|
}
|
|
357
|
-
function
|
|
362
|
+
function Dt(t, r) {
|
|
358
363
|
const s = r.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
|
|
359
364
|
`);
|
|
360
365
|
t(
|
|
@@ -363,10 +368,10 @@ function Et(t, r) {
|
|
|
363
368
|
title: "Execute Command Line on Host Machine",
|
|
364
369
|
description: `Execute command lines on the host machine. Use this to build, test, lint, install packages, or run system commands. Prefer process-run with waitTime parameter if you need to immediately execute and wait for completion, instead of separate process-run and process-wait calls. Security: Command lines are validated against configured rules processed in order (later rules override earlier ones). Current command line rules:
|
|
365
370
|
${s}`,
|
|
366
|
-
inputSchema:
|
|
371
|
+
inputSchema: Ce.shape
|
|
367
372
|
},
|
|
368
373
|
async (o) => {
|
|
369
|
-
const e = await
|
|
374
|
+
const e = await Nt(o, r);
|
|
370
375
|
if (!("output" in e))
|
|
371
376
|
return `Method: process-run(${JSON.stringify(o)})
|
|
372
377
|
❌ Error: ${e.error}`;
|
|
@@ -393,18 +398,18 @@ const ke = p.object({
|
|
|
393
398
|
'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'
|
|
394
399
|
)
|
|
395
400
|
});
|
|
396
|
-
async function
|
|
397
|
-
|
|
401
|
+
async function Et(t, r) {
|
|
402
|
+
Q();
|
|
398
403
|
let s;
|
|
399
404
|
try {
|
|
400
405
|
s = ke.parse(t);
|
|
401
406
|
} catch (l) {
|
|
402
407
|
return {
|
|
403
|
-
error:
|
|
408
|
+
error: C(l)
|
|
404
409
|
};
|
|
405
410
|
}
|
|
406
411
|
const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: i } = s;
|
|
407
|
-
let a = Array.from(
|
|
412
|
+
let a = Array.from(O.values());
|
|
408
413
|
if (o) {
|
|
409
414
|
const l = new Date(o.replace(/[_\s]/g, "T"));
|
|
410
415
|
a = a.filter((c) => c.startTime >= l);
|
|
@@ -414,10 +419,10 @@ async function Nt(t, r) {
|
|
|
414
419
|
a = a.filter((c) => c.endTime && c.endTime >= l);
|
|
415
420
|
}
|
|
416
421
|
return n && (a = a.filter((l) => l.isRunning)), { processes: a.map((l) => {
|
|
417
|
-
|
|
422
|
+
H({ process: l });
|
|
418
423
|
let c = {
|
|
419
424
|
id: l.id,
|
|
420
|
-
cwd:
|
|
425
|
+
cwd: at.relative(r.workingDir || "", l.cwd),
|
|
421
426
|
commandLine: l.commandLine,
|
|
422
427
|
pid: l.pid,
|
|
423
428
|
startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
@@ -436,7 +441,7 @@ async function Nt(t, r) {
|
|
|
436
441
|
return c;
|
|
437
442
|
}) };
|
|
438
443
|
}
|
|
439
|
-
function
|
|
444
|
+
function Bt(t, r) {
|
|
440
445
|
t(
|
|
441
446
|
"process-list",
|
|
442
447
|
{
|
|
@@ -445,7 +450,7 @@ function Dt(t, r) {
|
|
|
445
450
|
inputSchema: ke.shape
|
|
446
451
|
},
|
|
447
452
|
async (s) => {
|
|
448
|
-
const o = await
|
|
453
|
+
const o = await Et(s, r);
|
|
449
454
|
if (o.error != null)
|
|
450
455
|
return `Method: process-list(${JSON.stringify(s)})
|
|
451
456
|
❌ Error: ${o.error}`;
|
|
@@ -459,21 +464,21 @@ ${e}`;
|
|
|
459
464
|
}
|
|
460
465
|
);
|
|
461
466
|
}
|
|
462
|
-
const
|
|
467
|
+
const Ne = p.object({
|
|
463
468
|
id: p.number().describe(
|
|
464
469
|
"Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
|
|
465
470
|
)
|
|
466
471
|
});
|
|
467
|
-
function
|
|
472
|
+
function Ft(t) {
|
|
468
473
|
let r;
|
|
469
474
|
try {
|
|
470
|
-
r =
|
|
475
|
+
r = Ne.parse(t);
|
|
471
476
|
} catch (e) {
|
|
472
477
|
return {
|
|
473
|
-
error:
|
|
478
|
+
error: C(e)
|
|
474
479
|
};
|
|
475
480
|
}
|
|
476
|
-
const { id: s } = r, o =
|
|
481
|
+
const { id: s } = r, o = O.get(s);
|
|
477
482
|
if (!o)
|
|
478
483
|
return {
|
|
479
484
|
error: `Process ${s} not found. The process may have already completed, been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
@@ -487,31 +492,31 @@ function Bt(t) {
|
|
|
487
492
|
error: `Process ${s} has no system process ID (PID). This indicates the process failed to start properly or the system was unable to assign a PID. Check process-status for error details.`
|
|
488
493
|
};
|
|
489
494
|
try {
|
|
490
|
-
return
|
|
495
|
+
return Me(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
|
|
491
496
|
} catch (e) {
|
|
492
497
|
return {
|
|
493
498
|
error: `Failed to terminate process ${s}: ${e instanceof Error ? e.message : "Unknown error"}. The process may have already exited, be protected by the system, or there may be insufficient permissions. Use process-status to check current process state.`
|
|
494
499
|
};
|
|
495
500
|
}
|
|
496
501
|
}
|
|
497
|
-
function
|
|
502
|
+
function Ot(t, r) {
|
|
498
503
|
t(
|
|
499
504
|
"process-kill",
|
|
500
505
|
{
|
|
501
506
|
title: "Kill Host Machine Process",
|
|
502
507
|
description: "Forcibly terminate a running process on the host machine. Use this to stop runaway processes, hung commands, or long-running tasks that need to be cancelled",
|
|
503
|
-
inputSchema:
|
|
508
|
+
inputSchema: Ne.shape
|
|
504
509
|
},
|
|
505
510
|
async (s) => {
|
|
506
|
-
const o =
|
|
511
|
+
const o = Ft(s);
|
|
507
512
|
return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
|
|
508
513
|
❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
|
|
509
514
|
${JSON.stringify(o, null, 2)}`;
|
|
510
515
|
}
|
|
511
516
|
);
|
|
512
517
|
}
|
|
513
|
-
function
|
|
514
|
-
|
|
518
|
+
function Rt(t, r) {
|
|
519
|
+
Tt(), r.run && Dt(t, r), r.status && Ct(t, r), r.wait && kt(t, r), r.list && Bt(t, r), r.kill && Ot(t);
|
|
515
520
|
const s = r.commandLineRules?.map(
|
|
516
521
|
(o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
|
|
517
522
|
) || [];
|
|
@@ -524,16 +529,16 @@ ${s.map((o) => `- ${o}`).join(`
|
|
|
524
529
|
`
|
|
525
530
|
);
|
|
526
531
|
}
|
|
527
|
-
function
|
|
532
|
+
function zt(t, r) {
|
|
528
533
|
return function(o, e, n) {
|
|
529
534
|
const i = async (...a) => {
|
|
530
|
-
await
|
|
535
|
+
await q({
|
|
531
536
|
logFilePath: r.logFilePath,
|
|
532
537
|
message: "REQUEST",
|
|
533
538
|
data: { name: o, args: a }
|
|
534
539
|
});
|
|
535
540
|
const u = await n(...a);
|
|
536
|
-
return await
|
|
541
|
+
return await q({
|
|
537
542
|
logFilePath: r.logFilePath,
|
|
538
543
|
message: "RESPONSE",
|
|
539
544
|
data: u
|
|
@@ -553,26 +558,26 @@ function Rt(t, r) {
|
|
|
553
558
|
);
|
|
554
559
|
};
|
|
555
560
|
}
|
|
556
|
-
function
|
|
561
|
+
function Pt(t) {
|
|
557
562
|
return t.match(/^[/\\]?[^/\\]+/)[0];
|
|
558
563
|
}
|
|
559
|
-
function
|
|
560
|
-
return
|
|
564
|
+
function Lt(t, r) {
|
|
565
|
+
return Pt(t) + "|" + r.ino;
|
|
561
566
|
}
|
|
562
|
-
function
|
|
567
|
+
function Ut(t) {
|
|
563
568
|
return t.endsWith(":") && (t += "/"), T.resolve(t);
|
|
564
569
|
}
|
|
565
|
-
const
|
|
566
|
-
function
|
|
570
|
+
const De = new ct(ft.cpus().length);
|
|
571
|
+
function le(t, r) {
|
|
567
572
|
t.totalSize += r.totalSize, t.maxFileDateModified = Math.max(
|
|
568
573
|
t.maxFileDateModified,
|
|
569
574
|
r.maxFileDateModified
|
|
570
575
|
), t.countFiles += r.countFiles, t.countDirs += r.countDirs, t.countLinks += r.countLinks;
|
|
571
576
|
}
|
|
572
|
-
const
|
|
577
|
+
const At = function(r) {
|
|
573
578
|
return r.code === "ENOENT";
|
|
574
579
|
};
|
|
575
|
-
function
|
|
580
|
+
function Ee(t) {
|
|
576
581
|
const r = t.paths;
|
|
577
582
|
if (!r || r.length === 0)
|
|
578
583
|
return Promise.resolve({
|
|
@@ -582,16 +587,16 @@ function Ne(t) {
|
|
|
582
587
|
countDirs: 0,
|
|
583
588
|
countLinks: 0
|
|
584
589
|
});
|
|
585
|
-
const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ??
|
|
590
|
+
const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? De, i = t.handleError, a = t.priority ?? P(0), u = t.walkLinks ?? !1, l = t.log, c = t.handlePath, f = t.matchPath;
|
|
586
591
|
async function d(h) {
|
|
587
|
-
if (!(i && await i(h)) && !
|
|
592
|
+
if (!(i && await i(h)) && !At(h))
|
|
588
593
|
throw h;
|
|
589
594
|
}
|
|
590
595
|
function m(h) {
|
|
591
596
|
return !(!l || l.minTotalContentSize != null && h < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
|
|
592
597
|
}
|
|
593
|
-
return
|
|
594
|
-
const g =
|
|
598
|
+
return ut(async (h) => {
|
|
599
|
+
const g = dt(e, h), b = {
|
|
595
600
|
totalSize: 0,
|
|
596
601
|
maxFileDateModified: 0,
|
|
597
602
|
countFiles: 0,
|
|
@@ -604,8 +609,8 @@ function Ne(t) {
|
|
|
604
609
|
l?.handleLog ? l.handleLog(v) : console.log(v);
|
|
605
610
|
}
|
|
606
611
|
}
|
|
607
|
-
async function
|
|
608
|
-
return c ? await
|
|
612
|
+
async function x(w, M, $, v) {
|
|
613
|
+
return c ? await L({
|
|
609
614
|
pool: n,
|
|
610
615
|
func: async () => {
|
|
611
616
|
try {
|
|
@@ -613,12 +618,12 @@ function Ne(t) {
|
|
|
613
618
|
level: s,
|
|
614
619
|
path: w,
|
|
615
620
|
stat: M,
|
|
616
|
-
itemStat:
|
|
621
|
+
itemStat: $,
|
|
617
622
|
totalStat: b,
|
|
618
623
|
abortSignal: g
|
|
619
624
|
});
|
|
620
|
-
} catch (
|
|
621
|
-
return await d(
|
|
625
|
+
} catch (D) {
|
|
626
|
+
return await d(D), !1;
|
|
622
627
|
}
|
|
623
628
|
},
|
|
624
629
|
count: 1,
|
|
@@ -626,97 +631,97 @@ function Ne(t) {
|
|
|
626
631
|
abortSignal: g
|
|
627
632
|
}) : !0;
|
|
628
633
|
}
|
|
629
|
-
async function I(w, M,
|
|
634
|
+
async function I(w, M, $, v) {
|
|
630
635
|
v || (v = w);
|
|
631
|
-
const
|
|
636
|
+
const D = await L({
|
|
632
637
|
pool: n,
|
|
633
|
-
func: () =>
|
|
638
|
+
func: () => F.promises.lstat(w).catch(d),
|
|
634
639
|
count: 1,
|
|
635
|
-
priority:
|
|
640
|
+
priority: P(M, P(1, a)),
|
|
636
641
|
abortSignal: g
|
|
637
642
|
});
|
|
638
|
-
if (!
|
|
643
|
+
if (!D || !$ && D.isFile())
|
|
639
644
|
return null;
|
|
640
|
-
const
|
|
641
|
-
if (o.has(
|
|
645
|
+
const ne = Lt(w, D);
|
|
646
|
+
if (o.has(ne))
|
|
642
647
|
return null;
|
|
643
|
-
o.add(
|
|
644
|
-
let
|
|
645
|
-
totalSize:
|
|
646
|
-
maxFileDateModified:
|
|
648
|
+
o.add(ne);
|
|
649
|
+
let N = {
|
|
650
|
+
totalSize: D.size,
|
|
651
|
+
maxFileDateModified: D.isDirectory() ? 0 : D.mtimeMs,
|
|
647
652
|
countFiles: 0,
|
|
648
653
|
countDirs: 0,
|
|
649
654
|
countLinks: 0
|
|
650
655
|
};
|
|
651
|
-
const
|
|
656
|
+
const U = P(
|
|
652
657
|
M,
|
|
653
|
-
|
|
658
|
+
P(D.isDirectory() ? 2 : 3, a)
|
|
654
659
|
);
|
|
655
|
-
if (
|
|
660
|
+
if (D.isSymbolicLink()) {
|
|
656
661
|
if (u) {
|
|
657
|
-
const
|
|
662
|
+
const B = await L({
|
|
658
663
|
pool: n,
|
|
659
|
-
func: () =>
|
|
664
|
+
func: () => F.promises.readlink(w).catch(d).then((R) => R ?? null),
|
|
660
665
|
count: 1,
|
|
661
|
-
priority:
|
|
666
|
+
priority: U,
|
|
662
667
|
abortSignal: g
|
|
663
668
|
});
|
|
664
|
-
if (
|
|
665
|
-
const
|
|
666
|
-
|
|
669
|
+
if (B) {
|
|
670
|
+
const R = T.isAbsolute(B) ? B : T.resolve(T.dirname(v), B), A = await I(
|
|
671
|
+
R,
|
|
667
672
|
M,
|
|
668
|
-
|
|
673
|
+
$,
|
|
669
674
|
v
|
|
670
675
|
);
|
|
671
|
-
|
|
676
|
+
A && (N = A);
|
|
672
677
|
}
|
|
673
678
|
}
|
|
674
|
-
return (
|
|
679
|
+
return ($ || N.countFiles + N.countDirs + N.countLinks > 1) && (N.countLinks += 1, await x(
|
|
675
680
|
v,
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
) && (
|
|
680
|
-
} else if (
|
|
681
|
-
const
|
|
681
|
+
D,
|
|
682
|
+
N,
|
|
683
|
+
U
|
|
684
|
+
) && (le(b, N), y(v, N))), N;
|
|
685
|
+
} else if (D.isDirectory()) {
|
|
686
|
+
const B = await L({
|
|
682
687
|
pool: n,
|
|
683
|
-
func: () =>
|
|
688
|
+
func: () => F.promises.readdir(w).catch(d),
|
|
684
689
|
count: 1,
|
|
685
690
|
priority: a,
|
|
686
691
|
abortSignal: g
|
|
687
692
|
});
|
|
688
|
-
if (
|
|
689
|
-
for (let
|
|
690
|
-
|
|
691
|
-
|
|
693
|
+
if (B) {
|
|
694
|
+
for (let R = 0, A = B.length; R < A; R++)
|
|
695
|
+
B[R] = T.join(v, B[R]);
|
|
696
|
+
N = await Ee({
|
|
692
697
|
...t,
|
|
693
|
-
paths:
|
|
698
|
+
paths: B,
|
|
694
699
|
abortSignal: g,
|
|
695
|
-
priority:
|
|
700
|
+
priority: U,
|
|
696
701
|
level: s + 1,
|
|
697
702
|
walkedIds: o
|
|
698
703
|
});
|
|
699
704
|
}
|
|
700
705
|
}
|
|
701
|
-
return (
|
|
706
|
+
return ($ || N.countFiles + N.countDirs + N.countLinks > 1) && (D.isDirectory() ? N.countDirs += 1 : D.isFile() && (N.countFiles += 1), await x(
|
|
702
707
|
v,
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
) && (
|
|
708
|
+
D,
|
|
709
|
+
N,
|
|
710
|
+
U
|
|
711
|
+
) && (le(b, N), y(v, N))), N;
|
|
707
712
|
}
|
|
708
|
-
const
|
|
713
|
+
const S = [];
|
|
709
714
|
for (let w = 0, M = r.length; w < M; w++) {
|
|
710
|
-
const
|
|
711
|
-
v !== !1 &&
|
|
715
|
+
const $ = Ut(r[w]), v = f ? f($) : !0;
|
|
716
|
+
v !== !1 && S.push(I($, w, v));
|
|
712
717
|
}
|
|
713
|
-
return await Promise.all(
|
|
718
|
+
return await Promise.all(S), b;
|
|
714
719
|
});
|
|
715
720
|
}
|
|
716
|
-
function
|
|
717
|
-
return
|
|
721
|
+
function Be(t) {
|
|
722
|
+
return Ee(t);
|
|
718
723
|
}
|
|
719
|
-
function
|
|
724
|
+
function Gt(t, r) {
|
|
720
725
|
if (!r || r === ".")
|
|
721
726
|
return t;
|
|
722
727
|
const s = t.startsWith("^");
|
|
@@ -724,43 +729,43 @@ function At(t, r) {
|
|
|
724
729
|
const o = t.startsWith("!");
|
|
725
730
|
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;
|
|
726
731
|
}
|
|
727
|
-
function
|
|
732
|
+
function qt(t) {
|
|
728
733
|
const r = t.startsWith("!");
|
|
729
734
|
return r && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), r && (t = "!" + t), t;
|
|
730
735
|
}
|
|
731
|
-
function
|
|
736
|
+
function ce(t) {
|
|
732
737
|
return "^" + t;
|
|
733
738
|
}
|
|
734
|
-
async function
|
|
735
|
-
const s = (await
|
|
739
|
+
async function _t(t) {
|
|
740
|
+
const s = (await F.promises.readFile(t, "utf-8")).split(`
|
|
736
741
|
`), o = [];
|
|
737
742
|
return s.forEach((e) => {
|
|
738
743
|
e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
|
|
739
744
|
}), o;
|
|
740
745
|
}
|
|
741
|
-
async function
|
|
746
|
+
async function Fe(t) {
|
|
742
747
|
const r = t.rootDir ?? ".", s = [];
|
|
743
748
|
if (!t.globs?.length)
|
|
744
749
|
return s;
|
|
745
750
|
const o = [];
|
|
746
751
|
return t.globs.forEach((e) => {
|
|
747
|
-
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ?
|
|
752
|
+
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? ce(e.value) : e.value));
|
|
748
753
|
}), o.length && await Promise.all(
|
|
749
754
|
o.map(async (e) => {
|
|
750
|
-
await
|
|
751
|
-
pool:
|
|
755
|
+
await L({
|
|
756
|
+
pool: De,
|
|
752
757
|
count: 1,
|
|
753
758
|
func: async () => {
|
|
754
|
-
const n = T.resolve(r, e.value), i = await
|
|
759
|
+
const n = T.resolve(r, e.value), i = await _t(n), a = T.relative(r, T.dirname(n));
|
|
755
760
|
i.forEach((u) => {
|
|
756
|
-
u =
|
|
761
|
+
u = qt(u), u = Gt(u, a), s.push(e.exclude ? ce(u) : u);
|
|
757
762
|
});
|
|
758
763
|
}
|
|
759
764
|
});
|
|
760
765
|
})
|
|
761
766
|
), s;
|
|
762
767
|
}
|
|
763
|
-
function
|
|
768
|
+
function Oe({
|
|
764
769
|
globs: t,
|
|
765
770
|
rootDir: r,
|
|
766
771
|
noCase: s
|
|
@@ -781,7 +786,7 @@ function Fe({
|
|
|
781
786
|
return;
|
|
782
787
|
let u;
|
|
783
788
|
try {
|
|
784
|
-
u =
|
|
789
|
+
u = mt(a, {
|
|
785
790
|
nocase: s ?? !1,
|
|
786
791
|
dot: !0,
|
|
787
792
|
strictBrackets: !0
|
|
@@ -808,17 +813,17 @@ function Fe({
|
|
|
808
813
|
return a ? !1 : i;
|
|
809
814
|
};
|
|
810
815
|
}
|
|
811
|
-
async function
|
|
816
|
+
async function jt(t) {
|
|
812
817
|
const r = t.rootDir ?? ".", s = [], o = {};
|
|
813
818
|
t.result.countFiles && (o.countFiles = 0), t.result.size && (o.size = 0);
|
|
814
|
-
const e = await
|
|
819
|
+
const e = await Fe({
|
|
815
820
|
rootDir: r,
|
|
816
821
|
globs: t.globs
|
|
817
822
|
});
|
|
818
|
-
return await
|
|
823
|
+
return await Be({
|
|
819
824
|
paths: [r],
|
|
820
825
|
walkLinks: !0,
|
|
821
|
-
matchPath:
|
|
826
|
+
matchPath: Oe({
|
|
822
827
|
globs: e,
|
|
823
828
|
rootDir: r,
|
|
824
829
|
noCase: !0
|
|
@@ -832,34 +837,34 @@ async function _t(t) {
|
|
|
832
837
|
type: d
|
|
833
838
|
};
|
|
834
839
|
if (t.result.dateModified && (b.dateModified = m), t.result.size && (b.size = h), t.result.countFiles && (b.countFiles = g), t.dateModified && m != null) {
|
|
835
|
-
const [y,
|
|
836
|
-
if (y != null && m < y ||
|
|
840
|
+
const [y, x] = t.dateModified;
|
|
841
|
+
if (y != null && m < y || x != null && m > x)
|
|
837
842
|
return !1;
|
|
838
843
|
}
|
|
839
844
|
if (t.totalSize && h != null) {
|
|
840
|
-
const [y,
|
|
841
|
-
if (y != null && h < y ||
|
|
845
|
+
const [y, x] = t.totalSize;
|
|
846
|
+
if (y != null && h < y || x != null && h > x)
|
|
842
847
|
return !1;
|
|
843
848
|
}
|
|
844
849
|
return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && h != null && (o.size = (o.size ?? 0) + h), m != null && (o.dateModified == null || m > o.dateModified) && (o.dateModified = m), l && !t.result.dirs || c && !t.result.files || s.push(b), !0;
|
|
845
850
|
}
|
|
846
851
|
}), { items: s, totals: o };
|
|
847
852
|
}
|
|
848
|
-
const
|
|
849
|
-
function
|
|
853
|
+
const ue = ["B", "KB", "MB", "GB", "TB"], de = 1024;
|
|
854
|
+
function fe(t) {
|
|
850
855
|
if (t == null) return "-";
|
|
851
856
|
let r = t ?? 0, s = 0;
|
|
852
|
-
for (; r >=
|
|
853
|
-
r /=
|
|
854
|
-
return `${s === 0 ? r.toString() : r.toFixed(2)}${
|
|
857
|
+
for (; r >= de && s < ue.length - 1; )
|
|
858
|
+
r /= de, s++;
|
|
859
|
+
return `${s === 0 ? r.toString() : r.toFixed(2)}${ue[s]}`;
|
|
855
860
|
}
|
|
856
|
-
function
|
|
861
|
+
function me(t) {
|
|
857
862
|
const s = Date.now() - t;
|
|
858
863
|
if (s < 0) return "0s";
|
|
859
864
|
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), i = Math.floor(n / 24), a = Math.floor(i / 7), u = Math.floor(i / 30), l = Math.floor(i / 365);
|
|
860
865
|
return l > 0 ? `${l}Y` : u > 0 ? `${u}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
|
|
861
866
|
}
|
|
862
|
-
function
|
|
867
|
+
function Jt(t, r) {
|
|
863
868
|
return r?.length ? [...t].sort((s, o) => {
|
|
864
869
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
865
870
|
const i = r[e];
|
|
@@ -895,8 +900,8 @@ function jt(t, r) {
|
|
|
895
900
|
return 0;
|
|
896
901
|
}) : t;
|
|
897
902
|
}
|
|
898
|
-
function
|
|
899
|
-
const s =
|
|
903
|
+
function Kt(t, r) {
|
|
904
|
+
const s = Jt(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
|
|
900
905
|
let e = "";
|
|
901
906
|
if (s.length > 0 && o.length > 0) {
|
|
902
907
|
for (let n = 0, i = o.length; n < i; n++) {
|
|
@@ -927,10 +932,10 @@ function Jt(t, r) {
|
|
|
927
932
|
const c = o[u];
|
|
928
933
|
switch (u > 0 && (e += " | "), c) {
|
|
929
934
|
case "dateModified":
|
|
930
|
-
e += a.dateModified ?
|
|
935
|
+
e += a.dateModified ? me(a.dateModified) : "-";
|
|
931
936
|
break;
|
|
932
937
|
case "size":
|
|
933
|
-
e +=
|
|
938
|
+
e += fe(a.size);
|
|
934
939
|
break;
|
|
935
940
|
case "type":
|
|
936
941
|
e += a.type;
|
|
@@ -949,13 +954,13 @@ function Jt(t, r) {
|
|
|
949
954
|
e.length > 0 && (e += `
|
|
950
955
|
---
|
|
951
956
|
`);
|
|
952
|
-
const n =
|
|
957
|
+
const n = fe(t.totals.size ?? 0), i = t.totals.dateModified ? `, last modified ${me(t.totals.dateModified)} ago` : "";
|
|
953
958
|
e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
|
|
954
959
|
}
|
|
955
960
|
return e;
|
|
956
961
|
}
|
|
957
|
-
const
|
|
958
|
-
function
|
|
962
|
+
const is = "project-tools", as = "1.0.0", ls = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", he = 25e3;
|
|
963
|
+
function pe(t) {
|
|
959
964
|
const r = t.match(
|
|
960
965
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
961
966
|
);
|
|
@@ -986,7 +991,7 @@ function he(t) {
|
|
|
986
991
|
);
|
|
987
992
|
}
|
|
988
993
|
}
|
|
989
|
-
function
|
|
994
|
+
function ge(t) {
|
|
990
995
|
const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
991
996
|
if (!r)
|
|
992
997
|
throw new Error(
|
|
@@ -1010,7 +1015,7 @@ function pe(t) {
|
|
|
1010
1015
|
);
|
|
1011
1016
|
}
|
|
1012
1017
|
}
|
|
1013
|
-
const
|
|
1018
|
+
const Re = p.object({
|
|
1014
1019
|
rootDir: p.string().optional().describe(
|
|
1015
1020
|
'Root directory to list files from, resolved relative to the current working directory. Leave empty to use current directory. Examples: "src" (list src/ subdirectory), "../parent" (list parent directory), "docs/api" (list nested subdirectory). Path must exist and be accessible'
|
|
1016
1021
|
),
|
|
@@ -1049,13 +1054,13 @@ const Oe = p.object({
|
|
|
1049
1054
|
'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'
|
|
1050
1055
|
)
|
|
1051
1056
|
});
|
|
1052
|
-
async function
|
|
1057
|
+
async function Wt(t, r) {
|
|
1053
1058
|
let s;
|
|
1054
1059
|
try {
|
|
1055
|
-
s =
|
|
1060
|
+
s = Re.parse(t);
|
|
1056
1061
|
} catch (g) {
|
|
1057
1062
|
return {
|
|
1058
|
-
error:
|
|
1063
|
+
error: C(g)
|
|
1059
1064
|
};
|
|
1060
1065
|
}
|
|
1061
1066
|
const {
|
|
@@ -1088,55 +1093,55 @@ async function Kt(t, r) {
|
|
|
1088
1093
|
);
|
|
1089
1094
|
try {
|
|
1090
1095
|
try {
|
|
1091
|
-
await
|
|
1092
|
-
} catch (
|
|
1093
|
-
if (
|
|
1096
|
+
await F.promises.access(h, F.constants.F_OK);
|
|
1097
|
+
} catch ($) {
|
|
1098
|
+
if ($.code === "ENOENT")
|
|
1094
1099
|
return {
|
|
1095
1100
|
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-list without rootDir to list the current directory, or check parent directories first.`
|
|
1096
1101
|
};
|
|
1097
|
-
throw
|
|
1102
|
+
throw $;
|
|
1098
1103
|
}
|
|
1099
|
-
const g = o && o.length > 0 ? o.map((
|
|
1100
|
-
value:
|
|
1104
|
+
const g = o && o.length > 0 ? o.map(($) => ({
|
|
1105
|
+
value: $,
|
|
1101
1106
|
valueType: "pattern",
|
|
1102
1107
|
exclude: !1
|
|
1103
|
-
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], b = r.globsExclude || [], y = [...g, ...b],
|
|
1108
|
+
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], b = r.globsExclude || [], y = [...g, ...b], x = {
|
|
1104
1109
|
files: e ?? !1,
|
|
1105
1110
|
dirs: n ?? !1,
|
|
1106
1111
|
dateModified: f.includes("dateModified") || m.includes("dateModified"),
|
|
1107
1112
|
size: f.includes("size") || m.includes("size"),
|
|
1108
1113
|
countFiles: f.includes("countFiles") || m.includes("countFiles")
|
|
1109
1114
|
};
|
|
1110
|
-
let I = null,
|
|
1115
|
+
let I = null, S = null;
|
|
1111
1116
|
if (a || u)
|
|
1112
1117
|
try {
|
|
1113
|
-
const
|
|
1114
|
-
I = [v,
|
|
1115
|
-
} catch (
|
|
1118
|
+
const $ = Date.now(), v = u ? $ - pe(u) : null, D = a ? $ - pe(a) : null;
|
|
1119
|
+
I = [v, D];
|
|
1120
|
+
} catch ($) {
|
|
1116
1121
|
return {
|
|
1117
|
-
error:
|
|
1122
|
+
error: $ instanceof Error ? $.message : "Unknown error parsing time ago filter"
|
|
1118
1123
|
};
|
|
1119
1124
|
}
|
|
1120
1125
|
if (l || c)
|
|
1121
1126
|
try {
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1124
|
-
} catch (
|
|
1127
|
+
const $ = l ? ge(l) : null, v = c ? ge(c) : null;
|
|
1128
|
+
S = [$, v];
|
|
1129
|
+
} catch ($) {
|
|
1125
1130
|
return {
|
|
1126
|
-
error:
|
|
1131
|
+
error: $ instanceof Error ? $.message : "Unknown error parsing size filter"
|
|
1127
1132
|
};
|
|
1128
1133
|
}
|
|
1129
|
-
const w = await
|
|
1134
|
+
const w = await jt({
|
|
1130
1135
|
rootDir: h || null,
|
|
1131
1136
|
globs: y,
|
|
1132
|
-
result:
|
|
1137
|
+
result: x,
|
|
1133
1138
|
dateModified: I,
|
|
1134
|
-
totalSize:
|
|
1139
|
+
totalSize: S
|
|
1135
1140
|
});
|
|
1136
|
-
return w.items.length >
|
|
1137
|
-
error: `Number of paths (${w.items.length}) exceeds maximum allowed (${
|
|
1141
|
+
return w.items.length > he ? {
|
|
1142
|
+
error: `Number of paths (${w.items.length}) exceeds maximum allowed (${he}). Consider using more specific glob patterns or filters to reduce the result set.`
|
|
1138
1143
|
} : {
|
|
1139
|
-
output:
|
|
1144
|
+
output: Kt(w, {
|
|
1140
1145
|
sort: d,
|
|
1141
1146
|
fields: f,
|
|
1142
1147
|
totals: !0
|
|
@@ -1146,30 +1151,30 @@ async function Kt(t, r) {
|
|
|
1146
1151
|
return { error: g instanceof Error ? g.message : "Unknown error" };
|
|
1147
1152
|
}
|
|
1148
1153
|
}
|
|
1149
|
-
function
|
|
1154
|
+
function Qt(t, r) {
|
|
1150
1155
|
t(
|
|
1151
1156
|
"fs-list",
|
|
1152
1157
|
{
|
|
1153
1158
|
title: "List Files and Directories",
|
|
1154
1159
|
description: "List files and directories with advanced filtering, sorting and formatting options. Use this to analyze filesystem structure",
|
|
1155
|
-
inputSchema:
|
|
1160
|
+
inputSchema: Re.shape
|
|
1156
1161
|
},
|
|
1157
1162
|
async (s) => {
|
|
1158
|
-
const o = await
|
|
1163
|
+
const o = await Wt(s, r);
|
|
1159
1164
|
return o.error ? `Method: fs-list(${JSON.stringify(s)})
|
|
1160
1165
|
❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
|
|
1161
1166
|
${o.output || JSON.stringify(o, null, 2)}`;
|
|
1162
1167
|
}
|
|
1163
1168
|
);
|
|
1164
1169
|
}
|
|
1165
|
-
const
|
|
1166
|
-
function
|
|
1167
|
-
return
|
|
1170
|
+
const j = /* @__PURE__ */ new Map();
|
|
1171
|
+
function V(t) {
|
|
1172
|
+
return j.has(t) || j.set(t, {
|
|
1168
1173
|
fsSnapshotQueries: /* @__PURE__ */ new Map(),
|
|
1169
1174
|
fsSnapshots: /* @__PURE__ */ new Map()
|
|
1170
|
-
}),
|
|
1175
|
+
}), j.get(t);
|
|
1171
1176
|
}
|
|
1172
|
-
function
|
|
1177
|
+
function we(t) {
|
|
1173
1178
|
const r = t.match(
|
|
1174
1179
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
1175
1180
|
);
|
|
@@ -1200,7 +1205,7 @@ function ge(t) {
|
|
|
1200
1205
|
);
|
|
1201
1206
|
}
|
|
1202
1207
|
}
|
|
1203
|
-
function
|
|
1208
|
+
function ye(t) {
|
|
1204
1209
|
const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
1205
1210
|
if (!r)
|
|
1206
1211
|
throw new Error(
|
|
@@ -1224,7 +1229,7 @@ function we(t) {
|
|
|
1224
1229
|
);
|
|
1225
1230
|
}
|
|
1226
1231
|
}
|
|
1227
|
-
const
|
|
1232
|
+
const Z = p.object({
|
|
1228
1233
|
name: p.string().describe(
|
|
1229
1234
|
"Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1230
1235
|
),
|
|
@@ -1255,7 +1260,7 @@ const V = p.object({
|
|
|
1255
1260
|
maxTotalSize: p.string().optional().describe(
|
|
1256
1261
|
'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'
|
|
1257
1262
|
)
|
|
1258
|
-
}),
|
|
1263
|
+
}), be = new Map(
|
|
1259
1264
|
[
|
|
1260
1265
|
"name",
|
|
1261
1266
|
"type",
|
|
@@ -1264,17 +1269,17 @@ const V = p.object({
|
|
|
1264
1269
|
"dateModified"
|
|
1265
1270
|
].map((t, r) => [t, r])
|
|
1266
1271
|
);
|
|
1267
|
-
function
|
|
1268
|
-
const s =
|
|
1272
|
+
function Ht(t, r) {
|
|
1273
|
+
const s = be.get(t) ?? 1 / 0, o = be.get(r) ?? 1 / 0;
|
|
1269
1274
|
return s > o ? 1 : s < o ? -1 : 0;
|
|
1270
1275
|
}
|
|
1271
|
-
async function
|
|
1276
|
+
async function ze(t, r, s) {
|
|
1272
1277
|
let o;
|
|
1273
1278
|
try {
|
|
1274
|
-
o =
|
|
1279
|
+
o = Z.parse(t);
|
|
1275
1280
|
} catch (h) {
|
|
1276
1281
|
return {
|
|
1277
|
-
error:
|
|
1282
|
+
error: C(h)
|
|
1278
1283
|
};
|
|
1279
1284
|
}
|
|
1280
1285
|
const {
|
|
@@ -1291,7 +1296,7 @@ async function Re(t, r, s) {
|
|
|
1291
1296
|
return {
|
|
1292
1297
|
error: "Session ID is required"
|
|
1293
1298
|
};
|
|
1294
|
-
const d =
|
|
1299
|
+
const d = V(s.sessionId);
|
|
1295
1300
|
if (d.fsSnapshotQueries.has(e))
|
|
1296
1301
|
return {
|
|
1297
1302
|
error: `Filesystem snapshot query "${e}" already exists`
|
|
@@ -1299,7 +1304,7 @@ async function Re(t, r, s) {
|
|
|
1299
1304
|
const m = T.resolve(r.workingDir || "", o.rootDir || "").replace(/\\/g, "/");
|
|
1300
1305
|
try {
|
|
1301
1306
|
try {
|
|
1302
|
-
await
|
|
1307
|
+
await F.promises.access(m, F.constants.F_OK);
|
|
1303
1308
|
} catch (w) {
|
|
1304
1309
|
if (w.code === "ENOENT")
|
|
1305
1310
|
return {
|
|
@@ -1308,17 +1313,17 @@ async function Re(t, r, s) {
|
|
|
1308
1313
|
throw w;
|
|
1309
1314
|
}
|
|
1310
1315
|
const h = o.extraFields ? o.extraFields.map((w) => w === "lastModified" ? "dateModified" : w) : [];
|
|
1311
|
-
h.includes("name") || h.push("name"), h.sort(
|
|
1316
|
+
h.includes("name") || h.push("name"), h.sort(Ht);
|
|
1312
1317
|
const g = n && n.length > 0 ? n.map((w) => ({
|
|
1313
1318
|
value: w,
|
|
1314
1319
|
valueType: "pattern",
|
|
1315
1320
|
exclude: !1
|
|
1316
1321
|
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], b = r.globsExclude || [], y = [...g, ...b];
|
|
1317
|
-
let
|
|
1322
|
+
let x = null, I = null;
|
|
1318
1323
|
if (u || l)
|
|
1319
1324
|
try {
|
|
1320
|
-
const w = Date.now(), M = l ? w -
|
|
1321
|
-
|
|
1325
|
+
const w = Date.now(), M = l ? w - we(l) : null, $ = u ? w - we(u) : null;
|
|
1326
|
+
x = [M, $];
|
|
1322
1327
|
} catch (w) {
|
|
1323
1328
|
return {
|
|
1324
1329
|
error: w instanceof Error ? w.message : "Unknown error parsing time ago filter"
|
|
@@ -1326,25 +1331,25 @@ async function Re(t, r, s) {
|
|
|
1326
1331
|
}
|
|
1327
1332
|
if (c || f)
|
|
1328
1333
|
try {
|
|
1329
|
-
const w = c ?
|
|
1334
|
+
const w = c ? ye(c) : null, M = f ? ye(f) : null;
|
|
1330
1335
|
I = [w, M];
|
|
1331
1336
|
} catch (w) {
|
|
1332
1337
|
return {
|
|
1333
1338
|
error: w instanceof Error ? w.message : "Unknown error parsing size filter"
|
|
1334
1339
|
};
|
|
1335
1340
|
}
|
|
1336
|
-
const
|
|
1341
|
+
const S = {
|
|
1337
1342
|
name: e,
|
|
1338
1343
|
rootDir: m,
|
|
1339
1344
|
globs: y,
|
|
1340
1345
|
matchFiles: i ?? null,
|
|
1341
1346
|
matchDirs: a ?? null,
|
|
1342
|
-
dateModified:
|
|
1347
|
+
dateModified: x,
|
|
1343
1348
|
totalSize: I,
|
|
1344
1349
|
fields: h
|
|
1345
1350
|
};
|
|
1346
|
-
return d.fsSnapshotQueries.set(e,
|
|
1347
|
-
snapshotQuery:
|
|
1351
|
+
return d.fsSnapshotQueries.set(e, S), {
|
|
1352
|
+
snapshotQuery: S
|
|
1348
1353
|
};
|
|
1349
1354
|
} catch (h) {
|
|
1350
1355
|
return {
|
|
@@ -1352,23 +1357,23 @@ async function Re(t, r, s) {
|
|
|
1352
1357
|
};
|
|
1353
1358
|
}
|
|
1354
1359
|
}
|
|
1355
|
-
function
|
|
1360
|
+
function Yt(t, r) {
|
|
1356
1361
|
t(
|
|
1357
1362
|
"fs-snapshot-query-create",
|
|
1358
1363
|
{
|
|
1359
1364
|
title: "Create Filesystem Snapshot Query",
|
|
1360
1365
|
description: "Create a filesystem snapshot query. Prefer fs-snapshot-browse if you need to immediately create a query, snapshot and browse it",
|
|
1361
|
-
inputSchema:
|
|
1366
|
+
inputSchema: Z.shape
|
|
1362
1367
|
},
|
|
1363
1368
|
async (s, o) => {
|
|
1364
|
-
const e = await
|
|
1369
|
+
const e = await ze(s, r, o);
|
|
1365
1370
|
return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1366
1371
|
❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1367
1372
|
✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
1368
1373
|
}
|
|
1369
1374
|
);
|
|
1370
1375
|
}
|
|
1371
|
-
function
|
|
1376
|
+
function _(t) {
|
|
1372
1377
|
const { idToNode: r, idToChildIds: s } = t, o = r.get(null);
|
|
1373
1378
|
if (o == null)
|
|
1374
1379
|
throw new Error(
|
|
@@ -1408,16 +1413,16 @@ function q(t) {
|
|
|
1408
1413
|
}
|
|
1409
1414
|
};
|
|
1410
1415
|
}
|
|
1411
|
-
function
|
|
1416
|
+
function Pe(t, r, s) {
|
|
1412
1417
|
let o = null;
|
|
1413
1418
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
1414
|
-
const i = r[e], a = t(i), u = a == null ? null :
|
|
1419
|
+
const i = r[e], a = t(i), u = a == null ? null : Pe(t, a, s), l = s(i, u);
|
|
1415
1420
|
l != null && (o == null && (o = []), o.push(l));
|
|
1416
1421
|
}
|
|
1417
1422
|
return o;
|
|
1418
1423
|
}
|
|
1419
|
-
function
|
|
1420
|
-
const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u =
|
|
1424
|
+
function Le(t) {
|
|
1425
|
+
const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = Pe(
|
|
1421
1426
|
s,
|
|
1422
1427
|
o,
|
|
1423
1428
|
(c, f) => {
|
|
@@ -1442,10 +1447,10 @@ function Ue(t) {
|
|
|
1442
1447
|
idToChildIds: a
|
|
1443
1448
|
};
|
|
1444
1449
|
}
|
|
1445
|
-
function
|
|
1450
|
+
function W(t) {
|
|
1446
1451
|
return t = t?.replace(/\\/g, "/").replace(/\/$/, ""), !t || t === "." ? null : t;
|
|
1447
1452
|
}
|
|
1448
|
-
async function
|
|
1453
|
+
async function Vt(t) {
|
|
1449
1454
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = T.resolve(t.rootDir || "."), n = {
|
|
1450
1455
|
path: ".",
|
|
1451
1456
|
name: T.basename(o),
|
|
@@ -1455,14 +1460,14 @@ async function Yt(t) {
|
|
|
1455
1460
|
size: 0
|
|
1456
1461
|
};
|
|
1457
1462
|
r.set(null, n);
|
|
1458
|
-
const i = await
|
|
1463
|
+
const i = await Fe({
|
|
1459
1464
|
rootDir: o,
|
|
1460
1465
|
globs: t.globs
|
|
1461
1466
|
});
|
|
1462
|
-
return await
|
|
1467
|
+
return await Be({
|
|
1463
1468
|
paths: [o],
|
|
1464
1469
|
walkLinks: !0,
|
|
1465
|
-
matchPath:
|
|
1470
|
+
matchPath: Oe({
|
|
1466
1471
|
globs: i,
|
|
1467
1472
|
rootDir: o,
|
|
1468
1473
|
noCase: !0
|
|
@@ -1471,7 +1476,7 @@ async function Yt(t) {
|
|
|
1471
1476
|
const c = T.relative(o, a), f = u.isDirectory(), d = u.isFile();
|
|
1472
1477
|
if (!f && !d)
|
|
1473
1478
|
return !0;
|
|
1474
|
-
const m =
|
|
1479
|
+
const m = W(c || "."), h = f ? "dir" : "file", g = f ? null : u.mtimeMs, b = u.size;
|
|
1475
1480
|
let y = !0;
|
|
1476
1481
|
if (d && !t.matchFiles && (y = !1), f && !t.matchDirs && (y = !1), y && d && t.dateModified && g != null) {
|
|
1477
1482
|
const [w, M] = t.dateModified;
|
|
@@ -1485,7 +1490,7 @@ async function Yt(t) {
|
|
|
1485
1490
|
if (!(l.countFiles && l.countFiles > 0)) return !1;
|
|
1486
1491
|
} else if (!y)
|
|
1487
1492
|
return !1;
|
|
1488
|
-
const
|
|
1493
|
+
const x = {
|
|
1489
1494
|
path: m ?? ".",
|
|
1490
1495
|
name: T.basename(a),
|
|
1491
1496
|
type: h,
|
|
@@ -1495,17 +1500,17 @@ async function Yt(t) {
|
|
|
1495
1500
|
};
|
|
1496
1501
|
if (m == null)
|
|
1497
1502
|
return n.dateModified = g, n.size = b, n.isMatched = y, !0;
|
|
1498
|
-
r.set(m,
|
|
1499
|
-
const I =
|
|
1500
|
-
let
|
|
1501
|
-
return
|
|
1503
|
+
r.set(m, x);
|
|
1504
|
+
const I = W(T.dirname(m).replace(/\\/g, "/"));
|
|
1505
|
+
let S = s.get(I);
|
|
1506
|
+
return S || (S = [], s.set(I, S)), S.push(m), !0;
|
|
1502
1507
|
}
|
|
1503
1508
|
}), {
|
|
1504
1509
|
idToNode: r,
|
|
1505
1510
|
idToChildIds: s
|
|
1506
1511
|
};
|
|
1507
1512
|
}
|
|
1508
|
-
const
|
|
1513
|
+
const Zt = [
|
|
1509
1514
|
{ name: "[ ]", match: (t) => t === 32, min: 2, max: 81 },
|
|
1510
1515
|
{ name: "[\\t]", match: (t) => t === 9, min: 2, max: 20 },
|
|
1511
1516
|
{ name: "[\\n]", match: (t) => t === 10, min: 2, max: 14 },
|
|
@@ -1528,7 +1533,7 @@ const Vt = [
|
|
|
1528
1533
|
// max: 2,
|
|
1529
1534
|
// },
|
|
1530
1535
|
];
|
|
1531
|
-
function
|
|
1536
|
+
function xe(t, r = Zt) {
|
|
1532
1537
|
const s = t.length;
|
|
1533
1538
|
if (s === 0) return 0;
|
|
1534
1539
|
const o = r.length;
|
|
@@ -1554,25 +1559,25 @@ function be(t, r = Vt) {
|
|
|
1554
1559
|
}
|
|
1555
1560
|
return e;
|
|
1556
1561
|
}
|
|
1557
|
-
function
|
|
1562
|
+
function Ue(t) {
|
|
1558
1563
|
let r = 0;
|
|
1559
|
-
return r +=
|
|
1564
|
+
return r += xe(t.textOpen) + 1, t.textClose != null && (r += xe(t.textClose) + 1), t.indent && (r += 1), r;
|
|
1560
1565
|
}
|
|
1561
|
-
const
|
|
1562
|
-
function
|
|
1566
|
+
const Se = ["B", "KB", "MB", "GB", "TB"], $e = 1024;
|
|
1567
|
+
function Xt(t) {
|
|
1563
1568
|
if (t == null) return "-";
|
|
1564
1569
|
let r = t ?? 0, s = 0;
|
|
1565
|
-
for (; r >=
|
|
1566
|
-
r /=
|
|
1567
|
-
return `${s === 0 ? r.toString() : r.toFixed(2)}${
|
|
1570
|
+
for (; r >= $e && s < Se.length - 1; )
|
|
1571
|
+
r /= $e, s++;
|
|
1572
|
+
return `${s === 0 ? r.toString() : r.toFixed(2)}${Se[s]}`;
|
|
1568
1573
|
}
|
|
1569
|
-
function
|
|
1574
|
+
function er(t) {
|
|
1570
1575
|
const s = Date.now() - t;
|
|
1571
1576
|
if (s < 0) return "0s";
|
|
1572
1577
|
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), i = Math.floor(n / 24), a = Math.floor(i / 7), u = Math.floor(i / 30), l = Math.floor(i / 365);
|
|
1573
1578
|
return l > 0 ? `${l}Y` : u > 0 ? `${u}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
|
|
1574
1579
|
}
|
|
1575
|
-
function
|
|
1580
|
+
function tr(t) {
|
|
1576
1581
|
return function(s, o) {
|
|
1577
1582
|
const e = t.get(s), n = t.get(o);
|
|
1578
1583
|
if (e.type !== n.type)
|
|
@@ -1585,26 +1590,26 @@ function er(t) {
|
|
|
1585
1590
|
}
|
|
1586
1591
|
};
|
|
1587
1592
|
}
|
|
1588
|
-
function
|
|
1593
|
+
function rr(t) {
|
|
1589
1594
|
const r = t.fields ?? [];
|
|
1590
1595
|
return function(o, e) {
|
|
1591
1596
|
let n = "", i, a = 0;
|
|
1592
1597
|
const u = e ? e.length : 0;
|
|
1593
|
-
let l = 1, c, f = 0, d = 0, m = 0, h = 0, g = null, b, y,
|
|
1598
|
+
let l = 1, c, f = 0, d = 0, m = 0, h = 0, g = null, b, y, x;
|
|
1594
1599
|
if (e)
|
|
1595
|
-
for (let
|
|
1596
|
-
const w = e[
|
|
1600
|
+
for (let S = 0; S < e.length; S++) {
|
|
1601
|
+
const w = e[S];
|
|
1597
1602
|
a += w.countMatched, l += w.countTotal, f += w.tokens, d += w.tokensTotal, m += w.size, h += w.countFiles, w.dateModified != null && (g == null || w.dateModified > g) && (g = w.dateModified);
|
|
1598
1603
|
}
|
|
1599
|
-
o ? (b = o.type, y = o.name,
|
|
1600
|
-
for (let
|
|
1601
|
-
const M = r[
|
|
1602
|
-
switch (
|
|
1604
|
+
o ? (b = o.type, y = o.name, x = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (m = o.size || 0, h = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (b = "dir", y = "<root>", x = ".", i = !0);
|
|
1605
|
+
for (let S = 0, w = r.length; S < w; S++) {
|
|
1606
|
+
const M = r[S];
|
|
1607
|
+
switch (S > 0 && (n += " "), M) {
|
|
1603
1608
|
case "dateModified":
|
|
1604
|
-
n += g ?
|
|
1609
|
+
n += g ? er(g) : "-";
|
|
1605
1610
|
break;
|
|
1606
1611
|
case "size":
|
|
1607
|
-
n +=
|
|
1612
|
+
n += Xt(m);
|
|
1608
1613
|
break;
|
|
1609
1614
|
case "type":
|
|
1610
1615
|
n += b;
|
|
@@ -1622,10 +1627,10 @@ function tr(t) {
|
|
|
1622
1627
|
textOpen: n,
|
|
1623
1628
|
textClose: null
|
|
1624
1629
|
};
|
|
1625
|
-
return c =
|
|
1630
|
+
return c = Ue(I), d += c, {
|
|
1626
1631
|
type: b,
|
|
1627
1632
|
name: y,
|
|
1628
|
-
path:
|
|
1633
|
+
path: x,
|
|
1629
1634
|
isMatched: i,
|
|
1630
1635
|
countMatched: a,
|
|
1631
1636
|
countChilds: u,
|
|
@@ -1640,8 +1645,8 @@ function tr(t) {
|
|
|
1640
1645
|
};
|
|
1641
1646
|
};
|
|
1642
1647
|
}
|
|
1643
|
-
async function
|
|
1644
|
-
const r = await
|
|
1648
|
+
async function sr(t) {
|
|
1649
|
+
const r = await Vt(t), s = _(r), o = s.getChilds(s.root), e = Le({
|
|
1645
1650
|
getId: (i) => {
|
|
1646
1651
|
const a = s.getId(i);
|
|
1647
1652
|
if (a == null)
|
|
@@ -1651,29 +1656,29 @@ async function rr(t) {
|
|
|
1651
1656
|
return a;
|
|
1652
1657
|
},
|
|
1653
1658
|
getChilds: (i) => s.getChilds(i),
|
|
1654
|
-
createSnapshotNode:
|
|
1659
|
+
createSnapshotNode: rr(t),
|
|
1655
1660
|
rootNodes: o ?? []
|
|
1656
|
-
}), n =
|
|
1661
|
+
}), n = tr(e.idToNode);
|
|
1657
1662
|
return e.idToChildIds.forEach((i) => {
|
|
1658
1663
|
i.sort(n);
|
|
1659
|
-
}),
|
|
1664
|
+
}), _(e);
|
|
1660
1665
|
}
|
|
1661
|
-
const
|
|
1666
|
+
const X = p.object({
|
|
1662
1667
|
queryName: p.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
|
|
1663
|
-
query:
|
|
1664
|
-
"Filesystem snapshot query creation options to automatically create query"
|
|
1668
|
+
query: Z.optional().describe(
|
|
1669
|
+
"Filesystem snapshot query creation options JSON to automatically create query"
|
|
1665
1670
|
),
|
|
1666
1671
|
name: p.string().describe(
|
|
1667
1672
|
"Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1668
1673
|
)
|
|
1669
1674
|
});
|
|
1670
|
-
async function
|
|
1675
|
+
async function Ae(t, r, s) {
|
|
1671
1676
|
let o;
|
|
1672
1677
|
try {
|
|
1673
|
-
o =
|
|
1678
|
+
o = X.parse(t);
|
|
1674
1679
|
} catch (c) {
|
|
1675
1680
|
return {
|
|
1676
|
-
error:
|
|
1681
|
+
error: C(c)
|
|
1677
1682
|
};
|
|
1678
1683
|
}
|
|
1679
1684
|
const { name: e, queryName: n, query: i } = o;
|
|
@@ -1681,7 +1686,7 @@ async function Le(t, r, s) {
|
|
|
1681
1686
|
return {
|
|
1682
1687
|
error: "Session ID is required"
|
|
1683
1688
|
};
|
|
1684
|
-
const a =
|
|
1689
|
+
const a = V(s.sessionId);
|
|
1685
1690
|
if (a.fsSnapshots.has(e))
|
|
1686
1691
|
return {
|
|
1687
1692
|
error: `Filesystem snapshot "${e}" already exists`
|
|
@@ -1699,7 +1704,7 @@ async function Le(t, r, s) {
|
|
|
1699
1704
|
};
|
|
1700
1705
|
u = c;
|
|
1701
1706
|
} else if (i) {
|
|
1702
|
-
const c = await
|
|
1707
|
+
const c = await ze(
|
|
1703
1708
|
i,
|
|
1704
1709
|
r,
|
|
1705
1710
|
s
|
|
@@ -1714,7 +1719,7 @@ async function Le(t, r, s) {
|
|
|
1714
1719
|
error: "Either queryName or query must be provided"
|
|
1715
1720
|
};
|
|
1716
1721
|
try {
|
|
1717
|
-
const c = await
|
|
1722
|
+
const c = await sr(u), f = {
|
|
1718
1723
|
name: e,
|
|
1719
1724
|
query: u,
|
|
1720
1725
|
tree: c
|
|
@@ -1729,16 +1734,16 @@ async function Le(t, r, s) {
|
|
|
1729
1734
|
};
|
|
1730
1735
|
}
|
|
1731
1736
|
}
|
|
1732
|
-
function
|
|
1737
|
+
function or(t, r) {
|
|
1733
1738
|
t(
|
|
1734
1739
|
"fs-snapshot-create",
|
|
1735
1740
|
{
|
|
1736
1741
|
title: "Create Filesystem Snapshot",
|
|
1737
1742
|
description: "Create a filesystem snapshot. Use this to capture filesystem state for later browsing. Prefer fs-snapshot-browse if you need to immediately create and browse a snapshot",
|
|
1738
|
-
inputSchema:
|
|
1743
|
+
inputSchema: X.shape
|
|
1739
1744
|
},
|
|
1740
1745
|
async (s, o) => {
|
|
1741
|
-
const e = await
|
|
1746
|
+
const e = await Ae(s, r, o);
|
|
1742
1747
|
if (e.error != null)
|
|
1743
1748
|
return `Method: fs-snapshot-create(${JSON.stringify(s)})
|
|
1744
1749
|
❌ Error: ${e.error}`;
|
|
@@ -1749,7 +1754,7 @@ function sr(t, r) {
|
|
|
1749
1754
|
}
|
|
1750
1755
|
);
|
|
1751
1756
|
}
|
|
1752
|
-
class
|
|
1757
|
+
class nr {
|
|
1753
1758
|
_first = null;
|
|
1754
1759
|
_last = null;
|
|
1755
1760
|
_size = 0;
|
|
@@ -1772,8 +1777,8 @@ class or {
|
|
|
1772
1777
|
return this._size;
|
|
1773
1778
|
}
|
|
1774
1779
|
}
|
|
1775
|
-
function
|
|
1776
|
-
const r = new
|
|
1780
|
+
function ir(t) {
|
|
1781
|
+
const r = new nr(), {
|
|
1777
1782
|
tree: s,
|
|
1778
1783
|
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
|
|
1779
1784
|
indexRangeGroupStrategy: a
|
|
@@ -1795,36 +1800,36 @@ function nr(t) {
|
|
|
1795
1800
|
const b = g * a.tokens;
|
|
1796
1801
|
if (o != null && c + m.countChilds + g > o || e != null && f + m.tokensChilds + b > e) {
|
|
1797
1802
|
const y = [];
|
|
1798
|
-
let
|
|
1803
|
+
let x = null, I = 0;
|
|
1799
1804
|
for (let w = 0, M = h.length; w < M; w++) {
|
|
1800
|
-
const
|
|
1801
|
-
|
|
1802
|
-
!(o != null && c + 1 > o || e != null && f + a.tokens > e) && (n != null &&
|
|
1805
|
+
const $ = h[w], v = I * a.tokens;
|
|
1806
|
+
x != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
|
|
1807
|
+
!(o != null && c + 1 > o || e != null && f + a.tokens > e) && (n != null && x.countGrouped + 1 + I > n || i != null && x.tokensGrouped + $.tokens + v > i) && (y.push(x), c += 1, f += a.tokens, x = null, I = 0), x = a.add(x, $, w), $.countChilds > 0 && (I += 1);
|
|
1803
1808
|
}
|
|
1804
|
-
|
|
1805
|
-
const
|
|
1809
|
+
x != null && (y.push(x), c += 1, f += a.tokens);
|
|
1810
|
+
const S = y.map((w) => ({
|
|
1806
1811
|
text: a.getReportText(w)
|
|
1807
1812
|
}));
|
|
1808
1813
|
if (d != null) {
|
|
1809
1814
|
if (d.childs != null)
|
|
1810
1815
|
throw new Error("Impossible behavior: reportNode.childs != null");
|
|
1811
|
-
d.childs =
|
|
1816
|
+
d.childs = S;
|
|
1812
1817
|
} else {
|
|
1813
1818
|
if (l != null)
|
|
1814
1819
|
throw new Error("Impossible behavior: reportRootNodes != null");
|
|
1815
|
-
l =
|
|
1820
|
+
l = S;
|
|
1816
1821
|
}
|
|
1817
1822
|
} else {
|
|
1818
1823
|
c += m.countChilds, f += m.tokensChilds;
|
|
1819
1824
|
const y = [];
|
|
1820
|
-
for (let
|
|
1821
|
-
const I = h[
|
|
1825
|
+
for (let x = 0; x < h.length; x++) {
|
|
1826
|
+
const I = h[x], S = {
|
|
1822
1827
|
text: I.text
|
|
1823
1828
|
};
|
|
1824
|
-
y.push(
|
|
1829
|
+
y.push(S);
|
|
1825
1830
|
const w = s.getChilds(I);
|
|
1826
1831
|
w != null && w.length > 0 && r.enqueue({
|
|
1827
|
-
reportNode:
|
|
1832
|
+
reportNode: S,
|
|
1828
1833
|
node: I
|
|
1829
1834
|
});
|
|
1830
1835
|
}
|
|
@@ -1841,7 +1846,7 @@ function nr(t) {
|
|
|
1841
1846
|
}
|
|
1842
1847
|
return l ?? [];
|
|
1843
1848
|
}
|
|
1844
|
-
function
|
|
1849
|
+
function Ge(t) {
|
|
1845
1850
|
const {
|
|
1846
1851
|
tree: r,
|
|
1847
1852
|
request: { parentNodeId: s, childsIndexRange: o, limits: e },
|
|
@@ -1885,14 +1890,14 @@ function Ae(t) {
|
|
|
1885
1890
|
root: c,
|
|
1886
1891
|
getChilds: (d) => d === c ? [u] : d === u ? l : r.getChilds(d)
|
|
1887
1892
|
};
|
|
1888
|
-
return
|
|
1893
|
+
return ir({
|
|
1889
1894
|
tree: f,
|
|
1890
1895
|
limits: e,
|
|
1891
1896
|
indexRangeGroupStrategy: n,
|
|
1892
1897
|
...i
|
|
1893
1898
|
});
|
|
1894
1899
|
}
|
|
1895
|
-
function
|
|
1900
|
+
function qe(t, r) {
|
|
1896
1901
|
if (t == null || t.length === 0)
|
|
1897
1902
|
return "No results found";
|
|
1898
1903
|
let s = "";
|
|
@@ -1909,7 +1914,7 @@ function Ge(t, r) {
|
|
|
1909
1914
|
}
|
|
1910
1915
|
return o(t, ""), s;
|
|
1911
1916
|
}
|
|
1912
|
-
class
|
|
1917
|
+
class ar {
|
|
1913
1918
|
tokens = 16;
|
|
1914
1919
|
// +1 indent, +1 for line break
|
|
1915
1920
|
getReportText = (r) => ({
|
|
@@ -1924,10 +1929,10 @@ class ir {
|
|
|
1924
1929
|
tokensGrouped: s.tokens
|
|
1925
1930
|
} : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
|
|
1926
1931
|
}
|
|
1927
|
-
const
|
|
1932
|
+
const _e = p.object({
|
|
1928
1933
|
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
1929
|
-
snapshot:
|
|
1930
|
-
"Filesystem snapshot creation options to automatically create snapshot"
|
|
1934
|
+
snapshot: X.optional().describe(
|
|
1935
|
+
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
1931
1936
|
),
|
|
1932
1937
|
parentPath: p.string().optional().describe(
|
|
1933
1938
|
"Path relative to snapshot rootDir to browse. Omit to browse the rootDir itself"
|
|
@@ -1946,13 +1951,13 @@ const qe = p.object({
|
|
|
1946
1951
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
1947
1952
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
1948
1953
|
});
|
|
1949
|
-
async function
|
|
1954
|
+
async function lr(t, r, s) {
|
|
1950
1955
|
let o;
|
|
1951
1956
|
try {
|
|
1952
|
-
o =
|
|
1957
|
+
o = _e.parse(t);
|
|
1953
1958
|
} catch (g) {
|
|
1954
1959
|
return {
|
|
1955
|
-
error:
|
|
1960
|
+
error: C(g)
|
|
1956
1961
|
};
|
|
1957
1962
|
}
|
|
1958
1963
|
const {
|
|
@@ -1968,7 +1973,7 @@ async function ar(t, r, s) {
|
|
|
1968
1973
|
return {
|
|
1969
1974
|
error: "Session ID is required"
|
|
1970
1975
|
};
|
|
1971
|
-
const f =
|
|
1976
|
+
const f = V(s.sessionId);
|
|
1972
1977
|
let d, m = !1, h = !1;
|
|
1973
1978
|
if (e && n)
|
|
1974
1979
|
return {
|
|
@@ -1980,7 +1985,7 @@ async function ar(t, r, s) {
|
|
|
1980
1985
|
error: `Filesystem snapshot "${e}" not found`
|
|
1981
1986
|
};
|
|
1982
1987
|
} else if (n) {
|
|
1983
|
-
const g = await
|
|
1988
|
+
const g = await Ae(
|
|
1984
1989
|
n,
|
|
1985
1990
|
r,
|
|
1986
1991
|
s
|
|
@@ -1995,7 +2000,7 @@ async function ar(t, r, s) {
|
|
|
1995
2000
|
error: "Either snapshotName or snapshot must be provided"
|
|
1996
2001
|
};
|
|
1997
2002
|
try {
|
|
1998
|
-
const g =
|
|
2003
|
+
const g = W(o.parentPath), b = Ge({
|
|
1999
2004
|
tree: d.tree,
|
|
2000
2005
|
request: {
|
|
2001
2006
|
parentNodeId: g,
|
|
@@ -2007,8 +2012,8 @@ async function ar(t, r, s) {
|
|
|
2007
2012
|
maxTokensGroup: c
|
|
2008
2013
|
}
|
|
2009
2014
|
},
|
|
2010
|
-
indexRangeGroupStrategy: new
|
|
2011
|
-
}), y =
|
|
2015
|
+
indexRangeGroupStrategy: new ar()
|
|
2016
|
+
}), y = qe(b);
|
|
2012
2017
|
return {
|
|
2013
2018
|
fsSnapshot: d,
|
|
2014
2019
|
queryCreated: m,
|
|
@@ -2023,16 +2028,16 @@ async function ar(t, r, s) {
|
|
|
2023
2028
|
};
|
|
2024
2029
|
}
|
|
2025
2030
|
}
|
|
2026
|
-
function
|
|
2031
|
+
function cr(t, r) {
|
|
2027
2032
|
t(
|
|
2028
2033
|
"fs-snapshot-browse",
|
|
2029
2034
|
{
|
|
2030
2035
|
title: "Browse Filesystem Snapshot",
|
|
2031
2036
|
description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
|
|
2032
|
-
inputSchema:
|
|
2037
|
+
inputSchema: _e.shape
|
|
2033
2038
|
},
|
|
2034
2039
|
async (s, o) => {
|
|
2035
|
-
const e = await
|
|
2040
|
+
const e = await lr(s, r, o);
|
|
2036
2041
|
if (e.error != null)
|
|
2037
2042
|
return `Method: fs-snapshot-browse(${JSON.stringify(s)})
|
|
2038
2043
|
❌ Error: ${e.error}`;
|
|
@@ -2054,21 +2059,21 @@ ${e.report}`, n;
|
|
|
2054
2059
|
}
|
|
2055
2060
|
);
|
|
2056
2061
|
}
|
|
2057
|
-
function
|
|
2058
|
-
r.list &&
|
|
2062
|
+
function ur(t, r) {
|
|
2063
|
+
r.list && Qt(t, r), r.snapshotQueryCreate && Yt(t, r), r.snapshotCreate && or(t, r), r.snapshotBrowse && cr(t, r), console.log(
|
|
2059
2064
|
`File manager:
|
|
2060
2065
|
- Working directory: ${T.resolve(r.workingDir || "")}
|
|
2061
2066
|
`
|
|
2062
2067
|
);
|
|
2063
2068
|
}
|
|
2064
|
-
const
|
|
2065
|
-
function
|
|
2066
|
-
return
|
|
2069
|
+
const J = /* @__PURE__ */ new Map();
|
|
2070
|
+
function E(t) {
|
|
2071
|
+
return J.has(t) || J.set(t, {
|
|
2067
2072
|
browsers: /* @__PURE__ */ new Map(),
|
|
2068
2073
|
domSnapshotQueries: /* @__PURE__ */ new Map()
|
|
2069
|
-
}),
|
|
2074
|
+
}), J.get(t);
|
|
2070
2075
|
}
|
|
2071
|
-
const
|
|
2076
|
+
const ee = p.object({
|
|
2072
2077
|
name: p.string().describe(
|
|
2073
2078
|
"Unique name for the browser. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
2074
2079
|
),
|
|
@@ -2076,13 +2081,13 @@ const X = p.object({
|
|
|
2076
2081
|
muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
|
|
2077
2082
|
devTools: p.boolean().optional().describe("Open browser with dev tools")
|
|
2078
2083
|
});
|
|
2079
|
-
async function
|
|
2084
|
+
async function je(t, r, s) {
|
|
2080
2085
|
let o;
|
|
2081
2086
|
try {
|
|
2082
|
-
o =
|
|
2087
|
+
o = ee.parse(t);
|
|
2083
2088
|
} catch (c) {
|
|
2084
2089
|
return {
|
|
2085
|
-
error:
|
|
2090
|
+
error: C(c)
|
|
2086
2091
|
};
|
|
2087
2092
|
}
|
|
2088
2093
|
const { name: e, browserType: n, muteAudio: i, devTools: a } = o;
|
|
@@ -2090,16 +2095,16 @@ async function _e(t, r, s) {
|
|
|
2090
2095
|
return {
|
|
2091
2096
|
error: "Session ID is required"
|
|
2092
2097
|
};
|
|
2093
|
-
const u =
|
|
2098
|
+
const u = E(s.sessionId), l = u.browsers.get(e);
|
|
2094
2099
|
if (l)
|
|
2095
2100
|
return {
|
|
2096
2101
|
error: `Browser "${l.name}" (${l.browserType}) already exists`
|
|
2097
2102
|
};
|
|
2098
2103
|
try {
|
|
2099
2104
|
const f = await {
|
|
2100
|
-
chromium:
|
|
2101
|
-
firefox:
|
|
2102
|
-
webkit:
|
|
2105
|
+
chromium: gt,
|
|
2106
|
+
firefox: pt,
|
|
2107
|
+
webkit: ht
|
|
2103
2108
|
}[n].launch({
|
|
2104
2109
|
headless: !1,
|
|
2105
2110
|
devtools: a,
|
|
@@ -2117,50 +2122,50 @@ async function _e(t, r, s) {
|
|
|
2117
2122
|
};
|
|
2118
2123
|
}
|
|
2119
2124
|
}
|
|
2120
|
-
function
|
|
2125
|
+
function dr(t, r) {
|
|
2121
2126
|
t(
|
|
2122
2127
|
"playwright-browser-create",
|
|
2123
2128
|
{
|
|
2124
2129
|
title: "Create Browser",
|
|
2125
2130
|
description: "Create a new browser. Prefer page-goto if you need to immediately create a browser, context, page and navigate",
|
|
2126
|
-
inputSchema:
|
|
2131
|
+
inputSchema: ee.shape
|
|
2127
2132
|
},
|
|
2128
2133
|
async (s, o) => {
|
|
2129
|
-
const e = await
|
|
2134
|
+
const e = await je(s, r, o);
|
|
2130
2135
|
return `Method: playwright-browser-create(${JSON.stringify(s)})
|
|
2131
2136
|
${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
|
|
2132
2137
|
}
|
|
2133
2138
|
);
|
|
2134
2139
|
}
|
|
2135
|
-
const
|
|
2136
|
-
async function
|
|
2140
|
+
const Je = p.object({});
|
|
2141
|
+
async function fr(t, r, s) {
|
|
2137
2142
|
let o;
|
|
2138
2143
|
try {
|
|
2139
|
-
o =
|
|
2144
|
+
o = Je.parse(t);
|
|
2140
2145
|
} catch (i) {
|
|
2141
2146
|
return {
|
|
2142
|
-
error:
|
|
2147
|
+
error: C(i)
|
|
2143
2148
|
};
|
|
2144
2149
|
}
|
|
2145
2150
|
if (!s.sessionId)
|
|
2146
2151
|
return {
|
|
2147
2152
|
error: "Session ID is required"
|
|
2148
2153
|
};
|
|
2149
|
-
const e =
|
|
2154
|
+
const e = E(s.sessionId);
|
|
2150
2155
|
return {
|
|
2151
2156
|
browserInfos: Array.from(e.browsers.values())
|
|
2152
2157
|
};
|
|
2153
2158
|
}
|
|
2154
|
-
function
|
|
2159
|
+
function mr(t, r) {
|
|
2155
2160
|
t(
|
|
2156
2161
|
"playwright-browser-list",
|
|
2157
2162
|
{
|
|
2158
2163
|
title: "List Browsers",
|
|
2159
2164
|
description: "List active browser instances",
|
|
2160
|
-
inputSchema:
|
|
2165
|
+
inputSchema: Je.shape
|
|
2161
2166
|
},
|
|
2162
2167
|
async (s, o) => {
|
|
2163
|
-
const e = await
|
|
2168
|
+
const e = await fr(s, r, o);
|
|
2164
2169
|
if (e.error != null)
|
|
2165
2170
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
2166
2171
|
❌ Error: ${e.error}`;
|
|
@@ -2172,18 +2177,18 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
|
|
|
2172
2177
|
}
|
|
2173
2178
|
);
|
|
2174
2179
|
}
|
|
2175
|
-
const
|
|
2180
|
+
const Ke = p.object({
|
|
2176
2181
|
names: p.array(p.string()).optional().describe(
|
|
2177
2182
|
"Names of browsers to close. If not specified, closes all browsers"
|
|
2178
2183
|
)
|
|
2179
2184
|
});
|
|
2180
|
-
async function
|
|
2185
|
+
async function hr(t, r, s) {
|
|
2181
2186
|
let o;
|
|
2182
2187
|
try {
|
|
2183
|
-
o =
|
|
2188
|
+
o = Ke.parse(t);
|
|
2184
2189
|
} catch (l) {
|
|
2185
2190
|
return {
|
|
2186
|
-
error:
|
|
2191
|
+
error: C(l)
|
|
2187
2192
|
};
|
|
2188
2193
|
}
|
|
2189
2194
|
const { names: e } = o;
|
|
@@ -2191,7 +2196,7 @@ async function mr(t, r, s) {
|
|
|
2191
2196
|
return {
|
|
2192
2197
|
error: "Session ID is required"
|
|
2193
2198
|
};
|
|
2194
|
-
const n =
|
|
2199
|
+
const n = E(s.sessionId), i = [], a = [];
|
|
2195
2200
|
let u = [];
|
|
2196
2201
|
return e ? e.forEach((l) => {
|
|
2197
2202
|
const c = n.browsers.get(l);
|
|
@@ -2211,16 +2216,16 @@ async function mr(t, r, s) {
|
|
|
2211
2216
|
...a.length > 0 && { errors: a }
|
|
2212
2217
|
};
|
|
2213
2218
|
}
|
|
2214
|
-
function
|
|
2219
|
+
function pr(t, r) {
|
|
2215
2220
|
t(
|
|
2216
2221
|
"playwright-browser-close",
|
|
2217
2222
|
{
|
|
2218
2223
|
title: "Close Browsers",
|
|
2219
2224
|
description: "Close browsers. Automatically closes all contexts and pages within the browsers",
|
|
2220
|
-
inputSchema:
|
|
2225
|
+
inputSchema: Ke.shape
|
|
2221
2226
|
},
|
|
2222
2227
|
async (s, o) => {
|
|
2223
|
-
const e = await
|
|
2228
|
+
const e = await hr(s, r, o);
|
|
2224
2229
|
if (e.error != null)
|
|
2225
2230
|
return `Method: playwright-browser-close(${JSON.stringify(s)})
|
|
2226
2231
|
❌ Error: ${e.error}`;
|
|
@@ -2237,10 +2242,10 @@ ${n.join(`
|
|
|
2237
2242
|
}
|
|
2238
2243
|
);
|
|
2239
2244
|
}
|
|
2240
|
-
const
|
|
2245
|
+
const te = p.object({
|
|
2241
2246
|
browserName: p.string().optional().describe("Name of previously created browser, to use"),
|
|
2242
|
-
browser:
|
|
2243
|
-
"Browser creation options to automatically create browser"
|
|
2247
|
+
browser: ee.optional().describe(
|
|
2248
|
+
"Browser creation options JSON to automatically create browser"
|
|
2244
2249
|
),
|
|
2245
2250
|
name: p.string().describe(
|
|
2246
2251
|
"Unique name for the context. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
@@ -2252,13 +2257,13 @@ const ee = p.object({
|
|
|
2252
2257
|
height: p.number()
|
|
2253
2258
|
}).optional().describe("Viewport size configuration")
|
|
2254
2259
|
});
|
|
2255
|
-
async function
|
|
2260
|
+
async function We(t, r, s) {
|
|
2256
2261
|
let o;
|
|
2257
2262
|
try {
|
|
2258
|
-
o =
|
|
2263
|
+
o = te.parse(t);
|
|
2259
2264
|
} catch (m) {
|
|
2260
2265
|
return {
|
|
2261
|
-
error:
|
|
2266
|
+
error: C(m)
|
|
2262
2267
|
};
|
|
2263
2268
|
}
|
|
2264
2269
|
const { name: e, browserName: n, browser: i, isMobile: a, hasTouch: u, viewport: l } = o;
|
|
@@ -2266,7 +2271,7 @@ async function Ke(t, r, s) {
|
|
|
2266
2271
|
return {
|
|
2267
2272
|
error: "Session ID is required"
|
|
2268
2273
|
};
|
|
2269
|
-
const c =
|
|
2274
|
+
const c = E(s.sessionId);
|
|
2270
2275
|
if (n && i)
|
|
2271
2276
|
return {
|
|
2272
2277
|
error: "Either browserName or browser must be provided, not both"
|
|
@@ -2278,7 +2283,7 @@ async function Ke(t, r, s) {
|
|
|
2278
2283
|
error: `Browser "${n}" not found`
|
|
2279
2284
|
};
|
|
2280
2285
|
} else if (i) {
|
|
2281
|
-
const m = await
|
|
2286
|
+
const m = await je(i, r, s);
|
|
2282
2287
|
if (m.error != null)
|
|
2283
2288
|
return {
|
|
2284
2289
|
error: m.error
|
|
@@ -2314,16 +2319,16 @@ async function Ke(t, r, s) {
|
|
|
2314
2319
|
};
|
|
2315
2320
|
}
|
|
2316
2321
|
}
|
|
2317
|
-
function
|
|
2322
|
+
function gr(t, r) {
|
|
2318
2323
|
t(
|
|
2319
2324
|
"playwright-context-create",
|
|
2320
2325
|
{
|
|
2321
2326
|
title: "Create Browser Context",
|
|
2322
2327
|
description: "Create a new browser context. Prefer page-goto if you need to immediately create a context, page and navigate",
|
|
2323
|
-
inputSchema:
|
|
2328
|
+
inputSchema: te.shape
|
|
2324
2329
|
},
|
|
2325
2330
|
async (s, o) => {
|
|
2326
|
-
const e = await
|
|
2331
|
+
const e = await We(s, r, o);
|
|
2327
2332
|
if (e.error != null)
|
|
2328
2333
|
return `Method: playwright-context-create(${JSON.stringify(s)})
|
|
2329
2334
|
❌ Error: ${e.error}`;
|
|
@@ -2334,18 +2339,18 @@ function pr(t, r) {
|
|
|
2334
2339
|
}
|
|
2335
2340
|
);
|
|
2336
2341
|
}
|
|
2337
|
-
const
|
|
2342
|
+
const Qe = p.object({
|
|
2338
2343
|
browserName: p.string().optional().describe(
|
|
2339
2344
|
"Name of browser to list contexts from. If not specified, lists contexts from all browsers"
|
|
2340
2345
|
)
|
|
2341
2346
|
});
|
|
2342
|
-
async function
|
|
2347
|
+
async function wr(t, r, s) {
|
|
2343
2348
|
let o;
|
|
2344
2349
|
try {
|
|
2345
|
-
o =
|
|
2350
|
+
o = Qe.parse(t);
|
|
2346
2351
|
} catch (a) {
|
|
2347
2352
|
return {
|
|
2348
|
-
error:
|
|
2353
|
+
error: C(a)
|
|
2349
2354
|
};
|
|
2350
2355
|
}
|
|
2351
2356
|
const { browserName: e } = o;
|
|
@@ -2353,7 +2358,7 @@ async function gr(t, r, s) {
|
|
|
2353
2358
|
return {
|
|
2354
2359
|
error: "Session ID is required"
|
|
2355
2360
|
};
|
|
2356
|
-
const n =
|
|
2361
|
+
const n = E(s.sessionId), i = [];
|
|
2357
2362
|
if (e) {
|
|
2358
2363
|
const a = n.browsers.get(e);
|
|
2359
2364
|
if (!a)
|
|
@@ -2376,16 +2381,16 @@ async function gr(t, r, s) {
|
|
|
2376
2381
|
contextsByBrowser: i
|
|
2377
2382
|
};
|
|
2378
2383
|
}
|
|
2379
|
-
function
|
|
2384
|
+
function yr(t, r) {
|
|
2380
2385
|
t(
|
|
2381
2386
|
"playwright-context-list",
|
|
2382
2387
|
{
|
|
2383
2388
|
title: "List Browser Contexts",
|
|
2384
2389
|
description: "List active browser contexts",
|
|
2385
|
-
inputSchema:
|
|
2390
|
+
inputSchema: Qe.shape
|
|
2386
2391
|
},
|
|
2387
2392
|
async (s, o) => {
|
|
2388
|
-
const e = await
|
|
2393
|
+
const e = await wr(s, r, o);
|
|
2389
2394
|
if ("error" in e)
|
|
2390
2395
|
return `Method: playwright-context-list(${JSON.stringify(s)})
|
|
2391
2396
|
❌ Error: ${e.error}`;
|
|
@@ -2398,7 +2403,7 @@ function wr(t, r) {
|
|
|
2398
2403
|
}
|
|
2399
2404
|
);
|
|
2400
2405
|
}
|
|
2401
|
-
const
|
|
2406
|
+
const He = p.object({
|
|
2402
2407
|
names: p.array(p.string()).optional().describe(
|
|
2403
2408
|
"Names of contexts to close. If not specified, closes all contexts"
|
|
2404
2409
|
),
|
|
@@ -2406,13 +2411,13 @@ const Qe = p.object({
|
|
|
2406
2411
|
"Name of browser to close contexts from. If not specified, searches all browsers"
|
|
2407
2412
|
)
|
|
2408
2413
|
});
|
|
2409
|
-
async function
|
|
2414
|
+
async function br(t, r, s) {
|
|
2410
2415
|
let o;
|
|
2411
2416
|
try {
|
|
2412
|
-
o =
|
|
2417
|
+
o = He.parse(t);
|
|
2413
2418
|
} catch (c) {
|
|
2414
2419
|
return {
|
|
2415
|
-
error:
|
|
2420
|
+
error: C(c)
|
|
2416
2421
|
};
|
|
2417
2422
|
}
|
|
2418
2423
|
const { names: e, browserName: n } = o;
|
|
@@ -2420,7 +2425,7 @@ async function yr(t, r, s) {
|
|
|
2420
2425
|
return {
|
|
2421
2426
|
error: "Session ID is required"
|
|
2422
2427
|
};
|
|
2423
|
-
const i =
|
|
2428
|
+
const i = E(s.sessionId), a = [], u = [];
|
|
2424
2429
|
let l = [];
|
|
2425
2430
|
if (n) {
|
|
2426
2431
|
const c = i.browsers.get(n);
|
|
@@ -2460,16 +2465,16 @@ async function yr(t, r, s) {
|
|
|
2460
2465
|
...u.length > 0 && { errors: u }
|
|
2461
2466
|
};
|
|
2462
2467
|
}
|
|
2463
|
-
function
|
|
2468
|
+
function xr(t, r) {
|
|
2464
2469
|
t(
|
|
2465
2470
|
"playwright-context-close",
|
|
2466
2471
|
{
|
|
2467
2472
|
title: "Close Browser Contexts",
|
|
2468
2473
|
description: "Close browser contexts. Automatically closes all pages within the contexts",
|
|
2469
|
-
inputSchema:
|
|
2474
|
+
inputSchema: He.shape
|
|
2470
2475
|
},
|
|
2471
2476
|
async (s, o) => {
|
|
2472
|
-
const e = await
|
|
2477
|
+
const e = await br(s, r, o);
|
|
2473
2478
|
if ("error" in e)
|
|
2474
2479
|
return `Method: playwright-context-close(${JSON.stringify(s)})
|
|
2475
2480
|
❌ Error: ${e.error}`;
|
|
@@ -2486,7 +2491,7 @@ ${n.join(`
|
|
|
2486
2491
|
}
|
|
2487
2492
|
);
|
|
2488
2493
|
}
|
|
2489
|
-
function
|
|
2494
|
+
function Sr() {
|
|
2490
2495
|
class t {
|
|
2491
2496
|
prevId = 0;
|
|
2492
2497
|
objectToId = /* @__PURE__ */ new WeakMap();
|
|
@@ -2521,15 +2526,15 @@ function $r() {
|
|
|
2521
2526
|
const { getId: u, getChilds: l, rootNodes: c, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = r(
|
|
2522
2527
|
l,
|
|
2523
2528
|
c,
|
|
2524
|
-
(y,
|
|
2525
|
-
const I = f(y,
|
|
2529
|
+
(y, x) => {
|
|
2530
|
+
const I = f(y, x);
|
|
2526
2531
|
if (y != null && I != null) {
|
|
2527
|
-
const
|
|
2528
|
-
d.set(
|
|
2532
|
+
const S = u(y);
|
|
2533
|
+
d.set(S, I), m.set(I, S);
|
|
2529
2534
|
}
|
|
2530
|
-
return I != null &&
|
|
2535
|
+
return I != null && x != null && h.set(
|
|
2531
2536
|
m.get(I),
|
|
2532
|
-
|
|
2537
|
+
x.map((S) => m.get(S))
|
|
2533
2538
|
), I;
|
|
2534
2539
|
}
|
|
2535
2540
|
), b = f(null, g);
|
|
@@ -2574,22 +2579,22 @@ function $r() {
|
|
|
2574
2579
|
}
|
|
2575
2580
|
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
|
|
2576
2581
|
}
|
|
2577
|
-
const
|
|
2582
|
+
const $r = `(function (){function __name(fn){return fn};${Sr.toString()}; setupPageGlobals();})()`, re = p.object({
|
|
2578
2583
|
contextName: p.string().optional().describe("Name of previously created context, to use"),
|
|
2579
|
-
context:
|
|
2580
|
-
"Context creation options to automatically create context"
|
|
2584
|
+
context: te.optional().describe(
|
|
2585
|
+
"Context creation options JSON to automatically create context"
|
|
2581
2586
|
),
|
|
2582
2587
|
name: p.string().describe(
|
|
2583
2588
|
"Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
2584
2589
|
)
|
|
2585
2590
|
});
|
|
2586
|
-
async function
|
|
2591
|
+
async function Ye(t, r, s) {
|
|
2587
2592
|
let o;
|
|
2588
2593
|
try {
|
|
2589
|
-
o =
|
|
2594
|
+
o = re.parse(t);
|
|
2590
2595
|
} catch (f) {
|
|
2591
2596
|
return {
|
|
2592
|
-
error:
|
|
2597
|
+
error: C(f)
|
|
2593
2598
|
};
|
|
2594
2599
|
}
|
|
2595
2600
|
const { name: e, contextName: n, context: i } = o;
|
|
@@ -2597,7 +2602,7 @@ async function He(t, r, s) {
|
|
|
2597
2602
|
return {
|
|
2598
2603
|
error: "Session ID is required"
|
|
2599
2604
|
};
|
|
2600
|
-
const a =
|
|
2605
|
+
const a = E(s.sessionId);
|
|
2601
2606
|
if (n && i)
|
|
2602
2607
|
return {
|
|
2603
2608
|
error: "Either contextName or context must be provided, not both"
|
|
@@ -2614,7 +2619,7 @@ async function He(t, r, s) {
|
|
|
2614
2619
|
error: `Context "${n}" not found`
|
|
2615
2620
|
};
|
|
2616
2621
|
} else if (i) {
|
|
2617
|
-
const f = await
|
|
2622
|
+
const f = await We(i, r, s);
|
|
2618
2623
|
if (f.error != null)
|
|
2619
2624
|
return {
|
|
2620
2625
|
error: f.error
|
|
@@ -2630,7 +2635,7 @@ async function He(t, r, s) {
|
|
|
2630
2635
|
};
|
|
2631
2636
|
try {
|
|
2632
2637
|
const f = await c.context.newPage();
|
|
2633
|
-
await f.addInitScript(
|
|
2638
|
+
await f.addInitScript($r), await f.goto("about:blank");
|
|
2634
2639
|
const d = {
|
|
2635
2640
|
contextInfo: c,
|
|
2636
2641
|
name: e,
|
|
@@ -2648,16 +2653,16 @@ async function He(t, r, s) {
|
|
|
2648
2653
|
};
|
|
2649
2654
|
}
|
|
2650
2655
|
}
|
|
2651
|
-
function
|
|
2656
|
+
function Ir(t, r) {
|
|
2652
2657
|
t(
|
|
2653
2658
|
"playwright-page-create",
|
|
2654
2659
|
{
|
|
2655
2660
|
title: "Create Page",
|
|
2656
2661
|
description: "Create a new page. Prefer page-goto if you need to immediately create a page and navigate",
|
|
2657
|
-
inputSchema:
|
|
2662
|
+
inputSchema: re.shape
|
|
2658
2663
|
},
|
|
2659
2664
|
async (s, o) => {
|
|
2660
|
-
const e = await
|
|
2665
|
+
const e = await Ye(s, r, o);
|
|
2661
2666
|
if (e.error != null)
|
|
2662
2667
|
return `Method: playwright-page-create(${JSON.stringify(s)})
|
|
2663
2668
|
❌ Error: ${e.error}`;
|
|
@@ -2669,7 +2674,7 @@ function Sr(t, r) {
|
|
|
2669
2674
|
}
|
|
2670
2675
|
);
|
|
2671
2676
|
}
|
|
2672
|
-
const
|
|
2677
|
+
const Ve = p.object({
|
|
2673
2678
|
contextName: p.string().optional().describe(
|
|
2674
2679
|
"Name of context to list pages from. If not specified, lists pages from all contexts"
|
|
2675
2680
|
),
|
|
@@ -2677,13 +2682,13 @@ const Ye = p.object({
|
|
|
2677
2682
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
2678
2683
|
)
|
|
2679
2684
|
});
|
|
2680
|
-
async function
|
|
2685
|
+
async function Mr(t, r, s) {
|
|
2681
2686
|
let o;
|
|
2682
2687
|
try {
|
|
2683
|
-
o =
|
|
2688
|
+
o = Ve.parse(t);
|
|
2684
2689
|
} catch (u) {
|
|
2685
2690
|
return {
|
|
2686
|
-
error:
|
|
2691
|
+
error: C(u)
|
|
2687
2692
|
};
|
|
2688
2693
|
}
|
|
2689
2694
|
const { contextName: e, browserName: n } = o;
|
|
@@ -2691,7 +2696,7 @@ async function Ir(t, r, s) {
|
|
|
2691
2696
|
return {
|
|
2692
2697
|
error: "Session ID is required"
|
|
2693
2698
|
};
|
|
2694
|
-
const i =
|
|
2699
|
+
const i = E(s.sessionId), a = [];
|
|
2695
2700
|
if (n) {
|
|
2696
2701
|
const u = i.browsers.get(n);
|
|
2697
2702
|
if (!u)
|
|
@@ -2741,16 +2746,16 @@ async function Ir(t, r, s) {
|
|
|
2741
2746
|
pagesByContext: a
|
|
2742
2747
|
};
|
|
2743
2748
|
}
|
|
2744
|
-
function
|
|
2749
|
+
function Tr(t, r) {
|
|
2745
2750
|
t(
|
|
2746
2751
|
"playwright-page-list",
|
|
2747
2752
|
{
|
|
2748
2753
|
title: "List Pages",
|
|
2749
2754
|
description: "List active pages",
|
|
2750
|
-
inputSchema:
|
|
2755
|
+
inputSchema: Ve.shape
|
|
2751
2756
|
},
|
|
2752
2757
|
async (s, o) => {
|
|
2753
|
-
const e = await
|
|
2758
|
+
const e = await Mr(s, r, o);
|
|
2754
2759
|
if ("error" in e)
|
|
2755
2760
|
return `Method: playwright-page-list(${JSON.stringify(s)})
|
|
2756
2761
|
❌ Error: ${e.error}`;
|
|
@@ -2763,7 +2768,7 @@ function Mr(t, r) {
|
|
|
2763
2768
|
}
|
|
2764
2769
|
);
|
|
2765
2770
|
}
|
|
2766
|
-
const
|
|
2771
|
+
const Ze = p.object({
|
|
2767
2772
|
names: p.array(p.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
|
|
2768
2773
|
contextName: p.string().optional().describe(
|
|
2769
2774
|
"Name of context to close pages from. If not specified, searches all contexts"
|
|
@@ -2772,13 +2777,13 @@ const Ve = p.object({
|
|
|
2772
2777
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
2773
2778
|
)
|
|
2774
2779
|
});
|
|
2775
|
-
async function
|
|
2780
|
+
async function vr(t, r, s) {
|
|
2776
2781
|
let o;
|
|
2777
2782
|
try {
|
|
2778
|
-
o =
|
|
2783
|
+
o = Ze.parse(t);
|
|
2779
2784
|
} catch (f) {
|
|
2780
2785
|
return {
|
|
2781
|
-
error:
|
|
2786
|
+
error: C(f)
|
|
2782
2787
|
};
|
|
2783
2788
|
}
|
|
2784
2789
|
const { names: e, contextName: n, browserName: i } = o;
|
|
@@ -2786,7 +2791,7 @@ async function Tr(t, r, s) {
|
|
|
2786
2791
|
return {
|
|
2787
2792
|
error: "Session ID is required"
|
|
2788
2793
|
};
|
|
2789
|
-
const a =
|
|
2794
|
+
const a = E(s.sessionId), u = [], l = [];
|
|
2790
2795
|
let c = [];
|
|
2791
2796
|
if (i) {
|
|
2792
2797
|
const f = a.browsers.get(i);
|
|
@@ -2850,16 +2855,16 @@ async function Tr(t, r, s) {
|
|
|
2850
2855
|
...l.length > 0 && { errors: l }
|
|
2851
2856
|
};
|
|
2852
2857
|
}
|
|
2853
|
-
function
|
|
2858
|
+
function Cr(t, r) {
|
|
2854
2859
|
t(
|
|
2855
2860
|
"playwright-page-close",
|
|
2856
2861
|
{
|
|
2857
2862
|
title: "Close Pages",
|
|
2858
2863
|
description: "Close pages",
|
|
2859
|
-
inputSchema:
|
|
2864
|
+
inputSchema: Ze.shape
|
|
2860
2865
|
},
|
|
2861
2866
|
async (s, o) => {
|
|
2862
|
-
const e = await
|
|
2867
|
+
const e = await vr(s, r, o);
|
|
2863
2868
|
if ("error" in e)
|
|
2864
2869
|
return `Method: playwright-page-close(${JSON.stringify(s)})
|
|
2865
2870
|
❌ Error: ${e.error}`;
|
|
@@ -2870,10 +2875,10 @@ ${n.join(`
|
|
|
2870
2875
|
}
|
|
2871
2876
|
);
|
|
2872
2877
|
}
|
|
2873
|
-
const
|
|
2878
|
+
const Xe = p.object({
|
|
2874
2879
|
pageName: p.string().optional().describe("Name of previously created page to navigate"),
|
|
2875
|
-
page:
|
|
2876
|
-
"Page creation options to automatically create page"
|
|
2880
|
+
page: re.optional().describe(
|
|
2881
|
+
"Page creation options JSON to automatically create page"
|
|
2877
2882
|
),
|
|
2878
2883
|
url: p.string().describe("URL to navigate to"),
|
|
2879
2884
|
timeout: p.number().describe("Timeout in seconds"),
|
|
@@ -2888,10 +2893,10 @@ const Ze = p.object({
|
|
|
2888
2893
|
async function kr(t, r, s) {
|
|
2889
2894
|
let o;
|
|
2890
2895
|
try {
|
|
2891
|
-
o =
|
|
2896
|
+
o = Xe.parse(t);
|
|
2892
2897
|
} catch (h) {
|
|
2893
2898
|
return {
|
|
2894
|
-
error:
|
|
2899
|
+
error: C(h)
|
|
2895
2900
|
};
|
|
2896
2901
|
}
|
|
2897
2902
|
const { pageName: e, page: n, url: i, timeout: a, waitUntil: u } = o;
|
|
@@ -2899,7 +2904,7 @@ async function kr(t, r, s) {
|
|
|
2899
2904
|
return {
|
|
2900
2905
|
error: "Session ID is required"
|
|
2901
2906
|
};
|
|
2902
|
-
const l =
|
|
2907
|
+
const l = E(s.sessionId);
|
|
2903
2908
|
if (e && n)
|
|
2904
2909
|
return {
|
|
2905
2910
|
error: "Either pageName or page must be provided, not both"
|
|
@@ -2919,7 +2924,7 @@ async function kr(t, r, s) {
|
|
|
2919
2924
|
error: `Page "${e}" not found`
|
|
2920
2925
|
};
|
|
2921
2926
|
} else if (n) {
|
|
2922
|
-
const h = await
|
|
2927
|
+
const h = await Ye(n, r, s);
|
|
2923
2928
|
if (h.error != null)
|
|
2924
2929
|
return {
|
|
2925
2930
|
error: h.error
|
|
@@ -2953,13 +2958,13 @@ async function kr(t, r, s) {
|
|
|
2953
2958
|
};
|
|
2954
2959
|
}
|
|
2955
2960
|
}
|
|
2956
|
-
function
|
|
2961
|
+
function Nr(t, r) {
|
|
2957
2962
|
t(
|
|
2958
2963
|
"playwright-page-goto",
|
|
2959
2964
|
{
|
|
2960
2965
|
title: "Navigate Page",
|
|
2961
2966
|
description: "Navigate page to URL. Use for manual browser interaction",
|
|
2962
|
-
inputSchema:
|
|
2967
|
+
inputSchema: Xe.shape
|
|
2963
2968
|
},
|
|
2964
2969
|
async (s, o) => {
|
|
2965
2970
|
const e = await kr(s, r, o);
|
|
@@ -2975,19 +2980,19 @@ function Cr(t, r) {
|
|
|
2975
2980
|
}
|
|
2976
2981
|
);
|
|
2977
2982
|
}
|
|
2978
|
-
const
|
|
2983
|
+
const se = p.object({
|
|
2979
2984
|
name: p.string().describe(
|
|
2980
2985
|
"Unique name for the DOM snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
2981
2986
|
),
|
|
2982
2987
|
cssSelector: p.string().describe("CSS selector to capture page content")
|
|
2983
2988
|
});
|
|
2984
|
-
async function
|
|
2989
|
+
async function et(t, r, s) {
|
|
2985
2990
|
let o;
|
|
2986
2991
|
try {
|
|
2987
|
-
o =
|
|
2992
|
+
o = se.parse(t);
|
|
2988
2993
|
} catch (u) {
|
|
2989
2994
|
return {
|
|
2990
|
-
error:
|
|
2995
|
+
error: C(u)
|
|
2991
2996
|
};
|
|
2992
2997
|
}
|
|
2993
2998
|
const { name: e, cssSelector: n } = o;
|
|
@@ -2995,7 +3000,7 @@ async function Xe(t, r, s) {
|
|
|
2995
3000
|
return {
|
|
2996
3001
|
error: "Session ID is required"
|
|
2997
3002
|
};
|
|
2998
|
-
const i =
|
|
3003
|
+
const i = E(s.sessionId);
|
|
2999
3004
|
if (i.domSnapshotQueries.has(e))
|
|
3000
3005
|
return {
|
|
3001
3006
|
error: `DOM snapshot query "${e}" already exists`
|
|
@@ -3008,23 +3013,23 @@ async function Xe(t, r, s) {
|
|
|
3008
3013
|
snapshotQuery: a
|
|
3009
3014
|
};
|
|
3010
3015
|
}
|
|
3011
|
-
function
|
|
3016
|
+
function Dr(t, r) {
|
|
3012
3017
|
t(
|
|
3013
3018
|
"playwright-dom-snapshot-query-create",
|
|
3014
3019
|
{
|
|
3015
3020
|
title: "Create DOM Snapshot Query",
|
|
3016
3021
|
description: "Create a DOM snapshot query. Prefer dom-snapshot-browse if you need to immediately create a query and snapshot and browse it",
|
|
3017
|
-
inputSchema:
|
|
3022
|
+
inputSchema: se.shape
|
|
3018
3023
|
},
|
|
3019
3024
|
async (s, o) => {
|
|
3020
|
-
const e = await
|
|
3025
|
+
const e = await et(s, r, o);
|
|
3021
3026
|
return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3022
3027
|
❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3023
3028
|
✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
3024
3029
|
}
|
|
3025
3030
|
);
|
|
3026
3031
|
}
|
|
3027
|
-
function
|
|
3032
|
+
function Er(t) {
|
|
3028
3033
|
return function(s, o) {
|
|
3029
3034
|
let e, n = 0;
|
|
3030
3035
|
const i = o ? o.length : 0;
|
|
@@ -3045,7 +3050,7 @@ function Nr(t) {
|
|
|
3045
3050
|
textOpen: `<root uid:${c}>`,
|
|
3046
3051
|
textClose: "</root>"
|
|
3047
3052
|
};
|
|
3048
|
-
const m =
|
|
3053
|
+
const m = Ue(d);
|
|
3049
3054
|
return l += m, {
|
|
3050
3055
|
uid: c,
|
|
3051
3056
|
tagName: f,
|
|
@@ -3060,8 +3065,8 @@ function Nr(t) {
|
|
|
3060
3065
|
};
|
|
3061
3066
|
};
|
|
3062
3067
|
}
|
|
3063
|
-
function
|
|
3064
|
-
const s =
|
|
3068
|
+
function Br(t, r) {
|
|
3069
|
+
const s = _(r), o = s.getChilds(s.root), e = Le({
|
|
3065
3070
|
getId: (n) => {
|
|
3066
3071
|
const i = s.getId(n);
|
|
3067
3072
|
if (i == null)
|
|
@@ -3071,28 +3076,28 @@ function Dr(t, r) {
|
|
|
3071
3076
|
return i;
|
|
3072
3077
|
},
|
|
3073
3078
|
getChilds: (n) => s.getChilds(n),
|
|
3074
|
-
createSnapshotNode:
|
|
3079
|
+
createSnapshotNode: Er(),
|
|
3075
3080
|
rootNodes: o ?? []
|
|
3076
3081
|
});
|
|
3077
|
-
return
|
|
3082
|
+
return _(e);
|
|
3078
3083
|
}
|
|
3079
|
-
const
|
|
3084
|
+
const oe = p.object({
|
|
3080
3085
|
pageName: p.string().describe("Name of previously created page, to create snapshot from"),
|
|
3081
3086
|
queryName: p.string().optional().describe("Name of previously created DOM snapshot query, to use"),
|
|
3082
|
-
query:
|
|
3083
|
-
"DOM snapshot query creation options to automatically create query"
|
|
3087
|
+
query: se.optional().describe(
|
|
3088
|
+
"DOM snapshot query creation options JSON to automatically create query"
|
|
3084
3089
|
),
|
|
3085
3090
|
name: p.string().describe(
|
|
3086
3091
|
"Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3087
3092
|
)
|
|
3088
3093
|
});
|
|
3089
|
-
async function
|
|
3094
|
+
async function tt(t, r, s) {
|
|
3090
3095
|
let o;
|
|
3091
3096
|
try {
|
|
3092
|
-
o =
|
|
3097
|
+
o = oe.parse(t);
|
|
3093
3098
|
} catch (d) {
|
|
3094
3099
|
return {
|
|
3095
|
-
error:
|
|
3100
|
+
error: C(d)
|
|
3096
3101
|
};
|
|
3097
3102
|
}
|
|
3098
3103
|
const { pageName: e, queryName: n, query: i, name: a } = o;
|
|
@@ -3100,7 +3105,7 @@ async function et(t, r, s) {
|
|
|
3100
3105
|
return {
|
|
3101
3106
|
error: "Session ID is required"
|
|
3102
3107
|
};
|
|
3103
|
-
const u =
|
|
3108
|
+
const u = E(s.sessionId);
|
|
3104
3109
|
let l;
|
|
3105
3110
|
for (const d of u.browsers.values()) {
|
|
3106
3111
|
for (const m of d.contexts.values())
|
|
@@ -3131,7 +3136,7 @@ async function et(t, r, s) {
|
|
|
3131
3136
|
};
|
|
3132
3137
|
c = d;
|
|
3133
3138
|
} else if (i) {
|
|
3134
|
-
const d = await
|
|
3139
|
+
const d = await et(
|
|
3135
3140
|
i,
|
|
3136
3141
|
r,
|
|
3137
3142
|
s
|
|
@@ -3151,17 +3156,17 @@ async function et(t, r, s) {
|
|
|
3151
3156
|
const y = window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom;
|
|
3152
3157
|
if (!y)
|
|
3153
3158
|
throw new Error("DOM snapshot global function not initialized");
|
|
3154
|
-
const
|
|
3159
|
+
const x = y(b);
|
|
3155
3160
|
return {
|
|
3156
|
-
idToNode: Array.from(
|
|
3157
|
-
idToChildIds: Array.from(
|
|
3161
|
+
idToNode: Array.from(x.idToNode.entries()),
|
|
3162
|
+
idToChildIds: Array.from(x.idToChildIds.entries())
|
|
3158
3163
|
};
|
|
3159
3164
|
},
|
|
3160
3165
|
c
|
|
3161
3166
|
), m = {
|
|
3162
3167
|
idToNode: new Map(d.idToNode),
|
|
3163
3168
|
idToChildIds: new Map(d.idToChildIds)
|
|
3164
|
-
}, h =
|
|
3169
|
+
}, h = Br(c, m), g = {
|
|
3165
3170
|
name: a,
|
|
3166
3171
|
query: c,
|
|
3167
3172
|
tree: h
|
|
@@ -3176,16 +3181,16 @@ async function et(t, r, s) {
|
|
|
3176
3181
|
};
|
|
3177
3182
|
}
|
|
3178
3183
|
}
|
|
3179
|
-
function
|
|
3184
|
+
function Fr(t, r) {
|
|
3180
3185
|
t(
|
|
3181
3186
|
"playwright-dom-snapshot-create",
|
|
3182
3187
|
{
|
|
3183
3188
|
title: "Create DOM Snapshot",
|
|
3184
3189
|
description: "Create a DOM snapshot of page. Use this to capture webpage state for later browsing. Prefer dom-snapshot-browse if you need to immediately create and browse a snapshot",
|
|
3185
|
-
inputSchema:
|
|
3190
|
+
inputSchema: oe.shape
|
|
3186
3191
|
},
|
|
3187
3192
|
async (s, o) => {
|
|
3188
|
-
const e = await
|
|
3193
|
+
const e = await tt(s, r, o);
|
|
3189
3194
|
if (e.error != null)
|
|
3190
3195
|
return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
|
|
3191
3196
|
❌ Error: ${e.error}`;
|
|
@@ -3196,7 +3201,7 @@ function Br(t, r) {
|
|
|
3196
3201
|
}
|
|
3197
3202
|
);
|
|
3198
3203
|
}
|
|
3199
|
-
class
|
|
3204
|
+
class Or {
|
|
3200
3205
|
tokens = 16;
|
|
3201
3206
|
getReportText = (r) => ({
|
|
3202
3207
|
indent: !0,
|
|
@@ -3210,10 +3215,10 @@ class Fr {
|
|
|
3210
3215
|
tokensGrouped: s.tokens
|
|
3211
3216
|
} : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
|
|
3212
3217
|
}
|
|
3213
|
-
const
|
|
3218
|
+
const rt = p.object({
|
|
3214
3219
|
snapshotName: p.string().optional().describe("Name of previously created DOM snapshot, to use"),
|
|
3215
|
-
snapshot:
|
|
3216
|
-
"DOM snapshot creation options to automatically create snapshot"
|
|
3220
|
+
snapshot: oe.optional().describe(
|
|
3221
|
+
"DOM snapshot creation options JSON to automatically create snapshot"
|
|
3217
3222
|
),
|
|
3218
3223
|
parentUid: p.number().optional().describe("UID of parent node to browse. Omit to browse the root node"),
|
|
3219
3224
|
childsIndexRange: p.tuple([p.number(), p.number()]).optional().describe(
|
|
@@ -3230,13 +3235,13 @@ const tt = p.object({
|
|
|
3230
3235
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
3231
3236
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
3232
3237
|
});
|
|
3233
|
-
async function
|
|
3238
|
+
async function Rr(t, r, s) {
|
|
3234
3239
|
let o;
|
|
3235
3240
|
try {
|
|
3236
|
-
o =
|
|
3241
|
+
o = rt.parse(t);
|
|
3237
3242
|
} catch (g) {
|
|
3238
3243
|
return {
|
|
3239
|
-
error:
|
|
3244
|
+
error: C(g)
|
|
3240
3245
|
};
|
|
3241
3246
|
}
|
|
3242
3247
|
const {
|
|
@@ -3252,7 +3257,7 @@ async function Or(t, r, s) {
|
|
|
3252
3257
|
return {
|
|
3253
3258
|
error: "Session ID is required"
|
|
3254
3259
|
};
|
|
3255
|
-
const f =
|
|
3260
|
+
const f = E(s.sessionId);
|
|
3256
3261
|
if (e && n)
|
|
3257
3262
|
return {
|
|
3258
3263
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
@@ -3275,7 +3280,7 @@ async function Or(t, r, s) {
|
|
|
3275
3280
|
error: `DOM snapshot "${e}" not found`
|
|
3276
3281
|
};
|
|
3277
3282
|
} else if (n) {
|
|
3278
|
-
const g = await
|
|
3283
|
+
const g = await tt(
|
|
3279
3284
|
n,
|
|
3280
3285
|
r,
|
|
3281
3286
|
s
|
|
@@ -3290,7 +3295,7 @@ async function Or(t, r, s) {
|
|
|
3290
3295
|
error: "Either snapshotName or snapshot must be provided"
|
|
3291
3296
|
};
|
|
3292
3297
|
try {
|
|
3293
|
-
const g = o.parentUid, b =
|
|
3298
|
+
const g = o.parentUid, b = Ge({
|
|
3294
3299
|
tree: d.tree,
|
|
3295
3300
|
request: {
|
|
3296
3301
|
parentNodeId: g,
|
|
@@ -3302,8 +3307,8 @@ async function Or(t, r, s) {
|
|
|
3302
3307
|
maxTokensGroup: c
|
|
3303
3308
|
}
|
|
3304
3309
|
},
|
|
3305
|
-
indexRangeGroupStrategy: new
|
|
3306
|
-
}), y =
|
|
3310
|
+
indexRangeGroupStrategy: new Or()
|
|
3311
|
+
}), y = qe(b);
|
|
3307
3312
|
return {
|
|
3308
3313
|
domSnapshot: d,
|
|
3309
3314
|
queryCreated: m,
|
|
@@ -3318,16 +3323,16 @@ async function Or(t, r, s) {
|
|
|
3318
3323
|
};
|
|
3319
3324
|
}
|
|
3320
3325
|
}
|
|
3321
|
-
function
|
|
3326
|
+
function zr(t, r) {
|
|
3322
3327
|
t(
|
|
3323
3328
|
"playwright-dom-snapshot-browse",
|
|
3324
3329
|
{
|
|
3325
3330
|
title: "Browse DOM Snapshot",
|
|
3326
3331
|
description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
|
|
3327
|
-
inputSchema:
|
|
3332
|
+
inputSchema: rt.shape
|
|
3328
3333
|
},
|
|
3329
3334
|
async (s, o) => {
|
|
3330
|
-
const e = await
|
|
3335
|
+
const e = await Rr(s, r, o);
|
|
3331
3336
|
if (e.error != null)
|
|
3332
3337
|
return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
|
|
3333
3338
|
❌ Error: ${e.error}`;
|
|
@@ -3348,13 +3353,13 @@ ${e.report}`, n;
|
|
|
3348
3353
|
}
|
|
3349
3354
|
);
|
|
3350
3355
|
}
|
|
3351
|
-
function
|
|
3352
|
-
r.browserCreate &&
|
|
3356
|
+
function Pr(t, r) {
|
|
3357
|
+
r.browserCreate && dr(t, r), r.browserList && mr(t, r), r.browserClose && pr(t, r), r.contextCreate && gr(t, r), r.contextList && yr(t, r), r.contextClose && xr(t, r), r.pageCreate && Ir(t, r), r.pageList && Tr(t, r), r.pageClose && Cr(t, r), r.pageGoto && Nr(t, r), r.domSnapshotQueryCreate && Dr(t, r), r.domSnapshotCreate && Fr(t, r), r.domSnapshotBrowse && zr(t, r), console.log("Playwright manager");
|
|
3353
3358
|
}
|
|
3354
|
-
function
|
|
3359
|
+
function Lr(t) {
|
|
3355
3360
|
const { logFilePath: r } = t;
|
|
3356
3361
|
return async function(o, e, n, i) {
|
|
3357
|
-
await
|
|
3362
|
+
await q({
|
|
3358
3363
|
logFilePath: r,
|
|
3359
3364
|
message: "ERROR",
|
|
3360
3365
|
data: {
|
|
@@ -3373,28 +3378,28 @@ function Ur(t) {
|
|
|
3373
3378
|
});
|
|
3374
3379
|
};
|
|
3375
3380
|
}
|
|
3376
|
-
function
|
|
3381
|
+
function Ur() {
|
|
3377
3382
|
return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
|
|
3378
3383
|
}
|
|
3379
|
-
function
|
|
3380
|
-
const r =
|
|
3384
|
+
function Ar(t) {
|
|
3385
|
+
const r = G(), s = qr();
|
|
3381
3386
|
return r.use(s), r;
|
|
3382
3387
|
}
|
|
3383
|
-
function
|
|
3384
|
-
const r = new
|
|
3388
|
+
function Gr(t) {
|
|
3389
|
+
const r = new ot({
|
|
3385
3390
|
name: t.name,
|
|
3386
3391
|
version: t.version,
|
|
3387
3392
|
title: "Project Tools"
|
|
3388
|
-
}), s =
|
|
3393
|
+
}), s = _r(r, t);
|
|
3389
3394
|
return {
|
|
3390
3395
|
mcpServer: r,
|
|
3391
3396
|
mcpRouter: s
|
|
3392
3397
|
};
|
|
3393
3398
|
}
|
|
3394
|
-
function
|
|
3395
|
-
const r =
|
|
3399
|
+
function qr(t) {
|
|
3400
|
+
const r = G.Router();
|
|
3396
3401
|
return r.use(
|
|
3397
|
-
|
|
3402
|
+
st.default({
|
|
3398
3403
|
origin: "*",
|
|
3399
3404
|
credentials: !0,
|
|
3400
3405
|
allowedHeaders: [
|
|
@@ -3405,14 +3410,14 @@ function Gr(t) {
|
|
|
3405
3410
|
],
|
|
3406
3411
|
exposedHeaders: ["mcp-session-id"]
|
|
3407
3412
|
})
|
|
3408
|
-
), r.use(
|
|
3409
|
-
}
|
|
3410
|
-
function qr(t, r) {
|
|
3411
|
-
const s = A.Router();
|
|
3412
|
-
return s.use(gt({ authToken: r.authToken })), s.all("/mcp", wt(t, r)), s;
|
|
3413
|
+
), r.use(G.json()), r;
|
|
3413
3414
|
}
|
|
3414
3415
|
function _r(t, r) {
|
|
3415
|
-
|
|
3416
|
+
const s = G.Router();
|
|
3417
|
+
return s.use(wt({ authToken: r.authToken })), s.all("/mcp", yt(t, r)), s;
|
|
3418
|
+
}
|
|
3419
|
+
function jr(t, r) {
|
|
3420
|
+
return t.use(Lr({ logFilePath: r.logFilePath })), new Promise((s, o) => {
|
|
3416
3421
|
let e;
|
|
3417
3422
|
const n = () => {
|
|
3418
3423
|
s(e);
|
|
@@ -3426,7 +3431,7 @@ function _r(t, r) {
|
|
|
3426
3431
|
}
|
|
3427
3432
|
});
|
|
3428
3433
|
}
|
|
3429
|
-
function
|
|
3434
|
+
function Jr(t, r) {
|
|
3430
3435
|
const s = t.address().family, o = t.address().port;
|
|
3431
3436
|
let e = t.address().address;
|
|
3432
3437
|
e === "::" ? e = "localhost" : s === "IPv6" && (e = `[${e}]`);
|
|
@@ -3440,25 +3445,25 @@ SSE Endpoint: ${n}/sse
|
|
|
3440
3445
|
|
|
3441
3446
|
Log File: ${T.resolve(r.logFilePath)}`;
|
|
3442
3447
|
}
|
|
3443
|
-
async function
|
|
3444
|
-
const r = T.join(t.logDir,
|
|
3448
|
+
async function cs(t) {
|
|
3449
|
+
const r = T.join(t.logDir, Ur()), s = Ar(), { mcpServer: o, mcpRouter: e } = Gr({
|
|
3445
3450
|
...t,
|
|
3446
3451
|
logFilePath: r
|
|
3447
3452
|
});
|
|
3448
3453
|
s.use(e);
|
|
3449
|
-
const n =
|
|
3454
|
+
const n = zt(o, {
|
|
3450
3455
|
logFilePath: r
|
|
3451
3456
|
});
|
|
3452
|
-
t.tools.processManager &&
|
|
3457
|
+
t.tools.processManager && Rt(n, t.tools?.processManager), t.tools.fsManager && ur(n, t.tools.fsManager), t.tools.playwrightManager && Pr(n, {
|
|
3453
3458
|
...t.tools.playwrightManager
|
|
3454
3459
|
});
|
|
3455
|
-
const i = await
|
|
3460
|
+
const i = await jr(s, {
|
|
3456
3461
|
host: t.host,
|
|
3457
3462
|
port: t.port,
|
|
3458
3463
|
logFilePath: r
|
|
3459
3464
|
});
|
|
3460
3465
|
return console.log(
|
|
3461
|
-
|
|
3466
|
+
Jr(i, {
|
|
3462
3467
|
name: t.name,
|
|
3463
3468
|
version: t.version,
|
|
3464
3469
|
authToken: t.authToken,
|
|
@@ -3468,8 +3473,8 @@ async function ls(t) {
|
|
|
3468
3473
|
), i;
|
|
3469
3474
|
}
|
|
3470
3475
|
export {
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3476
|
+
ls as A,
|
|
3477
|
+
as as S,
|
|
3478
|
+
is as a,
|
|
3479
|
+
cs as s
|
|
3475
3480
|
};
|