@musistudio/claude-code-router 1.0.16 → 1.0.17
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/cli.js +533 -558
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -270,7 +270,7 @@ var require_queue = __commonJS({
|
|
|
270
270
|
queue.drained = drained;
|
|
271
271
|
return queue;
|
|
272
272
|
function push(value) {
|
|
273
|
-
var
|
|
273
|
+
var p = new Promise(function(resolve, reject) {
|
|
274
274
|
pushCb(value, function(err, result) {
|
|
275
275
|
if (err) {
|
|
276
276
|
reject(err);
|
|
@@ -279,11 +279,11 @@ var require_queue = __commonJS({
|
|
|
279
279
|
resolve(result);
|
|
280
280
|
});
|
|
281
281
|
});
|
|
282
|
-
|
|
283
|
-
return
|
|
282
|
+
p.catch(noop);
|
|
283
|
+
return p;
|
|
284
284
|
}
|
|
285
285
|
function unshift(value) {
|
|
286
|
-
var
|
|
286
|
+
var p = new Promise(function(resolve, reject) {
|
|
287
287
|
unshiftCb(value, function(err, result) {
|
|
288
288
|
if (err) {
|
|
289
289
|
reject(err);
|
|
@@ -292,11 +292,11 @@ var require_queue = __commonJS({
|
|
|
292
292
|
resolve(result);
|
|
293
293
|
});
|
|
294
294
|
});
|
|
295
|
-
|
|
296
|
-
return
|
|
295
|
+
p.catch(noop);
|
|
296
|
+
return p;
|
|
297
297
|
}
|
|
298
298
|
function drained() {
|
|
299
|
-
var
|
|
299
|
+
var p = new Promise(function(resolve) {
|
|
300
300
|
process.nextTick(function() {
|
|
301
301
|
if (queue.idle()) {
|
|
302
302
|
resolve();
|
|
@@ -310,7 +310,7 @@ var require_queue = __commonJS({
|
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
});
|
|
313
|
-
return
|
|
313
|
+
return p;
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
module2.exports = fastqueue;
|
|
@@ -918,8 +918,8 @@ var require_thenify = __commonJS({
|
|
|
918
918
|
}
|
|
919
919
|
debug("thenify");
|
|
920
920
|
return (resolve, reject) => {
|
|
921
|
-
const
|
|
922
|
-
return
|
|
921
|
+
const p = this._loadRegistered();
|
|
922
|
+
return p.then(() => {
|
|
923
923
|
this[kThenifyDoNotWrap] = true;
|
|
924
924
|
return resolve(this._server);
|
|
925
925
|
}, reject);
|
|
@@ -3644,11 +3644,11 @@ var require_parse = __commonJS({
|
|
|
3644
3644
|
const wildcards = [];
|
|
3645
3645
|
var wcLen = 0;
|
|
3646
3646
|
const secret = paths.reduce(function(o, strPath, ix) {
|
|
3647
|
-
var path3 = strPath.match(rx).map((
|
|
3647
|
+
var path3 = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
|
|
3648
3648
|
const leadingBracket = strPath[0] === "[";
|
|
3649
|
-
path3 = path3.map((
|
|
3650
|
-
if (
|
|
3651
|
-
else return
|
|
3649
|
+
path3 = path3.map((p) => {
|
|
3650
|
+
if (p[0] === "[") return p.substr(1, p.length - 2);
|
|
3651
|
+
else return p;
|
|
3652
3652
|
});
|
|
3653
3653
|
const star = path3.indexOf("*");
|
|
3654
3654
|
if (star > -1) {
|
|
@@ -3722,14 +3722,14 @@ var require_redactor = __commonJS({
|
|
|
3722
3722
|
const { index, input } = match;
|
|
3723
3723
|
if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1)));
|
|
3724
3724
|
}
|
|
3725
|
-
var existence = hops.map((
|
|
3725
|
+
var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
|
|
3726
3726
|
if (existence.length === 0) existence += `o${delim}${path3} != null`;
|
|
3727
3727
|
else existence += ` && o${delim}${path3} != null`;
|
|
3728
3728
|
const circularDetection = `
|
|
3729
3729
|
switch (true) {
|
|
3730
|
-
${hops.reverse().map((
|
|
3731
|
-
case o${delim}${
|
|
3732
|
-
secret[${escPath}].circle = ${JSON.stringify(
|
|
3730
|
+
${hops.reverse().map((p) => `
|
|
3731
|
+
case o${delim}${p} === censor:
|
|
3732
|
+
secret[${escPath}].circle = ${JSON.stringify(p)}
|
|
3733
3733
|
break
|
|
3734
3734
|
`).join("\n")}
|
|
3735
3735
|
}
|
|
@@ -3928,12 +3928,12 @@ var require_modifiers = __commonJS({
|
|
|
3928
3928
|
}
|
|
3929
3929
|
}
|
|
3930
3930
|
}
|
|
3931
|
-
function get(o,
|
|
3931
|
+
function get(o, p) {
|
|
3932
3932
|
var i = -1;
|
|
3933
|
-
var l =
|
|
3933
|
+
var l = p.length;
|
|
3934
3934
|
var n = o;
|
|
3935
3935
|
while (n != null && ++i < l) {
|
|
3936
|
-
n = n[
|
|
3936
|
+
n = n[p[i]];
|
|
3937
3937
|
}
|
|
3938
3938
|
return n;
|
|
3939
3939
|
}
|
|
@@ -4311,32 +4311,32 @@ var require_quick_format_unescaped = __commonJS({
|
|
|
4311
4311
|
}
|
|
4312
4312
|
}
|
|
4313
4313
|
module2.exports = format;
|
|
4314
|
-
function format(
|
|
4314
|
+
function format(f2, args, opts) {
|
|
4315
4315
|
var ss = opts && opts.stringify || tryStringify;
|
|
4316
4316
|
var offset = 1;
|
|
4317
|
-
if (typeof
|
|
4317
|
+
if (typeof f2 === "object" && f2 !== null) {
|
|
4318
4318
|
var len = args.length + offset;
|
|
4319
|
-
if (len === 1) return
|
|
4319
|
+
if (len === 1) return f2;
|
|
4320
4320
|
var objects = new Array(len);
|
|
4321
|
-
objects[0] = ss(
|
|
4321
|
+
objects[0] = ss(f2);
|
|
4322
4322
|
for (var index = 1; index < len; index++) {
|
|
4323
4323
|
objects[index] = ss(args[index]);
|
|
4324
4324
|
}
|
|
4325
4325
|
return objects.join(" ");
|
|
4326
4326
|
}
|
|
4327
|
-
if (typeof
|
|
4328
|
-
return
|
|
4327
|
+
if (typeof f2 !== "string") {
|
|
4328
|
+
return f2;
|
|
4329
4329
|
}
|
|
4330
4330
|
var argLen = args.length;
|
|
4331
|
-
if (argLen === 0) return
|
|
4331
|
+
if (argLen === 0) return f2;
|
|
4332
4332
|
var str = "";
|
|
4333
4333
|
var a = 1 - offset;
|
|
4334
4334
|
var lastPos = -1;
|
|
4335
|
-
var flen =
|
|
4335
|
+
var flen = f2 && f2.length || 0;
|
|
4336
4336
|
for (var i = 0; i < flen; ) {
|
|
4337
|
-
if (
|
|
4337
|
+
if (f2.charCodeAt(i) === 37 && i + 1 < flen) {
|
|
4338
4338
|
lastPos = lastPos > -1 ? lastPos : 0;
|
|
4339
|
-
switch (
|
|
4339
|
+
switch (f2.charCodeAt(i + 1)) {
|
|
4340
4340
|
case 100:
|
|
4341
4341
|
// 'd'
|
|
4342
4342
|
case 102:
|
|
@@ -4344,7 +4344,7 @@ var require_quick_format_unescaped = __commonJS({
|
|
|
4344
4344
|
break;
|
|
4345
4345
|
if (args[a] == null) break;
|
|
4346
4346
|
if (lastPos < i)
|
|
4347
|
-
str +=
|
|
4347
|
+
str += f2.slice(lastPos, i);
|
|
4348
4348
|
str += Number(args[a]);
|
|
4349
4349
|
lastPos = i + 2;
|
|
4350
4350
|
i++;
|
|
@@ -4354,7 +4354,7 @@ var require_quick_format_unescaped = __commonJS({
|
|
|
4354
4354
|
break;
|
|
4355
4355
|
if (args[a] == null) break;
|
|
4356
4356
|
if (lastPos < i)
|
|
4357
|
-
str +=
|
|
4357
|
+
str += f2.slice(lastPos, i);
|
|
4358
4358
|
str += Math.floor(Number(args[a]));
|
|
4359
4359
|
lastPos = i + 2;
|
|
4360
4360
|
i++;
|
|
@@ -4368,7 +4368,7 @@ var require_quick_format_unescaped = __commonJS({
|
|
|
4368
4368
|
break;
|
|
4369
4369
|
if (args[a] === void 0) break;
|
|
4370
4370
|
if (lastPos < i)
|
|
4371
|
-
str +=
|
|
4371
|
+
str += f2.slice(lastPos, i);
|
|
4372
4372
|
var type = typeof args[a];
|
|
4373
4373
|
if (type === "string") {
|
|
4374
4374
|
str += "'" + args[a] + "'";
|
|
@@ -4390,14 +4390,14 @@ var require_quick_format_unescaped = __commonJS({
|
|
|
4390
4390
|
if (a >= argLen)
|
|
4391
4391
|
break;
|
|
4392
4392
|
if (lastPos < i)
|
|
4393
|
-
str +=
|
|
4393
|
+
str += f2.slice(lastPos, i);
|
|
4394
4394
|
str += String(args[a]);
|
|
4395
4395
|
lastPos = i + 2;
|
|
4396
4396
|
i++;
|
|
4397
4397
|
break;
|
|
4398
4398
|
case 37:
|
|
4399
4399
|
if (lastPos < i)
|
|
4400
|
-
str +=
|
|
4400
|
+
str += f2.slice(lastPos, i);
|
|
4401
4401
|
str += "%";
|
|
4402
4402
|
lastPos = i + 2;
|
|
4403
4403
|
i++;
|
|
@@ -4409,9 +4409,9 @@ var require_quick_format_unescaped = __commonJS({
|
|
|
4409
4409
|
++i;
|
|
4410
4410
|
}
|
|
4411
4411
|
if (lastPos === -1)
|
|
4412
|
-
return
|
|
4412
|
+
return f2;
|
|
4413
4413
|
else if (lastPos < flen) {
|
|
4414
|
-
str +=
|
|
4414
|
+
str += f2.slice(lastPos);
|
|
4415
4415
|
}
|
|
4416
4416
|
return str;
|
|
4417
4417
|
}
|
|
@@ -5263,7 +5263,7 @@ var require_thread_stream = __commonJS({
|
|
|
5263
5263
|
var { version: version2 } = require_package();
|
|
5264
5264
|
var { EventEmitter } = require("events");
|
|
5265
5265
|
var { Worker } = require("worker_threads");
|
|
5266
|
-
var { join:
|
|
5266
|
+
var { join: join4 } = require("path");
|
|
5267
5267
|
var { pathToFileURL } = require("url");
|
|
5268
5268
|
var { wait } = require_wait();
|
|
5269
5269
|
var {
|
|
@@ -5299,7 +5299,7 @@ var require_thread_stream = __commonJS({
|
|
|
5299
5299
|
function createWorker(stream, opts) {
|
|
5300
5300
|
const { filename, workerData } = opts;
|
|
5301
5301
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
5302
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
5302
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join4(__dirname, "lib", "worker.js");
|
|
5303
5303
|
const worker = new Worker(toExecute, {
|
|
5304
5304
|
...opts.workerOpts,
|
|
5305
5305
|
trackUnmanagedFds: false,
|
|
@@ -5685,7 +5685,7 @@ var require_transport = __commonJS({
|
|
|
5685
5685
|
"use strict";
|
|
5686
5686
|
var { createRequire } = require("module");
|
|
5687
5687
|
var getCallers = require_caller();
|
|
5688
|
-
var { join:
|
|
5688
|
+
var { join: join4, isAbsolute, sep } = require("node:path");
|
|
5689
5689
|
var sleep = require_atomic_sleep();
|
|
5690
5690
|
var onExit = require_on_exit_leak_free();
|
|
5691
5691
|
var ThreadStream = require_thread_stream();
|
|
@@ -5748,7 +5748,7 @@ var require_transport = __commonJS({
|
|
|
5748
5748
|
throw new Error("only one of target or targets can be specified");
|
|
5749
5749
|
}
|
|
5750
5750
|
if (targets) {
|
|
5751
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
5751
|
+
target = bundlerOverrides["pino-worker"] || join4(__dirname, "worker.js");
|
|
5752
5752
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
5753
5753
|
return {
|
|
5754
5754
|
...dest,
|
|
@@ -5766,7 +5766,7 @@ var require_transport = __commonJS({
|
|
|
5766
5766
|
});
|
|
5767
5767
|
});
|
|
5768
5768
|
} else if (pipeline) {
|
|
5769
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
5769
|
+
target = bundlerOverrides["pino-worker"] || join4(__dirname, "worker.js");
|
|
5770
5770
|
options.pipelines = [pipeline.map((dest) => {
|
|
5771
5771
|
return {
|
|
5772
5772
|
...dest,
|
|
@@ -5788,7 +5788,7 @@ var require_transport = __commonJS({
|
|
|
5788
5788
|
return origin;
|
|
5789
5789
|
}
|
|
5790
5790
|
if (origin === "pino/file") {
|
|
5791
|
-
return
|
|
5791
|
+
return join4(__dirname, "..", "file.js");
|
|
5792
5792
|
}
|
|
5793
5793
|
let fixTarget2;
|
|
5794
5794
|
for (const filePath of callers) {
|
|
@@ -6739,7 +6739,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
6739
6739
|
return circularValue;
|
|
6740
6740
|
}
|
|
6741
6741
|
let res = "";
|
|
6742
|
-
let
|
|
6742
|
+
let join4 = ",";
|
|
6743
6743
|
const originalIndentation = indentation;
|
|
6744
6744
|
if (Array.isArray(value)) {
|
|
6745
6745
|
if (value.length === 0) {
|
|
@@ -6753,7 +6753,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
6753
6753
|
indentation += spacer;
|
|
6754
6754
|
res += `
|
|
6755
6755
|
${indentation}`;
|
|
6756
|
-
|
|
6756
|
+
join4 = `,
|
|
6757
6757
|
${indentation}`;
|
|
6758
6758
|
}
|
|
6759
6759
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -6761,13 +6761,13 @@ ${indentation}`;
|
|
|
6761
6761
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
6762
6762
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
6763
6763
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
6764
|
-
res +=
|
|
6764
|
+
res += join4;
|
|
6765
6765
|
}
|
|
6766
6766
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
6767
6767
|
res += tmp !== void 0 ? tmp : "null";
|
|
6768
6768
|
if (value.length - 1 > maximumBreadth) {
|
|
6769
6769
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
6770
|
-
res += `${
|
|
6770
|
+
res += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
6771
6771
|
}
|
|
6772
6772
|
if (spacer !== "") {
|
|
6773
6773
|
res += `
|
|
@@ -6788,7 +6788,7 @@ ${originalIndentation}`;
|
|
|
6788
6788
|
let separator = "";
|
|
6789
6789
|
if (spacer !== "") {
|
|
6790
6790
|
indentation += spacer;
|
|
6791
|
-
|
|
6791
|
+
join4 = `,
|
|
6792
6792
|
${indentation}`;
|
|
6793
6793
|
whitespace = " ";
|
|
6794
6794
|
}
|
|
@@ -6802,13 +6802,13 @@ ${indentation}`;
|
|
|
6802
6802
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
6803
6803
|
if (tmp !== void 0) {
|
|
6804
6804
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
6805
|
-
separator =
|
|
6805
|
+
separator = join4;
|
|
6806
6806
|
}
|
|
6807
6807
|
}
|
|
6808
6808
|
if (keyLength > maximumBreadth) {
|
|
6809
6809
|
const removedKeys = keyLength - maximumBreadth;
|
|
6810
6810
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
6811
|
-
separator =
|
|
6811
|
+
separator = join4;
|
|
6812
6812
|
}
|
|
6813
6813
|
if (spacer !== "" && separator.length > 1) {
|
|
6814
6814
|
res = `
|
|
@@ -6849,7 +6849,7 @@ ${originalIndentation}`;
|
|
|
6849
6849
|
}
|
|
6850
6850
|
const originalIndentation = indentation;
|
|
6851
6851
|
let res = "";
|
|
6852
|
-
let
|
|
6852
|
+
let join4 = ",";
|
|
6853
6853
|
if (Array.isArray(value)) {
|
|
6854
6854
|
if (value.length === 0) {
|
|
6855
6855
|
return "[]";
|
|
@@ -6862,7 +6862,7 @@ ${originalIndentation}`;
|
|
|
6862
6862
|
indentation += spacer;
|
|
6863
6863
|
res += `
|
|
6864
6864
|
${indentation}`;
|
|
6865
|
-
|
|
6865
|
+
join4 = `,
|
|
6866
6866
|
${indentation}`;
|
|
6867
6867
|
}
|
|
6868
6868
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -6870,13 +6870,13 @@ ${indentation}`;
|
|
|
6870
6870
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
6871
6871
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
6872
6872
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
6873
|
-
res +=
|
|
6873
|
+
res += join4;
|
|
6874
6874
|
}
|
|
6875
6875
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
6876
6876
|
res += tmp !== void 0 ? tmp : "null";
|
|
6877
6877
|
if (value.length - 1 > maximumBreadth) {
|
|
6878
6878
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
6879
|
-
res += `${
|
|
6879
|
+
res += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
6880
6880
|
}
|
|
6881
6881
|
if (spacer !== "") {
|
|
6882
6882
|
res += `
|
|
@@ -6889,7 +6889,7 @@ ${originalIndentation}`;
|
|
|
6889
6889
|
let whitespace = "";
|
|
6890
6890
|
if (spacer !== "") {
|
|
6891
6891
|
indentation += spacer;
|
|
6892
|
-
|
|
6892
|
+
join4 = `,
|
|
6893
6893
|
${indentation}`;
|
|
6894
6894
|
whitespace = " ";
|
|
6895
6895
|
}
|
|
@@ -6898,7 +6898,7 @@ ${indentation}`;
|
|
|
6898
6898
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
6899
6899
|
if (tmp !== void 0) {
|
|
6900
6900
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
6901
|
-
separator =
|
|
6901
|
+
separator = join4;
|
|
6902
6902
|
}
|
|
6903
6903
|
}
|
|
6904
6904
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -6956,20 +6956,20 @@ ${originalIndentation}`;
|
|
|
6956
6956
|
indentation += spacer;
|
|
6957
6957
|
let res2 = `
|
|
6958
6958
|
${indentation}`;
|
|
6959
|
-
const
|
|
6959
|
+
const join5 = `,
|
|
6960
6960
|
${indentation}`;
|
|
6961
6961
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
6962
6962
|
let i = 0;
|
|
6963
6963
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
6964
6964
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
6965
6965
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
6966
|
-
res2 +=
|
|
6966
|
+
res2 += join5;
|
|
6967
6967
|
}
|
|
6968
6968
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
6969
6969
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
6970
6970
|
if (value.length - 1 > maximumBreadth) {
|
|
6971
6971
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
6972
|
-
res2 += `${
|
|
6972
|
+
res2 += `${join5}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
6973
6973
|
}
|
|
6974
6974
|
res2 += `
|
|
6975
6975
|
${originalIndentation}`;
|
|
@@ -6985,16 +6985,16 @@ ${originalIndentation}`;
|
|
|
6985
6985
|
return '"[Object]"';
|
|
6986
6986
|
}
|
|
6987
6987
|
indentation += spacer;
|
|
6988
|
-
const
|
|
6988
|
+
const join4 = `,
|
|
6989
6989
|
${indentation}`;
|
|
6990
6990
|
let res = "";
|
|
6991
6991
|
let separator = "";
|
|
6992
6992
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
6993
6993
|
if (isTypedArrayWithEntries(value)) {
|
|
6994
|
-
res += stringifyTypedArray(value,
|
|
6994
|
+
res += stringifyTypedArray(value, join4, maximumBreadth);
|
|
6995
6995
|
keys = keys.slice(value.length);
|
|
6996
6996
|
maximumPropertiesToStringify -= value.length;
|
|
6997
|
-
separator =
|
|
6997
|
+
separator = join4;
|
|
6998
6998
|
}
|
|
6999
6999
|
if (deterministic) {
|
|
7000
7000
|
keys = sort(keys, comparator);
|
|
@@ -7005,13 +7005,13 @@ ${indentation}`;
|
|
|
7005
7005
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
7006
7006
|
if (tmp !== void 0) {
|
|
7007
7007
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
7008
|
-
separator =
|
|
7008
|
+
separator = join4;
|
|
7009
7009
|
}
|
|
7010
7010
|
}
|
|
7011
7011
|
if (keyLength > maximumBreadth) {
|
|
7012
7012
|
const removedKeys = keyLength - maximumBreadth;
|
|
7013
7013
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
7014
|
-
separator =
|
|
7014
|
+
separator = join4;
|
|
7015
7015
|
}
|
|
7016
7016
|
if (separator !== "") {
|
|
7017
7017
|
res = `
|
|
@@ -13188,12 +13188,12 @@ var require_util = __commonJS({
|
|
|
13188
13188
|
return str.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
13189
13189
|
}
|
|
13190
13190
|
exports2.unescapeJsonPointer = unescapeJsonPointer;
|
|
13191
|
-
function eachItem(xs,
|
|
13191
|
+
function eachItem(xs, f2) {
|
|
13192
13192
|
if (Array.isArray(xs)) {
|
|
13193
13193
|
for (const x of xs)
|
|
13194
|
-
|
|
13194
|
+
f2(x);
|
|
13195
13195
|
} else {
|
|
13196
|
-
|
|
13196
|
+
f2(xs);
|
|
13197
13197
|
}
|
|
13198
13198
|
}
|
|
13199
13199
|
exports2.eachItem = eachItem;
|
|
@@ -13236,14 +13236,14 @@ var require_util = __commonJS({
|
|
|
13236
13236
|
}
|
|
13237
13237
|
exports2.evaluatedPropsToName = evaluatedPropsToName;
|
|
13238
13238
|
function setEvaluated(gen, props, ps) {
|
|
13239
|
-
Object.keys(ps).forEach((
|
|
13239
|
+
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1._)`${props}${(0, codegen_1.getProperty)(p)}`, true));
|
|
13240
13240
|
}
|
|
13241
13241
|
exports2.setEvaluated = setEvaluated;
|
|
13242
13242
|
var snippets = {};
|
|
13243
|
-
function useFunc(gen,
|
|
13243
|
+
function useFunc(gen, f2) {
|
|
13244
13244
|
return gen.scopeValue("func", {
|
|
13245
|
-
ref:
|
|
13246
|
-
code: snippets[
|
|
13245
|
+
ref: f2,
|
|
13246
|
+
code: snippets[f2.code] || (snippets[f2.code] = new code_1._Code(f2.code))
|
|
13247
13247
|
});
|
|
13248
13248
|
}
|
|
13249
13249
|
exports2.useFunc = useFunc;
|
|
@@ -13809,11 +13809,11 @@ var require_code2 = __commonJS({
|
|
|
13809
13809
|
}
|
|
13810
13810
|
exports2.noPropertyInData = noPropertyInData;
|
|
13811
13811
|
function allSchemaProperties(schemaMap) {
|
|
13812
|
-
return schemaMap ? Object.keys(schemaMap).filter((
|
|
13812
|
+
return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
|
|
13813
13813
|
}
|
|
13814
13814
|
exports2.allSchemaProperties = allSchemaProperties;
|
|
13815
13815
|
function schemaProperties(it, schemaMap) {
|
|
13816
|
-
return allSchemaProperties(schemaMap).filter((
|
|
13816
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p]));
|
|
13817
13817
|
}
|
|
13818
13818
|
exports2.schemaProperties = schemaProperties;
|
|
13819
13819
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
@@ -14291,12 +14291,12 @@ var require_resolve = __commonJS({
|
|
|
14291
14291
|
function getFullPath(resolver, id2 = "", normalize) {
|
|
14292
14292
|
if (normalize !== false)
|
|
14293
14293
|
id2 = normalizeId(id2);
|
|
14294
|
-
const
|
|
14295
|
-
return _getFullPath(resolver,
|
|
14294
|
+
const p = resolver.parse(id2);
|
|
14295
|
+
return _getFullPath(resolver, p);
|
|
14296
14296
|
}
|
|
14297
14297
|
exports2.getFullPath = getFullPath;
|
|
14298
|
-
function _getFullPath(resolver,
|
|
14299
|
-
const serialized = resolver.serialize(
|
|
14298
|
+
function _getFullPath(resolver, p) {
|
|
14299
|
+
const serialized = resolver.serialize(p);
|
|
14300
14300
|
return serialized.split("#")[0] + "#";
|
|
14301
14301
|
}
|
|
14302
14302
|
exports2._getFullPath = _getFullPath;
|
|
@@ -15071,11 +15071,11 @@ var require_compile = __commonJS({
|
|
|
15071
15071
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
15072
15072
|
}
|
|
15073
15073
|
function resolveSchema(root, ref) {
|
|
15074
|
-
const
|
|
15075
|
-
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver,
|
|
15074
|
+
const p = this.opts.uriResolver.parse(ref);
|
|
15075
|
+
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p);
|
|
15076
15076
|
let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root.baseId, void 0);
|
|
15077
15077
|
if (Object.keys(root.schema).length > 0 && refPath === baseId) {
|
|
15078
|
-
return getJsonPointer.call(this,
|
|
15078
|
+
return getJsonPointer.call(this, p, root);
|
|
15079
15079
|
}
|
|
15080
15080
|
const id2 = (0, resolve_1.normalizeId)(refPath);
|
|
15081
15081
|
const schOrRef = this.refs[id2] || this.schemas[id2];
|
|
@@ -15083,7 +15083,7 @@ var require_compile = __commonJS({
|
|
|
15083
15083
|
const sch = resolveSchema.call(this, root, schOrRef);
|
|
15084
15084
|
if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
|
|
15085
15085
|
return;
|
|
15086
|
-
return getJsonPointer.call(this,
|
|
15086
|
+
return getJsonPointer.call(this, p, sch);
|
|
15087
15087
|
}
|
|
15088
15088
|
if (typeof (schOrRef === null || schOrRef === void 0 ? void 0 : schOrRef.schema) !== "object")
|
|
15089
15089
|
return;
|
|
@@ -15097,7 +15097,7 @@ var require_compile = __commonJS({
|
|
|
15097
15097
|
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
15098
15098
|
return new SchemaEnv({ schema, schemaId, root, baseId });
|
|
15099
15099
|
}
|
|
15100
|
-
return getJsonPointer.call(this,
|
|
15100
|
+
return getJsonPointer.call(this, p, schOrRef);
|
|
15101
15101
|
}
|
|
15102
15102
|
exports2.resolveSchema = resolveSchema;
|
|
15103
15103
|
var PREVENT_SCOPE_CHANGE = /* @__PURE__ */ new Set([
|
|
@@ -16048,9 +16048,9 @@ var require_core = __commonJS({
|
|
|
16048
16048
|
this.addSchema(_schema, ref, meta);
|
|
16049
16049
|
}
|
|
16050
16050
|
async function _loadSchema(ref) {
|
|
16051
|
-
const
|
|
16052
|
-
if (
|
|
16053
|
-
return
|
|
16051
|
+
const p = this._loading[ref];
|
|
16052
|
+
if (p)
|
|
16053
|
+
return p;
|
|
16054
16054
|
try {
|
|
16055
16055
|
return await (this._loading[ref] = loadSchema(ref));
|
|
16056
16056
|
} finally {
|
|
@@ -17523,12 +17523,12 @@ var require_additionalProperties = __commonJS({
|
|
|
17523
17523
|
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
|
|
17524
17524
|
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key);
|
|
17525
17525
|
} else if (props.length) {
|
|
17526
|
-
definedProp = (0, codegen_1.or)(...props.map((
|
|
17526
|
+
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key} === ${p}`));
|
|
17527
17527
|
} else {
|
|
17528
17528
|
definedProp = codegen_1.nil;
|
|
17529
17529
|
}
|
|
17530
17530
|
if (patProps.length) {
|
|
17531
|
-
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((
|
|
17531
|
+
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key})`));
|
|
17532
17532
|
}
|
|
17533
17533
|
return (0, codegen_1.not)(definedProp);
|
|
17534
17534
|
}
|
|
@@ -17608,7 +17608,7 @@ var require_properties = __commonJS({
|
|
|
17608
17608
|
if (it.opts.unevaluated && allProps.length && it.props !== true) {
|
|
17609
17609
|
it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props);
|
|
17610
17610
|
}
|
|
17611
|
-
const properties = allProps.filter((
|
|
17611
|
+
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
|
|
17612
17612
|
if (properties.length === 0)
|
|
17613
17613
|
return;
|
|
17614
17614
|
const valid = gen.name("valid");
|
|
@@ -17658,7 +17658,7 @@ var require_patternProperties = __commonJS({
|
|
|
17658
17658
|
const { gen, schema, data, parentSchema, it } = cxt;
|
|
17659
17659
|
const { opts } = it;
|
|
17660
17660
|
const patterns = (0, code_1.allSchemaProperties)(schema);
|
|
17661
|
-
const alwaysValidPatterns = patterns.filter((
|
|
17661
|
+
const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
|
|
17662
17662
|
if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) {
|
|
17663
17663
|
return;
|
|
17664
17664
|
}
|
|
@@ -18774,17 +18774,17 @@ var require_dist2 = __commonJS({
|
|
|
18774
18774
|
};
|
|
18775
18775
|
formatsPlugin.get = (name, mode = "full") => {
|
|
18776
18776
|
const formats = mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats;
|
|
18777
|
-
const
|
|
18778
|
-
if (!
|
|
18777
|
+
const f2 = formats[name];
|
|
18778
|
+
if (!f2)
|
|
18779
18779
|
throw new Error(`Unknown format "${name}"`);
|
|
18780
|
-
return
|
|
18780
|
+
return f2;
|
|
18781
18781
|
};
|
|
18782
18782
|
function addFormats(ajv, list, fs3, exportName) {
|
|
18783
18783
|
var _a;
|
|
18784
18784
|
var _b;
|
|
18785
18785
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
18786
|
-
for (const
|
|
18787
|
-
ajv.addFormat(
|
|
18786
|
+
for (const f2 of list)
|
|
18787
|
+
ajv.addFormat(f2, fs3[f2]);
|
|
18788
18788
|
}
|
|
18789
18789
|
module2.exports = exports2 = formatsPlugin;
|
|
18790
18790
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -21778,8 +21778,8 @@ var require_properties2 = __commonJS({
|
|
|
21778
21778
|
const optProps = parentSchema.optionalProperties;
|
|
21779
21779
|
if (!(props && optProps))
|
|
21780
21780
|
return false;
|
|
21781
|
-
for (const
|
|
21782
|
-
if (Object.prototype.hasOwnProperty.call(optProps,
|
|
21781
|
+
for (const p in props) {
|
|
21782
|
+
if (Object.prototype.hasOwnProperty.call(optProps, p))
|
|
21783
21783
|
return true;
|
|
21784
21784
|
}
|
|
21785
21785
|
return false;
|
|
@@ -21787,10 +21787,10 @@ var require_properties2 = __commonJS({
|
|
|
21787
21787
|
function schemaProperties(keyword) {
|
|
21788
21788
|
const schema = parentSchema[keyword];
|
|
21789
21789
|
const allPs = schema ? (0, code_1.allSchemaProperties)(schema) : [];
|
|
21790
|
-
if (it.jtdDiscriminator && allPs.some((
|
|
21790
|
+
if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) {
|
|
21791
21791
|
throw new Error(`JTD: discriminator tag used in ${keyword}`);
|
|
21792
21792
|
}
|
|
21793
|
-
const ps = allPs.filter((
|
|
21793
|
+
const ps = allPs.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
|
|
21794
21794
|
return [allPs, ps];
|
|
21795
21795
|
}
|
|
21796
21796
|
function validateProps(props, keyword, required) {
|
|
@@ -21841,7 +21841,7 @@ var require_properties2 = __commonJS({
|
|
|
21841
21841
|
}
|
|
21842
21842
|
} else if (props.length || jtdDiscriminator !== void 0) {
|
|
21843
21843
|
const ps = jtdDiscriminator === void 0 ? props : [jtdDiscriminator].concat(props);
|
|
21844
|
-
additional = (0, codegen_1.and)(...ps.map((
|
|
21844
|
+
additional = (0, codegen_1.and)(...ps.map((p) => (0, codegen_1._)`${key} !== ${p}`));
|
|
21845
21845
|
} else {
|
|
21846
21846
|
additional = true;
|
|
21847
21847
|
}
|
|
@@ -22397,7 +22397,7 @@ var require_serialize = __commonJS({
|
|
|
22397
22397
|
serializeCode({ ...cxt, schema: propSchema, data: value });
|
|
22398
22398
|
}
|
|
22399
22399
|
function isAdditional(key, ps) {
|
|
22400
|
-
return ps.length ? (0, codegen_1.and)(...ps.map((
|
|
22400
|
+
return ps.length ? (0, codegen_1.and)(...ps.map((p) => (0, codegen_1._)`${key} !== ${p}`)) : true;
|
|
22401
22401
|
}
|
|
22402
22402
|
}
|
|
22403
22403
|
function serializeType(cxt) {
|
|
@@ -22839,7 +22839,7 @@ var require_parse2 = __commonJS({
|
|
|
22839
22839
|
});
|
|
22840
22840
|
if (properties) {
|
|
22841
22841
|
const hasProp = (0, code_1.hasPropFunc)(gen);
|
|
22842
|
-
const allProps = (0, codegen_1.and)(...Object.keys(properties).map((
|
|
22842
|
+
const allProps = (0, codegen_1.and)(...Object.keys(properties).map((p) => (0, codegen_1._)`${hasProp}.call(${data}, ${p})`));
|
|
22843
22843
|
gen.if((0, codegen_1.not)(allProps), () => parsingError(cxt, (0, codegen_1.str)`missing required properties`));
|
|
22844
22844
|
}
|
|
22845
22845
|
}
|
|
@@ -23504,7 +23504,7 @@ var require_re = __commonJS({
|
|
|
23504
23504
|
} = require_constants2();
|
|
23505
23505
|
var debug = require_debug2();
|
|
23506
23506
|
exports2 = module2.exports = {};
|
|
23507
|
-
var
|
|
23507
|
+
var re2 = exports2.re = [];
|
|
23508
23508
|
var safeRe = exports2.safeRe = [];
|
|
23509
23509
|
var src = exports2.src = [];
|
|
23510
23510
|
var safeSrc = exports2.safeSrc = [];
|
|
@@ -23529,7 +23529,7 @@ var require_re = __commonJS({
|
|
|
23529
23529
|
t[name] = index;
|
|
23530
23530
|
src[index] = value;
|
|
23531
23531
|
safeSrc[index] = safe;
|
|
23532
|
-
|
|
23532
|
+
re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
23533
23533
|
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
23534
23534
|
};
|
|
23535
23535
|
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
@@ -23628,7 +23628,7 @@ var require_semver = __commonJS({
|
|
|
23628
23628
|
"use strict";
|
|
23629
23629
|
var debug = require_debug2();
|
|
23630
23630
|
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants2();
|
|
23631
|
-
var { safeRe:
|
|
23631
|
+
var { safeRe: re2, t } = require_re();
|
|
23632
23632
|
var parseOptions = require_parse_options();
|
|
23633
23633
|
var { compareIdentifiers } = require_identifiers();
|
|
23634
23634
|
var SemVer = class _SemVer {
|
|
@@ -23652,7 +23652,7 @@ var require_semver = __commonJS({
|
|
|
23652
23652
|
this.options = options;
|
|
23653
23653
|
this.loose = !!options.loose;
|
|
23654
23654
|
this.includePrerelease = !!options.includePrerelease;
|
|
23655
|
-
const m = version2.trim().match(options.loose ?
|
|
23655
|
+
const m = version2.trim().match(options.loose ? re2[t.LOOSE] : re2[t.FULL]);
|
|
23656
23656
|
if (!m) {
|
|
23657
23657
|
throw new TypeError(`Invalid Version: ${version2}`);
|
|
23658
23658
|
}
|
|
@@ -23773,7 +23773,7 @@ var require_semver = __commonJS({
|
|
|
23773
23773
|
throw new Error("invalid increment argument: identifier is empty");
|
|
23774
23774
|
}
|
|
23775
23775
|
if (identifier) {
|
|
23776
|
-
const match = `-${identifier}`.match(this.options.loose ?
|
|
23776
|
+
const match = `-${identifier}`.match(this.options.loose ? re2[t.PRERELEASELOOSE] : re2[t.PRERELEASE]);
|
|
23777
23777
|
if (!match || match[1] !== identifier) {
|
|
23778
23778
|
throw new Error(`invalid identifier: ${identifier}`);
|
|
23779
23779
|
}
|
|
@@ -24222,7 +24222,7 @@ var require_coerce = __commonJS({
|
|
|
24222
24222
|
"use strict";
|
|
24223
24223
|
var SemVer = require_semver();
|
|
24224
24224
|
var parse = require_parse3();
|
|
24225
|
-
var { safeRe:
|
|
24225
|
+
var { safeRe: re2, t } = require_re();
|
|
24226
24226
|
var coerce = (version2, options) => {
|
|
24227
24227
|
if (version2 instanceof SemVer) {
|
|
24228
24228
|
return version2;
|
|
@@ -24236,9 +24236,9 @@ var require_coerce = __commonJS({
|
|
|
24236
24236
|
options = options || {};
|
|
24237
24237
|
let match = null;
|
|
24238
24238
|
if (!options.rtl) {
|
|
24239
|
-
match = version2.match(options.includePrerelease ?
|
|
24239
|
+
match = version2.match(options.includePrerelease ? re2[t.COERCEFULL] : re2[t.COERCE]);
|
|
24240
24240
|
} else {
|
|
24241
|
-
const coerceRtlRegex = options.includePrerelease ?
|
|
24241
|
+
const coerceRtlRegex = options.includePrerelease ? re2[t.COERCERTLFULL] : re2[t.COERCERTL];
|
|
24242
24242
|
let next;
|
|
24243
24243
|
while ((next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
|
|
24244
24244
|
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
@@ -24377,20 +24377,20 @@ var require_range = __commonJS({
|
|
|
24377
24377
|
return cached;
|
|
24378
24378
|
}
|
|
24379
24379
|
const loose = this.options.loose;
|
|
24380
|
-
const hr = loose ?
|
|
24380
|
+
const hr = loose ? re2[t.HYPHENRANGELOOSE] : re2[t.HYPHENRANGE];
|
|
24381
24381
|
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
24382
24382
|
debug("hyphen replace", range);
|
|
24383
|
-
range = range.replace(
|
|
24383
|
+
range = range.replace(re2[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
24384
24384
|
debug("comparator trim", range);
|
|
24385
|
-
range = range.replace(
|
|
24385
|
+
range = range.replace(re2[t.TILDETRIM], tildeTrimReplace);
|
|
24386
24386
|
debug("tilde trim", range);
|
|
24387
|
-
range = range.replace(
|
|
24387
|
+
range = range.replace(re2[t.CARETTRIM], caretTrimReplace);
|
|
24388
24388
|
debug("caret trim", range);
|
|
24389
24389
|
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
24390
24390
|
if (loose) {
|
|
24391
24391
|
rangeList = rangeList.filter((comp) => {
|
|
24392
24392
|
debug("loose invalid filter", comp, this.options);
|
|
24393
|
-
return !!comp.match(
|
|
24393
|
+
return !!comp.match(re2[t.COMPARATORLOOSE]);
|
|
24394
24394
|
});
|
|
24395
24395
|
}
|
|
24396
24396
|
debug("range list", rangeList);
|
|
@@ -24451,7 +24451,7 @@ var require_range = __commonJS({
|
|
|
24451
24451
|
var debug = require_debug2();
|
|
24452
24452
|
var SemVer = require_semver();
|
|
24453
24453
|
var {
|
|
24454
|
-
safeRe:
|
|
24454
|
+
safeRe: re2,
|
|
24455
24455
|
t,
|
|
24456
24456
|
comparatorTrimReplace,
|
|
24457
24457
|
tildeTrimReplace,
|
|
@@ -24489,21 +24489,21 @@ var require_range = __commonJS({
|
|
|
24489
24489
|
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
24490
24490
|
};
|
|
24491
24491
|
var replaceTilde = (comp, options) => {
|
|
24492
|
-
const r = options.loose ?
|
|
24493
|
-
return comp.replace(r, (_,
|
|
24494
|
-
debug("tilde", comp, _,
|
|
24492
|
+
const r = options.loose ? re2[t.TILDELOOSE] : re2[t.TILDE];
|
|
24493
|
+
return comp.replace(r, (_, M2, m, p, pr) => {
|
|
24494
|
+
debug("tilde", comp, _, M2, m, p, pr);
|
|
24495
24495
|
let ret;
|
|
24496
|
-
if (isX(
|
|
24496
|
+
if (isX(M2)) {
|
|
24497
24497
|
ret = "";
|
|
24498
24498
|
} else if (isX(m)) {
|
|
24499
|
-
ret = `>=${
|
|
24500
|
-
} else if (isX(
|
|
24501
|
-
ret = `>=${
|
|
24499
|
+
ret = `>=${M2}.0.0 <${+M2 + 1}.0.0-0`;
|
|
24500
|
+
} else if (isX(p)) {
|
|
24501
|
+
ret = `>=${M2}.${m}.0 <${M2}.${+m + 1}.0-0`;
|
|
24502
24502
|
} else if (pr) {
|
|
24503
24503
|
debug("replaceTilde pr", pr);
|
|
24504
|
-
ret = `>=${
|
|
24504
|
+
ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${+m + 1}.0-0`;
|
|
24505
24505
|
} else {
|
|
24506
|
-
ret = `>=${
|
|
24506
|
+
ret = `>=${M2}.${m}.${p} <${M2}.${+m + 1}.0-0`;
|
|
24507
24507
|
}
|
|
24508
24508
|
debug("tilde return", ret);
|
|
24509
24509
|
return ret;
|
|
@@ -24514,42 +24514,42 @@ var require_range = __commonJS({
|
|
|
24514
24514
|
};
|
|
24515
24515
|
var replaceCaret = (comp, options) => {
|
|
24516
24516
|
debug("caret", comp, options);
|
|
24517
|
-
const r = options.loose ?
|
|
24517
|
+
const r = options.loose ? re2[t.CARETLOOSE] : re2[t.CARET];
|
|
24518
24518
|
const z = options.includePrerelease ? "-0" : "";
|
|
24519
|
-
return comp.replace(r, (_,
|
|
24520
|
-
debug("caret", comp, _,
|
|
24519
|
+
return comp.replace(r, (_, M2, m, p, pr) => {
|
|
24520
|
+
debug("caret", comp, _, M2, m, p, pr);
|
|
24521
24521
|
let ret;
|
|
24522
|
-
if (isX(
|
|
24522
|
+
if (isX(M2)) {
|
|
24523
24523
|
ret = "";
|
|
24524
24524
|
} else if (isX(m)) {
|
|
24525
|
-
ret = `>=${
|
|
24526
|
-
} else if (isX(
|
|
24527
|
-
if (
|
|
24528
|
-
ret = `>=${
|
|
24525
|
+
ret = `>=${M2}.0.0${z} <${+M2 + 1}.0.0-0`;
|
|
24526
|
+
} else if (isX(p)) {
|
|
24527
|
+
if (M2 === "0") {
|
|
24528
|
+
ret = `>=${M2}.${m}.0${z} <${M2}.${+m + 1}.0-0`;
|
|
24529
24529
|
} else {
|
|
24530
|
-
ret = `>=${
|
|
24530
|
+
ret = `>=${M2}.${m}.0${z} <${+M2 + 1}.0.0-0`;
|
|
24531
24531
|
}
|
|
24532
24532
|
} else if (pr) {
|
|
24533
24533
|
debug("replaceCaret pr", pr);
|
|
24534
|
-
if (
|
|
24534
|
+
if (M2 === "0") {
|
|
24535
24535
|
if (m === "0") {
|
|
24536
|
-
ret = `>=${
|
|
24536
|
+
ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${m}.${+p + 1}-0`;
|
|
24537
24537
|
} else {
|
|
24538
|
-
ret = `>=${
|
|
24538
|
+
ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${+m + 1}.0-0`;
|
|
24539
24539
|
}
|
|
24540
24540
|
} else {
|
|
24541
|
-
ret = `>=${
|
|
24541
|
+
ret = `>=${M2}.${m}.${p}-${pr} <${+M2 + 1}.0.0-0`;
|
|
24542
24542
|
}
|
|
24543
24543
|
} else {
|
|
24544
24544
|
debug("no pr");
|
|
24545
|
-
if (
|
|
24545
|
+
if (M2 === "0") {
|
|
24546
24546
|
if (m === "0") {
|
|
24547
|
-
ret = `>=${
|
|
24547
|
+
ret = `>=${M2}.${m}.${p}${z} <${M2}.${m}.${+p + 1}-0`;
|
|
24548
24548
|
} else {
|
|
24549
|
-
ret = `>=${
|
|
24549
|
+
ret = `>=${M2}.${m}.${p}${z} <${M2}.${+m + 1}.0-0`;
|
|
24550
24550
|
}
|
|
24551
24551
|
} else {
|
|
24552
|
-
ret = `>=${
|
|
24552
|
+
ret = `>=${M2}.${m}.${p} <${+M2 + 1}.0.0-0`;
|
|
24553
24553
|
}
|
|
24554
24554
|
}
|
|
24555
24555
|
debug("caret return", ret);
|
|
@@ -24562,12 +24562,12 @@ var require_range = __commonJS({
|
|
|
24562
24562
|
};
|
|
24563
24563
|
var replaceXRange = (comp, options) => {
|
|
24564
24564
|
comp = comp.trim();
|
|
24565
|
-
const r = options.loose ?
|
|
24566
|
-
return comp.replace(r, (ret, gtlt,
|
|
24567
|
-
debug("xRange", comp, ret, gtlt,
|
|
24568
|
-
const xM = isX(
|
|
24565
|
+
const r = options.loose ? re2[t.XRANGELOOSE] : re2[t.XRANGE];
|
|
24566
|
+
return comp.replace(r, (ret, gtlt, M2, m, p, pr) => {
|
|
24567
|
+
debug("xRange", comp, ret, gtlt, M2, m, p, pr);
|
|
24568
|
+
const xM = isX(M2);
|
|
24569
24569
|
const xm = xM || isX(m);
|
|
24570
|
-
const xp = xm || isX(
|
|
24570
|
+
const xp = xm || isX(p);
|
|
24571
24571
|
const anyX = xp;
|
|
24572
24572
|
if (gtlt === "=" && anyX) {
|
|
24573
24573
|
gtlt = "";
|
|
@@ -24583,21 +24583,21 @@ var require_range = __commonJS({
|
|
|
24583
24583
|
if (xm) {
|
|
24584
24584
|
m = 0;
|
|
24585
24585
|
}
|
|
24586
|
-
|
|
24586
|
+
p = 0;
|
|
24587
24587
|
if (gtlt === ">") {
|
|
24588
24588
|
gtlt = ">=";
|
|
24589
24589
|
if (xm) {
|
|
24590
|
-
|
|
24590
|
+
M2 = +M2 + 1;
|
|
24591
24591
|
m = 0;
|
|
24592
|
-
|
|
24592
|
+
p = 0;
|
|
24593
24593
|
} else {
|
|
24594
24594
|
m = +m + 1;
|
|
24595
|
-
|
|
24595
|
+
p = 0;
|
|
24596
24596
|
}
|
|
24597
24597
|
} else if (gtlt === "<=") {
|
|
24598
24598
|
gtlt = "<";
|
|
24599
24599
|
if (xm) {
|
|
24600
|
-
|
|
24600
|
+
M2 = +M2 + 1;
|
|
24601
24601
|
} else {
|
|
24602
24602
|
m = +m + 1;
|
|
24603
24603
|
}
|
|
@@ -24605,11 +24605,11 @@ var require_range = __commonJS({
|
|
|
24605
24605
|
if (gtlt === "<") {
|
|
24606
24606
|
pr = "-0";
|
|
24607
24607
|
}
|
|
24608
|
-
ret = `${gtlt +
|
|
24608
|
+
ret = `${gtlt + M2}.${m}.${p}${pr}`;
|
|
24609
24609
|
} else if (xm) {
|
|
24610
|
-
ret = `>=${
|
|
24610
|
+
ret = `>=${M2}.0.0${pr} <${+M2 + 1}.0.0-0`;
|
|
24611
24611
|
} else if (xp) {
|
|
24612
|
-
ret = `>=${
|
|
24612
|
+
ret = `>=${M2}.${m}.0${pr} <${M2}.${+m + 1}.0-0`;
|
|
24613
24613
|
}
|
|
24614
24614
|
debug("xRange return", ret);
|
|
24615
24615
|
return ret;
|
|
@@ -24617,11 +24617,11 @@ var require_range = __commonJS({
|
|
|
24617
24617
|
};
|
|
24618
24618
|
var replaceStars = (comp, options) => {
|
|
24619
24619
|
debug("replaceStars", comp, options);
|
|
24620
|
-
return comp.trim().replace(
|
|
24620
|
+
return comp.trim().replace(re2[t.STAR], "");
|
|
24621
24621
|
};
|
|
24622
24622
|
var replaceGTE0 = (comp, options) => {
|
|
24623
24623
|
debug("replaceGTE0", comp, options);
|
|
24624
|
-
return comp.trim().replace(
|
|
24624
|
+
return comp.trim().replace(re2[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
24625
24625
|
};
|
|
24626
24626
|
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
24627
24627
|
if (isX(fM)) {
|
|
@@ -24707,7 +24707,7 @@ var require_comparator = __commonJS({
|
|
|
24707
24707
|
debug("comp", this);
|
|
24708
24708
|
}
|
|
24709
24709
|
parse(comp) {
|
|
24710
|
-
const r = this.options.loose ?
|
|
24710
|
+
const r = this.options.loose ? re2[t.COMPARATORLOOSE] : re2[t.COMPARATOR];
|
|
24711
24711
|
const m = comp.match(r);
|
|
24712
24712
|
if (!m) {
|
|
24713
24713
|
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
@@ -24781,7 +24781,7 @@ var require_comparator = __commonJS({
|
|
|
24781
24781
|
};
|
|
24782
24782
|
module2.exports = Comparator;
|
|
24783
24783
|
var parseOptions = require_parse_options();
|
|
24784
|
-
var { safeRe:
|
|
24784
|
+
var { safeRe: re2, t } = require_re();
|
|
24785
24785
|
var cmp = require_cmp();
|
|
24786
24786
|
var debug = require_debug2();
|
|
24787
24787
|
var SemVer = require_semver();
|
|
@@ -26387,7 +26387,7 @@ var require_types4 = __commonJS({
|
|
|
26387
26387
|
o[k2] = m[k];
|
|
26388
26388
|
});
|
|
26389
26389
|
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
26390
|
-
for (var
|
|
26390
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
26391
26391
|
};
|
|
26392
26392
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26393
26393
|
__exportStar(require_tokens(), exports2);
|
|
@@ -26498,13 +26498,13 @@ var require_util2 = __commonJS({
|
|
|
26498
26498
|
let tokens = [], rs, c;
|
|
26499
26499
|
const regexp = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;
|
|
26500
26500
|
while ((rs = regexp.exec(str)) !== null) {
|
|
26501
|
-
const
|
|
26501
|
+
const p = (_g = (_f = (_e = (_d = (_c = (_b = (_a = rs[1] && sets.words()) !== null && _a !== void 0 ? _a : rs[2] && sets.ints()) !== null && _b !== void 0 ? _b : rs[3] && sets.whitespace()) !== null && _c !== void 0 ? _c : rs[4] && sets.notWords()) !== null && _d !== void 0 ? _d : rs[5] && sets.notInts()) !== null && _e !== void 0 ? _e : rs[6] && sets.notWhitespace()) !== null && _f !== void 0 ? _f : rs[7] && {
|
|
26502
26502
|
type: types_1.types.RANGE,
|
|
26503
26503
|
from: (rs[8] || rs[9]).charCodeAt(0),
|
|
26504
26504
|
to: (c = rs[10]).charCodeAt(c.length - 1)
|
|
26505
26505
|
}) !== null && _g !== void 0 ? _g : (c = rs[16]) && { type: types_1.types.CHAR, value: c.charCodeAt(0) };
|
|
26506
|
-
if (
|
|
26507
|
-
tokens.push(
|
|
26506
|
+
if (p) {
|
|
26507
|
+
tokens.push(p);
|
|
26508
26508
|
} else {
|
|
26509
26509
|
return [tokens, regexp.lastIndex];
|
|
26510
26510
|
}
|
|
@@ -27037,7 +27037,7 @@ var require_dist3 = __commonJS({
|
|
|
27037
27037
|
o[k2] = m[k];
|
|
27038
27038
|
});
|
|
27039
27039
|
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
27040
|
-
for (var
|
|
27040
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
27041
27041
|
};
|
|
27042
27042
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
27043
27043
|
exports2.types = void 0;
|
|
@@ -27063,13 +27063,13 @@ var require_safe_regex2 = __commonJS({
|
|
|
27063
27063
|
"use strict";
|
|
27064
27064
|
var parse = require_dist3();
|
|
27065
27065
|
var types = parse.types;
|
|
27066
|
-
function safeRegex(
|
|
27066
|
+
function safeRegex(re2, opts) {
|
|
27067
27067
|
if (!opts) opts = {};
|
|
27068
27068
|
const replimit = opts.limit === void 0 ? 25 : opts.limit;
|
|
27069
|
-
if (isRegExp(
|
|
27070
|
-
else if (typeof
|
|
27069
|
+
if (isRegExp(re2)) re2 = re2.source;
|
|
27070
|
+
else if (typeof re2 !== "string") re2 = String(re2);
|
|
27071
27071
|
try {
|
|
27072
|
-
|
|
27072
|
+
re2 = parse(re2);
|
|
27073
27073
|
} catch {
|
|
27074
27074
|
return false;
|
|
27075
27075
|
}
|
|
@@ -27097,7 +27097,7 @@ var require_safe_regex2 = __commonJS({
|
|
|
27097
27097
|
if (!ok) return false;
|
|
27098
27098
|
}
|
|
27099
27099
|
return true;
|
|
27100
|
-
}(
|
|
27100
|
+
}(re2, 0);
|
|
27101
27101
|
}
|
|
27102
27102
|
function isRegExp(x) {
|
|
27103
27103
|
return {}.toString.call(x) === "[object RegExp]";
|
|
@@ -37452,8 +37452,8 @@ var require_webidl = __commonJS({
|
|
|
37452
37452
|
message: `"${context.value}" is an invalid ${context.type}.`
|
|
37453
37453
|
});
|
|
37454
37454
|
};
|
|
37455
|
-
webidl.brandCheck = function(V2,
|
|
37456
|
-
if (!FunctionPrototypeSymbolHasInstance(
|
|
37455
|
+
webidl.brandCheck = function(V2, I) {
|
|
37456
|
+
if (!FunctionPrototypeSymbolHasInstance(I, V2)) {
|
|
37457
37457
|
const err = new TypeError("Illegal invocation");
|
|
37458
37458
|
err.code = "ERR_INVALID_THIS";
|
|
37459
37459
|
throw err;
|
|
@@ -37483,8 +37483,8 @@ var require_webidl = __commonJS({
|
|
|
37483
37483
|
message: "Illegal constructor"
|
|
37484
37484
|
});
|
|
37485
37485
|
};
|
|
37486
|
-
webidl.util.MakeTypeAssertion = function(
|
|
37487
|
-
return (O) => FunctionPrototypeSymbolHasInstance(
|
|
37486
|
+
webidl.util.MakeTypeAssertion = function(I) {
|
|
37487
|
+
return (O) => FunctionPrototypeSymbolHasInstance(I, O);
|
|
37488
37488
|
};
|
|
37489
37489
|
webidl.util.Type = function(V2) {
|
|
37490
37490
|
switch (typeof V2) {
|
|
@@ -38306,11 +38306,11 @@ var require_util4 = __commonJS({
|
|
|
38306
38306
|
}
|
|
38307
38307
|
function tryUpgradeRequestToAPotentiallyTrustworthyURL(request) {
|
|
38308
38308
|
}
|
|
38309
|
-
function sameOrigin(A2,
|
|
38310
|
-
if (A2.origin ===
|
|
38309
|
+
function sameOrigin(A2, B2) {
|
|
38310
|
+
if (A2.origin === B2.origin && A2.origin === "null") {
|
|
38311
38311
|
return true;
|
|
38312
38312
|
}
|
|
38313
|
-
if (A2.protocol ===
|
|
38313
|
+
if (A2.protocol === B2.protocol && A2.hostname === B2.hostname && A2.port === B2.port) {
|
|
38314
38314
|
return true;
|
|
38315
38315
|
}
|
|
38316
38316
|
return false;
|
|
@@ -39607,7 +39607,7 @@ var require_client_h1 = __commonJS({
|
|
|
39607
39607
|
* @param {number} len
|
|
39608
39608
|
* @returns {number}
|
|
39609
39609
|
*/
|
|
39610
|
-
wasm_on_url: (
|
|
39610
|
+
wasm_on_url: (p, at, len) => {
|
|
39611
39611
|
return 0;
|
|
39612
39612
|
},
|
|
39613
39613
|
/**
|
|
@@ -39616,8 +39616,8 @@ var require_client_h1 = __commonJS({
|
|
|
39616
39616
|
* @param {number} len
|
|
39617
39617
|
* @returns {number}
|
|
39618
39618
|
*/
|
|
39619
|
-
wasm_on_status: (
|
|
39620
|
-
assert(currentParser.ptr ===
|
|
39619
|
+
wasm_on_status: (p, at, len) => {
|
|
39620
|
+
assert(currentParser.ptr === p);
|
|
39621
39621
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39622
39622
|
return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39623
39623
|
},
|
|
@@ -39625,8 +39625,8 @@ var require_client_h1 = __commonJS({
|
|
|
39625
39625
|
* @param {number} p
|
|
39626
39626
|
* @returns {number}
|
|
39627
39627
|
*/
|
|
39628
|
-
wasm_on_message_begin: (
|
|
39629
|
-
assert(currentParser.ptr ===
|
|
39628
|
+
wasm_on_message_begin: (p) => {
|
|
39629
|
+
assert(currentParser.ptr === p);
|
|
39630
39630
|
return currentParser.onMessageBegin();
|
|
39631
39631
|
},
|
|
39632
39632
|
/**
|
|
@@ -39635,8 +39635,8 @@ var require_client_h1 = __commonJS({
|
|
|
39635
39635
|
* @param {number} len
|
|
39636
39636
|
* @returns {number}
|
|
39637
39637
|
*/
|
|
39638
|
-
wasm_on_header_field: (
|
|
39639
|
-
assert(currentParser.ptr ===
|
|
39638
|
+
wasm_on_header_field: (p, at, len) => {
|
|
39639
|
+
assert(currentParser.ptr === p);
|
|
39640
39640
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39641
39641
|
return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39642
39642
|
},
|
|
@@ -39646,8 +39646,8 @@ var require_client_h1 = __commonJS({
|
|
|
39646
39646
|
* @param {number} len
|
|
39647
39647
|
* @returns {number}
|
|
39648
39648
|
*/
|
|
39649
|
-
wasm_on_header_value: (
|
|
39650
|
-
assert(currentParser.ptr ===
|
|
39649
|
+
wasm_on_header_value: (p, at, len) => {
|
|
39650
|
+
assert(currentParser.ptr === p);
|
|
39651
39651
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39652
39652
|
return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39653
39653
|
},
|
|
@@ -39658,8 +39658,8 @@ var require_client_h1 = __commonJS({
|
|
|
39658
39658
|
* @param {0|1} shouldKeepAlive
|
|
39659
39659
|
* @returns {number}
|
|
39660
39660
|
*/
|
|
39661
|
-
wasm_on_headers_complete: (
|
|
39662
|
-
assert(currentParser.ptr ===
|
|
39661
|
+
wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => {
|
|
39662
|
+
assert(currentParser.ptr === p);
|
|
39663
39663
|
return currentParser.onHeadersComplete(statusCode, upgrade === 1, shouldKeepAlive === 1);
|
|
39664
39664
|
},
|
|
39665
39665
|
/**
|
|
@@ -39668,8 +39668,8 @@ var require_client_h1 = __commonJS({
|
|
|
39668
39668
|
* @param {number} len
|
|
39669
39669
|
* @returns {number}
|
|
39670
39670
|
*/
|
|
39671
|
-
wasm_on_body: (
|
|
39672
|
-
assert(currentParser.ptr ===
|
|
39671
|
+
wasm_on_body: (p, at, len) => {
|
|
39672
|
+
assert(currentParser.ptr === p);
|
|
39673
39673
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39674
39674
|
return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39675
39675
|
},
|
|
@@ -39677,8 +39677,8 @@ var require_client_h1 = __commonJS({
|
|
|
39677
39677
|
* @param {number} p
|
|
39678
39678
|
* @returns {number}
|
|
39679
39679
|
*/
|
|
39680
|
-
wasm_on_message_complete: (
|
|
39681
|
-
assert(currentParser.ptr ===
|
|
39680
|
+
wasm_on_message_complete: (p) => {
|
|
39681
|
+
assert(currentParser.ptr === p);
|
|
39682
39682
|
return currentParser.onMessageComplete();
|
|
39683
39683
|
}
|
|
39684
39684
|
}
|
|
@@ -42207,7 +42207,7 @@ var require_balanced_pool = __commonJS({
|
|
|
42207
42207
|
return this;
|
|
42208
42208
|
}
|
|
42209
42209
|
get upstreams() {
|
|
42210
|
-
return this[kClients].filter((dispatcher) => dispatcher.closed !== true && dispatcher.destroyed !== true).map((
|
|
42210
|
+
return this[kClients].filter((dispatcher) => dispatcher.closed !== true && dispatcher.destroyed !== true).map((p) => p[kUrl].origin);
|
|
42211
42211
|
}
|
|
42212
42212
|
[kGetDispatcher]() {
|
|
42213
42213
|
if (this[kClients].length === 0) {
|
|
@@ -48573,12 +48573,12 @@ var require_response2 = __commonJS({
|
|
|
48573
48573
|
...state
|
|
48574
48574
|
};
|
|
48575
48575
|
return new Proxy(response, {
|
|
48576
|
-
get(target,
|
|
48577
|
-
return
|
|
48576
|
+
get(target, p) {
|
|
48577
|
+
return p in state ? state[p] : target[p];
|
|
48578
48578
|
},
|
|
48579
|
-
set(target,
|
|
48580
|
-
assert(!(
|
|
48581
|
-
target[
|
|
48579
|
+
set(target, p, value) {
|
|
48580
|
+
assert(!(p in state));
|
|
48581
|
+
target[p] = value;
|
|
48582
48582
|
return true;
|
|
48583
48583
|
}
|
|
48584
48584
|
});
|
|
@@ -49581,18 +49581,18 @@ var require_fetch = __commonJS({
|
|
|
49581
49581
|
}
|
|
49582
49582
|
function fetch2(input, init = void 0) {
|
|
49583
49583
|
webidl.argumentLengthCheck(arguments, 1, "globalThis.fetch");
|
|
49584
|
-
let
|
|
49584
|
+
let p = createDeferredPromise();
|
|
49585
49585
|
let requestObject;
|
|
49586
49586
|
try {
|
|
49587
49587
|
requestObject = new Request(input, init);
|
|
49588
49588
|
} catch (e) {
|
|
49589
|
-
|
|
49590
|
-
return
|
|
49589
|
+
p.reject(e);
|
|
49590
|
+
return p.promise;
|
|
49591
49591
|
}
|
|
49592
49592
|
const request = getRequestState(requestObject);
|
|
49593
49593
|
if (requestObject.signal.aborted) {
|
|
49594
|
-
abortFetch(
|
|
49595
|
-
return
|
|
49594
|
+
abortFetch(p, request, null, requestObject.signal.reason);
|
|
49595
|
+
return p.promise;
|
|
49596
49596
|
}
|
|
49597
49597
|
const globalObject = request.client.globalObject;
|
|
49598
49598
|
if (globalObject?.constructor?.name === "ServiceWorkerGlobalScope") {
|
|
@@ -49608,7 +49608,7 @@ var require_fetch = __commonJS({
|
|
|
49608
49608
|
assert(controller != null);
|
|
49609
49609
|
controller.abort(requestObject.signal.reason);
|
|
49610
49610
|
const realResponse = responseObject?.deref();
|
|
49611
|
-
abortFetch(
|
|
49611
|
+
abortFetch(p, request, realResponse, requestObject.signal.reason);
|
|
49612
49612
|
}
|
|
49613
49613
|
);
|
|
49614
49614
|
const processResponse = (response) => {
|
|
@@ -49616,16 +49616,16 @@ var require_fetch = __commonJS({
|
|
|
49616
49616
|
return;
|
|
49617
49617
|
}
|
|
49618
49618
|
if (response.aborted) {
|
|
49619
|
-
abortFetch(
|
|
49619
|
+
abortFetch(p, request, responseObject, controller.serializedAbortReason);
|
|
49620
49620
|
return;
|
|
49621
49621
|
}
|
|
49622
49622
|
if (response.type === "error") {
|
|
49623
|
-
|
|
49623
|
+
p.reject(new TypeError("fetch failed", { cause: response.error }));
|
|
49624
49624
|
return;
|
|
49625
49625
|
}
|
|
49626
49626
|
responseObject = new WeakRef(fromInnerResponse(response, "immutable"));
|
|
49627
|
-
|
|
49628
|
-
|
|
49627
|
+
p.resolve(responseObject.deref());
|
|
49628
|
+
p = null;
|
|
49629
49629
|
};
|
|
49630
49630
|
controller = fetching({
|
|
49631
49631
|
request,
|
|
@@ -49634,7 +49634,7 @@ var require_fetch = __commonJS({
|
|
|
49634
49634
|
dispatcher: getRequestDispatcher(requestObject)
|
|
49635
49635
|
// undici
|
|
49636
49636
|
});
|
|
49637
|
-
return
|
|
49637
|
+
return p.promise;
|
|
49638
49638
|
}
|
|
49639
49639
|
function finalizeAndReportTiming(response, initiatorType = "other") {
|
|
49640
49640
|
if (response.type === "error" && response.aborted) {
|
|
@@ -49672,9 +49672,9 @@ var require_fetch = __commonJS({
|
|
|
49672
49672
|
);
|
|
49673
49673
|
}
|
|
49674
49674
|
var markResourceTiming = performance.markResourceTiming;
|
|
49675
|
-
function abortFetch(
|
|
49676
|
-
if (
|
|
49677
|
-
|
|
49675
|
+
function abortFetch(p, request, responseObject, error) {
|
|
49676
|
+
if (p) {
|
|
49677
|
+
p.reject(error);
|
|
49678
49678
|
}
|
|
49679
49679
|
if (request.body?.stream != null && isReadable(request.body.stream)) {
|
|
49680
49680
|
request.body.stream.cancel(error).catch((err) => {
|
|
@@ -50552,9 +50552,9 @@ var require_util5 = __commonJS({
|
|
|
50552
50552
|
var assert = require("node:assert");
|
|
50553
50553
|
var { URLSerializer } = require_data_url();
|
|
50554
50554
|
var { isValidHeaderName } = require_util4();
|
|
50555
|
-
function urlEquals(A2,
|
|
50555
|
+
function urlEquals(A2, B2, excludeFragment = false) {
|
|
50556
50556
|
const serializedA = URLSerializer(A2, excludeFragment);
|
|
50557
|
-
const serializedB = URLSerializer(
|
|
50557
|
+
const serializedB = URLSerializer(B2, excludeFragment);
|
|
50558
50558
|
return serializedA === serializedB;
|
|
50559
50559
|
}
|
|
50560
50560
|
function getFieldValues(header) {
|
|
@@ -50607,11 +50607,11 @@ var require_cache3 = __commonJS({
|
|
|
50607
50607
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
50608
50608
|
request = webidl.converters.RequestInfo(request, prefix, "request");
|
|
50609
50609
|
options = webidl.converters.CacheQueryOptions(options, prefix, "options");
|
|
50610
|
-
const
|
|
50611
|
-
if (
|
|
50610
|
+
const p = this.#internalMatchAll(request, options, 1);
|
|
50611
|
+
if (p.length === 0) {
|
|
50612
50612
|
return;
|
|
50613
50613
|
}
|
|
50614
|
-
return
|
|
50614
|
+
return p[0];
|
|
50615
50615
|
}
|
|
50616
50616
|
async matchAll(request = void 0, options = {}) {
|
|
50617
50617
|
webidl.brandCheck(this, _Cache);
|
|
@@ -50702,8 +50702,8 @@ var require_cache3 = __commonJS({
|
|
|
50702
50702
|
}));
|
|
50703
50703
|
responsePromises.push(responsePromise.promise);
|
|
50704
50704
|
}
|
|
50705
|
-
const
|
|
50706
|
-
const responses = await
|
|
50705
|
+
const p = Promise.all(responsePromises);
|
|
50706
|
+
const responses = await p;
|
|
50707
50707
|
const operations = [];
|
|
50708
50708
|
let index = 0;
|
|
50709
50709
|
for (const response of responses) {
|
|
@@ -53005,10 +53005,10 @@ var require_websocket = __commonJS({
|
|
|
53005
53005
|
if (typeof protocols === "string") {
|
|
53006
53006
|
protocols = [protocols];
|
|
53007
53007
|
}
|
|
53008
|
-
if (protocols.length !== new Set(protocols.map((
|
|
53008
|
+
if (protocols.length !== new Set(protocols.map((p) => p.toLowerCase())).size) {
|
|
53009
53009
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53010
53010
|
}
|
|
53011
|
-
if (protocols.length > 0 && !protocols.every((
|
|
53011
|
+
if (protocols.length > 0 && !protocols.every((p) => isValidSubprotocol(p))) {
|
|
53012
53012
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53013
53013
|
}
|
|
53014
53014
|
this.#url = new URL(urlRecord.href);
|
|
@@ -53496,10 +53496,10 @@ var require_websocketstream = __commonJS({
|
|
|
53496
53496
|
const baseURL = environmentSettingsObject.settingsObject.baseUrl;
|
|
53497
53497
|
const urlRecord = getURLRecord(url, baseURL);
|
|
53498
53498
|
const protocols = options.protocols;
|
|
53499
|
-
if (protocols.length !== new Set(protocols.map((
|
|
53499
|
+
if (protocols.length !== new Set(protocols.map((p) => p.toLowerCase())).size) {
|
|
53500
53500
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53501
53501
|
}
|
|
53502
|
-
if (protocols.length > 0 && !protocols.every((
|
|
53502
|
+
if (protocols.length > 0 && !protocols.every((p) => isValidSubprotocol(p))) {
|
|
53503
53503
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53504
53504
|
}
|
|
53505
53505
|
this.#url = urlRecord.toString();
|
|
@@ -54471,9 +54471,9 @@ var require_tiktoken_bg = __commonJS({
|
|
|
54471
54471
|
heap[idx] = obj;
|
|
54472
54472
|
return idx;
|
|
54473
54473
|
}
|
|
54474
|
-
function handleError(
|
|
54474
|
+
function handleError(f2, args) {
|
|
54475
54475
|
try {
|
|
54476
|
-
return
|
|
54476
|
+
return f2.apply(this, args);
|
|
54477
54477
|
} catch (e) {
|
|
54478
54478
|
wasm.__wbindgen_export_0(addHeapObject(e));
|
|
54479
54479
|
}
|
|
@@ -54884,10 +54884,10 @@ var import_node_readline = __toESM(require("node:readline"));
|
|
|
54884
54884
|
var import_node_path = __toESM(require("node:path"));
|
|
54885
54885
|
var import_node_os = __toESM(require("node:os"));
|
|
54886
54886
|
var HOME_DIR = import_node_path.default.join(import_node_os.default.homedir(), ".claude-code-router");
|
|
54887
|
-
var CONFIG_FILE =
|
|
54888
|
-
var PLUGINS_DIR =
|
|
54887
|
+
var CONFIG_FILE = import_node_path.default.join(HOME_DIR, "config.json");
|
|
54888
|
+
var PLUGINS_DIR = import_node_path.default.join(HOME_DIR, "plugins");
|
|
54889
54889
|
var PID_FILE = import_node_path.default.join(HOME_DIR, ".claude-code-router.pid");
|
|
54890
|
-
var REFERENCE_COUNT_FILE = "
|
|
54890
|
+
var REFERENCE_COUNT_FILE = import_node_path.default.join(import_node_os.default.tmpdir(), "claude-code-reference-count.txt");
|
|
54891
54891
|
var DEFAULT_CONFIG = {
|
|
54892
54892
|
LOG: false,
|
|
54893
54893
|
OPENAI_API_KEY: "",
|
|
@@ -54958,7 +54958,7 @@ var initConfig = async () => {
|
|
|
54958
54958
|
return config;
|
|
54959
54959
|
};
|
|
54960
54960
|
|
|
54961
|
-
// node_modules/.pnpm/@musistudio+llms@1.0.
|
|
54961
|
+
// node_modules/.pnpm/@musistudio+llms@1.0.4_ws@8.18.3_zod@3.25.67/node_modules/@musistudio/llms/dist/esm/server.mjs
|
|
54962
54962
|
var import_fastify = __toESM(require_fastify(), 1);
|
|
54963
54963
|
var import_cors = __toESM(require_cors(), 1);
|
|
54964
54964
|
var import_fs = require("fs");
|
|
@@ -54966,12 +54966,11 @@ var import_path = require("path");
|
|
|
54966
54966
|
var import_dotenv = __toESM(require_main(), 1);
|
|
54967
54967
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
54968
54968
|
var import_undici = __toESM(require_undici(), 1);
|
|
54969
|
-
var
|
|
54970
|
-
var W = ((a) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(a, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : a)(function(a) {
|
|
54969
|
+
var V = ((i) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(i, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : i)(function(i) {
|
|
54971
54970
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
54972
|
-
throw Error('Dynamic require of "' +
|
|
54971
|
+
throw Error('Dynamic require of "' + i + '" is not supported');
|
|
54973
54972
|
});
|
|
54974
|
-
var
|
|
54973
|
+
var j = class {
|
|
54975
54974
|
config = {};
|
|
54976
54975
|
options;
|
|
54977
54976
|
constructor(e = { jsonPath: "./config.json" }) {
|
|
@@ -55035,22 +55034,22 @@ var N = class {
|
|
|
55035
55034
|
return this.options.initialConfig && e.push("Initial Config"), this.options.useJsonFile && this.options.jsonPath && e.push(`JSON: ${this.options.jsonPath}`), this.options.useEnvFile && e.push(`ENV: ${this.options.envPath}`), this.options.useEnvironmentVariables && e.push("Environment Variables"), `Config sources: ${e.join(", ")}`;
|
|
55036
55035
|
}
|
|
55037
55036
|
};
|
|
55038
|
-
function
|
|
55039
|
-
if (console.log(...
|
|
55040
|
-
let n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${Array.isArray(
|
|
55037
|
+
function f(...i) {
|
|
55038
|
+
if (console.log(...i), !(process.env.LOG === "true")) return;
|
|
55039
|
+
let n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${Array.isArray(i) ? i.map((r) => typeof r == "object" ? JSON.stringify(r) : String(r)).join(" ") : ""}
|
|
55041
55040
|
`, o = process.env.LOG_FILE || "app.log";
|
|
55042
55041
|
import_node_fs.default.appendFileSync(o, n, "utf8");
|
|
55043
55042
|
}
|
|
55044
|
-
function A(
|
|
55045
|
-
let o = new Error(
|
|
55043
|
+
function A(i, e = 500, t = "internal_error", n = "api_error") {
|
|
55044
|
+
let o = new Error(i);
|
|
55046
55045
|
return o.statusCode = e, o.code = t, o.type = n, o;
|
|
55047
55046
|
}
|
|
55048
|
-
async function
|
|
55049
|
-
e.log.error(
|
|
55050
|
-
let n =
|
|
55047
|
+
async function X(i, e, t) {
|
|
55048
|
+
e.log.error(i);
|
|
55049
|
+
let n = i.statusCode || 500, o = { error: { message: i.message || "Internal Server Error", type: i.type || "api_error", code: i.code || "internal_error" } };
|
|
55051
55050
|
return t.code(n).send(o);
|
|
55052
55051
|
}
|
|
55053
|
-
function
|
|
55052
|
+
function Q(i, e, t) {
|
|
55054
55053
|
let n = new Headers({ "Content-Type": "application/json" });
|
|
55055
55054
|
t.headers && Object.entries(t.headers).forEach(([u, d]) => {
|
|
55056
55055
|
n.set(u, d);
|
|
@@ -55061,59 +55060,69 @@ function ee(a, e, t) {
|
|
|
55061
55060
|
t.signal.addEventListener("abort", d), r.addEventListener("abort", d), o = u.signal;
|
|
55062
55061
|
} else o = r;
|
|
55063
55062
|
let l = { method: "POST", headers: n, body: JSON.stringify(e), signal: o };
|
|
55064
|
-
return t.httpsProxy && (l.dispatcher = new import_undici.ProxyAgent(new URL(t.httpsProxy).toString())),
|
|
55063
|
+
return t.httpsProxy && (l.dispatcher = new import_undici.ProxyAgent(new URL(t.httpsProxy).toString())), f("final request:", typeof i == "string" ? i : i.toString(), t.httpsProxy, l), fetch(typeof i == "string" ? i : i.toString(), l);
|
|
55065
55064
|
}
|
|
55066
|
-
var
|
|
55067
|
-
|
|
55068
|
-
let e =
|
|
55069
|
-
for (let { name: t, transformer: n } of e) n.endPoint &&
|
|
55070
|
-
let l = o.body, u = o.provider, d =
|
|
55065
|
+
var Z = async (i) => {
|
|
55066
|
+
i.get("/", async (t, n) => ({ message: "LLMs API", version: "1.0.0" })), i.get("/health", async (t, n) => ({ status: "ok", timestamp: (/* @__PURE__ */ new Date()).toISOString() }));
|
|
55067
|
+
let e = i._server.transformerService.getTransformersWithEndpoint();
|
|
55068
|
+
for (let { name: t, transformer: n } of e) n.endPoint && i.post(n.endPoint, async (o, r) => {
|
|
55069
|
+
let l = o.body, u = o.provider, d = i._server.providerService.getProvider(u);
|
|
55071
55070
|
if (!d) throw A(`Provider '${u}' not found`, 404, "provider_not_found");
|
|
55072
|
-
let
|
|
55071
|
+
let a = l, c = {};
|
|
55073
55072
|
if (typeof n.transformRequestOut == "function") {
|
|
55074
|
-
let s =
|
|
55075
|
-
s.body ? (
|
|
55076
|
-
}
|
|
55077
|
-
if (
|
|
55078
|
-
|
|
55079
|
-
|
|
55080
|
-
|
|
55081
|
-
|
|
55082
|
-
|
|
55083
|
-
|
|
55084
|
-
|
|
55085
|
-
|
|
55086
|
-
|
|
55087
|
-
}
|
|
55088
|
-
|
|
55089
|
-
|
|
55090
|
-
|
|
55091
|
-
|
|
55073
|
+
let s = n.transformRequestOut(l);
|
|
55074
|
+
s.body ? (a = s.body, c = s.config || {}) : a = s;
|
|
55075
|
+
}
|
|
55076
|
+
if (d.transformer?.use?.length) for (let s of d.transformer.use) {
|
|
55077
|
+
let m = i._server.transformerService.getTransformer(s);
|
|
55078
|
+
if (!m || typeof m.transformRequestIn != "function") continue;
|
|
55079
|
+
let g = m.transformRequestIn(a, d);
|
|
55080
|
+
g.body ? (a = g.body, c = { ...c, ...g.config }) : a = g;
|
|
55081
|
+
}
|
|
55082
|
+
if (d.transformer?.[o.body.model]?.use?.length) for (let s of d.transformer[o.body.model].use) {
|
|
55083
|
+
let m = i._server.transformerService.getTransformer(s);
|
|
55084
|
+
!m || typeof m.transformRequestIn != "function" || (a = m.transformRequestIn(a, d));
|
|
55085
|
+
}
|
|
55086
|
+
let y = c.url || new URL(d.baseUrl), v = await Q(y, a, { httpsProxy: i._server.configService.getHttpsProxy(), ...c, headers: { Authorization: `Bearer ${d.apiKey}`, ...c?.headers || {} } });
|
|
55087
|
+
if (!v.ok) {
|
|
55088
|
+
let s = await v.text();
|
|
55089
|
+
throw f(`Error response from ${y}: ${s}`), A(`Error from provider: ${s}`, v.status, "provider_response_error");
|
|
55090
|
+
}
|
|
55091
|
+
let h = v;
|
|
55092
|
+
if (d.transformer?.use?.length) for (let s of d.transformer.use) {
|
|
55093
|
+
let m = i._server.transformerService.getTransformer(s);
|
|
55094
|
+
!m || typeof m.transformResponseOut != "function" || (h = await m.transformResponseOut(h));
|
|
55095
|
+
}
|
|
55096
|
+
if (d.transformer?.[o.body.model]?.use?.length) for (let s of d.transformer[o.body.model].use) {
|
|
55097
|
+
let m = i._server.transformerService.getTransformer(s);
|
|
55098
|
+
!m || typeof m.transformResponseOut != "function" || (h = await m.transformResponseOut(h));
|
|
55099
|
+
}
|
|
55100
|
+
return n.transformResponseIn && (h = await n.transformResponseIn(h)), h.ok || r.code(h.status), l?.stream === true ? (r.header("Content-Type", "text/event-stream"), r.header("Cache-Control", "no-cache"), r.header("Connection", "keep-alive"), r.send(h.body)) : h.json();
|
|
55092
55101
|
});
|
|
55093
|
-
|
|
55102
|
+
i.post("/providers", { schema: { body: { type: "object", properties: { id: { type: "string" }, name: { type: "string" }, type: { type: "string", enum: ["openai", "anthropic"] }, baseUrl: { type: "string" }, apiKey: { type: "string" }, models: { type: "array", items: { type: "string" } } }, required: ["id", "name", "type", "baseUrl", "apiKey", "models"] } } }, async (t, n) => {
|
|
55094
55103
|
let { name: o, type: r, baseUrl: l, apiKey: u, models: d } = t.body;
|
|
55095
55104
|
if (!o?.trim()) throw A("Provider name is required", 400, "invalid_request");
|
|
55096
|
-
if (!l || !
|
|
55105
|
+
if (!l || !ae(l)) throw A("Valid base URL is required", 400, "invalid_request");
|
|
55097
55106
|
if (!u?.trim()) throw A("API key is required", 400, "invalid_request");
|
|
55098
55107
|
if (!d || !Array.isArray(d) || d.length === 0) throw A("At least one model is required", 400, "invalid_request");
|
|
55099
|
-
if (
|
|
55100
|
-
return
|
|
55101
|
-
}),
|
|
55102
|
-
let o =
|
|
55108
|
+
if (i._server.providerService.getProvider(id)) throw A(`Provider with ID '${id}' already exists`, 400, "provider_exists");
|
|
55109
|
+
return i._server.providerService.registerProvider(t.body);
|
|
55110
|
+
}), i.get("/providers", async (t, n) => i._server.providerService.getProviders()), i.get("/providers/:id", { schema: { params: { type: "object", properties: { id: { type: "string" } }, required: ["id"] } } }, async (t, n) => {
|
|
55111
|
+
let o = i._server.providerService.getProvider(t.params.id);
|
|
55103
55112
|
return o || n.code(404).send({ error: "Provider not found" });
|
|
55104
|
-
}),
|
|
55105
|
-
let o =
|
|
55113
|
+
}), i.put("/providers/:id", { schema: { params: { type: "object", properties: { id: { type: "string" } }, required: ["id"] }, body: { type: "object", properties: { name: { type: "string" }, type: { type: "string", enum: ["openai", "anthropic"] }, baseUrl: { type: "string" }, apiKey: { type: "string" }, models: { type: "array", items: { type: "string" } }, enabled: { type: "boolean" } } } } }, async (t, n) => {
|
|
55114
|
+
let o = i._server.providerService.updateProvider(t.params.id, t.body);
|
|
55106
55115
|
return o || n.code(404).send({ error: "Provider not found" });
|
|
55107
|
-
}),
|
|
55116
|
+
}), i.delete("/providers/:id", { schema: { params: { type: "object", properties: { id: { type: "string" } }, required: ["id"] } } }, async (t, n) => i._server.providerService.deleteProvider(t.params.id) ? { message: "Provider deleted successfully" } : n.code(404).send({ error: "Provider not found" })), i.patch("/providers/:id/toggle", { schema: { params: { type: "object", properties: { id: { type: "string" } }, required: ["id"] }, body: { type: "object", properties: { enabled: { type: "boolean" } }, required: ["enabled"] } } }, async (t, n) => i._server.providerService.toggleProvider(t.params.id, t.body.enabled) ? { message: `Provider ${t.body.enabled ? "enabled" : "disabled"} successfully` } : n.code(404).send({ error: "Provider not found" }));
|
|
55108
55117
|
};
|
|
55109
|
-
function
|
|
55118
|
+
function ae(i) {
|
|
55110
55119
|
try {
|
|
55111
|
-
return new URL(
|
|
55120
|
+
return new URL(i), true;
|
|
55112
55121
|
} catch {
|
|
55113
55122
|
return false;
|
|
55114
55123
|
}
|
|
55115
55124
|
}
|
|
55116
|
-
var
|
|
55125
|
+
var q = class {
|
|
55117
55126
|
constructor(e) {
|
|
55118
55127
|
this.providerService = e;
|
|
55119
55128
|
}
|
|
@@ -55150,10 +55159,9 @@ var H = class {
|
|
|
55150
55159
|
return this.providerService.getModelRoutes();
|
|
55151
55160
|
}
|
|
55152
55161
|
};
|
|
55153
|
-
var
|
|
55154
|
-
constructor(e
|
|
55162
|
+
var J = class {
|
|
55163
|
+
constructor(e) {
|
|
55155
55164
|
this.configService = e;
|
|
55156
|
-
this.transformerService = t;
|
|
55157
55165
|
this.initializeCustomProviders();
|
|
55158
55166
|
}
|
|
55159
55167
|
providers = /* @__PURE__ */ new Map();
|
|
@@ -55169,24 +55177,9 @@ var $ = class {
|
|
|
55169
55177
|
e.forEach((t) => {
|
|
55170
55178
|
try {
|
|
55171
55179
|
if (!t.name || !t.api_base_url || !t.api_key) return;
|
|
55172
|
-
|
|
55173
|
-
t.transformer && Object.keys(t.transformer).forEach((o) => {
|
|
55174
|
-
o === "use" ? Array.isArray(t.transformer.use) && (n.use = t.transformer.use.map((r) => {
|
|
55175
|
-
if (Array.isArray(r) && typeof r[0] == "string") {
|
|
55176
|
-
let l = this.transformerService.getTransformer(r[0]);
|
|
55177
|
-
if (l) return new l(r[1]);
|
|
55178
|
-
}
|
|
55179
|
-
if (typeof r == "string") return this.transformerService.getTransformer(r);
|
|
55180
|
-
}).filter((r) => typeof r < "u")) : Array.isArray(t.transformer[o]?.use) && (n[o] = { use: t.transformer[o].use.map((r) => {
|
|
55181
|
-
if (Array.isArray(r) && typeof r[0] == "string") {
|
|
55182
|
-
let l = this.transformerService.getTransformer(r[0]);
|
|
55183
|
-
if (l) return new l(r[1]);
|
|
55184
|
-
}
|
|
55185
|
-
if (typeof r == "string") return this.transformerService.getTransformer(r);
|
|
55186
|
-
}).filter((r) => typeof r < "u") });
|
|
55187
|
-
}), console.log("providerConfig: ", t.name, n.use), this.registerProvider({ name: t.name, baseUrl: t.api_base_url, apiKey: t.api_key, models: t.models || [], transformer: t.transformer ? n : void 0 }), p(`${t.name} provider registered`);
|
|
55180
|
+
this.registerProvider({ name: t.name, baseUrl: t.api_base_url, apiKey: t.api_key, models: t.models || [], transformer: this.parseTransformerConfig(t.transformer) || {} }), f(`${t.name} provider registered`);
|
|
55188
55181
|
} catch (n) {
|
|
55189
|
-
|
|
55182
|
+
f(`${t.name} provider registered error: ${n}`);
|
|
55190
55183
|
}
|
|
55191
55184
|
});
|
|
55192
55185
|
}
|
|
@@ -55211,31 +55204,32 @@ var $ = class {
|
|
|
55211
55204
|
let l = `${n.id},${r}`;
|
|
55212
55205
|
this.modelRoutes.delete(l), this.modelRoutes.delete(r);
|
|
55213
55206
|
}), t.models.forEach((r) => {
|
|
55214
|
-
let l = `${n.
|
|
55207
|
+
let l = `${n.id},${r}`, u = { providerId: n.id, model: r, fullModel: l };
|
|
55215
55208
|
this.modelRoutes.set(l, u), this.modelRoutes.has(r) || this.modelRoutes.set(r, u);
|
|
55216
55209
|
})), o;
|
|
55217
55210
|
}
|
|
55218
55211
|
deleteProvider(e) {
|
|
55219
55212
|
let t = this.providers.get(e);
|
|
55220
55213
|
return t ? (t.models.forEach((n) => {
|
|
55221
|
-
let o = `${t.
|
|
55214
|
+
let o = `${t.id},${n}`;
|
|
55222
55215
|
this.modelRoutes.delete(o), this.modelRoutes.delete(n);
|
|
55223
55216
|
}), this.providers.delete(e), true) : false;
|
|
55224
55217
|
}
|
|
55225
55218
|
toggleProvider(e, t) {
|
|
55226
|
-
|
|
55219
|
+
let n = this.providers.get(e);
|
|
55220
|
+
return n ? (n.enabled = t, n.updatedAt = /* @__PURE__ */ new Date(), true) : false;
|
|
55227
55221
|
}
|
|
55228
55222
|
resolveModelRoute(e) {
|
|
55229
55223
|
let t = this.modelRoutes.get(e);
|
|
55230
55224
|
if (!t) return null;
|
|
55231
|
-
let n = this.providers.get(t.
|
|
55232
|
-
return n ? { provider: n, originalModel: e, targetModel: t.model }
|
|
55225
|
+
let n = this.providers.get(t.providerId);
|
|
55226
|
+
return !n || !n.enabled ? null : { provider: n, originalModel: e, targetModel: t.model };
|
|
55233
55227
|
}
|
|
55234
55228
|
getAvailableModelNames() {
|
|
55235
55229
|
let e = [];
|
|
55236
55230
|
return this.providers.forEach((t) => {
|
|
55237
|
-
t.models.forEach((n) => {
|
|
55238
|
-
e.push(n), e.push(`${t.
|
|
55231
|
+
t.enabled && t.models.forEach((n) => {
|
|
55232
|
+
e.push(n), e.push(`${t.id},${n}`);
|
|
55239
55233
|
});
|
|
55240
55234
|
}), e;
|
|
55241
55235
|
}
|
|
@@ -55254,17 +55248,17 @@ var $ = class {
|
|
|
55254
55248
|
async getAvailableModels() {
|
|
55255
55249
|
let e = [];
|
|
55256
55250
|
return this.providers.forEach((t) => {
|
|
55257
|
-
t.models.forEach((n) => {
|
|
55258
|
-
e.push({ id: n, object: "model", owned_by: t.name, provider: t.name }), e.push({ id: `${t.
|
|
55251
|
+
t.enabled && t.models.forEach((n) => {
|
|
55252
|
+
e.push({ id: n, object: "model", created: Math.floor(t.createdAt.getTime() / 1e3), owned_by: t.name, provider: t.name }), e.push({ id: `${t.id},${n}`, object: "model", created: Math.floor(t.createdAt.getTime() / 1e3), owned_by: t.name, provider: t.id });
|
|
55259
55253
|
});
|
|
55260
55254
|
}), { object: "list", data: e };
|
|
55261
55255
|
}
|
|
55262
55256
|
};
|
|
55263
|
-
var
|
|
55257
|
+
var M = class {
|
|
55264
55258
|
name = "Anthropic";
|
|
55265
55259
|
endPoint = "/v1/messages";
|
|
55266
55260
|
transformRequestOut(e) {
|
|
55267
|
-
|
|
55261
|
+
f("Anthropic Request:", JSON.stringify(e, null, 2));
|
|
55268
55262
|
let t = [];
|
|
55269
55263
|
if (e.system) {
|
|
55270
55264
|
if (typeof e.system == "string") t.push({ role: "system", content: e.system });
|
|
@@ -55280,17 +55274,17 @@ var F = class {
|
|
|
55280
55274
|
else if (Array.isArray(r.content)) {
|
|
55281
55275
|
if (r.role === "user") {
|
|
55282
55276
|
let d = r.content.filter((c) => c.type === "tool_result" && c.tool_use_id);
|
|
55283
|
-
d.length && d.forEach((c,
|
|
55284
|
-
let
|
|
55285
|
-
t.push(
|
|
55277
|
+
d.length && d.forEach((c, y) => {
|
|
55278
|
+
let v = { role: "tool", content: typeof c.content == "string" ? c.content : JSON.stringify(c.content), tool_call_id: c.tool_use_id, cache_control: c.cache_control };
|
|
55279
|
+
t.push(v);
|
|
55286
55280
|
});
|
|
55287
|
-
let
|
|
55288
|
-
|
|
55281
|
+
let a = r.content.filter((c) => c.type === "text" && c.text);
|
|
55282
|
+
a.length && t.push({ role: "user", content: a });
|
|
55289
55283
|
} else if (r.role === "assistant") {
|
|
55290
55284
|
let d = r.content.filter((c) => c.type === "text" && c.text);
|
|
55291
55285
|
d.length && t.push(...d.map((c) => ({ role: "assistant", content: c.text })));
|
|
55292
|
-
let
|
|
55293
|
-
|
|
55286
|
+
let a = r.content.filter((c) => c.type === "tool_use" && c.id);
|
|
55287
|
+
a.length && t.push({ role: "assistant", content: null, tool_calls: a.map((c) => ({ id: c.id, type: "function", function: { name: c.name, arguments: JSON.stringify(c.input || {}) } })) });
|
|
55294
55288
|
}
|
|
55295
55289
|
return;
|
|
55296
55290
|
}
|
|
@@ -55312,148 +55306,148 @@ var F = class {
|
|
|
55312
55306
|
}
|
|
55313
55307
|
async convertOpenAIStreamToAnthropic(e) {
|
|
55314
55308
|
return new ReadableStream({ async start(n) {
|
|
55315
|
-
let o = new TextEncoder(), r = `msg_${Date.now()}`, l = "unknown", u = false, d = false,
|
|
55309
|
+
let o = new TextEncoder(), r = `msg_${Date.now()}`, l = "unknown", u = false, d = false, a = false, c = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = 0, h = 0, p = 0, s = false, m = false, g = 0, k = (S) => {
|
|
55316
55310
|
if (!s) try {
|
|
55317
|
-
n.enqueue(
|
|
55318
|
-
let
|
|
55319
|
-
|
|
55320
|
-
} catch (C) {
|
|
55321
|
-
if (C instanceof TypeError && C.message.includes("Controller is already closed")) s = true;
|
|
55322
|
-
else throw p(`send data error: ${C.message}`), C;
|
|
55323
|
-
}
|
|
55324
|
-
}, z = () => {
|
|
55325
|
-
if (!s) try {
|
|
55326
|
-
n.close(), s = true;
|
|
55311
|
+
n.enqueue(S);
|
|
55312
|
+
let x = new TextDecoder().decode(S);
|
|
55313
|
+
f("send data:", x.trim());
|
|
55327
55314
|
} catch (x) {
|
|
55328
55315
|
if (x instanceof TypeError && x.message.includes("Controller is already closed")) s = true;
|
|
55329
|
-
else throw x;
|
|
55316
|
+
else throw f(`send data error: ${x.message}`), x;
|
|
55330
55317
|
}
|
|
55331
|
-
},
|
|
55318
|
+
}, D = () => {
|
|
55319
|
+
if (!s) try {
|
|
55320
|
+
n.close(), s = true;
|
|
55321
|
+
} catch (S) {
|
|
55322
|
+
if (S instanceof TypeError && S.message.includes("Controller is already closed")) s = true;
|
|
55323
|
+
else throw S;
|
|
55324
|
+
}
|
|
55325
|
+
}, I = null;
|
|
55332
55326
|
try {
|
|
55333
|
-
|
|
55334
|
-
let
|
|
55327
|
+
I = e.getReader();
|
|
55328
|
+
let S = new TextDecoder(), x = "";
|
|
55335
55329
|
for (; !s; ) {
|
|
55336
|
-
let { done:
|
|
55337
|
-
if (
|
|
55338
|
-
|
|
55339
|
-
let
|
|
55330
|
+
let { done: ee, value: te } = await I.read();
|
|
55331
|
+
if (ee) break;
|
|
55332
|
+
x += S.decode(te, { stream: true });
|
|
55333
|
+
let W = x.split(`
|
|
55340
55334
|
`);
|
|
55341
|
-
|
|
55342
|
-
for (let
|
|
55343
|
-
if (s ||
|
|
55344
|
-
if (!
|
|
55345
|
-
let
|
|
55346
|
-
if (
|
|
55347
|
-
let
|
|
55348
|
-
if (
|
|
55335
|
+
x = W.pop() || "";
|
|
55336
|
+
for (let G of W) {
|
|
55337
|
+
if (s || a) break;
|
|
55338
|
+
if (!G.startsWith("data: ")) continue;
|
|
55339
|
+
let z = G.slice(6);
|
|
55340
|
+
if (z !== "[DONE]") try {
|
|
55341
|
+
let T = JSON.parse(z);
|
|
55342
|
+
if (v++, f("Original Response:", JSON.stringify(T, null, 2)), l = T.model || l, !u && !s && !a) {
|
|
55349
55343
|
u = true;
|
|
55350
|
-
let
|
|
55351
|
-
|
|
55352
|
-
data: ${JSON.stringify(
|
|
55344
|
+
let b = { type: "message_start", message: { id: r, type: "message", role: "assistant", content: [], model: l, stop_reason: null, stop_sequence: null, usage: { input_tokens: 1, output_tokens: 1 } } };
|
|
55345
|
+
k(o.encode(`event: message_start
|
|
55346
|
+
data: ${JSON.stringify(b)}
|
|
55353
55347
|
|
|
55354
55348
|
`));
|
|
55355
55349
|
}
|
|
55356
|
-
let
|
|
55357
|
-
if (!
|
|
55358
|
-
if (
|
|
55359
|
-
if (!
|
|
55360
|
-
let
|
|
55361
|
-
|
|
55362
|
-
data: ${JSON.stringify(
|
|
55363
|
-
|
|
55364
|
-
`)),
|
|
55350
|
+
let P = T.choices?.[0];
|
|
55351
|
+
if (!P) continue;
|
|
55352
|
+
if (P?.delta?.thinking && !s && !a) {
|
|
55353
|
+
if (!m) {
|
|
55354
|
+
let b = { type: "content_block_start", index: g, content_block: { type: "thinking", thinking: "" } };
|
|
55355
|
+
k(o.encode(`event: content_block_start
|
|
55356
|
+
data: ${JSON.stringify(b)}
|
|
55357
|
+
|
|
55358
|
+
`)), m = true;
|
|
55365
55359
|
}
|
|
55366
|
-
if (
|
|
55367
|
-
let
|
|
55368
|
-
|
|
55369
|
-
data: ${JSON.stringify(
|
|
55360
|
+
if (P.delta.thinking.signature) {
|
|
55361
|
+
let b = { type: "content_block_delta", index: g, delta: { type: "signature_delta", signature: P.delta.thinking.signature } };
|
|
55362
|
+
k(o.encode(`event: content_block_delta
|
|
55363
|
+
data: ${JSON.stringify(b)}
|
|
55370
55364
|
|
|
55371
55365
|
`));
|
|
55372
|
-
let
|
|
55373
|
-
|
|
55366
|
+
let _ = { type: "content_block_stop", index: g };
|
|
55367
|
+
k(o.encode(`event: content_block_stop
|
|
55368
|
+
data: ${JSON.stringify(_)}
|
|
55369
|
+
|
|
55370
|
+
`)), g++;
|
|
55371
|
+
} else if (P.delta.thinking.content) {
|
|
55372
|
+
let b = { type: "content_block_delta", index: g, delta: { type: "thinking_delta", thinking: P.delta.thinking.content || "" } };
|
|
55373
|
+
k(o.encode(`event: content_block_delta
|
|
55374
55374
|
data: ${JSON.stringify(b)}
|
|
55375
55375
|
|
|
55376
|
-
`)), y++;
|
|
55377
|
-
} else if (S.delta.thinking.content) {
|
|
55378
|
-
let k = { type: "content_block_delta", index: y, delta: { type: "thinking_delta", thinking: S.delta.thinking.content || "" } };
|
|
55379
|
-
v(o.encode(`event: content_block_delta
|
|
55380
|
-
data: ${JSON.stringify(k)}
|
|
55381
|
-
|
|
55382
55376
|
`));
|
|
55383
55377
|
}
|
|
55384
55378
|
}
|
|
55385
|
-
if (
|
|
55386
|
-
if (
|
|
55379
|
+
if (P?.delta?.content && !s && !a) {
|
|
55380
|
+
if (h++, !d && !a) {
|
|
55387
55381
|
d = true;
|
|
55388
|
-
let
|
|
55389
|
-
|
|
55390
|
-
data: ${JSON.stringify(
|
|
55382
|
+
let b = { type: "content_block_start", index: g, content_block: { type: "text", text: "" } };
|
|
55383
|
+
k(o.encode(`event: content_block_start
|
|
55384
|
+
data: ${JSON.stringify(b)}
|
|
55391
55385
|
|
|
55392
55386
|
`));
|
|
55393
55387
|
}
|
|
55394
|
-
if (!s && !
|
|
55395
|
-
let
|
|
55396
|
-
|
|
55397
|
-
data: ${JSON.stringify(
|
|
55388
|
+
if (!s && !a) {
|
|
55389
|
+
let b = { type: "content_block_delta", index: g, delta: { type: "text_delta", text: P.delta.content } };
|
|
55390
|
+
k(o.encode(`event: content_block_delta
|
|
55391
|
+
data: ${JSON.stringify(b)}
|
|
55398
55392
|
|
|
55399
55393
|
`));
|
|
55400
55394
|
}
|
|
55401
55395
|
}
|
|
55402
|
-
if (
|
|
55403
|
-
|
|
55404
|
-
let
|
|
55405
|
-
for (let
|
|
55396
|
+
if (P?.delta?.tool_calls && !s && !a) {
|
|
55397
|
+
p++;
|
|
55398
|
+
let b = /* @__PURE__ */ new Set();
|
|
55399
|
+
for (let _ of P.delta.tool_calls) {
|
|
55406
55400
|
if (s) break;
|
|
55407
|
-
let R =
|
|
55408
|
-
if (
|
|
55409
|
-
if (
|
|
55410
|
-
let
|
|
55411
|
-
if (
|
|
55412
|
-
|
|
55413
|
-
let
|
|
55414
|
-
|
|
55415
|
-
data: ${JSON.stringify(
|
|
55416
|
-
|
|
55417
|
-
`)),
|
|
55401
|
+
let R = _.index ?? 0;
|
|
55402
|
+
if (b.has(R)) continue;
|
|
55403
|
+
if (b.add(R), !y.has(R)) {
|
|
55404
|
+
let C = d ? y.size + 1 : y.size;
|
|
55405
|
+
if (C !== 0) {
|
|
55406
|
+
f("content_block_stop2");
|
|
55407
|
+
let ne = { type: "content_block_stop", index: g };
|
|
55408
|
+
k(o.encode(`event: content_block_stop
|
|
55409
|
+
data: ${JSON.stringify(ne)}
|
|
55410
|
+
|
|
55411
|
+
`)), g++;
|
|
55418
55412
|
}
|
|
55419
|
-
|
|
55420
|
-
let E =
|
|
55421
|
-
|
|
55413
|
+
y.set(R, C);
|
|
55414
|
+
let E = _.id || `call_${Date.now()}_${R}`, w = _.function?.name || `tool_${R}`, O = { type: "content_block_start", index: g, content_block: { type: "tool_use", id: E, name: w, input: {} } };
|
|
55415
|
+
k(o.encode(`event: content_block_start
|
|
55422
55416
|
data: ${JSON.stringify(O)}
|
|
55423
55417
|
|
|
55424
55418
|
`));
|
|
55425
|
-
let L = { id: E, name: w, arguments: "", contentBlockIndex:
|
|
55419
|
+
let L = { id: E, name: w, arguments: "", contentBlockIndex: C };
|
|
55426
55420
|
c.set(R, L);
|
|
55427
|
-
} else if (
|
|
55428
|
-
let
|
|
55429
|
-
|
|
55421
|
+
} else if (_.id && _.function?.name) {
|
|
55422
|
+
let C = c.get(R);
|
|
55423
|
+
C.id.startsWith("call_") && C.name.startsWith("tool_") && (C.id = _.id, C.name = _.function.name);
|
|
55430
55424
|
}
|
|
55431
|
-
if (
|
|
55432
|
-
if (
|
|
55425
|
+
if (_.function?.arguments && !s && !a) {
|
|
55426
|
+
if (y.get(R) === void 0) continue;
|
|
55433
55427
|
let E = c.get(R);
|
|
55434
55428
|
if (E) {
|
|
55435
|
-
E.arguments +=
|
|
55429
|
+
E.arguments += _.function.arguments;
|
|
55436
55430
|
try {
|
|
55437
55431
|
let w = null, O = E.arguments.trim();
|
|
55438
55432
|
if (O.startsWith("{") && O.endsWith("}")) try {
|
|
55439
55433
|
w = JSON.parse(O);
|
|
55440
55434
|
} catch (L) {
|
|
55441
|
-
|
|
55435
|
+
f("Tool call index:", R, "error", L.message);
|
|
55442
55436
|
}
|
|
55443
55437
|
} catch (w) {
|
|
55444
|
-
|
|
55438
|
+
f("Tool call index:", R, "error", w.message);
|
|
55445
55439
|
}
|
|
55446
55440
|
}
|
|
55447
55441
|
try {
|
|
55448
|
-
let w = { type: "content_block_delta", index:
|
|
55449
|
-
|
|
55442
|
+
let w = { type: "content_block_delta", index: g, delta: { type: "input_json_delta", partial_json: _.function.arguments } };
|
|
55443
|
+
k(o.encode(`event: content_block_delta
|
|
55450
55444
|
data: ${JSON.stringify(w)}
|
|
55451
55445
|
|
|
55452
55446
|
`));
|
|
55453
55447
|
} catch {
|
|
55454
55448
|
try {
|
|
55455
|
-
let O =
|
|
55456
|
-
|
|
55449
|
+
let O = _.function.arguments.replace(/[\x00-\x1F\x7F-\x9F]/g, "").replace(/\\/g, "\\\\").replace(/"/g, '\\"'), L = { type: "content_block_delta", index: g, delta: { type: "input_json_delta", partial_json: O } };
|
|
55450
|
+
k(o.encode(`event: content_block_delta
|
|
55457
55451
|
data: ${JSON.stringify(L)}
|
|
55458
55452
|
|
|
55459
55453
|
`));
|
|
@@ -55464,56 +55458,56 @@ data: ${JSON.stringify(L)}
|
|
|
55464
55458
|
}
|
|
55465
55459
|
}
|
|
55466
55460
|
}
|
|
55467
|
-
if (
|
|
55468
|
-
if (
|
|
55469
|
-
|
|
55470
|
-
let
|
|
55471
|
-
|
|
55472
|
-
data: ${JSON.stringify(
|
|
55461
|
+
if (P?.finish_reason && !s && !a) {
|
|
55462
|
+
if (a = true, h === 0 && p === 0 && console.error("Warning: No content in the stream response!"), (d || p > 0) && !s) {
|
|
55463
|
+
f("content_block_stop hasTextContentStarted");
|
|
55464
|
+
let b = { type: "content_block_stop", index: g };
|
|
55465
|
+
k(o.encode(`event: content_block_stop
|
|
55466
|
+
data: ${JSON.stringify(b)}
|
|
55473
55467
|
|
|
55474
55468
|
`));
|
|
55475
55469
|
}
|
|
55476
55470
|
if (!s) {
|
|
55477
|
-
let R = { type: "message_delta", delta: { stop_reason: { stop: "end_turn", length: "max_tokens", tool_calls: "tool_use", content_filter: "stop_sequence" }[
|
|
55478
|
-
|
|
55471
|
+
let R = { type: "message_delta", delta: { stop_reason: { stop: "end_turn", length: "max_tokens", tool_calls: "tool_use", content_filter: "stop_sequence" }[P.finish_reason] || "end_turn", stop_sequence: null }, usage: { input_tokens: T.usage?.prompt_tokens || 0, output_tokens: T.usage?.completion_tokens || 0 } };
|
|
55472
|
+
k(o.encode(`event: message_delta
|
|
55479
55473
|
data: ${JSON.stringify(R)}
|
|
55480
55474
|
|
|
55481
55475
|
`));
|
|
55482
55476
|
}
|
|
55483
55477
|
if (!s) {
|
|
55484
|
-
let
|
|
55485
|
-
|
|
55486
|
-
data: ${JSON.stringify(
|
|
55478
|
+
let b = { type: "message_stop" };
|
|
55479
|
+
k(o.encode(`event: message_stop
|
|
55480
|
+
data: ${JSON.stringify(b)}
|
|
55487
55481
|
|
|
55488
55482
|
`));
|
|
55489
55483
|
}
|
|
55490
55484
|
break;
|
|
55491
55485
|
}
|
|
55492
|
-
} catch (
|
|
55493
|
-
|
|
55486
|
+
} catch (T) {
|
|
55487
|
+
f(`parseError: ${T.name} message: ${T.message} stack: ${T.stack} data: ${z}`);
|
|
55494
55488
|
}
|
|
55495
55489
|
}
|
|
55496
55490
|
}
|
|
55497
|
-
|
|
55498
|
-
} catch (
|
|
55491
|
+
D();
|
|
55492
|
+
} catch (S) {
|
|
55499
55493
|
if (!s) try {
|
|
55500
|
-
n.error(
|
|
55501
|
-
} catch (C) {
|
|
55502
|
-
console.error(C);
|
|
55503
|
-
}
|
|
55504
|
-
} finally {
|
|
55505
|
-
if (M) try {
|
|
55506
|
-
M.releaseLock();
|
|
55494
|
+
n.error(S);
|
|
55507
55495
|
} catch (x) {
|
|
55508
55496
|
console.error(x);
|
|
55509
55497
|
}
|
|
55498
|
+
} finally {
|
|
55499
|
+
if (I) try {
|
|
55500
|
+
I.releaseLock();
|
|
55501
|
+
} catch (S) {
|
|
55502
|
+
console.error(S);
|
|
55503
|
+
}
|
|
55510
55504
|
}
|
|
55511
55505
|
}, cancel(n) {
|
|
55512
|
-
|
|
55506
|
+
f("cancle stream:", n);
|
|
55513
55507
|
} });
|
|
55514
55508
|
}
|
|
55515
55509
|
convertOpenAIResponseToAnthropic(e) {
|
|
55516
|
-
|
|
55510
|
+
f("Original OpenAI response:", JSON.stringify(e, null, 2));
|
|
55517
55511
|
let t = e.choices[0];
|
|
55518
55512
|
if (!t) throw new Error("No choices found in OpenAI response");
|
|
55519
55513
|
let n = [];
|
|
@@ -55528,10 +55522,10 @@ data: ${JSON.stringify(k)}
|
|
|
55528
55522
|
n.push({ type: "tool_use", id: r.id, name: r.function.name, input: u });
|
|
55529
55523
|
});
|
|
55530
55524
|
let o = { id: e.id, type: "message", role: "assistant", model: e.model, content: n, stop_reason: t.finish_reason === "stop" ? "end_turn" : t.finish_reason === "length" ? "max_tokens" : t.finish_reason === "tool_calls" ? "tool_use" : t.finish_reason === "content_filter" ? "stop_sequence" : "end_turn", stop_sequence: null, usage: { input_tokens: e.usage?.prompt_tokens || 0, output_tokens: e.usage?.completion_tokens || 0 } };
|
|
55531
|
-
return
|
|
55525
|
+
return f("Conversion complete, final Anthropic response:", JSON.stringify(o, null, 2)), o;
|
|
55532
55526
|
}
|
|
55533
55527
|
};
|
|
55534
|
-
var
|
|
55528
|
+
var N = class {
|
|
55535
55529
|
name = "gemini";
|
|
55536
55530
|
endPoint = "/v1beta/models/:modelAndAction";
|
|
55537
55531
|
transformRequestIn(e, t) {
|
|
@@ -55547,14 +55541,14 @@ var I = class {
|
|
|
55547
55541
|
}), { name: n.function.name, description: n.function.description, parameters: n.function.parameters })) || [] }] }, config: { url: new URL(`./${e.model}:${e.stream ? "streamGenerateContent?alt=sse" : "generateContent"}`, t.baseUrl), headers: { "x-goog-api-key": t.apiKey, Authorization: void 0 } } };
|
|
55548
55542
|
}
|
|
55549
55543
|
transformRequestOut(e) {
|
|
55550
|
-
let t = e.contents, n = e.tools, o = e.model, r = e.max_tokens, l = e.temperature, u = e.stream, d = e.tool_choice,
|
|
55544
|
+
let t = e.contents, n = e.tools, o = e.model, r = e.max_tokens, l = e.temperature, u = e.stream, d = e.tool_choice, a = { messages: [], model: o, max_tokens: r, temperature: l, stream: u, tool_choice: d };
|
|
55551
55545
|
return Array.isArray(t) && t.forEach((c) => {
|
|
55552
|
-
typeof c == "string" ?
|
|
55553
|
-
}), Array.isArray(n) && (
|
|
55554
|
-
Array.isArray(c.functionDeclarations) && c.functionDeclarations.forEach((
|
|
55555
|
-
|
|
55546
|
+
typeof c == "string" ? a.messages.push({ role: "user", content: c }) : typeof c.text == "string" ? a.messages.push({ role: "user", content: c.text || null }) : c.role === "user" ? a.messages.push({ role: "user", content: c?.parts?.map((y) => ({ type: "text", text: y.text || "" })) || [] }) : c.role === "model" && a.messages.push({ role: "assistant", content: c?.parts?.map((y) => ({ type: "text", text: y.text || "" })) || [] });
|
|
55547
|
+
}), Array.isArray(n) && (a.tools = [], n.forEach((c) => {
|
|
55548
|
+
Array.isArray(c.functionDeclarations) && c.functionDeclarations.forEach((y) => {
|
|
55549
|
+
a.tools.push({ type: "function", function: { name: y.name, description: y.description, parameters: y.parameters } });
|
|
55556
55550
|
});
|
|
55557
|
-
})),
|
|
55551
|
+
})), a;
|
|
55558
55552
|
}
|
|
55559
55553
|
async transformResponseOut(e) {
|
|
55560
55554
|
if (e.headers.get("Content-Type")?.includes("application/json")) {
|
|
@@ -55569,13 +55563,13 @@ var I = class {
|
|
|
55569
55563
|
for (; ; ) {
|
|
55570
55564
|
let { done: u, value: d } = await l.read();
|
|
55571
55565
|
if (u) break;
|
|
55572
|
-
let
|
|
55573
|
-
if (
|
|
55566
|
+
let a = t.decode(d, { stream: true });
|
|
55567
|
+
if (a.startsWith("data: ")) a = a.slice(6).trim();
|
|
55574
55568
|
else break;
|
|
55575
|
-
|
|
55576
|
-
let c =
|
|
55577
|
-
`), tool_calls: c.length > 0 ? c : void 0 }, finish_reason:
|
|
55578
|
-
|
|
55569
|
+
f("gemini chunk:", a), a = JSON.parse(a);
|
|
55570
|
+
let c = a.candidates[0].content.parts.filter((v) => v.functionCall).map((v) => ({ id: v.functionCall?.id || `tool_${Math.random().toString(36).substring(2, 15)}`, type: "function", function: { name: v.functionCall?.name, arguments: JSON.stringify(v.functionCall?.args || {}) } })), y = { choices: [{ delta: { role: "assistant", content: a.candidates[0].content.parts.filter((v) => v.text).map((v) => v.text).join(`
|
|
55571
|
+
`), tool_calls: c.length > 0 ? c : void 0 }, finish_reason: a.candidates[0].finishReason?.toLowerCase() || null, index: a.candidates[0].index || c.length > 0 ? 1 : 0, logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: a.responseId || "", model: a.modelVersion || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1" };
|
|
55572
|
+
f("gemini response:", JSON.stringify(y, null, 2)), r.enqueue(n.encode(`data: ${JSON.stringify(y)}
|
|
55579
55573
|
|
|
55580
55574
|
`));
|
|
55581
55575
|
}
|
|
@@ -55590,7 +55584,7 @@ var I = class {
|
|
|
55590
55584
|
return e;
|
|
55591
55585
|
}
|
|
55592
55586
|
};
|
|
55593
|
-
var
|
|
55587
|
+
var H = class {
|
|
55594
55588
|
name = "deepseek";
|
|
55595
55589
|
transformRequestIn(e) {
|
|
55596
55590
|
return e.max_tokens && e.max_tokens > 8192 && (e.max_tokens = 8192), e;
|
|
@@ -55605,52 +55599,52 @@ var j = class {
|
|
|
55605
55599
|
let d = e.body.getReader();
|
|
55606
55600
|
try {
|
|
55607
55601
|
for (; ; ) {
|
|
55608
|
-
let { done:
|
|
55609
|
-
if (
|
|
55610
|
-
let
|
|
55602
|
+
let { done: a, value: c } = await d.read();
|
|
55603
|
+
if (a) break;
|
|
55604
|
+
let v = t.decode(c, { stream: true }).split(`
|
|
55611
55605
|
`);
|
|
55612
|
-
for (let
|
|
55613
|
-
let
|
|
55614
|
-
if (
|
|
55615
|
-
o +=
|
|
55616
|
-
let s = { ...
|
|
55606
|
+
for (let h of v) if (h.startsWith("data: ") && h.trim() !== "data: [DONE]") try {
|
|
55607
|
+
let p = JSON.parse(h.slice(6));
|
|
55608
|
+
if (p.choices?.[0]?.delta?.reasoning_content) {
|
|
55609
|
+
o += p.choices[0].delta.reasoning_content;
|
|
55610
|
+
let s = { ...p, choices: [{ ...p.choices[0], delta: { ...p.choices[0].delta, thinking: { content: p.choices[0].delta.reasoning_content } } }] };
|
|
55617
55611
|
delete s.choices[0].delta.reasoning_content;
|
|
55618
|
-
let
|
|
55612
|
+
let m = `data: ${JSON.stringify(s)}
|
|
55619
55613
|
|
|
55620
55614
|
`;
|
|
55621
|
-
u.enqueue(n.encode(
|
|
55615
|
+
u.enqueue(n.encode(m));
|
|
55622
55616
|
continue;
|
|
55623
55617
|
}
|
|
55624
|
-
if (
|
|
55618
|
+
if (p.choices?.[0]?.delta?.content && o && !r) {
|
|
55625
55619
|
r = true;
|
|
55626
|
-
let s = Date.now().toString(),
|
|
55627
|
-
delete
|
|
55628
|
-
let
|
|
55620
|
+
let s = Date.now().toString(), m = { ...p, choices: [{ ...p.choices[0], delta: { ...p.choices[0].delta, content: null, thinking: { content: o, signature: s } } }] };
|
|
55621
|
+
delete m.choices[0].delta.reasoning_content;
|
|
55622
|
+
let g = `data: ${JSON.stringify(m)}
|
|
55629
55623
|
|
|
55630
55624
|
`;
|
|
55631
|
-
u.enqueue(n.encode(
|
|
55625
|
+
u.enqueue(n.encode(g));
|
|
55632
55626
|
}
|
|
55633
|
-
if (
|
|
55634
|
-
r &&
|
|
55635
|
-
let s = `data: ${JSON.stringify(
|
|
55627
|
+
if (p.choices[0]?.delta?.reasoning_content && delete p.choices[0].delta.reasoning_content, p.choices?.[0]?.delta && Object.keys(p.choices[0].delta).length > 0) {
|
|
55628
|
+
r && p.choices[0].index++;
|
|
55629
|
+
let s = `data: ${JSON.stringify(p)}
|
|
55636
55630
|
|
|
55637
55631
|
`;
|
|
55638
55632
|
u.enqueue(n.encode(s));
|
|
55639
55633
|
}
|
|
55640
55634
|
} catch {
|
|
55641
|
-
u.enqueue(n.encode(
|
|
55635
|
+
u.enqueue(n.encode(h + `
|
|
55642
55636
|
`));
|
|
55643
55637
|
}
|
|
55644
|
-
else u.enqueue(n.encode(
|
|
55638
|
+
else u.enqueue(n.encode(h + `
|
|
55645
55639
|
`));
|
|
55646
55640
|
}
|
|
55647
|
-
} catch (
|
|
55648
|
-
u.error(
|
|
55641
|
+
} catch (a) {
|
|
55642
|
+
u.error(a);
|
|
55649
55643
|
} finally {
|
|
55650
55644
|
try {
|
|
55651
55645
|
d.releaseLock();
|
|
55652
|
-
} catch (
|
|
55653
|
-
console.error("Error releasing reader lock:",
|
|
55646
|
+
} catch (a) {
|
|
55647
|
+
console.error("Error releasing reader lock:", a);
|
|
55654
55648
|
}
|
|
55655
55649
|
u.close();
|
|
55656
55650
|
}
|
|
@@ -55660,7 +55654,7 @@ var j = class {
|
|
|
55660
55654
|
return e;
|
|
55661
55655
|
}
|
|
55662
55656
|
};
|
|
55663
|
-
var
|
|
55657
|
+
var $ = class {
|
|
55664
55658
|
name = "tooluse";
|
|
55665
55659
|
transformRequestIn(e) {
|
|
55666
55660
|
return e.messages.push({ role: "system", content: "<system-reminder>Tool mode is active. The user expects you to proactively execute the most suitable tool to help complete the task. \nBefore invoking a tool, you must carefully evaluate whether it matches the current task. If no available tool is appropriate for the task, you MUST call the `ExitTool` to exit tool mode \u2014 this is the only valid way to terminate tool mode.\nAlways prioritize completing the user's task effectively and efficiently by using tools whenever appropriate.</system-reminder>" }), e.tools?.length && (e.tool_choice = "required", e.tools.unshift({ type: "function", function: { name: "ExitTool", description: `Use this tool when you are in tool mode and have completed the task. This is the only valid way to exit tool mode.
|
|
@@ -55683,51 +55677,51 @@ Examples:
|
|
|
55683
55677
|
let d = e.body.getReader();
|
|
55684
55678
|
try {
|
|
55685
55679
|
for (; ; ) {
|
|
55686
|
-
let { done:
|
|
55687
|
-
if (
|
|
55688
|
-
let
|
|
55680
|
+
let { done: a, value: c } = await d.read();
|
|
55681
|
+
if (a) break;
|
|
55682
|
+
let v = t.decode(c, { stream: true }).split(`
|
|
55689
55683
|
`);
|
|
55690
|
-
for (let
|
|
55691
|
-
let
|
|
55692
|
-
if (
|
|
55693
|
-
let s =
|
|
55684
|
+
for (let h of v) if (h.startsWith("data: ") && h.trim() !== "data: [DONE]") try {
|
|
55685
|
+
let p = JSON.parse(h.slice(6));
|
|
55686
|
+
if (p.choices[0]?.delta?.tool_calls?.length) {
|
|
55687
|
+
let s = p.choices[0].delta.tool_calls[0];
|
|
55694
55688
|
if (s.function?.name === "ExitTool") {
|
|
55695
55689
|
o = s.index;
|
|
55696
55690
|
continue;
|
|
55697
55691
|
} else if (o > -1 && s.index === o && s.function.arguments) {
|
|
55698
55692
|
r += s.function.arguments;
|
|
55699
55693
|
try {
|
|
55700
|
-
let
|
|
55701
|
-
|
|
55702
|
-
let
|
|
55694
|
+
let m = JSON.parse(r);
|
|
55695
|
+
p.choices = [{ delta: { role: "assistant", content: m.response || "" } }];
|
|
55696
|
+
let g = `data: ${JSON.stringify(p)}
|
|
55703
55697
|
|
|
55704
55698
|
`;
|
|
55705
|
-
u.enqueue(n.encode(
|
|
55699
|
+
u.enqueue(n.encode(g));
|
|
55706
55700
|
} catch {
|
|
55707
55701
|
}
|
|
55708
55702
|
continue;
|
|
55709
55703
|
}
|
|
55710
55704
|
}
|
|
55711
|
-
if (
|
|
55712
|
-
let s = `data: ${JSON.stringify(
|
|
55705
|
+
if (p.choices?.[0]?.delta && Object.keys(p.choices[0].delta).length > 0) {
|
|
55706
|
+
let s = `data: ${JSON.stringify(p)}
|
|
55713
55707
|
|
|
55714
55708
|
`;
|
|
55715
55709
|
u.enqueue(n.encode(s));
|
|
55716
55710
|
}
|
|
55717
55711
|
} catch {
|
|
55718
|
-
u.enqueue(n.encode(
|
|
55712
|
+
u.enqueue(n.encode(h + `
|
|
55719
55713
|
`));
|
|
55720
55714
|
}
|
|
55721
|
-
else u.enqueue(n.encode(
|
|
55715
|
+
else u.enqueue(n.encode(h + `
|
|
55722
55716
|
`));
|
|
55723
55717
|
}
|
|
55724
|
-
} catch (
|
|
55725
|
-
u.error(
|
|
55718
|
+
} catch (a) {
|
|
55719
|
+
u.error(a);
|
|
55726
55720
|
} finally {
|
|
55727
55721
|
try {
|
|
55728
55722
|
d.releaseLock();
|
|
55729
|
-
} catch (
|
|
55730
|
-
console.error("Error releasing reader lock:",
|
|
55723
|
+
} catch (a) {
|
|
55724
|
+
console.error("Error releasing reader lock:", a);
|
|
55731
55725
|
}
|
|
55732
55726
|
u.close();
|
|
55733
55727
|
}
|
|
@@ -55737,7 +55731,7 @@ Examples:
|
|
|
55737
55731
|
return e;
|
|
55738
55732
|
}
|
|
55739
55733
|
};
|
|
55740
|
-
var
|
|
55734
|
+
var F = class {
|
|
55741
55735
|
name = "openrouter";
|
|
55742
55736
|
transformRequestIn(e) {
|
|
55743
55737
|
return e.model.includes("claude") || e.messages.forEach((t) => {
|
|
@@ -55753,51 +55747,51 @@ var J = class {
|
|
|
55753
55747
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55754
55748
|
if (!e.body) return e;
|
|
55755
55749
|
let t = new TextDecoder(), n = new TextEncoder(), o = false, r = "", l = false, u = new ReadableStream({ async start(d) {
|
|
55756
|
-
let
|
|
55750
|
+
let a = e.body.getReader();
|
|
55757
55751
|
try {
|
|
55758
55752
|
for (; ; ) {
|
|
55759
|
-
let { done: c, value:
|
|
55753
|
+
let { done: c, value: y } = await a.read();
|
|
55760
55754
|
if (c) break;
|
|
55761
|
-
let
|
|
55755
|
+
let h = t.decode(y, { stream: true }).split(`
|
|
55762
55756
|
`);
|
|
55763
|
-
for (let
|
|
55764
|
-
let s = JSON.parse(
|
|
55757
|
+
for (let p of h) if (p.startsWith("data: ") && p.trim() !== "data: [DONE]") try {
|
|
55758
|
+
let s = JSON.parse(p.slice(6));
|
|
55765
55759
|
if (s.choices[0]?.delta?.content && !o && (o = true), s.choices?.[0]?.delta?.reasoning) {
|
|
55766
55760
|
r += s.choices[0].delta.reasoning;
|
|
55767
|
-
let
|
|
55768
|
-
delete
|
|
55769
|
-
let
|
|
55761
|
+
let g = { ...s, choices: [{ ...s.choices[0], delta: { ...s.choices[0].delta, thinking: { content: s.choices[0].delta.reasoning } } }] };
|
|
55762
|
+
delete g.choices[0].delta.reasoning;
|
|
55763
|
+
let k = `data: ${JSON.stringify(g)}
|
|
55770
55764
|
|
|
55771
55765
|
`;
|
|
55772
|
-
d.enqueue(n.encode(
|
|
55766
|
+
d.enqueue(n.encode(k));
|
|
55773
55767
|
continue;
|
|
55774
55768
|
}
|
|
55775
55769
|
if (s.choices?.[0]?.delta?.content && r && !l) {
|
|
55776
55770
|
l = true;
|
|
55777
|
-
let
|
|
55778
|
-
delete
|
|
55779
|
-
let
|
|
55771
|
+
let g = Date.now().toString(), k = { ...s, choices: [{ ...s.choices[0], delta: { ...s.choices[0].delta, content: null, thinking: { content: r, signature: g } } }] };
|
|
55772
|
+
delete k.choices[0].delta.reasoning;
|
|
55773
|
+
let D = `data: ${JSON.stringify(k)}
|
|
55780
55774
|
|
|
55781
55775
|
`;
|
|
55782
|
-
d.enqueue(n.encode(
|
|
55776
|
+
d.enqueue(n.encode(D));
|
|
55783
55777
|
}
|
|
55784
55778
|
s.choices[0]?.delta?.reasoning && delete s.choices[0].delta.reasoning, s.choices[0]?.delta?.tool_calls?.length && o && (s.choices[0].index += 1);
|
|
55785
|
-
let
|
|
55779
|
+
let m = `data: ${JSON.stringify(s)}
|
|
55786
55780
|
|
|
55787
55781
|
`;
|
|
55788
|
-
d.enqueue(n.encode(
|
|
55782
|
+
d.enqueue(n.encode(m));
|
|
55789
55783
|
} catch {
|
|
55790
|
-
d.enqueue(n.encode(
|
|
55784
|
+
d.enqueue(n.encode(p + `
|
|
55791
55785
|
`));
|
|
55792
55786
|
}
|
|
55793
|
-
else d.enqueue(n.encode(
|
|
55787
|
+
else d.enqueue(n.encode(p + `
|
|
55794
55788
|
`));
|
|
55795
55789
|
}
|
|
55796
55790
|
} catch (c) {
|
|
55797
55791
|
d.error(c);
|
|
55798
55792
|
} finally {
|
|
55799
55793
|
try {
|
|
55800
|
-
|
|
55794
|
+
a.releaseLock();
|
|
55801
55795
|
} catch (c) {
|
|
55802
55796
|
console.error("Error releasing reader lock:", c);
|
|
55803
55797
|
}
|
|
@@ -55810,24 +55804,13 @@ var J = class {
|
|
|
55810
55804
|
}
|
|
55811
55805
|
};
|
|
55812
55806
|
var U = class {
|
|
55813
|
-
constructor(e) {
|
|
55814
|
-
this.options = e;
|
|
55815
|
-
this.max_tokens = this.options?.max_tokens;
|
|
55816
|
-
}
|
|
55817
|
-
static TransformerName = "maxtoken";
|
|
55818
|
-
max_tokens;
|
|
55819
|
-
transformRequestIn(e) {
|
|
55820
|
-
return e.max_tokens && e.max_tokens > this.max_tokens && (e.max_tokens = this.max_tokens), e;
|
|
55821
|
-
}
|
|
55822
|
-
};
|
|
55823
|
-
var ne = { AnthropicTransformer: F, GeminiTransformer: I, DeepseekTransformer: j, TooluseTransformer: q, OpenrouterTransformer: J, MaxTokenTransformer: U };
|
|
55824
|
-
var D = class {
|
|
55825
55807
|
constructor(e) {
|
|
55826
55808
|
this.configService = e;
|
|
55809
|
+
this.initialize();
|
|
55827
55810
|
}
|
|
55828
55811
|
transformers = /* @__PURE__ */ new Map();
|
|
55829
55812
|
registerTransformer(e, t) {
|
|
55830
|
-
this.transformers.set(e, t),
|
|
55813
|
+
this.transformers.set(e, t), f(`register transformer: ${e}${t.endPoint ? ` (endpoint: ${t.endPoint})` : " (no endpoint)"}`);
|
|
55831
55814
|
}
|
|
55832
55815
|
getTransformer(e) {
|
|
55833
55816
|
return this.transformers.get(e);
|
|
@@ -55855,40 +55838,32 @@ var D = class {
|
|
|
55855
55838
|
}
|
|
55856
55839
|
async registerTransformerFromConfig(e) {
|
|
55857
55840
|
try {
|
|
55858
|
-
|
|
55859
|
-
|
|
55860
|
-
|
|
55861
|
-
|
|
55862
|
-
|
|
55863
|
-
|
|
55864
|
-
let o = new n(e.options);
|
|
55865
|
-
if (!o.name) throw new Error(`Transformer instance from ${e.path} does not have a name property.`);
|
|
55866
|
-
return this.registerTransformer(o.name, o), true;
|
|
55841
|
+
if (e.path) {
|
|
55842
|
+
let t = V(e.path);
|
|
55843
|
+
if (t) {
|
|
55844
|
+
let n = new t(e.options);
|
|
55845
|
+
if (!n.name) throw new Error(`Transformer instance from ${e.path} does not have a name property.`);
|
|
55846
|
+
return this.registerTransformer(n.name, n), true;
|
|
55867
55847
|
}
|
|
55868
55848
|
}
|
|
55869
55849
|
return false;
|
|
55870
55850
|
} catch (t) {
|
|
55871
|
-
return
|
|
55851
|
+
return f(`load transformer (${e.path}):`, t), false;
|
|
55872
55852
|
}
|
|
55873
55853
|
}
|
|
55874
55854
|
async initialize() {
|
|
55875
55855
|
try {
|
|
55876
55856
|
await this.registerDefaultTransformersInternal(), await this.loadFromConfig();
|
|
55877
55857
|
} catch (e) {
|
|
55878
|
-
|
|
55858
|
+
f("TransformerService init error:", e);
|
|
55879
55859
|
}
|
|
55880
55860
|
}
|
|
55881
55861
|
async registerDefaultTransformersInternal() {
|
|
55882
55862
|
try {
|
|
55883
|
-
|
|
55884
|
-
|
|
55885
|
-
else {
|
|
55886
|
-
let t = new e();
|
|
55887
|
-
this.registerTransformer(t.name, t);
|
|
55888
|
-
}
|
|
55889
|
-
});
|
|
55863
|
+
let e = new M(), t = new N(), n = new H(), o = new $(), r = new F();
|
|
55864
|
+
this.registerTransformer(e.name, e), this.registerTransformer(t.name, t), this.registerTransformer(n.name, n), this.registerTransformer(o.name, o), this.registerTransformer(r.name, r);
|
|
55890
55865
|
} catch (e) {
|
|
55891
|
-
|
|
55866
|
+
f("transformer regist error:", e);
|
|
55892
55867
|
}
|
|
55893
55868
|
}
|
|
55894
55869
|
async loadFromConfig() {
|
|
@@ -55896,20 +55871,18 @@ var D = class {
|
|
|
55896
55871
|
for (let t of e) await this.registerTransformerFromConfig(t);
|
|
55897
55872
|
}
|
|
55898
55873
|
};
|
|
55899
|
-
function
|
|
55900
|
-
let
|
|
55901
|
-
return
|
|
55874
|
+
function le() {
|
|
55875
|
+
let i = (0, import_fastify.default)({});
|
|
55876
|
+
return i.setErrorHandler(X), i.register(import_cors.default), i;
|
|
55902
55877
|
}
|
|
55903
|
-
var
|
|
55878
|
+
var B = class {
|
|
55904
55879
|
app;
|
|
55905
55880
|
configService;
|
|
55906
55881
|
llmService;
|
|
55907
55882
|
providerService;
|
|
55908
55883
|
transformerService;
|
|
55909
55884
|
constructor(e = {}) {
|
|
55910
|
-
this.configService = new
|
|
55911
|
-
this.providerService = new $(this.configService, this.transformerService), this.llmService = new H(this.providerService);
|
|
55912
|
-
}), this.app = pe();
|
|
55885
|
+
this.configService = new j(e), this.providerService = new J(this.configService), this.llmService = new q(this.providerService), this.transformerService = new U(this.configService), this.app = le();
|
|
55913
55886
|
}
|
|
55914
55887
|
async register(e, t) {
|
|
55915
55888
|
await this.app.register(e, t);
|
|
@@ -55929,23 +55902,23 @@ var G = class {
|
|
|
55929
55902
|
} catch (r) {
|
|
55930
55903
|
return n.log.error("Error in modelProviderMiddleware:", r), o.code(500).send({ error: "Internal server error" });
|
|
55931
55904
|
}
|
|
55932
|
-
}), this.app.register(
|
|
55905
|
+
}), this.app.register(Z);
|
|
55933
55906
|
let e = await this.app.listen({ port: parseInt(this.configService.get("PORT") || "3000", 10), host: this.configService.get("HOST") || "127.0.0.1" });
|
|
55934
|
-
|
|
55907
|
+
f(`\u{1F680} LLMs API server listening on ${e}`);
|
|
55935
55908
|
let t = async (n) => {
|
|
55936
|
-
|
|
55909
|
+
f(`Received ${n}, shutting down gracefully...`), await this.app.close(), process.exit(0);
|
|
55937
55910
|
};
|
|
55938
55911
|
process.on("SIGINT", () => t("SIGINT")), process.on("SIGTERM", () => t("SIGTERM"));
|
|
55939
55912
|
} catch (e) {
|
|
55940
|
-
|
|
55913
|
+
f(`Error starting server: ${e}`), process.exit(1);
|
|
55941
55914
|
}
|
|
55942
55915
|
}
|
|
55943
55916
|
};
|
|
55944
|
-
var
|
|
55917
|
+
var xt = B;
|
|
55945
55918
|
|
|
55946
55919
|
// src/server.ts
|
|
55947
55920
|
var createServer = (config) => {
|
|
55948
|
-
const server = new
|
|
55921
|
+
const server = new xt(config);
|
|
55949
55922
|
return server;
|
|
55950
55923
|
};
|
|
55951
55924
|
|
|
@@ -56125,8 +56098,8 @@ function getServiceInfo() {
|
|
|
56125
56098
|
|
|
56126
56099
|
// src/index.ts
|
|
56127
56100
|
async function initializeClaudeConfig() {
|
|
56128
|
-
const homeDir =
|
|
56129
|
-
const configPath =
|
|
56101
|
+
const homeDir = (0, import_os.homedir)();
|
|
56102
|
+
const configPath = (0, import_path2.join)(homeDir, ".claude.json");
|
|
56130
56103
|
if (!(0, import_fs3.existsSync)(configPath)) {
|
|
56131
56104
|
const userID = Array.from(
|
|
56132
56105
|
{ length: 64 },
|
|
@@ -56264,11 +56237,12 @@ async function executeCodeCommand(args = []) {
|
|
|
56264
56237
|
}
|
|
56265
56238
|
|
|
56266
56239
|
// package.json
|
|
56267
|
-
var version = "1.0.
|
|
56240
|
+
var version = "1.0.17";
|
|
56268
56241
|
|
|
56269
56242
|
// src/cli.ts
|
|
56270
56243
|
var import_child_process2 = require("child_process");
|
|
56271
56244
|
var import_fs5 = require("fs");
|
|
56245
|
+
var import_path4 = require("path");
|
|
56272
56246
|
var command = process.argv[2];
|
|
56273
56247
|
var HELP_TEXT = `
|
|
56274
56248
|
Usage: ccr [command]
|
|
@@ -56329,7 +56303,8 @@ async function main() {
|
|
|
56329
56303
|
case "code":
|
|
56330
56304
|
if (!isServiceRunning()) {
|
|
56331
56305
|
console.log("Service not running, starting service...");
|
|
56332
|
-
const
|
|
56306
|
+
const cliPath = (0, import_path4.join)(__dirname, "cli.js");
|
|
56307
|
+
const startProcess = (0, import_child_process2.spawn)("node", [cliPath, "start"], {
|
|
56333
56308
|
detached: true,
|
|
56334
56309
|
stdio: "ignore"
|
|
56335
56310
|
});
|