UNPKG

create-eliza

Version:

Initialize an Eliza project

1,577 lines (1,543 loc) 140 kB
import { createRequire } from 'module'; const require = createRequire(import.meta.url); import { FormData, fetch_blob_default, formDataToBlob } from "./chunk-OTPEUTXL.js"; import { require_src } from "./chunk-JWMTR3QA.js"; import { require_main, require_signal_exit } from "./chunk-ZMJ3QLUC.js"; import { logger } from "./chunk-SAMVERMJ.js"; import { __commonJS, __require, __toESM } from "./chunk-WCMDOJQK.js"; // ../../node_modules/isexe/windows.js var require_windows = __commonJS({ "../../node_modules/isexe/windows.js"(exports, module) { module.exports = isexe; isexe.sync = sync; var fs3 = __require("fs"); function checkPathExt(path5, options) { var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT; if (!pathext) { return true; } pathext = pathext.split(";"); if (pathext.indexOf("") !== -1) { return true; } for (var i = 0; i < pathext.length; i++) { var p = pathext[i].toLowerCase(); if (p && path5.substr(-p.length).toLowerCase() === p) { return true; } } return false; } function checkStat(stat, path5, options) { if (!stat.isSymbolicLink() && !stat.isFile()) { return false; } return checkPathExt(path5, options); } function isexe(path5, options, cb) { fs3.stat(path5, function(er, stat) { cb(er, er ? false : checkStat(stat, path5, options)); }); } function sync(path5, options) { return checkStat(fs3.statSync(path5), path5, options); } } }); // ../../node_modules/isexe/mode.js var require_mode = __commonJS({ "../../node_modules/isexe/mode.js"(exports, module) { module.exports = isexe; isexe.sync = sync; var fs3 = __require("fs"); function isexe(path5, options, cb) { fs3.stat(path5, function(er, stat) { cb(er, er ? false : checkStat(stat, options)); }); } function sync(path5, options) { return checkStat(fs3.statSync(path5), options); } function checkStat(stat, options) { return stat.isFile() && checkMode(stat, options); } function checkMode(stat, options) { var mod = stat.mode; var uid = stat.uid; var gid = stat.gid; var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid(); var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid(); var u = parseInt("100", 8); var g = parseInt("010", 8); var o = parseInt("001", 8); var ug = u | g; var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0; return ret; } } }); // ../../node_modules/isexe/index.js var require_isexe = __commonJS({ "../../node_modules/isexe/index.js"(exports, module) { var fs3 = __require("fs"); var core; if (process.platform === "win32" || global.TESTING_WINDOWS) { core = require_windows(); } else { core = require_mode(); } module.exports = isexe; isexe.sync = sync; function isexe(path5, options, cb) { if (typeof options === "function") { cb = options; options = {}; } if (!cb) { if (typeof Promise !== "function") { throw new TypeError("callback not provided"); } return new Promise(function(resolve, reject) { isexe(path5, options || {}, function(er, is) { if (er) { reject(er); } else { resolve(is); } }); }); } core(path5, options || {}, function(er, is) { if (er) { if (er.code === "EACCES" || options && options.ignoreErrors) { er = null; is = false; } } cb(er, is); }); } function sync(path5, options) { try { return core.sync(path5, options || {}); } catch (er) { if (options && options.ignoreErrors || er.code === "EACCES") { return false; } else { throw er; } } } } }); // ../../node_modules/cross-spawn/node_modules/which/which.js var require_which = __commonJS({ "../../node_modules/cross-spawn/node_modules/which/which.js"(exports, module) { var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys"; var path5 = __require("path"); var COLON = isWindows ? ";" : ":"; var isexe = require_isexe(); var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" }); var getPathInfo = (cmd, opt) => { const colon = opt.colon || COLON; const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [ // windows always checks the cwd first ...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */ "").split(colon) ]; const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : ""; const pathExt = isWindows ? pathExtExe.split(colon) : [""]; if (isWindows) { if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift(""); } return { pathEnv, pathExt, pathExtExe }; }; var which = (cmd, opt, cb) => { if (typeof opt === "function") { cb = opt; opt = {}; } if (!opt) opt = {}; const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt); const found = []; const step = (i) => new Promise((resolve, reject) => { if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd)); const ppRaw = pathEnv[i]; const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; const pCmd = path5.join(pathPart, cmd); const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd; resolve(subStep(p, i, 0)); }); const subStep = (p, i, ii) => new Promise((resolve, reject) => { if (ii === pathExt.length) return resolve(step(i + 1)); const ext = pathExt[ii]; isexe(p + ext, { pathExt: pathExtExe }, (er, is) => { if (!er && is) { if (opt.all) found.push(p + ext); else return resolve(p + ext); } return resolve(subStep(p, i, ii + 1)); }); }); return cb ? step(0).then((res) => cb(null, res), cb) : step(0); }; var whichSync = (cmd, opt) => { opt = opt || {}; const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt); const found = []; for (let i = 0; i < pathEnv.length; i++) { const ppRaw = pathEnv[i]; const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; const pCmd = path5.join(pathPart, cmd); const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd; for (let j = 0; j < pathExt.length; j++) { const cur = p + pathExt[j]; try { const is = isexe.sync(cur, { pathExt: pathExtExe }); if (is) { if (opt.all) found.push(cur); else return cur; } } catch (ex) { } } } if (opt.all && found.length) return found; if (opt.nothrow) return null; throw getNotFoundError(cmd); }; module.exports = which; which.sync = whichSync; } }); // ../../node_modules/path-key/index.js var require_path_key = __commonJS({ "../../node_modules/path-key/index.js"(exports, module) { "use strict"; var pathKey2 = (options = {}) => { const environment = options.env || process.env; const platform = options.platform || process.platform; if (platform !== "win32") { return "PATH"; } return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path"; }; module.exports = pathKey2; module.exports.default = pathKey2; } }); // ../../node_modules/cross-spawn/lib/util/resolveCommand.js var require_resolveCommand = __commonJS({ "../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) { "use strict"; var path5 = __require("path"); var which = require_which(); var getPathKey = require_path_key(); function resolveCommandAttempt(parsed, withoutPathExt) { const env = parsed.options.env || process.env; const cwd = process.cwd(); const hasCustomCwd = parsed.options.cwd != null; const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled; if (shouldSwitchCwd) { try { process.chdir(parsed.options.cwd); } catch (err) { } } let resolved; try { resolved = which.sync(parsed.command, { path: env[getPathKey({ env })], pathExt: withoutPathExt ? path5.delimiter : void 0 }); } catch (e) { } finally { if (shouldSwitchCwd) { process.chdir(cwd); } } if (resolved) { resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved); } return resolved; } function resolveCommand(parsed) { return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true); } module.exports = resolveCommand; } }); // ../../node_modules/cross-spawn/lib/util/escape.js var require_escape = __commonJS({ "../../node_modules/cross-spawn/lib/util/escape.js"(exports, module) { "use strict"; var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g; function escapeCommand(arg) { arg = arg.replace(metaCharsRegExp, "^$1"); return arg; } function escapeArgument(arg, doubleEscapeMetaChars) { arg = `${arg}`; arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"'); arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1"); arg = `"${arg}"`; arg = arg.replace(metaCharsRegExp, "^$1"); if (doubleEscapeMetaChars) { arg = arg.replace(metaCharsRegExp, "^$1"); } return arg; } module.exports.command = escapeCommand; module.exports.argument = escapeArgument; } }); // ../../node_modules/shebang-regex/index.js var require_shebang_regex = __commonJS({ "../../node_modules/shebang-regex/index.js"(exports, module) { "use strict"; module.exports = /^#!(.*)/; } }); // ../../node_modules/shebang-command/index.js var require_shebang_command = __commonJS({ "../../node_modules/shebang-command/index.js"(exports, module) { "use strict"; var shebangRegex = require_shebang_regex(); module.exports = (string = "") => { const match = string.match(shebangRegex); if (!match) { return null; } const [path5, argument] = match[0].replace(/#! ?/, "").split(" "); const binary = path5.split("/").pop(); if (binary === "env") { return argument; } return argument ? `${binary} ${argument}` : binary; }; } }); // ../../node_modules/cross-spawn/lib/util/readShebang.js var require_readShebang = __commonJS({ "../../node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) { "use strict"; var fs3 = __require("fs"); var shebangCommand = require_shebang_command(); function readShebang(command) { const size = 150; const buffer = Buffer.alloc(size); let fd; try { fd = fs3.openSync(command, "r"); fs3.readSync(fd, buffer, 0, size, 0); fs3.closeSync(fd); } catch (e) { } return shebangCommand(buffer.toString()); } module.exports = readShebang; } }); // ../../node_modules/cross-spawn/lib/parse.js var require_parse = __commonJS({ "../../node_modules/cross-spawn/lib/parse.js"(exports, module) { "use strict"; var path5 = __require("path"); var resolveCommand = require_resolveCommand(); var escape = require_escape(); var readShebang = require_readShebang(); var isWin = process.platform === "win32"; var isExecutableRegExp = /\.(?:com|exe)$/i; var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; function detectShebang(parsed) { parsed.file = resolveCommand(parsed); const shebang = parsed.file && readShebang(parsed.file); if (shebang) { parsed.args.unshift(parsed.file); parsed.command = shebang; return resolveCommand(parsed); } return parsed.file; } function parseNonShell(parsed) { if (!isWin) { return parsed; } const commandFile = detectShebang(parsed); const needsShell = !isExecutableRegExp.test(commandFile); if (parsed.options.forceShell || needsShell) { const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile); parsed.command = path5.normalize(parsed.command); parsed.command = escape.command(parsed.command); parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars)); const shellCommand = [parsed.command].concat(parsed.args).join(" "); parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`]; parsed.command = process.env.comspec || "cmd.exe"; parsed.options.windowsVerbatimArguments = true; } return parsed; } function parse(command, args, options) { if (args && !Array.isArray(args)) { options = args; args = null; } args = args ? args.slice(0) : []; options = Object.assign({}, options); const parsed = { command, args, options, file: void 0, original: { command, args } }; return options.shell ? parsed : parseNonShell(parsed); } module.exports = parse; } }); // ../../node_modules/cross-spawn/lib/enoent.js var require_enoent = __commonJS({ "../../node_modules/cross-spawn/lib/enoent.js"(exports, module) { "use strict"; var isWin = process.platform === "win32"; function notFoundError(original, syscall) { return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), { code: "ENOENT", errno: "ENOENT", syscall: `${syscall} ${original.command}`, path: original.command, spawnargs: original.args }); } function hookChildProcess(cp, parsed) { if (!isWin) { return; } const originalEmit = cp.emit; cp.emit = function(name, arg1) { if (name === "exit") { const err = verifyENOENT(arg1, parsed); if (err) { return originalEmit.call(cp, "error", err); } } return originalEmit.apply(cp, arguments); }; } function verifyENOENT(status, parsed) { if (isWin && status === 1 && !parsed.file) { return notFoundError(parsed.original, "spawn"); } return null; } function verifyENOENTSync(status, parsed) { if (isWin && status === 1 && !parsed.file) { return notFoundError(parsed.original, "spawnSync"); } return null; } module.exports = { hookChildProcess, verifyENOENT, verifyENOENTSync, notFoundError }; } }); // ../../node_modules/cross-spawn/index.js var require_cross_spawn = __commonJS({ "../../node_modules/cross-spawn/index.js"(exports, module) { "use strict"; var cp = __require("child_process"); var parse = require_parse(); var enoent = require_enoent(); function spawn(command, args, options) { const parsed = parse(command, args, options); const spawned = cp.spawn(parsed.command, parsed.args, parsed.options); enoent.hookChildProcess(spawned, parsed); return spawned; } function spawnSync(command, args, options) { const parsed = parse(command, args, options); const result = cp.spawnSync(parsed.command, parsed.args, parsed.options); result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); return result; } module.exports = spawn; module.exports.spawn = spawn; module.exports.sync = spawnSync; module.exports._parse = parse; module.exports._enoent = enoent; } }); // ../../node_modules/execa/node_modules/get-stream/buffer-stream.js var require_buffer_stream = __commonJS({ "../../node_modules/execa/node_modules/get-stream/buffer-stream.js"(exports, module) { "use strict"; var { PassThrough: PassThroughStream } = __require("stream"); module.exports = (options) => { options = { ...options }; const { array } = options; let { encoding } = options; const isBuffer = encoding === "buffer"; let objectMode = false; if (array) { objectMode = !(encoding || isBuffer); } else { encoding = encoding || "utf8"; } if (isBuffer) { encoding = null; } const stream = new PassThroughStream({ objectMode }); if (encoding) { stream.setEncoding(encoding); } let length = 0; const chunks = []; stream.on("data", (chunk) => { chunks.push(chunk); if (objectMode) { length = chunks.length; } else { length += chunk.length; } }); stream.getBufferedValue = () => { if (array) { return chunks; } return isBuffer ? Buffer.concat(chunks, length) : chunks.join(""); }; stream.getBufferedLength = () => length; return stream; }; } }); // ../../node_modules/execa/node_modules/get-stream/index.js var require_get_stream = __commonJS({ "../../node_modules/execa/node_modules/get-stream/index.js"(exports, module) { "use strict"; var { constants: BufferConstants } = __require("buffer"); var stream = __require("stream"); var { promisify: promisify2 } = __require("util"); var bufferStream = require_buffer_stream(); var streamPipelinePromisified = promisify2(stream.pipeline); var MaxBufferError = class extends Error { constructor() { super("maxBuffer exceeded"); this.name = "MaxBufferError"; } }; async function getStream2(inputStream, options) { if (!inputStream) { throw new Error("Expected a stream"); } options = { maxBuffer: Infinity, ...options }; const { maxBuffer } = options; const stream2 = bufferStream(options); await new Promise((resolve, reject) => { const rejectPromise = (error) => { if (error && stream2.getBufferedLength() <= BufferConstants.MAX_LENGTH) { error.bufferedData = stream2.getBufferedValue(); } reject(error); }; (async () => { try { await streamPipelinePromisified(inputStream, stream2); resolve(); } catch (error) { rejectPromise(error); } })(); stream2.on("data", () => { if (stream2.getBufferedLength() > maxBuffer) { rejectPromise(new MaxBufferError()); } }); }); return stream2.getBufferedValue(); } module.exports = getStream2; module.exports.buffer = (stream2, options) => getStream2(stream2, { ...options, encoding: "buffer" }); module.exports.array = (stream2, options) => getStream2(stream2, { ...options, array: true }); module.exports.MaxBufferError = MaxBufferError; } }); // ../../node_modules/merge-stream/index.js var require_merge_stream = __commonJS({ "../../node_modules/merge-stream/index.js"(exports, module) { "use strict"; var { PassThrough: PassThrough3 } = __require("stream"); module.exports = function() { var sources = []; var output = new PassThrough3({ objectMode: true }); output.setMaxListeners(0); output.add = add; output.isEmpty = isEmpty; output.on("unpipe", remove); Array.prototype.slice.call(arguments).forEach(add); return output; function add(source) { if (Array.isArray(source)) { source.forEach(add); return this; } sources.push(source); source.once("end", remove.bind(null, source)); source.once("error", output.emit.bind(output, "error")); source.pipe(output, { end: false }); return this; } function isEmpty() { return sources.length == 0; } function remove(source) { sources = sources.filter(function(it) { return it !== source; }); if (!sources.length && output.readable) { output.end(); } } }; } }); // ../../node_modules/agent-base/dist/helpers.js var require_helpers = __commonJS({ "../../node_modules/agent-base/dist/helpers.js"(exports) { "use strict"; var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); } : function(o, m, k, k2) { if (k2 === void 0) k2 = k; o[k2] = m[k]; }); var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); var __importStar = exports && exports.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); } __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.req = exports.json = exports.toBuffer = void 0; var http3 = __importStar(__require("http")); var https2 = __importStar(__require("https")); async function toBuffer(stream) { let length = 0; const chunks = []; for await (const chunk of stream) { length += chunk.length; chunks.push(chunk); } return Buffer.concat(chunks, length); } exports.toBuffer = toBuffer; async function json(stream) { const buf = await toBuffer(stream); const str = buf.toString("utf8"); try { return JSON.parse(str); } catch (_err) { const err = _err; err.message += ` (input: ${str})`; throw err; } } exports.json = json; function req(url, opts = {}) { const href = typeof url === "string" ? url : url.href; const req2 = (href.startsWith("https:") ? https2 : http3).request(url, opts); const promise = new Promise((resolve, reject) => { req2.once("response", resolve).once("error", reject).end(); }); req2.then = promise.then.bind(promise); return req2; } exports.req = req; } }); // ../../node_modules/agent-base/dist/index.js var require_dist = __commonJS({ "../../node_modules/agent-base/dist/index.js"(exports) { "use strict"; var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); } : function(o, m, k, k2) { if (k2 === void 0) k2 = k; o[k2] = m[k]; }); var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); var __importStar = exports && exports.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); } __setModuleDefault(result, mod); return result; }; var __exportStar = exports && exports.__exportStar || function(m, exports2) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Agent = void 0; var net = __importStar(__require("net")); var http3 = __importStar(__require("http")); var https_1 = __require("https"); __exportStar(require_helpers(), exports); var INTERNAL = Symbol("AgentBaseInternalState"); var Agent = class extends http3.Agent { constructor(opts) { super(opts); this[INTERNAL] = {}; } /** * Determine whether this is an `http` or `https` request. */ isSecureEndpoint(options) { if (options) { if (typeof options.secureEndpoint === "boolean") { return options.secureEndpoint; } if (typeof options.protocol === "string") { return options.protocol === "https:"; } } const { stack } = new Error(); if (typeof stack !== "string") return false; return stack.split("\n").some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1); } // In order to support async signatures in `connect()` and Node's native // connection pooling in `http.Agent`, the array of sockets for each origin // has to be updated synchronously. This is so the length of the array is // accurate when `addRequest()` is next called. We achieve this by creating a // fake socket and adding it to `sockets[origin]` and incrementing // `totalSocketCount`. incrementSockets(name) { if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) { return null; } if (!this.sockets[name]) { this.sockets[name] = []; } const fakeSocket = new net.Socket({ writable: false }); this.sockets[name].push(fakeSocket); this.totalSocketCount++; return fakeSocket; } decrementSockets(name, socket) { if (!this.sockets[name] || socket === null) { return; } const sockets = this.sockets[name]; const index = sockets.indexOf(socket); if (index !== -1) { sockets.splice(index, 1); this.totalSocketCount--; if (sockets.length === 0) { delete this.sockets[name]; } } } // In order to properly update the socket pool, we need to call `getName()` on // the core `https.Agent` if it is a secureEndpoint. getName(options) { const secureEndpoint = typeof options.secureEndpoint === "boolean" ? options.secureEndpoint : this.isSecureEndpoint(options); if (secureEndpoint) { return https_1.Agent.prototype.getName.call(this, options); } return super.getName(options); } createSocket(req, options, cb) { const connectOpts = { ...options, secureEndpoint: this.isSecureEndpoint(options) }; const name = this.getName(connectOpts); const fakeSocket = this.incrementSockets(name); Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => { this.decrementSockets(name, fakeSocket); if (socket instanceof http3.Agent) { try { return socket.addRequest(req, connectOpts); } catch (err) { return cb(err); } } this[INTERNAL].currentSocket = socket; super.createSocket(req, options, cb); }, (err) => { this.decrementSockets(name, fakeSocket); cb(err); }); } createConnection() { const socket = this[INTERNAL].currentSocket; this[INTERNAL].currentSocket = void 0; if (!socket) { throw new Error("No socket was returned in the `connect()` function"); } return socket; } get defaultPort() { return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80); } set defaultPort(v) { if (this[INTERNAL]) { this[INTERNAL].defaultPort = v; } } get protocol() { return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:"); } set protocol(v) { if (this[INTERNAL]) { this[INTERNAL].protocol = v; } } }; exports.Agent = Agent; } }); // ../../node_modules/https-proxy-agent/dist/parse-proxy-response.js var require_parse_proxy_response = __commonJS({ "../../node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports) { "use strict"; var __importDefault = exports && exports.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseProxyResponse = void 0; var debug_1 = __importDefault(require_src()); var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response"); function parseProxyResponse(socket) { return new Promise((resolve, reject) => { let buffersLength = 0; const buffers = []; function read() { const b = socket.read(); if (b) ondata(b); else socket.once("readable", read); } function cleanup() { socket.removeListener("end", onend); socket.removeListener("error", onerror); socket.removeListener("readable", read); } function onend() { cleanup(); debug("onend"); reject(new Error("Proxy connection ended before receiving CONNECT response")); } function onerror(err) { cleanup(); debug("onerror %o", err); reject(err); } function ondata(b) { buffers.push(b); buffersLength += b.length; const buffered = Buffer.concat(buffers, buffersLength); const endOfHeaders = buffered.indexOf("\r\n\r\n"); if (endOfHeaders === -1) { debug("have not received end of HTTP headers yet..."); read(); return; } const headerParts = buffered.toString("ascii").split("\r\n"); const firstLine = headerParts.shift(); if (!firstLine) { socket.destroy(); return reject(new Error("No header received from proxy CONNECT response")); } const firstLineParts = firstLine.split(" "); const statusCode = +firstLineParts[1]; const statusText = firstLineParts.slice(2).join(" "); const headers = {}; for (const header of headerParts) { if (!header) continue; const firstColon = header.indexOf(":"); if (firstColon === -1) { socket.destroy(); return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`)); } const key = header.slice(0, firstColon).toLowerCase(); const value = header.slice(firstColon + 1).trimStart(); const current = headers[key]; if (typeof current === "string") { headers[key] = [current, value]; } else if (Array.isArray(current)) { current.push(value); } else { headers[key] = value; } } debug("got proxy server response: %o %o", firstLine, headers); cleanup(); resolve({ connect: { statusCode, statusText, headers }, buffered }); } socket.on("error", onerror); socket.on("end", onend); read(); }); } exports.parseProxyResponse = parseProxyResponse; } }); // ../../node_modules/https-proxy-agent/dist/index.js var require_dist2 = __commonJS({ "../../node_modules/https-proxy-agent/dist/index.js"(exports) { "use strict"; var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); } : function(o, m, k, k2) { if (k2 === void 0) k2 = k; o[k2] = m[k]; }); var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); var __importStar = exports && exports.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); } __setModuleDefault(result, mod); return result; }; var __importDefault = exports && exports.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpsProxyAgent = void 0; var net = __importStar(__require("net")); var tls = __importStar(__require("tls")); var assert_1 = __importDefault(__require("assert")); var debug_1 = __importDefault(require_src()); var agent_base_1 = require_dist(); var parse_proxy_response_1 = require_parse_proxy_response(); var debug = (0, debug_1.default)("https-proxy-agent"); var HttpsProxyAgent2 = class extends agent_base_1.Agent { get secureProxy() { return isHTTPS(this.proxy.protocol); } constructor(proxy, opts) { super(opts); this.options = { path: void 0 }; this.proxy = typeof proxy === "string" ? new URL(proxy) : proxy; this.proxyHeaders = opts?.headers ?? {}; debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href); const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ""); const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.secureProxy ? 443 : 80; this.connectOpts = { // Attempt to negotiate http/1.1 for proxy servers that support http/2 ALPNProtocols: ["http/1.1"], ...opts ? omit(opts, "headers") : null, host, port }; } /** * Called when the node-core HTTP client library is creating a * new HTTP request. */ async connect(req, opts) { const { proxy, secureProxy } = this; if (!opts.host) { throw new TypeError('No "host" provided'); } let socket; if (secureProxy) { debug("Creating `tls.Socket`: %o", this.connectOpts); socket = tls.connect(this.connectOpts); } else { debug("Creating `net.Socket`: %o", this.connectOpts); socket = net.connect(this.connectOpts); } const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders }; const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host; let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r `; if (proxy.username || proxy.password) { const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`; headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`; } headers.Host = `${host}:${opts.port}`; if (!headers["Proxy-Connection"]) { headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close"; } for (const name of Object.keys(headers)) { payload += `${name}: ${headers[name]}\r `; } const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket); socket.write(`${payload}\r `); const { connect, buffered } = await proxyResponsePromise; req.emit("proxyConnect", connect); this.emit("proxyConnect", connect, req); if (connect.statusCode === 200) { req.once("socket", resume); if (opts.secureEndpoint) { debug("Upgrading socket connection to TLS"); const servername = opts.servername || opts.host; return tls.connect({ ...omit(opts, "host", "path", "port"), socket, servername: net.isIP(servername) ? void 0 : servername }); } return socket; } socket.destroy(); const fakeSocket = new net.Socket({ writable: false }); fakeSocket.readable = true; req.once("socket", (s) => { debug("Replaying proxy buffer for failed request"); (0, assert_1.default)(s.listenerCount("data") > 0); s.push(buffered); s.push(null); }); return fakeSocket; } }; HttpsProxyAgent2.protocols = ["http", "https"]; exports.HttpsProxyAgent = HttpsProxyAgent2; function resume(socket) { socket.resume(); } function isHTTPS(protocol) { return typeof protocol === "string" ? /^https:?$/i.test(protocol) : false; } function omit(obj, ...keys) { const ret = {}; let key; for (key in obj) { if (!keys.includes(key)) { ret[key] = obj[key]; } } return ret; } } }); // ../../node_modules/execa/index.js var import_cross_spawn = __toESM(require_cross_spawn(), 1); import { Buffer as Buffer3 } from "node:buffer"; import path2 from "node:path"; import childProcess from "node:child_process"; import process5 from "node:process"; // ../../node_modules/strip-final-newline/index.js function stripFinalNewline(input) { const LF = typeof input === "string" ? "\n" : "\n".charCodeAt(); const CR = typeof input === "string" ? "\r" : "\r".charCodeAt(); if (input[input.length - 1] === LF) { input = input.slice(0, -1); } if (input[input.length - 1] === CR) { input = input.slice(0, -1); } return input; } // ../../node_modules/npm-run-path/index.js import process2 from "node:process"; import path from "node:path"; import { fileURLToPath } from "node:url"; // ../../node_modules/npm-run-path/node_modules/path-key/index.js function pathKey(options = {}) { const { env = process.env, platform = process.platform } = options; if (platform !== "win32") { return "PATH"; } return Object.keys(env).reverse().find((key) => key.toUpperCase() === "PATH") || "Path"; } // ../../node_modules/npm-run-path/index.js var npmRunPath = ({ cwd = process2.cwd(), path: pathOption = process2.env[pathKey()], preferLocal = true, execPath = process2.execPath, addExecPath = true } = {}) => { const cwdString = cwd instanceof URL ? fileURLToPath(cwd) : cwd; const cwdPath = path.resolve(cwdString); const result = []; if (preferLocal) { applyPreferLocal(result, cwdPath); } if (addExecPath) { applyExecPath(result, execPath, cwdPath); } return [...result, pathOption].join(path.delimiter); }; var applyPreferLocal = (result, cwdPath) => { let previous; while (previous !== cwdPath) { result.push(path.join(cwdPath, "node_modules/.bin")); previous = cwdPath; cwdPath = path.resolve(cwdPath, ".."); } }; var applyExecPath = (result, execPath, cwdPath) => { const execPathString = execPath instanceof URL ? fileURLToPath(execPath) : execPath; result.push(path.resolve(cwdPath, execPathString, "..")); }; var npmRunPathEnv = ({ env = process2.env, ...options } = {}) => { env = { ...env }; const pathName = pathKey({ env }); options.path = env[pathName]; env[pathName] = npmRunPath(options); return env; }; // ../../node_modules/mimic-fn/index.js var copyProperty = (to, from, property, ignoreNonConfigurable) => { if (property === "length" || property === "prototype") { return; } if (property === "arguments" || property === "caller") { return; } const toDescriptor = Object.getOwnPropertyDescriptor(to, property); const fromDescriptor = Object.getOwnPropertyDescriptor(from, property); if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) { return; } Object.defineProperty(to, property, fromDescriptor); }; var canCopyProperty = function(toDescriptor, fromDescriptor) { return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value); }; var changePrototype = (to, from) => { const fromPrototype = Object.getPrototypeOf(from); if (fromPrototype === Object.getPrototypeOf(to)) { return; } Object.setPrototypeOf(to, fromPrototype); }; var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/ ${fromBody}`; var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString"); var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name"); var changeToString = (to, from, name) => { const withName = name === "" ? "" : `with ${name.trim()}() `; const newToString = wrappedToString.bind(null, withName, from.toString()); Object.defineProperty(newToString, "name", toStringName); Object.defineProperty(to, "toString", { ...toStringDescriptor, value: newToString }); }; function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) { const { name } = to; for (const property of Reflect.ownKeys(from)) { copyProperty(to, from, property, ignoreNonConfigurable); } changePrototype(to, from); changeToString(to, from, name); return to; } // ../../node_modules/onetime/index.js var calledFunctions = /* @__PURE__ */ new WeakMap(); var onetime = (function_, options = {}) => { if (typeof function_ !== "function") { throw new TypeError("Expected a function"); } let returnValue; let callCount = 0; const functionName = function_.displayName || function_.name || "<anonymous>"; const onetime2 = function(...arguments_) { calledFunctions.set(onetime2, ++callCount); if (callCount === 1) { returnValue = function_.apply(this, arguments_); function_ = null; } else if (options.throw === true) { throw new Error(`Function \`${functionName}\` can only be called once`); } return returnValue; }; mimicFunction(onetime2, function_); calledFunctions.set(onetime2, callCount); return onetime2; }; onetime.callCount = (function_) => { if (!calledFunctions.has(function_)) { throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`); } return calledFunctions.get(function_); }; var onetime_default = onetime; // ../../node_modules/execa/lib/error.js import process3 from "node:process"; // ../../node_modules/human-signals/build/src/main.js import { constants as constants2 } from "node:os"; // ../../node_modules/human-signals/build/src/realtime.js var getRealtimeSignals = () => { const length = SIGRTMAX - SIGRTMIN + 1; return Array.from({ length }, getRealtimeSignal); }; var getRealtimeSignal = (value, index) => ({ name: `SIGRT${index + 1}`, number: SIGRTMIN + index, action: "terminate", description: "Application-specific signal (realtime)", standard: "posix" }); var SIGRTMIN = 34; var SIGRTMAX = 64; // ../../node_modules/human-signals/build/src/signals.js import { constants } from "node:os"; // ../../node_modules/human-signals/build/src/core.js var SIGNALS = [ { name: "SIGHUP", number: 1, action: "terminate", description: "Terminal closed", standard: "posix" }, { name: "SIGINT", number: 2, action: "terminate", description: "User interruption with CTRL-C", standard: "ansi" }, { name: "SIGQUIT", number: 3, action: "core", description: "User interruption with CTRL-\\", standard: "posix" }, { name: "SIGILL", number: 4, action: "core", description: "Invalid machine instruction", standard: "ansi" }, { name: "SIGTRAP", number: 5, action: "core", description: "Debugger breakpoint", standard: "posix" }, { name: "SIGABRT", number: 6, action: "core", description: "Aborted", standard: "ansi" }, { name: "SIGIOT", number: 6, action: "core", description: "Aborted", standard: "bsd" }, { name: "SIGBUS", number: 7, action: "core", description: "Bus error due to misaligned, non-existing address or paging error", standard: "bsd" }, { name: "SIGEMT", number: 7, action: "terminate", description: "Command should be emulated but is not implemented", standard: "other" }, { name: "SIGFPE", number: 8, action: "core", description: "Floating point arithmetic error", standard: "ansi" }, { name: "SIGKILL", number: 9, action: "terminate", description: "Forced termination", standard: "posix", forced: true }, { name: "SIGUSR1", number: 10, action: "terminate", description: "Application-specific signal", standard: "posix" }, { name: "SIGSEGV", number: 11, action: "core", description: "Segmentation fault", standard: "ansi" }, { name: "SIGUSR2", number: 12, action: "terminate", description: "Application-specific signal", standard: "posix" }, { name: "SIGPIPE", number: 13, action: "terminate", description: "Broken pipe or socket", standard: "posix" }, { name: "SIGALRM", number: 14, action: "terminate", description: "Timeout or timer", standard: "posix" }, { name: "SIGTERM", number: 15, action: "terminate", description: "Termination", standard: "ansi" }, { name: "SIGSTKFLT", number: 16, action: "terminate", description: "Stack is empty or overflowed", standard: "other" }, { name: "SIGCHLD", number: 17, action: "ignore", description: "Child process terminated, paused or unpaused", standard: "posix" }, { name: "SIGCLD", number: 17, action: "ignore", description: "Child process terminated, paused or unpaused", standard: "other" }, { name: "SIGCONT", number: 18, action: "unpause", description: "Unpaused", standard: "posix", forced: true }, { name: "SIGSTOP", number: 19, action: "pause", description: "Paused", standard: "posix", forced: true }, { name: "SIGTSTP", number: 20, action: "pause", description: 'Paused using CTRL-Z or "suspend"', standard: "posix" }, { name: "SIGTTIN", number: 21, action: "pause", description: "Background process cannot read terminal input", standard: "posix" }, { name: "SIGBREAK", number: 21, action: "terminate", description: "User interruption with CTRL-BREAK", standard: "other" }, { name: "SIGTTOU", number: 22, action: "pause", description: "Background process cannot write to terminal output", standard: "posix" }, { name: "SIGURG", number: 23, action: "ignore", description: "Socket received out-of-band data", standard: "bsd" }, { name: "SIGXCPU", number: 24, action: "core", description: "Process timed out", standard: "bsd" }, { name: "SIGXFSZ", number: 25, action: "core", description: "File too big", standard: "bsd" }, { name: "SIGVTALRM", number: 26, action: "terminate", description: "Timeout or timer", standard: "bsd" }, { name: "SIGPROF", number: 27, action: "terminate", description: "Timeout or timer", standard: "bsd" }, { name: "SIGWINCH", number: 28, action: "ignore", description: "Terminal window size changed", standard: "bsd" }, { name: "SIGIO", number: 29, action: "terminate", description: "I/O is available", standard: "other" }, { name: "SIGPOLL", number: 29, action: "terminate", description: "Watched event", standard: "other" }, { name: "SIGINFO", number: 29, action: "ignore", description: "Request for process information", standard: "other" }, { name: "SIGPWR", number: 30, action: "terminate", description: "Device running out of power", standard: "systemv" }, { name: "SIGSYS", number: 31, action: "core", description: "Invalid system call", standard: "other" }, { name: "SIGUNUSED", number: 31, action: "terminate", description: "Invalid system