This commit is contained in:
di-sukharev
2023-05-26 13:14:47 +08:00
parent cad179953a
commit a70b831f9d
2 changed files with 937 additions and 19 deletions
+4 -8
View File
@@ -16272,7 +16272,7 @@ function G3(t, e2) {
// package.json
var package_default = {
name: "opencommit",
version: "2.2.9",
version: "2.2.10",
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
keywords: [
"git",
@@ -21734,9 +21734,7 @@ var OpenAi = class {
max_tokens: maxTokens || 500
};
try {
const REQUEST_TOKENS = messages.map(
(msg) => tokenCount(msg.content) + 4
).reduce((a2, b5) => a2 + b5, 0);
const REQUEST_TOKENS = messages.map((msg) => tokenCount(msg.content) + 4).reduce((a2, b5) => a2 + b5, 0);
if (REQUEST_TOKENS > DEFAULT_MODEL_TOKEN_LIMIT - maxTokens) {
throw new Error("TOO_MUCH_TOKENS" /* tooMuchTokens */);
}
@@ -21761,10 +21759,8 @@ var OpenAi = class {
};
var getOpenCommitLatestVersion = async () => {
try {
const { data } = await axios_default.get(
"https://unpkg.com/opencommit/package.json"
);
return data.version;
const { stdout } = await execa("npm", ["view", "opencommit", "version"]);
return stdout;
} catch (_6) {
ce("Error while getting the latest version of opencommit");
return void 0;
+933 -11
View File
@@ -8819,7 +8819,7 @@ var require_utils5 = __commonJS({
function isFunction2(val) {
return toString3.call(val) === "[object Function]";
}
function isStream2(val) {
function isStream3(val) {
return isObject2(val) && isFunction2(val.pipe);
}
function isURLSearchParams2(val) {
@@ -8902,7 +8902,7 @@ var require_utils5 = __commonJS({
isFile: isFile2,
isBlob: isBlob2,
isFunction: isFunction2,
isStream: isStream2,
isStream: isStream3,
isURLSearchParams: isURLSearchParams2,
isStandardBrowserEnv,
forEach: forEach2,
@@ -12971,8 +12971,8 @@ var require_combined_stream = __commonJS({
this._pipeNext(stream4);
return;
}
var getStream = stream4;
getStream(function(stream5) {
var getStream2 = stream4;
getStream2(function(stream5) {
var isStreamLike = CombinedStream.isStreamLike(stream5);
if (isStreamLike) {
stream5.on("data", this._checkDataSize.bind(this));
@@ -23039,6 +23039,833 @@ var require_tiktoken = __commonJS({
}
});
// node_modules/isexe/windows.js
var require_windows = __commonJS({
"node_modules/isexe/windows.js"(exports, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs = require("fs");
function checkPathExt(path, 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 i2 = 0; i2 < pathext.length; i2++) {
var p2 = pathext[i2].toLowerCase();
if (p2 && path.substr(-p2.length).toLowerCase() === p2) {
return true;
}
}
return false;
}
function checkStat(stat, path, options) {
if (!stat.isSymbolicLink() && !stat.isFile()) {
return false;
}
return checkPathExt(path, options);
}
function isexe(path, options, cb) {
fs.stat(path, function(er, stat) {
cb(er, er ? false : checkStat(stat, path, options));
});
}
function sync(path, options) {
return checkStat(fs.statSync(path), path, options);
}
}
});
// node_modules/isexe/mode.js
var require_mode = __commonJS({
"node_modules/isexe/mode.js"(exports, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs = require("fs");
function isexe(path, options, cb) {
fs.stat(path, function(er, stat) {
cb(er, er ? false : checkStat(stat, options));
});
}
function sync(path, options) {
return checkStat(fs.statSync(path), 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 u2 = parseInt("100", 8);
var g = parseInt("010", 8);
var o2 = parseInt("001", 8);
var ug = u2 | g;
var ret = mod & o2 || mod & g && gid === myGid || mod & u2 && uid === myUid || mod & ug && myUid === 0;
return ret;
}
}
});
// node_modules/isexe/index.js
var require_isexe = __commonJS({
"node_modules/isexe/index.js"(exports, module2) {
var fs = require("fs");
var core2;
if (process.platform === "win32" || global.TESTING_WINDOWS) {
core2 = require_windows();
} else {
core2 = require_mode();
}
module2.exports = isexe;
isexe.sync = sync;
function isexe(path, 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(path, options || {}, function(er, is) {
if (er) {
reject(er);
} else {
resolve(is);
}
});
});
}
core2(path, options || {}, function(er, is) {
if (er) {
if (er.code === "EACCES" || options && options.ignoreErrors) {
er = null;
is = false;
}
}
cb(er, is);
});
}
function sync(path, options) {
try {
return core2.sync(path, options || {});
} catch (er) {
if (options && options.ignoreErrors || er.code === "EACCES") {
return false;
} else {
throw er;
}
}
}
}
});
// node_modules/which/which.js
var require_which = __commonJS({
"node_modules/which/which.js"(exports, module2) {
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
var path = 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(/\\/) ? [""] : [
...isWindows ? [process.cwd()] : [],
...(opt.path || process.env.PATH || "").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 = (i2) => new Promise((resolve, reject) => {
if (i2 === pathEnv.length)
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
const ppRaw = pathEnv[i2];
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
const pCmd = path.join(pathPart, cmd);
const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
resolve(subStep(p2, i2, 0));
});
const subStep = (p2, i2, ii) => new Promise((resolve, reject) => {
if (ii === pathExt.length)
return resolve(step(i2 + 1));
const ext = pathExt[ii];
isexe(p2 + ext, { pathExt: pathExtExe }, (er, is) => {
if (!er && is) {
if (opt.all)
found.push(p2 + ext);
else
return resolve(p2 + ext);
}
return resolve(subStep(p2, i2, 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 i2 = 0; i2 < pathEnv.length; i2++) {
const ppRaw = pathEnv[i2];
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
const pCmd = path.join(pathPart, cmd);
const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
for (let j2 = 0; j2 < pathExt.length; j2++) {
const cur = p2 + pathExt[j2];
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);
};
module2.exports = which;
which.sync = whichSync;
}
});
// node_modules/path-key/index.js
var require_path_key = __commonJS({
"node_modules/path-key/index.js"(exports, module2) {
"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";
};
module2.exports = pathKey2;
module2.exports.default = pathKey2;
}
});
// node_modules/cross-spawn/lib/util/resolveCommand.js
var require_resolveCommand = __commonJS({
"node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
"use strict";
var path = require("path");
var which = require_which();
var getPathKey = require_path_key();
function resolveCommandAttempt(parsed, withoutPathExt) {
const env2 = 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: env2[getPathKey({ env: env2 })],
pathExt: withoutPathExt ? path.delimiter : void 0
});
} catch (e2) {
} finally {
if (shouldSwitchCwd) {
process.chdir(cwd);
}
}
if (resolved) {
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
}
return resolved;
}
function resolveCommand(parsed) {
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
}
module2.exports = resolveCommand;
}
});
// node_modules/cross-spawn/lib/util/escape.js
var require_escape = __commonJS({
"node_modules/cross-spawn/lib/util/escape.js"(exports, module2) {
"use strict";
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
function escapeCommand(arg) {
arg = arg.replace(metaCharsRegExp, "^$1");
return arg;
}
function escapeArgument(arg, doubleEscapeMetaChars) {
arg = `${arg}`;
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
arg = arg.replace(/(\\*)$/, "$1$1");
arg = `"${arg}"`;
arg = arg.replace(metaCharsRegExp, "^$1");
if (doubleEscapeMetaChars) {
arg = arg.replace(metaCharsRegExp, "^$1");
}
return arg;
}
module2.exports.command = escapeCommand;
module2.exports.argument = escapeArgument;
}
});
// node_modules/shebang-regex/index.js
var require_shebang_regex = __commonJS({
"node_modules/shebang-regex/index.js"(exports, module2) {
"use strict";
module2.exports = /^#!(.*)/;
}
});
// node_modules/shebang-command/index.js
var require_shebang_command = __commonJS({
"node_modules/shebang-command/index.js"(exports, module2) {
"use strict";
var shebangRegex = require_shebang_regex();
module2.exports = (string = "") => {
const match = string.match(shebangRegex);
if (!match) {
return null;
}
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
const binary = path.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, module2) {
"use strict";
var fs = require("fs");
var shebangCommand = require_shebang_command();
function readShebang(command2) {
const size = 150;
const buffer = Buffer.alloc(size);
let fd;
try {
fd = fs.openSync(command2, "r");
fs.readSync(fd, buffer, 0, size, 0);
fs.closeSync(fd);
} catch (e2) {
}
return shebangCommand(buffer.toString());
}
module2.exports = readShebang;
}
});
// node_modules/cross-spawn/lib/parse.js
var require_parse2 = __commonJS({
"node_modules/cross-spawn/lib/parse.js"(exports, module2) {
"use strict";
var path = 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 = path.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(command2, args, options) {
if (args && !Array.isArray(args)) {
options = args;
args = null;
}
args = args ? args.slice(0) : [];
options = Object.assign({}, options);
const parsed = {
command: command2,
args,
options,
file: void 0,
original: {
command: command2,
args
}
};
return options.shell ? parsed : parseNonShell(parsed);
}
module2.exports = parse;
}
});
// node_modules/cross-spawn/lib/enoent.js
var require_enoent = __commonJS({
"node_modules/cross-spawn/lib/enoent.js"(exports, module2) {
"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, "spawn");
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;
}
module2.exports = {
hookChildProcess,
verifyENOENT,
verifyENOENTSync,
notFoundError
};
}
});
// node_modules/cross-spawn/index.js
var require_cross_spawn = __commonJS({
"node_modules/cross-spawn/index.js"(exports, module2) {
"use strict";
var cp = require("child_process");
var parse = require_parse2();
var enoent = require_enoent();
function spawn(command2, args, options) {
const parsed = parse(command2, args, options);
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
enoent.hookChildProcess(spawned, parsed);
return spawned;
}
function spawnSync(command2, args, options) {
const parsed = parse(command2, args, options);
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
return result;
}
module2.exports = spawn;
module2.exports.spawn = spawn;
module2.exports.sync = spawnSync;
module2.exports._parse = parse;
module2.exports._enoent = enoent;
}
});
// node_modules/signal-exit/signals.js
var require_signals = __commonJS({
"node_modules/signal-exit/signals.js"(exports, module2) {
module2.exports = [
"SIGABRT",
"SIGALRM",
"SIGHUP",
"SIGINT",
"SIGTERM"
];
if (process.platform !== "win32") {
module2.exports.push(
"SIGVTALRM",
"SIGXCPU",
"SIGXFSZ",
"SIGUSR2",
"SIGTRAP",
"SIGSYS",
"SIGQUIT",
"SIGIOT"
);
}
if (process.platform === "linux") {
module2.exports.push(
"SIGIO",
"SIGPOLL",
"SIGPWR",
"SIGSTKFLT",
"SIGUNUSED"
);
}
}
});
// node_modules/signal-exit/index.js
var require_signal_exit = __commonJS({
"node_modules/signal-exit/index.js"(exports, module2) {
var process3 = global.process;
var processOk = function(process4) {
return process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
};
if (!processOk(process3)) {
module2.exports = function() {
return function() {
};
};
} else {
assert = require("assert");
signals = require_signals();
isWin = /^win/i.test(process3.platform);
EE = require("events");
if (typeof EE !== "function") {
EE = EE.EventEmitter;
}
if (process3.__signal_exit_emitter__) {
emitter = process3.__signal_exit_emitter__;
} else {
emitter = process3.__signal_exit_emitter__ = new EE();
emitter.count = 0;
emitter.emitted = {};
}
if (!emitter.infinite) {
emitter.setMaxListeners(Infinity);
emitter.infinite = true;
}
module2.exports = function(cb, opts) {
if (!processOk(global.process)) {
return function() {
};
}
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
if (loaded === false) {
load();
}
var ev = "exit";
if (opts && opts.alwaysLast) {
ev = "afterexit";
}
var remove = function() {
emitter.removeListener(ev, cb);
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
unload();
}
};
emitter.on(ev, cb);
return remove;
};
unload = function unload2() {
if (!loaded || !processOk(global.process)) {
return;
}
loaded = false;
signals.forEach(function(sig) {
try {
process3.removeListener(sig, sigListeners[sig]);
} catch (er) {
}
});
process3.emit = originalProcessEmit;
process3.reallyExit = originalProcessReallyExit;
emitter.count -= 1;
};
module2.exports.unload = unload;
emit = function emit2(event, code, signal) {
if (emitter.emitted[event]) {
return;
}
emitter.emitted[event] = true;
emitter.emit(event, code, signal);
};
sigListeners = {};
signals.forEach(function(sig) {
sigListeners[sig] = function listener() {
if (!processOk(global.process)) {
return;
}
var listeners = process3.listeners(sig);
if (listeners.length === emitter.count) {
unload();
emit("exit", null, sig);
emit("afterexit", null, sig);
if (isWin && sig === "SIGHUP") {
sig = "SIGINT";
}
process3.kill(process3.pid, sig);
}
};
});
module2.exports.signals = function() {
return signals;
};
loaded = false;
load = function load2() {
if (loaded || !processOk(global.process)) {
return;
}
loaded = true;
emitter.count += 1;
signals = signals.filter(function(sig) {
try {
process3.on(sig, sigListeners[sig]);
return true;
} catch (er) {
return false;
}
});
process3.emit = processEmit;
process3.reallyExit = processReallyExit;
};
module2.exports.load = load;
originalProcessReallyExit = process3.reallyExit;
processReallyExit = function processReallyExit2(code) {
if (!processOk(global.process)) {
return;
}
process3.exitCode = code || 0;
emit("exit", process3.exitCode, null);
emit("afterexit", process3.exitCode, null);
originalProcessReallyExit.call(process3, process3.exitCode);
};
originalProcessEmit = process3.emit;
processEmit = function processEmit2(ev, arg) {
if (ev === "exit" && processOk(global.process)) {
if (arg !== void 0) {
process3.exitCode = arg;
}
var ret = originalProcessEmit.apply(this, arguments);
emit("exit", process3.exitCode, null);
emit("afterexit", process3.exitCode, null);
return ret;
} else {
return originalProcessEmit.apply(this, arguments);
}
};
}
var assert;
var signals;
var isWin;
var EE;
var emitter;
var unload;
var emit;
var sigListeners;
var loaded;
var load;
var originalProcessReallyExit;
var processReallyExit;
var originalProcessEmit;
var processEmit;
}
});
// node_modules/get-stream/buffer-stream.js
var require_buffer_stream = __commonJS({
"node_modules/get-stream/buffer-stream.js"(exports, module2) {
"use strict";
var { PassThrough: PassThroughStream } = require("stream");
module2.exports = (options) => {
options = { ...options };
const { array } = options;
let { encoding } = options;
const isBuffer2 = encoding === "buffer";
let objectMode = false;
if (array) {
objectMode = !(encoding || isBuffer2);
} else {
encoding = encoding || "utf8";
}
if (isBuffer2) {
encoding = null;
}
const stream4 = new PassThroughStream({ objectMode });
if (encoding) {
stream4.setEncoding(encoding);
}
let length = 0;
const chunks = [];
stream4.on("data", (chunk) => {
chunks.push(chunk);
if (objectMode) {
length = chunks.length;
} else {
length += chunk.length;
}
});
stream4.getBufferedValue = () => {
if (array) {
return chunks;
}
return isBuffer2 ? Buffer.concat(chunks, length) : chunks.join("");
};
stream4.getBufferedLength = () => length;
return stream4;
};
}
});
// node_modules/get-stream/index.js
var require_get_stream = __commonJS({
"node_modules/get-stream/index.js"(exports, module2) {
"use strict";
var { constants: BufferConstants } = require("buffer");
var stream4 = require("stream");
var { promisify } = require("util");
var bufferStream = require_buffer_stream();
var streamPipelinePromisified = promisify(stream4.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 stream5 = bufferStream(options);
await new Promise((resolve, reject) => {
const rejectPromise = (error) => {
if (error && stream5.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
error.bufferedData = stream5.getBufferedValue();
}
reject(error);
};
(async () => {
try {
await streamPipelinePromisified(inputStream, stream5);
resolve();
} catch (error) {
rejectPromise(error);
}
})();
stream5.on("data", () => {
if (stream5.getBufferedLength() > maxBuffer) {
rejectPromise(new MaxBufferError());
}
});
});
return stream5.getBufferedValue();
}
module2.exports = getStream2;
module2.exports.buffer = (stream5, options) => getStream2(stream5, { ...options, encoding: "buffer" });
module2.exports.array = (stream5, options) => getStream2(stream5, { ...options, array: true });
module2.exports.MaxBufferError = MaxBufferError;
}
});
// node_modules/merge-stream/index.js
var require_merge_stream = __commonJS({
"node_modules/merge-stream/index.js"(exports, module2) {
"use strict";
var { PassThrough } = require("stream");
module2.exports = function() {
var sources = [];
var output = new PassThrough({ 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();
}
}
};
}
});
// src/github-action.ts
var import_core3 = __toESM(require_core(), 1);
var import_github = __toESM(require_github(), 1);
@@ -23310,8 +24137,8 @@ var stripBOM = (content) => {
}
return content;
};
var inherits = (constructor, superConstructor, props, descriptors2) => {
constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
var inherits = (constructor, superConstructor, props, descriptors3) => {
constructor.prototype = Object.create(superConstructor.prototype, descriptors3);
constructor.prototype.constructor = constructor;
Object.defineProperty(constructor, "super", {
value: superConstructor.prototype
@@ -23397,9 +24224,9 @@ var toCamelCase = (str) => {
var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
var isRegExp = kindOfTest("RegExp");
var reduceDescriptors = (obj, reducer) => {
const descriptors2 = Object.getOwnPropertyDescriptors(obj);
const descriptors3 = Object.getOwnPropertyDescriptors(obj);
const reducedDescriptors = {};
forEach(descriptors2, (descriptor, name) => {
forEach(descriptors3, (descriptor, name) => {
if (reducer(descriptor, name, obj) !== false) {
reducedDescriptors[name] = descriptor;
}
@@ -26983,6 +27810,103 @@ function tokenCount(content) {
return tokens.length;
}
// node_modules/execa/index.js
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
// 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_);
};
// node_modules/execa/lib/kill.js
var import_signal_exit = __toESM(require_signal_exit(), 1);
var DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5;
// node_modules/execa/lib/stream.js
var import_get_stream = __toESM(require_get_stream(), 1);
var import_merge_stream = __toESM(require_merge_stream(), 1);
// node_modules/execa/lib/promise.js
var nativePromisePrototype = (async () => {
})().constructor.prototype;
var descriptors2 = ["then", "catch", "finally"].map((property) => [
property,
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
]);
// node_modules/execa/index.js
var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100;
// src/api.ts
var config2 = getConfig();
var maxTokens = config2?.OCO_OPENAI_MAX_TOKENS;
@@ -27020,9 +27944,7 @@ var OpenAi = class {
max_tokens: maxTokens || 500
};
try {
const REQUEST_TOKENS = messages.map(
(msg) => tokenCount(msg.content) + 4
).reduce((a2, b) => a2 + b, 0);
const REQUEST_TOKENS = messages.map((msg) => tokenCount(msg.content) + 4).reduce((a2, b) => a2 + b, 0);
if (REQUEST_TOKENS > DEFAULT_MODEL_TOKEN_LIMIT - maxTokens) {
throw new Error("TOO_MUCH_TOKENS" /* tooMuchTokens */);
}