@flemist/mcp-project-tools 3.0.15 → 3.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { McpServer as
|
|
3
|
-
import { randomUUID as
|
|
1
|
+
import ne from "express";
|
|
2
|
+
import { McpServer as Gt } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { randomUUID as Jt } from "crypto";
|
|
4
4
|
import * as W from "fs";
|
|
5
5
|
import * as R from "path";
|
|
6
|
-
import { StreamableHTTPServerTransport as
|
|
7
|
-
import { spawn as
|
|
6
|
+
import { StreamableHTTPServerTransport as jt } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
7
|
+
import { spawn as Kt } from "child_process";
|
|
8
8
|
import { z as p } from "zod";
|
|
9
|
-
import
|
|
10
|
-
import { Pool as
|
|
11
|
-
import { priorityCreate as
|
|
12
|
-
import { useAbortController as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { webkit as
|
|
16
|
-
function
|
|
9
|
+
import pe from "tree-kill";
|
|
10
|
+
import { Pool as Wt, poolRunWait as V } from "@flemist/time-limits";
|
|
11
|
+
import { priorityCreate as Z } from "@flemist/priority-queue";
|
|
12
|
+
import { useAbortController as Ht, combineAbortSignals as Qt, Locker as Yt } from "@flemist/async-utils";
|
|
13
|
+
import Vt from "node:os";
|
|
14
|
+
import Zt from "picomatch";
|
|
15
|
+
import { webkit as Xt, firefox as er, chromium as tr } from "playwright";
|
|
16
|
+
function rr(t) {
|
|
17
17
|
const { authToken: r } = t;
|
|
18
18
|
return function(o, e, n) {
|
|
19
19
|
if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== r) {
|
|
@@ -23,7 +23,7 @@ function tr(t) {
|
|
|
23
23
|
n();
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
async function
|
|
26
|
+
async function ie(t) {
|
|
27
27
|
const { logFilePath: r, message: s, data: o } = t;
|
|
28
28
|
try {
|
|
29
29
|
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), a = `[${e}] ${s}
|
|
@@ -35,21 +35,21 @@ ${n}
|
|
|
35
35
|
console.error(`Failed to log "${s}":`, e);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
function
|
|
38
|
+
const ae = /* @__PURE__ */ new Map();
|
|
39
|
+
function sr(t) {
|
|
40
40
|
return t.headers["mcp-session-id"] || t.headers["x-session-id"] || t.query.token;
|
|
41
41
|
}
|
|
42
|
-
async function
|
|
43
|
-
const s = t.createMcpServer(), o = new
|
|
44
|
-
sessionIdGenerator: () => r ||
|
|
42
|
+
async function or(t, r) {
|
|
43
|
+
const s = t.createMcpServer(), o = new jt({
|
|
44
|
+
sessionIdGenerator: () => r || Jt(),
|
|
45
45
|
onsessioninitialized: (n) => {
|
|
46
|
-
|
|
46
|
+
ae.set(n, o);
|
|
47
47
|
},
|
|
48
48
|
enableJsonResponse: !0
|
|
49
49
|
});
|
|
50
50
|
async function e() {
|
|
51
51
|
const n = o.sessionId;
|
|
52
|
-
n &&
|
|
52
|
+
n && ae.delete(n);
|
|
53
53
|
try {
|
|
54
54
|
await s.close();
|
|
55
55
|
} catch (a) {
|
|
@@ -63,28 +63,28 @@ async function sr(t, r) {
|
|
|
63
63
|
throw await e(), n;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
async function
|
|
67
|
-
await
|
|
66
|
+
async function nr(t, r, s, o) {
|
|
67
|
+
await ie({
|
|
68
68
|
logFilePath: s.logFilePath,
|
|
69
69
|
message: "REQUEST",
|
|
70
70
|
data: t.body
|
|
71
71
|
});
|
|
72
|
-
let e = o ?
|
|
73
|
-
e || (e = await
|
|
72
|
+
let e = o ? ae.get(o) : null;
|
|
73
|
+
e || (e = await or(s, o)), await e.handleRequest(t, r, t.body);
|
|
74
74
|
}
|
|
75
|
-
async function
|
|
76
|
-
const o = s ?
|
|
75
|
+
async function ir(t, r, s) {
|
|
76
|
+
const o = s ? ae.get(s) : null;
|
|
77
77
|
if (!o) {
|
|
78
78
|
r.status(400).json({ error: "No valid session found" });
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
await o.handleRequest(t, r);
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function ar(t) {
|
|
84
84
|
return async function(s, o) {
|
|
85
85
|
try {
|
|
86
|
-
const e =
|
|
87
|
-
s.method === "POST" ? await
|
|
86
|
+
const e = sr(s);
|
|
87
|
+
s.method === "POST" ? await nr(s, o, t, e) : s.method === "GET" ? await ir(s, o, e) : o.status(405).json({ error: "Method not allowed" });
|
|
88
88
|
} catch (e) {
|
|
89
89
|
console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
|
|
90
90
|
error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
|
|
@@ -92,10 +92,10 @@ function ir(t) {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
const
|
|
96
|
-
let
|
|
97
|
-
const
|
|
98
|
-
function
|
|
95
|
+
const Y = /* @__PURE__ */ new Map();
|
|
96
|
+
let lr = 0;
|
|
97
|
+
const Ce = 10, cr = 1800 * 1e3, J = 1e4, Q = 2e3, ur = 5e3;
|
|
98
|
+
function dr(t) {
|
|
99
99
|
const { commandLine: r, commandLineRules: s } = t;
|
|
100
100
|
let o = !1;
|
|
101
101
|
for (const e of s)
|
|
@@ -112,20 +112,20 @@ function ur(t) {
|
|
|
112
112
|
}
|
|
113
113
|
return o;
|
|
114
114
|
}
|
|
115
|
-
function dr() {
|
|
116
|
-
return ++ar;
|
|
117
|
-
}
|
|
118
|
-
let Ce = !1;
|
|
119
115
|
function fr() {
|
|
120
|
-
|
|
116
|
+
return ++lr;
|
|
117
|
+
}
|
|
118
|
+
let Ne = !1;
|
|
119
|
+
function hr() {
|
|
120
|
+
if (Ne)
|
|
121
121
|
return;
|
|
122
|
-
|
|
122
|
+
Ne = !0;
|
|
123
123
|
const t = () => {
|
|
124
124
|
console.log("Auto-killing all child processes...");
|
|
125
|
-
for (const [r, s] of Array.from(
|
|
125
|
+
for (const [r, s] of Array.from(Y.entries()))
|
|
126
126
|
if (s.isRunning && s.pid)
|
|
127
127
|
try {
|
|
128
|
-
|
|
128
|
+
pe(s.pid, "SIGKILL");
|
|
129
129
|
} catch (o) {
|
|
130
130
|
console.error(`Error killing process ${r}:`, o);
|
|
131
131
|
}
|
|
@@ -133,44 +133,44 @@ function fr() {
|
|
|
133
133
|
};
|
|
134
134
|
process.on("SIGINT", t), process.on("SIGTERM", t);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function ge() {
|
|
137
137
|
const t = Date.now(), r = [];
|
|
138
|
-
for (const [s, o] of Array.from(
|
|
139
|
-
!o.isRunning && o.endTime && t - o.endTime.getTime() >
|
|
138
|
+
for (const [s, o] of Array.from(Y.entries()))
|
|
139
|
+
!o.isRunning && o.endTime && t - o.endTime.getTime() > cr && r.push(s);
|
|
140
140
|
for (const s of r)
|
|
141
|
-
|
|
141
|
+
Y.delete(s);
|
|
142
142
|
}
|
|
143
|
-
const
|
|
144
|
-
let
|
|
145
|
-
function
|
|
146
|
-
return ++
|
|
143
|
+
const pr = 1800 * 1e3, ve = /* @__PURE__ */ new Map();
|
|
144
|
+
let mr = 0;
|
|
145
|
+
function gr() {
|
|
146
|
+
return ++mr;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
let r =
|
|
148
|
+
function Xe(t) {
|
|
149
|
+
let r = ve.get(t);
|
|
150
150
|
return r == null && (r = {
|
|
151
151
|
storedOutputs: /* @__PURE__ */ new Map()
|
|
152
|
-
},
|
|
152
|
+
}, ve.set(t, r)), r;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function et(t) {
|
|
155
155
|
return typeof t == "function" ? t() : t;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function tt(t, r) {
|
|
158
158
|
return setTimeout(() => {
|
|
159
159
|
t.storedOutputs.delete(r);
|
|
160
|
-
},
|
|
160
|
+
}, pr);
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
clearTimeout(s.cleanupTimer), s.cleanupTimer =
|
|
162
|
+
function wr(t, r, s) {
|
|
163
|
+
clearTimeout(s.cleanupTimer), s.cleanupTimer = tt(t, r);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
const { sessionId: r, source: s } = t, o =
|
|
165
|
+
function yr(t) {
|
|
166
|
+
const { sessionId: r, source: s } = t, o = Xe(r), e = gr(), n = {
|
|
167
167
|
source: s,
|
|
168
|
-
cleanupTimer:
|
|
168
|
+
cleanupTimer: tt(o, e)
|
|
169
169
|
};
|
|
170
170
|
return o.storedOutputs.set(e, n), e;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
const { sessionId: r, outputId: s, range: o } = t, [e, n] = o, a =
|
|
172
|
+
function rt(t) {
|
|
173
|
+
const { sessionId: r, outputId: s, range: o } = t, [e, n] = o, a = Xe(r), i = a.storedOutputs.get(s);
|
|
174
174
|
if (i == null)
|
|
175
175
|
return {
|
|
176
176
|
content: "",
|
|
@@ -178,15 +178,15 @@ function tt(t) {
|
|
|
178
178
|
range: [0, 0],
|
|
179
179
|
error: `Stored output with outputId=${s} not found or expired`
|
|
180
180
|
};
|
|
181
|
-
|
|
182
|
-
const c =
|
|
181
|
+
wr(a, s, i);
|
|
182
|
+
const c = et(i.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
|
|
183
183
|
return { content: c.substring(u, f), total: l, range: [u, f] };
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
const { sessionId: r, source: s, limit: o } = t, e =
|
|
185
|
+
function we(t) {
|
|
186
|
+
const { sessionId: r, source: s, limit: o } = t, e = et(s);
|
|
187
187
|
if (e.length <= o)
|
|
188
188
|
return { content: e, outputId: null };
|
|
189
|
-
const n =
|
|
189
|
+
const n = yr({ sessionId: r, source: s }), a = rt({
|
|
190
190
|
sessionId: r,
|
|
191
191
|
outputId: n,
|
|
192
192
|
range: [0, o]
|
|
@@ -202,16 +202,16 @@ function F(t) {
|
|
|
202
202
|
|
|
203
203
|
Provide valid parameters according to schema.`;
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const st = p.object({
|
|
206
206
|
outputId: p.number().int().describe("Output ID from truncation message"),
|
|
207
207
|
range: p.tuple([p.number().int().min(0), p.number().int().min(0)]).describe(
|
|
208
|
-
`Character range [from, to) to retrieve. Maximum range size: ${
|
|
208
|
+
`Character range [from, to) to retrieve. Maximum range size: ${J}.`
|
|
209
209
|
)
|
|
210
210
|
});
|
|
211
|
-
function
|
|
211
|
+
function br(t, r) {
|
|
212
212
|
let s;
|
|
213
213
|
try {
|
|
214
|
-
s =
|
|
214
|
+
s = st.parse(t);
|
|
215
215
|
} catch (a) {
|
|
216
216
|
return {
|
|
217
217
|
error: F(a)
|
|
@@ -226,27 +226,27 @@ function yr(t, r) {
|
|
|
226
226
|
return {
|
|
227
227
|
error: `Invalid range: to (${e}) must be greater than from (${o})`
|
|
228
228
|
};
|
|
229
|
-
if (e - o >
|
|
229
|
+
if (e - o > J)
|
|
230
230
|
return {
|
|
231
|
-
error: `Range size ${e - o} exceeds maximum ${
|
|
231
|
+
error: `Range size ${e - o} exceeds maximum ${J}`
|
|
232
232
|
};
|
|
233
|
-
const n =
|
|
233
|
+
const n = rt({
|
|
234
234
|
sessionId: r.sessionId,
|
|
235
235
|
outputId: s.outputId,
|
|
236
236
|
range: s.range
|
|
237
237
|
});
|
|
238
238
|
return n.error != null ? { error: n.error } : { content: n.content, total: n.total, range: n.range };
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Sr(t) {
|
|
241
241
|
t(
|
|
242
242
|
"output-read",
|
|
243
243
|
{
|
|
244
244
|
title: "Read Stored Output Range",
|
|
245
245
|
description: "Read any range from stored output. Use outputId from truncation message and specify character range [from, to).",
|
|
246
|
-
inputSchema:
|
|
246
|
+
inputSchema: st.shape
|
|
247
247
|
},
|
|
248
248
|
async (r, s) => {
|
|
249
|
-
const o =
|
|
249
|
+
const o = br(r, s);
|
|
250
250
|
if (o.error != null)
|
|
251
251
|
return `Method: output-read(${JSON.stringify(r)})
|
|
252
252
|
❌ Error: ${o.error}`;
|
|
@@ -260,28 +260,28 @@ ${o.content}`, i;
|
|
|
260
260
|
}
|
|
261
261
|
);
|
|
262
262
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
263
|
+
function xr(t) {
|
|
264
|
+
Sr(t);
|
|
265
265
|
}
|
|
266
|
-
const
|
|
266
|
+
const ot = p.object({
|
|
267
267
|
id: p.number().describe(
|
|
268
268
|
"Process ID to get detailed status information for. Get process IDs using process-list. Works for both running and completed processes. Examples: 1, 42, 123"
|
|
269
269
|
),
|
|
270
|
-
outputLimit: p.number().int().min(0).max(
|
|
271
|
-
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${
|
|
270
|
+
outputLimit: p.number().int().min(0).max(J).default(Q).describe(
|
|
271
|
+
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
272
272
|
)
|
|
273
273
|
});
|
|
274
|
-
async function
|
|
275
|
-
|
|
274
|
+
async function ye(t, r, s) {
|
|
275
|
+
ge();
|
|
276
276
|
let o;
|
|
277
277
|
try {
|
|
278
|
-
o =
|
|
278
|
+
o = ot.parse(t);
|
|
279
279
|
} catch (c) {
|
|
280
280
|
return {
|
|
281
281
|
error: F(c)
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
-
const { id: e, outputLimit: n } = o, a =
|
|
284
|
+
const { id: e, outputLimit: n } = o, a = Y.get(e);
|
|
285
285
|
if (!a)
|
|
286
286
|
return {
|
|
287
287
|
error: `Process ${e} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
@@ -290,7 +290,7 @@ async function we(t, r, s) {
|
|
|
290
290
|
return {
|
|
291
291
|
error: "Session ID is required"
|
|
292
292
|
};
|
|
293
|
-
const i =
|
|
293
|
+
const i = we({
|
|
294
294
|
sessionId: s.sessionId,
|
|
295
295
|
source: () => a.output,
|
|
296
296
|
limit: n
|
|
@@ -308,16 +308,16 @@ async function we(t, r, s) {
|
|
|
308
308
|
error: a.error
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function $r(t, r) {
|
|
312
312
|
t(
|
|
313
313
|
"process-status",
|
|
314
314
|
{
|
|
315
315
|
title: "Get Host Machine Process Status",
|
|
316
316
|
description: "Get detailed status information about a process on the host machine. Use this to check if commands completed successfully, get their output, or monitor running processes",
|
|
317
|
-
inputSchema:
|
|
317
|
+
inputSchema: ot.shape
|
|
318
318
|
},
|
|
319
319
|
async (s, o) => {
|
|
320
|
-
const e = await
|
|
320
|
+
const e = await ye(s, r, o);
|
|
321
321
|
if (!("output" in e))
|
|
322
322
|
return `Method: process-status(${JSON.stringify(s)})
|
|
323
323
|
❌ Error: ${e.error}`;
|
|
@@ -330,16 +330,16 @@ ${n.trim()}`;
|
|
|
330
330
|
}
|
|
331
331
|
);
|
|
332
332
|
}
|
|
333
|
-
function
|
|
334
|
-
|
|
333
|
+
function nt(t) {
|
|
334
|
+
pe(t, "SIGTERM", (r) => {
|
|
335
335
|
r && !r.message.includes("not found") && console.error(`Error sending SIGTERM to process ${t}:`, r);
|
|
336
336
|
}), setTimeout(() => {
|
|
337
|
-
|
|
337
|
+
pe(t, "SIGKILL", (r) => {
|
|
338
338
|
r && !r.message.includes("not found") && console.error(`Error sending SIGKILL to process ${t}:`, r);
|
|
339
339
|
});
|
|
340
|
-
},
|
|
340
|
+
}, ur);
|
|
341
341
|
}
|
|
342
|
-
const
|
|
342
|
+
const it = p.object({
|
|
343
343
|
id: p.number().describe(
|
|
344
344
|
"Process ID to wait for completion. Get process IDs using process-list. The process can be running or already completed. Examples: 1, 42, 123"
|
|
345
345
|
),
|
|
@@ -349,20 +349,20 @@ const nt = p.object({
|
|
|
349
349
|
autoKill: p.boolean().default(!1).describe(
|
|
350
350
|
"Automatically terminate the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running after timeout). Set to true for processes that should not run indefinitely"
|
|
351
351
|
),
|
|
352
|
-
outputLimit: p.number().int().min(0).max(
|
|
353
|
-
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${
|
|
352
|
+
outputLimit: p.number().int().min(0).max(J).default(Q).describe(
|
|
353
|
+
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
354
354
|
)
|
|
355
355
|
});
|
|
356
|
-
async function
|
|
356
|
+
async function at(t, r, s) {
|
|
357
357
|
let o;
|
|
358
358
|
try {
|
|
359
|
-
o =
|
|
359
|
+
o = it.parse(t);
|
|
360
360
|
} catch (g) {
|
|
361
361
|
return {
|
|
362
362
|
error: F(g)
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
|
-
const { id: e, waitTime: n, autoKill: a, outputLimit: i } = o, c =
|
|
365
|
+
const { id: e, waitTime: n, autoKill: a, outputLimit: i } = o, c = Y.get(e);
|
|
366
366
|
if (!c)
|
|
367
367
|
return {
|
|
368
368
|
error: `Process ${e} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
@@ -371,27 +371,27 @@ async function it(t, r, s) {
|
|
|
371
371
|
let u = !1, f = !1;
|
|
372
372
|
n != null && await new Promise((m) => {
|
|
373
373
|
const y = setInterval(() => {
|
|
374
|
-
c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, a && c.pid && (
|
|
374
|
+
c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, a && c.pid && (nt(c.pid), f = !0), m()) : (clearInterval(y), m());
|
|
375
375
|
}, 100);
|
|
376
376
|
});
|
|
377
377
|
const d = (Date.now() - l) / 1e3;
|
|
378
378
|
return {
|
|
379
|
-
...await
|
|
379
|
+
...await ye({ id: e, outputLimit: i }, r, s),
|
|
380
380
|
waitDuration: d,
|
|
381
381
|
waitTimeExceeded: u,
|
|
382
382
|
autoKillExecuted: f
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function Ir(t, r) {
|
|
386
386
|
t(
|
|
387
387
|
"process-wait",
|
|
388
388
|
{
|
|
389
389
|
title: "Wait for Host Machine Process",
|
|
390
390
|
description: "Wait for a host machine process to complete execution, with optional timeout and auto-kill functionality. Use this for long-running commands like builds, installs, or tests when you need final results",
|
|
391
|
-
inputSchema:
|
|
391
|
+
inputSchema: it.shape
|
|
392
392
|
},
|
|
393
393
|
async (s, o) => {
|
|
394
|
-
const e = await
|
|
394
|
+
const e = await at(s, r, o);
|
|
395
395
|
if (!("output" in e))
|
|
396
396
|
return `Method: process-wait(${JSON.stringify(s)})
|
|
397
397
|
❌ Error: ${e.error}`;
|
|
@@ -404,7 +404,7 @@ ${n.trim()}`;
|
|
|
404
404
|
}
|
|
405
405
|
);
|
|
406
406
|
}
|
|
407
|
-
const
|
|
407
|
+
const lt = p.object({
|
|
408
408
|
cwd: p.string().optional().describe(
|
|
409
409
|
'Working directory for command execution, resolved relative to the current working directory. Leave empty to use current directory. Examples: "src" (run in src/ subdirectory), "../parent" (run in parent directory), "build/output" (run in nested subdirectory). Directory must exist'
|
|
410
410
|
),
|
|
@@ -417,22 +417,22 @@ const at = p.object({
|
|
|
417
417
|
autoKill: p.boolean().default(!1).describe(
|
|
418
418
|
"Automatically kill the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running). Set to true for commands that should not run indefinitely"
|
|
419
419
|
),
|
|
420
|
-
outputLimit: p.number().int().min(0).max(
|
|
421
|
-
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${
|
|
420
|
+
outputLimit: p.number().int().min(0).max(J).default(Q).describe(
|
|
421
|
+
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
422
422
|
)
|
|
423
423
|
});
|
|
424
|
-
async function
|
|
425
|
-
|
|
424
|
+
async function Mr(t, r, s) {
|
|
425
|
+
ge();
|
|
426
426
|
let o;
|
|
427
427
|
try {
|
|
428
|
-
o =
|
|
428
|
+
o = lt.parse(t);
|
|
429
429
|
} catch (h) {
|
|
430
430
|
return {
|
|
431
431
|
error: F(h)
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
434
|
const { commandLine: e, waitTime: n, autoKill: a, outputLimit: i } = o, { commandLineRules: c } = r, l = R.resolve(r.workingDir || "", o.cwd || "");
|
|
435
|
-
if (!
|
|
435
|
+
if (!dr({ commandLine: e, commandLineRules: c })) {
|
|
436
436
|
const h = c.map(
|
|
437
437
|
(g) => `${g.rule.toUpperCase()}: /${g.regexp}/ (${g.note})`
|
|
438
438
|
).join(`
|
|
@@ -444,13 +444,13 @@ ${h}
|
|
|
444
444
|
To use this command line, ask the user to modify the command line rules in the configuration.`
|
|
445
445
|
};
|
|
446
446
|
}
|
|
447
|
-
if (Array.from(
|
|
447
|
+
if (Array.from(Y.values()).filter(
|
|
448
448
|
(h) => h.isRunning
|
|
449
|
-
).length >=
|
|
449
|
+
).length >= Ce)
|
|
450
450
|
return {
|
|
451
|
-
error: `Maximum concurrent process limit reached (${
|
|
451
|
+
error: `Maximum concurrent process limit reached (${Ce} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
|
|
452
452
|
};
|
|
453
|
-
const f =
|
|
453
|
+
const f = fr(), d = {
|
|
454
454
|
id: f,
|
|
455
455
|
cwd: l,
|
|
456
456
|
commandLine: e,
|
|
@@ -458,9 +458,9 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
458
458
|
isRunning: !0,
|
|
459
459
|
output: ""
|
|
460
460
|
};
|
|
461
|
-
|
|
461
|
+
Y.set(f, d);
|
|
462
462
|
try {
|
|
463
|
-
const h =
|
|
463
|
+
const h = Kt(e, [], {
|
|
464
464
|
shell: !0,
|
|
465
465
|
cwd: l,
|
|
466
466
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -474,16 +474,16 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
474
474
|
d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.exitCode = m !== null ? m : void 0, console.log(`Process ${f} (${e}) exited with code ${m}`);
|
|
475
475
|
}), h.on("error", (m) => {
|
|
476
476
|
d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = m.message, console.error(`Process ${f} error:`, m.message);
|
|
477
|
-
}), n != null ?
|
|
477
|
+
}), n != null ? at(
|
|
478
478
|
{ id: f, waitTime: n, autoKill: a, outputLimit: i },
|
|
479
479
|
r,
|
|
480
480
|
s
|
|
481
|
-
) :
|
|
481
|
+
) : ye({ id: f, outputLimit: i }, r, s);
|
|
482
482
|
} catch (h) {
|
|
483
483
|
return d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = h instanceof Error ? h.message : "Unknown error", { error: d.error };
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Tr(t, r) {
|
|
487
487
|
const s = r.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
|
|
488
488
|
`);
|
|
489
489
|
t(
|
|
@@ -492,10 +492,10 @@ function Mr(t, r) {
|
|
|
492
492
|
title: "Execute Command Line on Host Machine",
|
|
493
493
|
description: `Execute command lines on the host machine. Use this to build, test, lint, install packages, or run system commands. Prefer process-run with waitTime parameter if you need to immediately execute and wait for completion, instead of separate process-run and process-wait calls. Security: Command lines are validated against configured rules processed in order (later rules override earlier ones). Current command line rules:
|
|
494
494
|
${s}`,
|
|
495
|
-
inputSchema:
|
|
495
|
+
inputSchema: lt.shape
|
|
496
496
|
},
|
|
497
497
|
async (o, e) => {
|
|
498
|
-
const n = await
|
|
498
|
+
const n = await Mr(o, r, e);
|
|
499
499
|
if (!("output" in n))
|
|
500
500
|
return `Method: process-run(${JSON.stringify(o)})
|
|
501
501
|
❌ Error: ${n.error}`;
|
|
@@ -508,7 +508,7 @@ ${a.trim()}`;
|
|
|
508
508
|
}
|
|
509
509
|
);
|
|
510
510
|
}
|
|
511
|
-
const
|
|
511
|
+
const ct = p.object({
|
|
512
512
|
minOpenDateTime: p.string().optional().describe(
|
|
513
513
|
'Filter to processes started after this datetime. Accepts ISO format or space-separated format. Examples: "2024-01-15T10:30:00Z", "2024-01-15 10:30:00". Underscores and spaces are converted to standard ISO format internally'
|
|
514
514
|
),
|
|
@@ -522,18 +522,18 @@ const lt = p.object({
|
|
|
522
522
|
'Specific process data fields to include in the response. If omitted, returns all available fields. Fields id, isRunning, and commandLine are always included. Available fields: id, cwd, commandLine, pid, startTime, endTime, exitCode, isRunning, output, error. Examples: ["id", "commandLine", "isRunning"] for minimal info, ["id", "output", "exitCode"] for execution results'
|
|
523
523
|
)
|
|
524
524
|
});
|
|
525
|
-
async function
|
|
526
|
-
|
|
525
|
+
async function Cr(t, r) {
|
|
526
|
+
ge();
|
|
527
527
|
let s;
|
|
528
528
|
try {
|
|
529
|
-
s =
|
|
529
|
+
s = ct.parse(t);
|
|
530
530
|
} catch (l) {
|
|
531
531
|
return {
|
|
532
532
|
error: F(l)
|
|
533
533
|
};
|
|
534
534
|
}
|
|
535
535
|
const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: a } = s;
|
|
536
|
-
let i = Array.from(
|
|
536
|
+
let i = Array.from(Y.values());
|
|
537
537
|
if (o) {
|
|
538
538
|
const l = new Date(o.replace(/[_\s]/g, "T"));
|
|
539
539
|
i = i.filter((u) => u.startTime >= l);
|
|
@@ -565,16 +565,16 @@ async function Tr(t, r) {
|
|
|
565
565
|
return u;
|
|
566
566
|
}) };
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function Nr(t, r) {
|
|
569
569
|
t(
|
|
570
570
|
"process-list",
|
|
571
571
|
{
|
|
572
572
|
title: "List Host Machine Processes",
|
|
573
573
|
description: "List all processes that have been executed on the host machine. Use this to see running processes, check command history, or find process IDs for status/wait operations",
|
|
574
|
-
inputSchema:
|
|
574
|
+
inputSchema: ct.shape
|
|
575
575
|
},
|
|
576
576
|
async (s) => {
|
|
577
|
-
const o = await
|
|
577
|
+
const o = await Cr(s, r);
|
|
578
578
|
if (o.error != null)
|
|
579
579
|
return `Method: process-list(${JSON.stringify(s)})
|
|
580
580
|
❌ Error: ${o.error}`;
|
|
@@ -588,21 +588,21 @@ ${e}`;
|
|
|
588
588
|
}
|
|
589
589
|
);
|
|
590
590
|
}
|
|
591
|
-
const
|
|
591
|
+
const ut = p.object({
|
|
592
592
|
id: p.number().describe(
|
|
593
593
|
"Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
|
|
594
594
|
)
|
|
595
595
|
});
|
|
596
|
-
function
|
|
596
|
+
function vr(t) {
|
|
597
597
|
let r;
|
|
598
598
|
try {
|
|
599
|
-
r =
|
|
599
|
+
r = ut.parse(t);
|
|
600
600
|
} catch (e) {
|
|
601
601
|
return {
|
|
602
602
|
error: F(e)
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
|
-
const { id: s } = r, o =
|
|
605
|
+
const { id: s } = r, o = Y.get(s);
|
|
606
606
|
if (!o)
|
|
607
607
|
return {
|
|
608
608
|
error: `Process ${s} not found. The process may have already completed, been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
@@ -616,31 +616,31 @@ function Nr(t) {
|
|
|
616
616
|
error: `Process ${s} has no system process ID (PID). This indicates the process failed to start properly or the system was unable to assign a PID. Check process-status for error details.`
|
|
617
617
|
};
|
|
618
618
|
try {
|
|
619
|
-
return
|
|
619
|
+
return nt(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
|
|
620
620
|
} catch (e) {
|
|
621
621
|
return {
|
|
622
622
|
error: `Failed to terminate process ${s}: ${e instanceof Error ? e.message : "Unknown error"}. The process may have already exited, be protected by the system, or there may be insufficient permissions. Use process-status to check current process state.`
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function Er(t, r) {
|
|
627
627
|
t(
|
|
628
628
|
"process-kill",
|
|
629
629
|
{
|
|
630
630
|
title: "Kill Host Machine Process",
|
|
631
631
|
description: "Forcibly terminate a running process on the host machine. Use this to stop runaway processes, hung commands, or long-running tasks that need to be cancelled",
|
|
632
|
-
inputSchema:
|
|
632
|
+
inputSchema: ut.shape
|
|
633
633
|
},
|
|
634
634
|
async (s) => {
|
|
635
|
-
const o =
|
|
635
|
+
const o = vr(s);
|
|
636
636
|
return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
|
|
637
637
|
❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
|
|
638
638
|
${JSON.stringify(o, null, 2)}`;
|
|
639
639
|
}
|
|
640
640
|
);
|
|
641
641
|
}
|
|
642
|
-
function
|
|
643
|
-
|
|
642
|
+
function kr(t, r) {
|
|
643
|
+
hr(), r.run && Tr(t, r), r.status && $r(t, r), r.wait && Ir(t, r), r.list && Nr(t, r), r.kill && Er(t);
|
|
644
644
|
const s = r.commandLineRules?.map(
|
|
645
645
|
(o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
|
|
646
646
|
) || [];
|
|
@@ -653,16 +653,16 @@ ${s.map((o) => `- ${o}`).join(`
|
|
|
653
653
|
`
|
|
654
654
|
);
|
|
655
655
|
}
|
|
656
|
-
function
|
|
656
|
+
function Or(t, r) {
|
|
657
657
|
return function(o, e, n) {
|
|
658
658
|
const a = async (...i) => {
|
|
659
|
-
await
|
|
659
|
+
await ie({
|
|
660
660
|
logFilePath: r.logFilePath,
|
|
661
661
|
message: "REQUEST",
|
|
662
662
|
data: { name: o, args: i }
|
|
663
663
|
});
|
|
664
664
|
const c = await n(...i);
|
|
665
|
-
return await
|
|
665
|
+
return await ie({
|
|
666
666
|
logFilePath: r.logFilePath,
|
|
667
667
|
message: "RESPONSE",
|
|
668
668
|
data: c
|
|
@@ -682,26 +682,26 @@ function kr(t, r) {
|
|
|
682
682
|
);
|
|
683
683
|
};
|
|
684
684
|
}
|
|
685
|
-
function
|
|
685
|
+
function Dr(t) {
|
|
686
686
|
return t.match(/^[/\\]?[^/\\]+/)[0];
|
|
687
687
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
688
|
+
function Rr(t, r) {
|
|
689
|
+
return Dr(t) + "|" + r.ino;
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function Fr(t) {
|
|
692
692
|
return t.endsWith(":") && (t += "/"), R.resolve(t);
|
|
693
693
|
}
|
|
694
|
-
const
|
|
695
|
-
function
|
|
694
|
+
const be = new Wt(Vt.cpus().length);
|
|
695
|
+
function Ee(t, r) {
|
|
696
696
|
t.totalSize += r.totalSize, t.maxFileDateModified = Math.max(
|
|
697
697
|
t.maxFileDateModified,
|
|
698
698
|
r.maxFileDateModified
|
|
699
699
|
), t.countFiles += r.countFiles, t.countDirs += r.countDirs, t.countLinks += r.countLinks;
|
|
700
700
|
}
|
|
701
|
-
const
|
|
701
|
+
const Br = function(r) {
|
|
702
702
|
return r.code === "ENOENT";
|
|
703
703
|
};
|
|
704
|
-
function
|
|
704
|
+
function dt(t) {
|
|
705
705
|
const r = t.paths;
|
|
706
706
|
if (!r || r.length === 0)
|
|
707
707
|
return Promise.resolve({
|
|
@@ -711,16 +711,16 @@ function ut(t) {
|
|
|
711
711
|
countDirs: 0,
|
|
712
712
|
countLinks: 0
|
|
713
713
|
});
|
|
714
|
-
const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ??
|
|
714
|
+
const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? be, a = t.handleError, i = t.priority ?? Z(0), c = t.walkLinks ?? !1, l = t.log, u = t.handlePath, f = t.matchPath;
|
|
715
715
|
async function d(g) {
|
|
716
|
-
if (!(a && await a(g)) && !
|
|
716
|
+
if (!(a && await a(g)) && !Br(g))
|
|
717
717
|
throw g;
|
|
718
718
|
}
|
|
719
719
|
function h(g) {
|
|
720
720
|
return !(!l || l.minTotalContentSize != null && g < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
|
|
721
721
|
}
|
|
722
|
-
return
|
|
723
|
-
const m =
|
|
722
|
+
return Ht(async (g) => {
|
|
723
|
+
const m = Qt(e, g), y = {
|
|
724
724
|
totalSize: 0,
|
|
725
725
|
maxFileDateModified: 0,
|
|
726
726
|
countFiles: 0,
|
|
@@ -734,7 +734,7 @@ function ut(t) {
|
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
736
|
async function I($, S, x, T) {
|
|
737
|
-
return u ? await
|
|
737
|
+
return u ? await V({
|
|
738
738
|
pool: n,
|
|
739
739
|
func: async () => {
|
|
740
740
|
try {
|
|
@@ -757,19 +757,19 @@ function ut(t) {
|
|
|
757
757
|
}
|
|
758
758
|
async function v($, S, x, T) {
|
|
759
759
|
T || (T = $);
|
|
760
|
-
const N = await
|
|
760
|
+
const N = await V({
|
|
761
761
|
pool: n,
|
|
762
762
|
func: () => W.promises.lstat($).catch(d),
|
|
763
763
|
count: 1,
|
|
764
|
-
priority:
|
|
764
|
+
priority: Z(S, Z(1, i)),
|
|
765
765
|
abortSignal: m
|
|
766
766
|
});
|
|
767
767
|
if (!N || !x && N.isFile())
|
|
768
768
|
return null;
|
|
769
|
-
const
|
|
770
|
-
if (o.has(
|
|
769
|
+
const B = Rr($, N);
|
|
770
|
+
if (o.has(B))
|
|
771
771
|
return null;
|
|
772
|
-
o.add(
|
|
772
|
+
o.add(B);
|
|
773
773
|
let k = {
|
|
774
774
|
totalSize: N.size,
|
|
775
775
|
maxFileDateModified: N.isDirectory() ? 0 : N.mtimeMs,
|
|
@@ -777,13 +777,13 @@ function ut(t) {
|
|
|
777
777
|
countDirs: 0,
|
|
778
778
|
countLinks: 0
|
|
779
779
|
};
|
|
780
|
-
const M =
|
|
780
|
+
const M = Z(
|
|
781
781
|
S,
|
|
782
|
-
|
|
782
|
+
Z(N.isDirectory() ? 2 : 3, i)
|
|
783
783
|
);
|
|
784
784
|
if (N.isSymbolicLink()) {
|
|
785
785
|
if (c) {
|
|
786
|
-
const C = await
|
|
786
|
+
const C = await V({
|
|
787
787
|
pool: n,
|
|
788
788
|
func: () => W.promises.readlink($).catch(d).then((E) => E ?? null),
|
|
789
789
|
count: 1,
|
|
@@ -805,9 +805,9 @@ function ut(t) {
|
|
|
805
805
|
N,
|
|
806
806
|
k,
|
|
807
807
|
M
|
|
808
|
-
) && (
|
|
808
|
+
) && (Ee(y, k), w(T, k))), k;
|
|
809
809
|
} else if (N.isDirectory()) {
|
|
810
|
-
const C = await
|
|
810
|
+
const C = await V({
|
|
811
811
|
pool: n,
|
|
812
812
|
func: () => W.promises.readdir($).catch(d),
|
|
813
813
|
count: 1,
|
|
@@ -817,7 +817,7 @@ function ut(t) {
|
|
|
817
817
|
if (C) {
|
|
818
818
|
for (let E = 0, O = C.length; E < O; E++)
|
|
819
819
|
C[E] = R.join(T, C[E]);
|
|
820
|
-
k = await
|
|
820
|
+
k = await dt({
|
|
821
821
|
...t,
|
|
822
822
|
paths: C,
|
|
823
823
|
abortSignal: m,
|
|
@@ -832,23 +832,23 @@ function ut(t) {
|
|
|
832
832
|
N,
|
|
833
833
|
k,
|
|
834
834
|
M
|
|
835
|
-
) && (
|
|
835
|
+
) && (Ee(y, k), w(T, k))), k;
|
|
836
836
|
}
|
|
837
837
|
const b = [];
|
|
838
838
|
for (let $ = 0, S = r.length; $ < S; $++) {
|
|
839
|
-
const x =
|
|
839
|
+
const x = Fr(r[$]), T = f ? f(x) : !0;
|
|
840
840
|
T !== !1 && b.push(v(x, $, T));
|
|
841
841
|
}
|
|
842
842
|
return await Promise.all(b), y;
|
|
843
843
|
});
|
|
844
844
|
}
|
|
845
|
-
function
|
|
846
|
-
return
|
|
845
|
+
function ft(t) {
|
|
846
|
+
return dt(t);
|
|
847
847
|
}
|
|
848
848
|
function H(t) {
|
|
849
849
|
return t.replace(/\\/g, "/");
|
|
850
850
|
}
|
|
851
|
-
function
|
|
851
|
+
function Lr(t, r) {
|
|
852
852
|
if (!r || r === ".")
|
|
853
853
|
return t;
|
|
854
854
|
const s = t.startsWith("^");
|
|
@@ -856,43 +856,43 @@ function Br(t, r) {
|
|
|
856
856
|
const o = t.startsWith("!");
|
|
857
857
|
return o && (t = t.substring(1)), t.startsWith("/") ? (r.endsWith("/") && (r = r.substring(0, r.length - 1)), t = r + t) : (r.endsWith("/") || (r += "/"), t.startsWith("./") ? t = r + t.substring(2) : t.startsWith("../") ? t = r + t : (r.startsWith("..") && (r = ""), t.startsWith("**") ? t = r + t : t = r + "**/" + t)), t = H(R.normalize(t)), o && (t = "!" + t), s && (t = "^" + t), t;
|
|
858
858
|
}
|
|
859
|
-
function
|
|
859
|
+
function Pr(t) {
|
|
860
860
|
const r = t.startsWith("!");
|
|
861
861
|
return r && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), r && (t = "!" + t), t;
|
|
862
862
|
}
|
|
863
|
-
function
|
|
863
|
+
function ke(t) {
|
|
864
864
|
return "^" + t;
|
|
865
865
|
}
|
|
866
|
-
async function
|
|
866
|
+
async function Ar(t) {
|
|
867
867
|
const s = (await W.promises.readFile(t, "utf-8")).split(`
|
|
868
868
|
`), o = [];
|
|
869
869
|
return s.forEach((e) => {
|
|
870
870
|
e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
|
|
871
871
|
}), o;
|
|
872
872
|
}
|
|
873
|
-
async function
|
|
873
|
+
async function ht(t) {
|
|
874
874
|
const r = t.rootDir ?? ".", s = [];
|
|
875
875
|
if (!t.globs?.length)
|
|
876
876
|
return s;
|
|
877
877
|
const o = [];
|
|
878
878
|
return t.globs.forEach((e) => {
|
|
879
|
-
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ?
|
|
879
|
+
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? ke(e.value) : e.value));
|
|
880
880
|
}), o.length && await Promise.all(
|
|
881
881
|
o.map(async (e) => {
|
|
882
|
-
await
|
|
883
|
-
pool:
|
|
882
|
+
await V({
|
|
883
|
+
pool: be,
|
|
884
884
|
count: 1,
|
|
885
885
|
func: async () => {
|
|
886
|
-
const n = R.resolve(r, e.value), a = await
|
|
886
|
+
const n = R.resolve(r, e.value), a = await Ar(n), i = R.relative(r, R.dirname(n));
|
|
887
887
|
a.forEach((c) => {
|
|
888
|
-
c =
|
|
888
|
+
c = Pr(c), c = Lr(c, i), s.push(e.exclude ? ke(c) : c);
|
|
889
889
|
});
|
|
890
890
|
}
|
|
891
891
|
});
|
|
892
892
|
})
|
|
893
893
|
), s;
|
|
894
894
|
}
|
|
895
|
-
function
|
|
895
|
+
function pt({
|
|
896
896
|
globs: t,
|
|
897
897
|
rootDir: r,
|
|
898
898
|
noCase: s
|
|
@@ -913,7 +913,7 @@ function ht({
|
|
|
913
913
|
return;
|
|
914
914
|
let c;
|
|
915
915
|
try {
|
|
916
|
-
c =
|
|
916
|
+
c = Zt(i, {
|
|
917
917
|
nocase: s ?? !1,
|
|
918
918
|
dot: !0,
|
|
919
919
|
strictBrackets: !0
|
|
@@ -940,17 +940,17 @@ function ht({
|
|
|
940
940
|
return i ? !1 : a;
|
|
941
941
|
};
|
|
942
942
|
}
|
|
943
|
-
async function
|
|
943
|
+
async function zr(t) {
|
|
944
944
|
const r = t.rootDir ?? ".", s = [], o = {};
|
|
945
945
|
t.result.countFiles && (o.countFiles = 0), t.result.size && (o.size = 0);
|
|
946
|
-
const e = await
|
|
946
|
+
const e = await ht({
|
|
947
947
|
rootDir: r,
|
|
948
948
|
globs: t.globs
|
|
949
949
|
});
|
|
950
|
-
return await
|
|
950
|
+
return await ft({
|
|
951
951
|
paths: [r],
|
|
952
952
|
walkLinks: !0,
|
|
953
|
-
matchPath:
|
|
953
|
+
matchPath: pt({
|
|
954
954
|
globs: e,
|
|
955
955
|
rootDir: r,
|
|
956
956
|
noCase: !0
|
|
@@ -977,21 +977,21 @@ async function Ar(t) {
|
|
|
977
977
|
}
|
|
978
978
|
}), { items: s, totals: o };
|
|
979
979
|
}
|
|
980
|
-
const
|
|
981
|
-
function
|
|
980
|
+
const Oe = ["B", "KB", "MB", "GB", "TB"], De = 1024;
|
|
981
|
+
function Re(t) {
|
|
982
982
|
if (t == null) return "-";
|
|
983
983
|
let r = t ?? 0, s = 0;
|
|
984
|
-
for (; r >=
|
|
985
|
-
r /=
|
|
986
|
-
return `${s === 0 ? r.toString() : r.toFixed(2)}${
|
|
984
|
+
for (; r >= De && s < Oe.length - 1; )
|
|
985
|
+
r /= De, s++;
|
|
986
|
+
return `${s === 0 ? r.toString() : r.toFixed(2)}${Oe[s]}`;
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Fe(t) {
|
|
989
989
|
const s = Date.now() - t;
|
|
990
990
|
if (s < 0) return "0s";
|
|
991
991
|
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);
|
|
992
992
|
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`;
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function Ur(t, r) {
|
|
995
995
|
return r?.length ? [...t].sort((s, o) => {
|
|
996
996
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
997
997
|
const a = r[e];
|
|
@@ -1027,8 +1027,8 @@ function zr(t, r) {
|
|
|
1027
1027
|
return 0;
|
|
1028
1028
|
}) : t;
|
|
1029
1029
|
}
|
|
1030
|
-
function
|
|
1031
|
-
const s =
|
|
1030
|
+
function qr(t, r) {
|
|
1031
|
+
const s = Ur(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
|
|
1032
1032
|
let e = "";
|
|
1033
1033
|
if (s.length > 0 && o.length > 0) {
|
|
1034
1034
|
for (let n = 0, a = o.length; n < a; n++) {
|
|
@@ -1059,10 +1059,10 @@ function Ur(t, r) {
|
|
|
1059
1059
|
const u = o[c];
|
|
1060
1060
|
switch (c > 0 && (e += " | "), u) {
|
|
1061
1061
|
case "dateModified":
|
|
1062
|
-
e += i.dateModified ?
|
|
1062
|
+
e += i.dateModified ? Fe(i.dateModified) : "-";
|
|
1063
1063
|
break;
|
|
1064
1064
|
case "size":
|
|
1065
|
-
e +=
|
|
1065
|
+
e += Re(i.size);
|
|
1066
1066
|
break;
|
|
1067
1067
|
case "type":
|
|
1068
1068
|
e += i.type;
|
|
@@ -1081,15 +1081,15 @@ function Ur(t, r) {
|
|
|
1081
1081
|
e.length > 0 && (e += `
|
|
1082
1082
|
---
|
|
1083
1083
|
`);
|
|
1084
|
-
const n =
|
|
1084
|
+
const n = Re(t.totals.size ?? 0), a = t.totals.dateModified ? `, last modified ${Fe(t.totals.dateModified)} ago` : "";
|
|
1085
1085
|
e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${a}`;
|
|
1086
1086
|
}
|
|
1087
1087
|
return e;
|
|
1088
1088
|
}
|
|
1089
|
-
const
|
|
1090
|
-
version:
|
|
1091
|
-
},
|
|
1092
|
-
function
|
|
1089
|
+
const _r = "3.0.16", Gr = {
|
|
1090
|
+
version: _r
|
|
1091
|
+
}, $o = "Project Tools", Io = "project-tools", Mo = Gr.version, To = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Be = 25e3;
|
|
1092
|
+
function Le(t) {
|
|
1093
1093
|
const r = t.match(
|
|
1094
1094
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
1095
1095
|
);
|
|
@@ -1120,7 +1120,7 @@ function Be(t) {
|
|
|
1120
1120
|
);
|
|
1121
1121
|
}
|
|
1122
1122
|
}
|
|
1123
|
-
function
|
|
1123
|
+
function Pe(t) {
|
|
1124
1124
|
const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
1125
1125
|
if (!r)
|
|
1126
1126
|
throw new Error(
|
|
@@ -1144,7 +1144,7 @@ function Le(t) {
|
|
|
1144
1144
|
);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
const
|
|
1147
|
+
const mt = p.object({
|
|
1148
1148
|
rootDir: p.string().optional().describe(
|
|
1149
1149
|
'Root directory to list files from, resolved relative to the current working directory. Leave empty to use current directory. Examples: "src" (list src/ subdirectory), "../parent" (list parent directory), "docs/api" (list nested subdirectory). Path must exist and be accessible'
|
|
1150
1150
|
),
|
|
@@ -1183,10 +1183,10 @@ const pt = p.object({
|
|
|
1183
1183
|
'Filter files/directories with total size at most this large. Only items with size <= this value will be included. For directories, uses total size of all contents. Format: number + unit (B/KB/MB/GB/TB). Examples: "1MB" (up to 1 megabyte), "500KB" (up to 500 kilobytes), "10GB" (up to 10 gigabytes). Combine with minTotalSize for size ranges'
|
|
1184
1184
|
)
|
|
1185
1185
|
});
|
|
1186
|
-
async function
|
|
1186
|
+
async function Jr(t, r) {
|
|
1187
1187
|
let s;
|
|
1188
1188
|
try {
|
|
1189
|
-
s =
|
|
1189
|
+
s = mt.parse(t);
|
|
1190
1190
|
} catch (m) {
|
|
1191
1191
|
return {
|
|
1192
1192
|
error: F(m)
|
|
@@ -1244,7 +1244,7 @@ async function Gr(t, r) {
|
|
|
1244
1244
|
let v = null, b = null;
|
|
1245
1245
|
if (i || c)
|
|
1246
1246
|
try {
|
|
1247
|
-
const x = Date.now(), T = c ? x -
|
|
1247
|
+
const x = Date.now(), T = c ? x - Le(c) : null, N = i ? x - Le(i) : null;
|
|
1248
1248
|
v = [T, N];
|
|
1249
1249
|
} catch (x) {
|
|
1250
1250
|
return {
|
|
@@ -1253,24 +1253,24 @@ async function Gr(t, r) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
if (l || u)
|
|
1255
1255
|
try {
|
|
1256
|
-
const x = l ?
|
|
1256
|
+
const x = l ? Pe(l) : null, T = u ? Pe(u) : null;
|
|
1257
1257
|
b = [x, T];
|
|
1258
1258
|
} catch (x) {
|
|
1259
1259
|
return {
|
|
1260
1260
|
error: x instanceof Error ? x.message : "Unknown error parsing size filter"
|
|
1261
1261
|
};
|
|
1262
1262
|
}
|
|
1263
|
-
const $ = await
|
|
1263
|
+
const $ = await zr({
|
|
1264
1264
|
rootDir: g || null,
|
|
1265
1265
|
globs: w,
|
|
1266
1266
|
result: I,
|
|
1267
1267
|
dateModified: v,
|
|
1268
1268
|
totalSize: b
|
|
1269
1269
|
});
|
|
1270
|
-
return $.items.length >
|
|
1271
|
-
error: `Number of paths (${$.items.length}) exceeds maximum allowed (${
|
|
1270
|
+
return $.items.length > Be ? {
|
|
1271
|
+
error: `Number of paths (${$.items.length}) exceeds maximum allowed (${Be}). Consider using more specific glob patterns or filters to reduce the result set.`
|
|
1272
1272
|
} : {
|
|
1273
|
-
output:
|
|
1273
|
+
output: qr($, {
|
|
1274
1274
|
sort: d,
|
|
1275
1275
|
fields: f,
|
|
1276
1276
|
totals: !0
|
|
@@ -1280,30 +1280,30 @@ async function Gr(t, r) {
|
|
|
1280
1280
|
return { error: m instanceof Error ? m.message : "Unknown error" };
|
|
1281
1281
|
}
|
|
1282
1282
|
}
|
|
1283
|
-
function
|
|
1283
|
+
function jr(t, r) {
|
|
1284
1284
|
t(
|
|
1285
1285
|
"fs-list",
|
|
1286
1286
|
{
|
|
1287
1287
|
title: "List Files and Directories",
|
|
1288
1288
|
description: "List files and directories with advanced filtering, sorting and formatting options. Use this to analyze filesystem structure",
|
|
1289
|
-
inputSchema:
|
|
1289
|
+
inputSchema: mt.shape
|
|
1290
1290
|
},
|
|
1291
1291
|
async (s) => {
|
|
1292
|
-
const o = await
|
|
1292
|
+
const o = await Jr(s, r);
|
|
1293
1293
|
return o.error ? `Method: fs-list(${JSON.stringify(s)})
|
|
1294
1294
|
❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
|
|
1295
1295
|
${o.output || JSON.stringify(o, null, 2)}`;
|
|
1296
1296
|
}
|
|
1297
1297
|
);
|
|
1298
1298
|
}
|
|
1299
|
-
const
|
|
1300
|
-
function
|
|
1301
|
-
return
|
|
1299
|
+
const ue = /* @__PURE__ */ new Map();
|
|
1300
|
+
function X(t) {
|
|
1301
|
+
return ue.has(t) || ue.set(t, {
|
|
1302
1302
|
fsSnapshotQueries: /* @__PURE__ */ new Map(),
|
|
1303
1303
|
fsSnapshots: /* @__PURE__ */ new Map()
|
|
1304
|
-
}),
|
|
1304
|
+
}), ue.get(t);
|
|
1305
1305
|
}
|
|
1306
|
-
function
|
|
1306
|
+
function Ae(t) {
|
|
1307
1307
|
const r = t.match(
|
|
1308
1308
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
1309
1309
|
);
|
|
@@ -1334,7 +1334,7 @@ function Pe(t) {
|
|
|
1334
1334
|
);
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
|
-
function
|
|
1337
|
+
function ze(t) {
|
|
1338
1338
|
const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
1339
1339
|
if (!r)
|
|
1340
1340
|
throw new Error(
|
|
@@ -1358,7 +1358,7 @@ function Ae(t) {
|
|
|
1358
1358
|
);
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
|
-
const
|
|
1361
|
+
const Se = p.object({
|
|
1362
1362
|
name: p.string().describe(
|
|
1363
1363
|
"Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1364
1364
|
),
|
|
@@ -1386,7 +1386,7 @@ const be = p.object({
|
|
|
1386
1386
|
maxTotalSize: p.string().optional().describe(
|
|
1387
1387
|
'Filter files/directories with total size at most this large. Only items with size <= this value will be included. For directories, uses total size of all contents. Format: number + unit (B/KB/MB/GB/TB). Examples: "1MB" (up to 1 megabyte), "500KB" (up to 500 kilobytes), "10GB" (up to 10 gigabytes). Combine with minTotalSize for size ranges'
|
|
1388
1388
|
)
|
|
1389
|
-
}),
|
|
1389
|
+
}), Ue = new Map(
|
|
1390
1390
|
[
|
|
1391
1391
|
"name",
|
|
1392
1392
|
"type",
|
|
@@ -1395,14 +1395,14 @@ const be = p.object({
|
|
|
1395
1395
|
"dateModified"
|
|
1396
1396
|
].map((t, r) => [t, r])
|
|
1397
1397
|
);
|
|
1398
|
-
function
|
|
1399
|
-
const s =
|
|
1398
|
+
function Kr(t, r) {
|
|
1399
|
+
const s = Ue.get(t) ?? 1 / 0, o = Ue.get(r) ?? 1 / 0;
|
|
1400
1400
|
return s > o ? 1 : s < o ? -1 : 0;
|
|
1401
1401
|
}
|
|
1402
|
-
async function
|
|
1402
|
+
async function gt(t, r, s) {
|
|
1403
1403
|
let o;
|
|
1404
1404
|
try {
|
|
1405
|
-
o =
|
|
1405
|
+
o = Se.parse(t);
|
|
1406
1406
|
} catch (h) {
|
|
1407
1407
|
return {
|
|
1408
1408
|
error: F(h)
|
|
@@ -1421,7 +1421,7 @@ async function mt(t, r, s) {
|
|
|
1421
1421
|
return {
|
|
1422
1422
|
error: "Session ID is required"
|
|
1423
1423
|
};
|
|
1424
|
-
const f =
|
|
1424
|
+
const f = X(s.sessionId), d = H(
|
|
1425
1425
|
R.resolve(r.workingDir || "", o.rootDir || "")
|
|
1426
1426
|
);
|
|
1427
1427
|
try {
|
|
@@ -1435,7 +1435,7 @@ async function mt(t, r, s) {
|
|
|
1435
1435
|
throw S;
|
|
1436
1436
|
}
|
|
1437
1437
|
const h = o.extraFields ? o.extraFields.map((S) => S === "lastModified" ? "dateModified" : S) : [];
|
|
1438
|
-
h.includes("name") || h.push("name"), h.sort(
|
|
1438
|
+
h.includes("name") || h.push("name"), h.sort(Kr);
|
|
1439
1439
|
const g = n && n.length > 0 ? n.map((S) => ({
|
|
1440
1440
|
value: S,
|
|
1441
1441
|
valueType: "pattern",
|
|
@@ -1444,7 +1444,7 @@ async function mt(t, r, s) {
|
|
|
1444
1444
|
let w = null, I = null;
|
|
1445
1445
|
if (i || c)
|
|
1446
1446
|
try {
|
|
1447
|
-
const S = Date.now(), x = c ? S -
|
|
1447
|
+
const S = Date.now(), x = c ? S - Ae(c) : null, T = i ? S - Ae(i) : null;
|
|
1448
1448
|
w = [x, T];
|
|
1449
1449
|
} catch (S) {
|
|
1450
1450
|
return {
|
|
@@ -1453,7 +1453,7 @@ async function mt(t, r, s) {
|
|
|
1453
1453
|
}
|
|
1454
1454
|
if (l || u)
|
|
1455
1455
|
try {
|
|
1456
|
-
const S = l ?
|
|
1456
|
+
const S = l ? ze(l) : null, x = u ? ze(u) : null;
|
|
1457
1457
|
I = [S, x];
|
|
1458
1458
|
} catch (S) {
|
|
1459
1459
|
return {
|
|
@@ -1479,23 +1479,23 @@ async function mt(t, r, s) {
|
|
|
1479
1479
|
};
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
1482
|
-
function
|
|
1482
|
+
function Wr(t, r) {
|
|
1483
1483
|
t(
|
|
1484
1484
|
"fs-snapshot-query-create",
|
|
1485
1485
|
{
|
|
1486
1486
|
title: "Create Filesystem Snapshot Query",
|
|
1487
1487
|
description: "Create a filesystem snapshot query. Prefer fs-snapshot-browse if you need to immediately create a query, snapshot and browse it",
|
|
1488
|
-
inputSchema:
|
|
1488
|
+
inputSchema: Se.shape
|
|
1489
1489
|
},
|
|
1490
1490
|
async (s, o) => {
|
|
1491
|
-
const e = await
|
|
1491
|
+
const e = await gt(s, r, o);
|
|
1492
1492
|
return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1493
1493
|
❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1494
1494
|
✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
1495
1495
|
}
|
|
1496
1496
|
);
|
|
1497
1497
|
}
|
|
1498
|
-
function
|
|
1498
|
+
function le(t) {
|
|
1499
1499
|
const { idToNode: r, idToChildIds: s } = t, o = r.get(null);
|
|
1500
1500
|
if (o == null)
|
|
1501
1501
|
throw new Error(
|
|
@@ -1535,16 +1535,16 @@ function ae(t) {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
};
|
|
1537
1537
|
}
|
|
1538
|
-
function
|
|
1538
|
+
function wt(t, r, s) {
|
|
1539
1539
|
let o = null;
|
|
1540
1540
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
1541
|
-
const a = r[e], i = t(a), c = i == null ? null :
|
|
1541
|
+
const a = r[e], i = t(a), c = i == null ? null : wt(t, i, s), l = s(a, c);
|
|
1542
1542
|
l != null && (o == null && (o = []), o.push(l));
|
|
1543
1543
|
}
|
|
1544
1544
|
return o;
|
|
1545
1545
|
}
|
|
1546
|
-
function
|
|
1547
|
-
const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c =
|
|
1546
|
+
function yt(t) {
|
|
1547
|
+
const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = wt(
|
|
1548
1548
|
s,
|
|
1549
1549
|
o,
|
|
1550
1550
|
(u, f) => {
|
|
@@ -1569,10 +1569,10 @@ function wt(t) {
|
|
|
1569
1569
|
idToChildIds: i
|
|
1570
1570
|
};
|
|
1571
1571
|
}
|
|
1572
|
-
function
|
|
1572
|
+
function me(t) {
|
|
1573
1573
|
return t = t != null ? H(t).replace(/\/$/, "") : null, !t || t === "." ? null : t;
|
|
1574
1574
|
}
|
|
1575
|
-
async function
|
|
1575
|
+
async function Hr(t) {
|
|
1576
1576
|
const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = R.resolve(t.rootDir || "."), n = {
|
|
1577
1577
|
path: ".",
|
|
1578
1578
|
name: R.basename(o),
|
|
@@ -1582,14 +1582,14 @@ async function Wr(t) {
|
|
|
1582
1582
|
size: 0
|
|
1583
1583
|
};
|
|
1584
1584
|
r.set(null, n);
|
|
1585
|
-
const a = await
|
|
1585
|
+
const a = await ht({
|
|
1586
1586
|
rootDir: o,
|
|
1587
1587
|
globs: t.globs
|
|
1588
1588
|
});
|
|
1589
|
-
return await
|
|
1589
|
+
return await ft({
|
|
1590
1590
|
paths: [o],
|
|
1591
1591
|
walkLinks: !0,
|
|
1592
|
-
matchPath:
|
|
1592
|
+
matchPath: pt({
|
|
1593
1593
|
globs: a,
|
|
1594
1594
|
rootDir: o,
|
|
1595
1595
|
noCase: !0
|
|
@@ -1598,7 +1598,7 @@ async function Wr(t) {
|
|
|
1598
1598
|
const u = R.relative(o, i), f = c.isDirectory(), d = c.isFile();
|
|
1599
1599
|
if (!f && !d)
|
|
1600
1600
|
return !0;
|
|
1601
|
-
const h =
|
|
1601
|
+
const h = me(u || "."), g = f ? "dir" : "file", m = f ? null : c.mtimeMs, y = c.size;
|
|
1602
1602
|
let w = !0;
|
|
1603
1603
|
if (d && !t.matchFiles && (w = !1), f && !t.matchDirs && (w = !1), w && d && t.dateModified && m != null) {
|
|
1604
1604
|
const [$, S] = t.dateModified;
|
|
@@ -1623,7 +1623,7 @@ async function Wr(t) {
|
|
|
1623
1623
|
if (h == null)
|
|
1624
1624
|
return n.dateModified = m, n.size = y, n.isMatched = w, !0;
|
|
1625
1625
|
r.set(h, I);
|
|
1626
|
-
const v =
|
|
1626
|
+
const v = me(H(R.dirname(h)));
|
|
1627
1627
|
let b = s.get(v);
|
|
1628
1628
|
return b || (b = [], s.set(v, b)), b.push(h), !0;
|
|
1629
1629
|
}
|
|
@@ -1632,7 +1632,7 @@ async function Wr(t) {
|
|
|
1632
1632
|
idToChildIds: s
|
|
1633
1633
|
};
|
|
1634
1634
|
}
|
|
1635
|
-
const
|
|
1635
|
+
const Qr = [
|
|
1636
1636
|
{ name: "[ ]", match: (t) => t === 32, min: 2, max: 81 },
|
|
1637
1637
|
{ name: "[\\t]", match: (t) => t === 9, min: 2, max: 20 },
|
|
1638
1638
|
{ name: "[\\n]", match: (t) => t === 10, min: 2, max: 14 },
|
|
@@ -1655,7 +1655,7 @@ const Hr = [
|
|
|
1655
1655
|
// max: 2,
|
|
1656
1656
|
// },
|
|
1657
1657
|
];
|
|
1658
|
-
function
|
|
1658
|
+
function qe(t, r = Qr) {
|
|
1659
1659
|
const s = t.length;
|
|
1660
1660
|
if (s === 0) return 0;
|
|
1661
1661
|
const o = r.length;
|
|
@@ -1681,25 +1681,25 @@ function Ue(t, r = Hr) {
|
|
|
1681
1681
|
}
|
|
1682
1682
|
return e;
|
|
1683
1683
|
}
|
|
1684
|
-
function
|
|
1684
|
+
function bt(t) {
|
|
1685
1685
|
let r = 0;
|
|
1686
|
-
return r +=
|
|
1686
|
+
return r += qe(t.textOpen) + 1, t.textClose != null && (r += qe(t.textClose) + 1), t.indent && (r += 1), r;
|
|
1687
1687
|
}
|
|
1688
|
-
const
|
|
1689
|
-
function
|
|
1688
|
+
const _e = ["B", "KB", "MB", "GB", "TB"], Ge = 1024;
|
|
1689
|
+
function Yr(t) {
|
|
1690
1690
|
if (t == null) return "-";
|
|
1691
1691
|
let r = t ?? 0, s = 0;
|
|
1692
|
-
for (; r >=
|
|
1693
|
-
r /=
|
|
1694
|
-
return `${s === 0 ? r.toString() : r.toFixed(2)}${
|
|
1692
|
+
for (; r >= Ge && s < _e.length - 1; )
|
|
1693
|
+
r /= Ge, s++;
|
|
1694
|
+
return `${s === 0 ? r.toString() : r.toFixed(2)}${_e[s]}`;
|
|
1695
1695
|
}
|
|
1696
|
-
function
|
|
1696
|
+
function Vr(t) {
|
|
1697
1697
|
const s = Date.now() - t;
|
|
1698
1698
|
if (s < 0) return "0s";
|
|
1699
1699
|
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);
|
|
1700
1700
|
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`;
|
|
1701
1701
|
}
|
|
1702
|
-
function
|
|
1702
|
+
function Zr(t) {
|
|
1703
1703
|
return function(s, o) {
|
|
1704
1704
|
const e = t.get(s), n = t.get(o);
|
|
1705
1705
|
if (e.type !== n.type)
|
|
@@ -1712,7 +1712,7 @@ function Vr(t) {
|
|
|
1712
1712
|
}
|
|
1713
1713
|
};
|
|
1714
1714
|
}
|
|
1715
|
-
function
|
|
1715
|
+
function Xr(t) {
|
|
1716
1716
|
const r = t.fields ?? [];
|
|
1717
1717
|
return function(o, e) {
|
|
1718
1718
|
let n = "", a, i = 0;
|
|
@@ -1728,10 +1728,10 @@ function Zr(t) {
|
|
|
1728
1728
|
const S = r[b];
|
|
1729
1729
|
switch (b > 0 && (n += " "), S) {
|
|
1730
1730
|
case "dateModified":
|
|
1731
|
-
n += m ?
|
|
1731
|
+
n += m ? Vr(m) : "-";
|
|
1732
1732
|
break;
|
|
1733
1733
|
case "size":
|
|
1734
|
-
n +=
|
|
1734
|
+
n += Yr(h);
|
|
1735
1735
|
break;
|
|
1736
1736
|
case "type":
|
|
1737
1737
|
n += y;
|
|
@@ -1749,7 +1749,7 @@ function Zr(t) {
|
|
|
1749
1749
|
textOpen: n,
|
|
1750
1750
|
textClose: null
|
|
1751
1751
|
};
|
|
1752
|
-
return u =
|
|
1752
|
+
return u = bt(v), d += u, {
|
|
1753
1753
|
type: y,
|
|
1754
1754
|
name: w,
|
|
1755
1755
|
path: I,
|
|
@@ -1767,8 +1767,8 @@ function Zr(t) {
|
|
|
1767
1767
|
};
|
|
1768
1768
|
};
|
|
1769
1769
|
}
|
|
1770
|
-
async function
|
|
1771
|
-
const r = await
|
|
1770
|
+
async function es(t) {
|
|
1771
|
+
const r = await Hr(t), s = le(r), o = s.getChilds(s.root), e = yt({
|
|
1772
1772
|
getId: (a) => {
|
|
1773
1773
|
const i = s.getId(a);
|
|
1774
1774
|
if (i == null)
|
|
@@ -1778,26 +1778,26 @@ async function Xr(t) {
|
|
|
1778
1778
|
return i;
|
|
1779
1779
|
},
|
|
1780
1780
|
getChilds: (a) => s.getChilds(a),
|
|
1781
|
-
createSnapshotNode:
|
|
1781
|
+
createSnapshotNode: Xr(t),
|
|
1782
1782
|
rootNodes: o ?? []
|
|
1783
|
-
}), n =
|
|
1783
|
+
}), n = Zr(e.idToNode);
|
|
1784
1784
|
return e.idToChildIds.forEach((a) => {
|
|
1785
1785
|
a.sort(n);
|
|
1786
|
-
}),
|
|
1786
|
+
}), le(e);
|
|
1787
1787
|
}
|
|
1788
|
-
const
|
|
1788
|
+
const ee = p.object({
|
|
1789
1789
|
queryName: p.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
|
|
1790
|
-
query:
|
|
1790
|
+
query: Se.optional().describe(
|
|
1791
1791
|
"Filesystem snapshot query creation options JSON to automatically create query"
|
|
1792
1792
|
),
|
|
1793
1793
|
name: p.string().describe(
|
|
1794
1794
|
"Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1795
1795
|
)
|
|
1796
1796
|
});
|
|
1797
|
-
async function
|
|
1797
|
+
async function ce(t, r, s) {
|
|
1798
1798
|
let o;
|
|
1799
1799
|
try {
|
|
1800
|
-
o =
|
|
1800
|
+
o = ee.parse(t);
|
|
1801
1801
|
} catch (u) {
|
|
1802
1802
|
return {
|
|
1803
1803
|
error: F(u)
|
|
@@ -1808,7 +1808,7 @@ async function le(t, r, s) {
|
|
|
1808
1808
|
return {
|
|
1809
1809
|
error: "Session ID is required"
|
|
1810
1810
|
};
|
|
1811
|
-
const i =
|
|
1811
|
+
const i = X(s.sessionId);
|
|
1812
1812
|
if (n && a)
|
|
1813
1813
|
return {
|
|
1814
1814
|
error: "Either queryName or query must be provided, not both"
|
|
@@ -1822,7 +1822,7 @@ async function le(t, r, s) {
|
|
|
1822
1822
|
};
|
|
1823
1823
|
c = u;
|
|
1824
1824
|
} else if (a) {
|
|
1825
|
-
const u = await
|
|
1825
|
+
const u = await gt(
|
|
1826
1826
|
a,
|
|
1827
1827
|
r,
|
|
1828
1828
|
s
|
|
@@ -1837,7 +1837,7 @@ async function le(t, r, s) {
|
|
|
1837
1837
|
error: "Either queryName or query must be provided"
|
|
1838
1838
|
};
|
|
1839
1839
|
try {
|
|
1840
|
-
const u = await
|
|
1840
|
+
const u = await es(c), f = {
|
|
1841
1841
|
name: e,
|
|
1842
1842
|
query: c,
|
|
1843
1843
|
tree: u
|
|
@@ -1852,16 +1852,16 @@ async function le(t, r, s) {
|
|
|
1852
1852
|
};
|
|
1853
1853
|
}
|
|
1854
1854
|
}
|
|
1855
|
-
function
|
|
1855
|
+
function ts(t, r) {
|
|
1856
1856
|
t(
|
|
1857
1857
|
"fs-snapshot-create",
|
|
1858
1858
|
{
|
|
1859
1859
|
title: "Create Filesystem Snapshot",
|
|
1860
1860
|
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",
|
|
1861
|
-
inputSchema:
|
|
1861
|
+
inputSchema: ee.shape
|
|
1862
1862
|
},
|
|
1863
1863
|
async (s, o) => {
|
|
1864
|
-
const e = await
|
|
1864
|
+
const e = await ce(s, r, o);
|
|
1865
1865
|
if (e.error != null)
|
|
1866
1866
|
return `Method: fs-snapshot-create(${JSON.stringify(s)})
|
|
1867
1867
|
❌ Error: ${e.error}`;
|
|
@@ -1872,7 +1872,7 @@ function es(t, r) {
|
|
|
1872
1872
|
}
|
|
1873
1873
|
);
|
|
1874
1874
|
}
|
|
1875
|
-
class
|
|
1875
|
+
class rs {
|
|
1876
1876
|
_first = null;
|
|
1877
1877
|
_last = null;
|
|
1878
1878
|
_size = 0;
|
|
@@ -1895,8 +1895,8 @@ class ts {
|
|
|
1895
1895
|
return this._size;
|
|
1896
1896
|
}
|
|
1897
1897
|
}
|
|
1898
|
-
function
|
|
1899
|
-
const r = new
|
|
1898
|
+
function ss(t) {
|
|
1899
|
+
const r = new rs(), {
|
|
1900
1900
|
tree: s,
|
|
1901
1901
|
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: a },
|
|
1902
1902
|
indexRangeGroupStrategy: i
|
|
@@ -1964,7 +1964,7 @@ function rs(t) {
|
|
|
1964
1964
|
}
|
|
1965
1965
|
return l ?? [];
|
|
1966
1966
|
}
|
|
1967
|
-
function
|
|
1967
|
+
function St(t) {
|
|
1968
1968
|
const {
|
|
1969
1969
|
tree: r,
|
|
1970
1970
|
request: { parentNodeId: s, childsIndexRange: o, limits: e },
|
|
@@ -2008,14 +2008,14 @@ function bt(t) {
|
|
|
2008
2008
|
root: u,
|
|
2009
2009
|
getChilds: (d) => d === u ? [c] : d === c ? l : r.getChilds(d)
|
|
2010
2010
|
};
|
|
2011
|
-
return
|
|
2011
|
+
return ss({
|
|
2012
2012
|
tree: f,
|
|
2013
2013
|
limits: e,
|
|
2014
2014
|
indexRangeGroupStrategy: n,
|
|
2015
2015
|
...a
|
|
2016
2016
|
});
|
|
2017
2017
|
}
|
|
2018
|
-
function
|
|
2018
|
+
function xt(t, r) {
|
|
2019
2019
|
if (t == null || t.length === 0)
|
|
2020
2020
|
return "No results found";
|
|
2021
2021
|
let s = "";
|
|
@@ -2032,7 +2032,7 @@ function St(t, r) {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
return o(t, ""), s;
|
|
2034
2034
|
}
|
|
2035
|
-
class
|
|
2035
|
+
class os {
|
|
2036
2036
|
tokens = 16;
|
|
2037
2037
|
// +1 indent, +1 for line break
|
|
2038
2038
|
getReportText = (r) => ({
|
|
@@ -2047,9 +2047,9 @@ class ss {
|
|
|
2047
2047
|
tokensGrouped: s.tokens
|
|
2048
2048
|
} : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
|
|
2049
2049
|
}
|
|
2050
|
-
const
|
|
2050
|
+
const $t = p.object({
|
|
2051
2051
|
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2052
|
-
snapshot:
|
|
2052
|
+
snapshot: ee.optional().describe(
|
|
2053
2053
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2054
2054
|
),
|
|
2055
2055
|
parentPath: p.string().optional().describe(
|
|
@@ -2069,10 +2069,10 @@ const xt = p.object({
|
|
|
2069
2069
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
2070
2070
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
2071
2071
|
});
|
|
2072
|
-
async function
|
|
2072
|
+
async function ns(t, r, s) {
|
|
2073
2073
|
let o;
|
|
2074
2074
|
try {
|
|
2075
|
-
o =
|
|
2075
|
+
o = $t.parse(t);
|
|
2076
2076
|
} catch (m) {
|
|
2077
2077
|
return {
|
|
2078
2078
|
error: F(m)
|
|
@@ -2091,7 +2091,7 @@ async function os(t, r, s) {
|
|
|
2091
2091
|
return {
|
|
2092
2092
|
error: "Session ID is required"
|
|
2093
2093
|
};
|
|
2094
|
-
const f =
|
|
2094
|
+
const f = X(s.sessionId);
|
|
2095
2095
|
if (e && n)
|
|
2096
2096
|
return {
|
|
2097
2097
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
@@ -2103,7 +2103,7 @@ async function os(t, r, s) {
|
|
|
2103
2103
|
error: `Filesystem snapshot "${e}" not found`
|
|
2104
2104
|
};
|
|
2105
2105
|
} else if (n) {
|
|
2106
|
-
const m = await
|
|
2106
|
+
const m = await ce(
|
|
2107
2107
|
n,
|
|
2108
2108
|
r,
|
|
2109
2109
|
s
|
|
@@ -2118,7 +2118,7 @@ async function os(t, r, s) {
|
|
|
2118
2118
|
error: "Either snapshotName or snapshot must be provided"
|
|
2119
2119
|
};
|
|
2120
2120
|
try {
|
|
2121
|
-
const m =
|
|
2121
|
+
const m = me(o.parentPath), y = St({
|
|
2122
2122
|
tree: d.tree,
|
|
2123
2123
|
request: {
|
|
2124
2124
|
parentNodeId: m,
|
|
@@ -2130,8 +2130,8 @@ async function os(t, r, s) {
|
|
|
2130
2130
|
maxTokensGroup: u
|
|
2131
2131
|
}
|
|
2132
2132
|
},
|
|
2133
|
-
indexRangeGroupStrategy: new
|
|
2134
|
-
}), w =
|
|
2133
|
+
indexRangeGroupStrategy: new os()
|
|
2134
|
+
}), w = xt(y);
|
|
2135
2135
|
return {
|
|
2136
2136
|
fsSnapshot: d,
|
|
2137
2137
|
queryCreated: h,
|
|
@@ -2146,16 +2146,16 @@ async function os(t, r, s) {
|
|
|
2146
2146
|
};
|
|
2147
2147
|
}
|
|
2148
2148
|
}
|
|
2149
|
-
function
|
|
2149
|
+
function is(t, r) {
|
|
2150
2150
|
t(
|
|
2151
2151
|
"fs-snapshot-browse",
|
|
2152
2152
|
{
|
|
2153
2153
|
title: "Browse Filesystem Snapshot",
|
|
2154
2154
|
description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
|
|
2155
|
-
inputSchema:
|
|
2155
|
+
inputSchema: $t.shape
|
|
2156
2156
|
},
|
|
2157
2157
|
async (s, o) => {
|
|
2158
|
-
const e = await
|
|
2158
|
+
const e = await ns(s, r, o);
|
|
2159
2159
|
if (e.error != null)
|
|
2160
2160
|
return `Method: fs-snapshot-browse(${JSON.stringify(s)})
|
|
2161
2161
|
❌ Error: ${e.error}`;
|
|
@@ -2177,7 +2177,7 @@ ${e.report}`, n;
|
|
|
2177
2177
|
}
|
|
2178
2178
|
);
|
|
2179
2179
|
}
|
|
2180
|
-
function
|
|
2180
|
+
function It(t) {
|
|
2181
2181
|
const r = [], s = t.tree, o = t.query.rootDir ?? ".";
|
|
2182
2182
|
function e(n) {
|
|
2183
2183
|
n.type === "file" && n.isMatched && r.push(o + "/" + n.path);
|
|
@@ -2188,34 +2188,34 @@ function $t(t) {
|
|
|
2188
2188
|
}
|
|
2189
2189
|
return e(s.root), r;
|
|
2190
2190
|
}
|
|
2191
|
-
const
|
|
2192
|
-
function
|
|
2191
|
+
const Je = /* @__PURE__ */ new Map();
|
|
2192
|
+
function as(t) {
|
|
2193
2193
|
const r = H(t);
|
|
2194
|
-
let s =
|
|
2195
|
-
return s == null && (s = new
|
|
2194
|
+
let s = Je.get(r);
|
|
2195
|
+
return s == null && (s = new Yt(), Je.set(r, s)), s;
|
|
2196
2196
|
}
|
|
2197
|
-
async function
|
|
2197
|
+
async function ls(t) {
|
|
2198
2198
|
const { filePath: r, func: s } = t;
|
|
2199
|
-
return
|
|
2200
|
-
() =>
|
|
2201
|
-
pool:
|
|
2199
|
+
return as(r).lock(
|
|
2200
|
+
() => V({
|
|
2201
|
+
pool: be,
|
|
2202
2202
|
count: 1,
|
|
2203
2203
|
func: s
|
|
2204
2204
|
})
|
|
2205
2205
|
);
|
|
2206
2206
|
}
|
|
2207
|
-
const
|
|
2208
|
-
function
|
|
2207
|
+
const je = 10, re = 48, Ke = 57, de = 36, cs = 38, us = 39, ds = 60, fs = 62, hs = 96, se = 0, We = 1, He = 2, Qe = 3, Ye = 4, ps = 5;
|
|
2208
|
+
function ms(t) {
|
|
2209
2209
|
const { content: r, pattern: s, replacement: o } = t, e = r.length, n = [0];
|
|
2210
2210
|
for (let b = 0; b < e; b++)
|
|
2211
|
-
r.charCodeAt(b) ===
|
|
2211
|
+
r.charCodeAt(b) === je && b + 1 < e && n.push(b + 1);
|
|
2212
2212
|
const a = n.length, i = [], c = [];
|
|
2213
2213
|
let l = null, u = null, f = null, d = 0;
|
|
2214
2214
|
if (o != null) {
|
|
2215
2215
|
const b = o.length;
|
|
2216
2216
|
let $ = !1;
|
|
2217
2217
|
for (let S = 0; S < b; S++)
|
|
2218
|
-
if (o.charCodeAt(S) ===
|
|
2218
|
+
if (o.charCodeAt(S) === de) {
|
|
2219
2219
|
$ = !0;
|
|
2220
2220
|
break;
|
|
2221
2221
|
}
|
|
@@ -2223,37 +2223,37 @@ function ps(t) {
|
|
|
2223
2223
|
u = [], f = [];
|
|
2224
2224
|
let S = 0, x = 0;
|
|
2225
2225
|
for (; x < b; ) {
|
|
2226
|
-
if (o.charCodeAt(x) !==
|
|
2226
|
+
if (o.charCodeAt(x) !== de || x + 1 >= b) {
|
|
2227
2227
|
x++;
|
|
2228
2228
|
continue;
|
|
2229
2229
|
}
|
|
2230
2230
|
const T = o.charCodeAt(x + 1);
|
|
2231
|
-
let N = -1,
|
|
2232
|
-
if (T ===
|
|
2233
|
-
N =
|
|
2234
|
-
else if (T === ls)
|
|
2235
|
-
N = Ke;
|
|
2236
|
-
else if (T === fs)
|
|
2237
|
-
N = We;
|
|
2231
|
+
let N = -1, B = 0, k = 2;
|
|
2232
|
+
if (T === de)
|
|
2233
|
+
N = se, B = "$";
|
|
2238
2234
|
else if (T === cs)
|
|
2235
|
+
N = We;
|
|
2236
|
+
else if (T === hs)
|
|
2239
2237
|
N = He;
|
|
2240
|
-
else if (T
|
|
2238
|
+
else if (T === us)
|
|
2239
|
+
N = Qe;
|
|
2240
|
+
else if (T >= re && T <= Ke) {
|
|
2241
2241
|
let M = x + 2;
|
|
2242
2242
|
for (; M < b; ) {
|
|
2243
2243
|
const C = o.charCodeAt(M);
|
|
2244
|
-
if (C <
|
|
2244
|
+
if (C < re || C > Ke) break;
|
|
2245
2245
|
M++;
|
|
2246
2246
|
}
|
|
2247
|
-
N =
|
|
2248
|
-
} else if (T ===
|
|
2247
|
+
N = Ye, B = o.substring(x + 1, M), k = M - x;
|
|
2248
|
+
} else if (T === ds) {
|
|
2249
2249
|
let M = x + 2;
|
|
2250
|
-
for (; M < b && o.charCodeAt(M) !==
|
|
2250
|
+
for (; M < b && o.charCodeAt(M) !== fs; )
|
|
2251
2251
|
M++;
|
|
2252
|
-
M < b && M > x + 2 && (N =
|
|
2252
|
+
M < b && M > x + 2 && (N = ps, B = o.substring(x + 2, M), k = M + 1 - x);
|
|
2253
2253
|
}
|
|
2254
|
-
N >= 0 ? (x > S && (u.push(
|
|
2254
|
+
N >= 0 ? (x > S && (u.push(se), f.push(o.substring(S, x))), u.push(N), f.push(B), x += k, S = x) : x++;
|
|
2255
2255
|
}
|
|
2256
|
-
S < b && (u.push(
|
|
2256
|
+
S < b && (u.push(se), f.push(o.substring(S))), d = u.length;
|
|
2257
2257
|
} else
|
|
2258
2258
|
l = o;
|
|
2259
2259
|
}
|
|
@@ -2262,9 +2262,9 @@ function ps(t) {
|
|
|
2262
2262
|
let y;
|
|
2263
2263
|
for (; (y = s.exec(r)) !== null; ) {
|
|
2264
2264
|
const b = y.index, $ = y[0], S = $.length, x = b + S;
|
|
2265
|
-
let T, N,
|
|
2265
|
+
let T, N, B, k;
|
|
2266
2266
|
if (a === 1)
|
|
2267
|
-
T = 0, N = 1,
|
|
2267
|
+
T = 0, N = 1, B = 0, k = e;
|
|
2268
2268
|
else {
|
|
2269
2269
|
let M = 0, C = a - 1;
|
|
2270
2270
|
for (; M < C; ) {
|
|
@@ -2280,12 +2280,12 @@ function ps(t) {
|
|
|
2280
2280
|
N = M + 1;
|
|
2281
2281
|
} else
|
|
2282
2282
|
N = T + 1;
|
|
2283
|
-
|
|
2283
|
+
B = n[T], k = N < a ? n[N] : e;
|
|
2284
2284
|
}
|
|
2285
2285
|
if (i.push({
|
|
2286
2286
|
offset: [b, x],
|
|
2287
2287
|
lines: [T, N],
|
|
2288
|
-
linesOffset: [
|
|
2288
|
+
linesOffset: [B, k]
|
|
2289
2289
|
}), o != null) {
|
|
2290
2290
|
h += r.substring(g, b);
|
|
2291
2291
|
let M;
|
|
@@ -2295,34 +2295,34 @@ function ps(t) {
|
|
|
2295
2295
|
M = "";
|
|
2296
2296
|
const E = y.groups, O = y.length - 1;
|
|
2297
2297
|
for (let K = 0; K < d; K++) {
|
|
2298
|
-
const
|
|
2299
|
-
switch (
|
|
2300
|
-
case
|
|
2301
|
-
M +=
|
|
2298
|
+
const q = u[K], P = f[K];
|
|
2299
|
+
switch (q) {
|
|
2300
|
+
case se:
|
|
2301
|
+
M += P;
|
|
2302
2302
|
break;
|
|
2303
|
-
case
|
|
2303
|
+
case We:
|
|
2304
2304
|
M += $;
|
|
2305
2305
|
break;
|
|
2306
|
-
case
|
|
2306
|
+
case He:
|
|
2307
2307
|
M += r.substring(0, b);
|
|
2308
2308
|
break;
|
|
2309
|
-
case
|
|
2309
|
+
case Qe:
|
|
2310
2310
|
M += r.substring(x);
|
|
2311
2311
|
break;
|
|
2312
|
-
case
|
|
2313
|
-
const
|
|
2314
|
-
if (
|
|
2315
|
-
const
|
|
2312
|
+
case Ye: {
|
|
2313
|
+
const L = P, z = L.length, A = L.charCodeAt(0) - re;
|
|
2314
|
+
if (z >= 2) {
|
|
2315
|
+
const _ = L.charCodeAt(1) - re, D = A * 10 + _;
|
|
2316
2316
|
if (D >= 1 && D <= O) {
|
|
2317
|
-
M += y[D] ?? "",
|
|
2317
|
+
M += y[D] ?? "", z > 2 && (M += L.substring(2));
|
|
2318
2318
|
break;
|
|
2319
2319
|
}
|
|
2320
2320
|
}
|
|
2321
|
-
|
|
2321
|
+
A >= 1 && A <= O ? (M += y[A] ?? "", z > 1 && (M += L.substring(1))) : M += "$" + L;
|
|
2322
2322
|
break;
|
|
2323
2323
|
}
|
|
2324
2324
|
default:
|
|
2325
|
-
E != null ? M += E[
|
|
2325
|
+
E != null ? M += E[P] ?? "" : M += "$<" + P + ">";
|
|
2326
2326
|
}
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
@@ -2342,13 +2342,13 @@ function ps(t) {
|
|
|
2342
2342
|
h += r.substring(g);
|
|
2343
2343
|
const w = h.length, I = [0];
|
|
2344
2344
|
for (let b = 0; b < w; b++)
|
|
2345
|
-
h.charCodeAt(b) ===
|
|
2345
|
+
h.charCodeAt(b) === je && b + 1 < w && I.push(b + 1);
|
|
2346
2346
|
const v = I.length;
|
|
2347
2347
|
for (let b = 0, $ = c.length; b < $; b++) {
|
|
2348
2348
|
const S = c[b], x = S.offset[0], T = S.offset[1];
|
|
2349
|
-
let N,
|
|
2349
|
+
let N, B, k, M;
|
|
2350
2350
|
if (v === 1)
|
|
2351
|
-
N = 0,
|
|
2351
|
+
N = 0, B = 1, k = 0, M = w;
|
|
2352
2352
|
else {
|
|
2353
2353
|
let C = 0, E = v - 1;
|
|
2354
2354
|
for (; C < E; ) {
|
|
@@ -2361,19 +2361,19 @@ function ps(t) {
|
|
|
2361
2361
|
const K = C + E + 1 >> 1;
|
|
2362
2362
|
I[K] <= O ? C = K : E = K - 1;
|
|
2363
2363
|
}
|
|
2364
|
-
|
|
2364
|
+
B = C + 1;
|
|
2365
2365
|
} else
|
|
2366
|
-
|
|
2367
|
-
k = I[N], M =
|
|
2366
|
+
B = N + 1;
|
|
2367
|
+
k = I[N], M = B < v ? I[B] : w;
|
|
2368
2368
|
}
|
|
2369
|
-
S.lines[0] = N, S.lines[1] =
|
|
2369
|
+
S.lines[0] = N, S.lines[1] = B, S.linesOffset[0] = k, S.linesOffset[1] = M;
|
|
2370
2370
|
}
|
|
2371
2371
|
return {
|
|
2372
2372
|
search: { content: r, matches: i },
|
|
2373
2373
|
replace: { content: h, matches: c }
|
|
2374
2374
|
};
|
|
2375
2375
|
}
|
|
2376
|
-
function
|
|
2376
|
+
function Mt(t) {
|
|
2377
2377
|
if (t.length === 0)
|
|
2378
2378
|
return [];
|
|
2379
2379
|
const r = [...t].sort((a, i) => {
|
|
@@ -2398,7 +2398,7 @@ function It(t) {
|
|
|
2398
2398
|
linesOffset: n
|
|
2399
2399
|
}), s;
|
|
2400
2400
|
}
|
|
2401
|
-
function
|
|
2401
|
+
function oe(t, r, s, o) {
|
|
2402
2402
|
let e = 0, n = 0;
|
|
2403
2403
|
for (let u = 0; u < s; u++)
|
|
2404
2404
|
t.charCodeAt(u) === 10 && (n = u + 1, e++);
|
|
@@ -2412,69 +2412,69 @@ function se(t, r, s, o) {
|
|
|
2412
2412
|
return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: c + 1 };
|
|
2413
2413
|
return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: r };
|
|
2414
2414
|
}
|
|
2415
|
-
function
|
|
2415
|
+
function gs(t, r) {
|
|
2416
2416
|
if (t.replace == null && r.replace == null) {
|
|
2417
|
-
const
|
|
2417
|
+
const U = [...t.search.matches, ...r.search.matches];
|
|
2418
2418
|
return {
|
|
2419
|
-
search: { content: t.search.content, matches:
|
|
2419
|
+
search: { content: t.search.content, matches: Mt(U) },
|
|
2420
2420
|
replace: null
|
|
2421
2421
|
};
|
|
2422
2422
|
}
|
|
2423
2423
|
const s = t.replace ?? t.search, o = r.replace ?? r.search, e = t.search.content, n = o.content, a = e.length, i = n.length, c = t.search.matches, l = s.matches, u = r.search.matches, f = o.matches, d = l.length, h = u.length, g = [], m = [];
|
|
2424
|
-
let y = 0, w = 0, I = 0, v = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, N = 0,
|
|
2424
|
+
let y = 0, w = 0, I = 0, v = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, N = 0, B = 0, k = 0, M = 0, C = 0, E = 0, O = 0, K = 0, q = 0, P = 0, L = 0, z = 0, A = 0, _ = 0, D = 0;
|
|
2425
2425
|
for (; y < d || w < h; )
|
|
2426
2426
|
if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < h && (S = u[w].offset[0], x = u[w].offset[1]), y < d && w < h && b < x && S < $) {
|
|
2427
|
-
K = b < S ? b : S, T = $ > x ? $ : x,
|
|
2427
|
+
K = b < S ? b : S, T = $ > x ? $ : x, B = y, k = w, y++, w++;
|
|
2428
2428
|
do {
|
|
2429
2429
|
for (N = T; y < d && l[y].offset[0] < T; )
|
|
2430
2430
|
$ = l[y].offset[1], $ > T && (T = $), y++;
|
|
2431
2431
|
for (; w < h && u[w].offset[0] < T; )
|
|
2432
2432
|
x = u[w].offset[1], x > T && (T = x), w++;
|
|
2433
2433
|
} while (T !== N);
|
|
2434
|
-
M = 1 / 0, C = -1 / 0,
|
|
2435
|
-
for (let
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
for (let
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
const
|
|
2434
|
+
M = 1 / 0, C = -1 / 0, q = K, P = I;
|
|
2435
|
+
for (let G = B; G < y; G++)
|
|
2436
|
+
L = c[G].offset[0], z = c[G].offset[1], A = l[G].offset[0], _ = l[G].offset[1], q < A && (D = q + P, D < M && (M = D), D = A + P, D > C && (C = D)), L < M && (M = L), z > C && (C = z), P += z - L - _ + A, q = _;
|
|
2437
|
+
q < T && (D = q + P, D < M && (M = D), D = T + P, D > C && (C = D)), I = P, E = 1 / 0, O = -1 / 0, q = K, P = v;
|
|
2438
|
+
for (let G = k; G < w; G++)
|
|
2439
|
+
L = u[G].offset[0], z = u[G].offset[1], A = f[G].offset[0], _ = f[G].offset[1], q < L && (D = q + P, D < E && (E = D), D = L + P, D > O && (O = D)), A < E && (E = A), _ > O && (O = _), P += _ - A - z + L, q = z;
|
|
2440
|
+
q < T && (D = q + P, D < E && (E = D), D = T + P, D > O && (O = D)), v = P;
|
|
2441
|
+
const U = oe(e, a, M, C);
|
|
2442
2442
|
g.push({
|
|
2443
2443
|
offset: [M, C],
|
|
2444
|
-
lines: [
|
|
2445
|
-
linesOffset: [
|
|
2444
|
+
lines: [U.startLine, U.endLine],
|
|
2445
|
+
linesOffset: [U.startLineOfs, U.endLineOfs]
|
|
2446
2446
|
});
|
|
2447
|
-
const
|
|
2447
|
+
const te = oe(n, i, E, O);
|
|
2448
2448
|
m.push({
|
|
2449
2449
|
offset: [E, O],
|
|
2450
|
-
lines: [
|
|
2451
|
-
linesOffset: [
|
|
2450
|
+
lines: [te.startLine, te.endLine],
|
|
2451
|
+
linesOffset: [te.startLineOfs, te.endLineOfs]
|
|
2452
2452
|
});
|
|
2453
2453
|
} else if (w >= h || y < d && b <= S) {
|
|
2454
|
-
|
|
2455
|
-
const
|
|
2454
|
+
L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], _ = l[y].offset[1], E = A + v, O = _ + v;
|
|
2455
|
+
const U = oe(n, i, E, O);
|
|
2456
2456
|
g.push(c[y]), m.push({
|
|
2457
2457
|
offset: [E, O],
|
|
2458
|
-
lines: [
|
|
2459
|
-
linesOffset: [
|
|
2460
|
-
}), I +=
|
|
2458
|
+
lines: [U.startLine, U.endLine],
|
|
2459
|
+
linesOffset: [U.startLineOfs, U.endLineOfs]
|
|
2460
|
+
}), I += z - L - _ + A, y++;
|
|
2461
2461
|
} else {
|
|
2462
|
-
|
|
2463
|
-
const
|
|
2462
|
+
L = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], _ = f[w].offset[1], M = L + I, C = z + I;
|
|
2463
|
+
const U = oe(e, a, M, C);
|
|
2464
2464
|
g.push({
|
|
2465
2465
|
offset: [M, C],
|
|
2466
|
-
lines: [
|
|
2467
|
-
linesOffset: [
|
|
2468
|
-
}), m.push(f[w]), v +=
|
|
2466
|
+
lines: [U.startLine, U.endLine],
|
|
2467
|
+
linesOffset: [U.startLineOfs, U.endLineOfs]
|
|
2468
|
+
}), m.push(f[w]), v += _ - A - z + L, w++;
|
|
2469
2469
|
}
|
|
2470
2470
|
return {
|
|
2471
2471
|
search: { content: e, matches: g },
|
|
2472
2472
|
replace: { content: n, matches: m }
|
|
2473
2473
|
};
|
|
2474
2474
|
}
|
|
2475
|
-
async function
|
|
2475
|
+
async function ws(t) {
|
|
2476
2476
|
const { filePath: r, operations: s, dryRun: o } = t;
|
|
2477
|
-
return s.length === 0 ? { filePath: r, result: null } :
|
|
2477
|
+
return s.length === 0 ? { filePath: r, result: null } : ls({
|
|
2478
2478
|
filePath: r,
|
|
2479
2479
|
func: async () => {
|
|
2480
2480
|
let e;
|
|
@@ -2500,12 +2500,12 @@ async function gs(t) {
|
|
|
2500
2500
|
error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
|
|
2501
2501
|
};
|
|
2502
2502
|
}
|
|
2503
|
-
const u = n?.replace?.content ?? e, f =
|
|
2503
|
+
const u = n?.replace?.content ?? e, f = ms({
|
|
2504
2504
|
content: u,
|
|
2505
2505
|
pattern: l,
|
|
2506
2506
|
replacement: c.replacement
|
|
2507
2507
|
});
|
|
2508
|
-
c.replacement != null && (a = !0), n == null ? n = f : n =
|
|
2508
|
+
c.replacement != null && (a = !0), n == null ? n = f : n = gs(n, f);
|
|
2509
2509
|
}
|
|
2510
2510
|
if (a && n?.replace != null && !o) {
|
|
2511
2511
|
const i = n.replace.content;
|
|
@@ -2524,17 +2524,17 @@ async function gs(t) {
|
|
|
2524
2524
|
}
|
|
2525
2525
|
});
|
|
2526
2526
|
}
|
|
2527
|
-
async function
|
|
2527
|
+
async function Tt(t) {
|
|
2528
2528
|
const { filePaths: r, operations: s, dryRun: o } = t;
|
|
2529
2529
|
return { results: await Promise.all(
|
|
2530
2530
|
r.map(
|
|
2531
|
-
(n) =>
|
|
2531
|
+
(n) => ws({ filePath: n, operations: s, dryRun: o })
|
|
2532
2532
|
)
|
|
2533
2533
|
) };
|
|
2534
2534
|
}
|
|
2535
|
-
const
|
|
2536
|
-
function
|
|
2537
|
-
const { content: r, startLine: s } = t, o = t.padWidth ??
|
|
2535
|
+
const ys = 6;
|
|
2536
|
+
function bs(t) {
|
|
2537
|
+
const { content: r, startLine: s } = t, o = t.padWidth ?? ys;
|
|
2538
2538
|
let e = "", n = 0, a = 0;
|
|
2539
2539
|
for (; n < r.length; ) {
|
|
2540
2540
|
const i = r.indexOf(`
|
|
@@ -2545,17 +2545,17 @@ function ys(t) {
|
|
|
2545
2545
|
`) && (e += `
|
|
2546
2546
|
`), e;
|
|
2547
2547
|
}
|
|
2548
|
-
function
|
|
2548
|
+
function fe(t) {
|
|
2549
2549
|
const { content: r, matches: s, outputLimit: o } = t;
|
|
2550
2550
|
if (s.length === 0)
|
|
2551
2551
|
return { output: "", truncated: !1 };
|
|
2552
|
-
const e =
|
|
2552
|
+
const e = Mt(s);
|
|
2553
2553
|
let n = "", a = !1;
|
|
2554
2554
|
for (let i = 0; i < e.length; i++) {
|
|
2555
2555
|
const c = e[i], l = r.substring(
|
|
2556
2556
|
c.linesOffset[0],
|
|
2557
2557
|
c.linesOffset[1]
|
|
2558
|
-
), u =
|
|
2558
|
+
), u = bs({
|
|
2559
2559
|
content: l,
|
|
2560
2560
|
startLine: c.lines[0]
|
|
2561
2561
|
}), f = i > 0 ? 2 : 0;
|
|
@@ -2568,36 +2568,36 @@ function de(t) {
|
|
|
2568
2568
|
}
|
|
2569
2569
|
return { output: n, truncated: a };
|
|
2570
2570
|
}
|
|
2571
|
-
const
|
|
2572
|
-
function
|
|
2571
|
+
const Ve = "BEFORE", Ze = "AFTER";
|
|
2572
|
+
function Ss(t) {
|
|
2573
2573
|
const { result: r, outputLimit: s } = t;
|
|
2574
2574
|
if (r.replace == null) {
|
|
2575
|
-
const g =
|
|
2575
|
+
const g = fe({
|
|
2576
2576
|
content: r.search.content,
|
|
2577
2577
|
matches: r.search.matches,
|
|
2578
2578
|
outputLimit: s
|
|
2579
2579
|
});
|
|
2580
2580
|
return { output: g.output, truncated: g.truncated };
|
|
2581
2581
|
}
|
|
2582
|
-
const o = `<${
|
|
2583
|
-
`, e = `</${
|
|
2584
|
-
`, n = `<${
|
|
2585
|
-
`, a = `</${
|
|
2582
|
+
const o = `<${Ve}>
|
|
2583
|
+
`, e = `</${Ve}>
|
|
2584
|
+
`, n = `<${Ze}>
|
|
2585
|
+
`, a = `</${Ze}>
|
|
2586
2586
|
`, i = o.length + e.length + n.length + a.length;
|
|
2587
2587
|
if (s != null && s < i)
|
|
2588
2588
|
return { output: "", truncated: !0 };
|
|
2589
|
-
const c = s != null ? s - i : void 0, l = c != null ? Math.floor(c / 2) : void 0, u =
|
|
2589
|
+
const c = s != null ? s - i : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = fe({
|
|
2590
2590
|
content: r.search.content,
|
|
2591
2591
|
matches: r.search.matches,
|
|
2592
2592
|
outputLimit: l
|
|
2593
|
-
}), f = c != null ? c - u.output.length : void 0, d =
|
|
2593
|
+
}), f = c != null ? c - u.output.length : void 0, d = fe({
|
|
2594
2594
|
content: r.replace.content,
|
|
2595
2595
|
matches: r.replace.matches,
|
|
2596
2596
|
outputLimit: f
|
|
2597
2597
|
});
|
|
2598
2598
|
return { output: o + u.output + e + n + d.output + a, truncated: u.truncated || d.truncated };
|
|
2599
2599
|
}
|
|
2600
|
-
function
|
|
2600
|
+
function Ct(t) {
|
|
2601
2601
|
const { result: r, rootDir: s } = t;
|
|
2602
2602
|
let o = "";
|
|
2603
2603
|
for (let e = 0; e < r.results.length; e++) {
|
|
@@ -2612,7 +2612,7 @@ function Tt(t) {
|
|
|
2612
2612
|
}
|
|
2613
2613
|
if (n.result == null || n.result.search.matches.length === 0)
|
|
2614
2614
|
continue;
|
|
2615
|
-
const c =
|
|
2615
|
+
const c = Ss({
|
|
2616
2616
|
result: n.result
|
|
2617
2617
|
});
|
|
2618
2618
|
c.output.length > 0 && (i > 0 && (o += `
|
|
@@ -2621,23 +2621,23 @@ function Tt(t) {
|
|
|
2621
2621
|
}
|
|
2622
2622
|
return o;
|
|
2623
2623
|
}
|
|
2624
|
-
const
|
|
2624
|
+
const xs = p.object({
|
|
2625
2625
|
pattern: p.string().describe("JS RegExp pattern"),
|
|
2626
2626
|
flags: p.string().optional().describe("JS RegExp flags")
|
|
2627
|
-
}),
|
|
2627
|
+
}), Nt = p.object({
|
|
2628
2628
|
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2629
|
-
snapshot:
|
|
2629
|
+
snapshot: ee.optional().describe(
|
|
2630
2630
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2631
2631
|
),
|
|
2632
|
-
operations: p.array(
|
|
2633
|
-
outputLimit: p.number().int().min(0).max(
|
|
2634
|
-
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${
|
|
2632
|
+
operations: p.array(xs).describe("Search operations to execute sequentially on each file"),
|
|
2633
|
+
outputLimit: p.number().int().min(0).max(J).default(Q).describe(
|
|
2634
|
+
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
|
|
2635
2635
|
)
|
|
2636
2636
|
});
|
|
2637
|
-
async function
|
|
2637
|
+
async function $s(t, r, s) {
|
|
2638
2638
|
let o;
|
|
2639
2639
|
try {
|
|
2640
|
-
o =
|
|
2640
|
+
o = Nt.parse(t);
|
|
2641
2641
|
} catch (w) {
|
|
2642
2642
|
return {
|
|
2643
2643
|
error: F(w)
|
|
@@ -2648,7 +2648,7 @@ async function xs(t, r, s) {
|
|
|
2648
2648
|
return {
|
|
2649
2649
|
error: "Session ID is required"
|
|
2650
2650
|
};
|
|
2651
|
-
const c =
|
|
2651
|
+
const c = X(s.sessionId);
|
|
2652
2652
|
if (e && n)
|
|
2653
2653
|
return {
|
|
2654
2654
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
@@ -2660,7 +2660,7 @@ async function xs(t, r, s) {
|
|
|
2660
2660
|
error: `Filesystem snapshot "${e}" not found`
|
|
2661
2661
|
};
|
|
2662
2662
|
} else if (n) {
|
|
2663
|
-
const w = await
|
|
2663
|
+
const w = await ce(
|
|
2664
2664
|
n,
|
|
2665
2665
|
r,
|
|
2666
2666
|
s
|
|
@@ -2674,29 +2674,29 @@ async function xs(t, r, s) {
|
|
|
2674
2674
|
return {
|
|
2675
2675
|
error: "Either snapshotName or snapshot must be provided"
|
|
2676
2676
|
};
|
|
2677
|
-
const d =
|
|
2677
|
+
const d = It(l), h = l.query.rootDir ?? ".", g = await Tt({
|
|
2678
2678
|
filePaths: d,
|
|
2679
2679
|
operations: a
|
|
2680
|
-
}), m =
|
|
2680
|
+
}), m = Ct({
|
|
2681
2681
|
result: g,
|
|
2682
2682
|
rootDir: h
|
|
2683
2683
|
});
|
|
2684
|
-
return { output:
|
|
2684
|
+
return { output: we({
|
|
2685
2685
|
sessionId: s.sessionId,
|
|
2686
2686
|
source: m,
|
|
2687
2687
|
limit: i
|
|
2688
2688
|
}).content, rootDir: h, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
|
|
2689
2689
|
}
|
|
2690
|
-
function
|
|
2690
|
+
function Is(t, r) {
|
|
2691
2691
|
t(
|
|
2692
2692
|
"fs-snapshot-search",
|
|
2693
2693
|
{
|
|
2694
2694
|
title: "Search File Contents in Snapshot",
|
|
2695
2695
|
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",
|
|
2696
|
-
inputSchema:
|
|
2696
|
+
inputSchema: Nt.shape
|
|
2697
2697
|
},
|
|
2698
2698
|
async (s, o) => {
|
|
2699
|
-
const e = await
|
|
2699
|
+
const e = await $s(
|
|
2700
2700
|
s,
|
|
2701
2701
|
r,
|
|
2702
2702
|
o
|
|
@@ -2715,27 +2715,27 @@ ${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` arr
|
|
|
2715
2715
|
}
|
|
2716
2716
|
);
|
|
2717
2717
|
}
|
|
2718
|
-
const
|
|
2718
|
+
const Ms = p.object({
|
|
2719
2719
|
pattern: p.string().describe("JS RegExp pattern"),
|
|
2720
2720
|
flags: p.string().optional().describe("JS RegExp flags"),
|
|
2721
2721
|
replacement: p.string().describe("JS replacement pattern")
|
|
2722
|
-
}),
|
|
2722
|
+
}), vt = p.object({
|
|
2723
2723
|
snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2724
|
-
snapshot:
|
|
2724
|
+
snapshot: ee.optional().describe(
|
|
2725
2725
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2726
2726
|
),
|
|
2727
|
-
operations: p.array(
|
|
2728
|
-
outputLimit: p.number().int().min(0).max(
|
|
2729
|
-
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${
|
|
2727
|
+
operations: p.array(Ms).describe("Replace operations to execute sequentially on each file"),
|
|
2728
|
+
outputLimit: p.number().int().min(0).max(J).default(Q).describe(
|
|
2729
|
+
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
|
|
2730
2730
|
),
|
|
2731
2731
|
dryRun: p.boolean().optional().describe(
|
|
2732
2732
|
"Preview changes without writing files. When true, shows what would be replaced but does not modify files"
|
|
2733
2733
|
)
|
|
2734
2734
|
});
|
|
2735
|
-
async function
|
|
2735
|
+
async function Ts(t, r, s) {
|
|
2736
2736
|
let o;
|
|
2737
2737
|
try {
|
|
2738
|
-
o =
|
|
2738
|
+
o = vt.parse(t);
|
|
2739
2739
|
} catch (I) {
|
|
2740
2740
|
return {
|
|
2741
2741
|
error: F(I)
|
|
@@ -2746,7 +2746,7 @@ async function Ms(t, r, s) {
|
|
|
2746
2746
|
return {
|
|
2747
2747
|
error: "Session ID is required"
|
|
2748
2748
|
};
|
|
2749
|
-
const l =
|
|
2749
|
+
const l = X(s.sessionId);
|
|
2750
2750
|
if (e && n)
|
|
2751
2751
|
return {
|
|
2752
2752
|
error: "Either snapshotName or snapshot must be provided, not both"
|
|
@@ -2758,7 +2758,7 @@ async function Ms(t, r, s) {
|
|
|
2758
2758
|
error: `Filesystem snapshot "${e}" not found`
|
|
2759
2759
|
};
|
|
2760
2760
|
} else if (n) {
|
|
2761
|
-
const I = await
|
|
2761
|
+
const I = await ce(
|
|
2762
2762
|
n,
|
|
2763
2763
|
r,
|
|
2764
2764
|
s
|
|
@@ -2772,30 +2772,30 @@ async function Ms(t, r, s) {
|
|
|
2772
2772
|
return {
|
|
2773
2773
|
error: "Either snapshotName or snapshot must be provided"
|
|
2774
2774
|
};
|
|
2775
|
-
const h =
|
|
2775
|
+
const h = It(u), g = u.query.rootDir ?? ".", m = await Tt({
|
|
2776
2776
|
filePaths: h,
|
|
2777
2777
|
operations: a,
|
|
2778
2778
|
dryRun: c
|
|
2779
|
-
}), y =
|
|
2779
|
+
}), y = Ct({
|
|
2780
2780
|
result: m,
|
|
2781
2781
|
rootDir: g
|
|
2782
2782
|
});
|
|
2783
|
-
return { output:
|
|
2783
|
+
return { output: we({
|
|
2784
2784
|
sessionId: s.sessionId,
|
|
2785
2785
|
source: y,
|
|
2786
2786
|
limit: i
|
|
2787
2787
|
}).content, rootDir: g, fsSnapshot: u, queryCreated: f, snapshotCreated: d };
|
|
2788
2788
|
}
|
|
2789
|
-
function
|
|
2789
|
+
function Cs(t, r) {
|
|
2790
2790
|
t(
|
|
2791
2791
|
"fs-snapshot-replace",
|
|
2792
2792
|
{
|
|
2793
2793
|
title: "Replace File Contents in Snapshot",
|
|
2794
2794
|
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",
|
|
2795
|
-
inputSchema:
|
|
2795
|
+
inputSchema: vt.shape
|
|
2796
2796
|
},
|
|
2797
2797
|
async (s, o) => {
|
|
2798
|
-
const e = await
|
|
2798
|
+
const e = await Ts(
|
|
2799
2799
|
s,
|
|
2800
2800
|
r,
|
|
2801
2801
|
o
|
|
@@ -2814,21 +2814,21 @@ ${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` arr
|
|
|
2814
2814
|
}
|
|
2815
2815
|
);
|
|
2816
2816
|
}
|
|
2817
|
-
function
|
|
2818
|
-
r.list &&
|
|
2817
|
+
function Ns(t, r) {
|
|
2818
|
+
r.list && jr(t, r), r.snapshotQueryCreate && Wr(t, r), r.snapshotCreate && ts(t, r), r.snapshotBrowse && is(t, r), r.snapshotSearch && Is(t, r), r.snapshotReplace && Cs(t, r), console.log(
|
|
2819
2819
|
`File manager:
|
|
2820
2820
|
- Working directory: ${R.resolve(r.workingDir || "")}
|
|
2821
2821
|
`
|
|
2822
2822
|
);
|
|
2823
2823
|
}
|
|
2824
|
-
const
|
|
2824
|
+
const he = /* @__PURE__ */ new Map();
|
|
2825
2825
|
function j(t) {
|
|
2826
|
-
return
|
|
2826
|
+
return he.has(t) || he.set(t, {
|
|
2827
2827
|
browsers: /* @__PURE__ */ new Map(),
|
|
2828
2828
|
domSnapshotQueries: /* @__PURE__ */ new Map()
|
|
2829
|
-
}),
|
|
2829
|
+
}), he.get(t);
|
|
2830
2830
|
}
|
|
2831
|
-
const
|
|
2831
|
+
const xe = p.object({
|
|
2832
2832
|
name: p.string().describe(
|
|
2833
2833
|
"Unique name for the browser. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
2834
2834
|
),
|
|
@@ -2836,10 +2836,10 @@ const Se = p.object({
|
|
|
2836
2836
|
muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
|
|
2837
2837
|
devTools: p.boolean().optional().describe("Open browser with dev tools")
|
|
2838
2838
|
});
|
|
2839
|
-
async function
|
|
2839
|
+
async function Et(t, r, s) {
|
|
2840
2840
|
let o;
|
|
2841
2841
|
try {
|
|
2842
|
-
o =
|
|
2842
|
+
o = xe.parse(t);
|
|
2843
2843
|
} catch (l) {
|
|
2844
2844
|
return {
|
|
2845
2845
|
error: F(l)
|
|
@@ -2853,9 +2853,9 @@ async function vt(t, r, s) {
|
|
|
2853
2853
|
const c = j(s.sessionId);
|
|
2854
2854
|
try {
|
|
2855
2855
|
const u = await {
|
|
2856
|
-
chromium:
|
|
2857
|
-
firefox:
|
|
2858
|
-
webkit:
|
|
2856
|
+
chromium: tr,
|
|
2857
|
+
firefox: er,
|
|
2858
|
+
webkit: Xt
|
|
2859
2859
|
}[n].launch({
|
|
2860
2860
|
headless: !1,
|
|
2861
2861
|
devtools: i,
|
|
@@ -2873,26 +2873,26 @@ async function vt(t, r, s) {
|
|
|
2873
2873
|
};
|
|
2874
2874
|
}
|
|
2875
2875
|
}
|
|
2876
|
-
function
|
|
2876
|
+
function vs(t, r) {
|
|
2877
2877
|
t(
|
|
2878
2878
|
"playwright-browser-create",
|
|
2879
2879
|
{
|
|
2880
2880
|
title: "Create Browser",
|
|
2881
2881
|
description: "Create a new browser. Prefer page-goto if you need to immediately create a browser, context, page and navigate",
|
|
2882
|
-
inputSchema:
|
|
2882
|
+
inputSchema: xe.shape
|
|
2883
2883
|
},
|
|
2884
2884
|
async (s, o) => {
|
|
2885
|
-
const e = await
|
|
2885
|
+
const e = await Et(s, r, o);
|
|
2886
2886
|
return `Method: playwright-browser-create(${JSON.stringify(s)})
|
|
2887
2887
|
${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
|
|
2888
2888
|
}
|
|
2889
2889
|
);
|
|
2890
2890
|
}
|
|
2891
|
-
const
|
|
2892
|
-
async function
|
|
2891
|
+
const kt = p.object({});
|
|
2892
|
+
async function Es(t, r, s) {
|
|
2893
2893
|
let o;
|
|
2894
2894
|
try {
|
|
2895
|
-
o =
|
|
2895
|
+
o = kt.parse(t);
|
|
2896
2896
|
} catch (a) {
|
|
2897
2897
|
return {
|
|
2898
2898
|
error: F(a)
|
|
@@ -2907,16 +2907,16 @@ async function vs(t, r, s) {
|
|
|
2907
2907
|
browserInfos: Array.from(e.browsers.values())
|
|
2908
2908
|
};
|
|
2909
2909
|
}
|
|
2910
|
-
function
|
|
2910
|
+
function ks(t, r) {
|
|
2911
2911
|
t(
|
|
2912
2912
|
"playwright-browser-list",
|
|
2913
2913
|
{
|
|
2914
2914
|
title: "List Browsers",
|
|
2915
2915
|
description: "List active browser instances",
|
|
2916
|
-
inputSchema:
|
|
2916
|
+
inputSchema: kt.shape
|
|
2917
2917
|
},
|
|
2918
2918
|
async (s, o) => {
|
|
2919
|
-
const e = await
|
|
2919
|
+
const e = await Es(s, r, o);
|
|
2920
2920
|
if (e.error != null)
|
|
2921
2921
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
2922
2922
|
❌ Error: ${e.error}`;
|
|
@@ -2928,15 +2928,15 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
|
|
|
2928
2928
|
}
|
|
2929
2929
|
);
|
|
2930
2930
|
}
|
|
2931
|
-
const
|
|
2931
|
+
const Ot = p.object({
|
|
2932
2932
|
names: p.array(p.string()).optional().describe(
|
|
2933
2933
|
"Names of browsers to close. If not specified, closes all browsers"
|
|
2934
2934
|
)
|
|
2935
2935
|
});
|
|
2936
|
-
async function
|
|
2936
|
+
async function Os(t, r, s) {
|
|
2937
2937
|
let o;
|
|
2938
2938
|
try {
|
|
2939
|
-
o =
|
|
2939
|
+
o = Ot.parse(t);
|
|
2940
2940
|
} catch (l) {
|
|
2941
2941
|
return {
|
|
2942
2942
|
error: F(l)
|
|
@@ -2967,16 +2967,16 @@ async function ks(t, r, s) {
|
|
|
2967
2967
|
...i.length > 0 && { errors: i }
|
|
2968
2968
|
};
|
|
2969
2969
|
}
|
|
2970
|
-
function
|
|
2970
|
+
function Ds(t, r) {
|
|
2971
2971
|
t(
|
|
2972
2972
|
"playwright-browser-close",
|
|
2973
2973
|
{
|
|
2974
2974
|
title: "Close Browsers",
|
|
2975
2975
|
description: "Close browsers. Automatically closes all contexts and pages within the browsers",
|
|
2976
|
-
inputSchema:
|
|
2976
|
+
inputSchema: Ot.shape
|
|
2977
2977
|
},
|
|
2978
2978
|
async (s, o) => {
|
|
2979
|
-
const e = await
|
|
2979
|
+
const e = await Os(s, r, o);
|
|
2980
2980
|
if (e.error != null)
|
|
2981
2981
|
return `Method: playwright-browser-close(${JSON.stringify(s)})
|
|
2982
2982
|
❌ Error: ${e.error}`;
|
|
@@ -2993,9 +2993,9 @@ ${n.join(`
|
|
|
2993
2993
|
}
|
|
2994
2994
|
);
|
|
2995
2995
|
}
|
|
2996
|
-
const
|
|
2996
|
+
const $e = p.object({
|
|
2997
2997
|
browserName: p.string().optional().describe("Name of previously created browser, to use"),
|
|
2998
|
-
browser:
|
|
2998
|
+
browser: xe.optional().describe(
|
|
2999
2999
|
"Browser creation options JSON to automatically create browser"
|
|
3000
3000
|
),
|
|
3001
3001
|
name: p.string().describe(
|
|
@@ -3008,10 +3008,10 @@ const xe = p.object({
|
|
|
3008
3008
|
height: p.number()
|
|
3009
3009
|
}).optional().describe("Viewport size configuration")
|
|
3010
3010
|
});
|
|
3011
|
-
async function
|
|
3011
|
+
async function Dt(t, r, s) {
|
|
3012
3012
|
let o;
|
|
3013
3013
|
try {
|
|
3014
|
-
o =
|
|
3014
|
+
o = $e.parse(t);
|
|
3015
3015
|
} catch (h) {
|
|
3016
3016
|
return {
|
|
3017
3017
|
error: F(h)
|
|
@@ -3034,7 +3034,7 @@ async function Ot(t, r, s) {
|
|
|
3034
3034
|
error: `Browser "${n}" not found`
|
|
3035
3035
|
};
|
|
3036
3036
|
} else if (a) {
|
|
3037
|
-
const h = await
|
|
3037
|
+
const h = await Et(a, r, s);
|
|
3038
3038
|
if (h.error != null)
|
|
3039
3039
|
return {
|
|
3040
3040
|
error: h.error
|
|
@@ -3066,16 +3066,16 @@ async function Ot(t, r, s) {
|
|
|
3066
3066
|
};
|
|
3067
3067
|
}
|
|
3068
3068
|
}
|
|
3069
|
-
function
|
|
3069
|
+
function Rs(t, r) {
|
|
3070
3070
|
t(
|
|
3071
3071
|
"playwright-context-create",
|
|
3072
3072
|
{
|
|
3073
3073
|
title: "Create Browser Context",
|
|
3074
3074
|
description: "Create a new browser context. Prefer page-goto if you need to immediately create a context, page and navigate",
|
|
3075
|
-
inputSchema:
|
|
3075
|
+
inputSchema: $e.shape
|
|
3076
3076
|
},
|
|
3077
3077
|
async (s, o) => {
|
|
3078
|
-
const e = await
|
|
3078
|
+
const e = await Dt(s, r, o);
|
|
3079
3079
|
if (e.error != null)
|
|
3080
3080
|
return `Method: playwright-context-create(${JSON.stringify(s)})
|
|
3081
3081
|
❌ Error: ${e.error}`;
|
|
@@ -3086,15 +3086,15 @@ function Ds(t, r) {
|
|
|
3086
3086
|
}
|
|
3087
3087
|
);
|
|
3088
3088
|
}
|
|
3089
|
-
const
|
|
3089
|
+
const Rt = p.object({
|
|
3090
3090
|
browserName: p.string().optional().describe(
|
|
3091
3091
|
"Name of browser to list contexts from. If not specified, lists contexts from all browsers"
|
|
3092
3092
|
)
|
|
3093
3093
|
});
|
|
3094
|
-
async function
|
|
3094
|
+
async function Fs(t, r, s) {
|
|
3095
3095
|
let o;
|
|
3096
3096
|
try {
|
|
3097
|
-
o =
|
|
3097
|
+
o = Rt.parse(t);
|
|
3098
3098
|
} catch (i) {
|
|
3099
3099
|
return {
|
|
3100
3100
|
error: F(i)
|
|
@@ -3128,16 +3128,16 @@ async function Rs(t, r, s) {
|
|
|
3128
3128
|
contextsByBrowser: a
|
|
3129
3129
|
};
|
|
3130
3130
|
}
|
|
3131
|
-
function
|
|
3131
|
+
function Bs(t, r) {
|
|
3132
3132
|
t(
|
|
3133
3133
|
"playwright-context-list",
|
|
3134
3134
|
{
|
|
3135
3135
|
title: "List Browser Contexts",
|
|
3136
3136
|
description: "List active browser contexts",
|
|
3137
|
-
inputSchema:
|
|
3137
|
+
inputSchema: Rt.shape
|
|
3138
3138
|
},
|
|
3139
3139
|
async (s, o) => {
|
|
3140
|
-
const e = await
|
|
3140
|
+
const e = await Fs(s, r, o);
|
|
3141
3141
|
if ("error" in e)
|
|
3142
3142
|
return `Method: playwright-context-list(${JSON.stringify(s)})
|
|
3143
3143
|
❌ Error: ${e.error}`;
|
|
@@ -3150,7 +3150,7 @@ function Fs(t, r) {
|
|
|
3150
3150
|
}
|
|
3151
3151
|
);
|
|
3152
3152
|
}
|
|
3153
|
-
const
|
|
3153
|
+
const Ft = p.object({
|
|
3154
3154
|
names: p.array(p.string()).optional().describe(
|
|
3155
3155
|
"Names of contexts to close. If not specified, closes all contexts"
|
|
3156
3156
|
),
|
|
@@ -3158,10 +3158,10 @@ const Rt = p.object({
|
|
|
3158
3158
|
"Name of browser to close contexts from. If not specified, searches all browsers"
|
|
3159
3159
|
)
|
|
3160
3160
|
});
|
|
3161
|
-
async function
|
|
3161
|
+
async function Ls(t, r, s) {
|
|
3162
3162
|
let o;
|
|
3163
3163
|
try {
|
|
3164
|
-
o =
|
|
3164
|
+
o = Ft.parse(t);
|
|
3165
3165
|
} catch (u) {
|
|
3166
3166
|
return {
|
|
3167
3167
|
error: F(u)
|
|
@@ -3212,16 +3212,16 @@ async function Bs(t, r, s) {
|
|
|
3212
3212
|
...c.length > 0 && { errors: c }
|
|
3213
3213
|
};
|
|
3214
3214
|
}
|
|
3215
|
-
function
|
|
3215
|
+
function Ps(t, r) {
|
|
3216
3216
|
t(
|
|
3217
3217
|
"playwright-context-close",
|
|
3218
3218
|
{
|
|
3219
3219
|
title: "Close Browser Contexts",
|
|
3220
3220
|
description: "Close browser contexts. Automatically closes all pages within the contexts",
|
|
3221
|
-
inputSchema:
|
|
3221
|
+
inputSchema: Ft.shape
|
|
3222
3222
|
},
|
|
3223
3223
|
async (s, o) => {
|
|
3224
|
-
const e = await
|
|
3224
|
+
const e = await Ls(s, r, o);
|
|
3225
3225
|
if ("error" in e)
|
|
3226
3226
|
return `Method: playwright-context-close(${JSON.stringify(s)})
|
|
3227
3227
|
❌ Error: ${e.error}`;
|
|
@@ -3238,7 +3238,7 @@ ${n.join(`
|
|
|
3238
3238
|
}
|
|
3239
3239
|
);
|
|
3240
3240
|
}
|
|
3241
|
-
function
|
|
3241
|
+
function As() {
|
|
3242
3242
|
class t {
|
|
3243
3243
|
prevId = 0;
|
|
3244
3244
|
objectToId = /* @__PURE__ */ new WeakMap();
|
|
@@ -3326,19 +3326,19 @@ function Ps() {
|
|
|
3326
3326
|
}
|
|
3327
3327
|
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = a;
|
|
3328
3328
|
}
|
|
3329
|
-
const
|
|
3329
|
+
const zs = `(function (){function __name(fn){return fn};${As.toString()}; setupPageGlobals();})()`, Ie = p.object({
|
|
3330
3330
|
contextName: p.string().optional().describe("Name of previously created context, to use"),
|
|
3331
|
-
context:
|
|
3331
|
+
context: $e.optional().describe(
|
|
3332
3332
|
"Context creation options JSON to automatically create context"
|
|
3333
3333
|
),
|
|
3334
3334
|
name: p.string().describe(
|
|
3335
3335
|
"Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3336
3336
|
)
|
|
3337
3337
|
});
|
|
3338
|
-
async function
|
|
3338
|
+
async function Bt(t, r, s) {
|
|
3339
3339
|
let o;
|
|
3340
3340
|
try {
|
|
3341
|
-
o =
|
|
3341
|
+
o = Ie.parse(t);
|
|
3342
3342
|
} catch (f) {
|
|
3343
3343
|
return {
|
|
3344
3344
|
error: F(f)
|
|
@@ -3366,7 +3366,7 @@ async function Ft(t, r, s) {
|
|
|
3366
3366
|
error: `Context "${n}" not found`
|
|
3367
3367
|
};
|
|
3368
3368
|
} else if (a) {
|
|
3369
|
-
const f = await
|
|
3369
|
+
const f = await Dt(a, r, s);
|
|
3370
3370
|
if (f.error != null)
|
|
3371
3371
|
return {
|
|
3372
3372
|
error: f.error
|
|
@@ -3378,7 +3378,7 @@ async function Ft(t, r, s) {
|
|
|
3378
3378
|
};
|
|
3379
3379
|
try {
|
|
3380
3380
|
const f = await u.context.newPage();
|
|
3381
|
-
await f.addInitScript(
|
|
3381
|
+
await f.addInitScript(zs), await f.goto("about:blank");
|
|
3382
3382
|
const d = {
|
|
3383
3383
|
contextInfo: u,
|
|
3384
3384
|
name: e,
|
|
@@ -3396,16 +3396,16 @@ async function Ft(t, r, s) {
|
|
|
3396
3396
|
};
|
|
3397
3397
|
}
|
|
3398
3398
|
}
|
|
3399
|
-
function
|
|
3399
|
+
function Us(t, r) {
|
|
3400
3400
|
t(
|
|
3401
3401
|
"playwright-page-create",
|
|
3402
3402
|
{
|
|
3403
3403
|
title: "Create Page",
|
|
3404
3404
|
description: "Create a new page. Prefer page-goto if you need to immediately create a page and navigate",
|
|
3405
|
-
inputSchema:
|
|
3405
|
+
inputSchema: Ie.shape
|
|
3406
3406
|
},
|
|
3407
3407
|
async (s, o) => {
|
|
3408
|
-
const e = await
|
|
3408
|
+
const e = await Bt(s, r, o);
|
|
3409
3409
|
if (e.error != null)
|
|
3410
3410
|
return `Method: playwright-page-create(${JSON.stringify(s)})
|
|
3411
3411
|
❌ Error: ${e.error}`;
|
|
@@ -3417,7 +3417,7 @@ function zs(t, r) {
|
|
|
3417
3417
|
}
|
|
3418
3418
|
);
|
|
3419
3419
|
}
|
|
3420
|
-
const
|
|
3420
|
+
const Lt = p.object({
|
|
3421
3421
|
contextName: p.string().optional().describe(
|
|
3422
3422
|
"Name of context to list pages from. If not specified, lists pages from all contexts"
|
|
3423
3423
|
),
|
|
@@ -3425,10 +3425,10 @@ const Bt = p.object({
|
|
|
3425
3425
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3426
3426
|
)
|
|
3427
3427
|
});
|
|
3428
|
-
async function
|
|
3428
|
+
async function qs(t, r, s) {
|
|
3429
3429
|
let o;
|
|
3430
3430
|
try {
|
|
3431
|
-
o =
|
|
3431
|
+
o = Lt.parse(t);
|
|
3432
3432
|
} catch (c) {
|
|
3433
3433
|
return {
|
|
3434
3434
|
error: F(c)
|
|
@@ -3489,16 +3489,16 @@ async function Us(t, r, s) {
|
|
|
3489
3489
|
pagesByContext: i
|
|
3490
3490
|
};
|
|
3491
3491
|
}
|
|
3492
|
-
function
|
|
3492
|
+
function _s(t, r) {
|
|
3493
3493
|
t(
|
|
3494
3494
|
"playwright-page-list",
|
|
3495
3495
|
{
|
|
3496
3496
|
title: "List Pages",
|
|
3497
3497
|
description: "List active pages",
|
|
3498
|
-
inputSchema:
|
|
3498
|
+
inputSchema: Lt.shape
|
|
3499
3499
|
},
|
|
3500
3500
|
async (s, o) => {
|
|
3501
|
-
const e = await
|
|
3501
|
+
const e = await qs(s, r, o);
|
|
3502
3502
|
if ("error" in e)
|
|
3503
3503
|
return `Method: playwright-page-list(${JSON.stringify(s)})
|
|
3504
3504
|
❌ Error: ${e.error}`;
|
|
@@ -3511,7 +3511,7 @@ function qs(t, r) {
|
|
|
3511
3511
|
}
|
|
3512
3512
|
);
|
|
3513
3513
|
}
|
|
3514
|
-
const
|
|
3514
|
+
const Pt = p.object({
|
|
3515
3515
|
names: p.array(p.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
|
|
3516
3516
|
contextName: p.string().optional().describe(
|
|
3517
3517
|
"Name of context to close pages from. If not specified, searches all contexts"
|
|
@@ -3520,10 +3520,10 @@ const Lt = p.object({
|
|
|
3520
3520
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3521
3521
|
)
|
|
3522
3522
|
});
|
|
3523
|
-
async function
|
|
3523
|
+
async function Gs(t, r, s) {
|
|
3524
3524
|
let o;
|
|
3525
3525
|
try {
|
|
3526
|
-
o =
|
|
3526
|
+
o = Pt.parse(t);
|
|
3527
3527
|
} catch (f) {
|
|
3528
3528
|
return {
|
|
3529
3529
|
error: F(f)
|
|
@@ -3598,16 +3598,16 @@ async function _s(t, r, s) {
|
|
|
3598
3598
|
...l.length > 0 && { errors: l }
|
|
3599
3599
|
};
|
|
3600
3600
|
}
|
|
3601
|
-
function
|
|
3601
|
+
function Js(t, r) {
|
|
3602
3602
|
t(
|
|
3603
3603
|
"playwright-page-close",
|
|
3604
3604
|
{
|
|
3605
3605
|
title: "Close Pages",
|
|
3606
3606
|
description: "Close pages",
|
|
3607
|
-
inputSchema:
|
|
3607
|
+
inputSchema: Pt.shape
|
|
3608
3608
|
},
|
|
3609
3609
|
async (s, o) => {
|
|
3610
|
-
const e = await
|
|
3610
|
+
const e = await Gs(s, r, o);
|
|
3611
3611
|
if ("error" in e)
|
|
3612
3612
|
return `Method: playwright-page-close(${JSON.stringify(s)})
|
|
3613
3613
|
❌ Error: ${e.error}`;
|
|
@@ -3618,9 +3618,9 @@ ${n.join(`
|
|
|
3618
3618
|
}
|
|
3619
3619
|
);
|
|
3620
3620
|
}
|
|
3621
|
-
const
|
|
3621
|
+
const At = p.object({
|
|
3622
3622
|
pageName: p.string().optional().describe("Name of previously created page to navigate"),
|
|
3623
|
-
page:
|
|
3623
|
+
page: Ie.optional().describe(
|
|
3624
3624
|
"Page creation options JSON to automatically create page"
|
|
3625
3625
|
),
|
|
3626
3626
|
url: p.string().describe("URL to navigate to"),
|
|
@@ -3633,10 +3633,10 @@ const Pt = p.object({
|
|
|
3633
3633
|
- 'commit': network response received and document started loading`
|
|
3634
3634
|
)
|
|
3635
3635
|
});
|
|
3636
|
-
async function
|
|
3636
|
+
async function js(t, r, s) {
|
|
3637
3637
|
let o;
|
|
3638
3638
|
try {
|
|
3639
|
-
o =
|
|
3639
|
+
o = At.parse(t);
|
|
3640
3640
|
} catch (g) {
|
|
3641
3641
|
return {
|
|
3642
3642
|
error: F(g)
|
|
@@ -3667,7 +3667,7 @@ async function Js(t, r, s) {
|
|
|
3667
3667
|
error: `Page "${e}" not found`
|
|
3668
3668
|
};
|
|
3669
3669
|
} else if (n) {
|
|
3670
|
-
const g = await
|
|
3670
|
+
const g = await Bt(n, r, s);
|
|
3671
3671
|
if (g.error != null)
|
|
3672
3672
|
return {
|
|
3673
3673
|
error: g.error
|
|
@@ -3701,16 +3701,16 @@ async function Js(t, r, s) {
|
|
|
3701
3701
|
};
|
|
3702
3702
|
}
|
|
3703
3703
|
}
|
|
3704
|
-
function
|
|
3704
|
+
function Ks(t, r) {
|
|
3705
3705
|
t(
|
|
3706
3706
|
"playwright-page-goto",
|
|
3707
3707
|
{
|
|
3708
3708
|
title: "Navigate Page",
|
|
3709
3709
|
description: "Navigate page to URL. Use for manual browser interaction",
|
|
3710
|
-
inputSchema:
|
|
3710
|
+
inputSchema: At.shape
|
|
3711
3711
|
},
|
|
3712
3712
|
async (s, o) => {
|
|
3713
|
-
const e = await
|
|
3713
|
+
const e = await js(s, r, o);
|
|
3714
3714
|
if (e.error != null)
|
|
3715
3715
|
return `Method: playwright-page-goto(${JSON.stringify(s)})
|
|
3716
3716
|
❌ Error: ${e.error}`;
|
|
@@ -3723,16 +3723,16 @@ function js(t, r) {
|
|
|
3723
3723
|
}
|
|
3724
3724
|
);
|
|
3725
3725
|
}
|
|
3726
|
-
const
|
|
3726
|
+
const Me = p.object({
|
|
3727
3727
|
name: p.string().describe(
|
|
3728
3728
|
"Unique name for the DOM snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3729
3729
|
),
|
|
3730
3730
|
cssSelector: p.string().describe("CSS selector to capture page content")
|
|
3731
3731
|
});
|
|
3732
|
-
async function
|
|
3732
|
+
async function zt(t, r, s) {
|
|
3733
3733
|
let o;
|
|
3734
3734
|
try {
|
|
3735
|
-
o =
|
|
3735
|
+
o = Me.parse(t);
|
|
3736
3736
|
} catch (c) {
|
|
3737
3737
|
return {
|
|
3738
3738
|
error: F(c)
|
|
@@ -3751,23 +3751,23 @@ async function At(t, r, s) {
|
|
|
3751
3751
|
snapshotQuery: i
|
|
3752
3752
|
};
|
|
3753
3753
|
}
|
|
3754
|
-
function
|
|
3754
|
+
function Ws(t, r) {
|
|
3755
3755
|
t(
|
|
3756
3756
|
"playwright-dom-snapshot-query-create",
|
|
3757
3757
|
{
|
|
3758
3758
|
title: "Create DOM Snapshot Query",
|
|
3759
3759
|
description: "Create a DOM snapshot query. Prefer dom-snapshot-browse if you need to immediately create a query and snapshot and browse it",
|
|
3760
|
-
inputSchema:
|
|
3760
|
+
inputSchema: Me.shape
|
|
3761
3761
|
},
|
|
3762
3762
|
async (s, o) => {
|
|
3763
|
-
const e = await
|
|
3763
|
+
const e = await zt(s, r, o);
|
|
3764
3764
|
return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3765
3765
|
❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3766
3766
|
✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
3767
3767
|
}
|
|
3768
3768
|
);
|
|
3769
3769
|
}
|
|
3770
|
-
function
|
|
3770
|
+
function Hs(t) {
|
|
3771
3771
|
return function(s, o) {
|
|
3772
3772
|
let e, n = 0;
|
|
3773
3773
|
const a = o ? o.length : 0;
|
|
@@ -3788,7 +3788,7 @@ function Ws(t) {
|
|
|
3788
3788
|
textOpen: `<root uid:${u}>`,
|
|
3789
3789
|
textClose: "</root>"
|
|
3790
3790
|
};
|
|
3791
|
-
const h =
|
|
3791
|
+
const h = bt(d);
|
|
3792
3792
|
return l += h, {
|
|
3793
3793
|
uid: u,
|
|
3794
3794
|
tagName: f,
|
|
@@ -3803,8 +3803,8 @@ function Ws(t) {
|
|
|
3803
3803
|
};
|
|
3804
3804
|
};
|
|
3805
3805
|
}
|
|
3806
|
-
function
|
|
3807
|
-
const s =
|
|
3806
|
+
function Qs(t, r) {
|
|
3807
|
+
const s = le(r), o = s.getChilds(s.root), e = yt({
|
|
3808
3808
|
getId: (n) => {
|
|
3809
3809
|
const a = s.getId(n);
|
|
3810
3810
|
if (a == null)
|
|
@@ -3814,25 +3814,25 @@ function Hs(t, r) {
|
|
|
3814
3814
|
return a;
|
|
3815
3815
|
},
|
|
3816
3816
|
getChilds: (n) => s.getChilds(n),
|
|
3817
|
-
createSnapshotNode:
|
|
3817
|
+
createSnapshotNode: Hs(),
|
|
3818
3818
|
rootNodes: o ?? []
|
|
3819
3819
|
});
|
|
3820
|
-
return
|
|
3820
|
+
return le(e);
|
|
3821
3821
|
}
|
|
3822
|
-
const
|
|
3822
|
+
const Te = p.object({
|
|
3823
3823
|
pageName: p.string().describe("Name of previously created page, to create snapshot from"),
|
|
3824
3824
|
queryName: p.string().optional().describe("Name of previously created DOM snapshot query, to use"),
|
|
3825
|
-
query:
|
|
3825
|
+
query: Me.optional().describe(
|
|
3826
3826
|
"DOM snapshot query creation options JSON to automatically create query"
|
|
3827
3827
|
),
|
|
3828
3828
|
name: p.string().describe(
|
|
3829
3829
|
"Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3830
3830
|
)
|
|
3831
3831
|
});
|
|
3832
|
-
async function
|
|
3832
|
+
async function Ut(t, r, s) {
|
|
3833
3833
|
let o;
|
|
3834
3834
|
try {
|
|
3835
|
-
o =
|
|
3835
|
+
o = Te.parse(t);
|
|
3836
3836
|
} catch (d) {
|
|
3837
3837
|
return {
|
|
3838
3838
|
error: F(d)
|
|
@@ -3870,7 +3870,7 @@ async function zt(t, r, s) {
|
|
|
3870
3870
|
};
|
|
3871
3871
|
u = d;
|
|
3872
3872
|
} else if (a) {
|
|
3873
|
-
const d = await
|
|
3873
|
+
const d = await zt(
|
|
3874
3874
|
a,
|
|
3875
3875
|
r,
|
|
3876
3876
|
s
|
|
@@ -3900,7 +3900,7 @@ async function zt(t, r, s) {
|
|
|
3900
3900
|
), h = {
|
|
3901
3901
|
idToNode: new Map(d.idToNode),
|
|
3902
3902
|
idToChildIds: new Map(d.idToChildIds)
|
|
3903
|
-
}, g =
|
|
3903
|
+
}, g = Qs(u, h), m = {
|
|
3904
3904
|
name: i,
|
|
3905
3905
|
query: u,
|
|
3906
3906
|
tree: g
|
|
@@ -3915,16 +3915,16 @@ async function zt(t, r, s) {
|
|
|
3915
3915
|
};
|
|
3916
3916
|
}
|
|
3917
3917
|
}
|
|
3918
|
-
function
|
|
3918
|
+
function Ys(t, r) {
|
|
3919
3919
|
t(
|
|
3920
3920
|
"playwright-dom-snapshot-create",
|
|
3921
3921
|
{
|
|
3922
3922
|
title: "Create DOM Snapshot",
|
|
3923
3923
|
description: "Create a DOM snapshot of page. Use this to capture webpage state for later browsing. Prefer dom-snapshot-browse if you need to immediately create and browse a snapshot",
|
|
3924
|
-
inputSchema:
|
|
3924
|
+
inputSchema: Te.shape
|
|
3925
3925
|
},
|
|
3926
3926
|
async (s, o) => {
|
|
3927
|
-
const e = await
|
|
3927
|
+
const e = await Ut(s, r, o);
|
|
3928
3928
|
if (e.error != null)
|
|
3929
3929
|
return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
|
|
3930
3930
|
❌ Error: ${e.error}`;
|
|
@@ -3935,7 +3935,7 @@ function Qs(t, r) {
|
|
|
3935
3935
|
}
|
|
3936
3936
|
);
|
|
3937
3937
|
}
|
|
3938
|
-
class
|
|
3938
|
+
class Vs {
|
|
3939
3939
|
tokens = 20;
|
|
3940
3940
|
getReportText = (r) => ({
|
|
3941
3941
|
indent: !0,
|
|
@@ -3949,9 +3949,9 @@ class Ys {
|
|
|
3949
3949
|
tokensGrouped: s.tokens
|
|
3950
3950
|
} : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
|
|
3951
3951
|
}
|
|
3952
|
-
const
|
|
3952
|
+
const qt = p.object({
|
|
3953
3953
|
snapshotName: p.string().optional().describe("Name of previously created DOM snapshot, to use"),
|
|
3954
|
-
snapshot:
|
|
3954
|
+
snapshot: Te.optional().describe(
|
|
3955
3955
|
"DOM snapshot creation options JSON to automatically create snapshot"
|
|
3956
3956
|
),
|
|
3957
3957
|
parentUid: p.number().optional().describe("UID of parent node to browse. Omit to browse the root node"),
|
|
@@ -3969,10 +3969,10 @@ const Ut = p.object({
|
|
|
3969
3969
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
3970
3970
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
3971
3971
|
});
|
|
3972
|
-
async function
|
|
3972
|
+
async function Zs(t, r, s) {
|
|
3973
3973
|
let o;
|
|
3974
3974
|
try {
|
|
3975
|
-
o =
|
|
3975
|
+
o = qt.parse(t);
|
|
3976
3976
|
} catch (m) {
|
|
3977
3977
|
return {
|
|
3978
3978
|
error: F(m)
|
|
@@ -4014,7 +4014,7 @@ async function Vs(t, r, s) {
|
|
|
4014
4014
|
error: `DOM snapshot "${e}" not found`
|
|
4015
4015
|
};
|
|
4016
4016
|
} else if (n) {
|
|
4017
|
-
const m = await
|
|
4017
|
+
const m = await Ut(
|
|
4018
4018
|
n,
|
|
4019
4019
|
r,
|
|
4020
4020
|
s
|
|
@@ -4029,7 +4029,7 @@ async function Vs(t, r, s) {
|
|
|
4029
4029
|
error: "Either snapshotName or snapshot must be provided"
|
|
4030
4030
|
};
|
|
4031
4031
|
try {
|
|
4032
|
-
const m = o.parentUid, y =
|
|
4032
|
+
const m = o.parentUid, y = St({
|
|
4033
4033
|
tree: d.tree,
|
|
4034
4034
|
request: {
|
|
4035
4035
|
parentNodeId: m,
|
|
@@ -4041,8 +4041,8 @@ async function Vs(t, r, s) {
|
|
|
4041
4041
|
maxTokensGroup: u
|
|
4042
4042
|
}
|
|
4043
4043
|
},
|
|
4044
|
-
indexRangeGroupStrategy: new
|
|
4045
|
-
}), w =
|
|
4044
|
+
indexRangeGroupStrategy: new Vs()
|
|
4045
|
+
}), w = xt(y);
|
|
4046
4046
|
return {
|
|
4047
4047
|
domSnapshot: d,
|
|
4048
4048
|
queryCreated: h,
|
|
@@ -4057,16 +4057,16 @@ async function Vs(t, r, s) {
|
|
|
4057
4057
|
};
|
|
4058
4058
|
}
|
|
4059
4059
|
}
|
|
4060
|
-
function
|
|
4060
|
+
function Xs(t, r) {
|
|
4061
4061
|
t(
|
|
4062
4062
|
"playwright-dom-snapshot-browse",
|
|
4063
4063
|
{
|
|
4064
4064
|
title: "Browse DOM Snapshot",
|
|
4065
4065
|
description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
|
|
4066
|
-
inputSchema:
|
|
4066
|
+
inputSchema: qt.shape
|
|
4067
4067
|
},
|
|
4068
4068
|
async (s, o) => {
|
|
4069
|
-
const e = await
|
|
4069
|
+
const e = await Zs(s, r, o);
|
|
4070
4070
|
if (e.error != null)
|
|
4071
4071
|
return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
|
|
4072
4072
|
❌ Error: ${e.error}`;
|
|
@@ -4087,13 +4087,13 @@ ${e.report}`, n;
|
|
|
4087
4087
|
}
|
|
4088
4088
|
);
|
|
4089
4089
|
}
|
|
4090
|
-
function
|
|
4091
|
-
r.browserCreate &&
|
|
4090
|
+
function eo(t, r) {
|
|
4091
|
+
r.browserCreate && vs(t, r), r.browserList && ks(t, r), r.browserClose && Ds(t, r), r.contextCreate && Rs(t, r), r.contextList && Bs(t, r), r.contextClose && Ps(t, r), r.pageCreate && Us(t, r), r.pageList && _s(t, r), r.pageClose && Js(t, r), r.pageGoto && Ks(t, r), r.domSnapshotQueryCreate && Ws(t, r), r.domSnapshotCreate && Ys(t, r), r.domSnapshotBrowse && Xs(t, r), console.log("Playwright manager");
|
|
4092
4092
|
}
|
|
4093
|
-
function
|
|
4093
|
+
function to(t) {
|
|
4094
4094
|
const { logFilePath: r } = t;
|
|
4095
4095
|
return async function(o, e, n, a) {
|
|
4096
|
-
await
|
|
4096
|
+
await ie({
|
|
4097
4097
|
logFilePath: r,
|
|
4098
4098
|
message: "ERROR",
|
|
4099
4099
|
data: {
|
|
@@ -4112,25 +4112,25 @@ function eo(t) {
|
|
|
4112
4112
|
});
|
|
4113
4113
|
};
|
|
4114
4114
|
}
|
|
4115
|
-
function
|
|
4115
|
+
function _t() {
|
|
4116
4116
|
return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
|
|
4117
4117
|
}
|
|
4118
|
-
function
|
|
4119
|
-
const r =
|
|
4118
|
+
function ro(t) {
|
|
4119
|
+
const r = ne(), s = so();
|
|
4120
4120
|
return r.use(s), r;
|
|
4121
4121
|
}
|
|
4122
|
-
function
|
|
4123
|
-
const r =
|
|
4122
|
+
function so(t) {
|
|
4123
|
+
const r = ne.Router();
|
|
4124
4124
|
return r.use((s, o, e) => {
|
|
4125
4125
|
s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
|
|
4126
|
-
}), r.use(
|
|
4126
|
+
}), r.use(ne.json()), r;
|
|
4127
4127
|
}
|
|
4128
|
-
function
|
|
4129
|
-
const r =
|
|
4130
|
-
return r.use(
|
|
4128
|
+
function oo(t) {
|
|
4129
|
+
const r = ne.Router();
|
|
4130
|
+
return r.use(rr({ authToken: t.authToken })), r.all("/mcp", ar(t)), r;
|
|
4131
4131
|
}
|
|
4132
|
-
function
|
|
4133
|
-
return t.use(
|
|
4132
|
+
function no(t, r) {
|
|
4133
|
+
return t.use(to({ logFilePath: r.logFilePath })), new Promise((s, o) => {
|
|
4134
4134
|
let e;
|
|
4135
4135
|
const n = () => {
|
|
4136
4136
|
s(e);
|
|
@@ -4144,7 +4144,7 @@ function oo(t, r) {
|
|
|
4144
4144
|
}
|
|
4145
4145
|
});
|
|
4146
4146
|
}
|
|
4147
|
-
function
|
|
4147
|
+
function io(t, r) {
|
|
4148
4148
|
if (!t.address())
|
|
4149
4149
|
throw new Error(
|
|
4150
4150
|
"Server address is not available. Check your DNS and host configuration."
|
|
@@ -4162,35 +4162,35 @@ SSE Endpoint: ${a}/sse
|
|
|
4162
4162
|
|
|
4163
4163
|
Log File: ${R.resolve(r.logFilePath)}`;
|
|
4164
4164
|
}
|
|
4165
|
-
function
|
|
4166
|
-
const s = R.join(r.logDir,
|
|
4165
|
+
function ao(t, r) {
|
|
4166
|
+
const s = R.join(r.logDir, _t()), o = Or(t, {
|
|
4167
4167
|
logFilePath: s
|
|
4168
4168
|
});
|
|
4169
|
-
r.tools.processManager &&
|
|
4169
|
+
r.tools.processManager && kr(o, r.tools.processManager), r.tools.fsManager && Ns(o, r.tools.fsManager), r.tools.playwrightManager && eo(o, {
|
|
4170
4170
|
...r.tools.playwrightManager
|
|
4171
|
-
}),
|
|
4171
|
+
}), xr(o);
|
|
4172
4172
|
}
|
|
4173
|
-
async function
|
|
4174
|
-
const r = R.join(t.logDir,
|
|
4173
|
+
async function Co(t) {
|
|
4174
|
+
const r = R.join(t.logDir, _t()), s = ro(), o = oo({
|
|
4175
4175
|
...t,
|
|
4176
4176
|
logFilePath: r,
|
|
4177
4177
|
createMcpServer: () => {
|
|
4178
|
-
const n = new
|
|
4178
|
+
const n = new Gt({
|
|
4179
4179
|
title: t.title,
|
|
4180
4180
|
name: t.name,
|
|
4181
4181
|
version: t.version
|
|
4182
4182
|
});
|
|
4183
|
-
return
|
|
4183
|
+
return ao(n, t), n;
|
|
4184
4184
|
}
|
|
4185
4185
|
});
|
|
4186
4186
|
s.use(o);
|
|
4187
|
-
const e = await
|
|
4187
|
+
const e = await no(s, {
|
|
4188
4188
|
host: t.host,
|
|
4189
4189
|
port: t.port,
|
|
4190
4190
|
logFilePath: r
|
|
4191
4191
|
});
|
|
4192
4192
|
return console.log(
|
|
4193
|
-
|
|
4193
|
+
io(e, {
|
|
4194
4194
|
title: t.title,
|
|
4195
4195
|
name: t.name,
|
|
4196
4196
|
version: t.version,
|
|
@@ -4199,10 +4199,10 @@ async function To(t) {
|
|
|
4199
4199
|
), e;
|
|
4200
4200
|
}
|
|
4201
4201
|
export {
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4202
|
+
To as A,
|
|
4203
|
+
Mo as S,
|
|
4204
|
+
Io as a,
|
|
4205
|
+
$o as b,
|
|
4206
|
+
Gr as p,
|
|
4207
|
+
Co as s
|
|
4208
4208
|
};
|