@flemist/mcp-project-tools 3.0.12 → 3.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +15 -14
- package/build/index.d.ts +2 -1
- package/build/index.js +1 -1
- package/build/{startMcpServer-DqxPC2vp.js → startMcpServer-DhLy-2P1.js} +1295 -1195
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { McpServer as
|
|
3
|
-
import { randomUUID as
|
|
1
|
+
import oe from "express";
|
|
2
|
+
import { McpServer as Pt } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { randomUUID as At } from "crypto";
|
|
4
4
|
import * as W from "fs";
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
7
|
-
import { StreamableHTTPServerTransport as
|
|
8
|
-
import { spawn as
|
|
5
|
+
import * as F from "path";
|
|
6
|
+
import zt from "path";
|
|
7
|
+
import { StreamableHTTPServerTransport as Ut } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
8
|
+
import { spawn as qt } from "child_process";
|
|
9
9
|
import { z as p } from "zod";
|
|
10
|
-
import
|
|
11
|
-
import { Pool as
|
|
10
|
+
import he from "tree-kill";
|
|
11
|
+
import { Pool as _t, poolRunWait as Y } from "@flemist/time-limits";
|
|
12
12
|
import { priorityCreate as V } from "@flemist/priority-queue";
|
|
13
|
-
import { useAbortController as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { webkit as
|
|
17
|
-
function
|
|
13
|
+
import { useAbortController as Gt, combineAbortSignals as Jt, Locker as jt } from "@flemist/async-utils";
|
|
14
|
+
import Kt from "node:os";
|
|
15
|
+
import Wt from "picomatch";
|
|
16
|
+
import { webkit as Ht, firefox as Qt, chromium as Yt } from "playwright";
|
|
17
|
+
function Vt(r) {
|
|
18
18
|
const { authToken: t } = r;
|
|
19
19
|
return function(o, e, n) {
|
|
20
20
|
if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
|
|
@@ -24,37 +24,37 @@ function Kt(r) {
|
|
|
24
24
|
n();
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
async function
|
|
27
|
+
async function ne(r) {
|
|
28
28
|
const { logFilePath: t, message: s, data: o } = r;
|
|
29
29
|
try {
|
|
30
|
-
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2),
|
|
30
|
+
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), a = `[${e}] ${s}
|
|
31
31
|
${n}
|
|
32
32
|
|
|
33
33
|
`;
|
|
34
|
-
await W.promises.mkdir(
|
|
34
|
+
await W.promises.mkdir(F.dirname(t), { recursive: !0 }), await W.promises.appendFile(t, a);
|
|
35
35
|
} catch (e) {
|
|
36
36
|
console.error(`Failed to log "${s}":`, e);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
function
|
|
39
|
+
const ie = /* @__PURE__ */ new Map();
|
|
40
|
+
function Zt(r) {
|
|
41
41
|
return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
44
|
-
const s = r.createMcpServer(), o = new
|
|
45
|
-
sessionIdGenerator: () => t ||
|
|
43
|
+
async function Xt(r, t) {
|
|
44
|
+
const s = r.createMcpServer(), o = new Ut({
|
|
45
|
+
sessionIdGenerator: () => t || At(),
|
|
46
46
|
onsessioninitialized: (n) => {
|
|
47
|
-
|
|
47
|
+
ie.set(n, o);
|
|
48
48
|
},
|
|
49
49
|
enableJsonResponse: !0
|
|
50
50
|
});
|
|
51
51
|
async function e() {
|
|
52
52
|
const n = o.sessionId;
|
|
53
|
-
n &&
|
|
53
|
+
n && ie.delete(n);
|
|
54
54
|
try {
|
|
55
55
|
await s.close();
|
|
56
|
-
} catch (
|
|
57
|
-
console.error("Failed to close session",
|
|
56
|
+
} catch (a) {
|
|
57
|
+
console.error("Failed to close session", a);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
o.onclose = e;
|
|
@@ -64,28 +64,28 @@ async function Ht(r, t) {
|
|
|
64
64
|
throw await e(), n;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
async function
|
|
68
|
-
await
|
|
67
|
+
async function er(r, t, s, o) {
|
|
68
|
+
await ne({
|
|
69
69
|
logFilePath: s.logFilePath,
|
|
70
70
|
message: "REQUEST",
|
|
71
71
|
data: r.body
|
|
72
72
|
});
|
|
73
|
-
let e = o ?
|
|
74
|
-
e || (e = await
|
|
73
|
+
let e = o ? ie.get(o) : null;
|
|
74
|
+
e || (e = await Xt(s, o)), await e.handleRequest(r, t, r.body);
|
|
75
75
|
}
|
|
76
|
-
async function
|
|
77
|
-
const o = s ?
|
|
76
|
+
async function tr(r, t, s) {
|
|
77
|
+
const o = s ? ie.get(s) : null;
|
|
78
78
|
if (!o) {
|
|
79
79
|
t.status(400).json({ error: "No valid session found" });
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
await o.handleRequest(r, t);
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function rr(r) {
|
|
85
85
|
return async function(s, o) {
|
|
86
86
|
try {
|
|
87
|
-
const e =
|
|
88
|
-
s.method === "POST" ? await
|
|
87
|
+
const e = Zt(s);
|
|
88
|
+
s.method === "POST" ? await er(s, o, r, e) : s.method === "GET" ? await tr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
|
|
89
89
|
} catch (e) {
|
|
90
90
|
console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
|
|
91
91
|
error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
|
|
@@ -94,9 +94,9 @@ function Vt(r) {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
const Q = /* @__PURE__ */ new Map();
|
|
97
|
-
let
|
|
98
|
-
const Te = 10,
|
|
99
|
-
function
|
|
97
|
+
let sr = 0;
|
|
98
|
+
const Te = 10, or = 1800 * 1e3, R = 1e4, nr = 500, ir = 5e3;
|
|
99
|
+
function ar(r) {
|
|
100
100
|
const { commandLine: t, commandLineRules: s } = r;
|
|
101
101
|
let o = !1;
|
|
102
102
|
for (const e of s)
|
|
@@ -113,11 +113,11 @@ function rr(r) {
|
|
|
113
113
|
}
|
|
114
114
|
return o;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
return ++
|
|
116
|
+
function lr() {
|
|
117
|
+
return ++sr;
|
|
118
118
|
}
|
|
119
119
|
let Ce = !1;
|
|
120
|
-
function
|
|
120
|
+
function cr() {
|
|
121
121
|
if (Ce)
|
|
122
122
|
return;
|
|
123
123
|
Ce = !0;
|
|
@@ -126,7 +126,7 @@ function or() {
|
|
|
126
126
|
for (const [t, s] of Array.from(Q.entries()))
|
|
127
127
|
if (s.isRunning && s.pid)
|
|
128
128
|
try {
|
|
129
|
-
|
|
129
|
+
he(s.pid, "SIGKILL");
|
|
130
130
|
} catch (o) {
|
|
131
131
|
console.error(`Error killing process ${t}:`, o);
|
|
132
132
|
}
|
|
@@ -134,29 +134,29 @@ function or() {
|
|
|
134
134
|
};
|
|
135
135
|
process.on("SIGINT", r), process.on("SIGTERM", r);
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function me() {
|
|
138
138
|
const r = Date.now(), t = [];
|
|
139
139
|
for (const [s, o] of Array.from(Q.entries()))
|
|
140
|
-
!o.isRunning && o.endTime && r - o.endTime.getTime() >
|
|
140
|
+
!o.isRunning && o.endTime && r - o.endTime.getTime() > or && t.push(s);
|
|
141
141
|
for (const s of t)
|
|
142
142
|
Q.delete(s);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function ge(r) {
|
|
145
145
|
const { process: t } = r, s = Date.now();
|
|
146
|
-
if (s - t.lastOutputTime.getTime() >=
|
|
146
|
+
if (s - t.lastOutputTime.getTime() >= nr && (t.output += t.localOutput, t.localOutput = "", t.lastOutputTime = new Date(s), t.output.length > R)) {
|
|
147
147
|
const n = `
|
|
148
|
-
... [${t.output.length -
|
|
149
|
-
`,
|
|
150
|
-
if (
|
|
151
|
-
const
|
|
152
|
-
t.output = t.output.substring(0,
|
|
153
|
-
t.output.length - (
|
|
148
|
+
... [${t.output.length - R} characters trimmed] ...
|
|
149
|
+
`, a = R - n.length;
|
|
150
|
+
if (a > 0) {
|
|
151
|
+
const i = Math.floor(a / 2);
|
|
152
|
+
t.output = t.output.substring(0, i) + n + t.output.substring(
|
|
153
|
+
t.output.length - (a - i)
|
|
154
154
|
);
|
|
155
155
|
} else
|
|
156
|
-
t.output = t.output.substring(0,
|
|
156
|
+
t.output = t.output.substring(0, R);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function ur(r, t) {
|
|
160
160
|
const s = t.limit;
|
|
161
161
|
if (r.length <= s) return r;
|
|
162
162
|
const e = `
|
|
@@ -164,8 +164,8 @@ function nr(r, t) {
|
|
|
164
164
|
`, n = s - e.length;
|
|
165
165
|
if (n <= 0)
|
|
166
166
|
return r.substring(0, s);
|
|
167
|
-
const
|
|
168
|
-
return r.substring(0,
|
|
167
|
+
const a = Math.floor(n / 2);
|
|
168
|
+
return r.substring(0, a) + e + r.substring(r.length - (n - a));
|
|
169
169
|
}
|
|
170
170
|
function B(r) {
|
|
171
171
|
return `Invalid arguments: ${r instanceof Error ? r.message : "Unknown error"}.
|
|
@@ -176,18 +176,18 @@ const Ze = p.object({
|
|
|
176
176
|
id: p.number().describe(
|
|
177
177
|
"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"
|
|
178
178
|
),
|
|
179
|
-
outputLimit: p.number().max(
|
|
180
|
-
`Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${
|
|
179
|
+
outputLimit: p.number().max(R).default(R).describe(
|
|
180
|
+
`Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${R} characters. Default: ${R}.`
|
|
181
181
|
)
|
|
182
182
|
});
|
|
183
|
-
async function
|
|
184
|
-
|
|
183
|
+
async function we(r, t) {
|
|
184
|
+
me();
|
|
185
185
|
let s;
|
|
186
186
|
try {
|
|
187
187
|
s = Ze.parse(r);
|
|
188
|
-
} catch (
|
|
188
|
+
} catch (c) {
|
|
189
189
|
return {
|
|
190
|
-
error: B(
|
|
190
|
+
error: B(c)
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
const { id: o, outputLimit: e } = s, n = Q.get(o);
|
|
@@ -195,22 +195,22 @@ async function ge(r, t) {
|
|
|
195
195
|
return {
|
|
196
196
|
error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
197
197
|
};
|
|
198
|
-
|
|
199
|
-
const
|
|
198
|
+
ge({ process: n });
|
|
199
|
+
const a = n.output + n.localOutput, i = ur(a, { limit: e });
|
|
200
200
|
return n.output = "", n.localOutput = "", {
|
|
201
201
|
id: n.id,
|
|
202
|
-
cwd:
|
|
202
|
+
cwd: F.relative(t.workingDir || "", n.cwd),
|
|
203
203
|
commandLine: n.commandLine,
|
|
204
204
|
pid: n.pid,
|
|
205
205
|
startTime: n.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
206
206
|
endTime: n.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
207
207
|
exitCode: n.exitCode,
|
|
208
208
|
isRunning: n.isRunning,
|
|
209
|
-
output:
|
|
209
|
+
output: i,
|
|
210
210
|
error: n.error
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function dr(r, t) {
|
|
214
214
|
r(
|
|
215
215
|
"process-status",
|
|
216
216
|
{
|
|
@@ -219,7 +219,7 @@ function ir(r, t) {
|
|
|
219
219
|
inputSchema: Ze.shape
|
|
220
220
|
},
|
|
221
221
|
async (s) => {
|
|
222
|
-
const o = await
|
|
222
|
+
const o = await we(s, t);
|
|
223
223
|
if (!("output" in o))
|
|
224
224
|
return `Method: process-status(${JSON.stringify(s)})
|
|
225
225
|
❌ Error: ${o.error}`;
|
|
@@ -233,13 +233,13 @@ ${e.trim()}`;
|
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
235
|
function Xe(r) {
|
|
236
|
-
|
|
236
|
+
he(r, "SIGTERM", (t) => {
|
|
237
237
|
t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
|
|
238
238
|
}), setTimeout(() => {
|
|
239
|
-
|
|
239
|
+
he(r, "SIGKILL", (t) => {
|
|
240
240
|
t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
|
|
241
241
|
});
|
|
242
|
-
},
|
|
242
|
+
}, ir);
|
|
243
243
|
}
|
|
244
244
|
const et = p.object({
|
|
245
245
|
id: p.number().describe(
|
|
@@ -251,8 +251,8 @@ const et = p.object({
|
|
|
251
251
|
autoKill: p.boolean().default(!1).describe(
|
|
252
252
|
"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"
|
|
253
253
|
),
|
|
254
|
-
outputLimit: p.number().max(
|
|
255
|
-
`Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${
|
|
254
|
+
outputLimit: p.number().max(R).default(R).describe(
|
|
255
|
+
`Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${R} characters. Default: ${R}.`
|
|
256
256
|
)
|
|
257
257
|
});
|
|
258
258
|
async function tt(r, t) {
|
|
@@ -264,27 +264,27 @@ async function tt(r, t) {
|
|
|
264
264
|
error: B(h)
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
|
-
const { id: o, waitTime: e, autoKill: n, outputLimit:
|
|
268
|
-
if (!
|
|
267
|
+
const { id: o, waitTime: e, autoKill: n, outputLimit: a } = s, i = Q.get(o);
|
|
268
|
+
if (!i)
|
|
269
269
|
return {
|
|
270
270
|
error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
271
271
|
};
|
|
272
|
-
const
|
|
273
|
-
let
|
|
272
|
+
const c = Date.now();
|
|
273
|
+
let l = !1, u = !1;
|
|
274
274
|
e != null && await new Promise((m) => {
|
|
275
275
|
const g = setInterval(() => {
|
|
276
|
-
|
|
276
|
+
i.isRunning ? Date.now() - c >= e * 1e3 && (clearInterval(g), l = !0, n && i.pid && (Xe(i.pid), u = !0), m()) : (clearInterval(g), m());
|
|
277
277
|
}, 100);
|
|
278
278
|
});
|
|
279
|
-
const
|
|
279
|
+
const d = (Date.now() - c) / 1e3;
|
|
280
280
|
return {
|
|
281
|
-
...await
|
|
282
|
-
waitDuration:
|
|
283
|
-
waitTimeExceeded:
|
|
281
|
+
...await we({ id: o, outputLimit: a }, t),
|
|
282
|
+
waitDuration: d,
|
|
283
|
+
waitTimeExceeded: l,
|
|
284
284
|
autoKillExecuted: u
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function fr(r, t) {
|
|
288
288
|
r(
|
|
289
289
|
"process-wait",
|
|
290
290
|
{
|
|
@@ -319,42 +319,42 @@ const rt = p.object({
|
|
|
319
319
|
autoKill: p.boolean().default(!1).describe(
|
|
320
320
|
"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"
|
|
321
321
|
),
|
|
322
|
-
outputLimit: p.number().max(
|
|
323
|
-
`Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${
|
|
322
|
+
outputLimit: p.number().max(R).default(R).describe(
|
|
323
|
+
`Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${R} characters. Default: ${R}.`
|
|
324
324
|
)
|
|
325
325
|
});
|
|
326
|
-
async function
|
|
327
|
-
|
|
326
|
+
async function hr(r, t) {
|
|
327
|
+
me();
|
|
328
328
|
let s;
|
|
329
329
|
try {
|
|
330
330
|
s = rt.parse(r);
|
|
331
|
-
} catch (
|
|
331
|
+
} catch (f) {
|
|
332
332
|
return {
|
|
333
|
-
error: B(
|
|
333
|
+
error: B(f)
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
|
-
const { commandLine: o, waitTime: e, autoKill: n, outputLimit:
|
|
337
|
-
if (!
|
|
338
|
-
const
|
|
336
|
+
const { commandLine: o, waitTime: e, autoKill: n, outputLimit: a } = s, { commandLineRules: i } = t, c = F.resolve(t.workingDir || "", s.cwd || "");
|
|
337
|
+
if (!ar({ commandLine: o, commandLineRules: i })) {
|
|
338
|
+
const f = i.map(
|
|
339
339
|
(h) => `${h.rule.toUpperCase()}: /${h.regexp}/ (${h.note})`
|
|
340
340
|
).join(`
|
|
341
341
|
`);
|
|
342
342
|
return {
|
|
343
343
|
error: `Command line not allowed: "${o}". For security, command lines are validated against configured rules in order. Command line was denied by the rule evaluation. Current command line rules:
|
|
344
|
-
${
|
|
344
|
+
${f}
|
|
345
345
|
|
|
346
346
|
To use this command line, ask the user to modify the command line rules in the configuration.`
|
|
347
347
|
};
|
|
348
348
|
}
|
|
349
349
|
if (Array.from(Q.values()).filter(
|
|
350
|
-
(
|
|
350
|
+
(f) => f.isRunning
|
|
351
351
|
).length >= Te)
|
|
352
352
|
return {
|
|
353
353
|
error: `Maximum concurrent process limit reached (${Te} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
|
|
354
354
|
};
|
|
355
|
-
const u =
|
|
355
|
+
const u = lr(), d = {
|
|
356
356
|
id: u,
|
|
357
|
-
cwd:
|
|
357
|
+
cwd: c,
|
|
358
358
|
commandLine: o,
|
|
359
359
|
startTime: /* @__PURE__ */ new Date(),
|
|
360
360
|
isRunning: !0,
|
|
@@ -362,40 +362,40 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
362
362
|
localOutput: "",
|
|
363
363
|
lastOutputTime: /* @__PURE__ */ new Date()
|
|
364
364
|
};
|
|
365
|
-
Q.set(u,
|
|
365
|
+
Q.set(u, d);
|
|
366
366
|
try {
|
|
367
|
-
const
|
|
367
|
+
const f = qt(o, [], {
|
|
368
368
|
shell: !0,
|
|
369
|
-
cwd:
|
|
369
|
+
cwd: c,
|
|
370
370
|
stdio: ["pipe", "pipe", "pipe"]
|
|
371
371
|
});
|
|
372
|
-
|
|
372
|
+
d.pid = f.pid;
|
|
373
373
|
const h = (m) => {
|
|
374
374
|
const g = m.toString();
|
|
375
|
-
|
|
375
|
+
d.localOutput += g, ge({ process: d }), console.log(g);
|
|
376
376
|
};
|
|
377
|
-
return
|
|
378
|
-
if (
|
|
377
|
+
return f.stdout?.on("data", h), f.stderr?.on("data", h), f.on("close", (m) => {
|
|
378
|
+
if (d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.exitCode = m !== null ? m : void 0, d.output += d.localOutput, d.localOutput = "", d.output.length > R) {
|
|
379
379
|
const y = `
|
|
380
|
-
... [${
|
|
381
|
-
`, w =
|
|
380
|
+
... [${d.output.length - R} characters trimmed] ...
|
|
381
|
+
`, w = R - y.length;
|
|
382
382
|
if (w > 0) {
|
|
383
383
|
const M = Math.floor(w / 2);
|
|
384
|
-
|
|
385
|
-
|
|
384
|
+
d.output = d.output.substring(0, M) + y + d.output.substring(
|
|
385
|
+
d.output.length - (w - M)
|
|
386
386
|
);
|
|
387
387
|
} else
|
|
388
|
-
|
|
388
|
+
d.output = d.output.substring(0, R);
|
|
389
389
|
}
|
|
390
390
|
console.log(`Process ${u} (${o}) exited with code ${m}`);
|
|
391
|
-
}),
|
|
392
|
-
|
|
393
|
-
}), e != null ? tt({ id: u, waitTime: e, autoKill: n, outputLimit:
|
|
394
|
-
} catch (
|
|
395
|
-
return
|
|
391
|
+
}), f.on("error", (m) => {
|
|
392
|
+
d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = m.message, console.error(`Process ${u} error:`, m.message);
|
|
393
|
+
}), e != null ? tt({ id: u, waitTime: e, autoKill: n, outputLimit: a }, t) : we({ id: u, outputLimit: a }, t);
|
|
394
|
+
} catch (f) {
|
|
395
|
+
return d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = f instanceof Error ? f.message : "Unknown error", { error: d.error };
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function pr(r, t) {
|
|
399
399
|
const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
|
|
400
400
|
`);
|
|
401
401
|
r(
|
|
@@ -407,7 +407,7 @@ ${s}`,
|
|
|
407
407
|
inputSchema: rt.shape
|
|
408
408
|
},
|
|
409
409
|
async (o) => {
|
|
410
|
-
const e = await
|
|
410
|
+
const e = await hr(o, t);
|
|
411
411
|
if (!("output" in e))
|
|
412
412
|
return `Method: process-run(${JSON.stringify(o)})
|
|
413
413
|
❌ Error: ${e.error}`;
|
|
@@ -434,50 +434,50 @@ const st = p.object({
|
|
|
434
434
|
'Specific process data fields to include in the response. If omitted, returns all available fields. Available fields: id, cwd, commandLine, pid, startTime, endTime, exitCode, isRunning, output, error. Examples: ["id", "commandLine", "isRunning"] for minimal info, ["id", "output", "exitCode"] for execution results'
|
|
435
435
|
)
|
|
436
436
|
});
|
|
437
|
-
async function
|
|
438
|
-
|
|
437
|
+
async function mr(r, t) {
|
|
438
|
+
me();
|
|
439
439
|
let s;
|
|
440
440
|
try {
|
|
441
441
|
s = st.parse(r);
|
|
442
|
-
} catch (
|
|
442
|
+
} catch (l) {
|
|
443
443
|
return {
|
|
444
|
-
error: B(
|
|
444
|
+
error: B(l)
|
|
445
445
|
};
|
|
446
446
|
}
|
|
447
|
-
const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields:
|
|
448
|
-
let
|
|
447
|
+
const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: a } = s;
|
|
448
|
+
let i = Array.from(Q.values());
|
|
449
449
|
if (o) {
|
|
450
|
-
const
|
|
451
|
-
|
|
450
|
+
const l = new Date(o.replace(/[_\s]/g, "T"));
|
|
451
|
+
i = i.filter((u) => u.startTime >= l);
|
|
452
452
|
}
|
|
453
453
|
if (e) {
|
|
454
|
-
const
|
|
455
|
-
|
|
454
|
+
const l = new Date(e.replace(/[_\s]/g, "T"));
|
|
455
|
+
i = i.filter((u) => u.endTime && u.endTime >= l);
|
|
456
456
|
}
|
|
457
|
-
return n && (
|
|
458
|
-
|
|
457
|
+
return n && (i = i.filter((l) => l.isRunning)), { processes: i.map((l) => {
|
|
458
|
+
ge({ process: l });
|
|
459
459
|
let u = {
|
|
460
|
-
id:
|
|
461
|
-
cwd:
|
|
462
|
-
commandLine:
|
|
463
|
-
pid:
|
|
464
|
-
startTime:
|
|
465
|
-
endTime:
|
|
466
|
-
exitCode:
|
|
467
|
-
isRunning:
|
|
468
|
-
output:
|
|
469
|
-
error:
|
|
470
|
-
};
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
for (const
|
|
474
|
-
|
|
475
|
-
u =
|
|
460
|
+
id: l.id,
|
|
461
|
+
cwd: zt.relative(t.workingDir || "", l.cwd),
|
|
462
|
+
commandLine: l.commandLine,
|
|
463
|
+
pid: l.pid,
|
|
464
|
+
startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
465
|
+
endTime: l.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
466
|
+
exitCode: l.exitCode,
|
|
467
|
+
isRunning: l.isRunning,
|
|
468
|
+
output: l.output + l.localOutput,
|
|
469
|
+
error: l.error
|
|
470
|
+
};
|
|
471
|
+
if (a) {
|
|
472
|
+
const d = {};
|
|
473
|
+
for (const f of a)
|
|
474
|
+
f in u && (d[f] = u[f]);
|
|
475
|
+
u = d;
|
|
476
476
|
}
|
|
477
477
|
return u;
|
|
478
478
|
}) };
|
|
479
479
|
}
|
|
480
|
-
function
|
|
480
|
+
function gr(r, t) {
|
|
481
481
|
r(
|
|
482
482
|
"process-list",
|
|
483
483
|
{
|
|
@@ -486,7 +486,7 @@ function dr(r, t) {
|
|
|
486
486
|
inputSchema: st.shape
|
|
487
487
|
},
|
|
488
488
|
async (s) => {
|
|
489
|
-
const o = await
|
|
489
|
+
const o = await mr(s, t);
|
|
490
490
|
if (o.error != null)
|
|
491
491
|
return `Method: process-list(${JSON.stringify(s)})
|
|
492
492
|
❌ Error: ${o.error}`;
|
|
@@ -505,7 +505,7 @@ const ot = p.object({
|
|
|
505
505
|
"Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
|
|
506
506
|
)
|
|
507
507
|
});
|
|
508
|
-
function
|
|
508
|
+
function wr(r) {
|
|
509
509
|
let t;
|
|
510
510
|
try {
|
|
511
511
|
t = ot.parse(r);
|
|
@@ -535,7 +535,7 @@ function fr(r) {
|
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function yr(r, t) {
|
|
539
539
|
r(
|
|
540
540
|
"process-kill",
|
|
541
541
|
{
|
|
@@ -544,45 +544,45 @@ function hr(r, t) {
|
|
|
544
544
|
inputSchema: ot.shape
|
|
545
545
|
},
|
|
546
546
|
async (s) => {
|
|
547
|
-
const o =
|
|
547
|
+
const o = wr(s);
|
|
548
548
|
return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
|
|
549
549
|
❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
|
|
550
550
|
${JSON.stringify(o, null, 2)}`;
|
|
551
551
|
}
|
|
552
552
|
);
|
|
553
553
|
}
|
|
554
|
-
function
|
|
555
|
-
|
|
554
|
+
function br(r, t) {
|
|
555
|
+
cr(), t.run && pr(r, t), t.status && dr(r, t), t.wait && fr(r, t), t.list && gr(r, t), t.kill && yr(r);
|
|
556
556
|
const s = t.commandLineRules?.map(
|
|
557
557
|
(o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
|
|
558
558
|
) || [];
|
|
559
559
|
console.log(
|
|
560
560
|
`Process manager:
|
|
561
|
-
- Working directory: ${
|
|
561
|
+
- Working directory: ${F.resolve(t.workingDir || "")}
|
|
562
562
|
- Command line rules: ${t.commandLineRules?.length || 0} rules configured:
|
|
563
563
|
${s.map((o) => `- ${o}`).join(`
|
|
564
564
|
`)}
|
|
565
565
|
`
|
|
566
566
|
);
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function Sr(r, t) {
|
|
569
569
|
return function(o, e, n) {
|
|
570
|
-
const
|
|
571
|
-
await
|
|
570
|
+
const a = async (...i) => {
|
|
571
|
+
await ne({
|
|
572
572
|
logFilePath: t.logFilePath,
|
|
573
573
|
message: "REQUEST",
|
|
574
|
-
data: { name: o, args:
|
|
574
|
+
data: { name: o, args: i }
|
|
575
575
|
});
|
|
576
|
-
const
|
|
577
|
-
return await
|
|
576
|
+
const c = await n(...i);
|
|
577
|
+
return await ne({
|
|
578
578
|
logFilePath: t.logFilePath,
|
|
579
579
|
message: "RESPONSE",
|
|
580
|
-
data:
|
|
580
|
+
data: c
|
|
581
581
|
}), {
|
|
582
582
|
content: [
|
|
583
583
|
{
|
|
584
584
|
type: "text",
|
|
585
|
-
text:
|
|
585
|
+
text: c
|
|
586
586
|
}
|
|
587
587
|
]
|
|
588
588
|
};
|
|
@@ -590,27 +590,27 @@ function mr(r, t) {
|
|
|
590
590
|
return r.registerTool(
|
|
591
591
|
o,
|
|
592
592
|
e,
|
|
593
|
-
|
|
593
|
+
a
|
|
594
594
|
);
|
|
595
595
|
};
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function xr(r) {
|
|
598
598
|
return r.match(/^[/\\]?[^/\\]+/)[0];
|
|
599
599
|
}
|
|
600
|
-
function
|
|
601
|
-
return
|
|
600
|
+
function $r(r, t) {
|
|
601
|
+
return xr(r) + "|" + t.ino;
|
|
602
602
|
}
|
|
603
|
-
function
|
|
604
|
-
return r.endsWith(":") && (r += "/"),
|
|
603
|
+
function Ir(r) {
|
|
604
|
+
return r.endsWith(":") && (r += "/"), F.resolve(r);
|
|
605
605
|
}
|
|
606
|
-
const
|
|
606
|
+
const ye = new _t(Kt.cpus().length);
|
|
607
607
|
function ve(r, t) {
|
|
608
608
|
r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
|
|
609
609
|
r.maxFileDateModified,
|
|
610
610
|
t.maxFileDateModified
|
|
611
611
|
), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
|
|
612
612
|
}
|
|
613
|
-
const
|
|
613
|
+
const Mr = function(t) {
|
|
614
614
|
return t.code === "ENOENT";
|
|
615
615
|
};
|
|
616
616
|
function nt(r) {
|
|
@@ -623,16 +623,16 @@ function nt(r) {
|
|
|
623
623
|
countDirs: 0,
|
|
624
624
|
countLinks: 0
|
|
625
625
|
});
|
|
626
|
-
const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ??
|
|
627
|
-
async function
|
|
628
|
-
if (!(
|
|
626
|
+
const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? ye, a = r.handleError, i = r.priority ?? V(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, d = r.matchPath;
|
|
627
|
+
async function f(m) {
|
|
628
|
+
if (!(a && await a(m)) && !Mr(m))
|
|
629
629
|
throw m;
|
|
630
630
|
}
|
|
631
631
|
function h(m) {
|
|
632
|
-
return !(!
|
|
632
|
+
return !(!l || l.minTotalContentSize != null && m < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
|
|
633
633
|
}
|
|
634
|
-
return
|
|
635
|
-
const g =
|
|
634
|
+
return Gt(async (m) => {
|
|
635
|
+
const g = Jt(e, m), y = {
|
|
636
636
|
totalSize: 0,
|
|
637
637
|
maxFileDateModified: 0,
|
|
638
638
|
countFiles: 0,
|
|
@@ -642,7 +642,7 @@ function nt(r) {
|
|
|
642
642
|
function w($, S) {
|
|
643
643
|
if (h(S.totalSize)) {
|
|
644
644
|
const T = `${S.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${$}`;
|
|
645
|
-
|
|
645
|
+
l?.handleLog ? l.handleLog(T) : console.log(T);
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
async function M($, S, x, T) {
|
|
@@ -659,7 +659,7 @@ function nt(r) {
|
|
|
659
659
|
abortSignal: g
|
|
660
660
|
});
|
|
661
661
|
} catch (v) {
|
|
662
|
-
return await
|
|
662
|
+
return await f(v), !1;
|
|
663
663
|
}
|
|
664
664
|
},
|
|
665
665
|
count: 1,
|
|
@@ -667,18 +667,18 @@ function nt(r) {
|
|
|
667
667
|
abortSignal: g
|
|
668
668
|
}) : !0;
|
|
669
669
|
}
|
|
670
|
-
async function
|
|
670
|
+
async function N($, S, x, T) {
|
|
671
671
|
T || (T = $);
|
|
672
672
|
const v = await Y({
|
|
673
673
|
pool: n,
|
|
674
|
-
func: () => W.promises.lstat($).catch(
|
|
674
|
+
func: () => W.promises.lstat($).catch(f),
|
|
675
675
|
count: 1,
|
|
676
|
-
priority: V(S, V(1,
|
|
676
|
+
priority: V(S, V(1, i)),
|
|
677
677
|
abortSignal: g
|
|
678
678
|
});
|
|
679
679
|
if (!v || !x && v.isFile())
|
|
680
680
|
return null;
|
|
681
|
-
const L =
|
|
681
|
+
const L = $r($, v);
|
|
682
682
|
if (o.has(L))
|
|
683
683
|
return null;
|
|
684
684
|
o.add(L);
|
|
@@ -691,20 +691,20 @@ function nt(r) {
|
|
|
691
691
|
};
|
|
692
692
|
const I = V(
|
|
693
693
|
S,
|
|
694
|
-
V(v.isDirectory() ? 2 : 3,
|
|
694
|
+
V(v.isDirectory() ? 2 : 3, i)
|
|
695
695
|
);
|
|
696
696
|
if (v.isSymbolicLink()) {
|
|
697
|
-
if (
|
|
697
|
+
if (c) {
|
|
698
698
|
const C = await Y({
|
|
699
699
|
pool: n,
|
|
700
|
-
func: () => W.promises.readlink($).catch(
|
|
700
|
+
func: () => W.promises.readlink($).catch(f).then((E) => E ?? null),
|
|
701
701
|
count: 1,
|
|
702
702
|
priority: I,
|
|
703
703
|
abortSignal: g
|
|
704
704
|
});
|
|
705
705
|
if (C) {
|
|
706
|
-
const
|
|
707
|
-
|
|
706
|
+
const E = F.isAbsolute(C) ? C : F.resolve(F.dirname(T), C), O = await N(
|
|
707
|
+
E,
|
|
708
708
|
S,
|
|
709
709
|
x,
|
|
710
710
|
T
|
|
@@ -721,14 +721,14 @@ function nt(r) {
|
|
|
721
721
|
} else if (v.isDirectory()) {
|
|
722
722
|
const C = await Y({
|
|
723
723
|
pool: n,
|
|
724
|
-
func: () => W.promises.readdir($).catch(
|
|
724
|
+
func: () => W.promises.readdir($).catch(f),
|
|
725
725
|
count: 1,
|
|
726
|
-
priority:
|
|
726
|
+
priority: i,
|
|
727
727
|
abortSignal: g
|
|
728
728
|
});
|
|
729
729
|
if (C) {
|
|
730
|
-
for (let
|
|
731
|
-
C[
|
|
730
|
+
for (let E = 0, O = C.length; E < O; E++)
|
|
731
|
+
C[E] = F.join(T, C[E]);
|
|
732
732
|
k = await nt({
|
|
733
733
|
...r,
|
|
734
734
|
paths: C,
|
|
@@ -748,8 +748,8 @@ function nt(r) {
|
|
|
748
748
|
}
|
|
749
749
|
const b = [];
|
|
750
750
|
for (let $ = 0, S = t.length; $ < S; $++) {
|
|
751
|
-
const x =
|
|
752
|
-
T !== !1 && b.push(
|
|
751
|
+
const x = Ir(t[$]), T = d ? d(x) : !0;
|
|
752
|
+
T !== !1 && b.push(N(x, $, T));
|
|
753
753
|
}
|
|
754
754
|
return await Promise.all(b), y;
|
|
755
755
|
});
|
|
@@ -760,22 +760,22 @@ function it(r) {
|
|
|
760
760
|
function H(r) {
|
|
761
761
|
return r.replace(/\\/g, "/");
|
|
762
762
|
}
|
|
763
|
-
function
|
|
763
|
+
function Tr(r, t) {
|
|
764
764
|
if (!t || t === ".")
|
|
765
765
|
return r;
|
|
766
766
|
const s = r.startsWith("^");
|
|
767
767
|
s && (r = r.substring(1));
|
|
768
768
|
const o = r.startsWith("!");
|
|
769
|
-
return o && (r = r.substring(1)), r.startsWith("/") ? (t.endsWith("/") && (t = t.substring(0, t.length - 1)), r = t + r) : (t.endsWith("/") || (t += "/"), r.startsWith("./") ? r = t + r.substring(2) : r.startsWith("../") ? r = t + r : (t.startsWith("..") && (t = ""), r.startsWith("**") ? r = t + r : r = t + "**/" + r)), r = H(
|
|
769
|
+
return o && (r = r.substring(1)), r.startsWith("/") ? (t.endsWith("/") && (t = t.substring(0, t.length - 1)), r = t + r) : (t.endsWith("/") || (t += "/"), r.startsWith("./") ? r = t + r.substring(2) : r.startsWith("../") ? r = t + r : (t.startsWith("..") && (t = ""), r.startsWith("**") ? r = t + r : r = t + "**/" + r)), r = H(F.normalize(r)), o && (r = "!" + r), s && (r = "^" + r), r;
|
|
770
770
|
}
|
|
771
|
-
function
|
|
771
|
+
function Cr(r) {
|
|
772
772
|
const t = r.startsWith("!");
|
|
773
773
|
return t && (r = r.substring(1)), r.startsWith("/") ? r = r.substring(1) : !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function Ne(r) {
|
|
776
776
|
return "^" + r;
|
|
777
777
|
}
|
|
778
|
-
async function
|
|
778
|
+
async function vr(r) {
|
|
779
779
|
const s = (await W.promises.readFile(r, "utf-8")).split(`
|
|
780
780
|
`), o = [];
|
|
781
781
|
return s.forEach((e) => {
|
|
@@ -788,16 +788,16 @@ async function at(r) {
|
|
|
788
788
|
return s;
|
|
789
789
|
const o = [];
|
|
790
790
|
return r.globs.forEach((e) => {
|
|
791
|
-
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ?
|
|
791
|
+
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Ne(e.value) : e.value));
|
|
792
792
|
}), o.length && await Promise.all(
|
|
793
793
|
o.map(async (e) => {
|
|
794
794
|
await Y({
|
|
795
|
-
pool:
|
|
795
|
+
pool: ye,
|
|
796
796
|
count: 1,
|
|
797
797
|
func: async () => {
|
|
798
|
-
const n =
|
|
799
|
-
|
|
800
|
-
|
|
798
|
+
const n = F.resolve(t, e.value), a = await vr(n), i = F.relative(t, F.dirname(n));
|
|
799
|
+
a.forEach((c) => {
|
|
800
|
+
c = Cr(c), c = Tr(c, i), s.push(e.exclude ? Ne(c) : c);
|
|
801
801
|
});
|
|
802
802
|
}
|
|
803
803
|
});
|
|
@@ -814,45 +814,45 @@ function lt({
|
|
|
814
814
|
e = H(e).trim();
|
|
815
815
|
const n = e.startsWith("^");
|
|
816
816
|
n && (e = e.substring(1).trim());
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
817
|
+
const a = e.startsWith("!");
|
|
818
|
+
if (a && (e = e.substring(1).trim()), e.startsWith("!") || e.startsWith("^"))
|
|
819
819
|
throw new Error(
|
|
820
820
|
`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.`
|
|
821
821
|
);
|
|
822
822
|
e.startsWith("/") && (e = "." + e);
|
|
823
|
-
const
|
|
824
|
-
if (!
|
|
823
|
+
const i = H(t ? F.resolve(t, e) : e);
|
|
824
|
+
if (!i)
|
|
825
825
|
return;
|
|
826
|
-
let
|
|
826
|
+
let c;
|
|
827
827
|
try {
|
|
828
|
-
|
|
828
|
+
c = Wt(i, {
|
|
829
829
|
nocase: s ?? !1,
|
|
830
830
|
dot: !0,
|
|
831
831
|
strictBrackets: !0
|
|
832
832
|
// Validate bracket balance for patterns like "["
|
|
833
833
|
});
|
|
834
|
-
} catch (
|
|
834
|
+
} catch (l) {
|
|
835
835
|
throw new Error(
|
|
836
|
-
`Invalid glob pattern: "${e}". ${
|
|
836
|
+
`Invalid glob pattern: "${e}". ${l instanceof Error ? l.message : "Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`
|
|
837
837
|
);
|
|
838
838
|
}
|
|
839
839
|
o.push({
|
|
840
840
|
exclude: n,
|
|
841
|
-
negative:
|
|
842
|
-
debugInfo:
|
|
843
|
-
match:
|
|
841
|
+
negative: a,
|
|
842
|
+
debugInfo: i,
|
|
843
|
+
match: c
|
|
844
844
|
});
|
|
845
845
|
}), function(n) {
|
|
846
846
|
n = H(n);
|
|
847
|
-
let
|
|
848
|
-
for (let
|
|
849
|
-
const u = o[
|
|
850
|
-
u.match(n) && (u.exclude ?
|
|
847
|
+
let a = null, i = !1;
|
|
848
|
+
for (let c = 0, l = o.length; c < l; c++) {
|
|
849
|
+
const u = o[c];
|
|
850
|
+
u.match(n) && (u.exclude ? i = !u.negative : (a = !u.negative, i = !1));
|
|
851
851
|
}
|
|
852
|
-
return
|
|
852
|
+
return i ? !1 : a;
|
|
853
853
|
};
|
|
854
854
|
}
|
|
855
|
-
async function
|
|
855
|
+
async function Nr(r) {
|
|
856
856
|
const t = r.rootDir ?? ".", s = [], o = {};
|
|
857
857
|
r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
|
|
858
858
|
const e = await at({
|
|
@@ -867,13 +867,13 @@ async function Ir(r) {
|
|
|
867
867
|
rootDir: t,
|
|
868
868
|
noCase: !0
|
|
869
869
|
}),
|
|
870
|
-
handlePath: async ({ path: n, stat:
|
|
871
|
-
const
|
|
872
|
-
if (!
|
|
870
|
+
handlePath: async ({ path: n, stat: a, itemStat: i }) => {
|
|
871
|
+
const c = F.relative(t, n), l = a.isDirectory(), u = a.isFile();
|
|
872
|
+
if (!l && !u)
|
|
873
873
|
return !0;
|
|
874
|
-
const
|
|
875
|
-
path:
|
|
876
|
-
type:
|
|
874
|
+
const d = H(c || "."), f = l ? "dir" : "file", h = l ? i.maxFileDateModified || null : a.mtimeMs, m = l ? i.totalSize : a.size, g = l ? i.countFiles : null, y = {
|
|
875
|
+
path: d,
|
|
876
|
+
type: f
|
|
877
877
|
};
|
|
878
878
|
if (r.result.dateModified && (y.dateModified = h), r.result.size && (y.size = m), r.result.countFiles && (y.countFiles = g), r.dateModified && h != null) {
|
|
879
879
|
const [w, M] = r.dateModified;
|
|
@@ -885,67 +885,67 @@ async function Ir(r) {
|
|
|
885
885
|
if (w != null && m < w || M != null && m > M)
|
|
886
886
|
return !1;
|
|
887
887
|
}
|
|
888
|
-
return
|
|
888
|
+
return f === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), f === "file" && m != null && (o.size = (o.size ?? 0) + m), h != null && (o.dateModified == null || h > o.dateModified) && (o.dateModified = h), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
|
|
889
889
|
}
|
|
890
890
|
}), { items: s, totals: o };
|
|
891
891
|
}
|
|
892
|
-
const
|
|
892
|
+
const Ee = ["B", "KB", "MB", "GB", "TB"], ke = 1024;
|
|
893
893
|
function Oe(r) {
|
|
894
894
|
if (r == null) return "-";
|
|
895
895
|
let t = r ?? 0, s = 0;
|
|
896
|
-
for (; t >= ke && s <
|
|
896
|
+
for (; t >= ke && s < Ee.length - 1; )
|
|
897
897
|
t /= ke, s++;
|
|
898
|
-
return `${s === 0 ? t.toString() : t.toFixed(2)}${
|
|
898
|
+
return `${s === 0 ? t.toString() : t.toFixed(2)}${Ee[s]}`;
|
|
899
899
|
}
|
|
900
900
|
function De(r) {
|
|
901
901
|
const s = Date.now() - r;
|
|
902
902
|
if (s < 0) return "0s";
|
|
903
|
-
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60),
|
|
904
|
-
return
|
|
903
|
+
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), c = Math.floor(a / 30), l = Math.floor(a / 365);
|
|
904
|
+
return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
|
|
905
905
|
}
|
|
906
|
-
function
|
|
906
|
+
function Er(r, t) {
|
|
907
907
|
return t?.length ? [...r].sort((s, o) => {
|
|
908
908
|
for (let e = 0, n = t.length; e < n; e++) {
|
|
909
|
-
const
|
|
910
|
-
let
|
|
911
|
-
switch (
|
|
909
|
+
const a = t[e];
|
|
910
|
+
let i, c;
|
|
911
|
+
switch (a.field) {
|
|
912
912
|
case "type":
|
|
913
|
-
|
|
913
|
+
i = s.type, c = o.type;
|
|
914
914
|
break;
|
|
915
915
|
case "path":
|
|
916
|
-
|
|
916
|
+
i = s.path, c = o.path;
|
|
917
917
|
break;
|
|
918
918
|
case "dateModified":
|
|
919
|
-
|
|
919
|
+
i = s.dateModified, c = o.dateModified;
|
|
920
920
|
break;
|
|
921
921
|
case "size":
|
|
922
|
-
|
|
922
|
+
i = s.size, c = o.size;
|
|
923
923
|
break;
|
|
924
924
|
case "countFiles":
|
|
925
|
-
|
|
925
|
+
i = s.countFiles, c = o.countFiles;
|
|
926
926
|
break;
|
|
927
927
|
}
|
|
928
|
-
if (
|
|
929
|
-
if (
|
|
928
|
+
if (i == null) {
|
|
929
|
+
if (c == null)
|
|
930
930
|
continue;
|
|
931
931
|
return 1;
|
|
932
932
|
}
|
|
933
|
-
if (
|
|
933
|
+
if (c == null)
|
|
934
934
|
return -1;
|
|
935
|
-
const
|
|
936
|
-
if (
|
|
937
|
-
return
|
|
935
|
+
const l = i > c ? 1 : i < c ? -1 : 0;
|
|
936
|
+
if (l !== 0)
|
|
937
|
+
return a.desc ? -l : l;
|
|
938
938
|
}
|
|
939
939
|
return 0;
|
|
940
940
|
}) : r;
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
const s =
|
|
942
|
+
function kr(r, t) {
|
|
943
|
+
const s = Er(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
|
|
944
944
|
let e = "";
|
|
945
945
|
if (s.length > 0 && o.length > 0) {
|
|
946
|
-
for (let n = 0,
|
|
947
|
-
const
|
|
948
|
-
switch (n > 0 && (e += " | "),
|
|
946
|
+
for (let n = 0, a = o.length; n < a; n++) {
|
|
947
|
+
const i = o[n];
|
|
948
|
+
switch (n > 0 && (e += " | "), i) {
|
|
949
949
|
case "dateModified":
|
|
950
950
|
e += "Time ago (s/m/h/d/w/M/Y)";
|
|
951
951
|
break;
|
|
@@ -963,27 +963,27 @@ function Tr(r, t) {
|
|
|
963
963
|
break;
|
|
964
964
|
}
|
|
965
965
|
}
|
|
966
|
-
for (let n = 0,
|
|
967
|
-
const
|
|
966
|
+
for (let n = 0, a = s.length; n < a; n++) {
|
|
967
|
+
const i = s[n];
|
|
968
968
|
e += `
|
|
969
969
|
`;
|
|
970
|
-
for (let
|
|
971
|
-
const u = o[
|
|
972
|
-
switch (
|
|
970
|
+
for (let c = 0, l = o.length; c < l; c++) {
|
|
971
|
+
const u = o[c];
|
|
972
|
+
switch (c > 0 && (e += " | "), u) {
|
|
973
973
|
case "dateModified":
|
|
974
|
-
e +=
|
|
974
|
+
e += i.dateModified ? De(i.dateModified) : "-";
|
|
975
975
|
break;
|
|
976
976
|
case "size":
|
|
977
|
-
e += Oe(
|
|
977
|
+
e += Oe(i.size);
|
|
978
978
|
break;
|
|
979
979
|
case "type":
|
|
980
|
-
e +=
|
|
980
|
+
e += i.type;
|
|
981
981
|
break;
|
|
982
982
|
case "path":
|
|
983
|
-
e +=
|
|
983
|
+
e += i.type === "dir" ? `${i.path}/` : i.path;
|
|
984
984
|
break;
|
|
985
985
|
case "countFiles":
|
|
986
|
-
|
|
986
|
+
i.type === "dir" ? e += i.countFiles != null ? i.countFiles.toString() : "-" : e += "-";
|
|
987
987
|
break;
|
|
988
988
|
}
|
|
989
989
|
}
|
|
@@ -993,14 +993,14 @@ function Tr(r, t) {
|
|
|
993
993
|
e.length > 0 && (e += `
|
|
994
994
|
---
|
|
995
995
|
`);
|
|
996
|
-
const n = Oe(r.totals.size ?? 0),
|
|
997
|
-
e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${
|
|
996
|
+
const n = Oe(r.totals.size ?? 0), a = r.totals.dateModified ? `, last modified ${De(r.totals.dateModified)} ago` : "";
|
|
997
|
+
e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${a}`;
|
|
998
998
|
}
|
|
999
999
|
return e;
|
|
1000
1000
|
}
|
|
1001
|
-
const
|
|
1002
|
-
version:
|
|
1003
|
-
},
|
|
1001
|
+
const Or = "3.0.14", Dr = {
|
|
1002
|
+
version: Or
|
|
1003
|
+
}, fo = "Project Tools", ho = "project-tools", po = Dr.version, mo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Re = 25e3;
|
|
1004
1004
|
function Fe(r) {
|
|
1005
1005
|
const t = r.match(
|
|
1006
1006
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
@@ -1095,7 +1095,7 @@ const ct = p.object({
|
|
|
1095
1095
|
'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'
|
|
1096
1096
|
)
|
|
1097
1097
|
});
|
|
1098
|
-
async function
|
|
1098
|
+
async function Rr(r, t) {
|
|
1099
1099
|
let s;
|
|
1100
1100
|
try {
|
|
1101
1101
|
s = ct.parse(r);
|
|
@@ -1108,18 +1108,18 @@ async function Er(r, t) {
|
|
|
1108
1108
|
globs: o,
|
|
1109
1109
|
showFiles: e,
|
|
1110
1110
|
showDirs: n,
|
|
1111
|
-
sortBy:
|
|
1112
|
-
minTimeAgo:
|
|
1113
|
-
maxTimeAgo:
|
|
1114
|
-
minTotalSize:
|
|
1111
|
+
sortBy: a,
|
|
1112
|
+
minTimeAgo: i,
|
|
1113
|
+
maxTimeAgo: c,
|
|
1114
|
+
minTotalSize: l,
|
|
1115
1115
|
maxTotalSize: u
|
|
1116
1116
|
} = s;
|
|
1117
1117
|
if (s.fields && s.fields.length > 0 && !s.fields.includes("path"))
|
|
1118
1118
|
return {
|
|
1119
1119
|
error: 'Fields array must include "path" field when fields are specified. The "path" field is required to identify files and directories in the output'
|
|
1120
1120
|
};
|
|
1121
|
-
const
|
|
1122
|
-
let
|
|
1121
|
+
const d = s.fields ? s.fields.map((g) => g === "totalCountFiles" ? "countFiles" : g === "lastModified" ? "dateModified" : g) : [];
|
|
1122
|
+
let f = a?.map((g) => {
|
|
1123
1123
|
let y = g.field;
|
|
1124
1124
|
return y === "totalCountFiles" && (y = "countFiles"), y === "lastModified" && (y = "dateModified"), {
|
|
1125
1125
|
field: y,
|
|
@@ -1127,8 +1127,8 @@ async function Er(r, t) {
|
|
|
1127
1127
|
// Default to ascending if not specified
|
|
1128
1128
|
};
|
|
1129
1129
|
}) ?? null;
|
|
1130
|
-
(!
|
|
1131
|
-
const h =
|
|
1130
|
+
(!f || f.length === 0) && (f = [{ field: "path", desc: !1 }]);
|
|
1131
|
+
const h = f?.map((g) => g.field) || [], m = F.resolve(
|
|
1132
1132
|
t.workingDir || "",
|
|
1133
1133
|
s.rootDir || ""
|
|
1134
1134
|
);
|
|
@@ -1149,42 +1149,42 @@ async function Er(r, t) {
|
|
|
1149
1149
|
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...g, ...y], M = {
|
|
1150
1150
|
files: e ?? !1,
|
|
1151
1151
|
dirs: n ?? !1,
|
|
1152
|
-
dateModified:
|
|
1153
|
-
size:
|
|
1154
|
-
countFiles:
|
|
1152
|
+
dateModified: d.includes("dateModified") || h.includes("dateModified"),
|
|
1153
|
+
size: d.includes("size") || h.includes("size"),
|
|
1154
|
+
countFiles: d.includes("countFiles") || h.includes("countFiles")
|
|
1155
1155
|
};
|
|
1156
|
-
let
|
|
1157
|
-
if (
|
|
1156
|
+
let N = null, b = null;
|
|
1157
|
+
if (i || c)
|
|
1158
1158
|
try {
|
|
1159
|
-
const x = Date.now(), T =
|
|
1160
|
-
|
|
1159
|
+
const x = Date.now(), T = c ? x - Fe(c) : null, v = i ? x - Fe(i) : null;
|
|
1160
|
+
N = [T, v];
|
|
1161
1161
|
} catch (x) {
|
|
1162
1162
|
return {
|
|
1163
1163
|
error: x instanceof Error ? x.message : "Unknown error parsing time ago filter"
|
|
1164
1164
|
};
|
|
1165
1165
|
}
|
|
1166
|
-
if (
|
|
1166
|
+
if (l || u)
|
|
1167
1167
|
try {
|
|
1168
|
-
const x =
|
|
1168
|
+
const x = l ? Be(l) : null, T = u ? Be(u) : null;
|
|
1169
1169
|
b = [x, T];
|
|
1170
1170
|
} catch (x) {
|
|
1171
1171
|
return {
|
|
1172
1172
|
error: x instanceof Error ? x.message : "Unknown error parsing size filter"
|
|
1173
1173
|
};
|
|
1174
1174
|
}
|
|
1175
|
-
const $ = await
|
|
1175
|
+
const $ = await Nr({
|
|
1176
1176
|
rootDir: m || null,
|
|
1177
1177
|
globs: w,
|
|
1178
1178
|
result: M,
|
|
1179
|
-
dateModified:
|
|
1179
|
+
dateModified: N,
|
|
1180
1180
|
totalSize: b
|
|
1181
1181
|
});
|
|
1182
1182
|
return $.items.length > Re ? {
|
|
1183
1183
|
error: `Number of paths (${$.items.length}) exceeds maximum allowed (${Re}). Consider using more specific glob patterns or filters to reduce the result set.`
|
|
1184
1184
|
} : {
|
|
1185
|
-
output:
|
|
1186
|
-
sort:
|
|
1187
|
-
fields:
|
|
1185
|
+
output: kr($, {
|
|
1186
|
+
sort: f,
|
|
1187
|
+
fields: d,
|
|
1188
1188
|
totals: !0
|
|
1189
1189
|
})
|
|
1190
1190
|
};
|
|
@@ -1192,7 +1192,7 @@ async function Er(r, t) {
|
|
|
1192
1192
|
return { error: g instanceof Error ? g.message : "Unknown error" };
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
|
-
function
|
|
1195
|
+
function Fr(r, t) {
|
|
1196
1196
|
r(
|
|
1197
1197
|
"fs-list",
|
|
1198
1198
|
{
|
|
@@ -1201,19 +1201,19 @@ function Nr(r, t) {
|
|
|
1201
1201
|
inputSchema: ct.shape
|
|
1202
1202
|
},
|
|
1203
1203
|
async (s) => {
|
|
1204
|
-
const o = await
|
|
1204
|
+
const o = await Rr(s, t);
|
|
1205
1205
|
return o.error ? `Method: fs-list(${JSON.stringify(s)})
|
|
1206
1206
|
❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
|
|
1207
1207
|
${o.output || JSON.stringify(o, null, 2)}`;
|
|
1208
1208
|
}
|
|
1209
1209
|
);
|
|
1210
1210
|
}
|
|
1211
|
-
const
|
|
1212
|
-
function
|
|
1213
|
-
return
|
|
1211
|
+
const ce = /* @__PURE__ */ new Map();
|
|
1212
|
+
function Z(r) {
|
|
1213
|
+
return ce.has(r) || ce.set(r, {
|
|
1214
1214
|
fsSnapshotQueries: /* @__PURE__ */ new Map(),
|
|
1215
1215
|
fsSnapshots: /* @__PURE__ */ new Map()
|
|
1216
|
-
}),
|
|
1216
|
+
}), ce.get(r);
|
|
1217
1217
|
}
|
|
1218
1218
|
function Le(r) {
|
|
1219
1219
|
const t = r.match(
|
|
@@ -1270,7 +1270,7 @@ function Pe(r) {
|
|
|
1270
1270
|
);
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
|
-
const
|
|
1273
|
+
const be = p.object({
|
|
1274
1274
|
name: p.string().describe(
|
|
1275
1275
|
"Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1276
1276
|
),
|
|
@@ -1307,14 +1307,14 @@ const ye = p.object({
|
|
|
1307
1307
|
"dateModified"
|
|
1308
1308
|
].map((r, t) => [r, t])
|
|
1309
1309
|
);
|
|
1310
|
-
function
|
|
1310
|
+
function Br(r, t) {
|
|
1311
1311
|
const s = Ae.get(r) ?? 1 / 0, o = Ae.get(t) ?? 1 / 0;
|
|
1312
1312
|
return s > o ? 1 : s < o ? -1 : 0;
|
|
1313
1313
|
}
|
|
1314
1314
|
async function ut(r, t, s) {
|
|
1315
1315
|
let o;
|
|
1316
1316
|
try {
|
|
1317
|
-
o =
|
|
1317
|
+
o = be.parse(r);
|
|
1318
1318
|
} catch (h) {
|
|
1319
1319
|
return {
|
|
1320
1320
|
error: B(h)
|
|
@@ -1323,66 +1323,66 @@ async function ut(r, t, s) {
|
|
|
1323
1323
|
const {
|
|
1324
1324
|
name: e,
|
|
1325
1325
|
globs: n,
|
|
1326
|
-
types:
|
|
1327
|
-
minTimeAgo:
|
|
1328
|
-
maxTimeAgo:
|
|
1329
|
-
minTotalSize:
|
|
1326
|
+
types: a,
|
|
1327
|
+
minTimeAgo: i,
|
|
1328
|
+
maxTimeAgo: c,
|
|
1329
|
+
minTotalSize: l,
|
|
1330
1330
|
maxTotalSize: u
|
|
1331
1331
|
} = o;
|
|
1332
1332
|
if (!s.sessionId)
|
|
1333
1333
|
return {
|
|
1334
1334
|
error: "Session ID is required"
|
|
1335
1335
|
};
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1336
|
+
const d = Z(s.sessionId), f = H(
|
|
1337
|
+
F.resolve(t.workingDir || "", o.rootDir || "")
|
|
1338
1338
|
);
|
|
1339
1339
|
try {
|
|
1340
1340
|
try {
|
|
1341
|
-
await W.promises.access(
|
|
1341
|
+
await W.promises.access(f, W.constants.F_OK);
|
|
1342
1342
|
} catch (S) {
|
|
1343
1343
|
if (S.code === "ENOENT")
|
|
1344
1344
|
return {
|
|
1345
|
-
error: `Directory does not exist: "${
|
|
1345
|
+
error: `Directory does not exist: "${f}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
|
|
1346
1346
|
};
|
|
1347
1347
|
throw S;
|
|
1348
1348
|
}
|
|
1349
1349
|
const h = o.extraFields ? o.extraFields.map((S) => S === "lastModified" ? "dateModified" : S) : [];
|
|
1350
|
-
h.includes("name") || h.push("name"), h.sort(
|
|
1350
|
+
h.includes("name") || h.push("name"), h.sort(Br);
|
|
1351
1351
|
const m = n && n.length > 0 ? n.map((S) => ({
|
|
1352
1352
|
value: S,
|
|
1353
1353
|
valueType: "pattern",
|
|
1354
1354
|
exclude: !1
|
|
1355
1355
|
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], g = t.globsExclude || [], y = [...m, ...g];
|
|
1356
1356
|
let w = null, M = null;
|
|
1357
|
-
if (
|
|
1357
|
+
if (i || c)
|
|
1358
1358
|
try {
|
|
1359
|
-
const S = Date.now(), x =
|
|
1359
|
+
const S = Date.now(), x = c ? S - Le(c) : null, T = i ? S - Le(i) : null;
|
|
1360
1360
|
w = [x, T];
|
|
1361
1361
|
} catch (S) {
|
|
1362
1362
|
return {
|
|
1363
1363
|
error: S instanceof Error ? S.message : "Unknown error parsing time ago filter"
|
|
1364
1364
|
};
|
|
1365
1365
|
}
|
|
1366
|
-
if (
|
|
1366
|
+
if (l || u)
|
|
1367
1367
|
try {
|
|
1368
|
-
const S =
|
|
1368
|
+
const S = l ? Pe(l) : null, x = u ? Pe(u) : null;
|
|
1369
1369
|
M = [S, x];
|
|
1370
1370
|
} catch (S) {
|
|
1371
1371
|
return {
|
|
1372
1372
|
error: S instanceof Error ? S.message : "Unknown error parsing size filter"
|
|
1373
1373
|
};
|
|
1374
1374
|
}
|
|
1375
|
-
const
|
|
1375
|
+
const N = a ? a.includes("file") : !0, b = a ? a.includes("dir") : !0, $ = {
|
|
1376
1376
|
name: e,
|
|
1377
|
-
rootDir:
|
|
1377
|
+
rootDir: f,
|
|
1378
1378
|
globs: y,
|
|
1379
|
-
matchFiles:
|
|
1379
|
+
matchFiles: N,
|
|
1380
1380
|
matchDirs: b,
|
|
1381
1381
|
dateModified: w,
|
|
1382
1382
|
totalSize: M,
|
|
1383
1383
|
fields: h
|
|
1384
1384
|
};
|
|
1385
|
-
return
|
|
1385
|
+
return d.fsSnapshotQueries.set(e, $), {
|
|
1386
1386
|
snapshotQuery: $
|
|
1387
1387
|
};
|
|
1388
1388
|
} catch (h) {
|
|
@@ -1391,13 +1391,13 @@ async function ut(r, t, s) {
|
|
|
1391
1391
|
};
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
|
-
function
|
|
1394
|
+
function Lr(r, t) {
|
|
1395
1395
|
r(
|
|
1396
1396
|
"fs-snapshot-query-create",
|
|
1397
1397
|
{
|
|
1398
1398
|
title: "Create Filesystem Snapshot Query",
|
|
1399
1399
|
description: "Create a filesystem snapshot query. Prefer fs-snapshot-browse if you need to immediately create a query, snapshot and browse it",
|
|
1400
|
-
inputSchema:
|
|
1400
|
+
inputSchema: be.shape
|
|
1401
1401
|
},
|
|
1402
1402
|
async (s, o) => {
|
|
1403
1403
|
const e = await ut(s, t, o);
|
|
@@ -1407,42 +1407,42 @@ function Or(r, t) {
|
|
|
1407
1407
|
}
|
|
1408
1408
|
);
|
|
1409
1409
|
}
|
|
1410
|
-
function
|
|
1410
|
+
function ae(r) {
|
|
1411
1411
|
const { idToNode: t, idToChildIds: s } = r, o = t.get(null);
|
|
1412
1412
|
if (o == null)
|
|
1413
1413
|
throw new Error(
|
|
1414
1414
|
"Impossible behavior: root node (id: null) not found in idToNode"
|
|
1415
1415
|
);
|
|
1416
1416
|
const e = /* @__PURE__ */ new Map();
|
|
1417
|
-
return t.forEach((n,
|
|
1417
|
+
return t.forEach((n, a) => {
|
|
1418
1418
|
if (n != null) {
|
|
1419
1419
|
if (e.has(n)) {
|
|
1420
|
-
const
|
|
1420
|
+
const i = e.get(n);
|
|
1421
1421
|
throw new Error(
|
|
1422
|
-
`Impossible behavior: node appears with multiple IDs (existing: ${
|
|
1422
|
+
`Impossible behavior: node appears with multiple IDs (existing: ${i}, new: ${a})`
|
|
1423
1423
|
);
|
|
1424
1424
|
}
|
|
1425
|
-
e.set(n,
|
|
1425
|
+
e.set(n, a);
|
|
1426
1426
|
}
|
|
1427
1427
|
}), {
|
|
1428
1428
|
root: o,
|
|
1429
1429
|
getNode: (n) => t.get(n) ?? null,
|
|
1430
1430
|
getId: (n) => e.get(n) ?? null,
|
|
1431
1431
|
getChilds: (n) => {
|
|
1432
|
-
let
|
|
1433
|
-
if (
|
|
1432
|
+
let a = e.get(n);
|
|
1433
|
+
if (a == null)
|
|
1434
1434
|
if (n === t.get(null))
|
|
1435
|
-
|
|
1435
|
+
a = null;
|
|
1436
1436
|
else
|
|
1437
1437
|
throw new Error("Impossible behavior: node not found in idToNode");
|
|
1438
|
-
const
|
|
1439
|
-
return
|
|
1440
|
-
const
|
|
1441
|
-
if (
|
|
1438
|
+
const i = s.get(a);
|
|
1439
|
+
return i == null ? null : i.map((c) => {
|
|
1440
|
+
const l = t.get(c);
|
|
1441
|
+
if (l == null)
|
|
1442
1442
|
throw new Error(
|
|
1443
|
-
`Child node with id '${
|
|
1443
|
+
`Child node with id '${c}' not found in idToNode`
|
|
1444
1444
|
);
|
|
1445
|
-
return
|
|
1445
|
+
return l;
|
|
1446
1446
|
});
|
|
1447
1447
|
}
|
|
1448
1448
|
};
|
|
@@ -1450,51 +1450,51 @@ function ne(r) {
|
|
|
1450
1450
|
function dt(r, t, s) {
|
|
1451
1451
|
let o = null;
|
|
1452
1452
|
for (let e = 0, n = t.length; e < n; e++) {
|
|
1453
|
-
const
|
|
1454
|
-
|
|
1453
|
+
const a = t[e], i = r(a), c = i == null ? null : dt(r, i, s), l = s(a, c);
|
|
1454
|
+
l != null && (o == null && (o = []), o.push(l));
|
|
1455
1455
|
}
|
|
1456
1456
|
return o;
|
|
1457
1457
|
}
|
|
1458
1458
|
function ft(r) {
|
|
1459
|
-
const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(),
|
|
1459
|
+
const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = dt(
|
|
1460
1460
|
s,
|
|
1461
1461
|
o,
|
|
1462
|
-
(u,
|
|
1463
|
-
const
|
|
1464
|
-
if (u != null &&
|
|
1462
|
+
(u, d) => {
|
|
1463
|
+
const f = e(u, d);
|
|
1464
|
+
if (u != null && f != null) {
|
|
1465
1465
|
const h = t(u);
|
|
1466
|
-
n.set(h,
|
|
1466
|
+
n.set(h, f), a.set(f, h);
|
|
1467
1467
|
}
|
|
1468
|
-
return
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
),
|
|
1468
|
+
return f != null && d != null && i.set(
|
|
1469
|
+
a.get(f),
|
|
1470
|
+
d.map((h) => a.get(h))
|
|
1471
|
+
), f;
|
|
1472
1472
|
}
|
|
1473
|
-
),
|
|
1474
|
-
if (
|
|
1473
|
+
), l = e(null, c);
|
|
1474
|
+
if (l == null)
|
|
1475
1475
|
throw new Error("Impossible behavior: rootNode == null");
|
|
1476
|
-
return n.set(null,
|
|
1476
|
+
return n.set(null, l), c != null && i.set(
|
|
1477
1477
|
null,
|
|
1478
|
-
|
|
1478
|
+
c.map((u) => a.get(u))
|
|
1479
1479
|
), {
|
|
1480
1480
|
idToNode: n,
|
|
1481
|
-
idToChildIds:
|
|
1481
|
+
idToChildIds: i
|
|
1482
1482
|
};
|
|
1483
1483
|
}
|
|
1484
|
-
function
|
|
1484
|
+
function pe(r) {
|
|
1485
1485
|
return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
|
|
1486
1486
|
}
|
|
1487
|
-
async function
|
|
1488
|
-
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o =
|
|
1487
|
+
async function Pr(r) {
|
|
1488
|
+
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = F.resolve(r.rootDir || "."), n = {
|
|
1489
1489
|
path: ".",
|
|
1490
|
-
name:
|
|
1490
|
+
name: F.basename(o),
|
|
1491
1491
|
type: "dir",
|
|
1492
1492
|
isMatched: !1,
|
|
1493
1493
|
dateModified: null,
|
|
1494
1494
|
size: 0
|
|
1495
1495
|
};
|
|
1496
1496
|
t.set(null, n);
|
|
1497
|
-
const
|
|
1497
|
+
const a = await at({
|
|
1498
1498
|
rootDir: o,
|
|
1499
1499
|
globs: r.globs
|
|
1500
1500
|
});
|
|
@@ -1502,31 +1502,31 @@ async function Dr(r) {
|
|
|
1502
1502
|
paths: [o],
|
|
1503
1503
|
walkLinks: !0,
|
|
1504
1504
|
matchPath: lt({
|
|
1505
|
-
globs:
|
|
1505
|
+
globs: a,
|
|
1506
1506
|
rootDir: o,
|
|
1507
1507
|
noCase: !0
|
|
1508
1508
|
}),
|
|
1509
|
-
handlePath: async ({ path:
|
|
1510
|
-
const u =
|
|
1511
|
-
if (!
|
|
1509
|
+
handlePath: async ({ path: i, stat: c, itemStat: l }) => {
|
|
1510
|
+
const u = F.relative(o, i), d = c.isDirectory(), f = c.isFile();
|
|
1511
|
+
if (!d && !f)
|
|
1512
1512
|
return !0;
|
|
1513
|
-
const h =
|
|
1513
|
+
const h = pe(u || "."), m = d ? "dir" : "file", g = d ? null : c.mtimeMs, y = c.size;
|
|
1514
1514
|
let w = !0;
|
|
1515
|
-
if (
|
|
1515
|
+
if (f && !r.matchFiles && (w = !1), d && !r.matchDirs && (w = !1), w && f && r.dateModified && g != null) {
|
|
1516
1516
|
const [$, S] = r.dateModified;
|
|
1517
1517
|
($ != null && g < $ || S != null && g > S) && (w = !1);
|
|
1518
1518
|
}
|
|
1519
|
-
if (w &&
|
|
1519
|
+
if (w && f && r.totalSize && y != null) {
|
|
1520
1520
|
const [$, S] = r.totalSize;
|
|
1521
1521
|
($ != null && y < $ || S != null && y > S) && (w = !1);
|
|
1522
1522
|
}
|
|
1523
|
-
if (
|
|
1524
|
-
if (!(
|
|
1523
|
+
if (d && !w) {
|
|
1524
|
+
if (!(l.countFiles && l.countFiles > 0)) return !1;
|
|
1525
1525
|
} else if (!w)
|
|
1526
1526
|
return !1;
|
|
1527
1527
|
const M = {
|
|
1528
1528
|
path: h ?? ".",
|
|
1529
|
-
name:
|
|
1529
|
+
name: F.basename(i),
|
|
1530
1530
|
type: m,
|
|
1531
1531
|
dateModified: g,
|
|
1532
1532
|
size: y,
|
|
@@ -1535,16 +1535,16 @@ async function Dr(r) {
|
|
|
1535
1535
|
if (h == null)
|
|
1536
1536
|
return n.dateModified = g, n.size = y, n.isMatched = w, !0;
|
|
1537
1537
|
t.set(h, M);
|
|
1538
|
-
const
|
|
1539
|
-
let b = s.get(
|
|
1540
|
-
return b || (b = [], s.set(
|
|
1538
|
+
const N = pe(H(F.dirname(h)));
|
|
1539
|
+
let b = s.get(N);
|
|
1540
|
+
return b || (b = [], s.set(N, b)), b.push(h), !0;
|
|
1541
1541
|
}
|
|
1542
1542
|
}), {
|
|
1543
1543
|
idToNode: t,
|
|
1544
1544
|
idToChildIds: s
|
|
1545
1545
|
};
|
|
1546
1546
|
}
|
|
1547
|
-
const
|
|
1547
|
+
const Ar = [
|
|
1548
1548
|
{ name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
|
|
1549
1549
|
{ name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
|
|
1550
1550
|
{ name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
|
|
@@ -1567,7 +1567,7 @@ const Rr = [
|
|
|
1567
1567
|
// max: 2,
|
|
1568
1568
|
// },
|
|
1569
1569
|
];
|
|
1570
|
-
function ze(r, t =
|
|
1570
|
+
function ze(r, t = Ar) {
|
|
1571
1571
|
const s = r.length;
|
|
1572
1572
|
if (s === 0) return 0;
|
|
1573
1573
|
const o = t.length;
|
|
@@ -1575,21 +1575,21 @@ function ze(r, t = Rr) {
|
|
|
1575
1575
|
return s;
|
|
1576
1576
|
let e = 0, n = 0;
|
|
1577
1577
|
for (; n < s; ) {
|
|
1578
|
-
const
|
|
1579
|
-
let
|
|
1580
|
-
for (let
|
|
1581
|
-
const
|
|
1582
|
-
if (
|
|
1578
|
+
const a = r.charCodeAt(n);
|
|
1579
|
+
let i = !1;
|
|
1580
|
+
for (let c = 0; c < o; c++) {
|
|
1581
|
+
const l = t[c];
|
|
1582
|
+
if (l.match(a)) {
|
|
1583
1583
|
let u = 1;
|
|
1584
|
-
for (; ++n < s &&
|
|
1584
|
+
for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
|
|
1585
1585
|
u++;
|
|
1586
|
-
if (u >=
|
|
1587
|
-
e++,
|
|
1586
|
+
if (u >= l.min) {
|
|
1587
|
+
e++, i = !0;
|
|
1588
1588
|
break;
|
|
1589
1589
|
}
|
|
1590
1590
|
}
|
|
1591
1591
|
}
|
|
1592
|
-
|
|
1592
|
+
i || (n++, e++);
|
|
1593
1593
|
}
|
|
1594
1594
|
return e;
|
|
1595
1595
|
}
|
|
@@ -1597,21 +1597,21 @@ function ht(r) {
|
|
|
1597
1597
|
let t = 0;
|
|
1598
1598
|
return t += ze(r.textOpen) + 1, r.textClose != null && (t += ze(r.textClose) + 1), r.indent && (t += 1), t;
|
|
1599
1599
|
}
|
|
1600
|
-
const Ue = ["B", "KB", "MB", "GB", "TB"],
|
|
1601
|
-
function
|
|
1600
|
+
const Ue = ["B", "KB", "MB", "GB", "TB"], qe = 1024;
|
|
1601
|
+
function zr(r) {
|
|
1602
1602
|
if (r == null) return "-";
|
|
1603
1603
|
let t = r ?? 0, s = 0;
|
|
1604
|
-
for (; t >=
|
|
1605
|
-
t /=
|
|
1604
|
+
for (; t >= qe && s < Ue.length - 1; )
|
|
1605
|
+
t /= qe, s++;
|
|
1606
1606
|
return `${s === 0 ? t.toString() : t.toFixed(2)}${Ue[s]}`;
|
|
1607
1607
|
}
|
|
1608
|
-
function
|
|
1608
|
+
function Ur(r) {
|
|
1609
1609
|
const s = Date.now() - r;
|
|
1610
1610
|
if (s < 0) return "0s";
|
|
1611
|
-
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60),
|
|
1612
|
-
return
|
|
1611
|
+
const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), c = Math.floor(a / 30), l = Math.floor(a / 365);
|
|
1612
|
+
return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
|
|
1613
1613
|
}
|
|
1614
|
-
function
|
|
1614
|
+
function qr(r) {
|
|
1615
1615
|
return function(s, o) {
|
|
1616
1616
|
const e = r.get(s), n = r.get(o);
|
|
1617
1617
|
if (e.type !== n.type)
|
|
@@ -1619,31 +1619,31 @@ function Lr(r) {
|
|
|
1619
1619
|
if (e.type === "file")
|
|
1620
1620
|
return e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
|
|
1621
1621
|
{
|
|
1622
|
-
const
|
|
1623
|
-
return
|
|
1622
|
+
const a = e.countFiles || 0, i = n.countFiles || 0;
|
|
1623
|
+
return a < i ? -1 : a > i ? 1 : e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
|
|
1624
1624
|
}
|
|
1625
1625
|
};
|
|
1626
1626
|
}
|
|
1627
|
-
function
|
|
1627
|
+
function _r(r) {
|
|
1628
1628
|
const t = r.fields ?? [];
|
|
1629
1629
|
return function(o, e) {
|
|
1630
|
-
let n = "",
|
|
1631
|
-
const
|
|
1632
|
-
let
|
|
1630
|
+
let n = "", a, i = 0;
|
|
1631
|
+
const c = e ? e.length : 0;
|
|
1632
|
+
let l = 1, u, d = 0, f = 0, h = 0, m = 0, g = null, y, w, M;
|
|
1633
1633
|
if (e)
|
|
1634
1634
|
for (let b = 0; b < e.length; b++) {
|
|
1635
1635
|
const $ = e[b];
|
|
1636
|
-
|
|
1636
|
+
i += $.countMatched, l += $.countTotal, d += $.tokens, f += $.tokensTotal, h += $.size, m += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
|
|
1637
1637
|
}
|
|
1638
|
-
o ? (y = o.type, w = o.name, M = o.path,
|
|
1638
|
+
o ? (y = o.type, w = o.name, M = o.path, a = o.isMatched, a && (i += 1), o.type === "file" ? (h = o.size || 0, m = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (y = "dir", w = "<root>", M = ".", a = !0);
|
|
1639
1639
|
for (let b = 0, $ = t.length; b < $; b++) {
|
|
1640
1640
|
const S = t[b];
|
|
1641
1641
|
switch (b > 0 && (n += " "), S) {
|
|
1642
1642
|
case "dateModified":
|
|
1643
|
-
n += g ?
|
|
1643
|
+
n += g ? Ur(g) : "-";
|
|
1644
1644
|
break;
|
|
1645
1645
|
case "size":
|
|
1646
|
-
n +=
|
|
1646
|
+
n += zr(h);
|
|
1647
1647
|
break;
|
|
1648
1648
|
case "type":
|
|
1649
1649
|
n += y;
|
|
@@ -1652,90 +1652,90 @@ function Pr(r) {
|
|
|
1652
1652
|
n += y === "dir" ? `${w}/` : w;
|
|
1653
1653
|
break;
|
|
1654
1654
|
case "countMatched":
|
|
1655
|
-
n +=
|
|
1655
|
+
n += i.toString();
|
|
1656
1656
|
break;
|
|
1657
1657
|
}
|
|
1658
1658
|
}
|
|
1659
|
-
const
|
|
1659
|
+
const N = {
|
|
1660
1660
|
indent: !0,
|
|
1661
1661
|
textOpen: n,
|
|
1662
1662
|
textClose: null
|
|
1663
1663
|
};
|
|
1664
|
-
return u = ht(
|
|
1664
|
+
return u = ht(N), f += u, {
|
|
1665
1665
|
type: y,
|
|
1666
1666
|
name: w,
|
|
1667
1667
|
path: M,
|
|
1668
|
-
isMatched:
|
|
1669
|
-
countMatched:
|
|
1670
|
-
countChilds:
|
|
1671
|
-
countTotal:
|
|
1668
|
+
isMatched: a,
|
|
1669
|
+
countMatched: i,
|
|
1670
|
+
countChilds: c,
|
|
1671
|
+
countTotal: l,
|
|
1672
1672
|
tokens: u,
|
|
1673
|
-
tokensChilds:
|
|
1674
|
-
tokensTotal:
|
|
1675
|
-
text:
|
|
1673
|
+
tokensChilds: d,
|
|
1674
|
+
tokensTotal: f,
|
|
1675
|
+
text: N,
|
|
1676
1676
|
size: h,
|
|
1677
1677
|
countFiles: m,
|
|
1678
1678
|
dateModified: g
|
|
1679
1679
|
};
|
|
1680
1680
|
};
|
|
1681
1681
|
}
|
|
1682
|
-
async function
|
|
1683
|
-
const t = await
|
|
1684
|
-
getId: (
|
|
1685
|
-
const
|
|
1686
|
-
if (
|
|
1682
|
+
async function Gr(r) {
|
|
1683
|
+
const t = await Pr(r), s = ae(t), o = s.getChilds(s.root), e = ft({
|
|
1684
|
+
getId: (a) => {
|
|
1685
|
+
const i = s.getId(a);
|
|
1686
|
+
if (i == null)
|
|
1687
1687
|
throw new Error(
|
|
1688
|
-
`Invalid tree structure: node ID is null for node ${JSON.stringify(
|
|
1688
|
+
`Invalid tree structure: node ID is null for node ${JSON.stringify(a)}`
|
|
1689
1689
|
);
|
|
1690
|
-
return
|
|
1690
|
+
return i;
|
|
1691
1691
|
},
|
|
1692
|
-
getChilds: (
|
|
1693
|
-
createSnapshotNode:
|
|
1692
|
+
getChilds: (a) => s.getChilds(a),
|
|
1693
|
+
createSnapshotNode: _r(r),
|
|
1694
1694
|
rootNodes: o ?? []
|
|
1695
|
-
}), n =
|
|
1696
|
-
return e.idToChildIds.forEach((
|
|
1697
|
-
|
|
1698
|
-
}),
|
|
1695
|
+
}), n = qr(e.idToNode);
|
|
1696
|
+
return e.idToChildIds.forEach((a) => {
|
|
1697
|
+
a.sort(n);
|
|
1698
|
+
}), ae(e);
|
|
1699
1699
|
}
|
|
1700
|
-
const
|
|
1700
|
+
const X = p.object({
|
|
1701
1701
|
queryName: p.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
|
|
1702
|
-
query:
|
|
1702
|
+
query: be.optional().describe(
|
|
1703
1703
|
"Filesystem snapshot query creation options JSON to automatically create query"
|
|
1704
1704
|
),
|
|
1705
1705
|
name: p.string().describe(
|
|
1706
1706
|
"Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1707
1707
|
)
|
|
1708
1708
|
});
|
|
1709
|
-
async function
|
|
1709
|
+
async function le(r, t, s) {
|
|
1710
1710
|
let o;
|
|
1711
1711
|
try {
|
|
1712
|
-
o =
|
|
1712
|
+
o = X.parse(r);
|
|
1713
1713
|
} catch (u) {
|
|
1714
1714
|
return {
|
|
1715
1715
|
error: B(u)
|
|
1716
1716
|
};
|
|
1717
1717
|
}
|
|
1718
|
-
const { name: e, queryName: n, query:
|
|
1718
|
+
const { name: e, queryName: n, query: a } = o;
|
|
1719
1719
|
if (!s.sessionId)
|
|
1720
1720
|
return {
|
|
1721
1721
|
error: "Session ID is required"
|
|
1722
1722
|
};
|
|
1723
|
-
const
|
|
1724
|
-
if (n &&
|
|
1723
|
+
const i = Z(s.sessionId);
|
|
1724
|
+
if (n && a)
|
|
1725
1725
|
return {
|
|
1726
1726
|
error: "Either queryName or query must be provided, not both"
|
|
1727
1727
|
};
|
|
1728
|
-
let
|
|
1728
|
+
let c, l = !1;
|
|
1729
1729
|
if (n) {
|
|
1730
|
-
const u =
|
|
1730
|
+
const u = i.fsSnapshotQueries.get(n);
|
|
1731
1731
|
if (!u)
|
|
1732
1732
|
return {
|
|
1733
1733
|
error: `Filesystem snapshot query "${n}" not found`
|
|
1734
1734
|
};
|
|
1735
|
-
|
|
1736
|
-
} else if (
|
|
1735
|
+
c = u;
|
|
1736
|
+
} else if (a) {
|
|
1737
1737
|
const u = await ut(
|
|
1738
|
-
|
|
1738
|
+
a,
|
|
1739
1739
|
t,
|
|
1740
1740
|
s
|
|
1741
1741
|
);
|
|
@@ -1743,20 +1743,20 @@ async function be(r, t, s) {
|
|
|
1743
1743
|
return {
|
|
1744
1744
|
error: u.error
|
|
1745
1745
|
};
|
|
1746
|
-
|
|
1746
|
+
c = u.snapshotQuery, l = !0;
|
|
1747
1747
|
} else
|
|
1748
1748
|
return {
|
|
1749
1749
|
error: "Either queryName or query must be provided"
|
|
1750
1750
|
};
|
|
1751
1751
|
try {
|
|
1752
|
-
const u = await
|
|
1752
|
+
const u = await Gr(c), d = {
|
|
1753
1753
|
name: e,
|
|
1754
|
-
query:
|
|
1754
|
+
query: c,
|
|
1755
1755
|
tree: u
|
|
1756
1756
|
};
|
|
1757
|
-
return
|
|
1758
|
-
fsSnapshot:
|
|
1759
|
-
queryCreated:
|
|
1757
|
+
return i.fsSnapshots.set(e, d), {
|
|
1758
|
+
fsSnapshot: d,
|
|
1759
|
+
queryCreated: l
|
|
1760
1760
|
};
|
|
1761
1761
|
} catch (u) {
|
|
1762
1762
|
return {
|
|
@@ -1764,16 +1764,16 @@ async function be(r, t, s) {
|
|
|
1764
1764
|
};
|
|
1765
1765
|
}
|
|
1766
1766
|
}
|
|
1767
|
-
function
|
|
1767
|
+
function Jr(r, t) {
|
|
1768
1768
|
r(
|
|
1769
1769
|
"fs-snapshot-create",
|
|
1770
1770
|
{
|
|
1771
1771
|
title: "Create Filesystem Snapshot",
|
|
1772
1772
|
description: "Create a filesystem snapshot. Use this to capture filesystem state for later browsing. Prefer fs-snapshot-browse if you need to immediately create and browse a snapshot",
|
|
1773
|
-
inputSchema:
|
|
1773
|
+
inputSchema: X.shape
|
|
1774
1774
|
},
|
|
1775
1775
|
async (s, o) => {
|
|
1776
|
-
const e = await
|
|
1776
|
+
const e = await le(s, t, o);
|
|
1777
1777
|
if (e.error != null)
|
|
1778
1778
|
return `Method: fs-snapshot-create(${JSON.stringify(s)})
|
|
1779
1779
|
❌ Error: ${e.error}`;
|
|
@@ -1784,7 +1784,7 @@ function zr(r, t) {
|
|
|
1784
1784
|
}
|
|
1785
1785
|
);
|
|
1786
1786
|
}
|
|
1787
|
-
class
|
|
1787
|
+
class jr {
|
|
1788
1788
|
_first = null;
|
|
1789
1789
|
_last = null;
|
|
1790
1790
|
_size = 0;
|
|
@@ -1807,19 +1807,19 @@ class Ur {
|
|
|
1807
1807
|
return this._size;
|
|
1808
1808
|
}
|
|
1809
1809
|
}
|
|
1810
|
-
function
|
|
1811
|
-
const t = new
|
|
1810
|
+
function Kr(r) {
|
|
1811
|
+
const t = new jr(), {
|
|
1812
1812
|
tree: s,
|
|
1813
|
-
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup:
|
|
1814
|
-
indexRangeGroupStrategy:
|
|
1815
|
-
} = r,
|
|
1816
|
-
|
|
1813
|
+
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: a },
|
|
1814
|
+
indexRangeGroupStrategy: i
|
|
1815
|
+
} = r, c = s.getChilds(s.root);
|
|
1816
|
+
c != null && c.length > 0 && t.enqueue({
|
|
1817
1817
|
reportNode: null,
|
|
1818
1818
|
node: s.root
|
|
1819
1819
|
});
|
|
1820
|
-
let
|
|
1820
|
+
let l = null, u = 0, d = 0;
|
|
1821
1821
|
for (; !t.isEmpty(); ) {
|
|
1822
|
-
const { reportNode:
|
|
1822
|
+
const { reportNode: f, node: h } = t.dequeue(), m = s.getChilds(h);
|
|
1823
1823
|
if (m == null || h.countChilds === 0 || m.length !== h.countChilds)
|
|
1824
1824
|
throw new Error(
|
|
1825
1825
|
"Impossible behavior: nodeChilds is null or length mismatch"
|
|
@@ -1827,104 +1827,104 @@ function _r(r) {
|
|
|
1827
1827
|
let g = t.size();
|
|
1828
1828
|
for (let w = 0; w < m.length; w++)
|
|
1829
1829
|
m[w].countChilds > 0 && (g += 1);
|
|
1830
|
-
const y = g *
|
|
1831
|
-
if (o != null && u + h.countChilds + g > o || e != null &&
|
|
1830
|
+
const y = g * i.tokens;
|
|
1831
|
+
if (o != null && u + h.countChilds + g > o || e != null && d + h.tokensChilds + y > e) {
|
|
1832
1832
|
const w = [];
|
|
1833
|
-
let M = null,
|
|
1833
|
+
let M = null, N = 0;
|
|
1834
1834
|
for (let $ = 0, S = m.length; $ < S; $++) {
|
|
1835
|
-
const x = m[$], T =
|
|
1835
|
+
const x = m[$], T = N * i.tokens;
|
|
1836
1836
|
M != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
|
|
1837
|
-
!(o != null && u + 1 > o || e != null &&
|
|
1837
|
+
!(o != null && u + 1 > o || e != null && d + i.tokens > e) && (n != null && M.countGrouped + 1 + N > n || a != null && M.tokensGrouped + x.tokens + T > a) && (w.push(M), u += 1, d += i.tokens, M = null, N = 0), M = i.add(M, x, $), x.countChilds > 0 && (N += 1);
|
|
1838
1838
|
}
|
|
1839
|
-
M != null && (w.push(M), u += 1,
|
|
1839
|
+
M != null && (w.push(M), u += 1, d += i.tokens);
|
|
1840
1840
|
const b = w.map(($) => ({
|
|
1841
|
-
text:
|
|
1841
|
+
text: i.getReportText($)
|
|
1842
1842
|
}));
|
|
1843
|
-
if (
|
|
1844
|
-
if (
|
|
1843
|
+
if (f != null) {
|
|
1844
|
+
if (f.childs != null)
|
|
1845
1845
|
throw new Error("Impossible behavior: reportNode.childs != null");
|
|
1846
|
-
|
|
1846
|
+
f.childs = b;
|
|
1847
1847
|
} else {
|
|
1848
|
-
if (
|
|
1848
|
+
if (l != null)
|
|
1849
1849
|
throw new Error("Impossible behavior: reportRootNodes != null");
|
|
1850
|
-
|
|
1850
|
+
l = b;
|
|
1851
1851
|
}
|
|
1852
1852
|
} else {
|
|
1853
|
-
u += h.countChilds,
|
|
1853
|
+
u += h.countChilds, d += h.tokensChilds;
|
|
1854
1854
|
const w = [];
|
|
1855
1855
|
for (let M = 0; M < m.length; M++) {
|
|
1856
|
-
const
|
|
1857
|
-
text:
|
|
1856
|
+
const N = m[M], b = {
|
|
1857
|
+
text: N.text
|
|
1858
1858
|
};
|
|
1859
1859
|
w.push(b);
|
|
1860
|
-
const $ = s.getChilds(
|
|
1860
|
+
const $ = s.getChilds(N);
|
|
1861
1861
|
$ != null && $.length > 0 && t.enqueue({
|
|
1862
1862
|
reportNode: b,
|
|
1863
|
-
node:
|
|
1863
|
+
node: N
|
|
1864
1864
|
});
|
|
1865
1865
|
}
|
|
1866
|
-
if (
|
|
1867
|
-
if (
|
|
1866
|
+
if (f != null) {
|
|
1867
|
+
if (f.childs != null)
|
|
1868
1868
|
throw new Error("Impossible behavior: reportNode.childs != null");
|
|
1869
|
-
|
|
1869
|
+
f.childs = w;
|
|
1870
1870
|
} else {
|
|
1871
|
-
if (
|
|
1871
|
+
if (l != null)
|
|
1872
1872
|
throw new Error("Impossible behavior: reportRootNodes != null");
|
|
1873
|
-
|
|
1873
|
+
l = w;
|
|
1874
1874
|
}
|
|
1875
1875
|
}
|
|
1876
1876
|
}
|
|
1877
|
-
return
|
|
1877
|
+
return l ?? [];
|
|
1878
1878
|
}
|
|
1879
1879
|
function pt(r) {
|
|
1880
1880
|
const {
|
|
1881
1881
|
tree: t,
|
|
1882
1882
|
request: { parentNodeId: s, childsIndexRange: o, limits: e },
|
|
1883
1883
|
indexRangeGroupStrategy: n,
|
|
1884
|
-
...
|
|
1884
|
+
...a
|
|
1885
1885
|
} = r;
|
|
1886
|
-
let
|
|
1886
|
+
let i;
|
|
1887
1887
|
if (s != null) {
|
|
1888
|
-
const
|
|
1889
|
-
if (
|
|
1888
|
+
const f = t.getNode(s);
|
|
1889
|
+
if (f == null)
|
|
1890
1890
|
throw new Error(`Parent node "${s}" not found`);
|
|
1891
|
-
|
|
1891
|
+
i = f;
|
|
1892
1892
|
} else
|
|
1893
|
-
|
|
1894
|
-
let
|
|
1893
|
+
i = t.root;
|
|
1894
|
+
let c, l = t.getChilds(i) ?? [];
|
|
1895
1895
|
if (o != null) {
|
|
1896
|
-
const [
|
|
1897
|
-
if (
|
|
1896
|
+
const [f, h] = o;
|
|
1897
|
+
if (f < 0 || h <= f || h >= l.length)
|
|
1898
1898
|
throw new Error(
|
|
1899
|
-
`Invalid index range: ${
|
|
1899
|
+
`Invalid index range: ${f}-${h} for root nodes length ${l.length}`
|
|
1900
1900
|
);
|
|
1901
1901
|
const m = [];
|
|
1902
1902
|
let g = null;
|
|
1903
|
-
for (let y =
|
|
1904
|
-
const w =
|
|
1903
|
+
for (let y = f; y <= h; y++) {
|
|
1904
|
+
const w = l[y];
|
|
1905
1905
|
m.push(w), g = n.add(g, w, y);
|
|
1906
1906
|
}
|
|
1907
|
-
|
|
1908
|
-
...
|
|
1907
|
+
l = m, c = {
|
|
1908
|
+
...i,
|
|
1909
1909
|
text: n.getReportText(g),
|
|
1910
1910
|
countChilds: g.countGrouped,
|
|
1911
1911
|
tokensChilds: g.tokensGrouped
|
|
1912
1912
|
};
|
|
1913
1913
|
} else
|
|
1914
|
-
|
|
1914
|
+
c = i;
|
|
1915
1915
|
const u = {
|
|
1916
1916
|
countChilds: 1,
|
|
1917
|
-
tokensChilds:
|
|
1918
|
-
},
|
|
1917
|
+
tokensChilds: c.tokens
|
|
1918
|
+
}, d = {
|
|
1919
1919
|
...t,
|
|
1920
1920
|
root: u,
|
|
1921
|
-
getChilds: (
|
|
1921
|
+
getChilds: (f) => f === u ? [c] : f === c ? l : t.getChilds(f)
|
|
1922
1922
|
};
|
|
1923
|
-
return
|
|
1924
|
-
tree:
|
|
1923
|
+
return Kr({
|
|
1924
|
+
tree: d,
|
|
1925
1925
|
limits: e,
|
|
1926
1926
|
indexRangeGroupStrategy: n,
|
|
1927
|
-
...
|
|
1927
|
+
...a
|
|
1928
1928
|
});
|
|
1929
1929
|
}
|
|
1930
1930
|
function mt(r, t) {
|
|
@@ -1932,19 +1932,19 @@ function mt(r, t) {
|
|
|
1932
1932
|
return "No results found";
|
|
1933
1933
|
let s = "";
|
|
1934
1934
|
function o(e, n) {
|
|
1935
|
-
for (let
|
|
1936
|
-
const
|
|
1937
|
-
s += n, s +=
|
|
1938
|
-
`,
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
),
|
|
1935
|
+
for (let a = 0, i = e.length; a < i; a++) {
|
|
1936
|
+
const c = e[a];
|
|
1937
|
+
s += n, s += c.text.textOpen + `
|
|
1938
|
+
`, c.childs != null && c.childs.length > 0 && o(
|
|
1939
|
+
c.childs,
|
|
1940
|
+
c.text.indent ? n + " " : n
|
|
1941
|
+
), c.text.textClose != null && (s += n, s += c.text.textClose + `
|
|
1942
1942
|
`);
|
|
1943
1943
|
}
|
|
1944
1944
|
}
|
|
1945
1945
|
return o(r, ""), s;
|
|
1946
1946
|
}
|
|
1947
|
-
class
|
|
1947
|
+
class Wr {
|
|
1948
1948
|
tokens = 16;
|
|
1949
1949
|
// +1 indent, +1 for line break
|
|
1950
1950
|
getReportText = (t) => ({
|
|
@@ -1961,7 +1961,7 @@ class qr {
|
|
|
1961
1961
|
}
|
|
1962
1962
|
const gt = p.object({
|
|
1963
1963
|
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
1964
|
-
snapshot:
|
|
1964
|
+
snapshot: X.optional().describe(
|
|
1965
1965
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
1966
1966
|
),
|
|
1967
1967
|
parentPath: p.string().optional().describe(
|
|
@@ -1981,7 +1981,7 @@ const gt = p.object({
|
|
|
1981
1981
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
1982
1982
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
1983
1983
|
});
|
|
1984
|
-
async function
|
|
1984
|
+
async function Hr(r, t, s) {
|
|
1985
1985
|
let o;
|
|
1986
1986
|
try {
|
|
1987
1987
|
o = gt.parse(r);
|
|
@@ -1993,29 +1993,29 @@ async function Gr(r, t, s) {
|
|
|
1993
1993
|
const {
|
|
1994
1994
|
snapshotName: e,
|
|
1995
1995
|
snapshot: n,
|
|
1996
|
-
childsIndexRange:
|
|
1996
|
+
childsIndexRange: a
|
|
1997
1997
|
// maxCountTotal,
|
|
1998
1998
|
// maxTokensTotal,
|
|
1999
1999
|
// maxCountGroup,
|
|
2000
2000
|
// maxTokensGroup,
|
|
2001
|
-
} = o,
|
|
2001
|
+
} = o, i = 60, c = 1e3, l = 25, u = 900;
|
|
2002
2002
|
if (!s.sessionId)
|
|
2003
2003
|
return {
|
|
2004
2004
|
error: "Session ID is required"
|
|
2005
2005
|
};
|
|
2006
|
-
const
|
|
2006
|
+
const d = Z(s.sessionId);
|
|
2007
2007
|
if (e && n)
|
|
2008
2008
|
return {
|
|
2009
2009
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
2010
2010
|
};
|
|
2011
|
-
let
|
|
2011
|
+
let f, h = !1, m = !1;
|
|
2012
2012
|
if (e) {
|
|
2013
|
-
if (
|
|
2013
|
+
if (f = d.fsSnapshots.get(e), f == null)
|
|
2014
2014
|
return {
|
|
2015
2015
|
error: `Filesystem snapshot "${e}" not found`
|
|
2016
2016
|
};
|
|
2017
2017
|
} else if (n) {
|
|
2018
|
-
const g = await
|
|
2018
|
+
const g = await le(
|
|
2019
2019
|
n,
|
|
2020
2020
|
t,
|
|
2021
2021
|
s
|
|
@@ -2024,32 +2024,32 @@ async function Gr(r, t, s) {
|
|
|
2024
2024
|
return {
|
|
2025
2025
|
error: g.error
|
|
2026
2026
|
};
|
|
2027
|
-
|
|
2027
|
+
f = g.fsSnapshot, h = g.queryCreated, m = !0;
|
|
2028
2028
|
} else
|
|
2029
2029
|
return {
|
|
2030
2030
|
error: "Either snapshotName or snapshot must be provided"
|
|
2031
2031
|
};
|
|
2032
2032
|
try {
|
|
2033
|
-
const g =
|
|
2034
|
-
tree:
|
|
2033
|
+
const g = pe(o.parentPath), y = pt({
|
|
2034
|
+
tree: f.tree,
|
|
2035
2035
|
request: {
|
|
2036
2036
|
parentNodeId: g,
|
|
2037
|
-
childsIndexRange:
|
|
2037
|
+
childsIndexRange: a,
|
|
2038
2038
|
limits: {
|
|
2039
|
-
maxCountTotal:
|
|
2040
|
-
maxTokensTotal:
|
|
2041
|
-
maxCountGroup:
|
|
2039
|
+
maxCountTotal: i,
|
|
2040
|
+
maxTokensTotal: c,
|
|
2041
|
+
maxCountGroup: l,
|
|
2042
2042
|
maxTokensGroup: u
|
|
2043
2043
|
}
|
|
2044
2044
|
},
|
|
2045
|
-
indexRangeGroupStrategy: new
|
|
2045
|
+
indexRangeGroupStrategy: new Wr()
|
|
2046
2046
|
}), w = mt(y);
|
|
2047
2047
|
return {
|
|
2048
|
-
fsSnapshot:
|
|
2048
|
+
fsSnapshot: f,
|
|
2049
2049
|
queryCreated: h,
|
|
2050
2050
|
snapshotCreated: m,
|
|
2051
2051
|
parentPath: g,
|
|
2052
|
-
childsIndexRange:
|
|
2052
|
+
childsIndexRange: a,
|
|
2053
2053
|
report: w
|
|
2054
2054
|
};
|
|
2055
2055
|
} catch (g) {
|
|
@@ -2058,7 +2058,7 @@ async function Gr(r, t, s) {
|
|
|
2058
2058
|
};
|
|
2059
2059
|
}
|
|
2060
2060
|
}
|
|
2061
|
-
function
|
|
2061
|
+
function Qr(r, t) {
|
|
2062
2062
|
r(
|
|
2063
2063
|
"fs-snapshot-browse",
|
|
2064
2064
|
{
|
|
@@ -2067,7 +2067,7 @@ function jr(r, t) {
|
|
|
2067
2067
|
inputSchema: gt.shape
|
|
2068
2068
|
},
|
|
2069
2069
|
async (s, o) => {
|
|
2070
|
-
const e = await
|
|
2070
|
+
const e = await Hr(s, t, o);
|
|
2071
2071
|
if (e.error != null)
|
|
2072
2072
|
return `Method: fs-snapshot-browse(${JSON.stringify(s)})
|
|
2073
2073
|
❌ Error: ${e.error}`;
|
|
@@ -2078,10 +2078,10 @@ function jr(r, t) {
|
|
|
2078
2078
|
`), n += `✅ Browsing filesystem snapshot "${e.fsSnapshot.name}":
|
|
2079
2079
|
`, n += `Root directory (<root>/): ${e.fsSnapshot.query.rootDir || "./"}
|
|
2080
2080
|
`, n += `Parent path: ${"./" + (e.parentPath ?? "")}
|
|
2081
|
-
`, n += `Fields: ${e.fsSnapshot.query.fields.map((
|
|
2081
|
+
`, n += `Fields: ${e.fsSnapshot.query.fields.map((a) => a === "dateModified" ? "lastModified" : a).join(" ")}
|
|
2082
2082
|
`, e.childsIndexRange) {
|
|
2083
|
-
const [
|
|
2084
|
-
n += ` Showing indexes: ${
|
|
2083
|
+
const [a, i] = e.childsIndexRange, l = (e.parentPath ? e.fsSnapshot.tree.getNode(e.parentPath) : e.fsSnapshot.tree.root).countChilds;
|
|
2084
|
+
n += ` Showing indexes: ${a}-${i} of ${l}
|
|
2085
2085
|
`;
|
|
2086
2086
|
}
|
|
2087
2087
|
return n += `
|
|
@@ -2089,85 +2089,85 @@ ${e.report}`, n;
|
|
|
2089
2089
|
}
|
|
2090
2090
|
);
|
|
2091
2091
|
}
|
|
2092
|
-
function
|
|
2092
|
+
function wt(r) {
|
|
2093
2093
|
const t = [], s = r.tree, o = r.query.rootDir ?? ".";
|
|
2094
2094
|
function e(n) {
|
|
2095
2095
|
n.type === "file" && n.isMatched && t.push(o + "/" + n.path);
|
|
2096
|
-
const
|
|
2097
|
-
if (
|
|
2098
|
-
for (let
|
|
2099
|
-
e(i
|
|
2096
|
+
const a = s.getChilds(n);
|
|
2097
|
+
if (a != null)
|
|
2098
|
+
for (let i = 0; i < a.length; i++)
|
|
2099
|
+
e(a[i]);
|
|
2100
2100
|
}
|
|
2101
2101
|
return e(s.root), t;
|
|
2102
2102
|
}
|
|
2103
|
-
const
|
|
2104
|
-
function
|
|
2103
|
+
const _e = /* @__PURE__ */ new Map();
|
|
2104
|
+
function Yr(r) {
|
|
2105
2105
|
const t = H(r);
|
|
2106
|
-
let s =
|
|
2107
|
-
return s == null && (s = new
|
|
2106
|
+
let s = _e.get(t);
|
|
2107
|
+
return s == null && (s = new jt(), _e.set(t, s)), s;
|
|
2108
2108
|
}
|
|
2109
|
-
async function
|
|
2109
|
+
async function Vr(r) {
|
|
2110
2110
|
const { filePath: t, func: s } = r;
|
|
2111
|
-
return
|
|
2111
|
+
return Yr(t).lock(
|
|
2112
2112
|
() => Y({
|
|
2113
|
-
pool:
|
|
2113
|
+
pool: ye,
|
|
2114
2114
|
count: 1,
|
|
2115
2115
|
func: s
|
|
2116
2116
|
})
|
|
2117
2117
|
);
|
|
2118
2118
|
}
|
|
2119
|
-
const Ge = 10,
|
|
2120
|
-
function
|
|
2119
|
+
const Ge = 10, te = 48, Je = 57, ue = 36, Zr = 38, Xr = 39, es = 60, ts = 62, rs = 96, re = 0, je = 1, Ke = 2, We = 3, He = 4, ss = 5;
|
|
2120
|
+
function os(r) {
|
|
2121
2121
|
const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
|
|
2122
2122
|
for (let b = 0; b < e; b++)
|
|
2123
2123
|
t.charCodeAt(b) === Ge && b + 1 < e && n.push(b + 1);
|
|
2124
|
-
const
|
|
2125
|
-
let
|
|
2124
|
+
const a = n.length, i = [], c = [];
|
|
2125
|
+
let l = null, u = null, d = null, f = 0;
|
|
2126
2126
|
if (o != null) {
|
|
2127
2127
|
const b = o.length;
|
|
2128
2128
|
let $ = !1;
|
|
2129
2129
|
for (let S = 0; S < b; S++)
|
|
2130
|
-
if (o.charCodeAt(S) ===
|
|
2130
|
+
if (o.charCodeAt(S) === ue) {
|
|
2131
2131
|
$ = !0;
|
|
2132
2132
|
break;
|
|
2133
2133
|
}
|
|
2134
2134
|
if ($) {
|
|
2135
|
-
u = [],
|
|
2135
|
+
u = [], d = [];
|
|
2136
2136
|
let S = 0, x = 0;
|
|
2137
2137
|
for (; x < b; ) {
|
|
2138
|
-
if (o.charCodeAt(x) !==
|
|
2138
|
+
if (o.charCodeAt(x) !== ue || x + 1 >= b) {
|
|
2139
2139
|
x++;
|
|
2140
2140
|
continue;
|
|
2141
2141
|
}
|
|
2142
2142
|
const T = o.charCodeAt(x + 1);
|
|
2143
2143
|
let v = -1, L = 0, k = 2;
|
|
2144
|
-
if (T ===
|
|
2145
|
-
v =
|
|
2146
|
-
else if (T === Hr)
|
|
2147
|
-
v = Je;
|
|
2144
|
+
if (T === ue)
|
|
2145
|
+
v = re, L = "$";
|
|
2148
2146
|
else if (T === Zr)
|
|
2147
|
+
v = je;
|
|
2148
|
+
else if (T === rs)
|
|
2149
2149
|
v = Ke;
|
|
2150
|
-
else if (T ===
|
|
2150
|
+
else if (T === Xr)
|
|
2151
2151
|
v = We;
|
|
2152
|
-
else if (T >=
|
|
2152
|
+
else if (T >= te && T <= Je) {
|
|
2153
2153
|
let I = x + 2;
|
|
2154
2154
|
for (; I < b; ) {
|
|
2155
2155
|
const C = o.charCodeAt(I);
|
|
2156
|
-
if (C <
|
|
2156
|
+
if (C < te || C > Je) break;
|
|
2157
2157
|
I++;
|
|
2158
2158
|
}
|
|
2159
2159
|
v = He, L = o.substring(x + 1, I), k = I - x;
|
|
2160
|
-
} else if (T ===
|
|
2160
|
+
} else if (T === es) {
|
|
2161
2161
|
let I = x + 2;
|
|
2162
|
-
for (; I < b && o.charCodeAt(I) !==
|
|
2162
|
+
for (; I < b && o.charCodeAt(I) !== ts; )
|
|
2163
2163
|
I++;
|
|
2164
|
-
I < b && I > x + 2 && (v =
|
|
2164
|
+
I < b && I > x + 2 && (v = ss, L = o.substring(x + 2, I), k = I + 1 - x);
|
|
2165
2165
|
}
|
|
2166
|
-
v >= 0 ? (x > S && (u.push(
|
|
2166
|
+
v >= 0 ? (x > S && (u.push(re), d.push(o.substring(S, x))), u.push(v), d.push(L), x += k, S = x) : x++;
|
|
2167
2167
|
}
|
|
2168
|
-
S < b && (u.push(
|
|
2168
|
+
S < b && (u.push(re), d.push(o.substring(S))), f = u.length;
|
|
2169
2169
|
} else
|
|
2170
|
-
|
|
2170
|
+
l = o;
|
|
2171
2171
|
}
|
|
2172
2172
|
let h = "", m = 0, g = 0;
|
|
2173
2173
|
s.lastIndex = 0;
|
|
@@ -2175,44 +2175,44 @@ function es(r) {
|
|
|
2175
2175
|
for (; (y = s.exec(t)) !== null; ) {
|
|
2176
2176
|
const b = y.index, $ = y[0], S = $.length, x = b + S;
|
|
2177
2177
|
let T, v, L, k;
|
|
2178
|
-
if (
|
|
2178
|
+
if (a === 1)
|
|
2179
2179
|
T = 0, v = 1, L = 0, k = e;
|
|
2180
2180
|
else {
|
|
2181
|
-
let I = 0, C =
|
|
2181
|
+
let I = 0, C = a - 1;
|
|
2182
2182
|
for (; I < C; ) {
|
|
2183
|
-
const
|
|
2184
|
-
n[
|
|
2183
|
+
const E = I + C + 1 >> 1;
|
|
2184
|
+
n[E] <= b ? I = E : C = E - 1;
|
|
2185
2185
|
}
|
|
2186
2186
|
if (T = I, S > 0) {
|
|
2187
|
-
const
|
|
2188
|
-
for (C =
|
|
2187
|
+
const E = x - 1;
|
|
2188
|
+
for (C = a - 1; I < C; ) {
|
|
2189
2189
|
const O = I + C + 1 >> 1;
|
|
2190
|
-
n[O] <=
|
|
2190
|
+
n[O] <= E ? I = O : C = O - 1;
|
|
2191
2191
|
}
|
|
2192
2192
|
v = I + 1;
|
|
2193
2193
|
} else
|
|
2194
2194
|
v = T + 1;
|
|
2195
|
-
L = n[T], k = v <
|
|
2195
|
+
L = n[T], k = v < a ? n[v] : e;
|
|
2196
2196
|
}
|
|
2197
|
-
if (
|
|
2197
|
+
if (i.push({
|
|
2198
2198
|
offset: [b, x],
|
|
2199
2199
|
lines: [T, v],
|
|
2200
2200
|
linesOffset: [L, k]
|
|
2201
2201
|
}), o != null) {
|
|
2202
2202
|
h += t.substring(m, b);
|
|
2203
2203
|
let I;
|
|
2204
|
-
if (
|
|
2205
|
-
I =
|
|
2204
|
+
if (l != null)
|
|
2205
|
+
I = l;
|
|
2206
2206
|
else {
|
|
2207
2207
|
I = "";
|
|
2208
|
-
const
|
|
2209
|
-
for (let K = 0; K <
|
|
2210
|
-
const _ = u[K], A =
|
|
2208
|
+
const E = y.groups, O = y.length - 1;
|
|
2209
|
+
for (let K = 0; K < f; K++) {
|
|
2210
|
+
const _ = u[K], A = d[K];
|
|
2211
2211
|
switch (_) {
|
|
2212
|
-
case
|
|
2212
|
+
case re:
|
|
2213
2213
|
I += A;
|
|
2214
2214
|
break;
|
|
2215
|
-
case
|
|
2215
|
+
case je:
|
|
2216
2216
|
I += $;
|
|
2217
2217
|
break;
|
|
2218
2218
|
case Ke:
|
|
@@ -2222,9 +2222,9 @@ function es(r) {
|
|
|
2222
2222
|
I += t.substring(x);
|
|
2223
2223
|
break;
|
|
2224
2224
|
case He: {
|
|
2225
|
-
const P = A, U = P.length, z = P.charCodeAt(0) -
|
|
2225
|
+
const P = A, U = P.length, z = P.charCodeAt(0) - te;
|
|
2226
2226
|
if (U >= 2) {
|
|
2227
|
-
const
|
|
2227
|
+
const G = P.charCodeAt(1) - te, D = z * 10 + G;
|
|
2228
2228
|
if (D >= 1 && D <= O) {
|
|
2229
2229
|
I += y[D] ?? "", U > 2 && (I += P.substring(2));
|
|
2230
2230
|
break;
|
|
@@ -2234,13 +2234,13 @@ function es(r) {
|
|
|
2234
2234
|
break;
|
|
2235
2235
|
}
|
|
2236
2236
|
default:
|
|
2237
|
-
|
|
2237
|
+
E != null ? I += E[A] ?? "" : I += "$<" + A + ">";
|
|
2238
2238
|
}
|
|
2239
2239
|
}
|
|
2240
2240
|
}
|
|
2241
2241
|
h += I;
|
|
2242
2242
|
const C = b + g;
|
|
2243
|
-
|
|
2243
|
+
c.push({
|
|
2244
2244
|
offset: [C, C + I.length],
|
|
2245
2245
|
lines: [0, 0],
|
|
2246
2246
|
linesOffset: [0, 0]
|
|
@@ -2250,153 +2250,185 @@ function es(r) {
|
|
|
2250
2250
|
break;
|
|
2251
2251
|
}
|
|
2252
2252
|
if (s.lastIndex = 0, o == null)
|
|
2253
|
-
return { search: { content: t, matches:
|
|
2253
|
+
return { search: { content: t, matches: i }, replace: null };
|
|
2254
2254
|
h += t.substring(m);
|
|
2255
2255
|
const w = h.length, M = [0];
|
|
2256
2256
|
for (let b = 0; b < w; b++)
|
|
2257
2257
|
h.charCodeAt(b) === Ge && b + 1 < w && M.push(b + 1);
|
|
2258
|
-
const
|
|
2259
|
-
for (let b = 0, $ =
|
|
2260
|
-
const S =
|
|
2258
|
+
const N = M.length;
|
|
2259
|
+
for (let b = 0, $ = c.length; b < $; b++) {
|
|
2260
|
+
const S = c[b], x = S.offset[0], T = S.offset[1];
|
|
2261
2261
|
let v, L, k, I;
|
|
2262
|
-
if (
|
|
2262
|
+
if (N === 1)
|
|
2263
2263
|
v = 0, L = 1, k = 0, I = w;
|
|
2264
2264
|
else {
|
|
2265
|
-
let C = 0,
|
|
2266
|
-
for (; C <
|
|
2267
|
-
const O = C +
|
|
2268
|
-
M[O] <= x ? C = O :
|
|
2265
|
+
let C = 0, E = N - 1;
|
|
2266
|
+
for (; C < E; ) {
|
|
2267
|
+
const O = C + E + 1 >> 1;
|
|
2268
|
+
M[O] <= x ? C = O : E = O - 1;
|
|
2269
2269
|
}
|
|
2270
2270
|
if (v = C, T > x) {
|
|
2271
2271
|
const O = T - 1;
|
|
2272
|
-
for (
|
|
2273
|
-
const K = C +
|
|
2274
|
-
M[K] <= O ? C = K :
|
|
2272
|
+
for (E = N - 1; C < E; ) {
|
|
2273
|
+
const K = C + E + 1 >> 1;
|
|
2274
|
+
M[K] <= O ? C = K : E = K - 1;
|
|
2275
2275
|
}
|
|
2276
2276
|
L = C + 1;
|
|
2277
2277
|
} else
|
|
2278
2278
|
L = v + 1;
|
|
2279
|
-
k = M[v], I = L <
|
|
2279
|
+
k = M[v], I = L < N ? M[L] : w;
|
|
2280
2280
|
}
|
|
2281
2281
|
S.lines[0] = v, S.lines[1] = L, S.linesOffset[0] = k, S.linesOffset[1] = I;
|
|
2282
2282
|
}
|
|
2283
2283
|
return {
|
|
2284
|
-
search: { content: t, matches:
|
|
2285
|
-
replace: { content: h, matches:
|
|
2284
|
+
search: { content: t, matches: i },
|
|
2285
|
+
replace: { content: h, matches: c }
|
|
2286
2286
|
};
|
|
2287
2287
|
}
|
|
2288
|
-
function
|
|
2288
|
+
function yt(r) {
|
|
2289
|
+
if (r.length === 0)
|
|
2290
|
+
return [];
|
|
2291
|
+
const t = [...r].sort((a, i) => {
|
|
2292
|
+
const c = a.lines[0], l = i.lines[0];
|
|
2293
|
+
if (c > l) return 1;
|
|
2294
|
+
if (c < l) return -1;
|
|
2295
|
+
const u = a.lines[1], d = i.lines[1];
|
|
2296
|
+
return u > d ? 1 : u < d ? -1 : 0;
|
|
2297
|
+
}), s = [];
|
|
2298
|
+
let o = [...t[0].offset], e = [...t[0].lines], n = [...t[0].linesOffset];
|
|
2299
|
+
for (let a = 1; a < t.length; a++) {
|
|
2300
|
+
const i = t[a];
|
|
2301
|
+
i.lines[0] <= e[1] ? (i.offset[0] < o[0] && (o[0] = i.offset[0]), i.offset[1] > o[1] && (o[1] = i.offset[1]), i.lines[1] > e[1] && (e[1] = i.lines[1], n[1] = i.linesOffset[1])) : (s.push({
|
|
2302
|
+
offset: o,
|
|
2303
|
+
lines: e,
|
|
2304
|
+
linesOffset: n
|
|
2305
|
+
}), o = [...i.offset], e = [...i.lines], n = [...i.linesOffset]);
|
|
2306
|
+
}
|
|
2307
|
+
return s.push({
|
|
2308
|
+
offset: o,
|
|
2309
|
+
lines: e,
|
|
2310
|
+
linesOffset: n
|
|
2311
|
+
}), s;
|
|
2312
|
+
}
|
|
2313
|
+
function se(r, t, s, o) {
|
|
2289
2314
|
let e = 0, n = 0;
|
|
2290
2315
|
for (let u = 0; u < s; u++)
|
|
2291
2316
|
r.charCodeAt(u) === 10 && (n = u + 1, e++);
|
|
2292
|
-
const
|
|
2293
|
-
let
|
|
2294
|
-
for (;
|
|
2295
|
-
r.charCodeAt(
|
|
2296
|
-
const
|
|
2297
|
-
for (;
|
|
2298
|
-
if (r.charCodeAt(
|
|
2299
|
-
return { startLine:
|
|
2300
|
-
return { startLine:
|
|
2301
|
-
}
|
|
2302
|
-
function
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2317
|
+
const a = e, i = n;
|
|
2318
|
+
let c = s;
|
|
2319
|
+
for (; c < o; c++)
|
|
2320
|
+
r.charCodeAt(c) === 10 && e++;
|
|
2321
|
+
const l = e + 1;
|
|
2322
|
+
for (; c < t; c++)
|
|
2323
|
+
if (r.charCodeAt(c) === 10)
|
|
2324
|
+
return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: c + 1 };
|
|
2325
|
+
return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: t };
|
|
2326
|
+
}
|
|
2327
|
+
function ns(r, t) {
|
|
2328
|
+
if (r.replace == null && t.replace == null) {
|
|
2329
|
+
const q = [...r.search.matches, ...t.search.matches];
|
|
2330
|
+
return {
|
|
2331
|
+
search: { content: r.search.content, matches: yt(q) },
|
|
2332
|
+
replace: null
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
const s = r.replace ?? r.search, o = t.replace ?? t.search, e = r.search.content, n = o.content, a = e.length, i = n.length, c = r.search.matches, l = s.matches, u = t.search.matches, d = o.matches, f = l.length, h = u.length, m = [], g = [];
|
|
2336
|
+
let y = 0, w = 0, M = 0, N = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, L = 0, k = 0, I = 0, C = 0, E = 0, O = 0, K = 0, _ = 0, A = 0, P = 0, U = 0, z = 0, G = 0, D = 0;
|
|
2337
|
+
for (; y < f || w < h; )
|
|
2338
|
+
if (y < f && (b = l[y].offset[0], $ = l[y].offset[1]), w < h && (S = u[w].offset[0], x = u[w].offset[1]), y < f && w < h && b < x && S < $) {
|
|
2307
2339
|
K = b < S ? b : S, T = $ > x ? $ : x, L = y, k = w, y++, w++;
|
|
2308
2340
|
do {
|
|
2309
|
-
for (v = T; y <
|
|
2310
|
-
$ =
|
|
2341
|
+
for (v = T; y < f && l[y].offset[0] < T; )
|
|
2342
|
+
$ = l[y].offset[1], $ > T && (T = $), y++;
|
|
2311
2343
|
for (; w < h && u[w].offset[0] < T; )
|
|
2312
2344
|
x = u[w].offset[1], x > T && (T = x), w++;
|
|
2313
2345
|
} while (T !== v);
|
|
2314
2346
|
I = 1 / 0, C = -1 / 0, _ = K, A = M;
|
|
2315
|
-
for (let
|
|
2316
|
-
P =
|
|
2317
|
-
_ < T && (D = _ + A, D < I && (I = D), D = T + A, D > C && (C = D)), M = A,
|
|
2318
|
-
for (let
|
|
2319
|
-
P = u[
|
|
2320
|
-
_ < T && (D = _ + A, D <
|
|
2321
|
-
const
|
|
2347
|
+
for (let J = L; J < y; J++)
|
|
2348
|
+
P = c[J].offset[0], U = c[J].offset[1], z = l[J].offset[0], G = l[J].offset[1], _ < z && (D = _ + A, D < I && (I = D), D = z + A, D > C && (C = D)), P < I && (I = P), U > C && (C = U), A += U - P - G + z, _ = G;
|
|
2349
|
+
_ < T && (D = _ + A, D < I && (I = D), D = T + A, D > C && (C = D)), M = A, E = 1 / 0, O = -1 / 0, _ = K, A = N;
|
|
2350
|
+
for (let J = k; J < w; J++)
|
|
2351
|
+
P = u[J].offset[0], U = u[J].offset[1], z = d[J].offset[0], G = d[J].offset[1], _ < P && (D = _ + A, D < E && (E = D), D = P + A, D > O && (O = D)), z < E && (E = z), G > O && (O = G), A += G - z - U + P, _ = U;
|
|
2352
|
+
_ < T && (D = _ + A, D < E && (E = D), D = T + A, D > O && (O = D)), N = A;
|
|
2353
|
+
const q = se(e, a, I, C);
|
|
2322
2354
|
m.push({
|
|
2323
2355
|
offset: [I, C],
|
|
2324
|
-
lines: [
|
|
2325
|
-
linesOffset: [
|
|
2356
|
+
lines: [q.startLine, q.endLine],
|
|
2357
|
+
linesOffset: [q.startLineOfs, q.endLineOfs]
|
|
2326
2358
|
});
|
|
2327
|
-
const
|
|
2359
|
+
const ee = se(n, i, E, O);
|
|
2328
2360
|
g.push({
|
|
2329
|
-
offset: [
|
|
2330
|
-
lines: [
|
|
2331
|
-
linesOffset: [
|
|
2361
|
+
offset: [E, O],
|
|
2362
|
+
lines: [ee.startLine, ee.endLine],
|
|
2363
|
+
linesOffset: [ee.startLineOfs, ee.endLineOfs]
|
|
2332
2364
|
});
|
|
2333
|
-
} else if (w >= h || y <
|
|
2334
|
-
P =
|
|
2335
|
-
const
|
|
2336
|
-
m.push(
|
|
2337
|
-
offset: [
|
|
2338
|
-
lines: [
|
|
2339
|
-
linesOffset: [
|
|
2340
|
-
}), M += U - P -
|
|
2365
|
+
} else if (w >= h || y < f && b <= S) {
|
|
2366
|
+
P = c[y].offset[0], U = c[y].offset[1], z = l[y].offset[0], G = l[y].offset[1], E = z + N, O = G + N;
|
|
2367
|
+
const q = se(n, i, E, O);
|
|
2368
|
+
m.push(c[y]), g.push({
|
|
2369
|
+
offset: [E, O],
|
|
2370
|
+
lines: [q.startLine, q.endLine],
|
|
2371
|
+
linesOffset: [q.startLineOfs, q.endLineOfs]
|
|
2372
|
+
}), M += U - P - G + z, y++;
|
|
2341
2373
|
} else {
|
|
2342
|
-
P = u[w].offset[0], U = u[w].offset[1], z =
|
|
2343
|
-
const
|
|
2374
|
+
P = u[w].offset[0], U = u[w].offset[1], z = d[w].offset[0], G = d[w].offset[1], I = P + M, C = U + M;
|
|
2375
|
+
const q = se(e, a, I, C);
|
|
2344
2376
|
m.push({
|
|
2345
2377
|
offset: [I, C],
|
|
2346
|
-
lines: [
|
|
2347
|
-
linesOffset: [
|
|
2348
|
-
}), g.push(
|
|
2378
|
+
lines: [q.startLine, q.endLine],
|
|
2379
|
+
linesOffset: [q.startLineOfs, q.endLineOfs]
|
|
2380
|
+
}), g.push(d[w]), N += G - z - U + P, w++;
|
|
2349
2381
|
}
|
|
2350
2382
|
return {
|
|
2351
2383
|
search: { content: e, matches: m },
|
|
2352
2384
|
replace: { content: n, matches: g }
|
|
2353
2385
|
};
|
|
2354
2386
|
}
|
|
2355
|
-
async function
|
|
2387
|
+
async function is(r) {
|
|
2356
2388
|
const { filePath: t, operations: s, dryRun: o } = r;
|
|
2357
|
-
return s.length === 0 ? { filePath: t, result: null } :
|
|
2389
|
+
return s.length === 0 ? { filePath: t, result: null } : Vr({
|
|
2358
2390
|
filePath: t,
|
|
2359
2391
|
func: async () => {
|
|
2360
2392
|
let e;
|
|
2361
2393
|
try {
|
|
2362
2394
|
e = await W.promises.readFile(t, "utf-8");
|
|
2363
|
-
} catch (
|
|
2395
|
+
} catch (i) {
|
|
2364
2396
|
return {
|
|
2365
2397
|
filePath: t,
|
|
2366
2398
|
result: null,
|
|
2367
|
-
error: `Failed to read file: ${
|
|
2399
|
+
error: `Failed to read file: ${i instanceof Error ? i.message : i + ""}`
|
|
2368
2400
|
};
|
|
2369
2401
|
}
|
|
2370
|
-
let n = null,
|
|
2371
|
-
for (let
|
|
2372
|
-
const
|
|
2373
|
-
let
|
|
2402
|
+
let n = null, a = !1;
|
|
2403
|
+
for (let i = 0; i < s.length; i++) {
|
|
2404
|
+
const c = s[i];
|
|
2405
|
+
let l;
|
|
2374
2406
|
try {
|
|
2375
|
-
|
|
2376
|
-
} catch (
|
|
2407
|
+
l = new RegExp(c.pattern, c.flags ?? "");
|
|
2408
|
+
} catch (f) {
|
|
2377
2409
|
return {
|
|
2378
2410
|
filePath: t,
|
|
2379
2411
|
result: null,
|
|
2380
|
-
error: `Invalid RegExp pattern "${
|
|
2412
|
+
error: `Invalid RegExp pattern "${c.pattern}": ${f instanceof Error ? f.message : f + ""}`
|
|
2381
2413
|
};
|
|
2382
2414
|
}
|
|
2383
|
-
const u = n?.replace?.content ?? e,
|
|
2415
|
+
const u = n?.replace?.content ?? e, d = os({
|
|
2384
2416
|
content: u,
|
|
2385
|
-
pattern:
|
|
2386
|
-
replacement:
|
|
2417
|
+
pattern: l,
|
|
2418
|
+
replacement: c.replacement
|
|
2387
2419
|
});
|
|
2388
|
-
|
|
2420
|
+
c.replacement != null && (a = !0), n == null ? n = d : n = ns(n, d);
|
|
2389
2421
|
}
|
|
2390
|
-
if (
|
|
2391
|
-
const
|
|
2392
|
-
if (
|
|
2422
|
+
if (a && n?.replace != null && !o) {
|
|
2423
|
+
const i = n.replace.content;
|
|
2424
|
+
if (i !== e)
|
|
2393
2425
|
try {
|
|
2394
|
-
await W.promises.writeFile(t,
|
|
2395
|
-
} catch (
|
|
2426
|
+
await W.promises.writeFile(t, i, "utf-8");
|
|
2427
|
+
} catch (c) {
|
|
2396
2428
|
return {
|
|
2397
2429
|
filePath: t,
|
|
2398
2430
|
result: n,
|
|
2399
|
-
error: `Failed to write file: ${
|
|
2431
|
+
error: `Failed to write file: ${c instanceof Error ? c.message : c + ""}`
|
|
2400
2432
|
};
|
|
2401
2433
|
}
|
|
2402
2434
|
}
|
|
@@ -2404,78 +2436,55 @@ async function rs(r) {
|
|
|
2404
2436
|
}
|
|
2405
2437
|
});
|
|
2406
2438
|
}
|
|
2407
|
-
async function
|
|
2439
|
+
async function bt(r) {
|
|
2408
2440
|
const { filePaths: t, operations: s, dryRun: o } = r;
|
|
2409
2441
|
return { results: await Promise.all(
|
|
2410
2442
|
t.map(
|
|
2411
|
-
(n) =>
|
|
2443
|
+
(n) => is({ filePath: n, operations: s, dryRun: o })
|
|
2412
2444
|
)
|
|
2413
2445
|
) };
|
|
2414
2446
|
}
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
const a = n.lines[0], l = i.lines[0];
|
|
2420
|
-
if (a > l) return 1;
|
|
2421
|
-
if (a < l) return -1;
|
|
2422
|
-
const c = n.lines[1], u = i.lines[1];
|
|
2423
|
-
return c > u ? 1 : c < u ? -1 : 0;
|
|
2424
|
-
}), s = [];
|
|
2425
|
-
let o = [...t[0].lines], e = [...t[0].linesOffset];
|
|
2426
|
-
for (let n = 1; n < t.length; n++) {
|
|
2427
|
-
const i = t[n];
|
|
2428
|
-
i.lines[0] <= o[1] ? i.lines[1] > o[1] && (o[1] = i.lines[1], e[1] = i.linesOffset[1]) : (s.push({
|
|
2429
|
-
lines: o,
|
|
2430
|
-
linesOffset: e
|
|
2431
|
-
}), o = [...i.lines], e = [...i.linesOffset]);
|
|
2432
|
-
}
|
|
2433
|
-
return s.push({
|
|
2434
|
-
lines: o,
|
|
2435
|
-
linesOffset: e
|
|
2436
|
-
}), s;
|
|
2437
|
-
}
|
|
2438
|
-
const ns = 6;
|
|
2439
|
-
function is(r) {
|
|
2440
|
-
const { content: t, startLine: s } = r, o = r.padWidth ?? ns;
|
|
2441
|
-
let e = "", n = 0, i = 0;
|
|
2447
|
+
const as = 6;
|
|
2448
|
+
function ls(r) {
|
|
2449
|
+
const { content: t, startLine: s } = r, o = r.padWidth ?? as;
|
|
2450
|
+
let e = "", n = 0, a = 0;
|
|
2442
2451
|
for (; n < t.length; ) {
|
|
2443
|
-
const
|
|
2444
|
-
`, n),
|
|
2445
|
-
e += String(s +
|
|
2452
|
+
const i = t.indexOf(`
|
|
2453
|
+
`, n), c = i === -1 ? t.length : i + 1;
|
|
2454
|
+
e += String(s + a + 1).padStart(o) + "→" + t.substring(n, c), n = c, a++;
|
|
2446
2455
|
}
|
|
2447
2456
|
return e.length > 0 && !e.endsWith(`
|
|
2448
2457
|
`) && (e += `
|
|
2449
2458
|
`), e;
|
|
2450
2459
|
}
|
|
2451
|
-
function
|
|
2460
|
+
function de(r) {
|
|
2452
2461
|
const { content: t, matches: s, outputLimit: o } = r;
|
|
2453
2462
|
if (s.length === 0)
|
|
2454
2463
|
return { output: "", truncated: !1 };
|
|
2455
|
-
const e =
|
|
2456
|
-
let n = "",
|
|
2457
|
-
for (let
|
|
2458
|
-
const
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
), u =
|
|
2462
|
-
content:
|
|
2463
|
-
startLine:
|
|
2464
|
-
}),
|
|
2465
|
-
if (o != null && n.length +
|
|
2466
|
-
|
|
2464
|
+
const e = yt(s);
|
|
2465
|
+
let n = "", a = !1;
|
|
2466
|
+
for (let i = 0; i < e.length; i++) {
|
|
2467
|
+
const c = e[i], l = t.substring(
|
|
2468
|
+
c.linesOffset[0],
|
|
2469
|
+
c.linesOffset[1]
|
|
2470
|
+
), u = ls({
|
|
2471
|
+
content: l,
|
|
2472
|
+
startLine: c.lines[0]
|
|
2473
|
+
}), d = i > 0 ? 2 : 0;
|
|
2474
|
+
if (o != null && n.length + d + u.length > o) {
|
|
2475
|
+
a = !0;
|
|
2467
2476
|
break;
|
|
2468
2477
|
}
|
|
2469
|
-
|
|
2478
|
+
i > 0 && (n += `⋮
|
|
2470
2479
|
`), n += u;
|
|
2471
2480
|
}
|
|
2472
|
-
return { output: n, truncated:
|
|
2481
|
+
return { output: n, truncated: a };
|
|
2473
2482
|
}
|
|
2474
2483
|
const Qe = "BEFORE", Ye = "AFTER";
|
|
2475
|
-
function
|
|
2484
|
+
function cs(r) {
|
|
2476
2485
|
const { result: t, outputLimit: s } = r;
|
|
2477
2486
|
if (t.replace == null) {
|
|
2478
|
-
const m =
|
|
2487
|
+
const m = de({
|
|
2479
2488
|
content: t.search.content,
|
|
2480
2489
|
matches: t.search.matches,
|
|
2481
2490
|
outputLimit: s
|
|
@@ -2485,103 +2494,194 @@ function as(r) {
|
|
|
2485
2494
|
const o = `<${Qe}>
|
|
2486
2495
|
`, e = `</${Qe}>
|
|
2487
2496
|
`, n = `<${Ye}>
|
|
2488
|
-
`,
|
|
2489
|
-
`,
|
|
2490
|
-
if (s != null && s <
|
|
2497
|
+
`, a = `</${Ye}>
|
|
2498
|
+
`, i = o.length + e.length + n.length + a.length;
|
|
2499
|
+
if (s != null && s < i)
|
|
2491
2500
|
return { output: "", truncated: !0 };
|
|
2492
|
-
const
|
|
2501
|
+
const c = s != null ? s - i : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = de({
|
|
2493
2502
|
content: t.search.content,
|
|
2494
2503
|
matches: t.search.matches,
|
|
2495
|
-
outputLimit:
|
|
2496
|
-
}),
|
|
2504
|
+
outputLimit: l
|
|
2505
|
+
}), d = c != null ? c - u.output.length : void 0, f = de({
|
|
2497
2506
|
content: t.replace.content,
|
|
2498
2507
|
matches: t.replace.matches,
|
|
2499
|
-
outputLimit:
|
|
2508
|
+
outputLimit: d
|
|
2500
2509
|
});
|
|
2501
|
-
return { output: o + u.output + e + n +
|
|
2510
|
+
return { output: o + u.output + e + n + f.output + a, truncated: u.truncated || f.truncated };
|
|
2502
2511
|
}
|
|
2503
2512
|
const Ve = `
|
|
2504
|
-
... [output
|
|
2513
|
+
... [truncated, too much output, use more specific search patterns] ...
|
|
2505
2514
|
`;
|
|
2506
|
-
function
|
|
2515
|
+
function St(r) {
|
|
2507
2516
|
const { result: t, rootDir: s, outputLimit: o } = r, e = o - Ve.length;
|
|
2508
|
-
let n = "",
|
|
2509
|
-
for (let
|
|
2510
|
-
const
|
|
2511
|
-
if (
|
|
2512
|
-
const h =
|
|
2513
|
-
❌ ` +
|
|
2517
|
+
let n = "", a = !1;
|
|
2518
|
+
for (let i = 0; i < t.results.length; i++) {
|
|
2519
|
+
const c = t.results[i], l = F.relative(s, c.filePath), u = n.length > 0 ? 1 : 0;
|
|
2520
|
+
if (c.error != null) {
|
|
2521
|
+
const h = l + `
|
|
2522
|
+
❌ ` + c.error + `
|
|
2514
2523
|
`;
|
|
2515
2524
|
if (n.length + u + h.length > e) {
|
|
2516
|
-
|
|
2525
|
+
a = !0;
|
|
2517
2526
|
break;
|
|
2518
2527
|
}
|
|
2519
2528
|
u > 0 && (n += `
|
|
2520
2529
|
`), n += h;
|
|
2521
2530
|
continue;
|
|
2522
2531
|
}
|
|
2523
|
-
if (
|
|
2532
|
+
if (c.result == null || c.result.search.matches.length === 0)
|
|
2524
2533
|
continue;
|
|
2525
|
-
const
|
|
2526
|
-
if (
|
|
2527
|
-
|
|
2534
|
+
const d = e - n.length - u - l.length - 1;
|
|
2535
|
+
if (d <= 0) {
|
|
2536
|
+
a = !0;
|
|
2528
2537
|
break;
|
|
2529
2538
|
}
|
|
2530
|
-
const
|
|
2531
|
-
result:
|
|
2532
|
-
outputLimit:
|
|
2539
|
+
const f = cs({
|
|
2540
|
+
result: c.result,
|
|
2541
|
+
outputLimit: d
|
|
2533
2542
|
});
|
|
2534
|
-
if (
|
|
2535
|
-
`), n +=
|
|
2536
|
-
` +
|
|
2543
|
+
if (a = a || f.truncated, f.output.length > 0 && (u > 0 && (n += `
|
|
2544
|
+
`), n += l + `
|
|
2545
|
+
` + f.output), a)
|
|
2537
2546
|
break;
|
|
2538
2547
|
}
|
|
2539
|
-
return
|
|
2548
|
+
return a && (n += Ve), n;
|
|
2540
2549
|
}
|
|
2541
|
-
const
|
|
2550
|
+
const us = p.object({
|
|
2551
|
+
pattern: p.string().describe("JS RegExp pattern"),
|
|
2552
|
+
flags: p.string().optional().describe("JS RegExp flags")
|
|
2553
|
+
}), xt = p.object({
|
|
2554
|
+
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2555
|
+
snapshot: X.optional().describe(
|
|
2556
|
+
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2557
|
+
),
|
|
2558
|
+
operations: p.array(us).describe("Search operations to execute sequentially on each file"),
|
|
2559
|
+
outputLimit: p.number().max(R).default(R).describe(
|
|
2560
|
+
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${R}. Default: ${R}`
|
|
2561
|
+
)
|
|
2562
|
+
});
|
|
2563
|
+
async function ds(r, t, s) {
|
|
2564
|
+
let o;
|
|
2565
|
+
try {
|
|
2566
|
+
o = xt.parse(r);
|
|
2567
|
+
} catch (y) {
|
|
2568
|
+
return {
|
|
2569
|
+
error: B(y)
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
const { snapshotName: e, snapshot: n, operations: a, outputLimit: i } = o;
|
|
2573
|
+
if (!s.sessionId)
|
|
2574
|
+
return {
|
|
2575
|
+
error: "Session ID is required"
|
|
2576
|
+
};
|
|
2577
|
+
const c = Z(s.sessionId);
|
|
2578
|
+
if (e && n)
|
|
2579
|
+
return {
|
|
2580
|
+
error: "Either snapshotName or snapshot must be provided, not both"
|
|
2581
|
+
};
|
|
2582
|
+
let l, u = !1, d = !1;
|
|
2583
|
+
if (e) {
|
|
2584
|
+
if (l = c.fsSnapshots.get(e), l == null)
|
|
2585
|
+
return {
|
|
2586
|
+
error: `Filesystem snapshot "${e}" not found`
|
|
2587
|
+
};
|
|
2588
|
+
} else if (n) {
|
|
2589
|
+
const y = await le(
|
|
2590
|
+
n,
|
|
2591
|
+
t,
|
|
2592
|
+
s
|
|
2593
|
+
);
|
|
2594
|
+
if (y.error != null)
|
|
2595
|
+
return {
|
|
2596
|
+
error: y.error
|
|
2597
|
+
};
|
|
2598
|
+
l = y.fsSnapshot, u = y.queryCreated, d = !0;
|
|
2599
|
+
} else
|
|
2600
|
+
return {
|
|
2601
|
+
error: "Either snapshotName or snapshot must be provided"
|
|
2602
|
+
};
|
|
2603
|
+
const f = wt(l), h = l.query.rootDir ?? ".", m = await bt({
|
|
2604
|
+
filePaths: f,
|
|
2605
|
+
operations: a
|
|
2606
|
+
});
|
|
2607
|
+
return { output: St({
|
|
2608
|
+
result: m,
|
|
2609
|
+
rootDir: h,
|
|
2610
|
+
outputLimit: i
|
|
2611
|
+
}), rootDir: h, fsSnapshot: l, queryCreated: u, snapshotCreated: d };
|
|
2612
|
+
}
|
|
2613
|
+
function fs(r, t) {
|
|
2614
|
+
r(
|
|
2615
|
+
"fs-snapshot-search",
|
|
2616
|
+
{
|
|
2617
|
+
title: "Search File Contents in Snapshot",
|
|
2618
|
+
description: "Search file contents using JS RegExp. Use this to find text patterns across snapshot files. Combine all patterns into the `operations` array within one tool call; never split patterns across multiple tool calls",
|
|
2619
|
+
inputSchema: xt.shape
|
|
2620
|
+
},
|
|
2621
|
+
async (s, o) => {
|
|
2622
|
+
const e = await ds(
|
|
2623
|
+
s,
|
|
2624
|
+
t,
|
|
2625
|
+
o
|
|
2626
|
+
);
|
|
2627
|
+
if (e.error != null)
|
|
2628
|
+
return `Method: fs-snapshot-search(${JSON.stringify(s)})
|
|
2629
|
+
❌ Error: ${e.error}`;
|
|
2630
|
+
let n = `Method: fs-snapshot-search(${JSON.stringify(s)})
|
|
2631
|
+
`;
|
|
2632
|
+
return e.queryCreated && (n += `✅ Filesystem snapshot query "${e.fsSnapshot.query.name}" created successfully
|
|
2633
|
+
`), e.snapshotCreated && (n += `✅ Filesystem snapshot "${e.fsSnapshot.name}" created successfully
|
|
2634
|
+
`), n += `✅ Search in snapshot "${e.fsSnapshot.name}":
|
|
2635
|
+
`, n += `Root directory (<root>/): ${e.rootDir}
|
|
2636
|
+
`, n += `
|
|
2637
|
+
${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` array in one tool call; never split patterns across multiple tool calls", n;
|
|
2638
|
+
}
|
|
2639
|
+
);
|
|
2640
|
+
}
|
|
2641
|
+
const hs = p.object({
|
|
2542
2642
|
pattern: p.string().describe("JS RegExp pattern"),
|
|
2543
2643
|
flags: p.string().optional().describe("JS RegExp flags"),
|
|
2544
|
-
replacement: p.string().
|
|
2545
|
-
}),
|
|
2644
|
+
replacement: p.string().describe("JS replacement pattern")
|
|
2645
|
+
}), $t = p.object({
|
|
2546
2646
|
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2547
|
-
snapshot:
|
|
2647
|
+
snapshot: X.optional().describe(
|
|
2548
2648
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2549
2649
|
),
|
|
2550
|
-
operations: p.array(
|
|
2551
|
-
outputLimit: p.number().max(
|
|
2552
|
-
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${
|
|
2650
|
+
operations: p.array(hs).describe("Replace operations to execute sequentially on each file"),
|
|
2651
|
+
outputLimit: p.number().max(R).default(R).describe(
|
|
2652
|
+
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${R}. Default: ${R}`
|
|
2553
2653
|
),
|
|
2554
2654
|
dryRun: p.boolean().optional().describe(
|
|
2555
2655
|
"Preview changes without writing files. When true, shows what would be replaced but does not modify files"
|
|
2556
2656
|
)
|
|
2557
2657
|
});
|
|
2558
|
-
async function
|
|
2658
|
+
async function ps(r, t, s) {
|
|
2559
2659
|
let o;
|
|
2560
2660
|
try {
|
|
2561
|
-
o =
|
|
2661
|
+
o = $t.parse(r);
|
|
2562
2662
|
} catch (w) {
|
|
2563
2663
|
return {
|
|
2564
2664
|
error: B(w)
|
|
2565
2665
|
};
|
|
2566
2666
|
}
|
|
2567
|
-
const { snapshotName: e, snapshot: n, operations:
|
|
2667
|
+
const { snapshotName: e, snapshot: n, operations: a, outputLimit: i, dryRun: c } = o;
|
|
2568
2668
|
if (!s.sessionId)
|
|
2569
2669
|
return {
|
|
2570
2670
|
error: "Session ID is required"
|
|
2571
2671
|
};
|
|
2572
|
-
const
|
|
2672
|
+
const l = Z(s.sessionId);
|
|
2573
2673
|
if (e && n)
|
|
2574
2674
|
return {
|
|
2575
2675
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
2576
2676
|
};
|
|
2577
|
-
let u,
|
|
2677
|
+
let u, d = !1, f = !1;
|
|
2578
2678
|
if (e) {
|
|
2579
|
-
if (u =
|
|
2679
|
+
if (u = l.fsSnapshots.get(e), u == null)
|
|
2580
2680
|
return {
|
|
2581
2681
|
error: `Filesystem snapshot "${e}" not found`
|
|
2582
2682
|
};
|
|
2583
2683
|
} else if (n) {
|
|
2584
|
-
const w = await
|
|
2684
|
+
const w = await le(
|
|
2585
2685
|
n,
|
|
2586
2686
|
t,
|
|
2587
2687
|
s
|
|
@@ -2590,63 +2690,63 @@ async function us(r, t, s) {
|
|
|
2590
2690
|
return {
|
|
2591
2691
|
error: w.error
|
|
2592
2692
|
};
|
|
2593
|
-
u = w.fsSnapshot,
|
|
2693
|
+
u = w.fsSnapshot, d = w.queryCreated, f = !0;
|
|
2594
2694
|
} else
|
|
2595
2695
|
return {
|
|
2596
2696
|
error: "Either snapshotName or snapshot must be provided"
|
|
2597
2697
|
};
|
|
2598
|
-
const h =
|
|
2698
|
+
const h = wt(u), m = u.query.rootDir ?? ".", g = await bt({
|
|
2599
2699
|
filePaths: h,
|
|
2600
|
-
operations:
|
|
2601
|
-
dryRun:
|
|
2700
|
+
operations: a,
|
|
2701
|
+
dryRun: c
|
|
2602
2702
|
});
|
|
2603
|
-
return { output:
|
|
2703
|
+
return { output: St({
|
|
2604
2704
|
result: g,
|
|
2605
2705
|
rootDir: m,
|
|
2606
|
-
outputLimit:
|
|
2607
|
-
}), rootDir: m, fsSnapshot: u, queryCreated:
|
|
2706
|
+
outputLimit: i
|
|
2707
|
+
}), rootDir: m, fsSnapshot: u, queryCreated: d, snapshotCreated: f };
|
|
2608
2708
|
}
|
|
2609
|
-
function
|
|
2709
|
+
function ms(r, t) {
|
|
2610
2710
|
r(
|
|
2611
|
-
"fs-snapshot-
|
|
2711
|
+
"fs-snapshot-replace",
|
|
2612
2712
|
{
|
|
2613
|
-
title: "
|
|
2614
|
-
description: "
|
|
2615
|
-
inputSchema:
|
|
2713
|
+
title: "Replace File Contents in Snapshot",
|
|
2714
|
+
description: "Replace file contents using JS RegExp. Use this to perform bulk replacements across snapshot files. Combine all patterns into the `operations` array within one tool call; never split patterns across multiple tool calls",
|
|
2715
|
+
inputSchema: $t.shape
|
|
2616
2716
|
},
|
|
2617
2717
|
async (s, o) => {
|
|
2618
|
-
const e = await
|
|
2718
|
+
const e = await ps(
|
|
2619
2719
|
s,
|
|
2620
2720
|
t,
|
|
2621
2721
|
o
|
|
2622
2722
|
);
|
|
2623
2723
|
if (e.error != null)
|
|
2624
|
-
return `Method: fs-snapshot-
|
|
2724
|
+
return `Method: fs-snapshot-replace(${JSON.stringify(s)})
|
|
2625
2725
|
❌ Error: ${e.error}`;
|
|
2626
|
-
let n = `Method: fs-snapshot-
|
|
2726
|
+
let n = `Method: fs-snapshot-replace(${JSON.stringify(s)})
|
|
2627
2727
|
`;
|
|
2628
2728
|
return e.queryCreated && (n += `✅ Filesystem snapshot query "${e.fsSnapshot.query.name}" created successfully
|
|
2629
2729
|
`), e.snapshotCreated && (n += `✅ Filesystem snapshot "${e.fsSnapshot.name}" created successfully
|
|
2630
|
-
`), n += `✅
|
|
2730
|
+
`), n += `✅ Replace in snapshot "${e.fsSnapshot.name}":
|
|
2631
2731
|
`, n += `Root directory (<root>/): ${e.rootDir}
|
|
2632
2732
|
`, n += `
|
|
2633
2733
|
${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` array in one tool call; never split patterns across multiple tool calls", n;
|
|
2634
2734
|
}
|
|
2635
2735
|
);
|
|
2636
2736
|
}
|
|
2637
|
-
function
|
|
2638
|
-
t.list &&
|
|
2737
|
+
function gs(r, t) {
|
|
2738
|
+
t.list && Fr(r, t), t.snapshotQueryCreate && Lr(r, t), t.snapshotCreate && Jr(r, t), t.snapshotBrowse && Qr(r, t), t.snapshotSearch && fs(r, t), t.snapshotReplace && ms(r, t), console.log(
|
|
2639
2739
|
`File manager:
|
|
2640
|
-
- Working directory: ${
|
|
2740
|
+
- Working directory: ${F.resolve(t.workingDir || "")}
|
|
2641
2741
|
`
|
|
2642
2742
|
);
|
|
2643
2743
|
}
|
|
2644
|
-
const
|
|
2645
|
-
function
|
|
2646
|
-
return
|
|
2744
|
+
const fe = /* @__PURE__ */ new Map();
|
|
2745
|
+
function j(r) {
|
|
2746
|
+
return fe.has(r) || fe.set(r, {
|
|
2647
2747
|
browsers: /* @__PURE__ */ new Map(),
|
|
2648
2748
|
domSnapshotQueries: /* @__PURE__ */ new Map()
|
|
2649
|
-
}),
|
|
2749
|
+
}), fe.get(r);
|
|
2650
2750
|
}
|
|
2651
2751
|
const Se = p.object({
|
|
2652
2752
|
name: p.string().describe(
|
|
@@ -2656,44 +2756,44 @@ const Se = p.object({
|
|
|
2656
2756
|
muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
|
|
2657
2757
|
devTools: p.boolean().optional().describe("Open browser with dev tools")
|
|
2658
2758
|
});
|
|
2659
|
-
async function
|
|
2759
|
+
async function It(r, t, s) {
|
|
2660
2760
|
let o;
|
|
2661
2761
|
try {
|
|
2662
2762
|
o = Se.parse(r);
|
|
2663
|
-
} catch (
|
|
2763
|
+
} catch (l) {
|
|
2664
2764
|
return {
|
|
2665
|
-
error: B(
|
|
2765
|
+
error: B(l)
|
|
2666
2766
|
};
|
|
2667
2767
|
}
|
|
2668
|
-
const { name: e, browserType: n, muteAudio:
|
|
2768
|
+
const { name: e, browserType: n, muteAudio: a, devTools: i } = o;
|
|
2669
2769
|
if (!s.sessionId)
|
|
2670
2770
|
return {
|
|
2671
2771
|
error: "Session ID is required"
|
|
2672
2772
|
};
|
|
2673
|
-
const
|
|
2773
|
+
const c = j(s.sessionId);
|
|
2674
2774
|
try {
|
|
2675
2775
|
const u = await {
|
|
2676
|
-
chromium:
|
|
2677
|
-
firefox:
|
|
2678
|
-
webkit:
|
|
2776
|
+
chromium: Yt,
|
|
2777
|
+
firefox: Qt,
|
|
2778
|
+
webkit: Ht
|
|
2679
2779
|
}[n].launch({
|
|
2680
2780
|
headless: !1,
|
|
2681
|
-
devtools:
|
|
2682
|
-
args:
|
|
2683
|
-
}),
|
|
2781
|
+
devtools: i,
|
|
2782
|
+
args: a ? ["--mute-audio"] : void 0
|
|
2783
|
+
}), d = {
|
|
2684
2784
|
name: e,
|
|
2685
2785
|
browserType: n,
|
|
2686
2786
|
browser: u,
|
|
2687
2787
|
contexts: /* @__PURE__ */ new Map()
|
|
2688
2788
|
};
|
|
2689
|
-
return
|
|
2690
|
-
} catch (
|
|
2789
|
+
return c.browsers.set(e, d), { browserInfo: d };
|
|
2790
|
+
} catch (l) {
|
|
2691
2791
|
return {
|
|
2692
|
-
error: `Failed to create browser: ${
|
|
2792
|
+
error: `Failed to create browser: ${l instanceof Error ? l.message : "Unknown error"}`
|
|
2693
2793
|
};
|
|
2694
2794
|
}
|
|
2695
2795
|
}
|
|
2696
|
-
function
|
|
2796
|
+
function ws(r, t) {
|
|
2697
2797
|
r(
|
|
2698
2798
|
"playwright-browser-create",
|
|
2699
2799
|
{
|
|
@@ -2702,64 +2802,64 @@ function hs(r, t) {
|
|
|
2702
2802
|
inputSchema: Se.shape
|
|
2703
2803
|
},
|
|
2704
2804
|
async (s, o) => {
|
|
2705
|
-
const e = await
|
|
2805
|
+
const e = await It(s, t, o);
|
|
2706
2806
|
return `Method: playwright-browser-create(${JSON.stringify(s)})
|
|
2707
2807
|
${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
|
|
2708
2808
|
}
|
|
2709
2809
|
);
|
|
2710
2810
|
}
|
|
2711
|
-
const
|
|
2712
|
-
async function
|
|
2811
|
+
const Mt = p.object({});
|
|
2812
|
+
async function ys(r, t, s) {
|
|
2713
2813
|
let o;
|
|
2714
2814
|
try {
|
|
2715
|
-
o =
|
|
2716
|
-
} catch (
|
|
2815
|
+
o = Mt.parse(r);
|
|
2816
|
+
} catch (a) {
|
|
2717
2817
|
return {
|
|
2718
|
-
error: B(
|
|
2818
|
+
error: B(a)
|
|
2719
2819
|
};
|
|
2720
2820
|
}
|
|
2721
2821
|
if (!s.sessionId)
|
|
2722
2822
|
return {
|
|
2723
2823
|
error: "Session ID is required"
|
|
2724
2824
|
};
|
|
2725
|
-
const e =
|
|
2825
|
+
const e = j(s.sessionId);
|
|
2726
2826
|
return {
|
|
2727
2827
|
browserInfos: Array.from(e.browsers.values())
|
|
2728
2828
|
};
|
|
2729
2829
|
}
|
|
2730
|
-
function
|
|
2830
|
+
function bs(r, t) {
|
|
2731
2831
|
r(
|
|
2732
2832
|
"playwright-browser-list",
|
|
2733
2833
|
{
|
|
2734
2834
|
title: "List Browsers",
|
|
2735
2835
|
description: "List active browser instances",
|
|
2736
|
-
inputSchema:
|
|
2836
|
+
inputSchema: Mt.shape
|
|
2737
2837
|
},
|
|
2738
2838
|
async (s, o) => {
|
|
2739
|
-
const e = await
|
|
2839
|
+
const e = await ys(s, t, o);
|
|
2740
2840
|
if (e.error != null)
|
|
2741
2841
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
2742
2842
|
❌ Error: ${e.error}`;
|
|
2743
2843
|
const n = e.browserInfos.map(
|
|
2744
|
-
(
|
|
2844
|
+
(a) => `${a.name} (${a.browserType})`
|
|
2745
2845
|
);
|
|
2746
2846
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
2747
2847
|
${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
|
|
2748
2848
|
}
|
|
2749
2849
|
);
|
|
2750
2850
|
}
|
|
2751
|
-
const
|
|
2851
|
+
const Tt = p.object({
|
|
2752
2852
|
names: p.array(p.string()).optional().describe(
|
|
2753
2853
|
"Names of browsers to close. If not specified, closes all browsers"
|
|
2754
2854
|
)
|
|
2755
2855
|
});
|
|
2756
|
-
async function
|
|
2856
|
+
async function Ss(r, t, s) {
|
|
2757
2857
|
let o;
|
|
2758
2858
|
try {
|
|
2759
|
-
o =
|
|
2760
|
-
} catch (
|
|
2859
|
+
o = Tt.parse(r);
|
|
2860
|
+
} catch (l) {
|
|
2761
2861
|
return {
|
|
2762
|
-
error: B(
|
|
2862
|
+
error: B(l)
|
|
2763
2863
|
};
|
|
2764
2864
|
}
|
|
2765
2865
|
const { names: e } = o;
|
|
@@ -2767,47 +2867,47 @@ async function gs(r, t, s) {
|
|
|
2767
2867
|
return {
|
|
2768
2868
|
error: "Session ID is required"
|
|
2769
2869
|
};
|
|
2770
|
-
const n =
|
|
2771
|
-
let
|
|
2772
|
-
return e ? e.forEach((
|
|
2773
|
-
const u = n.browsers.get(
|
|
2774
|
-
u ?
|
|
2775
|
-
}) :
|
|
2776
|
-
|
|
2870
|
+
const n = j(s.sessionId), a = [], i = [];
|
|
2871
|
+
let c = [];
|
|
2872
|
+
return e ? e.forEach((l) => {
|
|
2873
|
+
const u = n.browsers.get(l);
|
|
2874
|
+
u ? c.push(u) : i.push(`Browser "${l}" not found`);
|
|
2875
|
+
}) : c = Array.from(n.browsers.values()), await Promise.all(
|
|
2876
|
+
c.map(async (l) => {
|
|
2777
2877
|
try {
|
|
2778
|
-
await
|
|
2878
|
+
await l.browser.close(), n.browsers.delete(l.name), a.push(l);
|
|
2779
2879
|
} catch (u) {
|
|
2780
|
-
|
|
2781
|
-
`Failed to close browser "${
|
|
2880
|
+
i.push(
|
|
2881
|
+
`Failed to close browser "${l.name}" (${l.browserType}): ${u instanceof Error ? u.message : "Unknown error"}`
|
|
2782
2882
|
);
|
|
2783
2883
|
}
|
|
2784
2884
|
})
|
|
2785
2885
|
), {
|
|
2786
|
-
closedBrowserInfos:
|
|
2787
|
-
...
|
|
2886
|
+
closedBrowserInfos: a,
|
|
2887
|
+
...i.length > 0 && { errors: i }
|
|
2788
2888
|
};
|
|
2789
2889
|
}
|
|
2790
|
-
function
|
|
2890
|
+
function xs(r, t) {
|
|
2791
2891
|
r(
|
|
2792
2892
|
"playwright-browser-close",
|
|
2793
2893
|
{
|
|
2794
2894
|
title: "Close Browsers",
|
|
2795
2895
|
description: "Close browsers. Automatically closes all contexts and pages within the browsers",
|
|
2796
|
-
inputSchema:
|
|
2896
|
+
inputSchema: Tt.shape
|
|
2797
2897
|
},
|
|
2798
2898
|
async (s, o) => {
|
|
2799
|
-
const e = await
|
|
2899
|
+
const e = await Ss(s, t, o);
|
|
2800
2900
|
if (e.error != null)
|
|
2801
2901
|
return `Method: playwright-browser-close(${JSON.stringify(s)})
|
|
2802
2902
|
❌ Error: ${e.error}`;
|
|
2803
2903
|
const n = [];
|
|
2804
2904
|
if (e.closedBrowserInfos.length > 0) {
|
|
2805
|
-
const
|
|
2806
|
-
(
|
|
2905
|
+
const a = e.closedBrowserInfos.map(
|
|
2906
|
+
(i) => `${i.name} (${i.browserType})`
|
|
2807
2907
|
);
|
|
2808
|
-
n.push(`✅ Closed browsers: ${
|
|
2908
|
+
n.push(`✅ Closed browsers: ${a.join(", ")}`);
|
|
2809
2909
|
}
|
|
2810
|
-
return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((
|
|
2910
|
+
return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((a) => n.push(a))), n.length === 0 && n.push("No browsers to close"), `Method: playwright-browser-close(${JSON.stringify(s)})
|
|
2811
2911
|
${n.join(`
|
|
2812
2912
|
`)}`;
|
|
2813
2913
|
}
|
|
@@ -2828,7 +2928,7 @@ const xe = p.object({
|
|
|
2828
2928
|
height: p.number()
|
|
2829
2929
|
}).optional().describe("Viewport size configuration")
|
|
2830
2930
|
});
|
|
2831
|
-
async function
|
|
2931
|
+
async function Ct(r, t, s) {
|
|
2832
2932
|
let o;
|
|
2833
2933
|
try {
|
|
2834
2934
|
o = xe.parse(r);
|
|
@@ -2837,56 +2937,56 @@ async function xt(r, t, s) {
|
|
|
2837
2937
|
error: B(h)
|
|
2838
2938
|
};
|
|
2839
2939
|
}
|
|
2840
|
-
const { name: e, browserName: n, browser:
|
|
2940
|
+
const { name: e, browserName: n, browser: a, isMobile: i, hasTouch: c, viewport: l } = o;
|
|
2841
2941
|
if (!s.sessionId)
|
|
2842
2942
|
return {
|
|
2843
2943
|
error: "Session ID is required"
|
|
2844
2944
|
};
|
|
2845
|
-
const u =
|
|
2846
|
-
if (n &&
|
|
2945
|
+
const u = j(s.sessionId);
|
|
2946
|
+
if (n && a)
|
|
2847
2947
|
return {
|
|
2848
2948
|
error: "Either browserName or browser must be provided, not both"
|
|
2849
2949
|
};
|
|
2850
|
-
let
|
|
2950
|
+
let d = !1, f;
|
|
2851
2951
|
if (n) {
|
|
2852
|
-
if (
|
|
2952
|
+
if (f = u.browsers.get(n), !f)
|
|
2853
2953
|
return {
|
|
2854
2954
|
error: `Browser "${n}" not found`
|
|
2855
2955
|
};
|
|
2856
|
-
} else if (
|
|
2857
|
-
const h = await
|
|
2956
|
+
} else if (a) {
|
|
2957
|
+
const h = await It(a, t, s);
|
|
2858
2958
|
if (h.error != null)
|
|
2859
2959
|
return {
|
|
2860
2960
|
error: h.error
|
|
2861
2961
|
};
|
|
2862
|
-
|
|
2962
|
+
f = h.browserInfo, d = !0;
|
|
2863
2963
|
} else
|
|
2864
2964
|
return {
|
|
2865
2965
|
error: "Either browserName or browser must be provided"
|
|
2866
2966
|
};
|
|
2867
2967
|
try {
|
|
2868
|
-
const h = await
|
|
2869
|
-
isMobile:
|
|
2870
|
-
hasTouch:
|
|
2871
|
-
viewport:
|
|
2968
|
+
const h = await f.browser.newContext({
|
|
2969
|
+
isMobile: i,
|
|
2970
|
+
hasTouch: c,
|
|
2971
|
+
viewport: l
|
|
2872
2972
|
}), m = {
|
|
2873
|
-
browserInfo:
|
|
2973
|
+
browserInfo: f,
|
|
2874
2974
|
name: e,
|
|
2875
2975
|
context: h,
|
|
2876
2976
|
pages: /* @__PURE__ */ new Map()
|
|
2877
2977
|
};
|
|
2878
|
-
return
|
|
2879
|
-
browserInfoCreated:
|
|
2880
|
-
browserInfo:
|
|
2978
|
+
return f.contexts.set(e, m), {
|
|
2979
|
+
browserInfoCreated: d,
|
|
2980
|
+
browserInfo: f,
|
|
2881
2981
|
contextInfo: m
|
|
2882
2982
|
};
|
|
2883
2983
|
} catch (h) {
|
|
2884
2984
|
return {
|
|
2885
|
-
error: `Failed to create context: ${h instanceof Error ? h.message : "Unknown error"} in browser "${
|
|
2985
|
+
error: `Failed to create context: ${h instanceof Error ? h.message : "Unknown error"} in browser "${f.name}" (${f.browserType})`
|
|
2886
2986
|
};
|
|
2887
2987
|
}
|
|
2888
2988
|
}
|
|
2889
|
-
function
|
|
2989
|
+
function $s(r, t) {
|
|
2890
2990
|
r(
|
|
2891
2991
|
"playwright-context-create",
|
|
2892
2992
|
{
|
|
@@ -2895,7 +2995,7 @@ function ys(r, t) {
|
|
|
2895
2995
|
inputSchema: xe.shape
|
|
2896
2996
|
},
|
|
2897
2997
|
async (s, o) => {
|
|
2898
|
-
const e = await
|
|
2998
|
+
const e = await Ct(s, t, o);
|
|
2899
2999
|
if (e.error != null)
|
|
2900
3000
|
return `Method: playwright-context-create(${JSON.stringify(s)})
|
|
2901
3001
|
❌ Error: ${e.error}`;
|
|
@@ -2906,18 +3006,18 @@ function ys(r, t) {
|
|
|
2906
3006
|
}
|
|
2907
3007
|
);
|
|
2908
3008
|
}
|
|
2909
|
-
const
|
|
3009
|
+
const vt = p.object({
|
|
2910
3010
|
browserName: p.string().optional().describe(
|
|
2911
3011
|
"Name of browser to list contexts from. If not specified, lists contexts from all browsers"
|
|
2912
3012
|
)
|
|
2913
3013
|
});
|
|
2914
|
-
async function
|
|
3014
|
+
async function Is(r, t, s) {
|
|
2915
3015
|
let o;
|
|
2916
3016
|
try {
|
|
2917
|
-
o =
|
|
2918
|
-
} catch (
|
|
3017
|
+
o = vt.parse(r);
|
|
3018
|
+
} catch (i) {
|
|
2919
3019
|
return {
|
|
2920
|
-
error: B(
|
|
3020
|
+
error: B(i)
|
|
2921
3021
|
};
|
|
2922
3022
|
}
|
|
2923
3023
|
const { browserName: e } = o;
|
|
@@ -2925,52 +3025,52 @@ async function bs(r, t, s) {
|
|
|
2925
3025
|
return {
|
|
2926
3026
|
error: "Session ID is required"
|
|
2927
3027
|
};
|
|
2928
|
-
const n =
|
|
3028
|
+
const n = j(s.sessionId), a = [];
|
|
2929
3029
|
if (e) {
|
|
2930
|
-
const
|
|
2931
|
-
if (!
|
|
3030
|
+
const i = n.browsers.get(e);
|
|
3031
|
+
if (!i)
|
|
2932
3032
|
return {
|
|
2933
3033
|
error: `Browser "${e}" not found`
|
|
2934
3034
|
};
|
|
2935
|
-
Array.from(
|
|
2936
|
-
browserInfo:
|
|
2937
|
-
contexts: Array.from(
|
|
3035
|
+
Array.from(i.contexts.values()).length > 0 && a.push({
|
|
3036
|
+
browserInfo: i,
|
|
3037
|
+
contexts: Array.from(i.contexts.values())
|
|
2938
3038
|
});
|
|
2939
3039
|
} else
|
|
2940
|
-
for (const
|
|
2941
|
-
const
|
|
2942
|
-
|
|
2943
|
-
browserInfo:
|
|
2944
|
-
contexts:
|
|
3040
|
+
for (const i of n.browsers.values()) {
|
|
3041
|
+
const c = Array.from(i.contexts.values());
|
|
3042
|
+
c.length > 0 && a.push({
|
|
3043
|
+
browserInfo: i,
|
|
3044
|
+
contexts: c
|
|
2945
3045
|
});
|
|
2946
3046
|
}
|
|
2947
3047
|
return {
|
|
2948
|
-
contextsByBrowser:
|
|
3048
|
+
contextsByBrowser: a
|
|
2949
3049
|
};
|
|
2950
3050
|
}
|
|
2951
|
-
function
|
|
3051
|
+
function Ms(r, t) {
|
|
2952
3052
|
r(
|
|
2953
3053
|
"playwright-context-list",
|
|
2954
3054
|
{
|
|
2955
3055
|
title: "List Browser Contexts",
|
|
2956
3056
|
description: "List active browser contexts",
|
|
2957
|
-
inputSchema:
|
|
3057
|
+
inputSchema: vt.shape
|
|
2958
3058
|
},
|
|
2959
3059
|
async (s, o) => {
|
|
2960
|
-
const e = await
|
|
3060
|
+
const e = await Is(s, t, o);
|
|
2961
3061
|
if ("error" in e)
|
|
2962
3062
|
return `Method: playwright-context-list(${JSON.stringify(s)})
|
|
2963
3063
|
❌ Error: ${e.error}`;
|
|
2964
3064
|
let n = `Method: playwright-context-list(${JSON.stringify(s)})
|
|
2965
3065
|
`;
|
|
2966
3066
|
return e.contextsByBrowser.length === 0 ? n += "No contexts found" : n += e.contextsByBrowser.map(
|
|
2967
|
-
({ browserInfo:
|
|
3067
|
+
({ browserInfo: a, contexts: i }) => `${a.name} (${a.browserType}): ${i.map((c) => c.name).join(", ")}`
|
|
2968
3068
|
).join(`
|
|
2969
3069
|
`), n;
|
|
2970
3070
|
}
|
|
2971
3071
|
);
|
|
2972
3072
|
}
|
|
2973
|
-
const
|
|
3073
|
+
const Nt = p.object({
|
|
2974
3074
|
names: p.array(p.string()).optional().describe(
|
|
2975
3075
|
"Names of contexts to close. If not specified, closes all contexts"
|
|
2976
3076
|
),
|
|
@@ -2978,10 +3078,10 @@ const It = p.object({
|
|
|
2978
3078
|
"Name of browser to close contexts from. If not specified, searches all browsers"
|
|
2979
3079
|
)
|
|
2980
3080
|
});
|
|
2981
|
-
async function
|
|
3081
|
+
async function Ts(r, t, s) {
|
|
2982
3082
|
let o;
|
|
2983
3083
|
try {
|
|
2984
|
-
o =
|
|
3084
|
+
o = Nt.parse(r);
|
|
2985
3085
|
} catch (u) {
|
|
2986
3086
|
return {
|
|
2987
3087
|
error: B(u)
|
|
@@ -2992,161 +3092,161 @@ async function xs(r, t, s) {
|
|
|
2992
3092
|
return {
|
|
2993
3093
|
error: "Session ID is required"
|
|
2994
3094
|
};
|
|
2995
|
-
const
|
|
2996
|
-
let
|
|
3095
|
+
const a = j(s.sessionId), i = [], c = [];
|
|
3096
|
+
let l = [];
|
|
2997
3097
|
if (n) {
|
|
2998
|
-
const u =
|
|
3098
|
+
const u = a.browsers.get(n);
|
|
2999
3099
|
if (!u)
|
|
3000
3100
|
return {
|
|
3001
3101
|
error: `Browser "${n}" not found`
|
|
3002
3102
|
};
|
|
3003
|
-
e ? e.forEach((
|
|
3004
|
-
const
|
|
3005
|
-
|
|
3006
|
-
`Context "${
|
|
3103
|
+
e ? e.forEach((d) => {
|
|
3104
|
+
const f = u.contexts.get(d);
|
|
3105
|
+
f ? l.push(f) : c.push(
|
|
3106
|
+
`Context "${d}" not found in browser "${u.name}" (${u.browserType})`
|
|
3007
3107
|
);
|
|
3008
|
-
}) :
|
|
3108
|
+
}) : l = Array.from(u.contexts.values());
|
|
3009
3109
|
} else if (e)
|
|
3010
|
-
for (const u of
|
|
3011
|
-
e.forEach((
|
|
3012
|
-
const
|
|
3013
|
-
|
|
3014
|
-
`Context "${
|
|
3110
|
+
for (const u of a.browsers.values())
|
|
3111
|
+
e.forEach((d) => {
|
|
3112
|
+
const f = u.contexts.get(d);
|
|
3113
|
+
f ? l.push(f) : c.push(
|
|
3114
|
+
`Context "${d}" not found in browser "${u.name}" (${u.browserType})`
|
|
3015
3115
|
);
|
|
3016
3116
|
});
|
|
3017
3117
|
else
|
|
3018
|
-
for (const u of
|
|
3019
|
-
|
|
3118
|
+
for (const u of a.browsers.values())
|
|
3119
|
+
l.push(...Array.from(u.contexts.values()));
|
|
3020
3120
|
return await Promise.all(
|
|
3021
|
-
|
|
3121
|
+
l.map(async (u) => {
|
|
3022
3122
|
try {
|
|
3023
|
-
await u.context.close(), u.browserInfo.contexts.delete(u.name),
|
|
3024
|
-
} catch (
|
|
3025
|
-
|
|
3026
|
-
`Failed to close context "${u.name}" (${u.browserInfo.name}) (${u.browserInfo.browserType}): ${
|
|
3123
|
+
await u.context.close(), u.browserInfo.contexts.delete(u.name), i.push(u);
|
|
3124
|
+
} catch (d) {
|
|
3125
|
+
c.push(
|
|
3126
|
+
`Failed to close context "${u.name}" (${u.browserInfo.name}) (${u.browserInfo.browserType}): ${d instanceof Error ? d.message : "Unknown error"}`
|
|
3027
3127
|
);
|
|
3028
3128
|
}
|
|
3029
3129
|
})
|
|
3030
3130
|
), {
|
|
3031
|
-
closedContextInfos:
|
|
3032
|
-
...
|
|
3131
|
+
closedContextInfos: i,
|
|
3132
|
+
...c.length > 0 && { errors: c }
|
|
3033
3133
|
};
|
|
3034
3134
|
}
|
|
3035
|
-
function
|
|
3135
|
+
function Cs(r, t) {
|
|
3036
3136
|
r(
|
|
3037
3137
|
"playwright-context-close",
|
|
3038
3138
|
{
|
|
3039
3139
|
title: "Close Browser Contexts",
|
|
3040
3140
|
description: "Close browser contexts. Automatically closes all pages within the contexts",
|
|
3041
|
-
inputSchema:
|
|
3141
|
+
inputSchema: Nt.shape
|
|
3042
3142
|
},
|
|
3043
3143
|
async (s, o) => {
|
|
3044
|
-
const e = await
|
|
3144
|
+
const e = await Ts(s, t, o);
|
|
3045
3145
|
if ("error" in e)
|
|
3046
3146
|
return `Method: playwright-context-close(${JSON.stringify(s)})
|
|
3047
3147
|
❌ Error: ${e.error}`;
|
|
3048
3148
|
const n = [];
|
|
3049
3149
|
if (e.closedContextInfos.length > 0) {
|
|
3050
|
-
const
|
|
3051
|
-
(
|
|
3150
|
+
const a = e.closedContextInfos.map(
|
|
3151
|
+
(i) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType})`
|
|
3052
3152
|
);
|
|
3053
|
-
n.push(`✅ Closed contexts: ${
|
|
3153
|
+
n.push(`✅ Closed contexts: ${a.join(", ")}`);
|
|
3054
3154
|
}
|
|
3055
|
-
return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((
|
|
3155
|
+
return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((a) => n.push(a))), n.length === 0 && n.push("No contexts to close"), `Method: playwright-context-close(${JSON.stringify(s)})
|
|
3056
3156
|
${n.join(`
|
|
3057
3157
|
`)}`;
|
|
3058
3158
|
}
|
|
3059
3159
|
);
|
|
3060
3160
|
}
|
|
3061
|
-
function
|
|
3161
|
+
function vs() {
|
|
3062
3162
|
class r {
|
|
3063
3163
|
prevId = 0;
|
|
3064
3164
|
objectToId = /* @__PURE__ */ new WeakMap();
|
|
3065
3165
|
idToObject = /* @__PURE__ */ new Map();
|
|
3066
3166
|
cleanupRegistry;
|
|
3067
3167
|
constructor() {
|
|
3068
|
-
this.cleanupRegistry = new FinalizationRegistry((
|
|
3069
|
-
this.idToObject.delete(
|
|
3168
|
+
this.cleanupRegistry = new FinalizationRegistry((c) => {
|
|
3169
|
+
this.idToObject.delete(c);
|
|
3070
3170
|
});
|
|
3071
3171
|
}
|
|
3072
|
-
getOrCreateId(
|
|
3073
|
-
let
|
|
3074
|
-
return
|
|
3172
|
+
getOrCreateId(c) {
|
|
3173
|
+
let l = this.objectToId.get(c);
|
|
3174
|
+
return l == null && (l = ++this.prevId, this.objectToId.set(c, l), this.idToObject.set(l, new WeakRef(c)), this.cleanupRegistry.register(c, l)), l;
|
|
3075
3175
|
}
|
|
3076
|
-
getObject(
|
|
3077
|
-
const
|
|
3078
|
-
if (!
|
|
3176
|
+
getObject(c) {
|
|
3177
|
+
const l = this.idToObject.get(c);
|
|
3178
|
+
if (!l)
|
|
3079
3179
|
return null;
|
|
3080
|
-
const u =
|
|
3081
|
-
return u ?? (this.idToObject.delete(
|
|
3180
|
+
const u = l.deref();
|
|
3181
|
+
return u ?? (this.idToObject.delete(c), null);
|
|
3082
3182
|
}
|
|
3083
3183
|
}
|
|
3084
|
-
function t(
|
|
3184
|
+
function t(i, c, l) {
|
|
3085
3185
|
let u = null;
|
|
3086
|
-
for (let
|
|
3087
|
-
const h =
|
|
3186
|
+
for (let d = 0, f = c.length; d < f; d++) {
|
|
3187
|
+
const h = c[d], m = i(h), g = m == null ? null : t(i, m, l), y = l(h, g);
|
|
3088
3188
|
y != null && (u == null && (u = []), u.push(y));
|
|
3089
3189
|
}
|
|
3090
3190
|
return u;
|
|
3091
3191
|
}
|
|
3092
|
-
function s(
|
|
3093
|
-
const { getId:
|
|
3094
|
-
|
|
3192
|
+
function s(i) {
|
|
3193
|
+
const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: d } = i, f = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = t(
|
|
3194
|
+
l,
|
|
3095
3195
|
u,
|
|
3096
3196
|
(w, M) => {
|
|
3097
|
-
const
|
|
3098
|
-
if (w != null &&
|
|
3099
|
-
const b =
|
|
3100
|
-
|
|
3197
|
+
const N = d(w, M);
|
|
3198
|
+
if (w != null && N != null) {
|
|
3199
|
+
const b = c(w);
|
|
3200
|
+
f.set(b, N), h.set(N, b);
|
|
3101
3201
|
}
|
|
3102
|
-
return
|
|
3103
|
-
h.get(
|
|
3202
|
+
return N != null && M != null && m.set(
|
|
3203
|
+
h.get(N),
|
|
3104
3204
|
M.map((b) => h.get(b))
|
|
3105
|
-
),
|
|
3205
|
+
), N;
|
|
3106
3206
|
}
|
|
3107
|
-
), y =
|
|
3207
|
+
), y = d(null, g);
|
|
3108
3208
|
if (y == null)
|
|
3109
3209
|
throw new Error("Impossible behavior: rootNode == null");
|
|
3110
|
-
return
|
|
3210
|
+
return f.set(null, y), g != null && m.set(
|
|
3111
3211
|
null,
|
|
3112
3212
|
g.map((w) => h.get(w))
|
|
3113
3213
|
), {
|
|
3114
|
-
idToNode:
|
|
3214
|
+
idToNode: f,
|
|
3115
3215
|
idToChildIds: m
|
|
3116
3216
|
};
|
|
3117
3217
|
}
|
|
3118
|
-
const o = (
|
|
3119
|
-
function e(
|
|
3120
|
-
return function(
|
|
3121
|
-
const
|
|
3122
|
-
let
|
|
3123
|
-
if (
|
|
3124
|
-
if (h = n.getOrCreateId(
|
|
3218
|
+
const o = (i) => i instanceof HTMLElement ? i.childNodes : null;
|
|
3219
|
+
function e(i) {
|
|
3220
|
+
return function(l, u) {
|
|
3221
|
+
const d = u != null && u.length > 0;
|
|
3222
|
+
let f = !1, h = null, m = null;
|
|
3223
|
+
if (l instanceof HTMLElement) {
|
|
3224
|
+
if (h = n.getOrCreateId(l), m = l.tagName.toLowerCase(), f = l.matches(i.cssSelector), !f && !d)
|
|
3125
3225
|
return null;
|
|
3126
|
-
} else if (
|
|
3127
|
-
h = null, m = null,
|
|
3226
|
+
} else if (l == null)
|
|
3227
|
+
h = null, m = null, f = !1;
|
|
3128
3228
|
else
|
|
3129
3229
|
return null;
|
|
3130
3230
|
return {
|
|
3131
3231
|
uid: h,
|
|
3132
3232
|
tagName: m,
|
|
3133
|
-
isMatched:
|
|
3233
|
+
isMatched: f
|
|
3134
3234
|
};
|
|
3135
3235
|
};
|
|
3136
3236
|
}
|
|
3137
3237
|
const n = new r();
|
|
3138
|
-
function i
|
|
3139
|
-
const
|
|
3238
|
+
function a(i) {
|
|
3239
|
+
const c = e(i);
|
|
3140
3240
|
return s({
|
|
3141
|
-
getId: (
|
|
3241
|
+
getId: (l) => n.getOrCreateId(l),
|
|
3142
3242
|
getChilds: o,
|
|
3143
|
-
createSnapshotNode:
|
|
3243
|
+
createSnapshotNode: c,
|
|
3144
3244
|
rootNodes: [window.document.documentElement]
|
|
3145
3245
|
});
|
|
3146
3246
|
}
|
|
3147
|
-
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom =
|
|
3247
|
+
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = a;
|
|
3148
3248
|
}
|
|
3149
|
-
const
|
|
3249
|
+
const Ns = `(function (){function __name(fn){return fn};${vs.toString()}; setupPageGlobals();})()`, $e = p.object({
|
|
3150
3250
|
contextName: p.string().optional().describe("Name of previously created context, to use"),
|
|
3151
3251
|
context: xe.optional().describe(
|
|
3152
3252
|
"Context creation options JSON to automatically create context"
|
|
@@ -3155,68 +3255,68 @@ const Ms = `(function (){function __name(fn){return fn};${Is.toString()}; setupP
|
|
|
3155
3255
|
"Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3156
3256
|
)
|
|
3157
3257
|
});
|
|
3158
|
-
async function
|
|
3258
|
+
async function Et(r, t, s) {
|
|
3159
3259
|
let o;
|
|
3160
3260
|
try {
|
|
3161
3261
|
o = $e.parse(r);
|
|
3162
|
-
} catch (
|
|
3262
|
+
} catch (d) {
|
|
3163
3263
|
return {
|
|
3164
|
-
error: B(
|
|
3264
|
+
error: B(d)
|
|
3165
3265
|
};
|
|
3166
3266
|
}
|
|
3167
|
-
const { name: e, contextName: n, context:
|
|
3267
|
+
const { name: e, contextName: n, context: a } = o;
|
|
3168
3268
|
if (!s.sessionId)
|
|
3169
3269
|
return {
|
|
3170
3270
|
error: "Session ID is required"
|
|
3171
3271
|
};
|
|
3172
|
-
const
|
|
3173
|
-
if (n &&
|
|
3272
|
+
const i = j(s.sessionId);
|
|
3273
|
+
if (n && a)
|
|
3174
3274
|
return {
|
|
3175
3275
|
error: "Either contextName or context must be provided, not both"
|
|
3176
3276
|
};
|
|
3177
|
-
let
|
|
3277
|
+
let c = !1, l = !1, u;
|
|
3178
3278
|
if (n) {
|
|
3179
|
-
for (const
|
|
3180
|
-
if (
|
|
3181
|
-
u =
|
|
3279
|
+
for (const d of i.browsers.values())
|
|
3280
|
+
if (d.contexts.has(n)) {
|
|
3281
|
+
u = d.contexts.get(n);
|
|
3182
3282
|
break;
|
|
3183
3283
|
}
|
|
3184
3284
|
if (!u)
|
|
3185
3285
|
return {
|
|
3186
3286
|
error: `Context "${n}" not found`
|
|
3187
3287
|
};
|
|
3188
|
-
} else if (
|
|
3189
|
-
const
|
|
3190
|
-
if (
|
|
3288
|
+
} else if (a) {
|
|
3289
|
+
const d = await Ct(a, t, s);
|
|
3290
|
+
if (d.error != null)
|
|
3191
3291
|
return {
|
|
3192
|
-
error:
|
|
3292
|
+
error: d.error
|
|
3193
3293
|
};
|
|
3194
|
-
u =
|
|
3294
|
+
u = d.contextInfo, c = d.browserInfoCreated, l = !0;
|
|
3195
3295
|
} else
|
|
3196
3296
|
return {
|
|
3197
3297
|
error: "Either contextName or context must be provided"
|
|
3198
3298
|
};
|
|
3199
3299
|
try {
|
|
3200
|
-
const
|
|
3201
|
-
await
|
|
3202
|
-
const
|
|
3300
|
+
const d = await u.context.newPage();
|
|
3301
|
+
await d.addInitScript(Ns), await d.goto("about:blank");
|
|
3302
|
+
const f = {
|
|
3203
3303
|
contextInfo: u,
|
|
3204
3304
|
name: e,
|
|
3205
|
-
page:
|
|
3305
|
+
page: d,
|
|
3206
3306
|
domSnapshots: /* @__PURE__ */ new Map()
|
|
3207
3307
|
};
|
|
3208
|
-
return u.pages.set(e,
|
|
3209
|
-
browserInfoCreated:
|
|
3210
|
-
contextInfoCreated:
|
|
3211
|
-
pageInfo:
|
|
3308
|
+
return u.pages.set(e, f), {
|
|
3309
|
+
browserInfoCreated: c,
|
|
3310
|
+
contextInfoCreated: l,
|
|
3311
|
+
pageInfo: f
|
|
3212
3312
|
};
|
|
3213
|
-
} catch (
|
|
3313
|
+
} catch (d) {
|
|
3214
3314
|
return {
|
|
3215
|
-
error: `Failed to create page: ${
|
|
3315
|
+
error: `Failed to create page: ${d instanceof Error ? d.message : "Unknown error"} in context "${u.name}" in browser "${u.browserInfo.name}" (${u.browserInfo.browserType})`
|
|
3216
3316
|
};
|
|
3217
3317
|
}
|
|
3218
3318
|
}
|
|
3219
|
-
function
|
|
3319
|
+
function Es(r, t) {
|
|
3220
3320
|
r(
|
|
3221
3321
|
"playwright-page-create",
|
|
3222
3322
|
{
|
|
@@ -3225,7 +3325,7 @@ function Ts(r, t) {
|
|
|
3225
3325
|
inputSchema: $e.shape
|
|
3226
3326
|
},
|
|
3227
3327
|
async (s, o) => {
|
|
3228
|
-
const e = await
|
|
3328
|
+
const e = await Et(s, t, o);
|
|
3229
3329
|
if (e.error != null)
|
|
3230
3330
|
return `Method: playwright-page-create(${JSON.stringify(s)})
|
|
3231
3331
|
❌ Error: ${e.error}`;
|
|
@@ -3237,7 +3337,7 @@ function Ts(r, t) {
|
|
|
3237
3337
|
}
|
|
3238
3338
|
);
|
|
3239
3339
|
}
|
|
3240
|
-
const
|
|
3340
|
+
const kt = p.object({
|
|
3241
3341
|
contextName: p.string().optional().describe(
|
|
3242
3342
|
"Name of context to list pages from. If not specified, lists pages from all contexts"
|
|
3243
3343
|
),
|
|
@@ -3245,13 +3345,13 @@ const Tt = p.object({
|
|
|
3245
3345
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3246
3346
|
)
|
|
3247
3347
|
});
|
|
3248
|
-
async function
|
|
3348
|
+
async function ks(r, t, s) {
|
|
3249
3349
|
let o;
|
|
3250
3350
|
try {
|
|
3251
|
-
o =
|
|
3252
|
-
} catch (
|
|
3351
|
+
o = kt.parse(r);
|
|
3352
|
+
} catch (c) {
|
|
3253
3353
|
return {
|
|
3254
|
-
error: B(
|
|
3354
|
+
error: B(c)
|
|
3255
3355
|
};
|
|
3256
3356
|
}
|
|
3257
3357
|
const { contextName: e, browserName: n } = o;
|
|
@@ -3259,79 +3359,79 @@ async function Cs(r, t, s) {
|
|
|
3259
3359
|
return {
|
|
3260
3360
|
error: "Session ID is required"
|
|
3261
3361
|
};
|
|
3262
|
-
const
|
|
3362
|
+
const a = j(s.sessionId), i = [];
|
|
3263
3363
|
if (n) {
|
|
3264
|
-
const
|
|
3265
|
-
if (!
|
|
3364
|
+
const c = a.browsers.get(n);
|
|
3365
|
+
if (!c)
|
|
3266
3366
|
return {
|
|
3267
3367
|
error: `Browser "${n}" not found`
|
|
3268
3368
|
};
|
|
3269
3369
|
if (e) {
|
|
3270
|
-
const
|
|
3271
|
-
if (!
|
|
3370
|
+
const l = c.contexts.get(e);
|
|
3371
|
+
if (!l)
|
|
3272
3372
|
return {
|
|
3273
|
-
error: `Context "${e}" not found in browser "${
|
|
3373
|
+
error: `Context "${e}" not found in browser "${c.name}" (${c.browserType})`
|
|
3274
3374
|
};
|
|
3275
|
-
const u = Array.from(
|
|
3276
|
-
u.length > 0 &&
|
|
3277
|
-
contextInfo:
|
|
3375
|
+
const u = Array.from(l.pages.values());
|
|
3376
|
+
u.length > 0 && i.push({
|
|
3377
|
+
contextInfo: l,
|
|
3278
3378
|
pages: u
|
|
3279
3379
|
});
|
|
3280
3380
|
} else
|
|
3281
|
-
for (const
|
|
3282
|
-
const u = Array.from(
|
|
3283
|
-
u.length > 0 &&
|
|
3284
|
-
contextInfo:
|
|
3381
|
+
for (const l of c.contexts.values()) {
|
|
3382
|
+
const u = Array.from(l.pages.values());
|
|
3383
|
+
u.length > 0 && i.push({
|
|
3384
|
+
contextInfo: l,
|
|
3285
3385
|
pages: u
|
|
3286
3386
|
});
|
|
3287
3387
|
}
|
|
3288
3388
|
} else if (e)
|
|
3289
|
-
for (const
|
|
3290
|
-
const
|
|
3291
|
-
if (
|
|
3292
|
-
const u = Array.from(
|
|
3293
|
-
u.length > 0 &&
|
|
3294
|
-
contextInfo:
|
|
3389
|
+
for (const c of a.browsers.values()) {
|
|
3390
|
+
const l = c.contexts.get(e);
|
|
3391
|
+
if (l) {
|
|
3392
|
+
const u = Array.from(l.pages.values());
|
|
3393
|
+
u.length > 0 && i.push({
|
|
3394
|
+
contextInfo: l,
|
|
3295
3395
|
pages: u
|
|
3296
3396
|
});
|
|
3297
3397
|
}
|
|
3298
3398
|
}
|
|
3299
3399
|
else
|
|
3300
|
-
for (const
|
|
3301
|
-
for (const
|
|
3302
|
-
const u = Array.from(
|
|
3303
|
-
u.length > 0 &&
|
|
3304
|
-
contextInfo:
|
|
3400
|
+
for (const c of a.browsers.values())
|
|
3401
|
+
for (const l of c.contexts.values()) {
|
|
3402
|
+
const u = Array.from(l.pages.values());
|
|
3403
|
+
u.length > 0 && i.push({
|
|
3404
|
+
contextInfo: l,
|
|
3305
3405
|
pages: u
|
|
3306
3406
|
});
|
|
3307
3407
|
}
|
|
3308
3408
|
return {
|
|
3309
|
-
pagesByContext:
|
|
3409
|
+
pagesByContext: i
|
|
3310
3410
|
};
|
|
3311
3411
|
}
|
|
3312
|
-
function
|
|
3412
|
+
function Os(r, t) {
|
|
3313
3413
|
r(
|
|
3314
3414
|
"playwright-page-list",
|
|
3315
3415
|
{
|
|
3316
3416
|
title: "List Pages",
|
|
3317
3417
|
description: "List active pages",
|
|
3318
|
-
inputSchema:
|
|
3418
|
+
inputSchema: kt.shape
|
|
3319
3419
|
},
|
|
3320
3420
|
async (s, o) => {
|
|
3321
|
-
const e = await
|
|
3421
|
+
const e = await ks(s, t, o);
|
|
3322
3422
|
if ("error" in e)
|
|
3323
3423
|
return `Method: playwright-page-list(${JSON.stringify(s)})
|
|
3324
3424
|
❌ Error: ${e.error}`;
|
|
3325
3425
|
let n = `Method: playwright-page-list(${JSON.stringify(s)})
|
|
3326
3426
|
`;
|
|
3327
3427
|
return e.pagesByContext.length === 0 ? n += "No pages found" : n += e.pagesByContext.map(
|
|
3328
|
-
({ contextInfo:
|
|
3428
|
+
({ contextInfo: a, pages: i }) => `${a.name} (${a.browserInfo.name}) (${a.browserInfo.browserType}): ${i.map((c) => c.name).join(", ")}`
|
|
3329
3429
|
).join(`
|
|
3330
3430
|
`), n;
|
|
3331
3431
|
}
|
|
3332
3432
|
);
|
|
3333
3433
|
}
|
|
3334
|
-
const
|
|
3434
|
+
const Ot = p.object({
|
|
3335
3435
|
names: p.array(p.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
|
|
3336
3436
|
contextName: p.string().optional().describe(
|
|
3337
3437
|
"Name of context to close pages from. If not specified, searches all contexts"
|
|
@@ -3340,105 +3440,105 @@ const Ct = p.object({
|
|
|
3340
3440
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3341
3441
|
)
|
|
3342
3442
|
});
|
|
3343
|
-
async function
|
|
3443
|
+
async function Ds(r, t, s) {
|
|
3344
3444
|
let o;
|
|
3345
3445
|
try {
|
|
3346
|
-
o =
|
|
3347
|
-
} catch (
|
|
3446
|
+
o = Ot.parse(r);
|
|
3447
|
+
} catch (d) {
|
|
3348
3448
|
return {
|
|
3349
|
-
error: B(
|
|
3449
|
+
error: B(d)
|
|
3350
3450
|
};
|
|
3351
3451
|
}
|
|
3352
|
-
const { names: e, contextName: n, browserName:
|
|
3452
|
+
const { names: e, contextName: n, browserName: a } = o;
|
|
3353
3453
|
if (!s.sessionId)
|
|
3354
3454
|
return {
|
|
3355
3455
|
error: "Session ID is required"
|
|
3356
3456
|
};
|
|
3357
|
-
const
|
|
3457
|
+
const i = j(s.sessionId), c = [], l = [];
|
|
3358
3458
|
let u = [];
|
|
3359
|
-
if (
|
|
3360
|
-
const
|
|
3361
|
-
if (!
|
|
3459
|
+
if (a) {
|
|
3460
|
+
const d = i.browsers.get(a);
|
|
3461
|
+
if (!d)
|
|
3362
3462
|
return {
|
|
3363
|
-
error: `Browser "${
|
|
3463
|
+
error: `Browser "${a}" not found`
|
|
3364
3464
|
};
|
|
3365
3465
|
if (n) {
|
|
3366
|
-
const
|
|
3367
|
-
if (!
|
|
3466
|
+
const f = d.contexts.get(n);
|
|
3467
|
+
if (!f)
|
|
3368
3468
|
return {
|
|
3369
|
-
error: `Context "${n}" not found in browser "${
|
|
3469
|
+
error: `Context "${n}" not found in browser "${d.name}" (${d.browserType})`
|
|
3370
3470
|
};
|
|
3371
3471
|
e ? e.forEach((h) => {
|
|
3372
|
-
const m =
|
|
3373
|
-
m ? u.push(m) :
|
|
3374
|
-
`Page "${h}" not found in context "${
|
|
3472
|
+
const m = f.pages.get(h);
|
|
3473
|
+
m ? u.push(m) : l.push(
|
|
3474
|
+
`Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
|
|
3375
3475
|
);
|
|
3376
|
-
}) : u = Array.from(
|
|
3476
|
+
}) : u = Array.from(f.pages.values());
|
|
3377
3477
|
} else
|
|
3378
|
-
for (const
|
|
3478
|
+
for (const f of d.contexts.values())
|
|
3379
3479
|
e ? e.forEach((h) => {
|
|
3380
|
-
const m =
|
|
3381
|
-
m ? u.push(m) :
|
|
3382
|
-
`Page "${h}" not found in context "${
|
|
3480
|
+
const m = f.pages.get(h);
|
|
3481
|
+
m ? u.push(m) : l.push(
|
|
3482
|
+
`Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
|
|
3383
3483
|
);
|
|
3384
|
-
}) : u.push(...Array.from(
|
|
3484
|
+
}) : u.push(...Array.from(f.pages.values()));
|
|
3385
3485
|
} else if (n)
|
|
3386
|
-
for (const
|
|
3387
|
-
const
|
|
3388
|
-
|
|
3389
|
-
const m =
|
|
3390
|
-
m ? u.push(m) :
|
|
3391
|
-
`Page "${h}" not found in context "${
|
|
3486
|
+
for (const d of i.browsers.values()) {
|
|
3487
|
+
const f = d.contexts.get(n);
|
|
3488
|
+
f && (e ? e.forEach((h) => {
|
|
3489
|
+
const m = f.pages.get(h);
|
|
3490
|
+
m ? u.push(m) : l.push(
|
|
3491
|
+
`Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
|
|
3392
3492
|
);
|
|
3393
|
-
}) : u.push(...Array.from(
|
|
3493
|
+
}) : u.push(...Array.from(f.pages.values())));
|
|
3394
3494
|
}
|
|
3395
3495
|
else
|
|
3396
|
-
for (const
|
|
3397
|
-
for (const
|
|
3496
|
+
for (const d of i.browsers.values())
|
|
3497
|
+
for (const f of d.contexts.values())
|
|
3398
3498
|
e ? e.forEach((h) => {
|
|
3399
|
-
const m =
|
|
3400
|
-
m ? u.push(m) :
|
|
3401
|
-
`Page "${h}" not found in context "${
|
|
3499
|
+
const m = f.pages.get(h);
|
|
3500
|
+
m ? u.push(m) : l.push(
|
|
3501
|
+
`Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
|
|
3402
3502
|
);
|
|
3403
|
-
}) : u.push(...Array.from(
|
|
3503
|
+
}) : u.push(...Array.from(f.pages.values()));
|
|
3404
3504
|
return await Promise.all(
|
|
3405
|
-
u.map(async (
|
|
3505
|
+
u.map(async (d) => {
|
|
3406
3506
|
try {
|
|
3407
|
-
await
|
|
3408
|
-
`${
|
|
3507
|
+
await d.page.close(), d.contextInfo.pages.delete(d.name), c.push(
|
|
3508
|
+
`${d.name} (${d.contextInfo.name}) (${d.contextInfo.browserInfo.name}) (${d.contextInfo.browserInfo.browserType})`
|
|
3409
3509
|
);
|
|
3410
|
-
} catch (
|
|
3411
|
-
|
|
3412
|
-
`Failed to close page "${
|
|
3510
|
+
} catch (f) {
|
|
3511
|
+
l.push(
|
|
3512
|
+
`Failed to close page "${d.name}" (${d.contextInfo.name}) (${d.contextInfo.browserInfo.name}) (${d.contextInfo.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
|
|
3413
3513
|
);
|
|
3414
3514
|
}
|
|
3415
3515
|
})
|
|
3416
3516
|
), {
|
|
3417
|
-
closedPages:
|
|
3418
|
-
...
|
|
3517
|
+
closedPages: c,
|
|
3518
|
+
...l.length > 0 && { errors: l }
|
|
3419
3519
|
};
|
|
3420
3520
|
}
|
|
3421
|
-
function
|
|
3521
|
+
function Rs(r, t) {
|
|
3422
3522
|
r(
|
|
3423
3523
|
"playwright-page-close",
|
|
3424
3524
|
{
|
|
3425
3525
|
title: "Close Pages",
|
|
3426
3526
|
description: "Close pages",
|
|
3427
|
-
inputSchema:
|
|
3527
|
+
inputSchema: Ot.shape
|
|
3428
3528
|
},
|
|
3429
3529
|
async (s, o) => {
|
|
3430
|
-
const e = await
|
|
3530
|
+
const e = await Ds(s, t, o);
|
|
3431
3531
|
if ("error" in e)
|
|
3432
3532
|
return `Method: playwright-page-close(${JSON.stringify(s)})
|
|
3433
3533
|
❌ Error: ${e.error}`;
|
|
3434
3534
|
const n = [];
|
|
3435
|
-
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((
|
|
3535
|
+
return e.closedPages.length > 0 && n.push(`✅ Closed pages: ${e.closedPages.join(", ")}`), e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((a) => n.push(a))), n.length === 0 && n.push("No pages to close"), `Method: playwright-page-close(${JSON.stringify(s)})
|
|
3436
3536
|
${n.join(`
|
|
3437
3537
|
`)}`;
|
|
3438
3538
|
}
|
|
3439
3539
|
);
|
|
3440
3540
|
}
|
|
3441
|
-
const
|
|
3541
|
+
const Dt = p.object({
|
|
3442
3542
|
pageName: p.string().optional().describe("Name of previously created page to navigate"),
|
|
3443
3543
|
page: $e.optional().describe(
|
|
3444
3544
|
"Page creation options JSON to automatically create page"
|
|
@@ -3453,28 +3553,28 @@ const vt = p.object({
|
|
|
3453
3553
|
- 'commit': network response received and document started loading`
|
|
3454
3554
|
)
|
|
3455
3555
|
});
|
|
3456
|
-
async function
|
|
3556
|
+
async function Fs(r, t, s) {
|
|
3457
3557
|
let o;
|
|
3458
3558
|
try {
|
|
3459
|
-
o =
|
|
3559
|
+
o = Dt.parse(r);
|
|
3460
3560
|
} catch (m) {
|
|
3461
3561
|
return {
|
|
3462
3562
|
error: B(m)
|
|
3463
3563
|
};
|
|
3464
3564
|
}
|
|
3465
|
-
const { pageName: e, page: n, url:
|
|
3565
|
+
const { pageName: e, page: n, url: a, timeout: i, waitUntil: c } = o;
|
|
3466
3566
|
if (!s.sessionId)
|
|
3467
3567
|
return {
|
|
3468
3568
|
error: "Session ID is required"
|
|
3469
3569
|
};
|
|
3470
|
-
const
|
|
3570
|
+
const l = j(s.sessionId);
|
|
3471
3571
|
if (e && n)
|
|
3472
3572
|
return {
|
|
3473
3573
|
error: "Either pageName or page must be provided, not both"
|
|
3474
3574
|
};
|
|
3475
|
-
let u = !1,
|
|
3575
|
+
let u = !1, d = !1, f = !1, h;
|
|
3476
3576
|
if (e) {
|
|
3477
|
-
for (const m of
|
|
3577
|
+
for (const m of l.browsers.values()) {
|
|
3478
3578
|
for (const g of m.contexts.values())
|
|
3479
3579
|
if (g.pages.has(e)) {
|
|
3480
3580
|
h = g.pages.get(e);
|
|
@@ -3487,50 +3587,50 @@ async function ks(r, t, s) {
|
|
|
3487
3587
|
error: `Page "${e}" not found`
|
|
3488
3588
|
};
|
|
3489
3589
|
} else if (n) {
|
|
3490
|
-
const m = await
|
|
3590
|
+
const m = await Et(n, t, s);
|
|
3491
3591
|
if (m.error != null)
|
|
3492
3592
|
return {
|
|
3493
3593
|
error: m.error
|
|
3494
3594
|
};
|
|
3495
|
-
h = m.pageInfo, u = m.browserInfoCreated,
|
|
3595
|
+
h = m.pageInfo, u = m.browserInfoCreated, d = m.contextInfoCreated, f = !0;
|
|
3496
3596
|
} else
|
|
3497
3597
|
return {
|
|
3498
3598
|
error: "Either pageName or page must be provided"
|
|
3499
3599
|
};
|
|
3500
3600
|
try {
|
|
3501
|
-
const m = await h.page.goto(
|
|
3502
|
-
timeout:
|
|
3503
|
-
waitUntil:
|
|
3601
|
+
const m = await h.page.goto(a, {
|
|
3602
|
+
timeout: i * 1e3,
|
|
3603
|
+
waitUntil: c
|
|
3504
3604
|
});
|
|
3505
3605
|
return m ? {
|
|
3506
3606
|
browserInfoCreated: u,
|
|
3507
|
-
contextInfoCreated:
|
|
3508
|
-
pageInfoCreated:
|
|
3607
|
+
contextInfoCreated: d,
|
|
3608
|
+
pageInfoCreated: f,
|
|
3509
3609
|
pageInfo: h,
|
|
3510
3610
|
status: m.status()
|
|
3511
3611
|
} : {
|
|
3512
3612
|
browserInfoCreated: u,
|
|
3513
|
-
contextInfoCreated:
|
|
3514
|
-
pageInfoCreated:
|
|
3613
|
+
contextInfoCreated: d,
|
|
3614
|
+
pageInfoCreated: f,
|
|
3515
3615
|
pageInfo: h,
|
|
3516
3616
|
status: 200
|
|
3517
3617
|
};
|
|
3518
3618
|
} catch (m) {
|
|
3519
3619
|
return {
|
|
3520
|
-
error: `Failed to navigate to "${
|
|
3620
|
+
error: `Failed to navigate to "${a}": ${m instanceof Error ? m.message : "Unknown error"}`
|
|
3521
3621
|
};
|
|
3522
3622
|
}
|
|
3523
3623
|
}
|
|
3524
|
-
function
|
|
3624
|
+
function Bs(r, t) {
|
|
3525
3625
|
r(
|
|
3526
3626
|
"playwright-page-goto",
|
|
3527
3627
|
{
|
|
3528
3628
|
title: "Navigate Page",
|
|
3529
3629
|
description: "Navigate page to URL. Use for manual browser interaction",
|
|
3530
|
-
inputSchema:
|
|
3630
|
+
inputSchema: Dt.shape
|
|
3531
3631
|
},
|
|
3532
3632
|
async (s, o) => {
|
|
3533
|
-
const e = await
|
|
3633
|
+
const e = await Fs(s, t, o);
|
|
3534
3634
|
if (e.error != null)
|
|
3535
3635
|
return `Method: playwright-page-goto(${JSON.stringify(s)})
|
|
3536
3636
|
❌ Error: ${e.error}`;
|
|
@@ -3549,13 +3649,13 @@ const Ie = p.object({
|
|
|
3549
3649
|
),
|
|
3550
3650
|
cssSelector: p.string().describe("CSS selector to capture page content")
|
|
3551
3651
|
});
|
|
3552
|
-
async function
|
|
3652
|
+
async function Rt(r, t, s) {
|
|
3553
3653
|
let o;
|
|
3554
3654
|
try {
|
|
3555
3655
|
o = Ie.parse(r);
|
|
3556
|
-
} catch (
|
|
3656
|
+
} catch (c) {
|
|
3557
3657
|
return {
|
|
3558
|
-
error: B(
|
|
3658
|
+
error: B(c)
|
|
3559
3659
|
};
|
|
3560
3660
|
}
|
|
3561
3661
|
const { name: e, cssSelector: n } = o;
|
|
@@ -3563,15 +3663,15 @@ async function Et(r, t, s) {
|
|
|
3563
3663
|
return {
|
|
3564
3664
|
error: "Session ID is required"
|
|
3565
3665
|
};
|
|
3566
|
-
const
|
|
3666
|
+
const a = j(s.sessionId), i = {
|
|
3567
3667
|
name: e,
|
|
3568
3668
|
cssSelector: n
|
|
3569
3669
|
};
|
|
3570
|
-
return
|
|
3571
|
-
snapshotQuery:
|
|
3670
|
+
return a.domSnapshotQueries.set(e, i), {
|
|
3671
|
+
snapshotQuery: i
|
|
3572
3672
|
};
|
|
3573
3673
|
}
|
|
3574
|
-
function
|
|
3674
|
+
function Ls(r, t) {
|
|
3575
3675
|
r(
|
|
3576
3676
|
"playwright-dom-snapshot-query-create",
|
|
3577
3677
|
{
|
|
@@ -3580,64 +3680,64 @@ function Ds(r, t) {
|
|
|
3580
3680
|
inputSchema: Ie.shape
|
|
3581
3681
|
},
|
|
3582
3682
|
async (s, o) => {
|
|
3583
|
-
const e = await
|
|
3683
|
+
const e = await Rt(s, t, o);
|
|
3584
3684
|
return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3585
3685
|
❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3586
3686
|
✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
3587
3687
|
}
|
|
3588
3688
|
);
|
|
3589
3689
|
}
|
|
3590
|
-
function
|
|
3690
|
+
function Ps(r) {
|
|
3591
3691
|
return function(s, o) {
|
|
3592
3692
|
let e, n = 0;
|
|
3593
|
-
const
|
|
3594
|
-
let
|
|
3693
|
+
const a = o ? o.length : 0;
|
|
3694
|
+
let i = 1, c = 0, l = 0, u, d;
|
|
3595
3695
|
if (o)
|
|
3596
3696
|
for (let m = 0; m < o.length; m++) {
|
|
3597
3697
|
const g = o[m];
|
|
3598
|
-
n += g.countMatched,
|
|
3698
|
+
n += g.countMatched, i += g.countTotal, c += g.tokens, l += g.tokensTotal;
|
|
3599
3699
|
}
|
|
3600
|
-
s ? (u = s.uid,
|
|
3601
|
-
let
|
|
3602
|
-
|
|
3700
|
+
s ? (u = s.uid, d = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, d = null, e = !1);
|
|
3701
|
+
let f;
|
|
3702
|
+
d ? f = {
|
|
3603
3703
|
indent: !0,
|
|
3604
|
-
textOpen: `<${
|
|
3605
|
-
textClose: `</${
|
|
3606
|
-
} :
|
|
3704
|
+
textOpen: `<${d} uid:${u}>`,
|
|
3705
|
+
textClose: `</${d}>`
|
|
3706
|
+
} : f = {
|
|
3607
3707
|
indent: !0,
|
|
3608
3708
|
textOpen: `<root uid:${u}>`,
|
|
3609
3709
|
textClose: "</root>"
|
|
3610
3710
|
};
|
|
3611
|
-
const h = ht(
|
|
3612
|
-
return
|
|
3711
|
+
const h = ht(f);
|
|
3712
|
+
return l += h, {
|
|
3613
3713
|
uid: u,
|
|
3614
|
-
tagName:
|
|
3714
|
+
tagName: d,
|
|
3615
3715
|
isMatched: e,
|
|
3616
3716
|
countMatched: n,
|
|
3617
|
-
countChilds:
|
|
3618
|
-
countTotal:
|
|
3717
|
+
countChilds: a,
|
|
3718
|
+
countTotal: i,
|
|
3619
3719
|
tokens: h,
|
|
3620
|
-
tokensChilds:
|
|
3621
|
-
tokensTotal:
|
|
3622
|
-
text:
|
|
3720
|
+
tokensChilds: c,
|
|
3721
|
+
tokensTotal: l,
|
|
3722
|
+
text: f
|
|
3623
3723
|
};
|
|
3624
3724
|
};
|
|
3625
3725
|
}
|
|
3626
|
-
function
|
|
3627
|
-
const s =
|
|
3726
|
+
function As(r, t) {
|
|
3727
|
+
const s = ae(t), o = s.getChilds(s.root), e = ft({
|
|
3628
3728
|
getId: (n) => {
|
|
3629
|
-
const
|
|
3630
|
-
if (
|
|
3729
|
+
const a = s.getId(n);
|
|
3730
|
+
if (a == null)
|
|
3631
3731
|
throw new Error(
|
|
3632
3732
|
`Invalid tree structure: node ID is null for node ${JSON.stringify(n)}`
|
|
3633
3733
|
);
|
|
3634
|
-
return
|
|
3734
|
+
return a;
|
|
3635
3735
|
},
|
|
3636
3736
|
getChilds: (n) => s.getChilds(n),
|
|
3637
|
-
createSnapshotNode:
|
|
3737
|
+
createSnapshotNode: Ps(),
|
|
3638
3738
|
rootNodes: o ?? []
|
|
3639
3739
|
});
|
|
3640
|
-
return
|
|
3740
|
+
return ae(e);
|
|
3641
3741
|
}
|
|
3642
3742
|
const Me = p.object({
|
|
3643
3743
|
pageName: p.string().describe("Name of previously created page, to create snapshot from"),
|
|
@@ -3649,63 +3749,63 @@ const Me = p.object({
|
|
|
3649
3749
|
"Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3650
3750
|
)
|
|
3651
3751
|
});
|
|
3652
|
-
async function
|
|
3752
|
+
async function Ft(r, t, s) {
|
|
3653
3753
|
let o;
|
|
3654
3754
|
try {
|
|
3655
3755
|
o = Me.parse(r);
|
|
3656
|
-
} catch (
|
|
3756
|
+
} catch (f) {
|
|
3657
3757
|
return {
|
|
3658
|
-
error: B(
|
|
3758
|
+
error: B(f)
|
|
3659
3759
|
};
|
|
3660
3760
|
}
|
|
3661
|
-
const { pageName: e, queryName: n, query:
|
|
3761
|
+
const { pageName: e, queryName: n, query: a, name: i } = o;
|
|
3662
3762
|
if (!s.sessionId)
|
|
3663
3763
|
return {
|
|
3664
3764
|
error: "Session ID is required"
|
|
3665
3765
|
};
|
|
3666
|
-
const
|
|
3667
|
-
let
|
|
3668
|
-
for (const
|
|
3669
|
-
for (const h of
|
|
3766
|
+
const c = j(s.sessionId);
|
|
3767
|
+
let l;
|
|
3768
|
+
for (const f of c.browsers.values()) {
|
|
3769
|
+
for (const h of f.contexts.values())
|
|
3670
3770
|
if (h.pages.has(e)) {
|
|
3671
|
-
|
|
3771
|
+
l = h.pages.get(e);
|
|
3672
3772
|
break;
|
|
3673
3773
|
}
|
|
3674
|
-
if (
|
|
3774
|
+
if (l) break;
|
|
3675
3775
|
}
|
|
3676
|
-
if (!
|
|
3776
|
+
if (!l)
|
|
3677
3777
|
return {
|
|
3678
3778
|
error: `Page "${e}" not found`
|
|
3679
3779
|
};
|
|
3680
|
-
if (n &&
|
|
3780
|
+
if (n && a)
|
|
3681
3781
|
return {
|
|
3682
3782
|
error: "Either queryName or query must be provided, not both"
|
|
3683
3783
|
};
|
|
3684
|
-
let u,
|
|
3784
|
+
let u, d = !1;
|
|
3685
3785
|
if (n) {
|
|
3686
|
-
const
|
|
3687
|
-
if (!
|
|
3786
|
+
const f = c.domSnapshotQueries.get(n);
|
|
3787
|
+
if (!f)
|
|
3688
3788
|
return {
|
|
3689
3789
|
error: `DOM snapshot query "${n}" not found`
|
|
3690
3790
|
};
|
|
3691
|
-
u =
|
|
3692
|
-
} else if (
|
|
3693
|
-
const
|
|
3694
|
-
|
|
3791
|
+
u = f;
|
|
3792
|
+
} else if (a) {
|
|
3793
|
+
const f = await Rt(
|
|
3794
|
+
a,
|
|
3695
3795
|
t,
|
|
3696
3796
|
s
|
|
3697
3797
|
);
|
|
3698
|
-
if (
|
|
3798
|
+
if (f.error != null)
|
|
3699
3799
|
return {
|
|
3700
|
-
error:
|
|
3800
|
+
error: f.error
|
|
3701
3801
|
};
|
|
3702
|
-
u =
|
|
3802
|
+
u = f.snapshotQuery, d = !0;
|
|
3703
3803
|
} else
|
|
3704
3804
|
return {
|
|
3705
3805
|
error: "Either queryName or query must be provided"
|
|
3706
3806
|
};
|
|
3707
3807
|
try {
|
|
3708
|
-
const
|
|
3808
|
+
const f = await l.page.evaluate(
|
|
3709
3809
|
(y) => {
|
|
3710
3810
|
const w = window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom;
|
|
3711
3811
|
if (!w)
|
|
@@ -3718,24 +3818,24 @@ async function Nt(r, t, s) {
|
|
|
3718
3818
|
},
|
|
3719
3819
|
u
|
|
3720
3820
|
), h = {
|
|
3721
|
-
idToNode: new Map(
|
|
3722
|
-
idToChildIds: new Map(
|
|
3723
|
-
}, m =
|
|
3724
|
-
name:
|
|
3821
|
+
idToNode: new Map(f.idToNode),
|
|
3822
|
+
idToChildIds: new Map(f.idToChildIds)
|
|
3823
|
+
}, m = As(u, h), g = {
|
|
3824
|
+
name: i,
|
|
3725
3825
|
query: u,
|
|
3726
3826
|
tree: m
|
|
3727
3827
|
};
|
|
3728
|
-
return
|
|
3828
|
+
return l.domSnapshots.set(i, g), {
|
|
3729
3829
|
domSnapshot: g,
|
|
3730
|
-
queryCreated:
|
|
3830
|
+
queryCreated: d
|
|
3731
3831
|
};
|
|
3732
|
-
} catch (
|
|
3832
|
+
} catch (f) {
|
|
3733
3833
|
return {
|
|
3734
|
-
error: `Failed to create DOM snapshot: ${
|
|
3834
|
+
error: `Failed to create DOM snapshot: ${f instanceof Error ? f.message : "Unknown error"}`
|
|
3735
3835
|
};
|
|
3736
3836
|
}
|
|
3737
3837
|
}
|
|
3738
|
-
function
|
|
3838
|
+
function zs(r, t) {
|
|
3739
3839
|
r(
|
|
3740
3840
|
"playwright-dom-snapshot-create",
|
|
3741
3841
|
{
|
|
@@ -3744,7 +3844,7 @@ function Bs(r, t) {
|
|
|
3744
3844
|
inputSchema: Me.shape
|
|
3745
3845
|
},
|
|
3746
3846
|
async (s, o) => {
|
|
3747
|
-
const e = await
|
|
3847
|
+
const e = await Ft(s, t, o);
|
|
3748
3848
|
if (e.error != null)
|
|
3749
3849
|
return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
|
|
3750
3850
|
❌ Error: ${e.error}`;
|
|
@@ -3755,7 +3855,7 @@ function Bs(r, t) {
|
|
|
3755
3855
|
}
|
|
3756
3856
|
);
|
|
3757
3857
|
}
|
|
3758
|
-
class
|
|
3858
|
+
class Us {
|
|
3759
3859
|
tokens = 20;
|
|
3760
3860
|
getReportText = (t) => ({
|
|
3761
3861
|
indent: !0,
|
|
@@ -3769,7 +3869,7 @@ class Ls {
|
|
|
3769
3869
|
tokensGrouped: s.tokens
|
|
3770
3870
|
} : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
|
|
3771
3871
|
}
|
|
3772
|
-
const
|
|
3872
|
+
const Bt = p.object({
|
|
3773
3873
|
snapshotName: p.string().optional().describe("Name of previously created DOM snapshot, to use"),
|
|
3774
3874
|
snapshot: Me.optional().describe(
|
|
3775
3875
|
"DOM snapshot creation options JSON to automatically create snapshot"
|
|
@@ -3789,10 +3889,10 @@ const kt = p.object({
|
|
|
3789
3889
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
3790
3890
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
3791
3891
|
});
|
|
3792
|
-
async function
|
|
3892
|
+
async function qs(r, t, s) {
|
|
3793
3893
|
let o;
|
|
3794
3894
|
try {
|
|
3795
|
-
o =
|
|
3895
|
+
o = Bt.parse(r);
|
|
3796
3896
|
} catch (g) {
|
|
3797
3897
|
return {
|
|
3798
3898
|
error: B(g)
|
|
@@ -3801,40 +3901,40 @@ async function Ps(r, t, s) {
|
|
|
3801
3901
|
const {
|
|
3802
3902
|
snapshotName: e,
|
|
3803
3903
|
snapshot: n,
|
|
3804
|
-
childsIndexRange:
|
|
3904
|
+
childsIndexRange: a
|
|
3805
3905
|
// maxCountTotal,
|
|
3806
3906
|
// maxTokensTotal,
|
|
3807
3907
|
// maxCountGroup,
|
|
3808
3908
|
// maxTokensGroup,
|
|
3809
|
-
} = o,
|
|
3909
|
+
} = o, i = 60, c = 1e3, l = 25, u = 900;
|
|
3810
3910
|
if (!s.sessionId)
|
|
3811
3911
|
return {
|
|
3812
3912
|
error: "Session ID is required"
|
|
3813
3913
|
};
|
|
3814
|
-
const
|
|
3914
|
+
const d = j(s.sessionId);
|
|
3815
3915
|
if (e && n)
|
|
3816
3916
|
return {
|
|
3817
3917
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
3818
3918
|
};
|
|
3819
|
-
let
|
|
3919
|
+
let f, h = !1, m = !1;
|
|
3820
3920
|
if (e) {
|
|
3821
|
-
for (const g of
|
|
3921
|
+
for (const g of d.browsers.values()) {
|
|
3822
3922
|
for (const y of g.contexts.values()) {
|
|
3823
3923
|
for (const w of y.pages.values())
|
|
3824
3924
|
if (w.domSnapshots.has(e)) {
|
|
3825
|
-
|
|
3925
|
+
f = w.domSnapshots.get(e);
|
|
3826
3926
|
break;
|
|
3827
3927
|
}
|
|
3828
|
-
if (
|
|
3928
|
+
if (f != null) break;
|
|
3829
3929
|
}
|
|
3830
|
-
if (
|
|
3930
|
+
if (f != null) break;
|
|
3831
3931
|
}
|
|
3832
|
-
if (
|
|
3932
|
+
if (f == null)
|
|
3833
3933
|
return {
|
|
3834
3934
|
error: `DOM snapshot "${e}" not found`
|
|
3835
3935
|
};
|
|
3836
3936
|
} else if (n) {
|
|
3837
|
-
const g = await
|
|
3937
|
+
const g = await Ft(
|
|
3838
3938
|
n,
|
|
3839
3939
|
t,
|
|
3840
3940
|
s
|
|
@@ -3843,32 +3943,32 @@ async function Ps(r, t, s) {
|
|
|
3843
3943
|
return {
|
|
3844
3944
|
error: g.error
|
|
3845
3945
|
};
|
|
3846
|
-
|
|
3946
|
+
f = g.domSnapshot, h = g.queryCreated, m = !0;
|
|
3847
3947
|
} else
|
|
3848
3948
|
return {
|
|
3849
3949
|
error: "Either snapshotName or snapshot must be provided"
|
|
3850
3950
|
};
|
|
3851
3951
|
try {
|
|
3852
3952
|
const g = o.parentUid, y = pt({
|
|
3853
|
-
tree:
|
|
3953
|
+
tree: f.tree,
|
|
3854
3954
|
request: {
|
|
3855
3955
|
parentNodeId: g,
|
|
3856
|
-
childsIndexRange:
|
|
3956
|
+
childsIndexRange: a,
|
|
3857
3957
|
limits: {
|
|
3858
|
-
maxCountTotal:
|
|
3859
|
-
maxTokensTotal:
|
|
3860
|
-
maxCountGroup:
|
|
3958
|
+
maxCountTotal: i,
|
|
3959
|
+
maxTokensTotal: c,
|
|
3960
|
+
maxCountGroup: l,
|
|
3861
3961
|
maxTokensGroup: u
|
|
3862
3962
|
}
|
|
3863
3963
|
},
|
|
3864
|
-
indexRangeGroupStrategy: new
|
|
3964
|
+
indexRangeGroupStrategy: new Us()
|
|
3865
3965
|
}), w = mt(y);
|
|
3866
3966
|
return {
|
|
3867
|
-
domSnapshot:
|
|
3967
|
+
domSnapshot: f,
|
|
3868
3968
|
queryCreated: h,
|
|
3869
3969
|
snapshotCreated: m,
|
|
3870
3970
|
parentUid: g,
|
|
3871
|
-
childsIndexRange:
|
|
3971
|
+
childsIndexRange: a,
|
|
3872
3972
|
report: w
|
|
3873
3973
|
};
|
|
3874
3974
|
} catch (g) {
|
|
@@ -3877,16 +3977,16 @@ async function Ps(r, t, s) {
|
|
|
3877
3977
|
};
|
|
3878
3978
|
}
|
|
3879
3979
|
}
|
|
3880
|
-
function
|
|
3980
|
+
function _s(r, t) {
|
|
3881
3981
|
r(
|
|
3882
3982
|
"playwright-dom-snapshot-browse",
|
|
3883
3983
|
{
|
|
3884
3984
|
title: "Browse DOM Snapshot",
|
|
3885
3985
|
description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
|
|
3886
|
-
inputSchema:
|
|
3986
|
+
inputSchema: Bt.shape
|
|
3887
3987
|
},
|
|
3888
3988
|
async (s, o) => {
|
|
3889
|
-
const e = await
|
|
3989
|
+
const e = await qs(s, t, o);
|
|
3890
3990
|
if (e.error != null)
|
|
3891
3991
|
return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
|
|
3892
3992
|
❌ Error: ${e.error}`;
|
|
@@ -3898,8 +3998,8 @@ function As(r, t) {
|
|
|
3898
3998
|
`, n += `CSS Selector: ${e.domSnapshot.query.cssSelector}
|
|
3899
3999
|
`, n += `Parent UID: ${e.parentUid ?? "null (root node)"}
|
|
3900
4000
|
`, e.childsIndexRange) {
|
|
3901
|
-
const [
|
|
3902
|
-
n += ` Showing indexes: ${
|
|
4001
|
+
const [a, i] = e.childsIndexRange, l = (e.parentUid ? e.domSnapshot.tree.getNode(e.parentUid) : e.domSnapshot.tree.root).countChilds;
|
|
4002
|
+
n += ` Showing indexes: ${a}-${i} of ${l}
|
|
3903
4003
|
`;
|
|
3904
4004
|
}
|
|
3905
4005
|
return n += `
|
|
@@ -3907,13 +4007,13 @@ ${e.report}`, n;
|
|
|
3907
4007
|
}
|
|
3908
4008
|
);
|
|
3909
4009
|
}
|
|
3910
|
-
function
|
|
3911
|
-
t.browserCreate &&
|
|
4010
|
+
function Gs(r, t) {
|
|
4011
|
+
t.browserCreate && ws(r, t), t.browserList && bs(r, t), t.browserClose && xs(r, t), t.contextCreate && $s(r, t), t.contextList && Ms(r, t), t.contextClose && Cs(r, t), t.pageCreate && Es(r, t), t.pageList && Os(r, t), t.pageClose && Rs(r, t), t.pageGoto && Bs(r, t), t.domSnapshotQueryCreate && Ls(r, t), t.domSnapshotCreate && zs(r, t), t.domSnapshotBrowse && _s(r, t), console.log("Playwright manager");
|
|
3912
4012
|
}
|
|
3913
|
-
function
|
|
4013
|
+
function Js(r) {
|
|
3914
4014
|
const { logFilePath: t } = r;
|
|
3915
|
-
return async function(o, e, n,
|
|
3916
|
-
await
|
|
4015
|
+
return async function(o, e, n, a) {
|
|
4016
|
+
await ne({
|
|
3917
4017
|
logFilePath: t,
|
|
3918
4018
|
message: "ERROR",
|
|
3919
4019
|
data: {
|
|
@@ -3932,83 +4032,83 @@ function Us(r) {
|
|
|
3932
4032
|
});
|
|
3933
4033
|
};
|
|
3934
4034
|
}
|
|
3935
|
-
function
|
|
4035
|
+
function Lt() {
|
|
3936
4036
|
return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
|
|
3937
4037
|
}
|
|
3938
|
-
function
|
|
3939
|
-
const t =
|
|
4038
|
+
function js(r) {
|
|
4039
|
+
const t = oe(), s = Ks();
|
|
3940
4040
|
return t.use(s), t;
|
|
3941
4041
|
}
|
|
3942
|
-
function
|
|
3943
|
-
const t =
|
|
4042
|
+
function Ks(r) {
|
|
4043
|
+
const t = oe.Router();
|
|
3944
4044
|
return t.use((s, o, e) => {
|
|
3945
4045
|
s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
|
|
3946
|
-
}), t.use(
|
|
4046
|
+
}), t.use(oe.json()), t;
|
|
3947
4047
|
}
|
|
3948
|
-
function
|
|
3949
|
-
const t =
|
|
3950
|
-
return t.use(
|
|
4048
|
+
function Ws(r) {
|
|
4049
|
+
const t = oe.Router();
|
|
4050
|
+
return t.use(Vt({ authToken: r.authToken })), t.all("/mcp", rr(r)), t;
|
|
3951
4051
|
}
|
|
3952
|
-
function
|
|
3953
|
-
return r.use(
|
|
4052
|
+
function Hs(r, t) {
|
|
4053
|
+
return r.use(Js({ logFilePath: t.logFilePath })), new Promise((s, o) => {
|
|
3954
4054
|
let e;
|
|
3955
4055
|
const n = () => {
|
|
3956
4056
|
s(e);
|
|
3957
4057
|
};
|
|
3958
4058
|
try {
|
|
3959
|
-
e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (
|
|
3960
|
-
o(
|
|
4059
|
+
e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (a) => {
|
|
4060
|
+
o(a);
|
|
3961
4061
|
});
|
|
3962
|
-
} catch (
|
|
3963
|
-
o(
|
|
4062
|
+
} catch (a) {
|
|
4063
|
+
o(a);
|
|
3964
4064
|
}
|
|
3965
4065
|
});
|
|
3966
4066
|
}
|
|
3967
|
-
function
|
|
4067
|
+
function Qs(r, t) {
|
|
3968
4068
|
if (!r.address())
|
|
3969
4069
|
throw new Error("Server address is not available. Check your DNS and host configuration.");
|
|
3970
4070
|
const o = r.address().family, e = r.address().port;
|
|
3971
4071
|
let n = r.address().address;
|
|
3972
4072
|
n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
|
|
3973
|
-
const
|
|
4073
|
+
const a = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
|
|
3974
4074
|
return `Project Tools - MCP Server Started
|
|
3975
4075
|
|
|
3976
4076
|
Server Name: ${t.name}
|
|
3977
4077
|
Server Version: ${t.version}
|
|
3978
|
-
Server URL: ${
|
|
3979
|
-
SSE Endpoint: ${
|
|
4078
|
+
Server URL: ${a}/mcp
|
|
4079
|
+
SSE Endpoint: ${a}/sse
|
|
3980
4080
|
|
|
3981
|
-
Log File: ${
|
|
4081
|
+
Log File: ${F.resolve(t.logFilePath)}`;
|
|
3982
4082
|
}
|
|
3983
|
-
function
|
|
3984
|
-
const s =
|
|
4083
|
+
function Ys(r, t) {
|
|
4084
|
+
const s = F.join(t.logDir, Lt()), o = Sr(r, {
|
|
3985
4085
|
logFilePath: s
|
|
3986
4086
|
});
|
|
3987
|
-
t.tools.processManager &&
|
|
4087
|
+
t.tools.processManager && br(o, t.tools.processManager), t.tools.fsManager && gs(o, t.tools.fsManager), t.tools.playwrightManager && Gs(o, {
|
|
3988
4088
|
...t.tools.playwrightManager
|
|
3989
4089
|
});
|
|
3990
4090
|
}
|
|
3991
|
-
async function
|
|
3992
|
-
const t =
|
|
4091
|
+
async function go(r) {
|
|
4092
|
+
const t = F.join(r.logDir, Lt()), s = js(), o = Ws({
|
|
3993
4093
|
...r,
|
|
3994
4094
|
logFilePath: t,
|
|
3995
4095
|
createMcpServer: () => {
|
|
3996
|
-
const n = new
|
|
4096
|
+
const n = new Pt({
|
|
3997
4097
|
title: r.title,
|
|
3998
4098
|
name: r.name,
|
|
3999
4099
|
version: r.version
|
|
4000
4100
|
});
|
|
4001
|
-
return
|
|
4101
|
+
return Ys(n, r), n;
|
|
4002
4102
|
}
|
|
4003
4103
|
});
|
|
4004
4104
|
s.use(o);
|
|
4005
|
-
const e = await
|
|
4105
|
+
const e = await Hs(s, {
|
|
4006
4106
|
host: r.host,
|
|
4007
4107
|
port: r.port,
|
|
4008
4108
|
logFilePath: t
|
|
4009
4109
|
});
|
|
4010
4110
|
return console.log(
|
|
4011
|
-
|
|
4111
|
+
Qs(e, {
|
|
4012
4112
|
title: r.title,
|
|
4013
4113
|
name: r.name,
|
|
4014
4114
|
version: r.version,
|
|
@@ -4017,10 +4117,10 @@ async function fo(r) {
|
|
|
4017
4117
|
), e;
|
|
4018
4118
|
}
|
|
4019
4119
|
export {
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4120
|
+
mo as A,
|
|
4121
|
+
po as S,
|
|
4122
|
+
ho as a,
|
|
4123
|
+
fo as b,
|
|
4124
|
+
Dr as p,
|
|
4125
|
+
go as s
|
|
4026
4126
|
};
|