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