@react-grab/opencode 0.0.80 → 0.0.82

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,9 +1,16 @@
1
- import { spawn } from 'child_process';
1
+ import childProcess2, { ChildProcess, spawn } from 'child_process';
2
+ import process2 from 'process';
3
+ import { Buffer as Buffer$1 } from 'buffer';
4
+ import path from 'path';
5
+ import { fileURLToPath, pathToFileURL } from 'url';
6
+ import os, { constants } from 'os';
7
+ import { createReadStream, createWriteStream } from 'fs';
8
+ import { setTimeout as setTimeout$1 } from 'timers/promises';
9
+ import { debuglog, promisify } from 'util';
2
10
  import { createServer as createServer$1 } from 'http';
3
11
  import { Http2ServerRequest } from 'http2';
4
12
  import { Readable } from 'stream';
5
13
  import crypto from 'crypto';
6
- import { pathToFileURL } from 'url';
7
14
 
8
15
  var __create = Object.create;
9
16
  var __defProp = Object.defineProperty;
@@ -37,80 +44,823 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
44
  mod
38
45
  ));
39
46
 
40
- // ../../node_modules/.pnpm/shell-exec@1.0.2/node_modules/shell-exec/index.js
41
- var require_shell_exec = __commonJS({
42
- "../../node_modules/.pnpm/shell-exec@1.0.2/node_modules/shell-exec/index.js"(exports, module) {
43
- var childProcess = __require("child_process");
44
- function shellExec(cmd = "", opts = {}) {
45
- if (Array.isArray(cmd)) {
46
- cmd = cmd.join(";");
47
- }
48
- opts = Object.assign({ stdio: "pipe", cwd: process.cwd() }, opts);
49
- let child;
50
- const shell = process.platform === "win32" ? { cmd: "cmd", arg: "/C" } : { cmd: "sh", arg: "-c" };
51
- try {
52
- child = childProcess.spawn(shell.cmd, [shell.arg, cmd], opts);
53
- } catch (error) {
54
- return Promise.reject(error);
55
- }
56
- return new Promise((resolve) => {
57
- let stdout = "";
58
- let stderr = "";
59
- if (child.stdout) {
60
- child.stdout.on("data", (data) => {
61
- stdout += data;
62
- });
47
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
48
+ var require_windows = __commonJS({
49
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
50
+ module.exports = isexe;
51
+ isexe.sync = sync;
52
+ var fs = __require("fs");
53
+ function checkPathExt(path5, options) {
54
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
55
+ if (!pathext) {
56
+ return true;
57
+ }
58
+ pathext = pathext.split(";");
59
+ if (pathext.indexOf("") !== -1) {
60
+ return true;
61
+ }
62
+ for (var i = 0; i < pathext.length; i++) {
63
+ var p = pathext[i].toLowerCase();
64
+ if (p && path5.substr(-p.length).toLowerCase() === p) {
65
+ return true;
66
+ }
67
+ }
68
+ return false;
69
+ }
70
+ function checkStat(stat, path5, options) {
71
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
72
+ return false;
73
+ }
74
+ return checkPathExt(path5, options);
75
+ }
76
+ function isexe(path5, options, cb) {
77
+ fs.stat(path5, function(er, stat) {
78
+ cb(er, er ? false : checkStat(stat, path5, options));
79
+ });
80
+ }
81
+ function sync(path5, options) {
82
+ return checkStat(fs.statSync(path5), path5, options);
83
+ }
84
+ }
85
+ });
86
+
87
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
88
+ var require_mode = __commonJS({
89
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
90
+ module.exports = isexe;
91
+ isexe.sync = sync;
92
+ var fs = __require("fs");
93
+ function isexe(path5, options, cb) {
94
+ fs.stat(path5, function(er, stat) {
95
+ cb(er, er ? false : checkStat(stat, options));
96
+ });
97
+ }
98
+ function sync(path5, options) {
99
+ return checkStat(fs.statSync(path5), options);
100
+ }
101
+ function checkStat(stat, options) {
102
+ return stat.isFile() && checkMode(stat, options);
103
+ }
104
+ function checkMode(stat, options) {
105
+ var mod = stat.mode;
106
+ var uid = stat.uid;
107
+ var gid = stat.gid;
108
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
109
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
110
+ var u = parseInt("100", 8);
111
+ var g = parseInt("010", 8);
112
+ var o = parseInt("001", 8);
113
+ var ug = u | g;
114
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
115
+ return ret;
116
+ }
117
+ }
118
+ });
119
+
120
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
121
+ var require_isexe = __commonJS({
122
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
123
+ __require("fs");
124
+ var core;
125
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
126
+ core = require_windows();
127
+ } else {
128
+ core = require_mode();
129
+ }
130
+ module.exports = isexe;
131
+ isexe.sync = sync;
132
+ function isexe(path5, options, cb) {
133
+ if (typeof options === "function") {
134
+ cb = options;
135
+ options = {};
136
+ }
137
+ if (!cb) {
138
+ if (typeof Promise !== "function") {
139
+ throw new TypeError("callback not provided");
63
140
  }
64
- if (child.stderr) {
65
- child.stderr.on("data", (data) => {
66
- stderr += data;
141
+ return new Promise(function(resolve, reject) {
142
+ isexe(path5, options || {}, function(er, is) {
143
+ if (er) {
144
+ reject(er);
145
+ } else {
146
+ resolve(is);
147
+ }
67
148
  });
149
+ });
150
+ }
151
+ core(path5, options || {}, function(er, is) {
152
+ if (er) {
153
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
154
+ er = null;
155
+ is = false;
156
+ }
157
+ }
158
+ cb(er, is);
159
+ });
160
+ }
161
+ function sync(path5, options) {
162
+ try {
163
+ return core.sync(path5, options || {});
164
+ } catch (er) {
165
+ if (options && options.ignoreErrors || er.code === "EACCES") {
166
+ return false;
167
+ } else {
168
+ throw er;
68
169
  }
69
- child.on("error", (error) => {
70
- resolve({ error, stdout, stderr, cmd });
170
+ }
171
+ }
172
+ }
173
+ });
174
+
175
+ // ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
176
+ var require_which = __commonJS({
177
+ "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
178
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
179
+ var path5 = __require("path");
180
+ var COLON = isWindows ? ";" : ":";
181
+ var isexe = require_isexe();
182
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
183
+ var getPathInfo = (cmd, opt) => {
184
+ const colon = opt.colon || COLON;
185
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
186
+ // windows always checks the cwd first
187
+ ...isWindows ? [process.cwd()] : [],
188
+ ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
189
+ "").split(colon)
190
+ ];
191
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
192
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
193
+ if (isWindows) {
194
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
195
+ pathExt.unshift("");
196
+ }
197
+ return {
198
+ pathEnv,
199
+ pathExt,
200
+ pathExtExe
201
+ };
202
+ };
203
+ var which = (cmd, opt, cb) => {
204
+ if (typeof opt === "function") {
205
+ cb = opt;
206
+ opt = {};
207
+ }
208
+ if (!opt)
209
+ opt = {};
210
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
211
+ const found = [];
212
+ const step = (i) => new Promise((resolve, reject) => {
213
+ if (i === pathEnv.length)
214
+ return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
215
+ const ppRaw = pathEnv[i];
216
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
217
+ const pCmd = path5.join(pathPart, cmd);
218
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
219
+ resolve(subStep(p, i, 0));
220
+ });
221
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
222
+ if (ii === pathExt.length)
223
+ return resolve(step(i + 1));
224
+ const ext = pathExt[ii];
225
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
226
+ if (!er && is) {
227
+ if (opt.all)
228
+ found.push(p + ext);
229
+ else
230
+ return resolve(p + ext);
231
+ }
232
+ return resolve(subStep(p, i, ii + 1));
71
233
  });
72
- child.on("close", (code) => {
73
- resolve({ stdout, stderr, cmd, code });
234
+ });
235
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
236
+ };
237
+ var whichSync = (cmd, opt) => {
238
+ opt = opt || {};
239
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
240
+ const found = [];
241
+ for (let i = 0; i < pathEnv.length; i++) {
242
+ const ppRaw = pathEnv[i];
243
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
244
+ const pCmd = path5.join(pathPart, cmd);
245
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
246
+ for (let j = 0; j < pathExt.length; j++) {
247
+ const cur = p + pathExt[j];
248
+ try {
249
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
250
+ if (is) {
251
+ if (opt.all)
252
+ found.push(cur);
253
+ else
254
+ return cur;
255
+ }
256
+ } catch (ex) {
257
+ }
258
+ }
259
+ }
260
+ if (opt.all && found.length)
261
+ return found;
262
+ if (opt.nothrow)
263
+ return null;
264
+ throw getNotFoundError(cmd);
265
+ };
266
+ module.exports = which;
267
+ which.sync = whichSync;
268
+ }
269
+ });
270
+
271
+ // ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
272
+ var require_path_key = __commonJS({
273
+ "../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
274
+ var pathKey2 = (options = {}) => {
275
+ const environment = options.env || process.env;
276
+ const platform = options.platform || process.platform;
277
+ if (platform !== "win32") {
278
+ return "PATH";
279
+ }
280
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
281
+ };
282
+ module.exports = pathKey2;
283
+ module.exports.default = pathKey2;
284
+ }
285
+ });
286
+
287
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
288
+ var require_resolveCommand = __commonJS({
289
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
290
+ var path5 = __require("path");
291
+ var which = require_which();
292
+ var getPathKey = require_path_key();
293
+ function resolveCommandAttempt(parsed, withoutPathExt) {
294
+ const env = parsed.options.env || process.env;
295
+ const cwd = process.cwd();
296
+ const hasCustomCwd = parsed.options.cwd != null;
297
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
298
+ if (shouldSwitchCwd) {
299
+ try {
300
+ process.chdir(parsed.options.cwd);
301
+ } catch (err) {
302
+ }
303
+ }
304
+ let resolved;
305
+ try {
306
+ resolved = which.sync(parsed.command, {
307
+ path: env[getPathKey({ env })],
308
+ pathExt: withoutPathExt ? path5.delimiter : void 0
74
309
  });
310
+ } catch (e) {
311
+ } finally {
312
+ if (shouldSwitchCwd) {
313
+ process.chdir(cwd);
314
+ }
315
+ }
316
+ if (resolved) {
317
+ resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
318
+ }
319
+ return resolved;
320
+ }
321
+ function resolveCommand(parsed) {
322
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
323
+ }
324
+ module.exports = resolveCommand;
325
+ }
326
+ });
327
+
328
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
329
+ var require_escape = __commonJS({
330
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
331
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
332
+ function escapeCommand(arg) {
333
+ arg = arg.replace(metaCharsRegExp, "^$1");
334
+ return arg;
335
+ }
336
+ function escapeArgument(arg, doubleEscapeMetaChars) {
337
+ arg = `${arg}`;
338
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
339
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
340
+ arg = `"${arg}"`;
341
+ arg = arg.replace(metaCharsRegExp, "^$1");
342
+ if (doubleEscapeMetaChars) {
343
+ arg = arg.replace(metaCharsRegExp, "^$1");
344
+ }
345
+ return arg;
346
+ }
347
+ module.exports.command = escapeCommand;
348
+ module.exports.argument = escapeArgument;
349
+ }
350
+ });
351
+
352
+ // ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
353
+ var require_shebang_regex = __commonJS({
354
+ "../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
355
+ module.exports = /^#!(.*)/;
356
+ }
357
+ });
358
+
359
+ // ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
360
+ var require_shebang_command = __commonJS({
361
+ "../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
362
+ var shebangRegex = require_shebang_regex();
363
+ module.exports = (string = "") => {
364
+ const match2 = string.match(shebangRegex);
365
+ if (!match2) {
366
+ return null;
367
+ }
368
+ const [path5, argument] = match2[0].replace(/#! ?/, "").split(" ");
369
+ const binary = path5.split("/").pop();
370
+ if (binary === "env") {
371
+ return argument;
372
+ }
373
+ return argument ? `${binary} ${argument}` : binary;
374
+ };
375
+ }
376
+ });
377
+
378
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
379
+ var require_readShebang = __commonJS({
380
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
381
+ var fs = __require("fs");
382
+ var shebangCommand = require_shebang_command();
383
+ function readShebang(command) {
384
+ const size = 150;
385
+ const buffer = Buffer.alloc(size);
386
+ let fd;
387
+ try {
388
+ fd = fs.openSync(command, "r");
389
+ fs.readSync(fd, buffer, 0, size, 0);
390
+ fs.closeSync(fd);
391
+ } catch (e) {
392
+ }
393
+ return shebangCommand(buffer.toString());
394
+ }
395
+ module.exports = readShebang;
396
+ }
397
+ });
398
+
399
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
400
+ var require_parse = __commonJS({
401
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
402
+ var path5 = __require("path");
403
+ var resolveCommand = require_resolveCommand();
404
+ var escape = require_escape();
405
+ var readShebang = require_readShebang();
406
+ var isWin = process.platform === "win32";
407
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
408
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
409
+ function detectShebang(parsed) {
410
+ parsed.file = resolveCommand(parsed);
411
+ const shebang = parsed.file && readShebang(parsed.file);
412
+ if (shebang) {
413
+ parsed.args.unshift(parsed.file);
414
+ parsed.command = shebang;
415
+ return resolveCommand(parsed);
416
+ }
417
+ return parsed.file;
418
+ }
419
+ function parseNonShell(parsed) {
420
+ if (!isWin) {
421
+ return parsed;
422
+ }
423
+ const commandFile = detectShebang(parsed);
424
+ const needsShell = !isExecutableRegExp.test(commandFile);
425
+ if (parsed.options.forceShell || needsShell) {
426
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
427
+ parsed.command = path5.normalize(parsed.command);
428
+ parsed.command = escape.command(parsed.command);
429
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
430
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
431
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
432
+ parsed.command = process.env.comspec || "cmd.exe";
433
+ parsed.options.windowsVerbatimArguments = true;
434
+ }
435
+ return parsed;
436
+ }
437
+ function parse(command, args, options) {
438
+ if (args && !Array.isArray(args)) {
439
+ options = args;
440
+ args = null;
441
+ }
442
+ args = args ? args.slice(0) : [];
443
+ options = Object.assign({}, options);
444
+ const parsed = {
445
+ command,
446
+ args,
447
+ options,
448
+ file: void 0,
449
+ original: {
450
+ command,
451
+ args
452
+ }
453
+ };
454
+ return options.shell ? parsed : parseNonShell(parsed);
455
+ }
456
+ module.exports = parse;
457
+ }
458
+ });
459
+
460
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
461
+ var require_enoent = __commonJS({
462
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
463
+ var isWin = process.platform === "win32";
464
+ function notFoundError(original, syscall) {
465
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
466
+ code: "ENOENT",
467
+ errno: "ENOENT",
468
+ syscall: `${syscall} ${original.command}`,
469
+ path: original.command,
470
+ spawnargs: original.args
75
471
  });
76
472
  }
77
- module.exports = shellExec;
473
+ function hookChildProcess(cp, parsed) {
474
+ if (!isWin) {
475
+ return;
476
+ }
477
+ const originalEmit = cp.emit;
478
+ cp.emit = function(name, arg1) {
479
+ if (name === "exit") {
480
+ const err = verifyENOENT(arg1, parsed);
481
+ if (err) {
482
+ return originalEmit.call(cp, "error", err);
483
+ }
484
+ }
485
+ return originalEmit.apply(cp, arguments);
486
+ };
487
+ }
488
+ function verifyENOENT(status, parsed) {
489
+ if (isWin && status === 1 && !parsed.file) {
490
+ return notFoundError(parsed.original, "spawn");
491
+ }
492
+ return null;
493
+ }
494
+ function verifyENOENTSync(status, parsed) {
495
+ if (isWin && status === 1 && !parsed.file) {
496
+ return notFoundError(parsed.original, "spawnSync");
497
+ }
498
+ return null;
499
+ }
500
+ module.exports = {
501
+ hookChildProcess,
502
+ verifyENOENT,
503
+ verifyENOENTSync,
504
+ notFoundError
505
+ };
506
+ }
507
+ });
508
+
509
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
510
+ var require_cross_spawn = __commonJS({
511
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
512
+ var cp = __require("child_process");
513
+ var parse = require_parse();
514
+ var enoent = require_enoent();
515
+ function spawn2(command, args, options) {
516
+ const parsed = parse(command, args, options);
517
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
518
+ enoent.hookChildProcess(spawned, parsed);
519
+ return spawned;
520
+ }
521
+ function spawnSync(command, args, options) {
522
+ const parsed = parse(command, args, options);
523
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
524
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
525
+ return result;
526
+ }
527
+ module.exports = spawn2;
528
+ module.exports.spawn = spawn2;
529
+ module.exports.sync = spawnSync;
530
+ module.exports._parse = parse;
531
+ module.exports._enoent = enoent;
532
+ }
533
+ });
534
+
535
+ // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js
536
+ var require_signals = __commonJS({
537
+ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js"(exports, module) {
538
+ module.exports = [
539
+ "SIGABRT",
540
+ "SIGALRM",
541
+ "SIGHUP",
542
+ "SIGINT",
543
+ "SIGTERM"
544
+ ];
545
+ if (process.platform !== "win32") {
546
+ module.exports.push(
547
+ "SIGVTALRM",
548
+ "SIGXCPU",
549
+ "SIGXFSZ",
550
+ "SIGUSR2",
551
+ "SIGTRAP",
552
+ "SIGSYS",
553
+ "SIGQUIT",
554
+ "SIGIOT"
555
+ // should detect profiler and enable/disable accordingly.
556
+ // see #21
557
+ // 'SIGPROF'
558
+ );
559
+ }
560
+ if (process.platform === "linux") {
561
+ module.exports.push(
562
+ "SIGIO",
563
+ "SIGPOLL",
564
+ "SIGPWR",
565
+ "SIGSTKFLT",
566
+ "SIGUNUSED"
567
+ );
568
+ }
78
569
  }
79
570
  });
80
571
 
81
- // ../../node_modules/.pnpm/kill-port@2.0.1/node_modules/kill-port/index.js
82
- var require_kill_port = __commonJS({
83
- "../../node_modules/.pnpm/kill-port@2.0.1/node_modules/kill-port/index.js"(exports, module) {
84
- var sh = require_shell_exec();
85
- module.exports = function(port, method = "tcp") {
86
- port = Number.parseInt(port);
87
- if (!port) {
88
- return Promise.reject(new Error("Invalid port number provided"));
89
- }
90
- if (process.platform === "win32") {
91
- return sh("netstat -nao").then((res) => {
92
- const { stdout } = res;
93
- if (!stdout) return res;
94
- const lines = stdout.split("\n");
95
- const lineWithLocalPortRegEx = new RegExp(`^ *${method.toUpperCase()} *[^ ]*:${port}`, "gm");
96
- const linesWithLocalPort = lines.filter((line) => line.match(lineWithLocalPortRegEx));
97
- const pids = linesWithLocalPort.reduce((acc, line) => {
98
- const match2 = line.match(/(\d*)\w*(\n|$)/gm);
99
- return match2 && match2[0] && !acc.includes(match2[0]) ? acc.concat(match2[0]) : acc;
100
- }, []);
101
- return sh(`TaskKill /F /PID ${pids.join(" /PID ")}`);
572
+ // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js
573
+ var require_signal_exit = __commonJS({
574
+ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports, module) {
575
+ var process13 = global.process;
576
+ var processOk2 = function(process14) {
577
+ 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";
578
+ };
579
+ if (!processOk2(process13)) {
580
+ module.exports = function() {
581
+ return function() {
582
+ };
583
+ };
584
+ } else {
585
+ assert = __require("assert");
586
+ signals2 = require_signals();
587
+ isWin = /^win/i.test(process13.platform);
588
+ EE = __require("events");
589
+ if (typeof EE !== "function") {
590
+ EE = EE.EventEmitter;
591
+ }
592
+ if (process13.__signal_exit_emitter__) {
593
+ emitter = process13.__signal_exit_emitter__;
594
+ } else {
595
+ emitter = process13.__signal_exit_emitter__ = new EE();
596
+ emitter.count = 0;
597
+ emitter.emitted = {};
598
+ }
599
+ if (!emitter.infinite) {
600
+ emitter.setMaxListeners(Infinity);
601
+ emitter.infinite = true;
602
+ }
603
+ module.exports = function(cb, opts) {
604
+ if (!processOk2(global.process)) {
605
+ return function() {
606
+ };
607
+ }
608
+ assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
609
+ if (loaded === false) {
610
+ load2();
611
+ }
612
+ var ev = "exit";
613
+ if (opts && opts.alwaysLast) {
614
+ ev = "afterexit";
615
+ }
616
+ var remove = function() {
617
+ emitter.removeListener(ev, cb);
618
+ if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
619
+ unload2();
620
+ }
621
+ };
622
+ emitter.on(ev, cb);
623
+ return remove;
624
+ };
625
+ unload2 = function unload3() {
626
+ if (!loaded || !processOk2(global.process)) {
627
+ return;
628
+ }
629
+ loaded = false;
630
+ signals2.forEach(function(sig) {
631
+ try {
632
+ process13.removeListener(sig, sigListeners[sig]);
633
+ } catch (er) {
634
+ }
635
+ });
636
+ process13.emit = originalProcessEmit;
637
+ process13.reallyExit = originalProcessReallyExit;
638
+ emitter.count -= 1;
639
+ };
640
+ module.exports.unload = unload2;
641
+ emit = function emit2(event, code, signal) {
642
+ if (emitter.emitted[event]) {
643
+ return;
644
+ }
645
+ emitter.emitted[event] = true;
646
+ emitter.emit(event, code, signal);
647
+ };
648
+ sigListeners = {};
649
+ signals2.forEach(function(sig) {
650
+ sigListeners[sig] = function listener() {
651
+ if (!processOk2(global.process)) {
652
+ return;
653
+ }
654
+ var listeners = process13.listeners(sig);
655
+ if (listeners.length === emitter.count) {
656
+ unload2();
657
+ emit("exit", null, sig);
658
+ emit("afterexit", null, sig);
659
+ if (isWin && sig === "SIGHUP") {
660
+ sig = "SIGINT";
661
+ }
662
+ process13.kill(process13.pid, sig);
663
+ }
664
+ };
665
+ });
666
+ module.exports.signals = function() {
667
+ return signals2;
668
+ };
669
+ loaded = false;
670
+ load2 = function load3() {
671
+ if (loaded || !processOk2(global.process)) {
672
+ return;
673
+ }
674
+ loaded = true;
675
+ emitter.count += 1;
676
+ signals2 = signals2.filter(function(sig) {
677
+ try {
678
+ process13.on(sig, sigListeners[sig]);
679
+ return true;
680
+ } catch (er) {
681
+ return false;
682
+ }
102
683
  });
684
+ process13.emit = processEmit;
685
+ process13.reallyExit = processReallyExit;
686
+ };
687
+ module.exports.load = load2;
688
+ originalProcessReallyExit = process13.reallyExit;
689
+ processReallyExit = function processReallyExit2(code) {
690
+ if (!processOk2(global.process)) {
691
+ return;
692
+ }
693
+ process13.exitCode = code || /* istanbul ignore next */
694
+ 0;
695
+ emit("exit", process13.exitCode, null);
696
+ emit("afterexit", process13.exitCode, null);
697
+ originalProcessReallyExit.call(process13, process13.exitCode);
698
+ };
699
+ originalProcessEmit = process13.emit;
700
+ processEmit = function processEmit2(ev, arg) {
701
+ if (ev === "exit" && processOk2(global.process)) {
702
+ if (arg !== void 0) {
703
+ process13.exitCode = arg;
704
+ }
705
+ var ret = originalProcessEmit.apply(this, arguments);
706
+ emit("exit", process13.exitCode, null);
707
+ emit("afterexit", process13.exitCode, null);
708
+ return ret;
709
+ } else {
710
+ return originalProcessEmit.apply(this, arguments);
711
+ }
712
+ };
713
+ }
714
+ var assert;
715
+ var signals2;
716
+ var isWin;
717
+ var EE;
718
+ var emitter;
719
+ var unload2;
720
+ var emit;
721
+ var sigListeners;
722
+ var loaded;
723
+ var load2;
724
+ var originalProcessReallyExit;
725
+ var processReallyExit;
726
+ var originalProcessEmit;
727
+ var processEmit;
728
+ }
729
+ });
730
+
731
+ // ../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js
732
+ var require_buffer_stream = __commonJS({
733
+ "../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/buffer-stream.js"(exports, module) {
734
+ var { PassThrough: PassThroughStream } = __require("stream");
735
+ module.exports = (options) => {
736
+ options = { ...options };
737
+ const { array } = options;
738
+ let { encoding } = options;
739
+ const isBuffer = encoding === "buffer";
740
+ let objectMode = false;
741
+ if (array) {
742
+ objectMode = !(encoding || isBuffer);
743
+ } else {
744
+ encoding = encoding || "utf8";
103
745
  }
104
- return sh("lsof -i -P").then((res) => {
105
- const { stdout } = res;
106
- if (!stdout) return res;
107
- const lines = stdout.split("\n");
108
- const existProccess = lines.filter((line) => line.match(new RegExp(`:*${port}`))).length > 0;
109
- if (!existProccess) return Promise.reject(new Error("No process running on port"));
110
- return sh(
111
- `lsof -i ${method === "udp" ? "udp" : "tcp"}:${port} | grep ${method === "udp" ? "UDP" : "LISTEN"} | awk '{print $2}' | xargs kill -9`
112
- );
746
+ if (isBuffer) {
747
+ encoding = null;
748
+ }
749
+ const stream2 = new PassThroughStream({ objectMode });
750
+ if (encoding) {
751
+ stream2.setEncoding(encoding);
752
+ }
753
+ let length = 0;
754
+ const chunks = [];
755
+ stream2.on("data", (chunk) => {
756
+ chunks.push(chunk);
757
+ if (objectMode) {
758
+ length = chunks.length;
759
+ } else {
760
+ length += chunk.length;
761
+ }
762
+ });
763
+ stream2.getBufferedValue = () => {
764
+ if (array) {
765
+ return chunks;
766
+ }
767
+ return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
768
+ };
769
+ stream2.getBufferedLength = () => length;
770
+ return stream2;
771
+ };
772
+ }
773
+ });
774
+
775
+ // ../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js
776
+ var require_get_stream = __commonJS({
777
+ "../../node_modules/.pnpm/get-stream@6.0.1/node_modules/get-stream/index.js"(exports, module) {
778
+ var { constants: BufferConstants } = __require("buffer");
779
+ var stream2 = __require("stream");
780
+ var { promisify: promisify2 } = __require("util");
781
+ var bufferStream = require_buffer_stream();
782
+ var streamPipelinePromisified = promisify2(stream2.pipeline);
783
+ var MaxBufferError2 = class extends Error {
784
+ constructor() {
785
+ super("maxBuffer exceeded");
786
+ this.name = "MaxBufferError";
787
+ }
788
+ };
789
+ async function getStream2(inputStream, options) {
790
+ if (!inputStream) {
791
+ throw new Error("Expected a stream");
792
+ }
793
+ options = {
794
+ maxBuffer: Infinity,
795
+ ...options
796
+ };
797
+ const { maxBuffer } = options;
798
+ const stream3 = bufferStream(options);
799
+ await new Promise((resolve, reject) => {
800
+ const rejectPromise = (error) => {
801
+ if (error && stream3.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
802
+ error.bufferedData = stream3.getBufferedValue();
803
+ }
804
+ reject(error);
805
+ };
806
+ (async () => {
807
+ try {
808
+ await streamPipelinePromisified(inputStream, stream3);
809
+ resolve();
810
+ } catch (error) {
811
+ rejectPromise(error);
812
+ }
813
+ })();
814
+ stream3.on("data", () => {
815
+ if (stream3.getBufferedLength() > maxBuffer) {
816
+ rejectPromise(new MaxBufferError2());
817
+ }
818
+ });
113
819
  });
820
+ return stream3.getBufferedValue();
821
+ }
822
+ module.exports = getStream2;
823
+ module.exports.buffer = (stream3, options) => getStream2(stream3, { ...options, encoding: "buffer" });
824
+ module.exports.array = (stream3, options) => getStream2(stream3, { ...options, array: true });
825
+ module.exports.MaxBufferError = MaxBufferError2;
826
+ }
827
+ });
828
+
829
+ // ../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js
830
+ var require_merge_stream = __commonJS({
831
+ "../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js"(exports, module) {
832
+ var { PassThrough } = __require("stream");
833
+ module.exports = function() {
834
+ var sources = [];
835
+ var output = new PassThrough({ objectMode: true });
836
+ output.setMaxListeners(0);
837
+ output.add = add;
838
+ output.isEmpty = isEmpty;
839
+ output.on("unpipe", remove);
840
+ Array.prototype.slice.call(arguments).forEach(add);
841
+ return output;
842
+ function add(source) {
843
+ if (Array.isArray(source)) {
844
+ source.forEach(add);
845
+ return this;
846
+ }
847
+ sources.push(source);
848
+ source.once("end", remove.bind(null, source));
849
+ source.once("error", output.emit.bind(output, "error"));
850
+ source.pipe(output, { end: false });
851
+ return this;
852
+ }
853
+ function isEmpty() {
854
+ return sources.length == 0;
855
+ }
856
+ function remove(source) {
857
+ sources = sources.filter(function(it) {
858
+ return it !== source;
859
+ });
860
+ if (!sources.length && output.readable) {
861
+ output.end();
862
+ }
863
+ }
114
864
  };
115
865
  }
116
866
  });
@@ -190,7 +940,7 @@ var require_picocolors = __commonJS({
190
940
  // ../../node_modules/.pnpm/@opencode-ai+sdk@1.0.132/node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
191
941
  var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
192
942
  let lastEventId;
193
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
943
+ const sleep2 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
194
944
  const createStream = async function* () {
195
945
  let retryDelay = sseDefaultRetryDelay ?? 3e3;
196
946
  let attempt = 0;
@@ -285,7 +1035,7 @@ var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseVa
285
1035
  break;
286
1036
  }
287
1037
  const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
288
- await sleep(backoff);
1038
+ await sleep2(backoff);
289
1039
  }
290
1040
  }
291
1041
  };
@@ -418,7 +1168,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
418
1168
 
419
1169
  // ../../node_modules/.pnpm/@opencode-ai+sdk@1.0.132/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
420
1170
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
421
- var defaultPathSerializer = ({ path, url: _url }) => {
1171
+ var defaultPathSerializer = ({ path: path5, url: _url }) => {
422
1172
  let url = _url;
423
1173
  const matches = _url.match(PATH_PARAM_RE);
424
1174
  if (matches) {
@@ -437,7 +1187,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
437
1187
  name = name.substring(1);
438
1188
  style = "matrix";
439
1189
  }
440
- const value = path[name];
1190
+ const value = path5[name];
441
1191
  if (value === void 0 || value === null) {
442
1192
  continue;
443
1193
  }
@@ -468,11 +1218,11 @@ var defaultPathSerializer = ({ path, url: _url }) => {
468
1218
  }
469
1219
  return url;
470
1220
  };
471
- var getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
1221
+ var getUrl = ({ baseUrl, path: path5, query, querySerializer, url: _url }) => {
472
1222
  const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
473
1223
  let url = (baseUrl ?? "") + pathUrl;
474
- if (path) {
475
- url = defaultPathSerializer({ path, url });
1224
+ if (path5) {
1225
+ url = defaultPathSerializer({ path: path5, url });
476
1226
  }
477
1227
  let search = query ? querySerializer(query) : "";
478
1228
  if (search.startsWith("?")) {
@@ -1541,167 +2291,2790 @@ var Tui = class extends _HeyApiClient {
1541
2291
  }
1542
2292
  control = new Control({ client: this._client });
1543
2293
  };
1544
- var Auth = class extends _HeyApiClient {
1545
- /**
1546
- * Set authentication credentials
1547
- */
1548
- set(options) {
1549
- return (options.client ?? this._client).put({
1550
- url: "/auth/{id}",
1551
- ...options,
1552
- headers: {
1553
- "Content-Type": "application/json",
1554
- ...options.headers
1555
- }
2294
+ var Auth = class extends _HeyApiClient {
2295
+ /**
2296
+ * Set authentication credentials
2297
+ */
2298
+ set(options) {
2299
+ return (options.client ?? this._client).put({
2300
+ url: "/auth/{id}",
2301
+ ...options,
2302
+ headers: {
2303
+ "Content-Type": "application/json",
2304
+ ...options.headers
2305
+ }
2306
+ });
2307
+ }
2308
+ };
2309
+ var Event = class extends _HeyApiClient {
2310
+ /**
2311
+ * Get events
2312
+ */
2313
+ subscribe(options) {
2314
+ return (options?.client ?? this._client).get.sse({
2315
+ url: "/event",
2316
+ ...options
2317
+ });
2318
+ }
2319
+ };
2320
+ var OpencodeClient = class extends _HeyApiClient {
2321
+ /**
2322
+ * Respond to a permission request
2323
+ */
2324
+ postSessionIdPermissionsPermissionId(options) {
2325
+ return (options.client ?? this._client).post({
2326
+ url: "/session/{id}/permissions/{permissionID}",
2327
+ ...options,
2328
+ headers: {
2329
+ "Content-Type": "application/json",
2330
+ ...options.headers
2331
+ }
2332
+ });
2333
+ }
2334
+ global = new Global({ client: this._client });
2335
+ project = new Project({ client: this._client });
2336
+ config = new Config({ client: this._client });
2337
+ tool = new Tool({ client: this._client });
2338
+ instance = new Instance({ client: this._client });
2339
+ path = new Path({ client: this._client });
2340
+ vcs = new Vcs({ client: this._client });
2341
+ session = new Session({ client: this._client });
2342
+ command = new Command({ client: this._client });
2343
+ provider = new Provider({ client: this._client });
2344
+ find = new Find({ client: this._client });
2345
+ file = new File2({ client: this._client });
2346
+ app = new App({ client: this._client });
2347
+ mcp = new Mcp({ client: this._client });
2348
+ lsp = new Lsp({ client: this._client });
2349
+ formatter = new Formatter({ client: this._client });
2350
+ tui = new Tui({ client: this._client });
2351
+ auth = new Auth({ client: this._client });
2352
+ event = new Event({ client: this._client });
2353
+ };
2354
+
2355
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.0.132/node_modules/@opencode-ai/sdk/dist/client.js
2356
+ function createOpencodeClient(config) {
2357
+ if (!config?.fetch) {
2358
+ config = {
2359
+ ...config,
2360
+ fetch: (req) => {
2361
+ req.timeout = false;
2362
+ return fetch(req);
2363
+ }
2364
+ };
2365
+ }
2366
+ if (config?.directory) {
2367
+ config.headers = {
2368
+ ...config.headers,
2369
+ "x-opencode-directory": config.directory
2370
+ };
2371
+ }
2372
+ const client2 = createClient(config);
2373
+ return new OpencodeClient({ client: client2 });
2374
+ }
2375
+ async function createOpencodeServer(options) {
2376
+ options = Object.assign({
2377
+ hostname: "127.0.0.1",
2378
+ port: 4096,
2379
+ timeout: 5e3
2380
+ }, options ?? {});
2381
+ const proc = spawn(`opencode`, [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`], {
2382
+ signal: options.signal,
2383
+ env: {
2384
+ ...process.env,
2385
+ OPENCODE_CONFIG_CONTENT: JSON.stringify(options.config ?? {})
2386
+ }
2387
+ });
2388
+ const url = await new Promise((resolve, reject) => {
2389
+ const id = setTimeout(() => {
2390
+ reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`));
2391
+ }, options.timeout);
2392
+ let output = "";
2393
+ proc.stdout?.on("data", (chunk) => {
2394
+ output += chunk.toString();
2395
+ const lines = output.split("\n");
2396
+ for (const line of lines) {
2397
+ if (line.startsWith("opencode server listening")) {
2398
+ const match2 = line.match(/on\s+(https?:\/\/[^\s]+)/);
2399
+ if (!match2) {
2400
+ throw new Error(`Failed to parse server url from output: ${line}`);
2401
+ }
2402
+ clearTimeout(id);
2403
+ resolve(match2[1]);
2404
+ return;
2405
+ }
2406
+ }
2407
+ });
2408
+ proc.stderr?.on("data", (chunk) => {
2409
+ output += chunk.toString();
2410
+ });
2411
+ proc.on("exit", (code) => {
2412
+ clearTimeout(id);
2413
+ let msg = `Server exited with code ${code}`;
2414
+ if (output.trim()) {
2415
+ msg += `
2416
+ Server output: ${output}`;
2417
+ }
2418
+ reject(new Error(msg));
2419
+ });
2420
+ proc.on("error", (error) => {
2421
+ clearTimeout(id);
2422
+ reject(error);
2423
+ });
2424
+ if (options.signal) {
2425
+ options.signal.addEventListener("abort", () => {
2426
+ clearTimeout(id);
2427
+ reject(new Error("Aborted"));
2428
+ });
2429
+ }
2430
+ });
2431
+ return {
2432
+ url,
2433
+ close() {
2434
+ proc.kill();
2435
+ }
2436
+ };
2437
+ }
2438
+
2439
+ // ../../node_modules/.pnpm/@opencode-ai+sdk@1.0.132/node_modules/@opencode-ai/sdk/dist/index.js
2440
+ async function createOpencode(options) {
2441
+ const server = await createOpencodeServer({
2442
+ ...options
2443
+ });
2444
+ const client2 = createOpencodeClient({
2445
+ baseUrl: server.url
2446
+ });
2447
+ return {
2448
+ client: client2,
2449
+ server
2450
+ };
2451
+ }
2452
+
2453
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/index.js
2454
+ var import_cross_spawn = __toESM(require_cross_spawn());
2455
+
2456
+ // ../../node_modules/.pnpm/strip-final-newline@3.0.0/node_modules/strip-final-newline/index.js
2457
+ function stripFinalNewline(input) {
2458
+ const LF = typeof input === "string" ? "\n" : "\n".charCodeAt();
2459
+ const CR = typeof input === "string" ? "\r" : "\r".charCodeAt();
2460
+ if (input[input.length - 1] === LF) {
2461
+ input = input.slice(0, -1);
2462
+ }
2463
+ if (input[input.length - 1] === CR) {
2464
+ input = input.slice(0, -1);
2465
+ }
2466
+ return input;
2467
+ }
2468
+
2469
+ // ../../node_modules/.pnpm/path-key@4.0.0/node_modules/path-key/index.js
2470
+ function pathKey(options = {}) {
2471
+ const {
2472
+ env = process.env,
2473
+ platform = process.platform
2474
+ } = options;
2475
+ if (platform !== "win32") {
2476
+ return "PATH";
2477
+ }
2478
+ return Object.keys(env).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
2479
+ }
2480
+
2481
+ // ../../node_modules/.pnpm/npm-run-path@5.3.0/node_modules/npm-run-path/index.js
2482
+ var npmRunPath = ({
2483
+ cwd = process2.cwd(),
2484
+ path: pathOption = process2.env[pathKey()],
2485
+ preferLocal = true,
2486
+ execPath = process2.execPath,
2487
+ addExecPath = true
2488
+ } = {}) => {
2489
+ const cwdString = cwd instanceof URL ? fileURLToPath(cwd) : cwd;
2490
+ const cwdPath = path.resolve(cwdString);
2491
+ const result = [];
2492
+ if (preferLocal) {
2493
+ applyPreferLocal(result, cwdPath);
2494
+ }
2495
+ if (addExecPath) {
2496
+ applyExecPath(result, execPath, cwdPath);
2497
+ }
2498
+ return [...result, pathOption].join(path.delimiter);
2499
+ };
2500
+ var applyPreferLocal = (result, cwdPath) => {
2501
+ let previous;
2502
+ while (previous !== cwdPath) {
2503
+ result.push(path.join(cwdPath, "node_modules/.bin"));
2504
+ previous = cwdPath;
2505
+ cwdPath = path.resolve(cwdPath, "..");
2506
+ }
2507
+ };
2508
+ var applyExecPath = (result, execPath, cwdPath) => {
2509
+ const execPathString = execPath instanceof URL ? fileURLToPath(execPath) : execPath;
2510
+ result.push(path.resolve(cwdPath, execPathString, ".."));
2511
+ };
2512
+ var npmRunPathEnv = ({ env = process2.env, ...options } = {}) => {
2513
+ env = { ...env };
2514
+ const pathName = pathKey({ env });
2515
+ options.path = env[pathName];
2516
+ env[pathName] = npmRunPath(options);
2517
+ return env;
2518
+ };
2519
+
2520
+ // ../../node_modules/.pnpm/mimic-fn@4.0.0/node_modules/mimic-fn/index.js
2521
+ var copyProperty = (to, from, property, ignoreNonConfigurable) => {
2522
+ if (property === "length" || property === "prototype") {
2523
+ return;
2524
+ }
2525
+ if (property === "arguments" || property === "caller") {
2526
+ return;
2527
+ }
2528
+ const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
2529
+ const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
2530
+ if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
2531
+ return;
2532
+ }
2533
+ Object.defineProperty(to, property, fromDescriptor);
2534
+ };
2535
+ var canCopyProperty = function(toDescriptor, fromDescriptor) {
2536
+ return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
2537
+ };
2538
+ var changePrototype = (to, from) => {
2539
+ const fromPrototype = Object.getPrototypeOf(from);
2540
+ if (fromPrototype === Object.getPrototypeOf(to)) {
2541
+ return;
2542
+ }
2543
+ Object.setPrototypeOf(to, fromPrototype);
2544
+ };
2545
+ var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
2546
+ ${fromBody}`;
2547
+ var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
2548
+ var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
2549
+ var changeToString = (to, from, name) => {
2550
+ const withName = name === "" ? "" : `with ${name.trim()}() `;
2551
+ const newToString = wrappedToString.bind(null, withName, from.toString());
2552
+ Object.defineProperty(newToString, "name", toStringName);
2553
+ Object.defineProperty(to, "toString", { ...toStringDescriptor, value: newToString });
2554
+ };
2555
+ function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
2556
+ const { name } = to;
2557
+ for (const property of Reflect.ownKeys(from)) {
2558
+ copyProperty(to, from, property, ignoreNonConfigurable);
2559
+ }
2560
+ changePrototype(to, from);
2561
+ changeToString(to, from, name);
2562
+ return to;
2563
+ }
2564
+
2565
+ // ../../node_modules/.pnpm/onetime@6.0.0/node_modules/onetime/index.js
2566
+ var calledFunctions = /* @__PURE__ */ new WeakMap();
2567
+ var onetime = (function_, options = {}) => {
2568
+ if (typeof function_ !== "function") {
2569
+ throw new TypeError("Expected a function");
2570
+ }
2571
+ let returnValue;
2572
+ let callCount = 0;
2573
+ const functionName = function_.displayName || function_.name || "<anonymous>";
2574
+ const onetime2 = function(...arguments_) {
2575
+ calledFunctions.set(onetime2, ++callCount);
2576
+ if (callCount === 1) {
2577
+ returnValue = function_.apply(this, arguments_);
2578
+ function_ = null;
2579
+ } else if (options.throw === true) {
2580
+ throw new Error(`Function \`${functionName}\` can only be called once`);
2581
+ }
2582
+ return returnValue;
2583
+ };
2584
+ mimicFunction(onetime2, function_);
2585
+ calledFunctions.set(onetime2, callCount);
2586
+ return onetime2;
2587
+ };
2588
+ onetime.callCount = (function_) => {
2589
+ if (!calledFunctions.has(function_)) {
2590
+ throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
2591
+ }
2592
+ return calledFunctions.get(function_);
2593
+ };
2594
+ var onetime_default = onetime;
2595
+
2596
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/realtime.js
2597
+ var getRealtimeSignals = function() {
2598
+ const length = SIGRTMAX - SIGRTMIN + 1;
2599
+ return Array.from({ length }, getRealtimeSignal);
2600
+ };
2601
+ var getRealtimeSignal = function(value, index) {
2602
+ return {
2603
+ name: `SIGRT${index + 1}`,
2604
+ number: SIGRTMIN + index,
2605
+ action: "terminate",
2606
+ description: "Application-specific signal (realtime)",
2607
+ standard: "posix"
2608
+ };
2609
+ };
2610
+ var SIGRTMIN = 34;
2611
+ var SIGRTMAX = 64;
2612
+
2613
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/core.js
2614
+ var SIGNALS = [
2615
+ {
2616
+ name: "SIGHUP",
2617
+ number: 1,
2618
+ action: "terminate",
2619
+ description: "Terminal closed",
2620
+ standard: "posix"
2621
+ },
2622
+ {
2623
+ name: "SIGINT",
2624
+ number: 2,
2625
+ action: "terminate",
2626
+ description: "User interruption with CTRL-C",
2627
+ standard: "ansi"
2628
+ },
2629
+ {
2630
+ name: "SIGQUIT",
2631
+ number: 3,
2632
+ action: "core",
2633
+ description: "User interruption with CTRL-\\",
2634
+ standard: "posix"
2635
+ },
2636
+ {
2637
+ name: "SIGILL",
2638
+ number: 4,
2639
+ action: "core",
2640
+ description: "Invalid machine instruction",
2641
+ standard: "ansi"
2642
+ },
2643
+ {
2644
+ name: "SIGTRAP",
2645
+ number: 5,
2646
+ action: "core",
2647
+ description: "Debugger breakpoint",
2648
+ standard: "posix"
2649
+ },
2650
+ {
2651
+ name: "SIGABRT",
2652
+ number: 6,
2653
+ action: "core",
2654
+ description: "Aborted",
2655
+ standard: "ansi"
2656
+ },
2657
+ {
2658
+ name: "SIGIOT",
2659
+ number: 6,
2660
+ action: "core",
2661
+ description: "Aborted",
2662
+ standard: "bsd"
2663
+ },
2664
+ {
2665
+ name: "SIGBUS",
2666
+ number: 7,
2667
+ action: "core",
2668
+ description: "Bus error due to misaligned, non-existing address or paging error",
2669
+ standard: "bsd"
2670
+ },
2671
+ {
2672
+ name: "SIGEMT",
2673
+ number: 7,
2674
+ action: "terminate",
2675
+ description: "Command should be emulated but is not implemented",
2676
+ standard: "other"
2677
+ },
2678
+ {
2679
+ name: "SIGFPE",
2680
+ number: 8,
2681
+ action: "core",
2682
+ description: "Floating point arithmetic error",
2683
+ standard: "ansi"
2684
+ },
2685
+ {
2686
+ name: "SIGKILL",
2687
+ number: 9,
2688
+ action: "terminate",
2689
+ description: "Forced termination",
2690
+ standard: "posix",
2691
+ forced: true
2692
+ },
2693
+ {
2694
+ name: "SIGUSR1",
2695
+ number: 10,
2696
+ action: "terminate",
2697
+ description: "Application-specific signal",
2698
+ standard: "posix"
2699
+ },
2700
+ {
2701
+ name: "SIGSEGV",
2702
+ number: 11,
2703
+ action: "core",
2704
+ description: "Segmentation fault",
2705
+ standard: "ansi"
2706
+ },
2707
+ {
2708
+ name: "SIGUSR2",
2709
+ number: 12,
2710
+ action: "terminate",
2711
+ description: "Application-specific signal",
2712
+ standard: "posix"
2713
+ },
2714
+ {
2715
+ name: "SIGPIPE",
2716
+ number: 13,
2717
+ action: "terminate",
2718
+ description: "Broken pipe or socket",
2719
+ standard: "posix"
2720
+ },
2721
+ {
2722
+ name: "SIGALRM",
2723
+ number: 14,
2724
+ action: "terminate",
2725
+ description: "Timeout or timer",
2726
+ standard: "posix"
2727
+ },
2728
+ {
2729
+ name: "SIGTERM",
2730
+ number: 15,
2731
+ action: "terminate",
2732
+ description: "Termination",
2733
+ standard: "ansi"
2734
+ },
2735
+ {
2736
+ name: "SIGSTKFLT",
2737
+ number: 16,
2738
+ action: "terminate",
2739
+ description: "Stack is empty or overflowed",
2740
+ standard: "other"
2741
+ },
2742
+ {
2743
+ name: "SIGCHLD",
2744
+ number: 17,
2745
+ action: "ignore",
2746
+ description: "Child process terminated, paused or unpaused",
2747
+ standard: "posix"
2748
+ },
2749
+ {
2750
+ name: "SIGCLD",
2751
+ number: 17,
2752
+ action: "ignore",
2753
+ description: "Child process terminated, paused or unpaused",
2754
+ standard: "other"
2755
+ },
2756
+ {
2757
+ name: "SIGCONT",
2758
+ number: 18,
2759
+ action: "unpause",
2760
+ description: "Unpaused",
2761
+ standard: "posix",
2762
+ forced: true
2763
+ },
2764
+ {
2765
+ name: "SIGSTOP",
2766
+ number: 19,
2767
+ action: "pause",
2768
+ description: "Paused",
2769
+ standard: "posix",
2770
+ forced: true
2771
+ },
2772
+ {
2773
+ name: "SIGTSTP",
2774
+ number: 20,
2775
+ action: "pause",
2776
+ description: 'Paused using CTRL-Z or "suspend"',
2777
+ standard: "posix"
2778
+ },
2779
+ {
2780
+ name: "SIGTTIN",
2781
+ number: 21,
2782
+ action: "pause",
2783
+ description: "Background process cannot read terminal input",
2784
+ standard: "posix"
2785
+ },
2786
+ {
2787
+ name: "SIGBREAK",
2788
+ number: 21,
2789
+ action: "terminate",
2790
+ description: "User interruption with CTRL-BREAK",
2791
+ standard: "other"
2792
+ },
2793
+ {
2794
+ name: "SIGTTOU",
2795
+ number: 22,
2796
+ action: "pause",
2797
+ description: "Background process cannot write to terminal output",
2798
+ standard: "posix"
2799
+ },
2800
+ {
2801
+ name: "SIGURG",
2802
+ number: 23,
2803
+ action: "ignore",
2804
+ description: "Socket received out-of-band data",
2805
+ standard: "bsd"
2806
+ },
2807
+ {
2808
+ name: "SIGXCPU",
2809
+ number: 24,
2810
+ action: "core",
2811
+ description: "Process timed out",
2812
+ standard: "bsd"
2813
+ },
2814
+ {
2815
+ name: "SIGXFSZ",
2816
+ number: 25,
2817
+ action: "core",
2818
+ description: "File too big",
2819
+ standard: "bsd"
2820
+ },
2821
+ {
2822
+ name: "SIGVTALRM",
2823
+ number: 26,
2824
+ action: "terminate",
2825
+ description: "Timeout or timer",
2826
+ standard: "bsd"
2827
+ },
2828
+ {
2829
+ name: "SIGPROF",
2830
+ number: 27,
2831
+ action: "terminate",
2832
+ description: "Timeout or timer",
2833
+ standard: "bsd"
2834
+ },
2835
+ {
2836
+ name: "SIGWINCH",
2837
+ number: 28,
2838
+ action: "ignore",
2839
+ description: "Terminal window size changed",
2840
+ standard: "bsd"
2841
+ },
2842
+ {
2843
+ name: "SIGIO",
2844
+ number: 29,
2845
+ action: "terminate",
2846
+ description: "I/O is available",
2847
+ standard: "other"
2848
+ },
2849
+ {
2850
+ name: "SIGPOLL",
2851
+ number: 29,
2852
+ action: "terminate",
2853
+ description: "Watched event",
2854
+ standard: "other"
2855
+ },
2856
+ {
2857
+ name: "SIGINFO",
2858
+ number: 29,
2859
+ action: "ignore",
2860
+ description: "Request for process information",
2861
+ standard: "other"
2862
+ },
2863
+ {
2864
+ name: "SIGPWR",
2865
+ number: 30,
2866
+ action: "terminate",
2867
+ description: "Device running out of power",
2868
+ standard: "systemv"
2869
+ },
2870
+ {
2871
+ name: "SIGSYS",
2872
+ number: 31,
2873
+ action: "core",
2874
+ description: "Invalid system call",
2875
+ standard: "other"
2876
+ },
2877
+ {
2878
+ name: "SIGUNUSED",
2879
+ number: 31,
2880
+ action: "terminate",
2881
+ description: "Invalid system call",
2882
+ standard: "other"
2883
+ }
2884
+ ];
2885
+
2886
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/signals.js
2887
+ var getSignals = function() {
2888
+ const realtimeSignals = getRealtimeSignals();
2889
+ const signals2 = [...SIGNALS, ...realtimeSignals].map(normalizeSignal);
2890
+ return signals2;
2891
+ };
2892
+ var normalizeSignal = function({
2893
+ name,
2894
+ number: defaultNumber,
2895
+ description,
2896
+ action,
2897
+ forced = false,
2898
+ standard
2899
+ }) {
2900
+ const {
2901
+ signals: { [name]: constantSignal }
2902
+ } = constants;
2903
+ const supported = constantSignal !== void 0;
2904
+ const number = supported ? constantSignal : defaultNumber;
2905
+ return { name, number, description, supported, action, forced, standard };
2906
+ };
2907
+
2908
+ // ../../node_modules/.pnpm/human-signals@3.0.1/node_modules/human-signals/build/src/main.js
2909
+ var getSignalsByName = function() {
2910
+ const signals2 = getSignals();
2911
+ return signals2.reduce(getSignalByName, {});
2912
+ };
2913
+ var getSignalByName = function(signalByNameMemo, { name, number, description, supported, action, forced, standard }) {
2914
+ return {
2915
+ ...signalByNameMemo,
2916
+ [name]: { name, number, description, supported, action, forced, standard }
2917
+ };
2918
+ };
2919
+ var signalsByName = getSignalsByName();
2920
+ var getSignalsByNumber = function() {
2921
+ const signals2 = getSignals();
2922
+ const length = SIGRTMAX + 1;
2923
+ const signalsA = Array.from({ length }, (value, number) => getSignalByNumber(number, signals2));
2924
+ return Object.assign({}, ...signalsA);
2925
+ };
2926
+ var getSignalByNumber = function(number, signals2) {
2927
+ const signal = findSignalByNumber(number, signals2);
2928
+ if (signal === void 0) {
2929
+ return {};
2930
+ }
2931
+ const { name, description, supported, action, forced, standard } = signal;
2932
+ return {
2933
+ [number]: {
2934
+ name,
2935
+ number,
2936
+ description,
2937
+ supported,
2938
+ action,
2939
+ forced,
2940
+ standard
2941
+ }
2942
+ };
2943
+ };
2944
+ var findSignalByNumber = function(number, signals2) {
2945
+ const signal = signals2.find(({ name }) => constants.signals[name] === number);
2946
+ if (signal !== void 0) {
2947
+ return signal;
2948
+ }
2949
+ return signals2.find((signalA) => signalA.number === number);
2950
+ };
2951
+ getSignalsByNumber();
2952
+
2953
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/error.js
2954
+ var getErrorPrefix = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => {
2955
+ if (timedOut) {
2956
+ return `timed out after ${timeout} milliseconds`;
2957
+ }
2958
+ if (isCanceled) {
2959
+ return "was canceled";
2960
+ }
2961
+ if (errorCode !== void 0) {
2962
+ return `failed with ${errorCode}`;
2963
+ }
2964
+ if (signal !== void 0) {
2965
+ return `was killed with ${signal} (${signalDescription})`;
2966
+ }
2967
+ if (exitCode !== void 0) {
2968
+ return `failed with exit code ${exitCode}`;
2969
+ }
2970
+ return "failed";
2971
+ };
2972
+ var makeError = ({
2973
+ stdout,
2974
+ stderr,
2975
+ all,
2976
+ error,
2977
+ signal,
2978
+ exitCode,
2979
+ command,
2980
+ escapedCommand,
2981
+ timedOut,
2982
+ isCanceled,
2983
+ killed,
2984
+ parsed: { options: { timeout } }
2985
+ }) => {
2986
+ exitCode = exitCode === null ? void 0 : exitCode;
2987
+ signal = signal === null ? void 0 : signal;
2988
+ const signalDescription = signal === void 0 ? void 0 : signalsByName[signal].description;
2989
+ const errorCode = error && error.code;
2990
+ const prefix = getErrorPrefix({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled });
2991
+ const execaMessage = `Command ${prefix}: ${command}`;
2992
+ const isError = Object.prototype.toString.call(error) === "[object Error]";
2993
+ const shortMessage = isError ? `${execaMessage}
2994
+ ${error.message}` : execaMessage;
2995
+ const message = [shortMessage, stderr, stdout].filter(Boolean).join("\n");
2996
+ if (isError) {
2997
+ error.originalMessage = error.message;
2998
+ error.message = message;
2999
+ } else {
3000
+ error = new Error(message);
3001
+ }
3002
+ error.shortMessage = shortMessage;
3003
+ error.command = command;
3004
+ error.escapedCommand = escapedCommand;
3005
+ error.exitCode = exitCode;
3006
+ error.signal = signal;
3007
+ error.signalDescription = signalDescription;
3008
+ error.stdout = stdout;
3009
+ error.stderr = stderr;
3010
+ if (all !== void 0) {
3011
+ error.all = all;
3012
+ }
3013
+ if ("bufferedData" in error) {
3014
+ delete error.bufferedData;
3015
+ }
3016
+ error.failed = true;
3017
+ error.timedOut = Boolean(timedOut);
3018
+ error.isCanceled = isCanceled;
3019
+ error.killed = killed && !timedOut;
3020
+ return error;
3021
+ };
3022
+
3023
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/stdio.js
3024
+ var aliases = ["stdin", "stdout", "stderr"];
3025
+ var hasAlias = (options) => aliases.some((alias) => options[alias] !== void 0);
3026
+ var normalizeStdio = (options) => {
3027
+ if (!options) {
3028
+ return;
3029
+ }
3030
+ const { stdio } = options;
3031
+ if (stdio === void 0) {
3032
+ return aliases.map((alias) => options[alias]);
3033
+ }
3034
+ if (hasAlias(options)) {
3035
+ throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map((alias) => `\`${alias}\``).join(", ")}`);
3036
+ }
3037
+ if (typeof stdio === "string") {
3038
+ return stdio;
3039
+ }
3040
+ if (!Array.isArray(stdio)) {
3041
+ throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
3042
+ }
3043
+ const length = Math.max(stdio.length, aliases.length);
3044
+ return Array.from({ length }, (value, index) => stdio[index]);
3045
+ };
3046
+
3047
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/kill.js
3048
+ var import_signal_exit = __toESM(require_signal_exit());
3049
+ var DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5;
3050
+ var spawnedKill = (kill2, signal = "SIGTERM", options = {}) => {
3051
+ const killResult = kill2(signal);
3052
+ setKillTimeout(kill2, signal, options, killResult);
3053
+ return killResult;
3054
+ };
3055
+ var setKillTimeout = (kill2, signal, options, killResult) => {
3056
+ if (!shouldForceKill(signal, options, killResult)) {
3057
+ return;
3058
+ }
3059
+ const timeout = getForceKillAfterTimeout(options);
3060
+ const t = setTimeout(() => {
3061
+ kill2("SIGKILL");
3062
+ }, timeout);
3063
+ if (t.unref) {
3064
+ t.unref();
3065
+ }
3066
+ };
3067
+ var shouldForceKill = (signal, { forceKillAfterTimeout }, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
3068
+ var isSigterm = (signal) => signal === os.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
3069
+ var getForceKillAfterTimeout = ({ forceKillAfterTimeout = true }) => {
3070
+ if (forceKillAfterTimeout === true) {
3071
+ return DEFAULT_FORCE_KILL_TIMEOUT;
3072
+ }
3073
+ if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
3074
+ throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
3075
+ }
3076
+ return forceKillAfterTimeout;
3077
+ };
3078
+ var spawnedCancel = (spawned, context) => {
3079
+ const killResult = spawned.kill();
3080
+ if (killResult) {
3081
+ context.isCanceled = true;
3082
+ }
3083
+ };
3084
+ var timeoutKill = (spawned, signal, reject) => {
3085
+ spawned.kill(signal);
3086
+ reject(Object.assign(new Error("Timed out"), { timedOut: true, signal }));
3087
+ };
3088
+ var setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
3089
+ if (timeout === 0 || timeout === void 0) {
3090
+ return spawnedPromise;
3091
+ }
3092
+ let timeoutId;
3093
+ const timeoutPromise = new Promise((resolve, reject) => {
3094
+ timeoutId = setTimeout(() => {
3095
+ timeoutKill(spawned, killSignal, reject);
3096
+ }, timeout);
3097
+ });
3098
+ const safeSpawnedPromise = spawnedPromise.finally(() => {
3099
+ clearTimeout(timeoutId);
3100
+ });
3101
+ return Promise.race([timeoutPromise, safeSpawnedPromise]);
3102
+ };
3103
+ var validateTimeout = ({ timeout }) => {
3104
+ if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout < 0)) {
3105
+ throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
3106
+ }
3107
+ };
3108
+ var setExitHandler = async (spawned, { cleanup, detached }, timedPromise) => {
3109
+ if (!cleanup || detached) {
3110
+ return timedPromise;
3111
+ }
3112
+ const removeExitHandler = (0, import_signal_exit.default)(() => {
3113
+ spawned.kill();
3114
+ });
3115
+ return timedPromise.finally(() => {
3116
+ removeExitHandler();
3117
+ });
3118
+ };
3119
+
3120
+ // ../../node_modules/.pnpm/is-stream@3.0.0/node_modules/is-stream/index.js
3121
+ function isStream(stream2) {
3122
+ return stream2 !== null && typeof stream2 === "object" && typeof stream2.pipe === "function";
3123
+ }
3124
+ function isWritableStream(stream2) {
3125
+ return isStream(stream2) && stream2.writable !== false && typeof stream2._write === "function" && typeof stream2._writableState === "object";
3126
+ }
3127
+
3128
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/stream.js
3129
+ var import_get_stream = __toESM(require_get_stream());
3130
+ var import_merge_stream = __toESM(require_merge_stream());
3131
+ var handleInput = (spawned, input) => {
3132
+ if (input === void 0 || spawned.stdin === void 0) {
3133
+ return;
3134
+ }
3135
+ if (isStream(input)) {
3136
+ input.pipe(spawned.stdin);
3137
+ } else {
3138
+ spawned.stdin.end(input);
3139
+ }
3140
+ };
3141
+ var makeAllStream = (spawned, { all }) => {
3142
+ if (!all || !spawned.stdout && !spawned.stderr) {
3143
+ return;
3144
+ }
3145
+ const mixed = (0, import_merge_stream.default)();
3146
+ if (spawned.stdout) {
3147
+ mixed.add(spawned.stdout);
3148
+ }
3149
+ if (spawned.stderr) {
3150
+ mixed.add(spawned.stderr);
3151
+ }
3152
+ return mixed;
3153
+ };
3154
+ var getBufferedData = async (stream2, streamPromise) => {
3155
+ if (!stream2) {
3156
+ return;
3157
+ }
3158
+ stream2.destroy();
3159
+ try {
3160
+ return await streamPromise;
3161
+ } catch (error) {
3162
+ return error.bufferedData;
3163
+ }
3164
+ };
3165
+ var getStreamPromise = (stream2, { encoding, buffer, maxBuffer }) => {
3166
+ if (!stream2 || !buffer) {
3167
+ return;
3168
+ }
3169
+ if (encoding) {
3170
+ return (0, import_get_stream.default)(stream2, { encoding, maxBuffer });
3171
+ }
3172
+ return import_get_stream.default.buffer(stream2, { maxBuffer });
3173
+ };
3174
+ var getSpawnedResult = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
3175
+ const stdoutPromise = getStreamPromise(stdout, { encoding, buffer, maxBuffer });
3176
+ const stderrPromise = getStreamPromise(stderr, { encoding, buffer, maxBuffer });
3177
+ const allPromise = getStreamPromise(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
3178
+ try {
3179
+ return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
3180
+ } catch (error) {
3181
+ return Promise.all([
3182
+ { error, signal: error.signal, timedOut: error.timedOut },
3183
+ getBufferedData(stdout, stdoutPromise),
3184
+ getBufferedData(stderr, stderrPromise),
3185
+ getBufferedData(all, allPromise)
3186
+ ]);
3187
+ }
3188
+ };
3189
+
3190
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/promise.js
3191
+ var nativePromisePrototype = (async () => {
3192
+ })().constructor.prototype;
3193
+ var descriptors = ["then", "catch", "finally"].map((property) => [
3194
+ property,
3195
+ Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
3196
+ ]);
3197
+ var mergePromise = (spawned, promise) => {
3198
+ for (const [property, descriptor] of descriptors) {
3199
+ const value = typeof promise === "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
3200
+ Reflect.defineProperty(spawned, property, { ...descriptor, value });
3201
+ }
3202
+ return spawned;
3203
+ };
3204
+ var getSpawnedPromise = (spawned) => new Promise((resolve, reject) => {
3205
+ spawned.on("exit", (exitCode, signal) => {
3206
+ resolve({ exitCode, signal });
3207
+ });
3208
+ spawned.on("error", (error) => {
3209
+ reject(error);
3210
+ });
3211
+ if (spawned.stdin) {
3212
+ spawned.stdin.on("error", (error) => {
3213
+ reject(error);
3214
+ });
3215
+ }
3216
+ });
3217
+
3218
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/command.js
3219
+ var normalizeArgs = (file, args = []) => {
3220
+ if (!Array.isArray(args)) {
3221
+ return [file];
3222
+ }
3223
+ return [file, ...args];
3224
+ };
3225
+ var NO_ESCAPE_REGEXP = /^[\w.-]+$/;
3226
+ var DOUBLE_QUOTES_REGEXP = /"/g;
3227
+ var escapeArg = (arg) => {
3228
+ if (typeof arg !== "string" || NO_ESCAPE_REGEXP.test(arg)) {
3229
+ return arg;
3230
+ }
3231
+ return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
3232
+ };
3233
+ var joinCommand = (file, args) => normalizeArgs(file, args).join(" ");
3234
+ var getEscapedCommand = (file, args) => normalizeArgs(file, args).map((arg) => escapeArg(arg)).join(" ");
3235
+
3236
+ // ../../node_modules/.pnpm/execa@6.1.0/node_modules/execa/index.js
3237
+ var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100;
3238
+ var getEnv = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
3239
+ const env = extendEnv ? { ...process2.env, ...envOption } : envOption;
3240
+ if (preferLocal) {
3241
+ return npmRunPathEnv({ env, cwd: localDir, execPath });
3242
+ }
3243
+ return env;
3244
+ };
3245
+ var handleArguments = (file, args, options = {}) => {
3246
+ const parsed = import_cross_spawn.default._parse(file, args, options);
3247
+ file = parsed.command;
3248
+ args = parsed.args;
3249
+ options = parsed.options;
3250
+ options = {
3251
+ maxBuffer: DEFAULT_MAX_BUFFER,
3252
+ buffer: true,
3253
+ stripFinalNewline: true,
3254
+ extendEnv: true,
3255
+ preferLocal: false,
3256
+ localDir: options.cwd || process2.cwd(),
3257
+ execPath: process2.execPath,
3258
+ encoding: "utf8",
3259
+ reject: true,
3260
+ cleanup: true,
3261
+ all: false,
3262
+ windowsHide: true,
3263
+ ...options
3264
+ };
3265
+ options.env = getEnv(options);
3266
+ options.stdio = normalizeStdio(options);
3267
+ if (process2.platform === "win32" && path.basename(file, ".exe") === "cmd") {
3268
+ args.unshift("/q");
3269
+ }
3270
+ return { file, args, options, parsed };
3271
+ };
3272
+ var handleOutput = (options, value, error) => {
3273
+ if (typeof value !== "string" && !Buffer$1.isBuffer(value)) {
3274
+ return error === void 0 ? void 0 : "";
3275
+ }
3276
+ if (options.stripFinalNewline) {
3277
+ return stripFinalNewline(value);
3278
+ }
3279
+ return value;
3280
+ };
3281
+ function execa(file, args, options) {
3282
+ const parsed = handleArguments(file, args, options);
3283
+ const command = joinCommand(file, args);
3284
+ const escapedCommand = getEscapedCommand(file, args);
3285
+ validateTimeout(parsed.options);
3286
+ let spawned;
3287
+ try {
3288
+ spawned = childProcess2.spawn(parsed.file, parsed.args, parsed.options);
3289
+ } catch (error) {
3290
+ const dummySpawned = new childProcess2.ChildProcess();
3291
+ const errorPromise = Promise.reject(makeError({
3292
+ error,
3293
+ stdout: "",
3294
+ stderr: "",
3295
+ all: "",
3296
+ command,
3297
+ escapedCommand,
3298
+ parsed,
3299
+ timedOut: false,
3300
+ isCanceled: false,
3301
+ killed: false
3302
+ }));
3303
+ return mergePromise(dummySpawned, errorPromise);
3304
+ }
3305
+ const spawnedPromise = getSpawnedPromise(spawned);
3306
+ const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
3307
+ const processDone = setExitHandler(spawned, parsed.options, timedPromise);
3308
+ const context = { isCanceled: false };
3309
+ spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
3310
+ spawned.cancel = spawnedCancel.bind(null, spawned, context);
3311
+ const handlePromise = async () => {
3312
+ const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
3313
+ const stdout = handleOutput(parsed.options, stdoutResult);
3314
+ const stderr = handleOutput(parsed.options, stderrResult);
3315
+ const all = handleOutput(parsed.options, allResult);
3316
+ if (error || exitCode !== 0 || signal !== null) {
3317
+ const returnedError = makeError({
3318
+ error,
3319
+ exitCode,
3320
+ signal,
3321
+ stdout,
3322
+ stderr,
3323
+ all,
3324
+ command,
3325
+ escapedCommand,
3326
+ parsed,
3327
+ timedOut,
3328
+ isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
3329
+ killed: spawned.killed
3330
+ });
3331
+ if (!parsed.options.reject) {
3332
+ return returnedError;
3333
+ }
3334
+ throw returnedError;
3335
+ }
3336
+ return {
3337
+ command,
3338
+ escapedCommand,
3339
+ exitCode: 0,
3340
+ stdout,
3341
+ stderr,
3342
+ all,
3343
+ failed: false,
3344
+ timedOut: false,
3345
+ isCanceled: false,
3346
+ killed: false
3347
+ };
3348
+ };
3349
+ const handlePromiseOnce = onetime_default(handlePromise);
3350
+ handleInput(spawned, parsed.options.input);
3351
+ spawned.all = makeAllStream(spawned, parsed.options);
3352
+ return mergePromise(spawned, handlePromiseOnce);
3353
+ }
3354
+
3355
+ // ../../node_modules/.pnpm/taskkill@5.0.0/node_modules/taskkill/index.js
3356
+ function parseArgs(input, options) {
3357
+ if (process2.platform !== "win32") {
3358
+ throw new Error("Windows only");
3359
+ }
3360
+ input = [input].flat();
3361
+ if (input.length === 0) {
3362
+ throw new Error("PID or image name required");
3363
+ }
3364
+ const arguments_ = [];
3365
+ if (options.system && options.username && options.password) {
3366
+ arguments_.push("/s", options.system, "/u", options.username, "/p", options.password);
3367
+ }
3368
+ if (options.filter) {
3369
+ arguments_.push("/fi", options.filter);
3370
+ }
3371
+ if (options.force) {
3372
+ arguments_.push("/f");
3373
+ }
3374
+ if (options.tree) {
3375
+ arguments_.push("/t");
3376
+ }
3377
+ for (const element of input) {
3378
+ arguments_.push(typeof element === "number" ? "/pid" : "/im", element);
3379
+ }
3380
+ return arguments_;
3381
+ }
3382
+ async function taskkill(input, options = {}) {
3383
+ await execa("taskkill", parseArgs(input, options));
3384
+ }
3385
+
3386
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js
3387
+ var import_cross_spawn2 = __toESM(require_cross_spawn());
3388
+
3389
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/realtime.js
3390
+ var getRealtimeSignals2 = () => {
3391
+ const length = SIGRTMAX2 - SIGRTMIN2 + 1;
3392
+ return Array.from({ length }, getRealtimeSignal2);
3393
+ };
3394
+ var getRealtimeSignal2 = (value, index) => ({
3395
+ name: `SIGRT${index + 1}`,
3396
+ number: SIGRTMIN2 + index,
3397
+ action: "terminate",
3398
+ description: "Application-specific signal (realtime)",
3399
+ standard: "posix"
3400
+ });
3401
+ var SIGRTMIN2 = 34;
3402
+ var SIGRTMAX2 = 64;
3403
+
3404
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/core.js
3405
+ var SIGNALS2 = [
3406
+ {
3407
+ name: "SIGHUP",
3408
+ number: 1,
3409
+ action: "terminate",
3410
+ description: "Terminal closed",
3411
+ standard: "posix"
3412
+ },
3413
+ {
3414
+ name: "SIGINT",
3415
+ number: 2,
3416
+ action: "terminate",
3417
+ description: "User interruption with CTRL-C",
3418
+ standard: "ansi"
3419
+ },
3420
+ {
3421
+ name: "SIGQUIT",
3422
+ number: 3,
3423
+ action: "core",
3424
+ description: "User interruption with CTRL-\\",
3425
+ standard: "posix"
3426
+ },
3427
+ {
3428
+ name: "SIGILL",
3429
+ number: 4,
3430
+ action: "core",
3431
+ description: "Invalid machine instruction",
3432
+ standard: "ansi"
3433
+ },
3434
+ {
3435
+ name: "SIGTRAP",
3436
+ number: 5,
3437
+ action: "core",
3438
+ description: "Debugger breakpoint",
3439
+ standard: "posix"
3440
+ },
3441
+ {
3442
+ name: "SIGABRT",
3443
+ number: 6,
3444
+ action: "core",
3445
+ description: "Aborted",
3446
+ standard: "ansi"
3447
+ },
3448
+ {
3449
+ name: "SIGIOT",
3450
+ number: 6,
3451
+ action: "core",
3452
+ description: "Aborted",
3453
+ standard: "bsd"
3454
+ },
3455
+ {
3456
+ name: "SIGBUS",
3457
+ number: 7,
3458
+ action: "core",
3459
+ description: "Bus error due to misaligned, non-existing address or paging error",
3460
+ standard: "bsd"
3461
+ },
3462
+ {
3463
+ name: "SIGEMT",
3464
+ number: 7,
3465
+ action: "terminate",
3466
+ description: "Command should be emulated but is not implemented",
3467
+ standard: "other"
3468
+ },
3469
+ {
3470
+ name: "SIGFPE",
3471
+ number: 8,
3472
+ action: "core",
3473
+ description: "Floating point arithmetic error",
3474
+ standard: "ansi"
3475
+ },
3476
+ {
3477
+ name: "SIGKILL",
3478
+ number: 9,
3479
+ action: "terminate",
3480
+ description: "Forced termination",
3481
+ standard: "posix",
3482
+ forced: true
3483
+ },
3484
+ {
3485
+ name: "SIGUSR1",
3486
+ number: 10,
3487
+ action: "terminate",
3488
+ description: "Application-specific signal",
3489
+ standard: "posix"
3490
+ },
3491
+ {
3492
+ name: "SIGSEGV",
3493
+ number: 11,
3494
+ action: "core",
3495
+ description: "Segmentation fault",
3496
+ standard: "ansi"
3497
+ },
3498
+ {
3499
+ name: "SIGUSR2",
3500
+ number: 12,
3501
+ action: "terminate",
3502
+ description: "Application-specific signal",
3503
+ standard: "posix"
3504
+ },
3505
+ {
3506
+ name: "SIGPIPE",
3507
+ number: 13,
3508
+ action: "terminate",
3509
+ description: "Broken pipe or socket",
3510
+ standard: "posix"
3511
+ },
3512
+ {
3513
+ name: "SIGALRM",
3514
+ number: 14,
3515
+ action: "terminate",
3516
+ description: "Timeout or timer",
3517
+ standard: "posix"
3518
+ },
3519
+ {
3520
+ name: "SIGTERM",
3521
+ number: 15,
3522
+ action: "terminate",
3523
+ description: "Termination",
3524
+ standard: "ansi"
3525
+ },
3526
+ {
3527
+ name: "SIGSTKFLT",
3528
+ number: 16,
3529
+ action: "terminate",
3530
+ description: "Stack is empty or overflowed",
3531
+ standard: "other"
3532
+ },
3533
+ {
3534
+ name: "SIGCHLD",
3535
+ number: 17,
3536
+ action: "ignore",
3537
+ description: "Child process terminated, paused or unpaused",
3538
+ standard: "posix"
3539
+ },
3540
+ {
3541
+ name: "SIGCLD",
3542
+ number: 17,
3543
+ action: "ignore",
3544
+ description: "Child process terminated, paused or unpaused",
3545
+ standard: "other"
3546
+ },
3547
+ {
3548
+ name: "SIGCONT",
3549
+ number: 18,
3550
+ action: "unpause",
3551
+ description: "Unpaused",
3552
+ standard: "posix",
3553
+ forced: true
3554
+ },
3555
+ {
3556
+ name: "SIGSTOP",
3557
+ number: 19,
3558
+ action: "pause",
3559
+ description: "Paused",
3560
+ standard: "posix",
3561
+ forced: true
3562
+ },
3563
+ {
3564
+ name: "SIGTSTP",
3565
+ number: 20,
3566
+ action: "pause",
3567
+ description: 'Paused using CTRL-Z or "suspend"',
3568
+ standard: "posix"
3569
+ },
3570
+ {
3571
+ name: "SIGTTIN",
3572
+ number: 21,
3573
+ action: "pause",
3574
+ description: "Background process cannot read terminal input",
3575
+ standard: "posix"
3576
+ },
3577
+ {
3578
+ name: "SIGBREAK",
3579
+ number: 21,
3580
+ action: "terminate",
3581
+ description: "User interruption with CTRL-BREAK",
3582
+ standard: "other"
3583
+ },
3584
+ {
3585
+ name: "SIGTTOU",
3586
+ number: 22,
3587
+ action: "pause",
3588
+ description: "Background process cannot write to terminal output",
3589
+ standard: "posix"
3590
+ },
3591
+ {
3592
+ name: "SIGURG",
3593
+ number: 23,
3594
+ action: "ignore",
3595
+ description: "Socket received out-of-band data",
3596
+ standard: "bsd"
3597
+ },
3598
+ {
3599
+ name: "SIGXCPU",
3600
+ number: 24,
3601
+ action: "core",
3602
+ description: "Process timed out",
3603
+ standard: "bsd"
3604
+ },
3605
+ {
3606
+ name: "SIGXFSZ",
3607
+ number: 25,
3608
+ action: "core",
3609
+ description: "File too big",
3610
+ standard: "bsd"
3611
+ },
3612
+ {
3613
+ name: "SIGVTALRM",
3614
+ number: 26,
3615
+ action: "terminate",
3616
+ description: "Timeout or timer",
3617
+ standard: "bsd"
3618
+ },
3619
+ {
3620
+ name: "SIGPROF",
3621
+ number: 27,
3622
+ action: "terminate",
3623
+ description: "Timeout or timer",
3624
+ standard: "bsd"
3625
+ },
3626
+ {
3627
+ name: "SIGWINCH",
3628
+ number: 28,
3629
+ action: "ignore",
3630
+ description: "Terminal window size changed",
3631
+ standard: "bsd"
3632
+ },
3633
+ {
3634
+ name: "SIGIO",
3635
+ number: 29,
3636
+ action: "terminate",
3637
+ description: "I/O is available",
3638
+ standard: "other"
3639
+ },
3640
+ {
3641
+ name: "SIGPOLL",
3642
+ number: 29,
3643
+ action: "terminate",
3644
+ description: "Watched event",
3645
+ standard: "other"
3646
+ },
3647
+ {
3648
+ name: "SIGINFO",
3649
+ number: 29,
3650
+ action: "ignore",
3651
+ description: "Request for process information",
3652
+ standard: "other"
3653
+ },
3654
+ {
3655
+ name: "SIGPWR",
3656
+ number: 30,
3657
+ action: "terminate",
3658
+ description: "Device running out of power",
3659
+ standard: "systemv"
3660
+ },
3661
+ {
3662
+ name: "SIGSYS",
3663
+ number: 31,
3664
+ action: "core",
3665
+ description: "Invalid system call",
3666
+ standard: "other"
3667
+ },
3668
+ {
3669
+ name: "SIGUNUSED",
3670
+ number: 31,
3671
+ action: "terminate",
3672
+ description: "Invalid system call",
3673
+ standard: "other"
3674
+ }
3675
+ ];
3676
+
3677
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/signals.js
3678
+ var getSignals2 = () => {
3679
+ const realtimeSignals = getRealtimeSignals2();
3680
+ const signals2 = [...SIGNALS2, ...realtimeSignals].map(normalizeSignal2);
3681
+ return signals2;
3682
+ };
3683
+ var normalizeSignal2 = ({
3684
+ name,
3685
+ number: defaultNumber,
3686
+ description,
3687
+ action,
3688
+ forced = false,
3689
+ standard
3690
+ }) => {
3691
+ const {
3692
+ signals: { [name]: constantSignal }
3693
+ } = constants;
3694
+ const supported = constantSignal !== void 0;
3695
+ const number = supported ? constantSignal : defaultNumber;
3696
+ return { name, number, description, supported, action, forced, standard };
3697
+ };
3698
+
3699
+ // ../../node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/main.js
3700
+ var getSignalsByName2 = () => {
3701
+ const signals2 = getSignals2();
3702
+ return Object.fromEntries(signals2.map(getSignalByName2));
3703
+ };
3704
+ var getSignalByName2 = ({
3705
+ name,
3706
+ number,
3707
+ description,
3708
+ supported,
3709
+ action,
3710
+ forced,
3711
+ standard
3712
+ }) => [name, { name, number, description, supported, action, forced, standard }];
3713
+ var signalsByName2 = getSignalsByName2();
3714
+ var getSignalsByNumber2 = () => {
3715
+ const signals2 = getSignals2();
3716
+ const length = SIGRTMAX2 + 1;
3717
+ const signalsA = Array.from(
3718
+ { length },
3719
+ (value, number) => getSignalByNumber2(number, signals2)
3720
+ );
3721
+ return Object.assign({}, ...signalsA);
3722
+ };
3723
+ var getSignalByNumber2 = (number, signals2) => {
3724
+ const signal = findSignalByNumber2(number, signals2);
3725
+ if (signal === void 0) {
3726
+ return {};
3727
+ }
3728
+ const { name, description, supported, action, forced, standard } = signal;
3729
+ return {
3730
+ [number]: {
3731
+ name,
3732
+ number,
3733
+ description,
3734
+ supported,
3735
+ action,
3736
+ forced,
3737
+ standard
3738
+ }
3739
+ };
3740
+ };
3741
+ var findSignalByNumber2 = (number, signals2) => {
3742
+ const signal = signals2.find(({ name }) => constants.signals[name] === number);
3743
+ if (signal !== void 0) {
3744
+ return signal;
3745
+ }
3746
+ return signals2.find((signalA) => signalA.number === number);
3747
+ };
3748
+ getSignalsByNumber2();
3749
+
3750
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/error.js
3751
+ var getErrorPrefix2 = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => {
3752
+ if (timedOut) {
3753
+ return `timed out after ${timeout} milliseconds`;
3754
+ }
3755
+ if (isCanceled) {
3756
+ return "was canceled";
3757
+ }
3758
+ if (errorCode !== void 0) {
3759
+ return `failed with ${errorCode}`;
3760
+ }
3761
+ if (signal !== void 0) {
3762
+ return `was killed with ${signal} (${signalDescription})`;
3763
+ }
3764
+ if (exitCode !== void 0) {
3765
+ return `failed with exit code ${exitCode}`;
3766
+ }
3767
+ return "failed";
3768
+ };
3769
+ var makeError2 = ({
3770
+ stdout,
3771
+ stderr,
3772
+ all,
3773
+ error,
3774
+ signal,
3775
+ exitCode,
3776
+ command,
3777
+ escapedCommand,
3778
+ timedOut,
3779
+ isCanceled,
3780
+ killed,
3781
+ parsed: { options: { timeout, cwd = process2.cwd() } }
3782
+ }) => {
3783
+ exitCode = exitCode === null ? void 0 : exitCode;
3784
+ signal = signal === null ? void 0 : signal;
3785
+ const signalDescription = signal === void 0 ? void 0 : signalsByName2[signal].description;
3786
+ const errorCode = error && error.code;
3787
+ const prefix = getErrorPrefix2({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled });
3788
+ const execaMessage = `Command ${prefix}: ${command}`;
3789
+ const isError = Object.prototype.toString.call(error) === "[object Error]";
3790
+ const shortMessage = isError ? `${execaMessage}
3791
+ ${error.message}` : execaMessage;
3792
+ const message = [shortMessage, stderr, stdout].filter(Boolean).join("\n");
3793
+ if (isError) {
3794
+ error.originalMessage = error.message;
3795
+ error.message = message;
3796
+ } else {
3797
+ error = new Error(message);
3798
+ }
3799
+ error.shortMessage = shortMessage;
3800
+ error.command = command;
3801
+ error.escapedCommand = escapedCommand;
3802
+ error.exitCode = exitCode;
3803
+ error.signal = signal;
3804
+ error.signalDescription = signalDescription;
3805
+ error.stdout = stdout;
3806
+ error.stderr = stderr;
3807
+ error.cwd = cwd;
3808
+ if (all !== void 0) {
3809
+ error.all = all;
3810
+ }
3811
+ if ("bufferedData" in error) {
3812
+ delete error.bufferedData;
3813
+ }
3814
+ error.failed = true;
3815
+ error.timedOut = Boolean(timedOut);
3816
+ error.isCanceled = isCanceled;
3817
+ error.killed = killed && !timedOut;
3818
+ return error;
3819
+ };
3820
+
3821
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stdio.js
3822
+ var aliases2 = ["stdin", "stdout", "stderr"];
3823
+ var hasAlias2 = (options) => aliases2.some((alias) => options[alias] !== void 0);
3824
+ var normalizeStdio2 = (options) => {
3825
+ if (!options) {
3826
+ return;
3827
+ }
3828
+ const { stdio } = options;
3829
+ if (stdio === void 0) {
3830
+ return aliases2.map((alias) => options[alias]);
3831
+ }
3832
+ if (hasAlias2(options)) {
3833
+ throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases2.map((alias) => `\`${alias}\``).join(", ")}`);
3834
+ }
3835
+ if (typeof stdio === "string") {
3836
+ return stdio;
3837
+ }
3838
+ if (!Array.isArray(stdio)) {
3839
+ throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
3840
+ }
3841
+ const length = Math.max(stdio.length, aliases2.length);
3842
+ return Array.from({ length }, (value, index) => stdio[index]);
3843
+ };
3844
+
3845
+ // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
3846
+ var signals = [];
3847
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
3848
+ if (process.platform !== "win32") {
3849
+ signals.push(
3850
+ "SIGALRM",
3851
+ "SIGABRT",
3852
+ "SIGVTALRM",
3853
+ "SIGXCPU",
3854
+ "SIGXFSZ",
3855
+ "SIGUSR2",
3856
+ "SIGTRAP",
3857
+ "SIGSYS",
3858
+ "SIGQUIT",
3859
+ "SIGIOT"
3860
+ // should detect profiler and enable/disable accordingly.
3861
+ // see #21
3862
+ // 'SIGPROF'
3863
+ );
3864
+ }
3865
+ if (process.platform === "linux") {
3866
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
3867
+ }
3868
+
3869
+ // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
3870
+ 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";
3871
+ var kExitEmitter = Symbol.for("signal-exit emitter");
3872
+ var global2 = globalThis;
3873
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
3874
+ var Emitter = class {
3875
+ emitted = {
3876
+ afterExit: false,
3877
+ exit: false
3878
+ };
3879
+ listeners = {
3880
+ afterExit: [],
3881
+ exit: []
3882
+ };
3883
+ count = 0;
3884
+ id = Math.random();
3885
+ constructor() {
3886
+ if (global2[kExitEmitter]) {
3887
+ return global2[kExitEmitter];
3888
+ }
3889
+ ObjectDefineProperty(global2, kExitEmitter, {
3890
+ value: this,
3891
+ writable: false,
3892
+ enumerable: false,
3893
+ configurable: false
3894
+ });
3895
+ }
3896
+ on(ev, fn) {
3897
+ this.listeners[ev].push(fn);
3898
+ }
3899
+ removeListener(ev, fn) {
3900
+ const list = this.listeners[ev];
3901
+ const i = list.indexOf(fn);
3902
+ if (i === -1) {
3903
+ return;
3904
+ }
3905
+ if (i === 0 && list.length === 1) {
3906
+ list.length = 0;
3907
+ } else {
3908
+ list.splice(i, 1);
3909
+ }
3910
+ }
3911
+ emit(ev, code, signal) {
3912
+ if (this.emitted[ev]) {
3913
+ return false;
3914
+ }
3915
+ this.emitted[ev] = true;
3916
+ let ret = false;
3917
+ for (const fn of this.listeners[ev]) {
3918
+ ret = fn(code, signal) === true || ret;
3919
+ }
3920
+ if (ev === "exit") {
3921
+ ret = this.emit("afterExit", code, signal) || ret;
3922
+ }
3923
+ return ret;
3924
+ }
3925
+ };
3926
+ var SignalExitBase = class {
3927
+ };
3928
+ var signalExitWrap = (handler) => {
3929
+ return {
3930
+ onExit(cb, opts) {
3931
+ return handler.onExit(cb, opts);
3932
+ },
3933
+ load() {
3934
+ return handler.load();
3935
+ },
3936
+ unload() {
3937
+ return handler.unload();
3938
+ }
3939
+ };
3940
+ };
3941
+ var SignalExitFallback = class extends SignalExitBase {
3942
+ onExit() {
3943
+ return () => {
3944
+ };
3945
+ }
3946
+ load() {
3947
+ }
3948
+ unload() {
3949
+ }
3950
+ };
3951
+ var SignalExit = class extends SignalExitBase {
3952
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
3953
+ // so use a supported signal instead
3954
+ /* c8 ignore start */
3955
+ #hupSig = process6.platform === "win32" ? "SIGINT" : "SIGHUP";
3956
+ /* c8 ignore stop */
3957
+ #emitter = new Emitter();
3958
+ #process;
3959
+ #originalProcessEmit;
3960
+ #originalProcessReallyExit;
3961
+ #sigListeners = {};
3962
+ #loaded = false;
3963
+ constructor(process13) {
3964
+ super();
3965
+ this.#process = process13;
3966
+ this.#sigListeners = {};
3967
+ for (const sig of signals) {
3968
+ this.#sigListeners[sig] = () => {
3969
+ const listeners = this.#process.listeners(sig);
3970
+ let { count } = this.#emitter;
3971
+ const p = process13;
3972
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
3973
+ count += p.__signal_exit_emitter__.count;
3974
+ }
3975
+ if (listeners.length === count) {
3976
+ this.unload();
3977
+ const ret = this.#emitter.emit("exit", null, sig);
3978
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
3979
+ if (!ret)
3980
+ process13.kill(process13.pid, s);
3981
+ }
3982
+ };
3983
+ }
3984
+ this.#originalProcessReallyExit = process13.reallyExit;
3985
+ this.#originalProcessEmit = process13.emit;
3986
+ }
3987
+ onExit(cb, opts) {
3988
+ if (!processOk(this.#process)) {
3989
+ return () => {
3990
+ };
3991
+ }
3992
+ if (this.#loaded === false) {
3993
+ this.load();
3994
+ }
3995
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
3996
+ this.#emitter.on(ev, cb);
3997
+ return () => {
3998
+ this.#emitter.removeListener(ev, cb);
3999
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
4000
+ this.unload();
4001
+ }
4002
+ };
4003
+ }
4004
+ load() {
4005
+ if (this.#loaded) {
4006
+ return;
4007
+ }
4008
+ this.#loaded = true;
4009
+ this.#emitter.count += 1;
4010
+ for (const sig of signals) {
4011
+ try {
4012
+ const fn = this.#sigListeners[sig];
4013
+ if (fn)
4014
+ this.#process.on(sig, fn);
4015
+ } catch (_) {
4016
+ }
4017
+ }
4018
+ this.#process.emit = (ev, ...a) => {
4019
+ return this.#processEmit(ev, ...a);
4020
+ };
4021
+ this.#process.reallyExit = (code) => {
4022
+ return this.#processReallyExit(code);
4023
+ };
4024
+ }
4025
+ unload() {
4026
+ if (!this.#loaded) {
4027
+ return;
4028
+ }
4029
+ this.#loaded = false;
4030
+ signals.forEach((sig) => {
4031
+ const listener = this.#sigListeners[sig];
4032
+ if (!listener) {
4033
+ throw new Error("Listener not defined for signal: " + sig);
4034
+ }
4035
+ try {
4036
+ this.#process.removeListener(sig, listener);
4037
+ } catch (_) {
4038
+ }
4039
+ });
4040
+ this.#process.emit = this.#originalProcessEmit;
4041
+ this.#process.reallyExit = this.#originalProcessReallyExit;
4042
+ this.#emitter.count -= 1;
4043
+ }
4044
+ #processReallyExit(code) {
4045
+ if (!processOk(this.#process)) {
4046
+ return 0;
4047
+ }
4048
+ this.#process.exitCode = code || 0;
4049
+ this.#emitter.emit("exit", this.#process.exitCode, null);
4050
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
4051
+ }
4052
+ #processEmit(ev, ...args) {
4053
+ const og = this.#originalProcessEmit;
4054
+ if (ev === "exit" && processOk(this.#process)) {
4055
+ if (typeof args[0] === "number") {
4056
+ this.#process.exitCode = args[0];
4057
+ }
4058
+ const ret = og.call(this.#process, ev, ...args);
4059
+ this.#emitter.emit("exit", this.#process.exitCode, null);
4060
+ return ret;
4061
+ } else {
4062
+ return og.call(this.#process, ev, ...args);
4063
+ }
4064
+ }
4065
+ };
4066
+ var process6 = globalThis.process;
4067
+ var {
4068
+ /**
4069
+ * Called when the process is exiting, whether via signal, explicit
4070
+ * exit, or running out of stuff to do.
4071
+ *
4072
+ * If the global process object is not suitable for instrumentation,
4073
+ * then this will be a no-op.
4074
+ *
4075
+ * Returns a function that may be used to unload signal-exit.
4076
+ */
4077
+ onExit: onExit2} = signalExitWrap(processOk(process6) ? new SignalExit(process6) : new SignalExitFallback());
4078
+
4079
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/kill.js
4080
+ var DEFAULT_FORCE_KILL_TIMEOUT2 = 1e3 * 5;
4081
+ var spawnedKill2 = (kill2, signal = "SIGTERM", options = {}) => {
4082
+ const killResult = kill2(signal);
4083
+ setKillTimeout2(kill2, signal, options, killResult);
4084
+ return killResult;
4085
+ };
4086
+ var setKillTimeout2 = (kill2, signal, options, killResult) => {
4087
+ if (!shouldForceKill2(signal, options, killResult)) {
4088
+ return;
4089
+ }
4090
+ const timeout = getForceKillAfterTimeout2(options);
4091
+ const t = setTimeout(() => {
4092
+ kill2("SIGKILL");
4093
+ }, timeout);
4094
+ if (t.unref) {
4095
+ t.unref();
4096
+ }
4097
+ };
4098
+ var shouldForceKill2 = (signal, { forceKillAfterTimeout }, killResult) => isSigterm2(signal) && forceKillAfterTimeout !== false && killResult;
4099
+ var isSigterm2 = (signal) => signal === os.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
4100
+ var getForceKillAfterTimeout2 = ({ forceKillAfterTimeout = true }) => {
4101
+ if (forceKillAfterTimeout === true) {
4102
+ return DEFAULT_FORCE_KILL_TIMEOUT2;
4103
+ }
4104
+ if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
4105
+ throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
4106
+ }
4107
+ return forceKillAfterTimeout;
4108
+ };
4109
+ var spawnedCancel2 = (spawned, context) => {
4110
+ const killResult = spawned.kill();
4111
+ if (killResult) {
4112
+ context.isCanceled = true;
4113
+ }
4114
+ };
4115
+ var timeoutKill2 = (spawned, signal, reject) => {
4116
+ spawned.kill(signal);
4117
+ reject(Object.assign(new Error("Timed out"), { timedOut: true, signal }));
4118
+ };
4119
+ var setupTimeout2 = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
4120
+ if (timeout === 0 || timeout === void 0) {
4121
+ return spawnedPromise;
4122
+ }
4123
+ let timeoutId;
4124
+ const timeoutPromise = new Promise((resolve, reject) => {
4125
+ timeoutId = setTimeout(() => {
4126
+ timeoutKill2(spawned, killSignal, reject);
4127
+ }, timeout);
4128
+ });
4129
+ const safeSpawnedPromise = spawnedPromise.finally(() => {
4130
+ clearTimeout(timeoutId);
4131
+ });
4132
+ return Promise.race([timeoutPromise, safeSpawnedPromise]);
4133
+ };
4134
+ var validateTimeout2 = ({ timeout }) => {
4135
+ if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout < 0)) {
4136
+ throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
4137
+ }
4138
+ };
4139
+ var setExitHandler2 = async (spawned, { cleanup, detached }, timedPromise) => {
4140
+ if (!cleanup || detached) {
4141
+ return timedPromise;
4142
+ }
4143
+ const removeExitHandler = onExit2(() => {
4144
+ spawned.kill();
4145
+ });
4146
+ return timedPromise.finally(() => {
4147
+ removeExitHandler();
4148
+ });
4149
+ };
4150
+ var isExecaChildProcess = (target) => target instanceof ChildProcess && typeof target.then === "function";
4151
+ var pipeToTarget = (spawned, streamName, target) => {
4152
+ if (typeof target === "string") {
4153
+ spawned[streamName].pipe(createWriteStream(target));
4154
+ return spawned;
4155
+ }
4156
+ if (isWritableStream(target)) {
4157
+ spawned[streamName].pipe(target);
4158
+ return spawned;
4159
+ }
4160
+ if (!isExecaChildProcess(target)) {
4161
+ throw new TypeError("The second argument must be a string, a stream or an Execa child process.");
4162
+ }
4163
+ if (!isWritableStream(target.stdin)) {
4164
+ throw new TypeError("The target child process's stdin must be available.");
4165
+ }
4166
+ spawned[streamName].pipe(target.stdin);
4167
+ return target;
4168
+ };
4169
+ var addPipeMethods = (spawned) => {
4170
+ if (spawned.stdout !== null) {
4171
+ spawned.pipeStdout = pipeToTarget.bind(void 0, spawned, "stdout");
4172
+ }
4173
+ if (spawned.stderr !== null) {
4174
+ spawned.pipeStderr = pipeToTarget.bind(void 0, spawned, "stderr");
4175
+ }
4176
+ if (spawned.all !== void 0) {
4177
+ spawned.pipeAll = pipeToTarget.bind(void 0, spawned, "all");
4178
+ }
4179
+ };
4180
+
4181
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/contents.js
4182
+ var getStreamContents = async (stream2, { init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize }, { maxBuffer = Number.POSITIVE_INFINITY } = {}) => {
4183
+ if (!isAsyncIterable(stream2)) {
4184
+ throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");
4185
+ }
4186
+ const state = init();
4187
+ state.length = 0;
4188
+ try {
4189
+ for await (const chunk of stream2) {
4190
+ const chunkType = getChunkType(chunk);
4191
+ const convertedChunk = convertChunk[chunkType](chunk, state);
4192
+ appendChunk({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer });
4193
+ }
4194
+ appendFinalChunk({ state, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer });
4195
+ return finalize(state);
4196
+ } catch (error) {
4197
+ error.bufferedData = finalize(state);
4198
+ throw error;
4199
+ }
4200
+ };
4201
+ var appendFinalChunk = ({ state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer }) => {
4202
+ const convertedChunk = getFinalChunk(state);
4203
+ if (convertedChunk !== void 0) {
4204
+ appendChunk({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer });
4205
+ }
4206
+ };
4207
+ var appendChunk = ({ convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer }) => {
4208
+ const chunkSize = getSize(convertedChunk);
4209
+ const newLength = state.length + chunkSize;
4210
+ if (newLength <= maxBuffer) {
4211
+ addNewChunk(convertedChunk, state, addChunk, newLength);
4212
+ return;
4213
+ }
4214
+ const truncatedChunk = truncateChunk(convertedChunk, maxBuffer - state.length);
4215
+ if (truncatedChunk !== void 0) {
4216
+ addNewChunk(truncatedChunk, state, addChunk, maxBuffer);
4217
+ }
4218
+ throw new MaxBufferError();
4219
+ };
4220
+ var addNewChunk = (convertedChunk, state, addChunk, newLength) => {
4221
+ state.contents = addChunk(convertedChunk, state, newLength);
4222
+ state.length = newLength;
4223
+ };
4224
+ var isAsyncIterable = (stream2) => typeof stream2 === "object" && stream2 !== null && typeof stream2[Symbol.asyncIterator] === "function";
4225
+ var getChunkType = (chunk) => {
4226
+ const typeOfChunk = typeof chunk;
4227
+ if (typeOfChunk === "string") {
4228
+ return "string";
4229
+ }
4230
+ if (typeOfChunk !== "object" || chunk === null) {
4231
+ return "others";
4232
+ }
4233
+ if (globalThis.Buffer?.isBuffer(chunk)) {
4234
+ return "buffer";
4235
+ }
4236
+ const prototypeName = objectToString.call(chunk);
4237
+ if (prototypeName === "[object ArrayBuffer]") {
4238
+ return "arrayBuffer";
4239
+ }
4240
+ if (prototypeName === "[object DataView]") {
4241
+ return "dataView";
4242
+ }
4243
+ if (Number.isInteger(chunk.byteLength) && Number.isInteger(chunk.byteOffset) && objectToString.call(chunk.buffer) === "[object ArrayBuffer]") {
4244
+ return "typedArray";
4245
+ }
4246
+ return "others";
4247
+ };
4248
+ var { toString: objectToString } = Object.prototype;
4249
+ var MaxBufferError = class extends Error {
4250
+ name = "MaxBufferError";
4251
+ constructor() {
4252
+ super("maxBuffer exceeded");
4253
+ }
4254
+ };
4255
+
4256
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/utils.js
4257
+ var identity = (value) => value;
4258
+ var noop = () => void 0;
4259
+ var getContentsProp = ({ contents }) => contents;
4260
+ var throwObjectStream = (chunk) => {
4261
+ throw new Error(`Streams in object mode are not supported: ${String(chunk)}`);
4262
+ };
4263
+ var getLengthProp = (convertedChunk) => convertedChunk.length;
4264
+
4265
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array-buffer.js
4266
+ async function getStreamAsArrayBuffer(stream2, options) {
4267
+ return getStreamContents(stream2, arrayBufferMethods, options);
4268
+ }
4269
+ var initArrayBuffer = () => ({ contents: new ArrayBuffer(0) });
4270
+ var useTextEncoder = (chunk) => textEncoder.encode(chunk);
4271
+ var textEncoder = new TextEncoder();
4272
+ var useUint8Array = (chunk) => new Uint8Array(chunk);
4273
+ var useUint8ArrayWithOffset = (chunk) => new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
4274
+ var truncateArrayBufferChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);
4275
+ var addArrayBufferChunk = (convertedChunk, { contents, length: previousLength }, length) => {
4276
+ const newContents = hasArrayBufferResize() ? resizeArrayBuffer(contents, length) : resizeArrayBufferSlow(contents, length);
4277
+ new Uint8Array(newContents).set(convertedChunk, previousLength);
4278
+ return newContents;
4279
+ };
4280
+ var resizeArrayBufferSlow = (contents, length) => {
4281
+ if (length <= contents.byteLength) {
4282
+ return contents;
4283
+ }
4284
+ const arrayBuffer = new ArrayBuffer(getNewContentsLength(length));
4285
+ new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
4286
+ return arrayBuffer;
4287
+ };
4288
+ var resizeArrayBuffer = (contents, length) => {
4289
+ if (length <= contents.maxByteLength) {
4290
+ contents.resize(length);
4291
+ return contents;
4292
+ }
4293
+ const arrayBuffer = new ArrayBuffer(length, { maxByteLength: getNewContentsLength(length) });
4294
+ new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);
4295
+ return arrayBuffer;
4296
+ };
4297
+ var getNewContentsLength = (length) => SCALE_FACTOR ** Math.ceil(Math.log(length) / Math.log(SCALE_FACTOR));
4298
+ var SCALE_FACTOR = 2;
4299
+ var finalizeArrayBuffer = ({ contents, length }) => hasArrayBufferResize() ? contents : contents.slice(0, length);
4300
+ var hasArrayBufferResize = () => "resize" in ArrayBuffer.prototype;
4301
+ var arrayBufferMethods = {
4302
+ init: initArrayBuffer,
4303
+ convertChunk: {
4304
+ string: useTextEncoder,
4305
+ buffer: useUint8Array,
4306
+ arrayBuffer: useUint8Array,
4307
+ dataView: useUint8ArrayWithOffset,
4308
+ typedArray: useUint8ArrayWithOffset,
4309
+ others: throwObjectStream
4310
+ },
4311
+ getSize: getLengthProp,
4312
+ truncateChunk: truncateArrayBufferChunk,
4313
+ addChunk: addArrayBufferChunk,
4314
+ getFinalChunk: noop,
4315
+ finalize: finalizeArrayBuffer
4316
+ };
4317
+
4318
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/buffer.js
4319
+ async function getStreamAsBuffer(stream2, options) {
4320
+ if (!("Buffer" in globalThis)) {
4321
+ throw new Error("getStreamAsBuffer() is only supported in Node.js");
4322
+ }
4323
+ try {
4324
+ return arrayBufferToNodeBuffer(await getStreamAsArrayBuffer(stream2, options));
4325
+ } catch (error) {
4326
+ if (error.bufferedData !== void 0) {
4327
+ error.bufferedData = arrayBufferToNodeBuffer(error.bufferedData);
4328
+ }
4329
+ throw error;
4330
+ }
4331
+ }
4332
+ var arrayBufferToNodeBuffer = (arrayBuffer) => globalThis.Buffer.from(arrayBuffer);
4333
+
4334
+ // ../../node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/string.js
4335
+ async function getStreamAsString(stream2, options) {
4336
+ return getStreamContents(stream2, stringMethods, options);
4337
+ }
4338
+ var initString = () => ({ contents: "", textDecoder: new TextDecoder() });
4339
+ var useTextDecoder = (chunk, { textDecoder }) => textDecoder.decode(chunk, { stream: true });
4340
+ var addStringChunk = (convertedChunk, { contents }) => contents + convertedChunk;
4341
+ var truncateStringChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);
4342
+ var getFinalStringChunk = ({ textDecoder }) => {
4343
+ const finalChunk = textDecoder.decode();
4344
+ return finalChunk === "" ? void 0 : finalChunk;
4345
+ };
4346
+ var stringMethods = {
4347
+ init: initString,
4348
+ convertChunk: {
4349
+ string: identity,
4350
+ buffer: useTextDecoder,
4351
+ arrayBuffer: useTextDecoder,
4352
+ dataView: useTextDecoder,
4353
+ typedArray: useTextDecoder,
4354
+ others: throwObjectStream
4355
+ },
4356
+ getSize: getLengthProp,
4357
+ truncateChunk: truncateStringChunk,
4358
+ addChunk: addStringChunk,
4359
+ getFinalChunk: getFinalStringChunk,
4360
+ finalize: getContentsProp
4361
+ };
4362
+
4363
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stream.js
4364
+ var import_merge_stream2 = __toESM(require_merge_stream());
4365
+ var validateInputOptions = (input) => {
4366
+ if (input !== void 0) {
4367
+ throw new TypeError("The `input` and `inputFile` options cannot be both set.");
4368
+ }
4369
+ };
4370
+ var getInput = ({ input, inputFile }) => {
4371
+ if (typeof inputFile !== "string") {
4372
+ return input;
4373
+ }
4374
+ validateInputOptions(input);
4375
+ return createReadStream(inputFile);
4376
+ };
4377
+ var handleInput2 = (spawned, options) => {
4378
+ const input = getInput(options);
4379
+ if (input === void 0) {
4380
+ return;
4381
+ }
4382
+ if (isStream(input)) {
4383
+ input.pipe(spawned.stdin);
4384
+ } else {
4385
+ spawned.stdin.end(input);
4386
+ }
4387
+ };
4388
+ var makeAllStream2 = (spawned, { all }) => {
4389
+ if (!all || !spawned.stdout && !spawned.stderr) {
4390
+ return;
4391
+ }
4392
+ const mixed = (0, import_merge_stream2.default)();
4393
+ if (spawned.stdout) {
4394
+ mixed.add(spawned.stdout);
4395
+ }
4396
+ if (spawned.stderr) {
4397
+ mixed.add(spawned.stderr);
4398
+ }
4399
+ return mixed;
4400
+ };
4401
+ var getBufferedData2 = async (stream2, streamPromise) => {
4402
+ if (!stream2 || streamPromise === void 0) {
4403
+ return;
4404
+ }
4405
+ await setTimeout$1(0);
4406
+ stream2.destroy();
4407
+ try {
4408
+ return await streamPromise;
4409
+ } catch (error) {
4410
+ return error.bufferedData;
4411
+ }
4412
+ };
4413
+ var getStreamPromise2 = (stream2, { encoding, buffer, maxBuffer }) => {
4414
+ if (!stream2 || !buffer) {
4415
+ return;
4416
+ }
4417
+ if (encoding === "utf8" || encoding === "utf-8") {
4418
+ return getStreamAsString(stream2, { maxBuffer });
4419
+ }
4420
+ if (encoding === null || encoding === "buffer") {
4421
+ return getStreamAsBuffer(stream2, { maxBuffer });
4422
+ }
4423
+ return applyEncoding(stream2, maxBuffer, encoding);
4424
+ };
4425
+ var applyEncoding = async (stream2, maxBuffer, encoding) => {
4426
+ const buffer = await getStreamAsBuffer(stream2, { maxBuffer });
4427
+ return buffer.toString(encoding);
4428
+ };
4429
+ var getSpawnedResult2 = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
4430
+ const stdoutPromise = getStreamPromise2(stdout, { encoding, buffer, maxBuffer });
4431
+ const stderrPromise = getStreamPromise2(stderr, { encoding, buffer, maxBuffer });
4432
+ const allPromise = getStreamPromise2(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
4433
+ try {
4434
+ return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
4435
+ } catch (error) {
4436
+ return Promise.all([
4437
+ { error, signal: error.signal, timedOut: error.timedOut },
4438
+ getBufferedData2(stdout, stdoutPromise),
4439
+ getBufferedData2(stderr, stderrPromise),
4440
+ getBufferedData2(all, allPromise)
4441
+ ]);
4442
+ }
4443
+ };
4444
+
4445
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/promise.js
4446
+ var nativePromisePrototype2 = (async () => {
4447
+ })().constructor.prototype;
4448
+ var descriptors2 = ["then", "catch", "finally"].map((property) => [
4449
+ property,
4450
+ Reflect.getOwnPropertyDescriptor(nativePromisePrototype2, property)
4451
+ ]);
4452
+ var mergePromise2 = (spawned, promise) => {
4453
+ for (const [property, descriptor] of descriptors2) {
4454
+ const value = typeof promise === "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
4455
+ Reflect.defineProperty(spawned, property, { ...descriptor, value });
4456
+ }
4457
+ };
4458
+ var getSpawnedPromise2 = (spawned) => new Promise((resolve, reject) => {
4459
+ spawned.on("exit", (exitCode, signal) => {
4460
+ resolve({ exitCode, signal });
4461
+ });
4462
+ spawned.on("error", (error) => {
4463
+ reject(error);
4464
+ });
4465
+ if (spawned.stdin) {
4466
+ spawned.stdin.on("error", (error) => {
4467
+ reject(error);
1556
4468
  });
1557
4469
  }
4470
+ });
4471
+ var normalizeArgs2 = (file, args = []) => {
4472
+ if (!Array.isArray(args)) {
4473
+ return [file];
4474
+ }
4475
+ return [file, ...args];
1558
4476
  };
1559
- var Event = class extends _HeyApiClient {
1560
- /**
1561
- * Get events
1562
- */
1563
- subscribe(options) {
1564
- return (options?.client ?? this._client).get.sse({
1565
- url: "/event",
1566
- ...options
1567
- });
4477
+ var NO_ESCAPE_REGEXP2 = /^[\w.-]+$/;
4478
+ var escapeArg2 = (arg) => {
4479
+ if (typeof arg !== "string" || NO_ESCAPE_REGEXP2.test(arg)) {
4480
+ return arg;
1568
4481
  }
4482
+ return `"${arg.replaceAll('"', '\\"')}"`;
1569
4483
  };
1570
- var OpencodeClient = class extends _HeyApiClient {
1571
- /**
1572
- * Respond to a permission request
1573
- */
1574
- postSessionIdPermissionsPermissionId(options) {
1575
- return (options.client ?? this._client).post({
1576
- url: "/session/{id}/permissions/{permissionID}",
1577
- ...options,
1578
- headers: {
1579
- "Content-Type": "application/json",
1580
- ...options.headers
1581
- }
1582
- });
4484
+ var joinCommand2 = (file, args) => normalizeArgs2(file, args).join(" ");
4485
+ var getEscapedCommand2 = (file, args) => normalizeArgs2(file, args).map((arg) => escapeArg2(arg)).join(" ");
4486
+ var verboseDefault = debuglog("execa").enabled;
4487
+ var padField = (field, padding) => String(field).padStart(padding, "0");
4488
+ var getTimestamp = () => {
4489
+ const date = /* @__PURE__ */ new Date();
4490
+ return `${padField(date.getHours(), 2)}:${padField(date.getMinutes(), 2)}:${padField(date.getSeconds(), 2)}.${padField(date.getMilliseconds(), 3)}`;
4491
+ };
4492
+ var logCommand = (escapedCommand, { verbose }) => {
4493
+ if (!verbose) {
4494
+ return;
1583
4495
  }
1584
- global = new Global({ client: this._client });
1585
- project = new Project({ client: this._client });
1586
- config = new Config({ client: this._client });
1587
- tool = new Tool({ client: this._client });
1588
- instance = new Instance({ client: this._client });
1589
- path = new Path({ client: this._client });
1590
- vcs = new Vcs({ client: this._client });
1591
- session = new Session({ client: this._client });
1592
- command = new Command({ client: this._client });
1593
- provider = new Provider({ client: this._client });
1594
- find = new Find({ client: this._client });
1595
- file = new File2({ client: this._client });
1596
- app = new App({ client: this._client });
1597
- mcp = new Mcp({ client: this._client });
1598
- lsp = new Lsp({ client: this._client });
1599
- formatter = new Formatter({ client: this._client });
1600
- tui = new Tui({ client: this._client });
1601
- auth = new Auth({ client: this._client });
1602
- event = new Event({ client: this._client });
4496
+ process2.stderr.write(`[${getTimestamp()}] ${escapedCommand}
4497
+ `);
1603
4498
  };
1604
4499
 
1605
- // ../../node_modules/.pnpm/@opencode-ai+sdk@1.0.132/node_modules/@opencode-ai/sdk/dist/client.js
1606
- function createOpencodeClient(config) {
1607
- if (!config?.fetch) {
1608
- config = {
1609
- ...config,
1610
- fetch: (req) => {
1611
- req.timeout = false;
1612
- return fetch(req);
4500
+ // ../../node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js
4501
+ var DEFAULT_MAX_BUFFER2 = 1e3 * 1e3 * 100;
4502
+ var getEnv2 = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
4503
+ const env = extendEnv ? { ...process2.env, ...envOption } : envOption;
4504
+ if (preferLocal) {
4505
+ return npmRunPathEnv({ env, cwd: localDir, execPath });
4506
+ }
4507
+ return env;
4508
+ };
4509
+ var handleArguments2 = (file, args, options = {}) => {
4510
+ const parsed = import_cross_spawn2.default._parse(file, args, options);
4511
+ file = parsed.command;
4512
+ args = parsed.args;
4513
+ options = parsed.options;
4514
+ options = {
4515
+ maxBuffer: DEFAULT_MAX_BUFFER2,
4516
+ buffer: true,
4517
+ stripFinalNewline: true,
4518
+ extendEnv: true,
4519
+ preferLocal: false,
4520
+ localDir: options.cwd || process2.cwd(),
4521
+ execPath: process2.execPath,
4522
+ encoding: "utf8",
4523
+ reject: true,
4524
+ cleanup: true,
4525
+ all: false,
4526
+ windowsHide: true,
4527
+ verbose: verboseDefault,
4528
+ ...options
4529
+ };
4530
+ options.env = getEnv2(options);
4531
+ options.stdio = normalizeStdio2(options);
4532
+ if (process2.platform === "win32" && path.basename(file, ".exe") === "cmd") {
4533
+ args.unshift("/q");
4534
+ }
4535
+ return { file, args, options, parsed };
4536
+ };
4537
+ var handleOutput2 = (options, value, error) => {
4538
+ if (typeof value !== "string" && !Buffer$1.isBuffer(value)) {
4539
+ return error === void 0 ? void 0 : "";
4540
+ }
4541
+ if (options.stripFinalNewline) {
4542
+ return stripFinalNewline(value);
4543
+ }
4544
+ return value;
4545
+ };
4546
+ function execa2(file, args, options) {
4547
+ const parsed = handleArguments2(file, args, options);
4548
+ const command = joinCommand2(file, args);
4549
+ const escapedCommand = getEscapedCommand2(file, args);
4550
+ logCommand(escapedCommand, parsed.options);
4551
+ validateTimeout2(parsed.options);
4552
+ let spawned;
4553
+ try {
4554
+ spawned = childProcess2.spawn(parsed.file, parsed.args, parsed.options);
4555
+ } catch (error) {
4556
+ const dummySpawned = new childProcess2.ChildProcess();
4557
+ const errorPromise = Promise.reject(makeError2({
4558
+ error,
4559
+ stdout: "",
4560
+ stderr: "",
4561
+ all: "",
4562
+ command,
4563
+ escapedCommand,
4564
+ parsed,
4565
+ timedOut: false,
4566
+ isCanceled: false,
4567
+ killed: false
4568
+ }));
4569
+ mergePromise2(dummySpawned, errorPromise);
4570
+ return dummySpawned;
4571
+ }
4572
+ const spawnedPromise = getSpawnedPromise2(spawned);
4573
+ const timedPromise = setupTimeout2(spawned, parsed.options, spawnedPromise);
4574
+ const processDone = setExitHandler2(spawned, parsed.options, timedPromise);
4575
+ const context = { isCanceled: false };
4576
+ spawned.kill = spawnedKill2.bind(null, spawned.kill.bind(spawned));
4577
+ spawned.cancel = spawnedCancel2.bind(null, spawned, context);
4578
+ const handlePromise = async () => {
4579
+ const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult2(spawned, parsed.options, processDone);
4580
+ const stdout = handleOutput2(parsed.options, stdoutResult);
4581
+ const stderr = handleOutput2(parsed.options, stderrResult);
4582
+ const all = handleOutput2(parsed.options, allResult);
4583
+ if (error || exitCode !== 0 || signal !== null) {
4584
+ const returnedError = makeError2({
4585
+ error,
4586
+ exitCode,
4587
+ signal,
4588
+ stdout,
4589
+ stderr,
4590
+ all,
4591
+ command,
4592
+ escapedCommand,
4593
+ parsed,
4594
+ timedOut,
4595
+ isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
4596
+ killed: spawned.killed
4597
+ });
4598
+ if (!parsed.options.reject) {
4599
+ return returnedError;
1613
4600
  }
4601
+ throw returnedError;
4602
+ }
4603
+ return {
4604
+ command,
4605
+ escapedCommand,
4606
+ exitCode: 0,
4607
+ stdout,
4608
+ stderr,
4609
+ all,
4610
+ failed: false,
4611
+ timedOut: false,
4612
+ isCanceled: false,
4613
+ killed: false
1614
4614
  };
4615
+ };
4616
+ const handlePromiseOnce = onetime_default(handlePromise);
4617
+ handleInput2(spawned, parsed.options);
4618
+ spawned.all = makeAllStream2(spawned, parsed.options);
4619
+ addPipeMethods(spawned);
4620
+ mergePromise2(spawned, handlePromiseOnce);
4621
+ return spawned;
4622
+ }
4623
+
4624
+ // ../../node_modules/.pnpm/indent-string@5.0.0/node_modules/indent-string/index.js
4625
+ function indentString(string, count = 1, options = {}) {
4626
+ const {
4627
+ indent = " ",
4628
+ includeEmptyLines = false
4629
+ } = options;
4630
+ if (typeof string !== "string") {
4631
+ throw new TypeError(
4632
+ `Expected \`input\` to be a \`string\`, got \`${typeof string}\``
4633
+ );
1615
4634
  }
1616
- if (config?.directory) {
1617
- config.headers = {
1618
- ...config.headers,
1619
- "x-opencode-directory": config.directory
1620
- };
4635
+ if (typeof count !== "number") {
4636
+ throw new TypeError(
4637
+ `Expected \`count\` to be a \`number\`, got \`${typeof count}\``
4638
+ );
1621
4639
  }
1622
- const client2 = createClient(config);
1623
- return new OpencodeClient({ client: client2 });
4640
+ if (count < 0) {
4641
+ throw new RangeError(
4642
+ `Expected \`count\` to be at least 0, got \`${count}\``
4643
+ );
4644
+ }
4645
+ if (typeof indent !== "string") {
4646
+ throw new TypeError(
4647
+ `Expected \`options.indent\` to be a \`string\`, got \`${typeof indent}\``
4648
+ );
4649
+ }
4650
+ if (count === 0) {
4651
+ return string;
4652
+ }
4653
+ const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
4654
+ return string.replace(regex, indent.repeat(count));
1624
4655
  }
1625
- async function createOpencodeServer(options) {
1626
- options = Object.assign({
1627
- hostname: "127.0.0.1",
1628
- port: 4096,
1629
- timeout: 5e3
1630
- }, options ?? {});
1631
- const proc = spawn(`opencode`, [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`], {
1632
- signal: options.signal,
1633
- env: {
1634
- ...process.env,
1635
- OPENCODE_CONFIG_CONTENT: JSON.stringify(options.config ?? {})
4656
+
4657
+ // ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
4658
+ function escapeStringRegexp(string) {
4659
+ if (typeof string !== "string") {
4660
+ throw new TypeError("Expected a string");
4661
+ }
4662
+ return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
4663
+ }
4664
+ var getHomeDirectory = () => os.homedir().replace(/\\/g, "/");
4665
+ var home_directory_default = getHomeDirectory;
4666
+
4667
+ // ../../node_modules/.pnpm/clean-stack@5.3.0/node_modules/clean-stack/index.js
4668
+ var extractPathRegex = /\s+at.*[(\s](.*)\)?/;
4669
+ var pathRegex = /^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;
4670
+ function cleanStack(stack, { pretty = false, basePath, pathFilter } = {}) {
4671
+ const basePathRegex = basePath && new RegExp(`(file://)?${escapeStringRegexp(basePath.replace(/\\/g, "/"))}/?`, "g");
4672
+ const homeDirectory = pretty ? home_directory_default() : "";
4673
+ if (typeof stack !== "string") {
4674
+ return void 0;
4675
+ }
4676
+ return stack.replace(/\\/g, "/").split("\n").filter((line) => {
4677
+ const pathMatches = line.match(extractPathRegex);
4678
+ if (pathMatches === null || !pathMatches[1]) {
4679
+ return true;
1636
4680
  }
1637
- });
1638
- const url = await new Promise((resolve, reject) => {
1639
- const id = setTimeout(() => {
1640
- reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`));
1641
- }, options.timeout);
1642
- let output = "";
1643
- proc.stdout?.on("data", (chunk) => {
1644
- output += chunk.toString();
1645
- const lines = output.split("\n");
1646
- for (const line of lines) {
1647
- if (line.startsWith("opencode server listening")) {
1648
- const match2 = line.match(/on\s+(https?:\/\/[^\s]+)/);
1649
- if (!match2) {
1650
- throw new Error(`Failed to parse server url from output: ${line}`);
1651
- }
1652
- clearTimeout(id);
1653
- resolve(match2[1]);
1654
- return;
4681
+ const match2 = pathMatches[1];
4682
+ 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")) {
4683
+ return false;
4684
+ }
4685
+ return pathFilter ? !pathRegex.test(match2) && pathFilter(match2) : !pathRegex.test(match2);
4686
+ }).filter((line) => line.trim() !== "").map((line) => {
4687
+ if (basePathRegex) {
4688
+ line = line.replace(basePathRegex, "");
4689
+ }
4690
+ if (pretty) {
4691
+ line = line.replace(extractPathRegex, (m, p1) => {
4692
+ let filePath = p1;
4693
+ if (filePath.startsWith("file://")) {
4694
+ filePath = fileURLToPath(filePath);
1655
4695
  }
4696
+ filePath = filePath.replace(homeDirectory, "~");
4697
+ return m.replace(p1, filePath);
4698
+ });
4699
+ }
4700
+ return line;
4701
+ }).join("\n");
4702
+ }
4703
+
4704
+ // ../../node_modules/.pnpm/aggregate-error@5.0.0/node_modules/aggregate-error/index.js
4705
+ var cleanInternalStack = (stack) => stack.replaceAll(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, "");
4706
+ var AggregateError = class extends Error {
4707
+ #errors;
4708
+ name = "AggregateError";
4709
+ constructor(errors) {
4710
+ if (!Array.isArray(errors)) {
4711
+ throw new TypeError(`Expected input to be an Array, got ${typeof errors}`);
4712
+ }
4713
+ errors = errors.map((error) => {
4714
+ if (error instanceof Error) {
4715
+ return error;
1656
4716
  }
1657
- });
1658
- proc.stderr?.on("data", (chunk) => {
1659
- output += chunk.toString();
1660
- });
1661
- proc.on("exit", (code) => {
1662
- clearTimeout(id);
1663
- let msg = `Server exited with code ${code}`;
1664
- if (output.trim()) {
1665
- msg += `
1666
- Server output: ${output}`;
4717
+ if (error !== null && typeof error === "object") {
4718
+ return Object.assign(new Error(error.message), error);
1667
4719
  }
1668
- reject(new Error(msg));
1669
- });
1670
- proc.on("error", (error) => {
1671
- clearTimeout(id);
1672
- reject(error);
4720
+ return new Error(error);
1673
4721
  });
1674
- if (options.signal) {
1675
- options.signal.addEventListener("abort", () => {
1676
- clearTimeout(id);
1677
- reject(new Error("Aborted"));
1678
- });
1679
- }
1680
- });
4722
+ let message = errors.map(
4723
+ (error) => (
4724
+ // The `stack` property is not standardized, so we can't assume it exists
4725
+ typeof error.stack === "string" && error.stack.length > 0 ? cleanInternalStack(cleanStack(error.stack)) : String(error)
4726
+ )
4727
+ ).join("\n");
4728
+ message = "\n" + indentString(message, 4);
4729
+ super(message);
4730
+ this.#errors = errors;
4731
+ }
4732
+ get errors() {
4733
+ return [...this.#errors];
4734
+ }
4735
+ };
4736
+ var netstat = async (type) => {
4737
+ const { stdout } = await execa2("netstat", ["-anv", "-p", type]);
4738
+ return stdout;
4739
+ };
4740
+ var macos = async () => {
4741
+ const result = await Promise.all([
4742
+ netstat("tcp"),
4743
+ netstat("udp")
4744
+ ]);
4745
+ const tcp = result[0];
4746
+ const headerStart = tcp.indexOf("\n") + 1;
4747
+ const header = tcp.slice(headerStart, tcp.indexOf("\n", headerStart));
1681
4748
  return {
1682
- url,
1683
- close() {
1684
- proc.kill();
1685
- }
4749
+ stdout: result.join("\n"),
4750
+ addressColumn: 3,
4751
+ // Some versions of macOS print two extra columns for rxbytes and
4752
+ // txbytes before pid. Unfortunately headers can't be parsed because
4753
+ // they're space separated but some contain spaces, so we use this
4754
+ // heuristic to distinguish the two netstat versions.
4755
+ pidColumn: header.includes("rxbytes") ? 10 : 8
1686
4756
  };
1687
- }
1688
-
1689
- // ../../node_modules/.pnpm/@opencode-ai+sdk@1.0.132/node_modules/@opencode-ai/sdk/dist/index.js
1690
- async function createOpencode(options) {
1691
- const server = await createOpencodeServer({
1692
- ...options
1693
- });
1694
- const client2 = createOpencodeClient({
1695
- baseUrl: server.url
1696
- });
4757
+ };
4758
+ var linux = async () => {
4759
+ const { stdout } = await execa2("ss", ["-tunlp"]);
1697
4760
  return {
1698
- client: client2,
1699
- server
4761
+ stdout,
4762
+ addressColumn: 4,
4763
+ pidColumn: 6
4764
+ };
4765
+ };
4766
+ var windows = async () => {
4767
+ const { stdout } = await execa2("netstat", ["-ano"]);
4768
+ return {
4769
+ stdout,
4770
+ addressColumn: 1,
4771
+ pidColumn: 4
1700
4772
  };
4773
+ };
4774
+ var isProtocol = (value) => /^\s*(tcp|udp)/i.test(value);
4775
+ var parsePid = (pid) => {
4776
+ if (typeof pid !== "string") {
4777
+ return;
4778
+ }
4779
+ const { groups } = /(?:^|",|",pid=)(?<pid>\d+)/.exec(pid) || {};
4780
+ if (groups) {
4781
+ return Number.parseInt(groups.pid, 10);
4782
+ }
4783
+ };
4784
+ var getPort = (port, { lines, addressColumn, pidColumn }) => {
4785
+ const regex = new RegExp(`[.:]${port}$`);
4786
+ const foundPort = lines.find((line) => regex.test(line[addressColumn]));
4787
+ if (!foundPort) {
4788
+ throw new Error(`Could not find a process that uses port \`${port}\``);
4789
+ }
4790
+ return parsePid(foundPort[pidColumn]);
4791
+ };
4792
+ var implementation = process2.platform === "darwin" ? macos : process2.platform === "linux" ? linux : windows;
4793
+ var getList = async () => {
4794
+ const { stdout, addressColumn, pidColumn } = await implementation();
4795
+ const lines = stdout.split("\n").filter((line) => isProtocol(line)).map((line) => line.match(/\S+/g) || []);
4796
+ return { lines, addressColumn, pidColumn };
4797
+ };
4798
+ async function portToPid(port) {
4799
+ if (Array.isArray(port)) {
4800
+ const list = await getList();
4801
+ const tuples = await Promise.all(port.map((port_) => [port_, getPort(port_, list)]));
4802
+ return new Map(tuples);
4803
+ }
4804
+ if (!Number.isInteger(port)) {
4805
+ throw new TypeError(`Expected an integer, got ${typeof port}`);
4806
+ }
4807
+ return getPort(port, await getList());
1701
4808
  }
4809
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
4810
+ var TEN_MEGABYTES = 1e3 * 1e3 * 10;
4811
+ var execFile = promisify(childProcess2.execFile);
4812
+ var windows2 = async () => {
4813
+ let binary;
4814
+ switch (process2.arch) {
4815
+ case "x64":
4816
+ binary = "fastlist-0.3.0-x64.exe";
4817
+ break;
4818
+ case "ia32":
4819
+ binary = "fastlist-0.3.0-x86.exe";
4820
+ break;
4821
+ default:
4822
+ throw new Error(`Unsupported architecture: ${process2.arch}`);
4823
+ }
4824
+ const binaryPath = path.join(__dirname, "vendor", binary);
4825
+ const { stdout } = await execFile(binaryPath, {
4826
+ maxBuffer: TEN_MEGABYTES,
4827
+ windowsHide: true
4828
+ });
4829
+ return stdout.trim().split("\r\n").map((line) => line.split(" ")).map(([pid, ppid, name]) => ({
4830
+ pid: Number.parseInt(pid, 10),
4831
+ ppid: Number.parseInt(ppid, 10),
4832
+ name
4833
+ }));
4834
+ };
4835
+ var nonWindowsMultipleCalls = async (options = {}) => {
4836
+ const flags = (options.all === false ? "" : "a") + "wwxo";
4837
+ const returnValue = {};
4838
+ await Promise.all(["comm", "args", "ppid", "uid", "%cpu", "%mem"].map(async (cmd) => {
4839
+ const { stdout } = await execFile("ps", [flags, `pid,${cmd}`], { maxBuffer: TEN_MEGABYTES });
4840
+ for (let line of stdout.trim().split("\n").slice(1)) {
4841
+ line = line.trim();
4842
+ const [pid] = line.split(" ", 1);
4843
+ const value = line.slice(pid.length + 1).trim();
4844
+ if (returnValue[pid] === void 0) {
4845
+ returnValue[pid] = {};
4846
+ }
4847
+ returnValue[pid][cmd] = value;
4848
+ }
4849
+ }));
4850
+ return Object.entries(returnValue).filter(([, value]) => value.comm && value.args && value.ppid && value.uid && value["%cpu"] && value["%mem"]).map(([key, value]) => ({
4851
+ pid: Number.parseInt(key, 10),
4852
+ name: path.basename(value.comm),
4853
+ cmd: value.args,
4854
+ ppid: Number.parseInt(value.ppid, 10),
4855
+ uid: Number.parseInt(value.uid, 10),
4856
+ cpu: Number.parseFloat(value["%cpu"]),
4857
+ memory: Number.parseFloat(value["%mem"])
4858
+ }));
4859
+ };
4860
+ var ERROR_MESSAGE_PARSING_FAILED = "ps output parsing failed";
4861
+ var psOutputRegex = /^[ \t]*(?<pid>\d+)[ \t]+(?<ppid>\d+)[ \t]+(?<uid>[-\d]+)[ \t]+(?<cpu>\d+\.\d+)[ \t]+(?<memory>\d+\.\d+)[ \t]+(?<comm>.*)?/;
4862
+ var nonWindowsCall = async (options = {}) => {
4863
+ const flags = options.all === false ? "wwxo" : "awwxo";
4864
+ const psPromises = [
4865
+ execFile("ps", [flags, "pid,ppid,uid,%cpu,%mem,comm"], { maxBuffer: TEN_MEGABYTES }),
4866
+ execFile("ps", [flags, "pid,args"], { maxBuffer: TEN_MEGABYTES })
4867
+ ];
4868
+ const [psLines, psArgsLines] = (await Promise.all(psPromises)).map(({ stdout }) => stdout.trim().split("\n"));
4869
+ const psPids = new Set(psPromises.map((promise) => promise.child.pid));
4870
+ psLines.shift();
4871
+ psArgsLines.shift();
4872
+ const processCmds = {};
4873
+ for (const line of psArgsLines) {
4874
+ const [pid, cmds] = line.trim().split(" ");
4875
+ processCmds[pid] = cmds.join(" ");
4876
+ }
4877
+ const processes = psLines.map((line) => {
4878
+ const match2 = psOutputRegex.exec(line);
4879
+ if (match2 === null) {
4880
+ throw new Error(ERROR_MESSAGE_PARSING_FAILED);
4881
+ }
4882
+ const { pid, ppid, uid, cpu, memory, comm } = match2.groups;
4883
+ const processInfo = {
4884
+ pid: Number.parseInt(pid, 10),
4885
+ ppid: Number.parseInt(ppid, 10),
4886
+ uid: Number.parseInt(uid, 10),
4887
+ cpu: Number.parseFloat(cpu),
4888
+ memory: Number.parseFloat(memory),
4889
+ name: path.basename(comm),
4890
+ cmd: processCmds[pid]
4891
+ };
4892
+ return processInfo;
4893
+ }).filter((processInfo) => !psPids.has(processInfo.pid));
4894
+ return processes;
4895
+ };
4896
+ var nonWindows = async (options = {}) => {
4897
+ try {
4898
+ return await nonWindowsCall(options);
4899
+ } catch {
4900
+ return nonWindowsMultipleCalls(options);
4901
+ }
4902
+ };
4903
+ var psList = process2.platform === "win32" ? windows2 : nonWindows;
4904
+ var ps_list_default = psList;
1702
4905
 
1703
- // src/server.ts
1704
- var import_kill_port = __toESM(require_kill_port());
4906
+ // ../../node_modules/.pnpm/process-exists@5.0.0/node_modules/process-exists/index.js
4907
+ var linuxProcessMatchesName = (wantedProcessName, process13) => {
4908
+ if (typeof wantedProcessName === "string") {
4909
+ return process13.name === wantedProcessName || process13.cmd.split(" ")[0] === wantedProcessName;
4910
+ }
4911
+ return process13.pid === wantedProcessName;
4912
+ };
4913
+ var nonLinuxProcessMatchesName = (wantedProcessName, process13) => {
4914
+ if (typeof wantedProcessName === "string") {
4915
+ return process13.name === wantedProcessName;
4916
+ }
4917
+ return process13.pid === wantedProcessName;
4918
+ };
4919
+ var processMatchesName = process2.platform === "linux" ? linuxProcessMatchesName : nonLinuxProcessMatchesName;
4920
+ async function processExistsMultiple(processNames) {
4921
+ const processes = await ps_list_default();
4922
+ return new Map(processNames.map((processName) => [processName, processes.some((y) => processMatchesName(processName, y))]));
4923
+ }
4924
+ async function filterExistingProcesses(processNames) {
4925
+ const processes = await ps_list_default();
4926
+ return processNames.filter((processName) => processes.some((process_) => processMatchesName(processName, process_)));
4927
+ }
4928
+
4929
+ // ../../node_modules/.pnpm/fkill@9.0.0/node_modules/fkill/index.js
4930
+ var ALIVE_CHECK_MIN_INTERVAL = 5;
4931
+ var ALIVE_CHECK_MAX_INTERVAL = 1280;
4932
+ var TASKKILL_EXIT_CODE_FOR_PROCESS_FILTERING_SIGTERM = 255;
4933
+ var delay = (ms) => new Promise((resolve) => {
4934
+ setTimeout(resolve, ms);
4935
+ });
4936
+ var missingBinaryError = async (command, arguments_) => {
4937
+ try {
4938
+ return await execa2(command, arguments_);
4939
+ } catch (error) {
4940
+ if (error.code === "ENOENT") {
4941
+ const newError = new Error(`\`${command}\` doesn't seem to be installed and is required by fkill`);
4942
+ newError.sourceError = error;
4943
+ throw newError;
4944
+ }
4945
+ throw error;
4946
+ }
4947
+ };
4948
+ var windowsKill = async (input, options) => {
4949
+ try {
4950
+ return await taskkill(input, {
4951
+ force: options.force,
4952
+ tree: options.tree === void 0 ? true : options.tree
4953
+ });
4954
+ } catch (error) {
4955
+ if (error.exitCode === TASKKILL_EXIT_CODE_FOR_PROCESS_FILTERING_SIGTERM && !options.force) {
4956
+ return;
4957
+ }
4958
+ throw error;
4959
+ }
4960
+ };
4961
+ var macosKill = (input, options) => {
4962
+ const killByName = typeof input === "string";
4963
+ const command = killByName ? "pkill" : "kill";
4964
+ const arguments_ = [input];
4965
+ if (killByName && options.ignoreCase) {
4966
+ arguments_.unshift("-i");
4967
+ }
4968
+ if (killByName) {
4969
+ arguments_.unshift("-x");
4970
+ }
4971
+ if (options.force) {
4972
+ if (killByName) {
4973
+ arguments_.unshift("-KILL");
4974
+ } else {
4975
+ arguments_.unshift("-9");
4976
+ }
4977
+ }
4978
+ return missingBinaryError(command, arguments_);
4979
+ };
4980
+ var defaultKill = (input, options) => {
4981
+ const killByName = typeof input === "string";
4982
+ const command = killByName ? "killall" : "kill";
4983
+ const arguments_ = [input];
4984
+ if (options.force) {
4985
+ arguments_.unshift("-9");
4986
+ }
4987
+ if (killByName && options.ignoreCase) {
4988
+ arguments_.unshift("-I");
4989
+ }
4990
+ return missingBinaryError(command, arguments_);
4991
+ };
4992
+ var kill = (() => {
4993
+ if (process2.platform === "darwin") {
4994
+ return macosKill;
4995
+ }
4996
+ if (process2.platform === "win32") {
4997
+ return windowsKill;
4998
+ }
4999
+ return defaultKill;
5000
+ })();
5001
+ var parseInput = async (input) => {
5002
+ if (typeof input === "string" && input[0] === ":") {
5003
+ return portToPid(Number.parseInt(input.slice(1), 10));
5004
+ }
5005
+ return input;
5006
+ };
5007
+ var getCurrentProcessParentsPID = (processes) => {
5008
+ const processMap = new Map(processes.map((ps) => [ps.pid, ps.ppid]));
5009
+ const pids = [];
5010
+ let currentId = process2.pid;
5011
+ while (currentId) {
5012
+ pids.push(currentId);
5013
+ currentId = processMap.get(currentId);
5014
+ }
5015
+ return pids;
5016
+ };
5017
+ var killWithLimits = async (input, options) => {
5018
+ input = await parseInput(input);
5019
+ if (input === process2.pid) {
5020
+ return;
5021
+ }
5022
+ if (input === "node" || input === "node.exe") {
5023
+ const processes = await ps_list_default();
5024
+ const pids = getCurrentProcessParentsPID(processes);
5025
+ await Promise.all(processes.map(async (ps) => {
5026
+ if ((ps.name === "node" || ps.name === "node.exe") && !pids.includes(ps.pid)) {
5027
+ await kill(ps.pid, options);
5028
+ }
5029
+ }));
5030
+ return;
5031
+ }
5032
+ await kill(input, options);
5033
+ };
5034
+ async function fkill(inputs, options = {}) {
5035
+ inputs = [inputs].flat();
5036
+ const exists = await processExistsMultiple(inputs);
5037
+ const errors = [];
5038
+ const handleKill = async (input) => {
5039
+ try {
5040
+ await killWithLimits(input, options);
5041
+ } catch (error) {
5042
+ if (!exists.get(input)) {
5043
+ errors.push(`Killing process ${input} failed: Process doesn't exist`);
5044
+ return;
5045
+ }
5046
+ errors.push(`Killing process ${input} failed: ${error.message.replace(/.*\n/, "").replace(/kill: \d+: /, "").trim()}`);
5047
+ }
5048
+ };
5049
+ await Promise.all(inputs.map((input) => handleKill(input)));
5050
+ if (errors.length > 0 && !options.silent) {
5051
+ throw new AggregateError(errors);
5052
+ }
5053
+ if (options.forceAfterTimeout !== void 0 && !options.force) {
5054
+ const endTime = Date.now() + options.forceAfterTimeout;
5055
+ let interval = ALIVE_CHECK_MIN_INTERVAL;
5056
+ if (interval > options.forceAfterTimeout) {
5057
+ interval = options.forceAfterTimeout;
5058
+ }
5059
+ let alive = inputs;
5060
+ do {
5061
+ await delay(interval);
5062
+ alive = await filterExistingProcesses(alive);
5063
+ interval *= 2;
5064
+ if (interval > ALIVE_CHECK_MAX_INTERVAL) {
5065
+ interval = ALIVE_CHECK_MAX_INTERVAL;
5066
+ }
5067
+ } while (Date.now() < endTime && alive.length > 0);
5068
+ if (alive.length > 0) {
5069
+ await Promise.all(alive.map(async (input) => {
5070
+ try {
5071
+ await killWithLimits(input, { ...options, force: true });
5072
+ } catch {
5073
+ }
5074
+ }));
5075
+ }
5076
+ }
5077
+ }
1705
5078
 
1706
5079
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/compose.js
1707
5080
  var compose = (middleware, onError, onNotFound) => {
@@ -1819,26 +5192,26 @@ var handleParsingNestedValues = (form, key, value) => {
1819
5192
  };
1820
5193
 
1821
5194
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/utils/url.js
1822
- var splitPath = (path) => {
1823
- const paths = path.split("/");
5195
+ var splitPath = (path5) => {
5196
+ const paths = path5.split("/");
1824
5197
  if (paths[0] === "") {
1825
5198
  paths.shift();
1826
5199
  }
1827
5200
  return paths;
1828
5201
  };
1829
5202
  var splitRoutingPath = (routePath) => {
1830
- const { groups, path } = extractGroupsFromPath(routePath);
1831
- const paths = splitPath(path);
5203
+ const { groups, path: path5 } = extractGroupsFromPath(routePath);
5204
+ const paths = splitPath(path5);
1832
5205
  return replaceGroupMarks(paths, groups);
1833
5206
  };
1834
- var extractGroupsFromPath = (path) => {
5207
+ var extractGroupsFromPath = (path5) => {
1835
5208
  const groups = [];
1836
- path = path.replace(/\{[^}]+\}/g, (match2, index) => {
5209
+ path5 = path5.replace(/\{[^}]+\}/g, (match2, index) => {
1837
5210
  const mark = `@${index}`;
1838
5211
  groups.push([mark, match2]);
1839
5212
  return mark;
1840
5213
  });
1841
- return { groups, path };
5214
+ return { groups, path: path5 };
1842
5215
  };
1843
5216
  var replaceGroupMarks = (paths, groups) => {
1844
5217
  for (let i = groups.length - 1; i >= 0; i--) {
@@ -1893,8 +5266,8 @@ var getPath = (request) => {
1893
5266
  const charCode = url.charCodeAt(i);
1894
5267
  if (charCode === 37) {
1895
5268
  const queryIndex = url.indexOf("?", i);
1896
- const path = url.slice(start, queryIndex === -1 ? void 0 : queryIndex);
1897
- return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
5269
+ const path5 = url.slice(start, queryIndex === -1 ? void 0 : queryIndex);
5270
+ return tryDecodeURI(path5.includes("%25") ? path5.replace(/%25/g, "%2525") : path5);
1898
5271
  } else if (charCode === 63) {
1899
5272
  break;
1900
5273
  }
@@ -1911,11 +5284,11 @@ var mergePath = (base, sub, ...rest) => {
1911
5284
  }
1912
5285
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
1913
5286
  };
1914
- var checkOptionalParameter = (path) => {
1915
- if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
5287
+ var checkOptionalParameter = (path5) => {
5288
+ if (path5.charCodeAt(path5.length - 1) !== 63 || !path5.includes(":")) {
1916
5289
  return null;
1917
5290
  }
1918
- const segments = path.split("/");
5291
+ const segments = path5.split("/");
1919
5292
  const results = [];
1920
5293
  let basePath = "";
1921
5294
  segments.forEach((segment) => {
@@ -2028,9 +5401,9 @@ var HonoRequest = class {
2028
5401
  routeIndex = 0;
2029
5402
  path;
2030
5403
  bodyCache = {};
2031
- constructor(request, path = "/", matchResult = [[]]) {
5404
+ constructor(request, path5 = "/", matchResult = [[]]) {
2032
5405
  this.raw = request;
2033
- this.path = path;
5406
+ this.path = path5;
2034
5407
  this.#matchResult = matchResult;
2035
5408
  this.#validatedData = {};
2036
5409
  }
@@ -2391,8 +5764,8 @@ var Hono = class {
2391
5764
  return this;
2392
5765
  };
2393
5766
  });
2394
- this.on = (method, path, ...handlers) => {
2395
- for (const p of [path].flat()) {
5767
+ this.on = (method, path5, ...handlers) => {
5768
+ for (const p of [path5].flat()) {
2396
5769
  this.#path = p;
2397
5770
  for (const m of [method].flat()) {
2398
5771
  handlers.map((handler) => {
@@ -2430,8 +5803,8 @@ var Hono = class {
2430
5803
  }
2431
5804
  #notFoundHandler = notFoundHandler;
2432
5805
  errorHandler = errorHandler;
2433
- route(path, app) {
2434
- const subApp = this.basePath(path);
5806
+ route(path5, app) {
5807
+ const subApp = this.basePath(path5);
2435
5808
  app.routes.map((r) => {
2436
5809
  let handler;
2437
5810
  if (app.errorHandler === errorHandler) {
@@ -2444,9 +5817,9 @@ var Hono = class {
2444
5817
  });
2445
5818
  return this;
2446
5819
  }
2447
- basePath(path) {
5820
+ basePath(path5) {
2448
5821
  const subApp = this.#clone();
2449
- subApp._basePath = mergePath(this._basePath, path);
5822
+ subApp._basePath = mergePath(this._basePath, path5);
2450
5823
  return subApp;
2451
5824
  }
2452
5825
  onError = (handler) => {
@@ -2457,7 +5830,7 @@ var Hono = class {
2457
5830
  this.#notFoundHandler = handler;
2458
5831
  return this;
2459
5832
  };
2460
- mount(path, applicationHandler, options) {
5833
+ mount(path5, applicationHandler, options) {
2461
5834
  let replaceRequest;
2462
5835
  let optionHandler;
2463
5836
  if (options) {
@@ -2484,7 +5857,7 @@ var Hono = class {
2484
5857
  return [c.env, executionContext];
2485
5858
  };
2486
5859
  replaceRequest ||= (() => {
2487
- const mergedPath = mergePath(this._basePath, path);
5860
+ const mergedPath = mergePath(this._basePath, path5);
2488
5861
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
2489
5862
  return (request) => {
2490
5863
  const url = new URL(request.url);
@@ -2499,14 +5872,14 @@ var Hono = class {
2499
5872
  }
2500
5873
  await next();
2501
5874
  };
2502
- this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
5875
+ this.#addRoute(METHOD_NAME_ALL, mergePath(path5, "*"), handler);
2503
5876
  return this;
2504
5877
  }
2505
- #addRoute(method, path, handler) {
5878
+ #addRoute(method, path5, handler) {
2506
5879
  method = method.toUpperCase();
2507
- path = mergePath(this._basePath, path);
2508
- const r = { basePath: this._basePath, path, method, handler };
2509
- this.router.add(method, path, [handler, r]);
5880
+ path5 = mergePath(this._basePath, path5);
5881
+ const r = { basePath: this._basePath, path: path5, method, handler };
5882
+ this.router.add(method, path5, [handler, r]);
2510
5883
  this.routes.push(r);
2511
5884
  }
2512
5885
  #handleError(err, c) {
@@ -2519,10 +5892,10 @@ var Hono = class {
2519
5892
  if (method === "HEAD") {
2520
5893
  return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
2521
5894
  }
2522
- const path = this.getPath(request, { env });
2523
- const matchResult = this.router.match(method, path);
5895
+ const path5 = this.getPath(request, { env });
5896
+ const matchResult = this.router.match(method, path5);
2524
5897
  const c = new Context(request, {
2525
- path,
5898
+ path: path5,
2526
5899
  matchResult,
2527
5900
  env,
2528
5901
  executionCtx,
@@ -2582,15 +5955,15 @@ var Hono = class {
2582
5955
 
2583
5956
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/router/reg-exp-router/matcher.js
2584
5957
  var emptyParam = [];
2585
- function match(method, path) {
5958
+ function match(method, path5) {
2586
5959
  const matchers = this.buildAllMatchers();
2587
- const match2 = (method2, path2) => {
5960
+ const match2 = (method2, path22) => {
2588
5961
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
2589
- const staticMatch = matcher[2][path2];
5962
+ const staticMatch = matcher[2][path22];
2590
5963
  if (staticMatch) {
2591
5964
  return staticMatch;
2592
5965
  }
2593
- const match3 = path2.match(matcher[0]);
5966
+ const match3 = path22.match(matcher[0]);
2594
5967
  if (!match3) {
2595
5968
  return [[], emptyParam];
2596
5969
  }
@@ -2598,7 +5971,7 @@ function match(method, path) {
2598
5971
  return [matcher[1][index], match3];
2599
5972
  };
2600
5973
  this.match = match2;
2601
- return match2(method, path);
5974
+ return match2(method, path5);
2602
5975
  }
2603
5976
 
2604
5977
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/router/reg-exp-router/node.js
@@ -2713,12 +6086,12 @@ var Node = class {
2713
6086
  var Trie = class {
2714
6087
  #context = { varIndex: 0 };
2715
6088
  #root = new Node();
2716
- insert(path, index, pathErrorCheckOnly) {
6089
+ insert(path5, index, pathErrorCheckOnly) {
2717
6090
  const paramAssoc = [];
2718
6091
  const groups = [];
2719
6092
  for (let i = 0; ; ) {
2720
6093
  let replaced = false;
2721
- path = path.replace(/\{[^}]+\}/g, (m) => {
6094
+ path5 = path5.replace(/\{[^}]+\}/g, (m) => {
2722
6095
  const mark = `@\\${i}`;
2723
6096
  groups[i] = [mark, m];
2724
6097
  i++;
@@ -2729,7 +6102,7 @@ var Trie = class {
2729
6102
  break;
2730
6103
  }
2731
6104
  }
2732
- const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
6105
+ const tokens = path5.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
2733
6106
  for (let i = groups.length - 1; i >= 0; i--) {
2734
6107
  const [mark] = groups[i];
2735
6108
  for (let j = tokens.length - 1; j >= 0; j--) {
@@ -2768,9 +6141,9 @@ var Trie = class {
2768
6141
  // ../../node_modules/.pnpm/hono@4.10.7/node_modules/hono/dist/router/reg-exp-router/router.js
2769
6142
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
2770
6143
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
2771
- function buildWildcardRegExp(path) {
2772
- return wildcardRegExpCache[path] ??= new RegExp(
2773
- path === "*" ? "" : `^${path.replace(
6144
+ function buildWildcardRegExp(path5) {
6145
+ return wildcardRegExpCache[path5] ??= new RegExp(
6146
+ path5 === "*" ? "" : `^${path5.replace(
2774
6147
  /\/\*$|([.\\+*[^\]$()])/g,
2775
6148
  (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
2776
6149
  )}$`
@@ -2792,17 +6165,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
2792
6165
  );
2793
6166
  const staticMap = /* @__PURE__ */ Object.create(null);
2794
6167
  for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
2795
- const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
6168
+ const [pathErrorCheckOnly, path5, handlers] = routesWithStaticPathFlag[i];
2796
6169
  if (pathErrorCheckOnly) {
2797
- staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
6170
+ staticMap[path5] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
2798
6171
  } else {
2799
6172
  j++;
2800
6173
  }
2801
6174
  let paramAssoc;
2802
6175
  try {
2803
- paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
6176
+ paramAssoc = trie.insert(path5, j, pathErrorCheckOnly);
2804
6177
  } catch (e) {
2805
- throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
6178
+ throw e === PATH_ERROR ? new UnsupportedPathError(path5) : e;
2806
6179
  }
2807
6180
  if (pathErrorCheckOnly) {
2808
6181
  continue;
@@ -2836,12 +6209,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
2836
6209
  }
2837
6210
  return [regexp, handlerMap, staticMap];
2838
6211
  }
2839
- function findMiddleware(middleware, path) {
6212
+ function findMiddleware(middleware, path5) {
2840
6213
  if (!middleware) {
2841
6214
  return void 0;
2842
6215
  }
2843
6216
  for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
2844
- if (buildWildcardRegExp(k).test(path)) {
6217
+ if (buildWildcardRegExp(k).test(path5)) {
2845
6218
  return [...middleware[k]];
2846
6219
  }
2847
6220
  }
@@ -2855,7 +6228,7 @@ var RegExpRouter = class {
2855
6228
  this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
2856
6229
  this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
2857
6230
  }
2858
- add(method, path, handler) {
6231
+ add(method, path5, handler) {
2859
6232
  const middleware = this.#middleware;
2860
6233
  const routes = this.#routes;
2861
6234
  if (!middleware || !routes) {
@@ -2869,18 +6242,18 @@ var RegExpRouter = class {
2869
6242
  });
2870
6243
  });
2871
6244
  }
2872
- if (path === "/*") {
2873
- path = "*";
6245
+ if (path5 === "/*") {
6246
+ path5 = "*";
2874
6247
  }
2875
- const paramCount = (path.match(/\/:/g) || []).length;
2876
- if (/\*$/.test(path)) {
2877
- const re = buildWildcardRegExp(path);
6248
+ const paramCount = (path5.match(/\/:/g) || []).length;
6249
+ if (/\*$/.test(path5)) {
6250
+ const re = buildWildcardRegExp(path5);
2878
6251
  if (method === METHOD_NAME_ALL) {
2879
6252
  Object.keys(middleware).forEach((m) => {
2880
- middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
6253
+ middleware[m][path5] ||= findMiddleware(middleware[m], path5) || findMiddleware(middleware[METHOD_NAME_ALL], path5) || [];
2881
6254
  });
2882
6255
  } else {
2883
- middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
6256
+ middleware[method][path5] ||= findMiddleware(middleware[method], path5) || findMiddleware(middleware[METHOD_NAME_ALL], path5) || [];
2884
6257
  }
2885
6258
  Object.keys(middleware).forEach((m) => {
2886
6259
  if (method === METHOD_NAME_ALL || method === m) {
@@ -2898,15 +6271,15 @@ var RegExpRouter = class {
2898
6271
  });
2899
6272
  return;
2900
6273
  }
2901
- const paths = checkOptionalParameter(path) || [path];
6274
+ const paths = checkOptionalParameter(path5) || [path5];
2902
6275
  for (let i = 0, len = paths.length; i < len; i++) {
2903
- const path2 = paths[i];
6276
+ const path22 = paths[i];
2904
6277
  Object.keys(routes).forEach((m) => {
2905
6278
  if (method === METHOD_NAME_ALL || method === m) {
2906
- routes[m][path2] ||= [
2907
- ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
6279
+ routes[m][path22] ||= [
6280
+ ...findMiddleware(middleware[m], path22) || findMiddleware(middleware[METHOD_NAME_ALL], path22) || []
2908
6281
  ];
2909
- routes[m][path2].push([handler, paramCount - len + i + 1]);
6282
+ routes[m][path22].push([handler, paramCount - len + i + 1]);
2910
6283
  }
2911
6284
  });
2912
6285
  }
@@ -2925,13 +6298,13 @@ var RegExpRouter = class {
2925
6298
  const routes = [];
2926
6299
  let hasOwnRoute = method === METHOD_NAME_ALL;
2927
6300
  [this.#middleware, this.#routes].forEach((r) => {
2928
- const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];
6301
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path5) => [path5, r[method][path5]]) : [];
2929
6302
  if (ownRoute.length !== 0) {
2930
6303
  hasOwnRoute ||= true;
2931
6304
  routes.push(...ownRoute);
2932
6305
  } else if (method !== METHOD_NAME_ALL) {
2933
6306
  routes.push(
2934
- ...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]])
6307
+ ...Object.keys(r[METHOD_NAME_ALL]).map((path5) => [path5, r[METHOD_NAME_ALL][path5]])
2935
6308
  );
2936
6309
  }
2937
6310
  });
@@ -2951,13 +6324,13 @@ var SmartRouter = class {
2951
6324
  constructor(init) {
2952
6325
  this.#routers = init.routers;
2953
6326
  }
2954
- add(method, path, handler) {
6327
+ add(method, path5, handler) {
2955
6328
  if (!this.#routes) {
2956
6329
  throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
2957
6330
  }
2958
- this.#routes.push([method, path, handler]);
6331
+ this.#routes.push([method, path5, handler]);
2959
6332
  }
2960
- match(method, path) {
6333
+ match(method, path5) {
2961
6334
  if (!this.#routes) {
2962
6335
  throw new Error("Fatal error");
2963
6336
  }
@@ -2972,7 +6345,7 @@ var SmartRouter = class {
2972
6345
  for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
2973
6346
  router.add(...routes[i2]);
2974
6347
  }
2975
- res = router.match(method, path);
6348
+ res = router.match(method, path5);
2976
6349
  } catch (e) {
2977
6350
  if (e instanceof UnsupportedPathError) {
2978
6351
  continue;
@@ -3016,10 +6389,10 @@ var Node2 = class {
3016
6389
  }
3017
6390
  this.#patterns = [];
3018
6391
  }
3019
- insert(method, path, handler) {
6392
+ insert(method, path5, handler) {
3020
6393
  this.#order = ++this.#order;
3021
6394
  let curNode = this;
3022
- const parts = splitRoutingPath(path);
6395
+ const parts = splitRoutingPath(path5);
3023
6396
  const possibleKeys = [];
3024
6397
  for (let i = 0, len = parts.length; i < len; i++) {
3025
6398
  const p = parts[i];
@@ -3070,12 +6443,12 @@ var Node2 = class {
3070
6443
  }
3071
6444
  return handlerSets;
3072
6445
  }
3073
- search(method, path) {
6446
+ search(method, path5) {
3074
6447
  const handlerSets = [];
3075
6448
  this.#params = emptyParams;
3076
6449
  const curNode = this;
3077
6450
  let curNodes = [curNode];
3078
- const parts = splitPath(path);
6451
+ const parts = splitPath(path5);
3079
6452
  const curNodesQueue = [];
3080
6453
  for (let i = 0, len = parts.length; i < len; i++) {
3081
6454
  const part = parts[i];
@@ -3163,18 +6536,18 @@ var TrieRouter = class {
3163
6536
  constructor() {
3164
6537
  this.#node = new Node2();
3165
6538
  }
3166
- add(method, path, handler) {
3167
- const results = checkOptionalParameter(path);
6539
+ add(method, path5, handler) {
6540
+ const results = checkOptionalParameter(path5);
3168
6541
  if (results) {
3169
6542
  for (let i = 0, len = results.length; i < len; i++) {
3170
6543
  this.#node.insert(method, results[i], handler);
3171
6544
  }
3172
6545
  return;
3173
6546
  }
3174
- this.#node.insert(method, path, handler);
6547
+ this.#node.insert(method, path5, handler);
3175
6548
  }
3176
- match(method, path) {
3177
- return this.#node.search(method, path);
6549
+ match(method, path5) {
6550
+ return this.#node.search(method, path5);
3178
6551
  }
3179
6552
  };
3180
6553
 
@@ -3955,16 +7328,21 @@ var import_picocolors = __toESM(require_picocolors());
3955
7328
 
3956
7329
  // src/constants.ts
3957
7330
  var DEFAULT_PORT = 6567;
3958
- var VERSION = "0.0.80";
7331
+ var VERSION = "0.0.82";
7332
+ var OPENCODE_SDK_PORT = 4096;
7333
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3959
7334
  var opencodeInstance = null;
3960
7335
  var sessionMap = /* @__PURE__ */ new Map();
3961
7336
  var abortedSessions = /* @__PURE__ */ new Set();
3962
7337
  var lastOpencodeSessionId;
3963
7338
  var getOpencodeClient = async () => {
3964
7339
  if (!opencodeInstance) {
7340
+ await fkill(`:${OPENCODE_SDK_PORT}`, { force: true, silent: true }).catch(() => {
7341
+ });
7342
+ await sleep(100);
3965
7343
  const instance = await createOpencode({
3966
7344
  hostname: "127.0.0.1",
3967
- port: 4096
7345
+ port: OPENCODE_SDK_PORT
3968
7346
  });
3969
7347
  opencodeInstance = instance;
3970
7348
  }
@@ -4095,8 +7473,9 @@ ${stderr.trim()}` : errorMessage;
4095
7473
  return honoApplication;
4096
7474
  };
4097
7475
  var startServer = async (port = DEFAULT_PORT) => {
4098
- await (0, import_kill_port.default)(port).catch(() => {
7476
+ await fkill(`:${port}`, { force: true, silent: true }).catch(() => {
4099
7477
  });
7478
+ await sleep(100);
4100
7479
  const honoApplication = createServer();
4101
7480
  serve({ fetch: honoApplication.fetch, port });
4102
7481
  console.log(`${import_picocolors.default.magenta("\u269B")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Opencode)")}`);