@react-grab/claude-code 0.0.78 → 0.0.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1,18 +1,20 @@
1
- import net from 'net';
2
- import { pathToFileURL, fileURLToPath } from 'url';
1
+ import childProcess2, { ChildProcess, execSync, spawn } from 'child_process';
2
+ import { fileURLToPath, pathToFileURL } from 'url';
3
3
  import { createServer as createServer$1 } from 'http';
4
4
  import { Http2ServerRequest } from 'http2';
5
5
  import { Readable } from 'stream';
6
6
  import crypto, { randomUUID } from 'crypto';
7
- import { dirname, join } from 'path';
7
+ import process2, { cwd } from 'process';
8
+ import { Buffer as Buffer$1 } from 'buffer';
9
+ import path, { dirname, join } from 'path';
10
+ import os, { constants, homedir } from 'os';
11
+ import * as fs from 'fs';
12
+ import { realpathSync, createReadStream, createWriteStream } from 'fs';
13
+ import { setTimeout as setTimeout$1 } from 'timers/promises';
14
+ import { debuglog, promisify } from 'util';
8
15
  import { setMaxListeners } from 'events';
9
- import { spawn } from 'child_process';
10
16
  import { createInterface } from 'readline';
11
- import * as fs from 'fs';
12
- import { realpathSync } from 'fs';
13
17
  import { stat } from 'fs/promises';
14
- import { homedir } from 'os';
15
- import { cwd } from 'process';
16
18
 
17
19
  var __create = Object.create;
18
20
  var __defProp = Object.defineProperty;
@@ -20,7 +22,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
20
22
  var __getOwnPropNames = Object.getOwnPropertyNames;
21
23
  var __getProtoOf = Object.getPrototypeOf;
22
24
  var __hasOwnProp = Object.prototype.hasOwnProperty;
23
- var __commonJS = (cb, mod) => function __require() {
25
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
26
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
27
+ }) : x)(function(x) {
28
+ if (typeof require !== "undefined") return require.apply(this, arguments);
29
+ throw Error('Dynamic require of "' + x + '" is not supported');
30
+ });
31
+ var __commonJS = (cb, mod) => function __require2() {
24
32
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
25
33
  };
26
34
  var __copyProps = (to, from, except, desc) => {
@@ -40,6 +48,827 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
40
48
  mod
41
49
  ));
42
50
 
51
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
52
+ var require_windows = __commonJS({
53
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
54
+ module.exports = isexe;
55
+ isexe.sync = sync;
56
+ var fs2 = __require("fs");
57
+ function checkPathExt(path5, options) {
58
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
59
+ if (!pathext) {
60
+ return true;
61
+ }
62
+ pathext = pathext.split(";");
63
+ if (pathext.indexOf("") !== -1) {
64
+ return true;
65
+ }
66
+ for (var i = 0; i < pathext.length; i++) {
67
+ var p = pathext[i].toLowerCase();
68
+ if (p && path5.substr(-p.length).toLowerCase() === p) {
69
+ return true;
70
+ }
71
+ }
72
+ return false;
73
+ }
74
+ function checkStat(stat, path5, options) {
75
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
76
+ return false;
77
+ }
78
+ return checkPathExt(path5, options);
79
+ }
80
+ function isexe(path5, options, cb) {
81
+ fs2.stat(path5, function(er, stat) {
82
+ cb(er, er ? false : checkStat(stat, path5, options));
83
+ });
84
+ }
85
+ function sync(path5, options) {
86
+ return checkStat(fs2.statSync(path5), path5, options);
87
+ }
88
+ }
89
+ });
90
+
91
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
92
+ var require_mode = __commonJS({
93
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
94
+ module.exports = isexe;
95
+ isexe.sync = sync;
96
+ var fs2 = __require("fs");
97
+ function isexe(path5, options, cb) {
98
+ fs2.stat(path5, function(er, stat) {
99
+ cb(er, er ? false : checkStat(stat, options));
100
+ });
101
+ }
102
+ function sync(path5, options) {
103
+ return checkStat(fs2.statSync(path5), options);
104
+ }
105
+ function checkStat(stat, options) {
106
+ return stat.isFile() && checkMode(stat, options);
107
+ }
108
+ function checkMode(stat, options) {
109
+ var mod = stat.mode;
110
+ var uid = stat.uid;
111
+ var gid = stat.gid;
112
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
113
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
114
+ var u = parseInt("100", 8);
115
+ var g = parseInt("010", 8);
116
+ var o = parseInt("001", 8);
117
+ var ug = u | g;
118
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
119
+ return ret;
120
+ }
121
+ }
122
+ });
123
+
124
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
125
+ var require_isexe = __commonJS({
126
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
127
+ __require("fs");
128
+ var core;
129
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
130
+ core = require_windows();
131
+ } else {
132
+ core = require_mode();
133
+ }
134
+ module.exports = isexe;
135
+ isexe.sync = sync;
136
+ function isexe(path5, options, cb) {
137
+ if (typeof options === "function") {
138
+ cb = options;
139
+ options = {};
140
+ }
141
+ if (!cb) {
142
+ if (typeof Promise !== "function") {
143
+ throw new TypeError("callback not provided");
144
+ }
145
+ return new Promise(function(resolve, reject) {
146
+ isexe(path5, options || {}, function(er, is) {
147
+ if (er) {
148
+ reject(er);
149
+ } else {
150
+ resolve(is);
151
+ }
152
+ });
153
+ });
154
+ }
155
+ core(path5, options || {}, function(er, is) {
156
+ if (er) {
157
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
158
+ er = null;
159
+ is = false;
160
+ }
161
+ }
162
+ cb(er, is);
163
+ });
164
+ }
165
+ function sync(path5, options) {
166
+ try {
167
+ return core.sync(path5, options || {});
168
+ } catch (er) {
169
+ if (options && options.ignoreErrors || er.code === "EACCES") {
170
+ return false;
171
+ } else {
172
+ throw er;
173
+ }
174
+ }
175
+ }
176
+ }
177
+ });
178
+
179
+ // ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
180
+ var require_which = __commonJS({
181
+ "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
182
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
183
+ var path5 = __require("path");
184
+ var COLON = isWindows ? ";" : ":";
185
+ var isexe = require_isexe();
186
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
187
+ var getPathInfo = (cmd, opt) => {
188
+ const colon = opt.colon || COLON;
189
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
190
+ // windows always checks the cwd first
191
+ ...isWindows ? [process.cwd()] : [],
192
+ ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
193
+ "").split(colon)
194
+ ];
195
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
196
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
197
+ if (isWindows) {
198
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
199
+ pathExt.unshift("");
200
+ }
201
+ return {
202
+ pathEnv,
203
+ pathExt,
204
+ pathExtExe
205
+ };
206
+ };
207
+ var which = (cmd, opt, cb) => {
208
+ if (typeof opt === "function") {
209
+ cb = opt;
210
+ opt = {};
211
+ }
212
+ if (!opt)
213
+ opt = {};
214
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
215
+ const found = [];
216
+ const step = (i) => new Promise((resolve, reject) => {
217
+ if (i === pathEnv.length)
218
+ return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
219
+ const ppRaw = pathEnv[i];
220
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
221
+ const pCmd = path5.join(pathPart, cmd);
222
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
223
+ resolve(subStep(p, i, 0));
224
+ });
225
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
226
+ if (ii === pathExt.length)
227
+ return resolve(step(i + 1));
228
+ const ext = pathExt[ii];
229
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
230
+ if (!er && is) {
231
+ if (opt.all)
232
+ found.push(p + ext);
233
+ else
234
+ return resolve(p + ext);
235
+ }
236
+ return resolve(subStep(p, i, ii + 1));
237
+ });
238
+ });
239
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
240
+ };
241
+ var whichSync = (cmd, opt) => {
242
+ opt = opt || {};
243
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
244
+ const found = [];
245
+ for (let i = 0; i < pathEnv.length; i++) {
246
+ const ppRaw = pathEnv[i];
247
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
248
+ const pCmd = path5.join(pathPart, cmd);
249
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
250
+ for (let j = 0; j < pathExt.length; j++) {
251
+ const cur = p + pathExt[j];
252
+ try {
253
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
254
+ if (is) {
255
+ if (opt.all)
256
+ found.push(cur);
257
+ else
258
+ return cur;
259
+ }
260
+ } catch (ex) {
261
+ }
262
+ }
263
+ }
264
+ if (opt.all && found.length)
265
+ return found;
266
+ if (opt.nothrow)
267
+ return null;
268
+ throw getNotFoundError(cmd);
269
+ };
270
+ module.exports = which;
271
+ which.sync = whichSync;
272
+ }
273
+ });
274
+
275
+ // ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
276
+ var require_path_key = __commonJS({
277
+ "../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
278
+ var pathKey2 = (options = {}) => {
279
+ const environment = options.env || process.env;
280
+ const platform = options.platform || process.platform;
281
+ if (platform !== "win32") {
282
+ return "PATH";
283
+ }
284
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
285
+ };
286
+ module.exports = pathKey2;
287
+ module.exports.default = pathKey2;
288
+ }
289
+ });
290
+
291
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
292
+ var require_resolveCommand = __commonJS({
293
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
294
+ var path5 = __require("path");
295
+ var which = require_which();
296
+ var getPathKey = require_path_key();
297
+ function resolveCommandAttempt(parsed, withoutPathExt) {
298
+ const env = parsed.options.env || process.env;
299
+ const cwd2 = process.cwd();
300
+ const hasCustomCwd = parsed.options.cwd != null;
301
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
302
+ if (shouldSwitchCwd) {
303
+ try {
304
+ process.chdir(parsed.options.cwd);
305
+ } catch (err) {
306
+ }
307
+ }
308
+ let resolved;
309
+ try {
310
+ resolved = which.sync(parsed.command, {
311
+ path: env[getPathKey({ env })],
312
+ pathExt: withoutPathExt ? path5.delimiter : void 0
313
+ });
314
+ } catch (e) {
315
+ } finally {
316
+ if (shouldSwitchCwd) {
317
+ process.chdir(cwd2);
318
+ }
319
+ }
320
+ if (resolved) {
321
+ resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
322
+ }
323
+ return resolved;
324
+ }
325
+ function resolveCommand(parsed) {
326
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
327
+ }
328
+ module.exports = resolveCommand;
329
+ }
330
+ });
331
+
332
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
333
+ var require_escape = __commonJS({
334
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
335
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
336
+ function escapeCommand(arg) {
337
+ arg = arg.replace(metaCharsRegExp, "^$1");
338
+ return arg;
339
+ }
340
+ function escapeArgument(arg, doubleEscapeMetaChars) {
341
+ arg = `${arg}`;
342
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
343
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
344
+ arg = `"${arg}"`;
345
+ arg = arg.replace(metaCharsRegExp, "^$1");
346
+ if (doubleEscapeMetaChars) {
347
+ arg = arg.replace(metaCharsRegExp, "^$1");
348
+ }
349
+ return arg;
350
+ }
351
+ module.exports.command = escapeCommand;
352
+ module.exports.argument = escapeArgument;
353
+ }
354
+ });
355
+
356
+ // ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
357
+ var require_shebang_regex = __commonJS({
358
+ "../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
359
+ module.exports = /^#!(.*)/;
360
+ }
361
+ });
362
+
363
+ // ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
364
+ var require_shebang_command = __commonJS({
365
+ "../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
366
+ var shebangRegex = require_shebang_regex();
367
+ module.exports = (string = "") => {
368
+ const match2 = string.match(shebangRegex);
369
+ if (!match2) {
370
+ return null;
371
+ }
372
+ const [path5, argument] = match2[0].replace(/#! ?/, "").split(" ");
373
+ const binary = path5.split("/").pop();
374
+ if (binary === "env") {
375
+ return argument;
376
+ }
377
+ return argument ? `${binary} ${argument}` : binary;
378
+ };
379
+ }
380
+ });
381
+
382
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
383
+ var require_readShebang = __commonJS({
384
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
385
+ var fs2 = __require("fs");
386
+ var shebangCommand = require_shebang_command();
387
+ function readShebang(command) {
388
+ const size = 150;
389
+ const buffer = Buffer.alloc(size);
390
+ let fd;
391
+ try {
392
+ fd = fs2.openSync(command, "r");
393
+ fs2.readSync(fd, buffer, 0, size, 0);
394
+ fs2.closeSync(fd);
395
+ } catch (e) {
396
+ }
397
+ return shebangCommand(buffer.toString());
398
+ }
399
+ module.exports = readShebang;
400
+ }
401
+ });
402
+
403
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
404
+ var require_parse = __commonJS({
405
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
406
+ var path5 = __require("path");
407
+ var resolveCommand = require_resolveCommand();
408
+ var escape = require_escape();
409
+ var readShebang = require_readShebang();
410
+ var isWin = process.platform === "win32";
411
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
412
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
413
+ function detectShebang(parsed) {
414
+ parsed.file = resolveCommand(parsed);
415
+ const shebang = parsed.file && readShebang(parsed.file);
416
+ if (shebang) {
417
+ parsed.args.unshift(parsed.file);
418
+ parsed.command = shebang;
419
+ return resolveCommand(parsed);
420
+ }
421
+ return parsed.file;
422
+ }
423
+ function parseNonShell(parsed) {
424
+ if (!isWin) {
425
+ return parsed;
426
+ }
427
+ const commandFile = detectShebang(parsed);
428
+ const needsShell = !isExecutableRegExp.test(commandFile);
429
+ if (parsed.options.forceShell || needsShell) {
430
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
431
+ parsed.command = path5.normalize(parsed.command);
432
+ parsed.command = escape.command(parsed.command);
433
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
434
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
435
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
436
+ parsed.command = process.env.comspec || "cmd.exe";
437
+ parsed.options.windowsVerbatimArguments = true;
438
+ }
439
+ return parsed;
440
+ }
441
+ function parse(command, args, options) {
442
+ if (args && !Array.isArray(args)) {
443
+ options = args;
444
+ args = null;
445
+ }
446
+ args = args ? args.slice(0) : [];
447
+ options = Object.assign({}, options);
448
+ const parsed = {
449
+ command,
450
+ args,
451
+ options,
452
+ file: void 0,
453
+ original: {
454
+ command,
455
+ args
456
+ }
457
+ };
458
+ return options.shell ? parsed : parseNonShell(parsed);
459
+ }
460
+ module.exports = parse;
461
+ }
462
+ });
463
+
464
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
465
+ var require_enoent = __commonJS({
466
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
467
+ var isWin = process.platform === "win32";
468
+ function notFoundError(original, syscall) {
469
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
470
+ code: "ENOENT",
471
+ errno: "ENOENT",
472
+ syscall: `${syscall} ${original.command}`,
473
+ path: original.command,
474
+ spawnargs: original.args
475
+ });
476
+ }
477
+ function hookChildProcess(cp, parsed) {
478
+ if (!isWin) {
479
+ return;
480
+ }
481
+ const originalEmit = cp.emit;
482
+ cp.emit = function(name, arg1) {
483
+ if (name === "exit") {
484
+ const err = verifyENOENT(arg1, parsed);
485
+ if (err) {
486
+ return originalEmit.call(cp, "error", err);
487
+ }
488
+ }
489
+ return originalEmit.apply(cp, arguments);
490
+ };
491
+ }
492
+ function verifyENOENT(status, parsed) {
493
+ if (isWin && status === 1 && !parsed.file) {
494
+ return notFoundError(parsed.original, "spawn");
495
+ }
496
+ return null;
497
+ }
498
+ function verifyENOENTSync(status, parsed) {
499
+ if (isWin && status === 1 && !parsed.file) {
500
+ return notFoundError(parsed.original, "spawnSync");
501
+ }
502
+ return null;
503
+ }
504
+ module.exports = {
505
+ hookChildProcess,
506
+ verifyENOENT,
507
+ verifyENOENTSync,
508
+ notFoundError
509
+ };
510
+ }
511
+ });
512
+
513
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
514
+ var require_cross_spawn = __commonJS({
515
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
516
+ var cp = __require("child_process");
517
+ var parse = require_parse();
518
+ var enoent = require_enoent();
519
+ function spawn2(command, args, options) {
520
+ const parsed = parse(command, args, options);
521
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
522
+ enoent.hookChildProcess(spawned, parsed);
523
+ return spawned;
524
+ }
525
+ function spawnSync(command, args, options) {
526
+ const parsed = parse(command, args, options);
527
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
528
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
529
+ return result;
530
+ }
531
+ module.exports = spawn2;
532
+ module.exports.spawn = spawn2;
533
+ module.exports.sync = spawnSync;
534
+ module.exports._parse = parse;
535
+ module.exports._enoent = enoent;
536
+ }
537
+ });
538
+
539
+ // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js
540
+ var require_signals = __commonJS({
541
+ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js"(exports, module) {
542
+ module.exports = [
543
+ "SIGABRT",
544
+ "SIGALRM",
545
+ "SIGHUP",
546
+ "SIGINT",
547
+ "SIGTERM"
548
+ ];
549
+ if (process.platform !== "win32") {
550
+ module.exports.push(
551
+ "SIGVTALRM",
552
+ "SIGXCPU",
553
+ "SIGXFSZ",
554
+ "SIGUSR2",
555
+ "SIGTRAP",
556
+ "SIGSYS",
557
+ "SIGQUIT",
558
+ "SIGIOT"
559
+ // should detect profiler and enable/disable accordingly.
560
+ // see #21
561
+ // 'SIGPROF'
562
+ );
563
+ }
564
+ if (process.platform === "linux") {
565
+ module.exports.push(
566
+ "SIGIO",
567
+ "SIGPOLL",
568
+ "SIGPWR",
569
+ "SIGSTKFLT",
570
+ "SIGUNUSED"
571
+ );
572
+ }
573
+ }
574
+ });
575
+
576
+ // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js
577
+ var require_signal_exit = __commonJS({
578
+ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports, module) {
579
+ var process13 = global.process;
580
+ var processOk2 = function(process14) {
581
+ return process14 && typeof process14 === "object" && typeof process14.removeListener === "function" && typeof process14.emit === "function" && typeof process14.reallyExit === "function" && typeof process14.listeners === "function" && typeof process14.kill === "function" && typeof process14.pid === "number" && typeof process14.on === "function";
582
+ };
583
+ if (!processOk2(process13)) {
584
+ module.exports = function() {
585
+ return function() {
586
+ };
587
+ };
588
+ } else {
589
+ assert = __require("assert");
590
+ signals2 = require_signals();
591
+ isWin = /^win/i.test(process13.platform);
592
+ EE = __require("events");
593
+ if (typeof EE !== "function") {
594
+ EE = EE.EventEmitter;
595
+ }
596
+ if (process13.__signal_exit_emitter__) {
597
+ emitter = process13.__signal_exit_emitter__;
598
+ } else {
599
+ emitter = process13.__signal_exit_emitter__ = new EE();
600
+ emitter.count = 0;
601
+ emitter.emitted = {};
602
+ }
603
+ if (!emitter.infinite) {
604
+ emitter.setMaxListeners(Infinity);
605
+ emitter.infinite = true;
606
+ }
607
+ module.exports = function(cb, opts) {
608
+ if (!processOk2(global.process)) {
609
+ return function() {
610
+ };
611
+ }
612
+ assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
613
+ if (loaded === false) {
614
+ load2();
615
+ }
616
+ var ev = "exit";
617
+ if (opts && opts.alwaysLast) {
618
+ ev = "afterexit";
619
+ }
620
+ var remove = function() {
621
+ emitter.removeListener(ev, cb);
622
+ if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
623
+ unload2();
624
+ }
625
+ };
626
+ emitter.on(ev, cb);
627
+ return remove;
628
+ };
629
+ unload2 = function unload3() {
630
+ if (!loaded || !processOk2(global.process)) {
631
+ return;
632
+ }
633
+ loaded = false;
634
+ signals2.forEach(function(sig) {
635
+ try {
636
+ process13.removeListener(sig, sigListeners[sig]);
637
+ } catch (er) {
638
+ }
639
+ });
640
+ process13.emit = originalProcessEmit;
641
+ process13.reallyExit = originalProcessReallyExit;
642
+ emitter.count -= 1;
643
+ };
644
+ module.exports.unload = unload2;
645
+ emit = function emit2(event, code, signal) {
646
+ if (emitter.emitted[event]) {
647
+ return;
648
+ }
649
+ emitter.emitted[event] = true;
650
+ emitter.emit(event, code, signal);
651
+ };
652
+ sigListeners = {};
653
+ signals2.forEach(function(sig) {
654
+ sigListeners[sig] = function listener() {
655
+ if (!processOk2(global.process)) {
656
+ return;
657
+ }
658
+ var listeners = process13.listeners(sig);
659
+ if (listeners.length === emitter.count) {
660
+ unload2();
661
+ emit("exit", null, sig);
662
+ emit("afterexit", null, sig);
663
+ if (isWin && sig === "SIGHUP") {
664
+ sig = "SIGINT";
665
+ }
666
+ process13.kill(process13.pid, sig);
667
+ }
668
+ };
669
+ });
670
+ module.exports.signals = function() {
671
+ return signals2;
672
+ };
673
+ loaded = false;
674
+ load2 = function load3() {
675
+ if (loaded || !processOk2(global.process)) {
676
+ return;
677
+ }
678
+ loaded = true;
679
+ emitter.count += 1;
680
+ signals2 = signals2.filter(function(sig) {
681
+ try {
682
+ process13.on(sig, sigListeners[sig]);
683
+ return true;
684
+ } catch (er) {
685
+ return false;
686
+ }
687
+ });
688
+ process13.emit = processEmit;
689
+ process13.reallyExit = processReallyExit;
690
+ };
691
+ module.exports.load = load2;
692
+ originalProcessReallyExit = process13.reallyExit;
693
+ processReallyExit = function processReallyExit2(code) {
694
+ if (!processOk2(global.process)) {
695
+ return;
696
+ }
697
+ process13.exitCode = code || /* istanbul ignore next */
698
+ 0;
699
+ emit("exit", process13.exitCode, null);
700
+ emit("afterexit", process13.exitCode, null);
701
+ originalProcessReallyExit.call(process13, process13.exitCode);
702
+ };
703
+ originalProcessEmit = process13.emit;
704
+ processEmit = function processEmit2(ev, arg) {
705
+ if (ev === "exit" && processOk2(global.process)) {
706
+ if (arg !== void 0) {
707
+ process13.exitCode = arg;
708
+ }
709
+ var ret = originalProcessEmit.apply(this, arguments);
710
+ emit("exit", process13.exitCode, null);
711
+ emit("afterexit", process13.exitCode, null);
712
+ return ret;
713
+ } else {
714
+ return originalProcessEmit.apply(this, arguments);
715
+ }
716
+ };
717
+ }
718
+ var assert;
719
+ var signals2;
720
+ var isWin;
721
+ var EE;
722
+ var emitter;
723
+ var unload2;
724
+ var emit;
725
+ var sigListeners;
726
+ var loaded;
727
+ var load2;
728
+ var originalProcessReallyExit;
729
+ var processReallyExit;
730
+ var originalProcessEmit;
731
+ var processEmit;
732
+ }
733
+ });
734
+
735
+ // ../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js
736
+ var require_buffer_stream = __commonJS({
737
+ "../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js"(exports, module) {
738
+ var { PassThrough: PassThroughStream } = __require("stream");
739
+ module.exports = (options) => {
740
+ options = { ...options };
741
+ const { array } = options;
742
+ let { encoding } = options;
743
+ const isBuffer = encoding === "buffer";
744
+ let objectMode = false;
745
+ if (array) {
746
+ objectMode = !(encoding || isBuffer);
747
+ } else {
748
+ encoding = encoding || "utf8";
749
+ }
750
+ if (isBuffer) {
751
+ encoding = null;
752
+ }
753
+ const stream2 = new PassThroughStream({ objectMode });
754
+ if (encoding) {
755
+ stream2.setEncoding(encoding);
756
+ }
757
+ let length = 0;
758
+ const chunks = [];
759
+ stream2.on("data", (chunk) => {
760
+ chunks.push(chunk);
761
+ if (objectMode) {
762
+ length = chunks.length;
763
+ } else {
764
+ length += chunk.length;
765
+ }
766
+ });
767
+ stream2.getBufferedValue = () => {
768
+ if (array) {
769
+ return chunks;
770
+ }
771
+ return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
772
+ };
773
+ stream2.getBufferedLength = () => length;
774
+ return stream2;
775
+ };
776
+ }
777
+ });
778
+
779
+ // ../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js
780
+ var require_get_stream = __commonJS({
781
+ "../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js"(exports, module) {
782
+ var { constants: BufferConstants } = __require("buffer");
783
+ var stream2 = __require("stream");
784
+ var { promisify: promisify2 } = __require("util");
785
+ var bufferStream = require_buffer_stream();
786
+ var streamPipelinePromisified = promisify2(stream2.pipeline);
787
+ var MaxBufferError2 = class extends Error {
788
+ constructor() {
789
+ super("maxBuffer exceeded");
790
+ this.name = "MaxBufferError";
791
+ }
792
+ };
793
+ async function getStream2(inputStream, options) {
794
+ if (!inputStream) {
795
+ throw new Error("Expected a stream");
796
+ }
797
+ options = {
798
+ maxBuffer: Infinity,
799
+ ...options
800
+ };
801
+ const { maxBuffer } = options;
802
+ const stream3 = bufferStream(options);
803
+ await new Promise((resolve, reject) => {
804
+ const rejectPromise = (error) => {
805
+ if (error && stream3.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
806
+ error.bufferedData = stream3.getBufferedValue();
807
+ }
808
+ reject(error);
809
+ };
810
+ (async () => {
811
+ try {
812
+ await streamPipelinePromisified(inputStream, stream3);
813
+ resolve();
814
+ } catch (error) {
815
+ rejectPromise(error);
816
+ }
817
+ })();
818
+ stream3.on("data", () => {
819
+ if (stream3.getBufferedLength() > maxBuffer) {
820
+ rejectPromise(new MaxBufferError2());
821
+ }
822
+ });
823
+ });
824
+ return stream3.getBufferedValue();
825
+ }
826
+ module.exports = getStream2;
827
+ module.exports.buffer = (stream3, options) => getStream2(stream3, { ...options, encoding: "buffer" });
828
+ module.exports.array = (stream3, options) => getStream2(stream3, { ...options, array: true });
829
+ module.exports.MaxBufferError = MaxBufferError2;
830
+ }
831
+ });
832
+
833
+ // ../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js
834
+ var require_merge_stream = __commonJS({
835
+ "../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js"(exports, module) {
836
+ var { PassThrough } = __require("stream");
837
+ module.exports = function() {
838
+ var sources = [];
839
+ var output = new PassThrough({ objectMode: true });
840
+ output.setMaxListeners(0);
841
+ output.add = add;
842
+ output.isEmpty = isEmpty;
843
+ output.on("unpipe", remove);
844
+ Array.prototype.slice.call(arguments).forEach(add);
845
+ return output;
846
+ function add(source) {
847
+ if (Array.isArray(source)) {
848
+ source.forEach(add);
849
+ return this;
850
+ }
851
+ sources.push(source);
852
+ source.once("end", remove.bind(null, source));
853
+ source.once("error", output.emit.bind(output, "error"));
854
+ source.pipe(output, { end: false });
855
+ return this;
856
+ }
857
+ function isEmpty() {
858
+ return sources.length == 0;
859
+ }
860
+ function remove(source) {
861
+ sources = sources.filter(function(it) {
862
+ return it !== source;
863
+ });
864
+ if (!sources.length && output.readable) {
865
+ output.end();
866
+ }
867
+ }
868
+ };
869
+ }
870
+ });
871
+
43
872
  // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
44
873
  var require_picocolors = __commonJS({
45
874
  "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
@@ -228,26 +1057,26 @@ var handleParsingNestedValues = (form, key, value) => {
228
1057
  };
229
1058
 
230
1059
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/utils/url.js
231
- var splitPath = (path) => {
232
- const paths = path.split("/");
1060
+ var splitPath = (path5) => {
1061
+ const paths = path5.split("/");
233
1062
  if (paths[0] === "") {
234
1063
  paths.shift();
235
1064
  }
236
1065
  return paths;
237
1066
  };
238
1067
  var splitRoutingPath = (routePath) => {
239
- const { groups, path } = extractGroupsFromPath(routePath);
240
- const paths = splitPath(path);
1068
+ const { groups, path: path5 } = extractGroupsFromPath(routePath);
1069
+ const paths = splitPath(path5);
241
1070
  return replaceGroupMarks(paths, groups);
242
1071
  };
243
- var extractGroupsFromPath = (path) => {
1072
+ var extractGroupsFromPath = (path5) => {
244
1073
  const groups = [];
245
- path = path.replace(/\{[^}]+\}/g, (match2, index) => {
1074
+ path5 = path5.replace(/\{[^}]+\}/g, (match2, index) => {
246
1075
  const mark = `@${index}`;
247
1076
  groups.push([mark, match2]);
248
1077
  return mark;
249
1078
  });
250
- return { groups, path };
1079
+ return { groups, path: path5 };
251
1080
  };
252
1081
  var replaceGroupMarks = (paths, groups) => {
253
1082
  for (let i = groups.length - 1; i >= 0; i--) {
@@ -302,8 +1131,8 @@ var getPath = (request) => {
302
1131
  const charCode = url.charCodeAt(i);
303
1132
  if (charCode === 37) {
304
1133
  const queryIndex = url.indexOf("?", i);
305
- const path = url.slice(start, queryIndex === -1 ? void 0 : queryIndex);
306
- return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
1134
+ const path5 = url.slice(start, queryIndex === -1 ? void 0 : queryIndex);
1135
+ return tryDecodeURI(path5.includes("%25") ? path5.replace(/%25/g, "%2525") : path5);
307
1136
  } else if (charCode === 63) {
308
1137
  break;
309
1138
  }
@@ -320,11 +1149,11 @@ var mergePath = (base, sub, ...rest) => {
320
1149
  }
321
1150
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
322
1151
  };
323
- var checkOptionalParameter = (path) => {
324
- if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
1152
+ var checkOptionalParameter = (path5) => {
1153
+ if (path5.charCodeAt(path5.length - 1) !== 63 || !path5.includes(":")) {
325
1154
  return null;
326
1155
  }
327
- const segments = path.split("/");
1156
+ const segments = path5.split("/");
328
1157
  const results = [];
329
1158
  let basePath = "";
330
1159
  segments.forEach((segment) => {
@@ -437,9 +1266,9 @@ var HonoRequest = class {
437
1266
  routeIndex = 0;
438
1267
  path;
439
1268
  bodyCache = {};
440
- constructor(request, path = "/", matchResult = [[]]) {
1269
+ constructor(request, path5 = "/", matchResult = [[]]) {
441
1270
  this.raw = request;
442
- this.path = path;
1271
+ this.path = path5;
443
1272
  this.#matchResult = matchResult;
444
1273
  this.#validatedData = {};
445
1274
  }
@@ -800,8 +1629,8 @@ var Hono = class {
800
1629
  return this;
801
1630
  };
802
1631
  });
803
- this.on = (method, path, ...handlers) => {
804
- for (const p of [path].flat()) {
1632
+ this.on = (method, path5, ...handlers) => {
1633
+ for (const p of [path5].flat()) {
805
1634
  this.#path = p;
806
1635
  for (const m of [method].flat()) {
807
1636
  handlers.map((handler) => {
@@ -839,8 +1668,8 @@ var Hono = class {
839
1668
  }
840
1669
  #notFoundHandler = notFoundHandler;
841
1670
  errorHandler = errorHandler;
842
- route(path, app) {
843
- const subApp = this.basePath(path);
1671
+ route(path5, app) {
1672
+ const subApp = this.basePath(path5);
844
1673
  app.routes.map((r) => {
845
1674
  let handler;
846
1675
  if (app.errorHandler === errorHandler) {
@@ -853,9 +1682,9 @@ var Hono = class {
853
1682
  });
854
1683
  return this;
855
1684
  }
856
- basePath(path) {
1685
+ basePath(path5) {
857
1686
  const subApp = this.#clone();
858
- subApp._basePath = mergePath(this._basePath, path);
1687
+ subApp._basePath = mergePath(this._basePath, path5);
859
1688
  return subApp;
860
1689
  }
861
1690
  onError = (handler) => {
@@ -866,7 +1695,7 @@ var Hono = class {
866
1695
  this.#notFoundHandler = handler;
867
1696
  return this;
868
1697
  };
869
- mount(path, applicationHandler, options) {
1698
+ mount(path5, applicationHandler, options) {
870
1699
  let replaceRequest;
871
1700
  let optionHandler;
872
1701
  if (options) {
@@ -893,7 +1722,7 @@ var Hono = class {
893
1722
  return [c.env, executionContext];
894
1723
  };
895
1724
  replaceRequest ||= (() => {
896
- const mergedPath = mergePath(this._basePath, path);
1725
+ const mergedPath = mergePath(this._basePath, path5);
897
1726
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
898
1727
  return (request) => {
899
1728
  const url = new URL(request.url);
@@ -908,14 +1737,14 @@ var Hono = class {
908
1737
  }
909
1738
  await next();
910
1739
  };
911
- this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
1740
+ this.#addRoute(METHOD_NAME_ALL, mergePath(path5, "*"), handler);
912
1741
  return this;
913
1742
  }
914
- #addRoute(method, path, handler) {
1743
+ #addRoute(method, path5, handler) {
915
1744
  method = method.toUpperCase();
916
- path = mergePath(this._basePath, path);
917
- const r = { basePath: this._basePath, path, method, handler };
918
- this.router.add(method, path, [handler, r]);
1745
+ path5 = mergePath(this._basePath, path5);
1746
+ const r = { basePath: this._basePath, path: path5, method, handler };
1747
+ this.router.add(method, path5, [handler, r]);
919
1748
  this.routes.push(r);
920
1749
  }
921
1750
  #handleError(err, c) {
@@ -928,10 +1757,10 @@ var Hono = class {
928
1757
  if (method === "HEAD") {
929
1758
  return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
930
1759
  }
931
- const path = this.getPath(request, { env });
932
- const matchResult = this.router.match(method, path);
1760
+ const path5 = this.getPath(request, { env });
1761
+ const matchResult = this.router.match(method, path5);
933
1762
  const c = new Context(request, {
934
- path,
1763
+ path: path5,
935
1764
  matchResult,
936
1765
  env,
937
1766
  executionCtx,
@@ -991,15 +1820,15 @@ var Hono = class {
991
1820
 
992
1821
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/router/reg-exp-router/matcher.js
993
1822
  var emptyParam = [];
994
- function match(method, path) {
1823
+ function match(method, path5) {
995
1824
  const matchers = this.buildAllMatchers();
996
- const match2 = (method2, path2) => {
1825
+ const match2 = (method2, path22) => {
997
1826
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
998
- const staticMatch = matcher[2][path2];
1827
+ const staticMatch = matcher[2][path22];
999
1828
  if (staticMatch) {
1000
1829
  return staticMatch;
1001
1830
  }
1002
- const match3 = path2.match(matcher[0]);
1831
+ const match3 = path22.match(matcher[0]);
1003
1832
  if (!match3) {
1004
1833
  return [[], emptyParam];
1005
1834
  }
@@ -1007,7 +1836,7 @@ function match(method, path) {
1007
1836
  return [matcher[1][index], match3];
1008
1837
  };
1009
1838
  this.match = match2;
1010
- return match2(method, path);
1839
+ return match2(method, path5);
1011
1840
  }
1012
1841
 
1013
1842
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/router/reg-exp-router/node.js
@@ -1122,12 +1951,12 @@ var Node = class {
1122
1951
  var Trie = class {
1123
1952
  #context = { varIndex: 0 };
1124
1953
  #root = new Node();
1125
- insert(path, index, pathErrorCheckOnly) {
1954
+ insert(path5, index, pathErrorCheckOnly) {
1126
1955
  const paramAssoc = [];
1127
1956
  const groups = [];
1128
1957
  for (let i = 0; ; ) {
1129
1958
  let replaced = false;
1130
- path = path.replace(/\{[^}]+\}/g, (m) => {
1959
+ path5 = path5.replace(/\{[^}]+\}/g, (m) => {
1131
1960
  const mark = `@\\${i}`;
1132
1961
  groups[i] = [mark, m];
1133
1962
  i++;
@@ -1138,7 +1967,7 @@ var Trie = class {
1138
1967
  break;
1139
1968
  }
1140
1969
  }
1141
- const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1970
+ const tokens = path5.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1142
1971
  for (let i = groups.length - 1; i >= 0; i--) {
1143
1972
  const [mark] = groups[i];
1144
1973
  for (let j = tokens.length - 1; j >= 0; j--) {
@@ -1177,9 +2006,9 @@ var Trie = class {
1177
2006
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/router/reg-exp-router/router.js
1178
2007
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
1179
2008
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1180
- function buildWildcardRegExp(path) {
1181
- return wildcardRegExpCache[path] ??= new RegExp(
1182
- path === "*" ? "" : `^${path.replace(
2009
+ function buildWildcardRegExp(path5) {
2010
+ return wildcardRegExpCache[path5] ??= new RegExp(
2011
+ path5 === "*" ? "" : `^${path5.replace(
1183
2012
  /\/\*$|([.\\+*[^\]$()])/g,
1184
2013
  (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
1185
2014
  )}$`
@@ -1201,17 +2030,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
1201
2030
  );
1202
2031
  const staticMap = /* @__PURE__ */ Object.create(null);
1203
2032
  for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
1204
- const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
2033
+ const [pathErrorCheckOnly, path5, handlers] = routesWithStaticPathFlag[i];
1205
2034
  if (pathErrorCheckOnly) {
1206
- staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
2035
+ staticMap[path5] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
1207
2036
  } else {
1208
2037
  j++;
1209
2038
  }
1210
2039
  let paramAssoc;
1211
2040
  try {
1212
- paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
2041
+ paramAssoc = trie.insert(path5, j, pathErrorCheckOnly);
1213
2042
  } catch (e) {
1214
- throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
2043
+ throw e === PATH_ERROR ? new UnsupportedPathError(path5) : e;
1215
2044
  }
1216
2045
  if (pathErrorCheckOnly) {
1217
2046
  continue;
@@ -1245,12 +2074,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
1245
2074
  }
1246
2075
  return [regexp, handlerMap, staticMap];
1247
2076
  }
1248
- function findMiddleware(middleware, path) {
2077
+ function findMiddleware(middleware, path5) {
1249
2078
  if (!middleware) {
1250
2079
  return void 0;
1251
2080
  }
1252
2081
  for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
1253
- if (buildWildcardRegExp(k).test(path)) {
2082
+ if (buildWildcardRegExp(k).test(path5)) {
1254
2083
  return [...middleware[k]];
1255
2084
  }
1256
2085
  }
@@ -1264,7 +2093,7 @@ var RegExpRouter = class {
1264
2093
  this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
1265
2094
  this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
1266
2095
  }
1267
- add(method, path, handler) {
2096
+ add(method, path5, handler) {
1268
2097
  const middleware = this.#middleware;
1269
2098
  const routes = this.#routes;
1270
2099
  if (!middleware || !routes) {
@@ -1278,18 +2107,18 @@ var RegExpRouter = class {
1278
2107
  });
1279
2108
  });
1280
2109
  }
1281
- if (path === "/*") {
1282
- path = "*";
2110
+ if (path5 === "/*") {
2111
+ path5 = "*";
1283
2112
  }
1284
- const paramCount = (path.match(/\/:/g) || []).length;
1285
- if (/\*$/.test(path)) {
1286
- const re = buildWildcardRegExp(path);
2113
+ const paramCount = (path5.match(/\/:/g) || []).length;
2114
+ if (/\*$/.test(path5)) {
2115
+ const re = buildWildcardRegExp(path5);
1287
2116
  if (method === METHOD_NAME_ALL) {
1288
2117
  Object.keys(middleware).forEach((m) => {
1289
- middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
2118
+ middleware[m][path5] ||= findMiddleware(middleware[m], path5) || findMiddleware(middleware[METHOD_NAME_ALL], path5) || [];
1290
2119
  });
1291
2120
  } else {
1292
- middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
2121
+ middleware[method][path5] ||= findMiddleware(middleware[method], path5) || findMiddleware(middleware[METHOD_NAME_ALL], path5) || [];
1293
2122
  }
1294
2123
  Object.keys(middleware).forEach((m) => {
1295
2124
  if (method === METHOD_NAME_ALL || method === m) {
@@ -1307,15 +2136,15 @@ var RegExpRouter = class {
1307
2136
  });
1308
2137
  return;
1309
2138
  }
1310
- const paths = checkOptionalParameter(path) || [path];
2139
+ const paths = checkOptionalParameter(path5) || [path5];
1311
2140
  for (let i = 0, len = paths.length; i < len; i++) {
1312
- const path2 = paths[i];
2141
+ const path22 = paths[i];
1313
2142
  Object.keys(routes).forEach((m) => {
1314
2143
  if (method === METHOD_NAME_ALL || method === m) {
1315
- routes[m][path2] ||= [
1316
- ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
2144
+ routes[m][path22] ||= [
2145
+ ...findMiddleware(middleware[m], path22) || findMiddleware(middleware[METHOD_NAME_ALL], path22) || []
1317
2146
  ];
1318
- routes[m][path2].push([handler, paramCount - len + i + 1]);
2147
+ routes[m][path22].push([handler, paramCount - len + i + 1]);
1319
2148
  }
1320
2149
  });
1321
2150
  }
@@ -1334,13 +2163,13 @@ var RegExpRouter = class {
1334
2163
  const routes = [];
1335
2164
  let hasOwnRoute = method === METHOD_NAME_ALL;
1336
2165
  [this.#middleware, this.#routes].forEach((r) => {
1337
- const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];
2166
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path5) => [path5, r[method][path5]]) : [];
1338
2167
  if (ownRoute.length !== 0) {
1339
2168
  hasOwnRoute ||= true;
1340
2169
  routes.push(...ownRoute);
1341
2170
  } else if (method !== METHOD_NAME_ALL) {
1342
2171
  routes.push(
1343
- ...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]])
2172
+ ...Object.keys(r[METHOD_NAME_ALL]).map((path5) => [path5, r[METHOD_NAME_ALL][path5]])
1344
2173
  );
1345
2174
  }
1346
2175
  });
@@ -1360,13 +2189,13 @@ var SmartRouter = class {
1360
2189
  constructor(init) {
1361
2190
  this.#routers = init.routers;
1362
2191
  }
1363
- add(method, path, handler) {
2192
+ add(method, path5, handler) {
1364
2193
  if (!this.#routes) {
1365
2194
  throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1366
2195
  }
1367
- this.#routes.push([method, path, handler]);
2196
+ this.#routes.push([method, path5, handler]);
1368
2197
  }
1369
- match(method, path) {
2198
+ match(method, path5) {
1370
2199
  if (!this.#routes) {
1371
2200
  throw new Error("Fatal error");
1372
2201
  }
@@ -1381,7 +2210,7 @@ var SmartRouter = class {
1381
2210
  for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
1382
2211
  router.add(...routes[i2]);
1383
2212
  }
1384
- res = router.match(method, path);
2213
+ res = router.match(method, path5);
1385
2214
  } catch (e) {
1386
2215
  if (e instanceof UnsupportedPathError) {
1387
2216
  continue;
@@ -1425,10 +2254,10 @@ var Node2 = class {
1425
2254
  }
1426
2255
  this.#patterns = [];
1427
2256
  }
1428
- insert(method, path, handler) {
2257
+ insert(method, path5, handler) {
1429
2258
  this.#order = ++this.#order;
1430
2259
  let curNode = this;
1431
- const parts = splitRoutingPath(path);
2260
+ const parts = splitRoutingPath(path5);
1432
2261
  const possibleKeys = [];
1433
2262
  for (let i = 0, len = parts.length; i < len; i++) {
1434
2263
  const p = parts[i];
@@ -1479,12 +2308,12 @@ var Node2 = class {
1479
2308
  }
1480
2309
  return handlerSets;
1481
2310
  }
1482
- search(method, path) {
2311
+ search(method, path5) {
1483
2312
  const handlerSets = [];
1484
2313
  this.#params = emptyParams;
1485
2314
  const curNode = this;
1486
2315
  let curNodes = [curNode];
1487
- const parts = splitPath(path);
2316
+ const parts = splitPath(path5);
1488
2317
  const curNodesQueue = [];
1489
2318
  for (let i = 0, len = parts.length; i < len; i++) {
1490
2319
  const part = parts[i];
@@ -1572,18 +2401,18 @@ var TrieRouter = class {
1572
2401
  constructor() {
1573
2402
  this.#node = new Node2();
1574
2403
  }
1575
- add(method, path, handler) {
1576
- const results = checkOptionalParameter(path);
2404
+ add(method, path5, handler) {
2405
+ const results = checkOptionalParameter(path5);
1577
2406
  if (results) {
1578
2407
  for (let i = 0, len = results.length; i < len; i++) {
1579
2408
  this.#node.insert(method, results[i], handler);
1580
2409
  }
1581
2410
  return;
1582
2411
  }
1583
- this.#node.insert(method, path, handler);
2412
+ this.#node.insert(method, path5, handler);
1584
2413
  }
1585
- match(method, path) {
1586
- return this.#node.search(method, path);
2414
+ match(method, path5) {
2415
+ return this.#node.search(method, path5);
1587
2416
  }
1588
2417
  };
1589
2418
 
@@ -2154,210 +2983,2836 @@ var handleResponseError = (e, outgoing) => {
2154
2983
  outgoing.destroy(err);
2155
2984
  }
2156
2985
  };
2157
- var flushHeaders = (outgoing) => {
2158
- if ("flushHeaders" in outgoing && outgoing.writable) {
2159
- outgoing.flushHeaders();
2986
+ var flushHeaders = (outgoing) => {
2987
+ if ("flushHeaders" in outgoing && outgoing.writable) {
2988
+ outgoing.flushHeaders();
2989
+ }
2990
+ };
2991
+ var responseViaCache = async (res, outgoing) => {
2992
+ let [status, body, header] = res[cacheKey];
2993
+ if (header instanceof Headers) {
2994
+ header = buildOutgoingHttpHeaders(header);
2995
+ }
2996
+ if (typeof body === "string") {
2997
+ header["Content-Length"] = Buffer.byteLength(body);
2998
+ } else if (body instanceof Uint8Array) {
2999
+ header["Content-Length"] = body.byteLength;
3000
+ } else if (body instanceof Blob) {
3001
+ header["Content-Length"] = body.size;
3002
+ }
3003
+ outgoing.writeHead(status, header);
3004
+ if (typeof body === "string" || body instanceof Uint8Array) {
3005
+ outgoing.end(body);
3006
+ } else if (body instanceof Blob) {
3007
+ outgoing.end(new Uint8Array(await body.arrayBuffer()));
3008
+ } else {
3009
+ flushHeaders(outgoing);
3010
+ await writeFromReadableStream(body, outgoing)?.catch(
3011
+ (e) => handleResponseError(e, outgoing)
3012
+ );
3013
+ }
3014
+ outgoing[outgoingEnded]?.();
3015
+ };
3016
+ var isPromise = (res) => typeof res.then === "function";
3017
+ var responseViaResponseObject = async (res, outgoing, options = {}) => {
3018
+ if (isPromise(res)) {
3019
+ if (options.errorHandler) {
3020
+ try {
3021
+ res = await res;
3022
+ } catch (err) {
3023
+ const errRes = await options.errorHandler(err);
3024
+ if (!errRes) {
3025
+ return;
3026
+ }
3027
+ res = errRes;
3028
+ }
3029
+ } else {
3030
+ res = await res.catch(handleFetchError);
3031
+ }
3032
+ }
3033
+ if (cacheKey in res) {
3034
+ return responseViaCache(res, outgoing);
3035
+ }
3036
+ const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
3037
+ if (res.body) {
3038
+ const reader = res.body.getReader();
3039
+ const values = [];
3040
+ let done = false;
3041
+ let currentReadPromise = void 0;
3042
+ if (resHeaderRecord["transfer-encoding"] !== "chunked") {
3043
+ let maxReadCount = 2;
3044
+ for (let i = 0; i < maxReadCount; i++) {
3045
+ currentReadPromise ||= reader.read();
3046
+ const chunk = await readWithoutBlocking(currentReadPromise).catch((e) => {
3047
+ console.error(e);
3048
+ done = true;
3049
+ });
3050
+ if (!chunk) {
3051
+ if (i === 1) {
3052
+ await new Promise((resolve) => setTimeout(resolve));
3053
+ maxReadCount = 3;
3054
+ continue;
3055
+ }
3056
+ break;
3057
+ }
3058
+ currentReadPromise = void 0;
3059
+ if (chunk.value) {
3060
+ values.push(chunk.value);
3061
+ }
3062
+ if (chunk.done) {
3063
+ done = true;
3064
+ break;
3065
+ }
3066
+ }
3067
+ if (done && !("content-length" in resHeaderRecord)) {
3068
+ resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
3069
+ }
3070
+ }
3071
+ outgoing.writeHead(res.status, resHeaderRecord);
3072
+ values.forEach((value) => {
3073
+ outgoing.write(value);
3074
+ });
3075
+ if (done) {
3076
+ outgoing.end();
3077
+ } else {
3078
+ if (values.length === 0) {
3079
+ flushHeaders(outgoing);
3080
+ }
3081
+ await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
3082
+ }
3083
+ } else if (resHeaderRecord[X_ALREADY_SENT]) ; else {
3084
+ outgoing.writeHead(res.status, resHeaderRecord);
3085
+ outgoing.end();
3086
+ }
3087
+ outgoing[outgoingEnded]?.();
3088
+ };
3089
+ var getRequestListener = (fetchCallback, options = {}) => {
3090
+ const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
3091
+ if (options.overrideGlobalObjects !== false && global.Request !== Request2) {
3092
+ Object.defineProperty(global, "Request", {
3093
+ value: Request2
3094
+ });
3095
+ Object.defineProperty(global, "Response", {
3096
+ value: Response2
3097
+ });
3098
+ }
3099
+ return async (incoming, outgoing) => {
3100
+ let res, req;
3101
+ try {
3102
+ req = newRequest(incoming, options.hostname);
3103
+ let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
3104
+ if (!incomingEnded) {
3105
+ ;
3106
+ incoming[wrapBodyStream] = true;
3107
+ incoming.on("end", () => {
3108
+ incomingEnded = true;
3109
+ });
3110
+ if (incoming instanceof Http2ServerRequest) {
3111
+ ;
3112
+ outgoing[outgoingEnded] = () => {
3113
+ if (!incomingEnded) {
3114
+ setTimeout(() => {
3115
+ if (!incomingEnded) {
3116
+ setTimeout(() => {
3117
+ incoming.destroy();
3118
+ outgoing.destroy();
3119
+ });
3120
+ }
3121
+ });
3122
+ }
3123
+ };
3124
+ }
3125
+ }
3126
+ outgoing.on("close", () => {
3127
+ const abortController = req[abortControllerKey];
3128
+ if (abortController) {
3129
+ if (incoming.errored) {
3130
+ req[abortControllerKey].abort(incoming.errored.toString());
3131
+ } else if (!outgoing.writableFinished) {
3132
+ req[abortControllerKey].abort("Client connection prematurely closed.");
3133
+ }
3134
+ }
3135
+ if (!incomingEnded) {
3136
+ setTimeout(() => {
3137
+ if (!incomingEnded) {
3138
+ setTimeout(() => {
3139
+ incoming.destroy();
3140
+ });
3141
+ }
3142
+ });
3143
+ }
3144
+ });
3145
+ res = fetchCallback(req, { incoming, outgoing });
3146
+ if (cacheKey in res) {
3147
+ return responseViaCache(res, outgoing);
3148
+ }
3149
+ } catch (e) {
3150
+ if (!res) {
3151
+ if (options.errorHandler) {
3152
+ res = await options.errorHandler(req ? e : toRequestError(e));
3153
+ if (!res) {
3154
+ return;
3155
+ }
3156
+ } else if (!req) {
3157
+ res = handleRequestError();
3158
+ } else {
3159
+ res = handleFetchError(e);
3160
+ }
3161
+ } else {
3162
+ return handleResponseError(e, outgoing);
3163
+ }
3164
+ }
3165
+ try {
3166
+ return await responseViaResponseObject(res, outgoing, options);
3167
+ } catch (e) {
3168
+ return handleResponseError(e, outgoing);
3169
+ }
3170
+ };
3171
+ };
3172
+ var createAdaptorServer = (options) => {
3173
+ const fetchCallback = options.fetch;
3174
+ const requestListener = getRequestListener(fetchCallback, {
3175
+ hostname: options.hostname,
3176
+ overrideGlobalObjects: options.overrideGlobalObjects,
3177
+ autoCleanupIncoming: options.autoCleanupIncoming
3178
+ });
3179
+ const createServer2 = options.createServer || createServer$1;
3180
+ const server = createServer2(options.serverOptions || {}, requestListener);
3181
+ return server;
3182
+ };
3183
+ var serve = (options, listeningListener) => {
3184
+ const server = createAdaptorServer(options);
3185
+ server.listen(options?.port ?? 3e3, options.hostname, () => {
3186
+ server.address();
3187
+ });
3188
+ return server;
3189
+ };
3190
+
3191
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/index.js
3192
+ var import_cross_spawn = __toESM(require_cross_spawn());
3193
+
3194
+ // ../../node_modules/.pnpm/strip-final-newline@3.0.0/node_modules/strip-final-newline/index.js
3195
+ function stripFinalNewline(input) {
3196
+ const LF = typeof input === "string" ? "\n" : "\n".charCodeAt();
3197
+ const CR = typeof input === "string" ? "\r" : "\r".charCodeAt();
3198
+ if (input[input.length - 1] === LF) {
3199
+ input = input.slice(0, -1);
3200
+ }
3201
+ if (input[input.length - 1] === CR) {
3202
+ input = input.slice(0, -1);
3203
+ }
3204
+ return input;
3205
+ }
3206
+
3207
+ // ../../node_modules/.pnpm/path-key@4.0.0/node_modules/path-key/index.js
3208
+ function pathKey(options = {}) {
3209
+ const {
3210
+ env = process.env,
3211
+ platform = process.platform
3212
+ } = options;
3213
+ if (platform !== "win32") {
3214
+ return "PATH";
3215
+ }
3216
+ return Object.keys(env).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
3217
+ }
3218
+
3219
+ // ../../node_modules/.pnpm/npm-run-path@5.3.0/node_modules/npm-run-path/index.js
3220
+ var npmRunPath = ({
3221
+ cwd: cwd2 = process2.cwd(),
3222
+ path: pathOption = process2.env[pathKey()],
3223
+ preferLocal = true,
3224
+ execPath = process2.execPath,
3225
+ addExecPath = true
3226
+ } = {}) => {
3227
+ const cwdString = cwd2 instanceof URL ? fileURLToPath(cwd2) : cwd2;
3228
+ const cwdPath = path.resolve(cwdString);
3229
+ const result = [];
3230
+ if (preferLocal) {
3231
+ applyPreferLocal(result, cwdPath);
3232
+ }
3233
+ if (addExecPath) {
3234
+ applyExecPath(result, execPath, cwdPath);
3235
+ }
3236
+ return [...result, pathOption].join(path.delimiter);
3237
+ };
3238
+ var applyPreferLocal = (result, cwdPath) => {
3239
+ let previous;
3240
+ while (previous !== cwdPath) {
3241
+ result.push(path.join(cwdPath, "node_modules/.bin"));
3242
+ previous = cwdPath;
3243
+ cwdPath = path.resolve(cwdPath, "..");
3244
+ }
3245
+ };
3246
+ var applyExecPath = (result, execPath, cwdPath) => {
3247
+ const execPathString = execPath instanceof URL ? fileURLToPath(execPath) : execPath;
3248
+ result.push(path.resolve(cwdPath, execPathString, ".."));
3249
+ };
3250
+ var npmRunPathEnv = ({ env = process2.env, ...options } = {}) => {
3251
+ env = { ...env };
3252
+ const pathName = pathKey({ env });
3253
+ options.path = env[pathName];
3254
+ env[pathName] = npmRunPath(options);
3255
+ return env;
3256
+ };
3257
+
3258
+ // ../../node_modules/.pnpm/mimic-fn@4.0.0/node_modules/mimic-fn/index.js
3259
+ var copyProperty = (to, from, property, ignoreNonConfigurable) => {
3260
+ if (property === "length" || property === "prototype") {
3261
+ return;
3262
+ }
3263
+ if (property === "arguments" || property === "caller") {
3264
+ return;
3265
+ }
3266
+ const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
3267
+ const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
3268
+ if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
3269
+ return;
3270
+ }
3271
+ Object.defineProperty(to, property, fromDescriptor);
3272
+ };
3273
+ var canCopyProperty = function(toDescriptor, fromDescriptor) {
3274
+ return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
3275
+ };
3276
+ var changePrototype = (to, from) => {
3277
+ const fromPrototype = Object.getPrototypeOf(from);
3278
+ if (fromPrototype === Object.getPrototypeOf(to)) {
3279
+ return;
3280
+ }
3281
+ Object.setPrototypeOf(to, fromPrototype);
3282
+ };
3283
+ var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
3284
+ ${fromBody}`;
3285
+ var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
3286
+ var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
3287
+ var changeToString = (to, from, name) => {
3288
+ const withName = name === "" ? "" : `with ${name.trim()}() `;
3289
+ const newToString = wrappedToString.bind(null, withName, from.toString());
3290
+ Object.defineProperty(newToString, "name", toStringName);
3291
+ Object.defineProperty(to, "toString", { ...toStringDescriptor, value: newToString });
3292
+ };
3293
+ function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
3294
+ const { name } = to;
3295
+ for (const property of Reflect.ownKeys(from)) {
3296
+ copyProperty(to, from, property, ignoreNonConfigurable);
3297
+ }
3298
+ changePrototype(to, from);
3299
+ changeToString(to, from, name);
3300
+ return to;
3301
+ }
3302
+
3303
+ // ../../node_modules/.pnpm/onetime@6.0.0/node_modules/onetime/index.js
3304
+ var calledFunctions = /* @__PURE__ */ new WeakMap();
3305
+ var onetime = (function_, options = {}) => {
3306
+ if (typeof function_ !== "function") {
3307
+ throw new TypeError("Expected a function");
3308
+ }
3309
+ let returnValue;
3310
+ let callCount = 0;
3311
+ const functionName = function_.displayName || function_.name || "<anonymous>";
3312
+ const onetime2 = function(...arguments_) {
3313
+ calledFunctions.set(onetime2, ++callCount);
3314
+ if (callCount === 1) {
3315
+ returnValue = function_.apply(this, arguments_);
3316
+ function_ = null;
3317
+ } else if (options.throw === true) {
3318
+ throw new Error(`Function \`${functionName}\` can only be called once`);
3319
+ }
3320
+ return returnValue;
3321
+ };
3322
+ mimicFunction(onetime2, function_);
3323
+ calledFunctions.set(onetime2, callCount);
3324
+ return onetime2;
3325
+ };
3326
+ onetime.callCount = (function_) => {
3327
+ if (!calledFunctions.has(function_)) {
3328
+ throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
3329
+ }
3330
+ return calledFunctions.get(function_);
3331
+ };
3332
+ var onetime_default = onetime;
3333
+
3334
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/realtime.js
3335
+ var getRealtimeSignals = function() {
3336
+ const length = SIGRTMAX - SIGRTMIN + 1;
3337
+ return Array.from({ length }, getRealtimeSignal);
3338
+ };
3339
+ var getRealtimeSignal = function(value, index) {
3340
+ return {
3341
+ name: `SIGRT${index + 1}`,
3342
+ number: SIGRTMIN + index,
3343
+ action: "terminate",
3344
+ description: "Application-specific signal (realtime)",
3345
+ standard: "posix"
3346
+ };
3347
+ };
3348
+ var SIGRTMIN = 34;
3349
+ var SIGRTMAX = 64;
3350
+
3351
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/core.js
3352
+ var SIGNALS = [
3353
+ {
3354
+ name: "SIGHUP",
3355
+ number: 1,
3356
+ action: "terminate",
3357
+ description: "Terminal closed",
3358
+ standard: "posix"
3359
+ },
3360
+ {
3361
+ name: "SIGINT",
3362
+ number: 2,
3363
+ action: "terminate",
3364
+ description: "User interruption with CTRL-C",
3365
+ standard: "ansi"
3366
+ },
3367
+ {
3368
+ name: "SIGQUIT",
3369
+ number: 3,
3370
+ action: "core",
3371
+ description: "User interruption with CTRL-\\",
3372
+ standard: "posix"
3373
+ },
3374
+ {
3375
+ name: "SIGILL",
3376
+ number: 4,
3377
+ action: "core",
3378
+ description: "Invalid machine instruction",
3379
+ standard: "ansi"
3380
+ },
3381
+ {
3382
+ name: "SIGTRAP",
3383
+ number: 5,
3384
+ action: "core",
3385
+ description: "Debugger breakpoint",
3386
+ standard: "posix"
3387
+ },
3388
+ {
3389
+ name: "SIGABRT",
3390
+ number: 6,
3391
+ action: "core",
3392
+ description: "Aborted",
3393
+ standard: "ansi"
3394
+ },
3395
+ {
3396
+ name: "SIGIOT",
3397
+ number: 6,
3398
+ action: "core",
3399
+ description: "Aborted",
3400
+ standard: "bsd"
3401
+ },
3402
+ {
3403
+ name: "SIGBUS",
3404
+ number: 7,
3405
+ action: "core",
3406
+ description: "Bus error due to misaligned, non-existing address or paging error",
3407
+ standard: "bsd"
3408
+ },
3409
+ {
3410
+ name: "SIGEMT",
3411
+ number: 7,
3412
+ action: "terminate",
3413
+ description: "Command should be emulated but is not implemented",
3414
+ standard: "other"
3415
+ },
3416
+ {
3417
+ name: "SIGFPE",
3418
+ number: 8,
3419
+ action: "core",
3420
+ description: "Floating point arithmetic error",
3421
+ standard: "ansi"
3422
+ },
3423
+ {
3424
+ name: "SIGKILL",
3425
+ number: 9,
3426
+ action: "terminate",
3427
+ description: "Forced termination",
3428
+ standard: "posix",
3429
+ forced: true
3430
+ },
3431
+ {
3432
+ name: "SIGUSR1",
3433
+ number: 10,
3434
+ action: "terminate",
3435
+ description: "Application-specific signal",
3436
+ standard: "posix"
3437
+ },
3438
+ {
3439
+ name: "SIGSEGV",
3440
+ number: 11,
3441
+ action: "core",
3442
+ description: "Segmentation fault",
3443
+ standard: "ansi"
3444
+ },
3445
+ {
3446
+ name: "SIGUSR2",
3447
+ number: 12,
3448
+ action: "terminate",
3449
+ description: "Application-specific signal",
3450
+ standard: "posix"
3451
+ },
3452
+ {
3453
+ name: "SIGPIPE",
3454
+ number: 13,
3455
+ action: "terminate",
3456
+ description: "Broken pipe or socket",
3457
+ standard: "posix"
3458
+ },
3459
+ {
3460
+ name: "SIGALRM",
3461
+ number: 14,
3462
+ action: "terminate",
3463
+ description: "Timeout or timer",
3464
+ standard: "posix"
3465
+ },
3466
+ {
3467
+ name: "SIGTERM",
3468
+ number: 15,
3469
+ action: "terminate",
3470
+ description: "Termination",
3471
+ standard: "ansi"
3472
+ },
3473
+ {
3474
+ name: "SIGSTKFLT",
3475
+ number: 16,
3476
+ action: "terminate",
3477
+ description: "Stack is empty or overflowed",
3478
+ standard: "other"
3479
+ },
3480
+ {
3481
+ name: "SIGCHLD",
3482
+ number: 17,
3483
+ action: "ignore",
3484
+ description: "Child process terminated, paused or unpaused",
3485
+ standard: "posix"
3486
+ },
3487
+ {
3488
+ name: "SIGCLD",
3489
+ number: 17,
3490
+ action: "ignore",
3491
+ description: "Child process terminated, paused or unpaused",
3492
+ standard: "other"
3493
+ },
3494
+ {
3495
+ name: "SIGCONT",
3496
+ number: 18,
3497
+ action: "unpause",
3498
+ description: "Unpaused",
3499
+ standard: "posix",
3500
+ forced: true
3501
+ },
3502
+ {
3503
+ name: "SIGSTOP",
3504
+ number: 19,
3505
+ action: "pause",
3506
+ description: "Paused",
3507
+ standard: "posix",
3508
+ forced: true
3509
+ },
3510
+ {
3511
+ name: "SIGTSTP",
3512
+ number: 20,
3513
+ action: "pause",
3514
+ description: 'Paused using CTRL-Z or "suspend"',
3515
+ standard: "posix"
3516
+ },
3517
+ {
3518
+ name: "SIGTTIN",
3519
+ number: 21,
3520
+ action: "pause",
3521
+ description: "Background process cannot read terminal input",
3522
+ standard: "posix"
3523
+ },
3524
+ {
3525
+ name: "SIGBREAK",
3526
+ number: 21,
3527
+ action: "terminate",
3528
+ description: "User interruption with CTRL-BREAK",
3529
+ standard: "other"
3530
+ },
3531
+ {
3532
+ name: "SIGTTOU",
3533
+ number: 22,
3534
+ action: "pause",
3535
+ description: "Background process cannot write to terminal output",
3536
+ standard: "posix"
3537
+ },
3538
+ {
3539
+ name: "SIGURG",
3540
+ number: 23,
3541
+ action: "ignore",
3542
+ description: "Socket received out-of-band data",
3543
+ standard: "bsd"
3544
+ },
3545
+ {
3546
+ name: "SIGXCPU",
3547
+ number: 24,
3548
+ action: "core",
3549
+ description: "Process timed out",
3550
+ standard: "bsd"
3551
+ },
3552
+ {
3553
+ name: "SIGXFSZ",
3554
+ number: 25,
3555
+ action: "core",
3556
+ description: "File too big",
3557
+ standard: "bsd"
3558
+ },
3559
+ {
3560
+ name: "SIGVTALRM",
3561
+ number: 26,
3562
+ action: "terminate",
3563
+ description: "Timeout or timer",
3564
+ standard: "bsd"
3565
+ },
3566
+ {
3567
+ name: "SIGPROF",
3568
+ number: 27,
3569
+ action: "terminate",
3570
+ description: "Timeout or timer",
3571
+ standard: "bsd"
3572
+ },
3573
+ {
3574
+ name: "SIGWINCH",
3575
+ number: 28,
3576
+ action: "ignore",
3577
+ description: "Terminal window size changed",
3578
+ standard: "bsd"
3579
+ },
3580
+ {
3581
+ name: "SIGIO",
3582
+ number: 29,
3583
+ action: "terminate",
3584
+ description: "I/O is available",
3585
+ standard: "other"
3586
+ },
3587
+ {
3588
+ name: "SIGPOLL",
3589
+ number: 29,
3590
+ action: "terminate",
3591
+ description: "Watched event",
3592
+ standard: "other"
3593
+ },
3594
+ {
3595
+ name: "SIGINFO",
3596
+ number: 29,
3597
+ action: "ignore",
3598
+ description: "Request for process information",
3599
+ standard: "other"
3600
+ },
3601
+ {
3602
+ name: "SIGPWR",
3603
+ number: 30,
3604
+ action: "terminate",
3605
+ description: "Device running out of power",
3606
+ standard: "systemv"
3607
+ },
3608
+ {
3609
+ name: "SIGSYS",
3610
+ number: 31,
3611
+ action: "core",
3612
+ description: "Invalid system call",
3613
+ standard: "other"
3614
+ },
3615
+ {
3616
+ name: "SIGUNUSED",
3617
+ number: 31,
3618
+ action: "terminate",
3619
+ description: "Invalid system call",
3620
+ standard: "other"
3621
+ }
3622
+ ];
3623
+
3624
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/signals.js
3625
+ var getSignals = function() {
3626
+ const realtimeSignals = getRealtimeSignals();
3627
+ const signals2 = [...SIGNALS, ...realtimeSignals].map(normalizeSignal);
3628
+ return signals2;
3629
+ };
3630
+ var normalizeSignal = function({
3631
+ name,
3632
+ number: defaultNumber,
3633
+ description,
3634
+ action,
3635
+ forced = false,
3636
+ standard
3637
+ }) {
3638
+ const {
3639
+ signals: { [name]: constantSignal }
3640
+ } = constants;
3641
+ const supported = constantSignal !== void 0;
3642
+ const number = supported ? constantSignal : defaultNumber;
3643
+ return { name, number, description, supported, action, forced, standard };
3644
+ };
3645
+
3646
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/main.js
3647
+ var getSignalsByName = function() {
3648
+ const signals2 = getSignals();
3649
+ return signals2.reduce(getSignalByName, {});
3650
+ };
3651
+ var getSignalByName = function(signalByNameMemo, { name, number, description, supported, action, forced, standard }) {
3652
+ return {
3653
+ ...signalByNameMemo,
3654
+ [name]: { name, number, description, supported, action, forced, standard }
3655
+ };
3656
+ };
3657
+ var signalsByName = getSignalsByName();
3658
+ var getSignalsByNumber = function() {
3659
+ const signals2 = getSignals();
3660
+ const length = SIGRTMAX + 1;
3661
+ const signalsA = Array.from({ length }, (value, number) => getSignalByNumber(number, signals2));
3662
+ return Object.assign({}, ...signalsA);
3663
+ };
3664
+ var getSignalByNumber = function(number, signals2) {
3665
+ const signal = findSignalByNumber(number, signals2);
3666
+ if (signal === void 0) {
3667
+ return {};
3668
+ }
3669
+ const { name, description, supported, action, forced, standard } = signal;
3670
+ return {
3671
+ [number]: {
3672
+ name,
3673
+ number,
3674
+ description,
3675
+ supported,
3676
+ action,
3677
+ forced,
3678
+ standard
3679
+ }
3680
+ };
3681
+ };
3682
+ var findSignalByNumber = function(number, signals2) {
3683
+ const signal = signals2.find(({ name }) => constants.signals[name] === number);
3684
+ if (signal !== void 0) {
3685
+ return signal;
3686
+ }
3687
+ return signals2.find((signalA) => signalA.number === number);
3688
+ };
3689
+ getSignalsByNumber();
3690
+
3691
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/error.js
3692
+ var getErrorPrefix = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => {
3693
+ if (timedOut) {
3694
+ return `timed out after ${timeout} milliseconds`;
3695
+ }
3696
+ if (isCanceled) {
3697
+ return "was canceled";
3698
+ }
3699
+ if (errorCode !== void 0) {
3700
+ return `failed with ${errorCode}`;
3701
+ }
3702
+ if (signal !== void 0) {
3703
+ return `was killed with ${signal} (${signalDescription})`;
3704
+ }
3705
+ if (exitCode !== void 0) {
3706
+ return `failed with exit code ${exitCode}`;
3707
+ }
3708
+ return "failed";
3709
+ };
3710
+ var makeError = ({
3711
+ stdout,
3712
+ stderr,
3713
+ all,
3714
+ error,
3715
+ signal,
3716
+ exitCode,
3717
+ command,
3718
+ escapedCommand,
3719
+ timedOut,
3720
+ isCanceled,
3721
+ killed,
3722
+ parsed: { options: { timeout } }
3723
+ }) => {
3724
+ exitCode = exitCode === null ? void 0 : exitCode;
3725
+ signal = signal === null ? void 0 : signal;
3726
+ const signalDescription = signal === void 0 ? void 0 : signalsByName[signal].description;
3727
+ const errorCode = error && error.code;
3728
+ const prefix = getErrorPrefix({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled });
3729
+ const execaMessage = `Command ${prefix}: ${command}`;
3730
+ const isError = Object.prototype.toString.call(error) === "[object Error]";
3731
+ const shortMessage = isError ? `${execaMessage}
3732
+ ${error.message}` : execaMessage;
3733
+ const message = [shortMessage, stderr, stdout].filter(Boolean).join("\n");
3734
+ if (isError) {
3735
+ error.originalMessage = error.message;
3736
+ error.message = message;
3737
+ } else {
3738
+ error = new Error(message);
3739
+ }
3740
+ error.shortMessage = shortMessage;
3741
+ error.command = command;
3742
+ error.escapedCommand = escapedCommand;
3743
+ error.exitCode = exitCode;
3744
+ error.signal = signal;
3745
+ error.signalDescription = signalDescription;
3746
+ error.stdout = stdout;
3747
+ error.stderr = stderr;
3748
+ if (all !== void 0) {
3749
+ error.all = all;
3750
+ }
3751
+ if ("bufferedData" in error) {
3752
+ delete error.bufferedData;
3753
+ }
3754
+ error.failed = true;
3755
+ error.timedOut = Boolean(timedOut);
3756
+ error.isCanceled = isCanceled;
3757
+ error.killed = killed && !timedOut;
3758
+ return error;
3759
+ };
3760
+
3761
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/stdio.js
3762
+ var aliases = ["stdin", "stdout", "stderr"];
3763
+ var hasAlias = (options) => aliases.some((alias) => options[alias] !== void 0);
3764
+ var normalizeStdio = (options) => {
3765
+ if (!options) {
3766
+ return;
3767
+ }
3768
+ const { stdio } = options;
3769
+ if (stdio === void 0) {
3770
+ return aliases.map((alias) => options[alias]);
3771
+ }
3772
+ if (hasAlias(options)) {
3773
+ throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map((alias) => `\`${alias}\``).join(", ")}`);
3774
+ }
3775
+ if (typeof stdio === "string") {
3776
+ return stdio;
3777
+ }
3778
+ if (!Array.isArray(stdio)) {
3779
+ throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
3780
+ }
3781
+ const length = Math.max(stdio.length, aliases.length);
3782
+ return Array.from({ length }, (value, index) => stdio[index]);
3783
+ };
3784
+
3785
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/kill.js
3786
+ var import_signal_exit = __toESM(require_signal_exit());
3787
+ var DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5;
3788
+ var spawnedKill = (kill2, signal = "SIGTERM", options = {}) => {
3789
+ const killResult = kill2(signal);
3790
+ setKillTimeout(kill2, signal, options, killResult);
3791
+ return killResult;
3792
+ };
3793
+ var setKillTimeout = (kill2, signal, options, killResult) => {
3794
+ if (!shouldForceKill(signal, options, killResult)) {
3795
+ return;
3796
+ }
3797
+ const timeout = getForceKillAfterTimeout(options);
3798
+ const t = setTimeout(() => {
3799
+ kill2("SIGKILL");
3800
+ }, timeout);
3801
+ if (t.unref) {
3802
+ t.unref();
3803
+ }
3804
+ };
3805
+ var shouldForceKill = (signal, { forceKillAfterTimeout }, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
3806
+ var isSigterm = (signal) => signal === os.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
3807
+ var getForceKillAfterTimeout = ({ forceKillAfterTimeout = true }) => {
3808
+ if (forceKillAfterTimeout === true) {
3809
+ return DEFAULT_FORCE_KILL_TIMEOUT;
3810
+ }
3811
+ if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
3812
+ throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
3813
+ }
3814
+ return forceKillAfterTimeout;
3815
+ };
3816
+ var spawnedCancel = (spawned, context) => {
3817
+ const killResult = spawned.kill();
3818
+ if (killResult) {
3819
+ context.isCanceled = true;
3820
+ }
3821
+ };
3822
+ var timeoutKill = (spawned, signal, reject) => {
3823
+ spawned.kill(signal);
3824
+ reject(Object.assign(new Error("Timed out"), { timedOut: true, signal }));
3825
+ };
3826
+ var setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
3827
+ if (timeout === 0 || timeout === void 0) {
3828
+ return spawnedPromise;
3829
+ }
3830
+ let timeoutId;
3831
+ const timeoutPromise = new Promise((resolve, reject) => {
3832
+ timeoutId = setTimeout(() => {
3833
+ timeoutKill(spawned, killSignal, reject);
3834
+ }, timeout);
3835
+ });
3836
+ const safeSpawnedPromise = spawnedPromise.finally(() => {
3837
+ clearTimeout(timeoutId);
3838
+ });
3839
+ return Promise.race([timeoutPromise, safeSpawnedPromise]);
3840
+ };
3841
+ var validateTimeout = ({ timeout }) => {
3842
+ if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout < 0)) {
3843
+ throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
3844
+ }
3845
+ };
3846
+ var setExitHandler = async (spawned, { cleanup, detached }, timedPromise) => {
3847
+ if (!cleanup || detached) {
3848
+ return timedPromise;
3849
+ }
3850
+ const removeExitHandler = (0, import_signal_exit.default)(() => {
3851
+ spawned.kill();
3852
+ });
3853
+ return timedPromise.finally(() => {
3854
+ removeExitHandler();
3855
+ });
3856
+ };
3857
+
3858
+ // ../../node_modules/.pnpm/is-stream@3.0.0/node_modules/is-stream/index.js
3859
+ function isStream(stream2) {
3860
+ return stream2 !== null && typeof stream2 === "object" && typeof stream2.pipe === "function";
3861
+ }
3862
+ function isWritableStream(stream2) {
3863
+ return isStream(stream2) && stream2.writable !== false && typeof stream2._write === "function" && typeof stream2._writableState === "object";
3864
+ }
3865
+
3866
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/stream.js
3867
+ var import_get_stream = __toESM(require_get_stream());
3868
+ var import_merge_stream = __toESM(require_merge_stream());
3869
+ var handleInput = (spawned, input) => {
3870
+ if (input === void 0 || spawned.stdin === void 0) {
3871
+ return;
3872
+ }
3873
+ if (isStream(input)) {
3874
+ input.pipe(spawned.stdin);
3875
+ } else {
3876
+ spawned.stdin.end(input);
3877
+ }
3878
+ };
3879
+ var makeAllStream = (spawned, { all }) => {
3880
+ if (!all || !spawned.stdout && !spawned.stderr) {
3881
+ return;
3882
+ }
3883
+ const mixed = (0, import_merge_stream.default)();
3884
+ if (spawned.stdout) {
3885
+ mixed.add(spawned.stdout);
3886
+ }
3887
+ if (spawned.stderr) {
3888
+ mixed.add(spawned.stderr);
3889
+ }
3890
+ return mixed;
3891
+ };
3892
+ var getBufferedData = async (stream2, streamPromise) => {
3893
+ if (!stream2) {
3894
+ return;
3895
+ }
3896
+ stream2.destroy();
3897
+ try {
3898
+ return await streamPromise;
3899
+ } catch (error) {
3900
+ return error.bufferedData;
3901
+ }
3902
+ };
3903
+ var getStreamPromise = (stream2, { encoding, buffer, maxBuffer }) => {
3904
+ if (!stream2 || !buffer) {
3905
+ return;
3906
+ }
3907
+ if (encoding) {
3908
+ return (0, import_get_stream.default)(stream2, { encoding, maxBuffer });
3909
+ }
3910
+ return import_get_stream.default.buffer(stream2, { maxBuffer });
3911
+ };
3912
+ var getSpawnedResult = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
3913
+ const stdoutPromise = getStreamPromise(stdout, { encoding, buffer, maxBuffer });
3914
+ const stderrPromise = getStreamPromise(stderr, { encoding, buffer, maxBuffer });
3915
+ const allPromise = getStreamPromise(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
3916
+ try {
3917
+ return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
3918
+ } catch (error) {
3919
+ return Promise.all([
3920
+ { error, signal: error.signal, timedOut: error.timedOut },
3921
+ getBufferedData(stdout, stdoutPromise),
3922
+ getBufferedData(stderr, stderrPromise),
3923
+ getBufferedData(all, allPromise)
3924
+ ]);
3925
+ }
3926
+ };
3927
+
3928
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/promise.js
3929
+ var nativePromisePrototype = (async () => {
3930
+ })().constructor.prototype;
3931
+ var descriptors = ["then", "catch", "finally"].map((property) => [
3932
+ property,
3933
+ Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
3934
+ ]);
3935
+ var mergePromise = (spawned, promise) => {
3936
+ for (const [property, descriptor] of descriptors) {
3937
+ const value = typeof promise === "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
3938
+ Reflect.defineProperty(spawned, property, { ...descriptor, value });
3939
+ }
3940
+ return spawned;
3941
+ };
3942
+ var getSpawnedPromise = (spawned) => new Promise((resolve, reject) => {
3943
+ spawned.on("exit", (exitCode, signal) => {
3944
+ resolve({ exitCode, signal });
3945
+ });
3946
+ spawned.on("error", (error) => {
3947
+ reject(error);
3948
+ });
3949
+ if (spawned.stdin) {
3950
+ spawned.stdin.on("error", (error) => {
3951
+ reject(error);
3952
+ });
3953
+ }
3954
+ });
3955
+
3956
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/command.js
3957
+ var normalizeArgs = (file, args = []) => {
3958
+ if (!Array.isArray(args)) {
3959
+ return [file];
3960
+ }
3961
+ return [file, ...args];
3962
+ };
3963
+ var NO_ESCAPE_REGEXP = /^[\w.-]+$/;
3964
+ var DOUBLE_QUOTES_REGEXP = /"/g;
3965
+ var escapeArg = (arg) => {
3966
+ if (typeof arg !== "string" || NO_ESCAPE_REGEXP.test(arg)) {
3967
+ return arg;
3968
+ }
3969
+ return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
3970
+ };
3971
+ var joinCommand = (file, args) => normalizeArgs(file, args).join(" ");
3972
+ var getEscapedCommand = (file, args) => normalizeArgs(file, args).map((arg) => escapeArg(arg)).join(" ");
3973
+
3974
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/index.js
3975
+ var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100;
3976
+ var getEnv = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
3977
+ const env = extendEnv ? { ...process2.env, ...envOption } : envOption;
3978
+ if (preferLocal) {
3979
+ return npmRunPathEnv({ env, cwd: localDir, execPath });
3980
+ }
3981
+ return env;
3982
+ };
3983
+ var handleArguments = (file, args, options = {}) => {
3984
+ const parsed = import_cross_spawn.default._parse(file, args, options);
3985
+ file = parsed.command;
3986
+ args = parsed.args;
3987
+ options = parsed.options;
3988
+ options = {
3989
+ maxBuffer: DEFAULT_MAX_BUFFER,
3990
+ buffer: true,
3991
+ stripFinalNewline: true,
3992
+ extendEnv: true,
3993
+ preferLocal: false,
3994
+ localDir: options.cwd || process2.cwd(),
3995
+ execPath: process2.execPath,
3996
+ encoding: "utf8",
3997
+ reject: true,
3998
+ cleanup: true,
3999
+ all: false,
4000
+ windowsHide: true,
4001
+ ...options
4002
+ };
4003
+ options.env = getEnv(options);
4004
+ options.stdio = normalizeStdio(options);
4005
+ if (process2.platform === "win32" && path.basename(file, ".exe") === "cmd") {
4006
+ args.unshift("/q");
4007
+ }
4008
+ return { file, args, options, parsed };
4009
+ };
4010
+ var handleOutput = (options, value, error) => {
4011
+ if (typeof value !== "string" && !Buffer$1.isBuffer(value)) {
4012
+ return error === void 0 ? void 0 : "";
4013
+ }
4014
+ if (options.stripFinalNewline) {
4015
+ return stripFinalNewline(value);
4016
+ }
4017
+ return value;
4018
+ };
4019
+ function execa(file, args, options) {
4020
+ const parsed = handleArguments(file, args, options);
4021
+ const command = joinCommand(file, args);
4022
+ const escapedCommand = getEscapedCommand(file, args);
4023
+ validateTimeout(parsed.options);
4024
+ let spawned;
4025
+ try {
4026
+ spawned = childProcess2.spawn(parsed.file, parsed.args, parsed.options);
4027
+ } catch (error) {
4028
+ const dummySpawned = new childProcess2.ChildProcess();
4029
+ const errorPromise = Promise.reject(makeError({
4030
+ error,
4031
+ stdout: "",
4032
+ stderr: "",
4033
+ all: "",
4034
+ command,
4035
+ escapedCommand,
4036
+ parsed,
4037
+ timedOut: false,
4038
+ isCanceled: false,
4039
+ killed: false
4040
+ }));
4041
+ return mergePromise(dummySpawned, errorPromise);
4042
+ }
4043
+ const spawnedPromise = getSpawnedPromise(spawned);
4044
+ const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
4045
+ const processDone = setExitHandler(spawned, parsed.options, timedPromise);
4046
+ const context = { isCanceled: false };
4047
+ spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
4048
+ spawned.cancel = spawnedCancel.bind(null, spawned, context);
4049
+ const handlePromise = async () => {
4050
+ const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
4051
+ const stdout = handleOutput(parsed.options, stdoutResult);
4052
+ const stderr = handleOutput(parsed.options, stderrResult);
4053
+ const all = handleOutput(parsed.options, allResult);
4054
+ if (error || exitCode !== 0 || signal !== null) {
4055
+ const returnedError = makeError({
4056
+ error,
4057
+ exitCode,
4058
+ signal,
4059
+ stdout,
4060
+ stderr,
4061
+ all,
4062
+ command,
4063
+ escapedCommand,
4064
+ parsed,
4065
+ timedOut,
4066
+ isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
4067
+ killed: spawned.killed
4068
+ });
4069
+ if (!parsed.options.reject) {
4070
+ return returnedError;
4071
+ }
4072
+ throw returnedError;
4073
+ }
4074
+ return {
4075
+ command,
4076
+ escapedCommand,
4077
+ exitCode: 0,
4078
+ stdout,
4079
+ stderr,
4080
+ all,
4081
+ failed: false,
4082
+ timedOut: false,
4083
+ isCanceled: false,
4084
+ killed: false
4085
+ };
4086
+ };
4087
+ const handlePromiseOnce = onetime_default(handlePromise);
4088
+ handleInput(spawned, parsed.options.input);
4089
+ spawned.all = makeAllStream(spawned, parsed.options);
4090
+ return mergePromise(spawned, handlePromiseOnce);
4091
+ }
4092
+
4093
+ // ../../node_modules/.pnpm/taskkill@5.0.0/node_modules/taskkill/index.js
4094
+ function parseArgs(input, options) {
4095
+ if (process2.platform !== "win32") {
4096
+ throw new Error("Windows only");
4097
+ }
4098
+ input = [input].flat();
4099
+ if (input.length === 0) {
4100
+ throw new Error("PID or image name required");
4101
+ }
4102
+ const arguments_ = [];
4103
+ if (options.system && options.username && options.password) {
4104
+ arguments_.push("/s", options.system, "/u", options.username, "/p", options.password);
4105
+ }
4106
+ if (options.filter) {
4107
+ arguments_.push("/fi", options.filter);
4108
+ }
4109
+ if (options.force) {
4110
+ arguments_.push("/f");
4111
+ }
4112
+ if (options.tree) {
4113
+ arguments_.push("/t");
4114
+ }
4115
+ for (const element of input) {
4116
+ arguments_.push(typeof element === "number" ? "/pid" : "/im", element);
4117
+ }
4118
+ return arguments_;
4119
+ }
4120
+ async function taskkill(input, options = {}) {
4121
+ await execa("taskkill", parseArgs(input, options));
4122
+ }
4123
+
4124
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js
4125
+ var import_cross_spawn2 = __toESM(require_cross_spawn());
4126
+
4127
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/realtime.js
4128
+ var getRealtimeSignals2 = () => {
4129
+ const length = SIGRTMAX2 - SIGRTMIN2 + 1;
4130
+ return Array.from({ length }, getRealtimeSignal2);
4131
+ };
4132
+ var getRealtimeSignal2 = (value, index) => ({
4133
+ name: `SIGRT${index + 1}`,
4134
+ number: SIGRTMIN2 + index,
4135
+ action: "terminate",
4136
+ description: "Application-specific signal (realtime)",
4137
+ standard: "posix"
4138
+ });
4139
+ var SIGRTMIN2 = 34;
4140
+ var SIGRTMAX2 = 64;
4141
+
4142
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/core.js
4143
+ var SIGNALS2 = [
4144
+ {
4145
+ name: "SIGHUP",
4146
+ number: 1,
4147
+ action: "terminate",
4148
+ description: "Terminal closed",
4149
+ standard: "posix"
4150
+ },
4151
+ {
4152
+ name: "SIGINT",
4153
+ number: 2,
4154
+ action: "terminate",
4155
+ description: "User interruption with CTRL-C",
4156
+ standard: "ansi"
4157
+ },
4158
+ {
4159
+ name: "SIGQUIT",
4160
+ number: 3,
4161
+ action: "core",
4162
+ description: "User interruption with CTRL-\\",
4163
+ standard: "posix"
4164
+ },
4165
+ {
4166
+ name: "SIGILL",
4167
+ number: 4,
4168
+ action: "core",
4169
+ description: "Invalid machine instruction",
4170
+ standard: "ansi"
4171
+ },
4172
+ {
4173
+ name: "SIGTRAP",
4174
+ number: 5,
4175
+ action: "core",
4176
+ description: "Debugger breakpoint",
4177
+ standard: "posix"
4178
+ },
4179
+ {
4180
+ name: "SIGABRT",
4181
+ number: 6,
4182
+ action: "core",
4183
+ description: "Aborted",
4184
+ standard: "ansi"
4185
+ },
4186
+ {
4187
+ name: "SIGIOT",
4188
+ number: 6,
4189
+ action: "core",
4190
+ description: "Aborted",
4191
+ standard: "bsd"
4192
+ },
4193
+ {
4194
+ name: "SIGBUS",
4195
+ number: 7,
4196
+ action: "core",
4197
+ description: "Bus error due to misaligned, non-existing address or paging error",
4198
+ standard: "bsd"
4199
+ },
4200
+ {
4201
+ name: "SIGEMT",
4202
+ number: 7,
4203
+ action: "terminate",
4204
+ description: "Command should be emulated but is not implemented",
4205
+ standard: "other"
4206
+ },
4207
+ {
4208
+ name: "SIGFPE",
4209
+ number: 8,
4210
+ action: "core",
4211
+ description: "Floating point arithmetic error",
4212
+ standard: "ansi"
4213
+ },
4214
+ {
4215
+ name: "SIGKILL",
4216
+ number: 9,
4217
+ action: "terminate",
4218
+ description: "Forced termination",
4219
+ standard: "posix",
4220
+ forced: true
4221
+ },
4222
+ {
4223
+ name: "SIGUSR1",
4224
+ number: 10,
4225
+ action: "terminate",
4226
+ description: "Application-specific signal",
4227
+ standard: "posix"
4228
+ },
4229
+ {
4230
+ name: "SIGSEGV",
4231
+ number: 11,
4232
+ action: "core",
4233
+ description: "Segmentation fault",
4234
+ standard: "ansi"
4235
+ },
4236
+ {
4237
+ name: "SIGUSR2",
4238
+ number: 12,
4239
+ action: "terminate",
4240
+ description: "Application-specific signal",
4241
+ standard: "posix"
4242
+ },
4243
+ {
4244
+ name: "SIGPIPE",
4245
+ number: 13,
4246
+ action: "terminate",
4247
+ description: "Broken pipe or socket",
4248
+ standard: "posix"
4249
+ },
4250
+ {
4251
+ name: "SIGALRM",
4252
+ number: 14,
4253
+ action: "terminate",
4254
+ description: "Timeout or timer",
4255
+ standard: "posix"
4256
+ },
4257
+ {
4258
+ name: "SIGTERM",
4259
+ number: 15,
4260
+ action: "terminate",
4261
+ description: "Termination",
4262
+ standard: "ansi"
4263
+ },
4264
+ {
4265
+ name: "SIGSTKFLT",
4266
+ number: 16,
4267
+ action: "terminate",
4268
+ description: "Stack is empty or overflowed",
4269
+ standard: "other"
4270
+ },
4271
+ {
4272
+ name: "SIGCHLD",
4273
+ number: 17,
4274
+ action: "ignore",
4275
+ description: "Child process terminated, paused or unpaused",
4276
+ standard: "posix"
4277
+ },
4278
+ {
4279
+ name: "SIGCLD",
4280
+ number: 17,
4281
+ action: "ignore",
4282
+ description: "Child process terminated, paused or unpaused",
4283
+ standard: "other"
4284
+ },
4285
+ {
4286
+ name: "SIGCONT",
4287
+ number: 18,
4288
+ action: "unpause",
4289
+ description: "Unpaused",
4290
+ standard: "posix",
4291
+ forced: true
4292
+ },
4293
+ {
4294
+ name: "SIGSTOP",
4295
+ number: 19,
4296
+ action: "pause",
4297
+ description: "Paused",
4298
+ standard: "posix",
4299
+ forced: true
4300
+ },
4301
+ {
4302
+ name: "SIGTSTP",
4303
+ number: 20,
4304
+ action: "pause",
4305
+ description: 'Paused using CTRL-Z or "suspend"',
4306
+ standard: "posix"
4307
+ },
4308
+ {
4309
+ name: "SIGTTIN",
4310
+ number: 21,
4311
+ action: "pause",
4312
+ description: "Background process cannot read terminal input",
4313
+ standard: "posix"
4314
+ },
4315
+ {
4316
+ name: "SIGBREAK",
4317
+ number: 21,
4318
+ action: "terminate",
4319
+ description: "User interruption with CTRL-BREAK",
4320
+ standard: "other"
4321
+ },
4322
+ {
4323
+ name: "SIGTTOU",
4324
+ number: 22,
4325
+ action: "pause",
4326
+ description: "Background process cannot write to terminal output",
4327
+ standard: "posix"
4328
+ },
4329
+ {
4330
+ name: "SIGURG",
4331
+ number: 23,
4332
+ action: "ignore",
4333
+ description: "Socket received out-of-band data",
4334
+ standard: "bsd"
4335
+ },
4336
+ {
4337
+ name: "SIGXCPU",
4338
+ number: 24,
4339
+ action: "core",
4340
+ description: "Process timed out",
4341
+ standard: "bsd"
4342
+ },
4343
+ {
4344
+ name: "SIGXFSZ",
4345
+ number: 25,
4346
+ action: "core",
4347
+ description: "File too big",
4348
+ standard: "bsd"
4349
+ },
4350
+ {
4351
+ name: "SIGVTALRM",
4352
+ number: 26,
4353
+ action: "terminate",
4354
+ description: "Timeout or timer",
4355
+ standard: "bsd"
4356
+ },
4357
+ {
4358
+ name: "SIGPROF",
4359
+ number: 27,
4360
+ action: "terminate",
4361
+ description: "Timeout or timer",
4362
+ standard: "bsd"
4363
+ },
4364
+ {
4365
+ name: "SIGWINCH",
4366
+ number: 28,
4367
+ action: "ignore",
4368
+ description: "Terminal window size changed",
4369
+ standard: "bsd"
4370
+ },
4371
+ {
4372
+ name: "SIGIO",
4373
+ number: 29,
4374
+ action: "terminate",
4375
+ description: "I/O is available",
4376
+ standard: "other"
4377
+ },
4378
+ {
4379
+ name: "SIGPOLL",
4380
+ number: 29,
4381
+ action: "terminate",
4382
+ description: "Watched event",
4383
+ standard: "other"
4384
+ },
4385
+ {
4386
+ name: "SIGINFO",
4387
+ number: 29,
4388
+ action: "ignore",
4389
+ description: "Request for process information",
4390
+ standard: "other"
4391
+ },
4392
+ {
4393
+ name: "SIGPWR",
4394
+ number: 30,
4395
+ action: "terminate",
4396
+ description: "Device running out of power",
4397
+ standard: "systemv"
4398
+ },
4399
+ {
4400
+ name: "SIGSYS",
4401
+ number: 31,
4402
+ action: "core",
4403
+ description: "Invalid system call",
4404
+ standard: "other"
4405
+ },
4406
+ {
4407
+ name: "SIGUNUSED",
4408
+ number: 31,
4409
+ action: "terminate",
4410
+ description: "Invalid system call",
4411
+ standard: "other"
4412
+ }
4413
+ ];
4414
+
4415
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/signals.js
4416
+ var getSignals2 = () => {
4417
+ const realtimeSignals = getRealtimeSignals2();
4418
+ const signals2 = [...SIGNALS2, ...realtimeSignals].map(normalizeSignal2);
4419
+ return signals2;
4420
+ };
4421
+ var normalizeSignal2 = ({
4422
+ name,
4423
+ number: defaultNumber,
4424
+ description,
4425
+ action,
4426
+ forced = false,
4427
+ standard
4428
+ }) => {
4429
+ const {
4430
+ signals: { [name]: constantSignal }
4431
+ } = constants;
4432
+ const supported = constantSignal !== void 0;
4433
+ const number = supported ? constantSignal : defaultNumber;
4434
+ return { name, number, description, supported, action, forced, standard };
4435
+ };
4436
+
4437
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/main.js
4438
+ var getSignalsByName2 = () => {
4439
+ const signals2 = getSignals2();
4440
+ return Object.fromEntries(signals2.map(getSignalByName2));
4441
+ };
4442
+ var getSignalByName2 = ({
4443
+ name,
4444
+ number,
4445
+ description,
4446
+ supported,
4447
+ action,
4448
+ forced,
4449
+ standard
4450
+ }) => [name, { name, number, description, supported, action, forced, standard }];
4451
+ var signalsByName2 = getSignalsByName2();
4452
+ var getSignalsByNumber2 = () => {
4453
+ const signals2 = getSignals2();
4454
+ const length = SIGRTMAX2 + 1;
4455
+ const signalsA = Array.from(
4456
+ { length },
4457
+ (value, number) => getSignalByNumber2(number, signals2)
4458
+ );
4459
+ return Object.assign({}, ...signalsA);
4460
+ };
4461
+ var getSignalByNumber2 = (number, signals2) => {
4462
+ const signal = findSignalByNumber2(number, signals2);
4463
+ if (signal === void 0) {
4464
+ return {};
4465
+ }
4466
+ const { name, description, supported, action, forced, standard } = signal;
4467
+ return {
4468
+ [number]: {
4469
+ name,
4470
+ number,
4471
+ description,
4472
+ supported,
4473
+ action,
4474
+ forced,
4475
+ standard
4476
+ }
4477
+ };
4478
+ };
4479
+ var findSignalByNumber2 = (number, signals2) => {
4480
+ const signal = signals2.find(({ name }) => constants.signals[name] === number);
4481
+ if (signal !== void 0) {
4482
+ return signal;
4483
+ }
4484
+ return signals2.find((signalA) => signalA.number === number);
4485
+ };
4486
+ getSignalsByNumber2();
4487
+
4488
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/error.js
4489
+ var getErrorPrefix2 = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => {
4490
+ if (timedOut) {
4491
+ return `timed out after ${timeout} milliseconds`;
4492
+ }
4493
+ if (isCanceled) {
4494
+ return "was canceled";
4495
+ }
4496
+ if (errorCode !== void 0) {
4497
+ return `failed with ${errorCode}`;
4498
+ }
4499
+ if (signal !== void 0) {
4500
+ return `was killed with ${signal} (${signalDescription})`;
4501
+ }
4502
+ if (exitCode !== void 0) {
4503
+ return `failed with exit code ${exitCode}`;
4504
+ }
4505
+ return "failed";
4506
+ };
4507
+ var makeError2 = ({
4508
+ stdout,
4509
+ stderr,
4510
+ all,
4511
+ error,
4512
+ signal,
4513
+ exitCode,
4514
+ command,
4515
+ escapedCommand,
4516
+ timedOut,
4517
+ isCanceled,
4518
+ killed,
4519
+ parsed: { options: { timeout, cwd: cwd2 = process2.cwd() } }
4520
+ }) => {
4521
+ exitCode = exitCode === null ? void 0 : exitCode;
4522
+ signal = signal === null ? void 0 : signal;
4523
+ const signalDescription = signal === void 0 ? void 0 : signalsByName2[signal].description;
4524
+ const errorCode = error && error.code;
4525
+ const prefix = getErrorPrefix2({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled });
4526
+ const execaMessage = `Command ${prefix}: ${command}`;
4527
+ const isError = Object.prototype.toString.call(error) === "[object Error]";
4528
+ const shortMessage = isError ? `${execaMessage}
4529
+ ${error.message}` : execaMessage;
4530
+ const message = [shortMessage, stderr, stdout].filter(Boolean).join("\n");
4531
+ if (isError) {
4532
+ error.originalMessage = error.message;
4533
+ error.message = message;
4534
+ } else {
4535
+ error = new Error(message);
4536
+ }
4537
+ error.shortMessage = shortMessage;
4538
+ error.command = command;
4539
+ error.escapedCommand = escapedCommand;
4540
+ error.exitCode = exitCode;
4541
+ error.signal = signal;
4542
+ error.signalDescription = signalDescription;
4543
+ error.stdout = stdout;
4544
+ error.stderr = stderr;
4545
+ error.cwd = cwd2;
4546
+ if (all !== void 0) {
4547
+ error.all = all;
4548
+ }
4549
+ if ("bufferedData" in error) {
4550
+ delete error.bufferedData;
4551
+ }
4552
+ error.failed = true;
4553
+ error.timedOut = Boolean(timedOut);
4554
+ error.isCanceled = isCanceled;
4555
+ error.killed = killed && !timedOut;
4556
+ return error;
4557
+ };
4558
+
4559
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stdio.js
4560
+ var aliases2 = ["stdin", "stdout", "stderr"];
4561
+ var hasAlias2 = (options) => aliases2.some((alias) => options[alias] !== void 0);
4562
+ var normalizeStdio2 = (options) => {
4563
+ if (!options) {
4564
+ return;
4565
+ }
4566
+ const { stdio } = options;
4567
+ if (stdio === void 0) {
4568
+ return aliases2.map((alias) => options[alias]);
4569
+ }
4570
+ if (hasAlias2(options)) {
4571
+ throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases2.map((alias) => `\`${alias}\``).join(", ")}`);
4572
+ }
4573
+ if (typeof stdio === "string") {
4574
+ return stdio;
4575
+ }
4576
+ if (!Array.isArray(stdio)) {
4577
+ throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
4578
+ }
4579
+ const length = Math.max(stdio.length, aliases2.length);
4580
+ return Array.from({ length }, (value, index) => stdio[index]);
4581
+ };
4582
+
4583
+ // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
4584
+ var signals = [];
4585
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
4586
+ if (process.platform !== "win32") {
4587
+ signals.push(
4588
+ "SIGALRM",
4589
+ "SIGABRT",
4590
+ "SIGVTALRM",
4591
+ "SIGXCPU",
4592
+ "SIGXFSZ",
4593
+ "SIGUSR2",
4594
+ "SIGTRAP",
4595
+ "SIGSYS",
4596
+ "SIGQUIT",
4597
+ "SIGIOT"
4598
+ // should detect profiler and enable/disable accordingly.
4599
+ // see #21
4600
+ // 'SIGPROF'
4601
+ );
4602
+ }
4603
+ if (process.platform === "linux") {
4604
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
4605
+ }
4606
+
4607
+ // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
4608
+ var processOk = (process13) => !!process13 && typeof process13 === "object" && typeof process13.removeListener === "function" && typeof process13.emit === "function" && typeof process13.reallyExit === "function" && typeof process13.listeners === "function" && typeof process13.kill === "function" && typeof process13.pid === "number" && typeof process13.on === "function";
4609
+ var kExitEmitter = Symbol.for("signal-exit emitter");
4610
+ var global2 = globalThis;
4611
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
4612
+ var Emitter = class {
4613
+ emitted = {
4614
+ afterExit: false,
4615
+ exit: false
4616
+ };
4617
+ listeners = {
4618
+ afterExit: [],
4619
+ exit: []
4620
+ };
4621
+ count = 0;
4622
+ id = Math.random();
4623
+ constructor() {
4624
+ if (global2[kExitEmitter]) {
4625
+ return global2[kExitEmitter];
4626
+ }
4627
+ ObjectDefineProperty(global2, kExitEmitter, {
4628
+ value: this,
4629
+ writable: false,
4630
+ enumerable: false,
4631
+ configurable: false
4632
+ });
4633
+ }
4634
+ on(ev, fn) {
4635
+ this.listeners[ev].push(fn);
4636
+ }
4637
+ removeListener(ev, fn) {
4638
+ const list = this.listeners[ev];
4639
+ const i = list.indexOf(fn);
4640
+ if (i === -1) {
4641
+ return;
4642
+ }
4643
+ if (i === 0 && list.length === 1) {
4644
+ list.length = 0;
4645
+ } else {
4646
+ list.splice(i, 1);
4647
+ }
4648
+ }
4649
+ emit(ev, code, signal) {
4650
+ if (this.emitted[ev]) {
4651
+ return false;
4652
+ }
4653
+ this.emitted[ev] = true;
4654
+ let ret = false;
4655
+ for (const fn of this.listeners[ev]) {
4656
+ ret = fn(code, signal) === true || ret;
4657
+ }
4658
+ if (ev === "exit") {
4659
+ ret = this.emit("afterExit", code, signal) || ret;
4660
+ }
4661
+ return ret;
4662
+ }
4663
+ };
4664
+ var SignalExitBase = class {
4665
+ };
4666
+ var signalExitWrap = (handler) => {
4667
+ return {
4668
+ onExit(cb, opts) {
4669
+ return handler.onExit(cb, opts);
4670
+ },
4671
+ load() {
4672
+ return handler.load();
4673
+ },
4674
+ unload() {
4675
+ return handler.unload();
4676
+ }
4677
+ };
4678
+ };
4679
+ var SignalExitFallback = class extends SignalExitBase {
4680
+ onExit() {
4681
+ return () => {
4682
+ };
4683
+ }
4684
+ load() {
4685
+ }
4686
+ unload() {
4687
+ }
4688
+ };
4689
+ var SignalExit = class extends SignalExitBase {
4690
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
4691
+ // so use a supported signal instead
4692
+ /* c8 ignore start */
4693
+ #hupSig = process6.platform === "win32" ? "SIGINT" : "SIGHUP";
4694
+ /* c8 ignore stop */
4695
+ #emitter = new Emitter();
4696
+ #process;
4697
+ #originalProcessEmit;
4698
+ #originalProcessReallyExit;
4699
+ #sigListeners = {};
4700
+ #loaded = false;
4701
+ constructor(process13) {
4702
+ super();
4703
+ this.#process = process13;
4704
+ this.#sigListeners = {};
4705
+ for (const sig of signals) {
4706
+ this.#sigListeners[sig] = () => {
4707
+ const listeners = this.#process.listeners(sig);
4708
+ let { count } = this.#emitter;
4709
+ const p = process13;
4710
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
4711
+ count += p.__signal_exit_emitter__.count;
4712
+ }
4713
+ if (listeners.length === count) {
4714
+ this.unload();
4715
+ const ret = this.#emitter.emit("exit", null, sig);
4716
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
4717
+ if (!ret)
4718
+ process13.kill(process13.pid, s);
4719
+ }
4720
+ };
4721
+ }
4722
+ this.#originalProcessReallyExit = process13.reallyExit;
4723
+ this.#originalProcessEmit = process13.emit;
4724
+ }
4725
+ onExit(cb, opts) {
4726
+ if (!processOk(this.#process)) {
4727
+ return () => {
4728
+ };
4729
+ }
4730
+ if (this.#loaded === false) {
4731
+ this.load();
4732
+ }
4733
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
4734
+ this.#emitter.on(ev, cb);
4735
+ return () => {
4736
+ this.#emitter.removeListener(ev, cb);
4737
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
4738
+ this.unload();
4739
+ }
4740
+ };
4741
+ }
4742
+ load() {
4743
+ if (this.#loaded) {
4744
+ return;
4745
+ }
4746
+ this.#loaded = true;
4747
+ this.#emitter.count += 1;
4748
+ for (const sig of signals) {
4749
+ try {
4750
+ const fn = this.#sigListeners[sig];
4751
+ if (fn)
4752
+ this.#process.on(sig, fn);
4753
+ } catch (_) {
4754
+ }
4755
+ }
4756
+ this.#process.emit = (ev, ...a) => {
4757
+ return this.#processEmit(ev, ...a);
4758
+ };
4759
+ this.#process.reallyExit = (code) => {
4760
+ return this.#processReallyExit(code);
4761
+ };
4762
+ }
4763
+ unload() {
4764
+ if (!this.#loaded) {
4765
+ return;
4766
+ }
4767
+ this.#loaded = false;
4768
+ signals.forEach((sig) => {
4769
+ const listener = this.#sigListeners[sig];
4770
+ if (!listener) {
4771
+ throw new Error("Listener not defined for signal: " + sig);
4772
+ }
4773
+ try {
4774
+ this.#process.removeListener(sig, listener);
4775
+ } catch (_) {
4776
+ }
4777
+ });
4778
+ this.#process.emit = this.#originalProcessEmit;
4779
+ this.#process.reallyExit = this.#originalProcessReallyExit;
4780
+ this.#emitter.count -= 1;
4781
+ }
4782
+ #processReallyExit(code) {
4783
+ if (!processOk(this.#process)) {
4784
+ return 0;
4785
+ }
4786
+ this.#process.exitCode = code || 0;
4787
+ this.#emitter.emit("exit", this.#process.exitCode, null);
4788
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
4789
+ }
4790
+ #processEmit(ev, ...args) {
4791
+ const og = this.#originalProcessEmit;
4792
+ if (ev === "exit" && processOk(this.#process)) {
4793
+ if (typeof args[0] === "number") {
4794
+ this.#process.exitCode = args[0];
4795
+ }
4796
+ const ret = og.call(this.#process, ev, ...args);
4797
+ this.#emitter.emit("exit", this.#process.exitCode, null);
4798
+ return ret;
4799
+ } else {
4800
+ return og.call(this.#process, ev, ...args);
4801
+ }
4802
+ }
4803
+ };
4804
+ var process6 = globalThis.process;
4805
+ var {
4806
+ /**
4807
+ * Called when the process is exiting, whether via signal, explicit
4808
+ * exit, or running out of stuff to do.
4809
+ *
4810
+ * If the global process object is not suitable for instrumentation,
4811
+ * then this will be a no-op.
4812
+ *
4813
+ * Returns a function that may be used to unload signal-exit.
4814
+ */
4815
+ onExit: onExit2} = signalExitWrap(processOk(process6) ? new SignalExit(process6) : new SignalExitFallback());
4816
+
4817
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/kill.js
4818
+ var DEFAULT_FORCE_KILL_TIMEOUT2 = 1e3 * 5;
4819
+ var spawnedKill2 = (kill2, signal = "SIGTERM", options = {}) => {
4820
+ const killResult = kill2(signal);
4821
+ setKillTimeout2(kill2, signal, options, killResult);
4822
+ return killResult;
4823
+ };
4824
+ var setKillTimeout2 = (kill2, signal, options, killResult) => {
4825
+ if (!shouldForceKill2(signal, options, killResult)) {
4826
+ return;
4827
+ }
4828
+ const timeout = getForceKillAfterTimeout2(options);
4829
+ const t = setTimeout(() => {
4830
+ kill2("SIGKILL");
4831
+ }, timeout);
4832
+ if (t.unref) {
4833
+ t.unref();
4834
+ }
4835
+ };
4836
+ var shouldForceKill2 = (signal, { forceKillAfterTimeout }, killResult) => isSigterm2(signal) && forceKillAfterTimeout !== false && killResult;
4837
+ var isSigterm2 = (signal) => signal === os.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
4838
+ var getForceKillAfterTimeout2 = ({ forceKillAfterTimeout = true }) => {
4839
+ if (forceKillAfterTimeout === true) {
4840
+ return DEFAULT_FORCE_KILL_TIMEOUT2;
4841
+ }
4842
+ if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
4843
+ throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
4844
+ }
4845
+ return forceKillAfterTimeout;
4846
+ };
4847
+ var spawnedCancel2 = (spawned, context) => {
4848
+ const killResult = spawned.kill();
4849
+ if (killResult) {
4850
+ context.isCanceled = true;
4851
+ }
4852
+ };
4853
+ var timeoutKill2 = (spawned, signal, reject) => {
4854
+ spawned.kill(signal);
4855
+ reject(Object.assign(new Error("Timed out"), { timedOut: true, signal }));
4856
+ };
4857
+ var setupTimeout2 = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
4858
+ if (timeout === 0 || timeout === void 0) {
4859
+ return spawnedPromise;
4860
+ }
4861
+ let timeoutId;
4862
+ const timeoutPromise = new Promise((resolve, reject) => {
4863
+ timeoutId = setTimeout(() => {
4864
+ timeoutKill2(spawned, killSignal, reject);
4865
+ }, timeout);
4866
+ });
4867
+ const safeSpawnedPromise = spawnedPromise.finally(() => {
4868
+ clearTimeout(timeoutId);
4869
+ });
4870
+ return Promise.race([timeoutPromise, safeSpawnedPromise]);
4871
+ };
4872
+ var validateTimeout2 = ({ timeout }) => {
4873
+ if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout < 0)) {
4874
+ throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
4875
+ }
4876
+ };
4877
+ var setExitHandler2 = async (spawned, { cleanup, detached }, timedPromise) => {
4878
+ if (!cleanup || detached) {
4879
+ return timedPromise;
4880
+ }
4881
+ const removeExitHandler = onExit2(() => {
4882
+ spawned.kill();
4883
+ });
4884
+ return timedPromise.finally(() => {
4885
+ removeExitHandler();
4886
+ });
4887
+ };
4888
+ var isExecaChildProcess = (target) => target instanceof ChildProcess && typeof target.then === "function";
4889
+ var pipeToTarget = (spawned, streamName, target) => {
4890
+ if (typeof target === "string") {
4891
+ spawned[streamName].pipe(createWriteStream(target));
4892
+ return spawned;
4893
+ }
4894
+ if (isWritableStream(target)) {
4895
+ spawned[streamName].pipe(target);
4896
+ return spawned;
4897
+ }
4898
+ if (!isExecaChildProcess(target)) {
4899
+ throw new TypeError("The second argument must be a string, a stream or an Execa child process.");
4900
+ }
4901
+ if (!isWritableStream(target.stdin)) {
4902
+ throw new TypeError("The target child process's stdin must be available.");
4903
+ }
4904
+ spawned[streamName].pipe(target.stdin);
4905
+ return target;
4906
+ };
4907
+ var addPipeMethods = (spawned) => {
4908
+ if (spawned.stdout !== null) {
4909
+ spawned.pipeStdout = pipeToTarget.bind(void 0, spawned, "stdout");
4910
+ }
4911
+ if (spawned.stderr !== null) {
4912
+ spawned.pipeStderr = pipeToTarget.bind(void 0, spawned, "stderr");
4913
+ }
4914
+ if (spawned.all !== void 0) {
4915
+ spawned.pipeAll = pipeToTarget.bind(void 0, spawned, "all");
4916
+ }
4917
+ };
4918
+
4919
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/contents.js
4920
+ var getStreamContents = async (stream2, { init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize }, { maxBuffer = Number.POSITIVE_INFINITY } = {}) => {
4921
+ if (!isAsyncIterable(stream2)) {
4922
+ throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");
4923
+ }
4924
+ const state = init();
4925
+ state.length = 0;
4926
+ try {
4927
+ for await (const chunk of stream2) {
4928
+ const chunkType = getChunkType(chunk);
4929
+ const convertedChunk = convertChunk[chunkType](chunk, state);
4930
+ appendChunk({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer });
4931
+ }
4932
+ appendFinalChunk({ state, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer });
4933
+ return finalize(state);
4934
+ } catch (error) {
4935
+ error.bufferedData = finalize(state);
4936
+ throw error;
4937
+ }
4938
+ };
4939
+ var appendFinalChunk = ({ state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer }) => {
4940
+ const convertedChunk = getFinalChunk(state);
4941
+ if (convertedChunk !== void 0) {
4942
+ appendChunk({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer });
4943
+ }
4944
+ };
4945
+ var appendChunk = ({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer }) => {
4946
+ const chunkSize = getSize(convertedChunk);
4947
+ const newLength = state.length + chunkSize;
4948
+ if (newLength <= maxBuffer) {
4949
+ addNewChunk(convertedChunk, state, addChunk, newLength);
4950
+ return;
4951
+ }
4952
+ const truncatedChunk = truncateChunk(convertedChunk, maxBuffer - state.length);
4953
+ if (truncatedChunk !== void 0) {
4954
+ addNewChunk(truncatedChunk, state, addChunk, maxBuffer);
4955
+ }
4956
+ throw new MaxBufferError();
4957
+ };
4958
+ var addNewChunk = (convertedChunk, state, addChunk, newLength) => {
4959
+ state.contents = addChunk(convertedChunk, state, newLength);
4960
+ state.length = newLength;
4961
+ };
4962
+ var isAsyncIterable = (stream2) => typeof stream2 === "object" && stream2 !== null && typeof stream2[Symbol.asyncIterator] === "function";
4963
+ var getChunkType = (chunk) => {
4964
+ const typeOfChunk = typeof chunk;
4965
+ if (typeOfChunk === "string") {
4966
+ return "string";
4967
+ }
4968
+ if (typeOfChunk !== "object" || chunk === null) {
4969
+ return "others";
4970
+ }
4971
+ if (globalThis.Buffer?.isBuffer(chunk)) {
4972
+ return "buffer";
4973
+ }
4974
+ const prototypeName = objectToString.call(chunk);
4975
+ if (prototypeName === "[object ArrayBuffer]") {
4976
+ return "arrayBuffer";
4977
+ }
4978
+ if (prototypeName === "[object DataView]") {
4979
+ return "dataView";
4980
+ }
4981
+ if (Number.isInteger(chunk.byteLength) && Number.isInteger(chunk.byteOffset) && objectToString.call(chunk.buffer) === "[object ArrayBuffer]") {
4982
+ return "typedArray";
4983
+ }
4984
+ return "others";
4985
+ };
4986
+ var { toString: objectToString } = Object.prototype;
4987
+ var MaxBufferError = class extends Error {
4988
+ name = "MaxBufferError";
4989
+ constructor() {
4990
+ super("maxBuffer exceeded");
4991
+ }
4992
+ };
4993
+
4994
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/utils.js
4995
+ var identity = (value) => value;
4996
+ var noop = () => void 0;
4997
+ var getContentsProp = ({ contents }) => contents;
4998
+ var throwObjectStream = (chunk) => {
4999
+ throw new Error(`Streams in object mode are not supported: ${String(chunk)}`);
5000
+ };
5001
+ var getLengthProp = (convertedChunk) => convertedChunk.length;
5002
+
5003
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array-buffer.js
5004
+ async function getStreamAsArrayBuffer(stream2, options) {
5005
+ return getStreamContents(stream2, arrayBufferMethods, options);
5006
+ }
5007
+ var initArrayBuffer = () => ({ contents: new ArrayBuffer(0) });
5008
+ var useTextEncoder = (chunk) => textEncoder.encode(chunk);
5009
+ var textEncoder = new TextEncoder();
5010
+ var useUint8Array = (chunk) => new Uint8Array(chunk);
5011
+ var useUint8ArrayWithOffset = (chunk) => new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
5012
+ var truncateArrayBufferChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);
5013
+ var addArrayBufferChunk = (convertedChunk, { contents, length: previousLength }, length) => {
5014
+ const newContents = hasArrayBufferResize() ? resizeArrayBuffer(contents, length) : resizeArrayBufferSlow(contents, length);
5015
+ new Uint8Array(newContents).set(convertedChunk, previousLength);
5016
+ return newContents;
5017
+ };
5018
+ var resizeArrayBufferSlow = (contents, length) => {
5019
+ if (length <= contents.byteLength) {
5020
+ return contents;
5021
+ }
5022
+ const arrayBuffer = new ArrayBuffer(getNewContentsLength(length));
5023
+ new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
5024
+ return arrayBuffer;
5025
+ };
5026
+ var resizeArrayBuffer = (contents, length) => {
5027
+ if (length <= contents.maxByteLength) {
5028
+ contents.resize(length);
5029
+ return contents;
5030
+ }
5031
+ const arrayBuffer = new ArrayBuffer(length, { maxByteLength: getNewContentsLength(length) });
5032
+ new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
5033
+ return arrayBuffer;
5034
+ };
5035
+ var getNewContentsLength = (length) => SCALE_FACTOR ** Math.ceil(Math.log(length) / Math.log(SCALE_FACTOR));
5036
+ var SCALE_FACTOR = 2;
5037
+ var finalizeArrayBuffer = ({ contents, length }) => hasArrayBufferResize() ? contents : contents.slice(0, length);
5038
+ var hasArrayBufferResize = () => "resize" in ArrayBuffer.prototype;
5039
+ var arrayBufferMethods = {
5040
+ init: initArrayBuffer,
5041
+ convertChunk: {
5042
+ string: useTextEncoder,
5043
+ buffer: useUint8Array,
5044
+ arrayBuffer: useUint8Array,
5045
+ dataView: useUint8ArrayWithOffset,
5046
+ typedArray: useUint8ArrayWithOffset,
5047
+ others: throwObjectStream
5048
+ },
5049
+ getSize: getLengthProp,
5050
+ truncateChunk: truncateArrayBufferChunk,
5051
+ addChunk: addArrayBufferChunk,
5052
+ getFinalChunk: noop,
5053
+ finalize: finalizeArrayBuffer
5054
+ };
5055
+
5056
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/buffer.js
5057
+ async function getStreamAsBuffer(stream2, options) {
5058
+ if (!("Buffer" in globalThis)) {
5059
+ throw new Error("getStreamAsBuffer() is only supported in Node.js");
5060
+ }
5061
+ try {
5062
+ return arrayBufferToNodeBuffer(await getStreamAsArrayBuffer(stream2, options));
5063
+ } catch (error) {
5064
+ if (error.bufferedData !== void 0) {
5065
+ error.bufferedData = arrayBufferToNodeBuffer(error.bufferedData);
5066
+ }
5067
+ throw error;
5068
+ }
5069
+ }
5070
+ var arrayBufferToNodeBuffer = (arrayBuffer) => globalThis.Buffer.from(arrayBuffer);
5071
+
5072
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/string.js
5073
+ async function getStreamAsString(stream2, options) {
5074
+ return getStreamContents(stream2, stringMethods, options);
5075
+ }
5076
+ var initString = () => ({ contents: "", textDecoder: new TextDecoder() });
5077
+ var useTextDecoder = (chunk, { textDecoder }) => textDecoder.decode(chunk, { stream: true });
5078
+ var addStringChunk = (convertedChunk, { contents }) => contents + convertedChunk;
5079
+ var truncateStringChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);
5080
+ var getFinalStringChunk = ({ textDecoder }) => {
5081
+ const finalChunk = textDecoder.decode();
5082
+ return finalChunk === "" ? void 0 : finalChunk;
5083
+ };
5084
+ var stringMethods = {
5085
+ init: initString,
5086
+ convertChunk: {
5087
+ string: identity,
5088
+ buffer: useTextDecoder,
5089
+ arrayBuffer: useTextDecoder,
5090
+ dataView: useTextDecoder,
5091
+ typedArray: useTextDecoder,
5092
+ others: throwObjectStream
5093
+ },
5094
+ getSize: getLengthProp,
5095
+ truncateChunk: truncateStringChunk,
5096
+ addChunk: addStringChunk,
5097
+ getFinalChunk: getFinalStringChunk,
5098
+ finalize: getContentsProp
5099
+ };
5100
+
5101
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stream.js
5102
+ var import_merge_stream2 = __toESM(require_merge_stream());
5103
+ var validateInputOptions = (input) => {
5104
+ if (input !== void 0) {
5105
+ throw new TypeError("The `input` and `inputFile` options cannot be both set.");
5106
+ }
5107
+ };
5108
+ var getInput = ({ input, inputFile }) => {
5109
+ if (typeof inputFile !== "string") {
5110
+ return input;
5111
+ }
5112
+ validateInputOptions(input);
5113
+ return createReadStream(inputFile);
5114
+ };
5115
+ var handleInput2 = (spawned, options) => {
5116
+ const input = getInput(options);
5117
+ if (input === void 0) {
5118
+ return;
5119
+ }
5120
+ if (isStream(input)) {
5121
+ input.pipe(spawned.stdin);
5122
+ } else {
5123
+ spawned.stdin.end(input);
5124
+ }
5125
+ };
5126
+ var makeAllStream2 = (spawned, { all }) => {
5127
+ if (!all || !spawned.stdout && !spawned.stderr) {
5128
+ return;
5129
+ }
5130
+ const mixed = (0, import_merge_stream2.default)();
5131
+ if (spawned.stdout) {
5132
+ mixed.add(spawned.stdout);
5133
+ }
5134
+ if (spawned.stderr) {
5135
+ mixed.add(spawned.stderr);
5136
+ }
5137
+ return mixed;
5138
+ };
5139
+ var getBufferedData2 = async (stream2, streamPromise) => {
5140
+ if (!stream2 || streamPromise === void 0) {
5141
+ return;
5142
+ }
5143
+ await setTimeout$1(0);
5144
+ stream2.destroy();
5145
+ try {
5146
+ return await streamPromise;
5147
+ } catch (error) {
5148
+ return error.bufferedData;
5149
+ }
5150
+ };
5151
+ var getStreamPromise2 = (stream2, { encoding, buffer, maxBuffer }) => {
5152
+ if (!stream2 || !buffer) {
5153
+ return;
5154
+ }
5155
+ if (encoding === "utf8" || encoding === "utf-8") {
5156
+ return getStreamAsString(stream2, { maxBuffer });
5157
+ }
5158
+ if (encoding === null || encoding === "buffer") {
5159
+ return getStreamAsBuffer(stream2, { maxBuffer });
5160
+ }
5161
+ return applyEncoding(stream2, maxBuffer, encoding);
5162
+ };
5163
+ var applyEncoding = async (stream2, maxBuffer, encoding) => {
5164
+ const buffer = await getStreamAsBuffer(stream2, { maxBuffer });
5165
+ return buffer.toString(encoding);
5166
+ };
5167
+ var getSpawnedResult2 = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
5168
+ const stdoutPromise = getStreamPromise2(stdout, { encoding, buffer, maxBuffer });
5169
+ const stderrPromise = getStreamPromise2(stderr, { encoding, buffer, maxBuffer });
5170
+ const allPromise = getStreamPromise2(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
5171
+ try {
5172
+ return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
5173
+ } catch (error) {
5174
+ return Promise.all([
5175
+ { error, signal: error.signal, timedOut: error.timedOut },
5176
+ getBufferedData2(stdout, stdoutPromise),
5177
+ getBufferedData2(stderr, stderrPromise),
5178
+ getBufferedData2(all, allPromise)
5179
+ ]);
5180
+ }
5181
+ };
5182
+
5183
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/promise.js
5184
+ var nativePromisePrototype2 = (async () => {
5185
+ })().constructor.prototype;
5186
+ var descriptors2 = ["then", "catch", "finally"].map((property) => [
5187
+ property,
5188
+ Reflect.getOwnPropertyDescriptor(nativePromisePrototype2, property)
5189
+ ]);
5190
+ var mergePromise2 = (spawned, promise) => {
5191
+ for (const [property, descriptor] of descriptors2) {
5192
+ const value = typeof promise === "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
5193
+ Reflect.defineProperty(spawned, property, { ...descriptor, value });
5194
+ }
5195
+ };
5196
+ var getSpawnedPromise2 = (spawned) => new Promise((resolve, reject) => {
5197
+ spawned.on("exit", (exitCode, signal) => {
5198
+ resolve({ exitCode, signal });
5199
+ });
5200
+ spawned.on("error", (error) => {
5201
+ reject(error);
5202
+ });
5203
+ if (spawned.stdin) {
5204
+ spawned.stdin.on("error", (error) => {
5205
+ reject(error);
5206
+ });
5207
+ }
5208
+ });
5209
+ var normalizeArgs2 = (file, args = []) => {
5210
+ if (!Array.isArray(args)) {
5211
+ return [file];
5212
+ }
5213
+ return [file, ...args];
5214
+ };
5215
+ var NO_ESCAPE_REGEXP2 = /^[\w.-]+$/;
5216
+ var escapeArg2 = (arg) => {
5217
+ if (typeof arg !== "string" || NO_ESCAPE_REGEXP2.test(arg)) {
5218
+ return arg;
5219
+ }
5220
+ return `"${arg.replaceAll('"', '\\"')}"`;
5221
+ };
5222
+ var joinCommand2 = (file, args) => normalizeArgs2(file, args).join(" ");
5223
+ var getEscapedCommand2 = (file, args) => normalizeArgs2(file, args).map((arg) => escapeArg2(arg)).join(" ");
5224
+ var verboseDefault = debuglog("execa").enabled;
5225
+ var padField = (field, padding) => String(field).padStart(padding, "0");
5226
+ var getTimestamp = () => {
5227
+ const date = /* @__PURE__ */ new Date();
5228
+ return `${padField(date.getHours(), 2)}:${padField(date.getMinutes(), 2)}:${padField(date.getSeconds(), 2)}.${padField(date.getMilliseconds(), 3)}`;
5229
+ };
5230
+ var logCommand = (escapedCommand, { verbose }) => {
5231
+ if (!verbose) {
5232
+ return;
5233
+ }
5234
+ process2.stderr.write(`[${getTimestamp()}] ${escapedCommand}
5235
+ `);
5236
+ };
5237
+
5238
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js
5239
+ var DEFAULT_MAX_BUFFER2 = 1e3 * 1e3 * 100;
5240
+ var getEnv2 = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
5241
+ const env = extendEnv ? { ...process2.env, ...envOption } : envOption;
5242
+ if (preferLocal) {
5243
+ return npmRunPathEnv({ env, cwd: localDir, execPath });
5244
+ }
5245
+ return env;
5246
+ };
5247
+ var handleArguments2 = (file, args, options = {}) => {
5248
+ const parsed = import_cross_spawn2.default._parse(file, args, options);
5249
+ file = parsed.command;
5250
+ args = parsed.args;
5251
+ options = parsed.options;
5252
+ options = {
5253
+ maxBuffer: DEFAULT_MAX_BUFFER2,
5254
+ buffer: true,
5255
+ stripFinalNewline: true,
5256
+ extendEnv: true,
5257
+ preferLocal: false,
5258
+ localDir: options.cwd || process2.cwd(),
5259
+ execPath: process2.execPath,
5260
+ encoding: "utf8",
5261
+ reject: true,
5262
+ cleanup: true,
5263
+ all: false,
5264
+ windowsHide: true,
5265
+ verbose: verboseDefault,
5266
+ ...options
5267
+ };
5268
+ options.env = getEnv2(options);
5269
+ options.stdio = normalizeStdio2(options);
5270
+ if (process2.platform === "win32" && path.basename(file, ".exe") === "cmd") {
5271
+ args.unshift("/q");
5272
+ }
5273
+ return { file, args, options, parsed };
5274
+ };
5275
+ var handleOutput2 = (options, value, error) => {
5276
+ if (typeof value !== "string" && !Buffer$1.isBuffer(value)) {
5277
+ return error === void 0 ? void 0 : "";
5278
+ }
5279
+ if (options.stripFinalNewline) {
5280
+ return stripFinalNewline(value);
5281
+ }
5282
+ return value;
5283
+ };
5284
+ function execa2(file, args, options) {
5285
+ const parsed = handleArguments2(file, args, options);
5286
+ const command = joinCommand2(file, args);
5287
+ const escapedCommand = getEscapedCommand2(file, args);
5288
+ logCommand(escapedCommand, parsed.options);
5289
+ validateTimeout2(parsed.options);
5290
+ let spawned;
5291
+ try {
5292
+ spawned = childProcess2.spawn(parsed.file, parsed.args, parsed.options);
5293
+ } catch (error) {
5294
+ const dummySpawned = new childProcess2.ChildProcess();
5295
+ const errorPromise = Promise.reject(makeError2({
5296
+ error,
5297
+ stdout: "",
5298
+ stderr: "",
5299
+ all: "",
5300
+ command,
5301
+ escapedCommand,
5302
+ parsed,
5303
+ timedOut: false,
5304
+ isCanceled: false,
5305
+ killed: false
5306
+ }));
5307
+ mergePromise2(dummySpawned, errorPromise);
5308
+ return dummySpawned;
5309
+ }
5310
+ const spawnedPromise = getSpawnedPromise2(spawned);
5311
+ const timedPromise = setupTimeout2(spawned, parsed.options, spawnedPromise);
5312
+ const processDone = setExitHandler2(spawned, parsed.options, timedPromise);
5313
+ const context = { isCanceled: false };
5314
+ spawned.kill = spawnedKill2.bind(null, spawned.kill.bind(spawned));
5315
+ spawned.cancel = spawnedCancel2.bind(null, spawned, context);
5316
+ const handlePromise = async () => {
5317
+ const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult2(spawned, parsed.options, processDone);
5318
+ const stdout = handleOutput2(parsed.options, stdoutResult);
5319
+ const stderr = handleOutput2(parsed.options, stderrResult);
5320
+ const all = handleOutput2(parsed.options, allResult);
5321
+ if (error || exitCode !== 0 || signal !== null) {
5322
+ const returnedError = makeError2({
5323
+ error,
5324
+ exitCode,
5325
+ signal,
5326
+ stdout,
5327
+ stderr,
5328
+ all,
5329
+ command,
5330
+ escapedCommand,
5331
+ parsed,
5332
+ timedOut,
5333
+ isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
5334
+ killed: spawned.killed
5335
+ });
5336
+ if (!parsed.options.reject) {
5337
+ return returnedError;
5338
+ }
5339
+ throw returnedError;
5340
+ }
5341
+ return {
5342
+ command,
5343
+ escapedCommand,
5344
+ exitCode: 0,
5345
+ stdout,
5346
+ stderr,
5347
+ all,
5348
+ failed: false,
5349
+ timedOut: false,
5350
+ isCanceled: false,
5351
+ killed: false
5352
+ };
5353
+ };
5354
+ const handlePromiseOnce = onetime_default(handlePromise);
5355
+ handleInput2(spawned, parsed.options);
5356
+ spawned.all = makeAllStream2(spawned, parsed.options);
5357
+ addPipeMethods(spawned);
5358
+ mergePromise2(spawned, handlePromiseOnce);
5359
+ return spawned;
5360
+ }
5361
+
5362
+ // ../../node_modules/.pnpm/indent-string@5.0.0/node_modules/indent-string/index.js
5363
+ function indentString(string, count = 1, options = {}) {
5364
+ const {
5365
+ indent = " ",
5366
+ includeEmptyLines = false
5367
+ } = options;
5368
+ if (typeof string !== "string") {
5369
+ throw new TypeError(
5370
+ `Expected \`input\` to be a \`string\`, got \`${typeof string}\``
5371
+ );
5372
+ }
5373
+ if (typeof count !== "number") {
5374
+ throw new TypeError(
5375
+ `Expected \`count\` to be a \`number\`, got \`${typeof count}\``
5376
+ );
5377
+ }
5378
+ if (count < 0) {
5379
+ throw new RangeError(
5380
+ `Expected \`count\` to be at least 0, got \`${count}\``
5381
+ );
5382
+ }
5383
+ if (typeof indent !== "string") {
5384
+ throw new TypeError(
5385
+ `Expected \`options.indent\` to be a \`string\`, got \`${typeof indent}\``
5386
+ );
5387
+ }
5388
+ if (count === 0) {
5389
+ return string;
5390
+ }
5391
+ const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
5392
+ return string.replace(regex, indent.repeat(count));
5393
+ }
5394
+
5395
+ // ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
5396
+ function escapeStringRegexp(string) {
5397
+ if (typeof string !== "string") {
5398
+ throw new TypeError("Expected a string");
5399
+ }
5400
+ return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
5401
+ }
5402
+ var getHomeDirectory = () => os.homedir().replace(/\\/g, "/");
5403
+ var home_directory_default = getHomeDirectory;
5404
+
5405
+ // ../../node_modules/.pnpm/clean-stack@5.3.0/node_modules/clean-stack/index.js
5406
+ var extractPathRegex = /\s+at.*[(\s](.*)\)?/;
5407
+ var pathRegex = /^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;
5408
+ function cleanStack(stack, { pretty = false, basePath, pathFilter } = {}) {
5409
+ const basePathRegex = basePath && new RegExp(`(file://)?${escapeStringRegexp(basePath.replace(/\\/g, "/"))}/?`, "g");
5410
+ const homeDirectory = pretty ? home_directory_default() : "";
5411
+ if (typeof stack !== "string") {
5412
+ return void 0;
5413
+ }
5414
+ return stack.replace(/\\/g, "/").split("\n").filter((line) => {
5415
+ const pathMatches = line.match(extractPathRegex);
5416
+ if (pathMatches === null || !pathMatches[1]) {
5417
+ return true;
5418
+ }
5419
+ const match2 = pathMatches[1];
5420
+ if (match2.includes(".app/Contents/Resources/electron.asar") || match2.includes(".app/Contents/Resources/default_app.asar") || match2.includes("node_modules/electron/dist/resources/electron.asar") || match2.includes("node_modules/electron/dist/resources/default_app.asar")) {
5421
+ return false;
5422
+ }
5423
+ return pathFilter ? !pathRegex.test(match2) && pathFilter(match2) : !pathRegex.test(match2);
5424
+ }).filter((line) => line.trim() !== "").map((line) => {
5425
+ if (basePathRegex) {
5426
+ line = line.replace(basePathRegex, "");
5427
+ }
5428
+ if (pretty) {
5429
+ line = line.replace(extractPathRegex, (m, p1) => {
5430
+ let filePath = p1;
5431
+ if (filePath.startsWith("file://")) {
5432
+ filePath = fileURLToPath(filePath);
5433
+ }
5434
+ filePath = filePath.replace(homeDirectory, "~");
5435
+ return m.replace(p1, filePath);
5436
+ });
5437
+ }
5438
+ return line;
5439
+ }).join("\n");
5440
+ }
5441
+
5442
+ // ../../node_modules/.pnpm/aggregate-error@5.0.0/node_modules/aggregate-error/index.js
5443
+ var cleanInternalStack = (stack) => stack.replaceAll(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, "");
5444
+ var AggregateError = class extends Error {
5445
+ #errors;
5446
+ name = "AggregateError";
5447
+ constructor(errors) {
5448
+ if (!Array.isArray(errors)) {
5449
+ throw new TypeError(`Expected input to be an Array, got ${typeof errors}`);
5450
+ }
5451
+ errors = errors.map((error) => {
5452
+ if (error instanceof Error) {
5453
+ return error;
5454
+ }
5455
+ if (error !== null && typeof error === "object") {
5456
+ return Object.assign(new Error(error.message), error);
5457
+ }
5458
+ return new Error(error);
5459
+ });
5460
+ let message = errors.map(
5461
+ (error) => (
5462
+ // The `stack` property is not standardized, so we can't assume it exists
5463
+ typeof error.stack === "string" && error.stack.length > 0 ? cleanInternalStack(cleanStack(error.stack)) : String(error)
5464
+ )
5465
+ ).join("\n");
5466
+ message = "\n" + indentString(message, 4);
5467
+ super(message);
5468
+ this.#errors = errors;
5469
+ }
5470
+ get errors() {
5471
+ return [...this.#errors];
5472
+ }
5473
+ };
5474
+ var netstat = async (type) => {
5475
+ const { stdout } = await execa2("netstat", ["-anv", "-p", type]);
5476
+ return stdout;
5477
+ };
5478
+ var macos = async () => {
5479
+ const result = await Promise.all([
5480
+ netstat("tcp"),
5481
+ netstat("udp")
5482
+ ]);
5483
+ const tcp = result[0];
5484
+ const headerStart = tcp.indexOf("\n") + 1;
5485
+ const header = tcp.slice(headerStart, tcp.indexOf("\n", headerStart));
5486
+ return {
5487
+ stdout: result.join("\n"),
5488
+ addressColumn: 3,
5489
+ // Some versions of macOS print two extra columns for rxbytes and
5490
+ // txbytes before pid. Unfortunately headers can't be parsed because
5491
+ // they're space separated but some contain spaces, so we use this
5492
+ // heuristic to distinguish the two netstat versions.
5493
+ pidColumn: header.includes("rxbytes") ? 10 : 8
5494
+ };
5495
+ };
5496
+ var linux = async () => {
5497
+ const { stdout } = await execa2("ss", ["-tunlp"]);
5498
+ return {
5499
+ stdout,
5500
+ addressColumn: 4,
5501
+ pidColumn: 6
5502
+ };
5503
+ };
5504
+ var windows = async () => {
5505
+ const { stdout } = await execa2("netstat", ["-ano"]);
5506
+ return {
5507
+ stdout,
5508
+ addressColumn: 1,
5509
+ pidColumn: 4
5510
+ };
5511
+ };
5512
+ var isProtocol = (value) => /^\s*(tcp|udp)/i.test(value);
5513
+ var parsePid = (pid) => {
5514
+ if (typeof pid !== "string") {
5515
+ return;
5516
+ }
5517
+ const { groups } = /(?:^|",|",pid=)(?<pid>\d+)/.exec(pid) || {};
5518
+ if (groups) {
5519
+ return Number.parseInt(groups.pid, 10);
5520
+ }
5521
+ };
5522
+ var getPort = (port, { lines, addressColumn, pidColumn }) => {
5523
+ const regex = new RegExp(`[.:]${port}$`);
5524
+ const foundPort = lines.find((line) => regex.test(line[addressColumn]));
5525
+ if (!foundPort) {
5526
+ throw new Error(`Could not find a process that uses port \`${port}\``);
5527
+ }
5528
+ return parsePid(foundPort[pidColumn]);
5529
+ };
5530
+ var implementation = process2.platform === "darwin" ? macos : process2.platform === "linux" ? linux : windows;
5531
+ var getList = async () => {
5532
+ const { stdout, addressColumn, pidColumn } = await implementation();
5533
+ const lines = stdout.split("\n").filter((line) => isProtocol(line)).map((line) => line.match(/\S+/g) || []);
5534
+ return { lines, addressColumn, pidColumn };
5535
+ };
5536
+ async function portToPid(port) {
5537
+ if (Array.isArray(port)) {
5538
+ const list = await getList();
5539
+ const tuples = await Promise.all(port.map((port_) => [port_, getPort(port_, list)]));
5540
+ return new Map(tuples);
5541
+ }
5542
+ if (!Number.isInteger(port)) {
5543
+ throw new TypeError(`Expected an integer, got ${typeof port}`);
5544
+ }
5545
+ return getPort(port, await getList());
5546
+ }
5547
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
5548
+ var TEN_MEGABYTES = 1e3 * 1e3 * 10;
5549
+ var execFile = promisify(childProcess2.execFile);
5550
+ var windows2 = async () => {
5551
+ let binary;
5552
+ switch (process2.arch) {
5553
+ case "x64":
5554
+ binary = "fastlist-0.3.0-x64.exe";
5555
+ break;
5556
+ case "ia32":
5557
+ binary = "fastlist-0.3.0-x86.exe";
5558
+ break;
5559
+ default:
5560
+ throw new Error(`Unsupported architecture: ${process2.arch}`);
5561
+ }
5562
+ const binaryPath = path.join(__dirname, "vendor", binary);
5563
+ const { stdout } = await execFile(binaryPath, {
5564
+ maxBuffer: TEN_MEGABYTES,
5565
+ windowsHide: true
5566
+ });
5567
+ return stdout.trim().split("\r\n").map((line) => line.split(" ")).map(([pid, ppid, name]) => ({
5568
+ pid: Number.parseInt(pid, 10),
5569
+ ppid: Number.parseInt(ppid, 10),
5570
+ name
5571
+ }));
5572
+ };
5573
+ var nonWindowsMultipleCalls = async (options = {}) => {
5574
+ const flags = (options.all === false ? "" : "a") + "wwxo";
5575
+ const returnValue = {};
5576
+ await Promise.all(["comm", "args", "ppid", "uid", "%cpu", "%mem"].map(async (cmd) => {
5577
+ const { stdout } = await execFile("ps", [flags, `pid,${cmd}`], { maxBuffer: TEN_MEGABYTES });
5578
+ for (let line of stdout.trim().split("\n").slice(1)) {
5579
+ line = line.trim();
5580
+ const [pid] = line.split(" ", 1);
5581
+ const value = line.slice(pid.length + 1).trim();
5582
+ if (returnValue[pid] === void 0) {
5583
+ returnValue[pid] = {};
5584
+ }
5585
+ returnValue[pid][cmd] = value;
5586
+ }
5587
+ }));
5588
+ return Object.entries(returnValue).filter(([, value]) => value.comm && value.args && value.ppid && value.uid && value["%cpu"] && value["%mem"]).map(([key, value]) => ({
5589
+ pid: Number.parseInt(key, 10),
5590
+ name: path.basename(value.comm),
5591
+ cmd: value.args,
5592
+ ppid: Number.parseInt(value.ppid, 10),
5593
+ uid: Number.parseInt(value.uid, 10),
5594
+ cpu: Number.parseFloat(value["%cpu"]),
5595
+ memory: Number.parseFloat(value["%mem"])
5596
+ }));
5597
+ };
5598
+ var ERROR_MESSAGE_PARSING_FAILED = "ps output parsing failed";
5599
+ var psOutputRegex = /^[ \t]*(?<pid>\d+)[ \t]+(?<ppid>\d+)[ \t]+(?<uid>[-\d]+)[ \t]+(?<cpu>\d+\.\d+)[ \t]+(?<memory>\d+\.\d+)[ \t]+(?<comm>.*)?/;
5600
+ var nonWindowsCall = async (options = {}) => {
5601
+ const flags = options.all === false ? "wwxo" : "awwxo";
5602
+ const psPromises = [
5603
+ execFile("ps", [flags, "pid,ppid,uid,%cpu,%mem,comm"], { maxBuffer: TEN_MEGABYTES }),
5604
+ execFile("ps", [flags, "pid,args"], { maxBuffer: TEN_MEGABYTES })
5605
+ ];
5606
+ const [psLines, psArgsLines] = (await Promise.all(psPromises)).map(({ stdout }) => stdout.trim().split("\n"));
5607
+ const psPids = new Set(psPromises.map((promise) => promise.child.pid));
5608
+ psLines.shift();
5609
+ psArgsLines.shift();
5610
+ const processCmds = {};
5611
+ for (const line of psArgsLines) {
5612
+ const [pid, cmds] = line.trim().split(" ");
5613
+ processCmds[pid] = cmds.join(" ");
5614
+ }
5615
+ const processes = psLines.map((line) => {
5616
+ const match2 = psOutputRegex.exec(line);
5617
+ if (match2 === null) {
5618
+ throw new Error(ERROR_MESSAGE_PARSING_FAILED);
5619
+ }
5620
+ const { pid, ppid, uid, cpu, memory, comm } = match2.groups;
5621
+ const processInfo = {
5622
+ pid: Number.parseInt(pid, 10),
5623
+ ppid: Number.parseInt(ppid, 10),
5624
+ uid: Number.parseInt(uid, 10),
5625
+ cpu: Number.parseFloat(cpu),
5626
+ memory: Number.parseFloat(memory),
5627
+ name: path.basename(comm),
5628
+ cmd: processCmds[pid]
5629
+ };
5630
+ return processInfo;
5631
+ }).filter((processInfo) => !psPids.has(processInfo.pid));
5632
+ return processes;
5633
+ };
5634
+ var nonWindows = async (options = {}) => {
5635
+ try {
5636
+ return await nonWindowsCall(options);
5637
+ } catch {
5638
+ return nonWindowsMultipleCalls(options);
5639
+ }
5640
+ };
5641
+ var psList = process2.platform === "win32" ? windows2 : nonWindows;
5642
+ var ps_list_default = psList;
5643
+
5644
+ // ../../node_modules/.pnpm/process-exists@5.0.0/node_modules/process-exists/index.js
5645
+ var linuxProcessMatchesName = (wantedProcessName, process13) => {
5646
+ if (typeof wantedProcessName === "string") {
5647
+ return process13.name === wantedProcessName || process13.cmd.split(" ")[0] === wantedProcessName;
2160
5648
  }
5649
+ return process13.pid === wantedProcessName;
2161
5650
  };
2162
- var responseViaCache = async (res, outgoing) => {
2163
- let [status, body, header] = res[cacheKey];
2164
- if (header instanceof Headers) {
2165
- header = buildOutgoingHttpHeaders(header);
5651
+ var nonLinuxProcessMatchesName = (wantedProcessName, process13) => {
5652
+ if (typeof wantedProcessName === "string") {
5653
+ return process13.name === wantedProcessName;
2166
5654
  }
2167
- if (typeof body === "string") {
2168
- header["Content-Length"] = Buffer.byteLength(body);
2169
- } else if (body instanceof Uint8Array) {
2170
- header["Content-Length"] = body.byteLength;
2171
- } else if (body instanceof Blob) {
2172
- header["Content-Length"] = body.size;
5655
+ return process13.pid === wantedProcessName;
5656
+ };
5657
+ var processMatchesName = process2.platform === "linux" ? linuxProcessMatchesName : nonLinuxProcessMatchesName;
5658
+ async function processExistsMultiple(processNames) {
5659
+ const processes = await ps_list_default();
5660
+ return new Map(processNames.map((processName) => [processName, processes.some((y) => processMatchesName(processName, y))]));
5661
+ }
5662
+ async function filterExistingProcesses(processNames) {
5663
+ const processes = await ps_list_default();
5664
+ return processNames.filter((processName) => processes.some((process_) => processMatchesName(processName, process_)));
5665
+ }
5666
+
5667
+ // ../../node_modules/.pnpm/fkill@9.0.0/node_modules/fkill/index.js
5668
+ var ALIVE_CHECK_MIN_INTERVAL = 5;
5669
+ var ALIVE_CHECK_MAX_INTERVAL = 1280;
5670
+ var TASKKILL_EXIT_CODE_FOR_PROCESS_FILTERING_SIGTERM = 255;
5671
+ var delay = (ms) => new Promise((resolve) => {
5672
+ setTimeout(resolve, ms);
5673
+ });
5674
+ var missingBinaryError = async (command, arguments_) => {
5675
+ try {
5676
+ return await execa2(command, arguments_);
5677
+ } catch (error) {
5678
+ if (error.code === "ENOENT") {
5679
+ const newError = new Error(`\`${command}\` doesn't seem to be installed and is required by fkill`);
5680
+ newError.sourceError = error;
5681
+ throw newError;
5682
+ }
5683
+ throw error;
2173
5684
  }
2174
- outgoing.writeHead(status, header);
2175
- if (typeof body === "string" || body instanceof Uint8Array) {
2176
- outgoing.end(body);
2177
- } else if (body instanceof Blob) {
2178
- outgoing.end(new Uint8Array(await body.arrayBuffer()));
2179
- } else {
2180
- flushHeaders(outgoing);
2181
- await writeFromReadableStream(body, outgoing)?.catch(
2182
- (e) => handleResponseError(e, outgoing)
2183
- );
5685
+ };
5686
+ var windowsKill = async (input, options) => {
5687
+ try {
5688
+ return await taskkill(input, {
5689
+ force: options.force,
5690
+ tree: options.tree === void 0 ? true : options.tree
5691
+ });
5692
+ } catch (error) {
5693
+ if (error.exitCode === TASKKILL_EXIT_CODE_FOR_PROCESS_FILTERING_SIGTERM && !options.force) {
5694
+ return;
5695
+ }
5696
+ throw error;
2184
5697
  }
2185
- outgoing[outgoingEnded]?.();
2186
5698
  };
2187
- var isPromise = (res) => typeof res.then === "function";
2188
- var responseViaResponseObject = async (res, outgoing, options = {}) => {
2189
- if (isPromise(res)) {
2190
- if (options.errorHandler) {
2191
- try {
2192
- res = await res;
2193
- } catch (err) {
2194
- const errRes = await options.errorHandler(err);
2195
- if (!errRes) {
2196
- return;
2197
- }
2198
- res = errRes;
2199
- }
5699
+ var macosKill = (input, options) => {
5700
+ const killByName = typeof input === "string";
5701
+ const command = killByName ? "pkill" : "kill";
5702
+ const arguments_ = [input];
5703
+ if (killByName && options.ignoreCase) {
5704
+ arguments_.unshift("-i");
5705
+ }
5706
+ if (killByName) {
5707
+ arguments_.unshift("-x");
5708
+ }
5709
+ if (options.force) {
5710
+ if (killByName) {
5711
+ arguments_.unshift("-KILL");
2200
5712
  } else {
2201
- res = await res.catch(handleFetchError);
5713
+ arguments_.unshift("-9");
2202
5714
  }
2203
5715
  }
2204
- if (cacheKey in res) {
2205
- return responseViaCache(res, outgoing);
5716
+ return missingBinaryError(command, arguments_);
5717
+ };
5718
+ var defaultKill = (input, options) => {
5719
+ const killByName = typeof input === "string";
5720
+ const command = killByName ? "killall" : "kill";
5721
+ const arguments_ = [input];
5722
+ if (options.force) {
5723
+ arguments_.unshift("-9");
2206
5724
  }
2207
- const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
2208
- if (res.body) {
2209
- const reader = res.body.getReader();
2210
- const values = [];
2211
- let done = false;
2212
- let currentReadPromise = void 0;
2213
- if (resHeaderRecord["transfer-encoding"] !== "chunked") {
2214
- let maxReadCount = 2;
2215
- for (let i = 0; i < maxReadCount; i++) {
2216
- currentReadPromise ||= reader.read();
2217
- const chunk = await readWithoutBlocking(currentReadPromise).catch((e) => {
2218
- console.error(e);
2219
- done = true;
2220
- });
2221
- if (!chunk) {
2222
- if (i === 1) {
2223
- await new Promise((resolve) => setTimeout(resolve));
2224
- maxReadCount = 3;
2225
- continue;
2226
- }
2227
- break;
2228
- }
2229
- currentReadPromise = void 0;
2230
- if (chunk.value) {
2231
- values.push(chunk.value);
2232
- }
2233
- if (chunk.done) {
2234
- done = true;
2235
- break;
2236
- }
2237
- }
2238
- if (done && !("content-length" in resHeaderRecord)) {
2239
- resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
2240
- }
2241
- }
2242
- outgoing.writeHead(res.status, resHeaderRecord);
2243
- values.forEach((value) => {
2244
- outgoing.write(value);
2245
- });
2246
- if (done) {
2247
- outgoing.end();
2248
- } else {
2249
- if (values.length === 0) {
2250
- flushHeaders(outgoing);
2251
- }
2252
- await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
2253
- }
2254
- } else if (resHeaderRecord[X_ALREADY_SENT]) ; else {
2255
- outgoing.writeHead(res.status, resHeaderRecord);
2256
- outgoing.end();
5725
+ if (killByName && options.ignoreCase) {
5726
+ arguments_.unshift("-I");
2257
5727
  }
2258
- outgoing[outgoingEnded]?.();
5728
+ return missingBinaryError(command, arguments_);
2259
5729
  };
2260
- var getRequestListener = (fetchCallback, options = {}) => {
2261
- const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
2262
- if (options.overrideGlobalObjects !== false && global.Request !== Request2) {
2263
- Object.defineProperty(global, "Request", {
2264
- value: Request2
2265
- });
2266
- Object.defineProperty(global, "Response", {
2267
- value: Response2
2268
- });
5730
+ var kill = (() => {
5731
+ if (process2.platform === "darwin") {
5732
+ return macosKill;
2269
5733
  }
2270
- return async (incoming, outgoing) => {
2271
- let res, req;
2272
- try {
2273
- req = newRequest(incoming, options.hostname);
2274
- let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
2275
- if (!incomingEnded) {
2276
- ;
2277
- incoming[wrapBodyStream] = true;
2278
- incoming.on("end", () => {
2279
- incomingEnded = true;
2280
- });
2281
- if (incoming instanceof Http2ServerRequest) {
2282
- ;
2283
- outgoing[outgoingEnded] = () => {
2284
- if (!incomingEnded) {
2285
- setTimeout(() => {
2286
- if (!incomingEnded) {
2287
- setTimeout(() => {
2288
- incoming.destroy();
2289
- outgoing.destroy();
2290
- });
2291
- }
2292
- });
2293
- }
2294
- };
2295
- }
2296
- }
2297
- outgoing.on("close", () => {
2298
- const abortController = req[abortControllerKey];
2299
- if (abortController) {
2300
- if (incoming.errored) {
2301
- req[abortControllerKey].abort(incoming.errored.toString());
2302
- } else if (!outgoing.writableFinished) {
2303
- req[abortControllerKey].abort("Client connection prematurely closed.");
2304
- }
2305
- }
2306
- if (!incomingEnded) {
2307
- setTimeout(() => {
2308
- if (!incomingEnded) {
2309
- setTimeout(() => {
2310
- incoming.destroy();
2311
- });
2312
- }
2313
- });
2314
- }
2315
- });
2316
- res = fetchCallback(req, { incoming, outgoing });
2317
- if (cacheKey in res) {
2318
- return responseViaCache(res, outgoing);
2319
- }
2320
- } catch (e) {
2321
- if (!res) {
2322
- if (options.errorHandler) {
2323
- res = await options.errorHandler(req ? e : toRequestError(e));
2324
- if (!res) {
2325
- return;
2326
- }
2327
- } else if (!req) {
2328
- res = handleRequestError();
2329
- } else {
2330
- res = handleFetchError(e);
2331
- }
2332
- } else {
2333
- return handleResponseError(e, outgoing);
5734
+ if (process2.platform === "win32") {
5735
+ return windowsKill;
5736
+ }
5737
+ return defaultKill;
5738
+ })();
5739
+ var parseInput = async (input) => {
5740
+ if (typeof input === "string" && input[0] === ":") {
5741
+ return portToPid(Number.parseInt(input.slice(1), 10));
5742
+ }
5743
+ return input;
5744
+ };
5745
+ var getCurrentProcessParentsPID = (processes) => {
5746
+ const processMap = new Map(processes.map((ps) => [ps.pid, ps.ppid]));
5747
+ const pids = [];
5748
+ let currentId = process2.pid;
5749
+ while (currentId) {
5750
+ pids.push(currentId);
5751
+ currentId = processMap.get(currentId);
5752
+ }
5753
+ return pids;
5754
+ };
5755
+ var killWithLimits = async (input, options) => {
5756
+ input = await parseInput(input);
5757
+ if (input === process2.pid) {
5758
+ return;
5759
+ }
5760
+ if (input === "node" || input === "node.exe") {
5761
+ const processes = await ps_list_default();
5762
+ const pids = getCurrentProcessParentsPID(processes);
5763
+ await Promise.all(processes.map(async (ps) => {
5764
+ if ((ps.name === "node" || ps.name === "node.exe") && !pids.includes(ps.pid)) {
5765
+ await kill(ps.pid, options);
2334
5766
  }
2335
- }
5767
+ }));
5768
+ return;
5769
+ }
5770
+ await kill(input, options);
5771
+ };
5772
+ async function fkill(inputs, options = {}) {
5773
+ inputs = [inputs].flat();
5774
+ const exists = await processExistsMultiple(inputs);
5775
+ const errors = [];
5776
+ const handleKill = async (input) => {
2336
5777
  try {
2337
- return await responseViaResponseObject(res, outgoing, options);
2338
- } catch (e) {
2339
- return handleResponseError(e, outgoing);
5778
+ await killWithLimits(input, options);
5779
+ } catch (error) {
5780
+ if (!exists.get(input)) {
5781
+ errors.push(`Killing process ${input} failed: Process doesn't exist`);
5782
+ return;
5783
+ }
5784
+ errors.push(`Killing process ${input} failed: ${error.message.replace(/.*\n/, "").replace(/kill: \d+: /, "").trim()}`);
2340
5785
  }
2341
5786
  };
2342
- };
2343
- var createAdaptorServer = (options) => {
2344
- const fetchCallback = options.fetch;
2345
- const requestListener = getRequestListener(fetchCallback, {
2346
- hostname: options.hostname,
2347
- overrideGlobalObjects: options.overrideGlobalObjects,
2348
- autoCleanupIncoming: options.autoCleanupIncoming
2349
- });
2350
- const createServer2 = options.createServer || createServer$1;
2351
- const server = createServer2(options.serverOptions || {}, requestListener);
2352
- return server;
2353
- };
2354
- var serve = (options, listeningListener) => {
2355
- const server = createAdaptorServer(options);
2356
- server.listen(options?.port ?? 3e3, options.hostname, () => {
2357
- server.address();
2358
- });
2359
- return server;
2360
- };
5787
+ await Promise.all(inputs.map((input) => handleKill(input)));
5788
+ if (errors.length > 0 && !options.silent) {
5789
+ throw new AggregateError(errors);
5790
+ }
5791
+ if (options.forceAfterTimeout !== void 0 && !options.force) {
5792
+ const endTime = Date.now() + options.forceAfterTimeout;
5793
+ let interval = ALIVE_CHECK_MIN_INTERVAL;
5794
+ if (interval > options.forceAfterTimeout) {
5795
+ interval = options.forceAfterTimeout;
5796
+ }
5797
+ let alive = inputs;
5798
+ do {
5799
+ await delay(interval);
5800
+ alive = await filterExistingProcesses(alive);
5801
+ interval *= 2;
5802
+ if (interval > ALIVE_CHECK_MAX_INTERVAL) {
5803
+ interval = ALIVE_CHECK_MAX_INTERVAL;
5804
+ }
5805
+ } while (Date.now() < endTime && alive.length > 0);
5806
+ if (alive.length > 0) {
5807
+ await Promise.all(alive.map(async (input) => {
5808
+ try {
5809
+ await killWithLimits(input, { ...options, force: true });
5810
+ } catch {
5811
+ }
5812
+ }));
5813
+ }
5814
+ }
5815
+ }
2361
5816
 
2362
5817
  // src/server.ts
2363
5818
  var import_picocolors = __toESM(require_picocolors());
@@ -2388,8 +5843,8 @@ var __export = (target, all) => {
2388
5843
  });
2389
5844
  };
2390
5845
  var require_uri_all = __commonJS2((exports, module) => {
2391
- (function(global2, factory) {
2392
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : factory(global2.URI = global2.URI || {});
5846
+ (function(global22, factory) {
5847
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : factory(global22.URI = global22.URI || {});
2393
5848
  })(exports, function(exports2) {
2394
5849
  function merge() {
2395
5850
  for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
@@ -3193,8 +6648,8 @@ var require_uri_all = __commonJS2((exports, module) => {
3193
6648
  wsComponents.secure = void 0;
3194
6649
  }
3195
6650
  if (wsComponents.resourceName) {
3196
- var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), path = _wsComponents$resourc2[0], query2 = _wsComponents$resourc2[1];
3197
- wsComponents.path = path && path !== "/" ? path : void 0;
6651
+ var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), path5 = _wsComponents$resourc2[0], query2 = _wsComponents$resourc2[1];
6652
+ wsComponents.path = path5 && path5 !== "/" ? path5 : void 0;
3198
6653
  wsComponents.query = query2;
3199
6654
  wsComponents.resourceName = void 0;
3200
6655
  }
@@ -3580,12 +7035,12 @@ var require_util = __commonJS2((exports, module) => {
3580
7035
  return "'" + escapeQuotes(str) + "'";
3581
7036
  }
3582
7037
  function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
3583
- var path = jsonPointers ? "'/' + " + expr + (isNumber ? "" : ".replace(/~/g, '~0').replace(/\\//g, '~1')") : isNumber ? "'[' + " + expr + " + ']'" : "'[\\'' + " + expr + " + '\\']'";
3584
- return joinPaths(currentPath, path);
7038
+ var path5 = jsonPointers ? "'/' + " + expr + (isNumber ? "" : ".replace(/~/g, '~0').replace(/\\//g, '~1')") : isNumber ? "'[' + " + expr + " + ']'" : "'[\\'' + " + expr + " + '\\']'";
7039
+ return joinPaths(currentPath, path5);
3585
7040
  }
3586
7041
  function getPath2(currentPath, prop, jsonPointers) {
3587
- var path = jsonPointers ? toQuotedString("/" + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
3588
- return joinPaths(currentPath, path);
7042
+ var path5 = jsonPointers ? toQuotedString("/" + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
7043
+ return joinPaths(currentPath, path5);
3589
7044
  }
3590
7045
  var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
3591
7046
  var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
@@ -8443,7 +11898,7 @@ var require_ajv = __commonJS2((exports, module) => {
8443
11898
  function setLogger(self2) {
8444
11899
  var logger = self2._opts.logger;
8445
11900
  if (logger === false) {
8446
- self2.logger = { log: noop, warn: noop, error: noop };
11901
+ self2.logger = { log: noop2, warn: noop2, error: noop2 };
8447
11902
  } else {
8448
11903
  if (logger === void 0)
8449
11904
  logger = console;
@@ -8452,7 +11907,7 @@ var require_ajv = __commonJS2((exports, module) => {
8452
11907
  self2.logger = logger;
8453
11908
  }
8454
11909
  }
8455
- function noop() {
11910
+ function noop2() {
8456
11911
  }
8457
11912
  });
8458
11913
  var DEFAULT_MAX_LISTENERS = 50;
@@ -8518,39 +11973,39 @@ var NodeFsOperations = {
8518
11973
  }
8519
11974
  }
8520
11975
  },
8521
- appendFileSync(path, data, options) {
8522
- if (!fs.existsSync(path)) {
11976
+ appendFileSync(path5, data, options) {
11977
+ if (!fs.existsSync(path5)) {
8523
11978
  const mode = options?.mode ?? 384;
8524
- const fd = fs.openSync(path, "a", mode);
11979
+ const fd = fs.openSync(path5, "a", mode);
8525
11980
  try {
8526
11981
  fs.appendFileSync(fd, data);
8527
11982
  } finally {
8528
11983
  fs.closeSync(fd);
8529
11984
  }
8530
11985
  } else {
8531
- fs.appendFileSync(path, data);
11986
+ fs.appendFileSync(path5, data);
8532
11987
  }
8533
11988
  },
8534
11989
  copyFileSync(src, dest) {
8535
11990
  fs.copyFileSync(src, dest);
8536
11991
  },
8537
- unlinkSync(path) {
8538
- fs.unlinkSync(path);
11992
+ unlinkSync(path5) {
11993
+ fs.unlinkSync(path5);
8539
11994
  },
8540
11995
  renameSync(oldPath, newPath) {
8541
11996
  fs.renameSync(oldPath, newPath);
8542
11997
  },
8543
- linkSync(target, path) {
8544
- fs.linkSync(target, path);
11998
+ linkSync(target, path5) {
11999
+ fs.linkSync(target, path5);
8545
12000
  },
8546
- symlinkSync(target, path) {
8547
- fs.symlinkSync(target, path);
12001
+ symlinkSync(target, path5) {
12002
+ fs.symlinkSync(target, path5);
8548
12003
  },
8549
- readlinkSync(path) {
8550
- return fs.readlinkSync(path);
12004
+ readlinkSync(path5) {
12005
+ return fs.readlinkSync(path5);
8551
12006
  },
8552
- realpathSync(path) {
8553
- return fs.realpathSync(path);
12007
+ realpathSync(path5) {
12008
+ return fs.realpathSync(path5);
8554
12009
  },
8555
12010
  mkdirSync(dirPath) {
8556
12011
  if (!fs.existsSync(dirPath)) {
@@ -8570,11 +12025,11 @@ var NodeFsOperations = {
8570
12025
  rmdirSync(dirPath) {
8571
12026
  fs.rmdirSync(dirPath);
8572
12027
  },
8573
- rmSync(path, options) {
8574
- fs.rmSync(path, options);
12028
+ rmSync(path5, options) {
12029
+ fs.rmSync(path5, options);
8575
12030
  },
8576
- createWriteStream(path) {
8577
- return fs.createWriteStream(path);
12031
+ createWriteStream(path5) {
12032
+ return fs.createWriteStream(path5);
8578
12033
  }
8579
12034
  };
8580
12035
  var activeFs = NodeFsOperations;
@@ -8736,8 +12191,7 @@ var ProcessTransport = class {
8736
12191
  env.CLAUDE_CODE_ENTRYPOINT = "sdk-ts";
8737
12192
  }
8738
12193
  const fs2 = getFsImplementation();
8739
- const isPathCommand = !pathToClaudeCodeExecutable.includes('/') && !pathToClaudeCodeExecutable.includes('\\');
8740
- if (!isPathCommand && !fs2.existsSync(pathToClaudeCodeExecutable)) {
12194
+ if (!fs2.existsSync(pathToClaudeCodeExecutable)) {
8741
12195
  const errorMessage = isNativeBinary(pathToClaudeCodeExecutable) ? `Claude Code native binary not found at ${pathToClaudeCodeExecutable}. Please ensure Claude Code is installed via native installer or specify a valid path with options.pathToClaudeCodeExecutable.` : `Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`;
8742
12196
  throw new ReferenceError(errorMessage);
8743
12197
  }
@@ -9086,10 +12540,10 @@ function getRawTag(value) {
9086
12540
  var _getRawTag_default = getRawTag;
9087
12541
  var objectProto2 = Object.prototype;
9088
12542
  var nativeObjectToString2 = objectProto2.toString;
9089
- function objectToString(value) {
12543
+ function objectToString2(value) {
9090
12544
  return nativeObjectToString2.call(value);
9091
12545
  }
9092
- var _objectToString_default = objectToString;
12546
+ var _objectToString_default = objectToString2;
9093
12547
  var nullTag = "[object Null]";
9094
12548
  var undefinedTag = "[object Undefined]";
9095
12549
  var symToStringTag2 = _Symbol_default ? _Symbol_default.toStringTag : void 0;
@@ -10499,8 +13953,8 @@ function getErrorMap() {
10499
13953
  return overrideErrorMap;
10500
13954
  }
10501
13955
  var makeIssue = (params) => {
10502
- const { data, path, errorMaps, issueData } = params;
10503
- const fullPath = [...path, ...issueData.path || []];
13956
+ const { data, path: path5, errorMaps, issueData } = params;
13957
+ const fullPath = [...path5, ...issueData.path || []];
10504
13958
  const fullIssue = {
10505
13959
  ...issueData,
10506
13960
  path: fullPath
@@ -10608,11 +14062,11 @@ var errorUtil;
10608
14062
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
10609
14063
  })(errorUtil || (errorUtil = {}));
10610
14064
  var ParseInputLazyPath = class {
10611
- constructor(parent, value, path, key) {
14065
+ constructor(parent, value, path5, key) {
10612
14066
  this._cachedPath = [];
10613
14067
  this.parent = parent;
10614
14068
  this.data = value;
10615
- this._path = path;
14069
+ this._path = path5;
10616
14070
  this._key = key;
10617
14071
  }
10618
14072
  get path() {
@@ -14551,7 +18005,12 @@ function query({
14551
18005
  } else if (systemPrompt.type === "preset") {
14552
18006
  appendSystemPrompt = systemPrompt.append;
14553
18007
  }
14554
- let pathToClaudeCodeExecutable = rest.pathToClaudeCodeExecutable || "claude";
18008
+ let pathToClaudeCodeExecutable = rest.pathToClaudeCodeExecutable;
18009
+ if (!pathToClaudeCodeExecutable) {
18010
+ const filename = fileURLToPath(import.meta.url);
18011
+ const dirname2 = join(filename, "..");
18012
+ pathToClaudeCodeExecutable = join(dirname2, "cli.js");
18013
+ }
14555
18014
  process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.46";
14556
18015
  const {
14557
18016
  abortController = createAbortController(),
@@ -14670,30 +18129,55 @@ function query({
14670
18129
  var DEFAULT_PORT = 4567;
14671
18130
 
14672
18131
  // src/server.ts
14673
- var VERSION = "0.0.78";
18132
+ var VERSION = "0.0.81";
18133
+ var resolveClaudePath = () => {
18134
+ const command = process.platform === "win32" ? "where claude" : "which claude";
18135
+ try {
18136
+ const result = execSync(command, { encoding: "utf8" }).trim();
18137
+ return result.split("\n")[0];
18138
+ } catch {
18139
+ return "claude";
18140
+ }
18141
+ };
18142
+ var claudeSessionMap = /* @__PURE__ */ new Map();
18143
+ var abortedSessions = /* @__PURE__ */ new Set();
18144
+ var lastClaudeSessionId;
14674
18145
  var isTextBlock = (block) => block.type === "text";
14675
18146
  var createServer = () => {
14676
18147
  const app = new Hono2();
14677
- app.use("/*", cors());
18148
+ app.use("*", cors());
14678
18149
  app.post("/agent", async (context) => {
14679
18150
  const body = await context.req.json();
14680
- const { content, prompt, options } = body;
14681
- const fullPrompt = `${prompt}
18151
+ const { content, prompt, options, sessionId } = body;
18152
+ const claudeSessionId = sessionId ? claudeSessionMap.get(sessionId) : void 0;
18153
+ const isFollowUp = Boolean(claudeSessionId);
18154
+ const userPrompt = isFollowUp ? prompt : `${prompt}
14682
18155
 
14683
18156
  ${content}`;
14684
18157
  return streamSSE(context, async (stream2) => {
18158
+ const isAborted2 = () => sessionId && abortedSessions.has(sessionId);
14685
18159
  try {
14686
18160
  await stream2.writeSSE({ data: "Thinking...", event: "status" });
18161
+ const env = { ...process.env };
18162
+ delete env.NODE_OPTIONS;
18163
+ delete env.VSCODE_INSPECTOR_OPTIONS;
14687
18164
  const queryResult = query({
14688
- prompt: fullPrompt,
18165
+ prompt: userPrompt,
14689
18166
  options: {
14690
- pathToClaudeCodeExecutable: "claude",
18167
+ pathToClaudeCodeExecutable: resolveClaudePath(),
14691
18168
  cwd: process.cwd(),
14692
18169
  includePartialMessages: true,
14693
- ...options
18170
+ env,
18171
+ ...options,
18172
+ ...isFollowUp && claudeSessionId ? { resume: claudeSessionId } : {}
14694
18173
  }
14695
18174
  });
18175
+ let capturedClaudeSessionId;
14696
18176
  for await (const message of queryResult) {
18177
+ if (isAborted2()) break;
18178
+ if (!capturedClaudeSessionId && message.session_id) {
18179
+ capturedClaudeSessionId = message.session_id;
18180
+ }
14697
18181
  if (message.type === "assistant") {
14698
18182
  const textContent = message.message.content.filter(isTextBlock).map((block) => block.text).join(" ");
14699
18183
  if (textContent) {
@@ -14707,37 +18191,79 @@ ${content}`;
14707
18191
  });
14708
18192
  }
14709
18193
  }
14710
- await stream2.writeSSE({ data: "", event: "done" });
18194
+ if (!isAborted2() && capturedClaudeSessionId) {
18195
+ lastClaudeSessionId = capturedClaudeSessionId;
18196
+ if (sessionId) {
18197
+ claudeSessionMap.set(sessionId, capturedClaudeSessionId);
18198
+ }
18199
+ }
18200
+ if (!isAborted2()) {
18201
+ await stream2.writeSSE({ data: "", event: "done" });
18202
+ }
14711
18203
  } catch (error) {
14712
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
14713
- await stream2.writeSSE({
14714
- data: `Error: ${errorMessage}`,
14715
- event: "error"
14716
- });
18204
+ if (!isAborted2()) {
18205
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
18206
+ const stderr = error instanceof Error && "stderr" in error ? String(error.stderr) : void 0;
18207
+ const fullError = stderr && stderr.trim() ? `${errorMessage}
18208
+
18209
+ stderr:
18210
+ ${stderr.trim()}` : errorMessage;
18211
+ await stream2.writeSSE({
18212
+ data: `Error: ${fullError}`,
18213
+ event: "error"
18214
+ });
18215
+ }
18216
+ } finally {
18217
+ if (sessionId) {
18218
+ abortedSessions.delete(sessionId);
18219
+ }
14717
18220
  }
14718
18221
  });
14719
18222
  });
18223
+ app.post("/abort/:sessionId", (context) => {
18224
+ const { sessionId } = context.req.param();
18225
+ abortedSessions.add(sessionId);
18226
+ return context.json({ status: "ok" });
18227
+ });
18228
+ app.post("/undo", async (context) => {
18229
+ if (!lastClaudeSessionId) {
18230
+ return context.json({ status: "error", message: "No session to undo" });
18231
+ }
18232
+ try {
18233
+ const env = { ...process.env };
18234
+ delete env.NODE_OPTIONS;
18235
+ delete env.VSCODE_INSPECTOR_OPTIONS;
18236
+ const queryResult = query({
18237
+ prompt: "/rewind",
18238
+ options: {
18239
+ pathToClaudeCodeExecutable: resolveClaudePath(),
18240
+ cwd: process.cwd(),
18241
+ env,
18242
+ resume: lastClaudeSessionId
18243
+ }
18244
+ });
18245
+ for await (const message of queryResult) {
18246
+ if (message.type === "result") break;
18247
+ }
18248
+ return context.json({ status: "ok" });
18249
+ } catch (error) {
18250
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
18251
+ return context.json({ status: "error", message: errorMessage });
18252
+ }
18253
+ });
14720
18254
  app.get("/health", (context) => {
14721
18255
  return context.json({ status: "ok", provider: "claude" });
14722
18256
  });
14723
18257
  return app;
14724
18258
  };
14725
- var isPortInUse = (port) => new Promise((resolve) => {
14726
- const server = net.createServer();
14727
- server.once("error", () => resolve(true));
14728
- server.once("listening", () => {
14729
- server.close();
14730
- resolve(false);
14731
- });
14732
- server.listen(port);
14733
- });
14734
18259
  var startServer = async (port = DEFAULT_PORT) => {
14735
- if (await isPortInUse(port)) {
14736
- return;
14737
- }
18260
+ await fkill(`:${port}`, { force: true, silent: true }).catch(() => {
18261
+ });
14738
18262
  const app = createServer();
14739
18263
  serve({ fetch: app.fetch, port });
14740
- console.log(`${import_picocolors.default.magenta("\u269B")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Claude Code)")}`);
18264
+ console.log(
18265
+ `${import_picocolors.default.magenta("\u269B")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Claude Code)")}`
18266
+ );
14741
18267
  console.log(`- Local: ${import_picocolors.default.cyan(`http://localhost:${port}`)}`);
14742
18268
  };
14743
18269
  if (import.meta.url === pathToFileURL(process.argv[1]).href) {