@musistudio/claude-code-router 1.0.12 → 1.0.13
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 +683 -636
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -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(f, args, opts) {
|
|
4315
4315
|
var ss = opts && opts.stringify || tryStringify;
|
|
4316
4316
|
var offset = 1;
|
|
4317
|
-
if (typeof
|
|
4317
|
+
if (typeof f === "object" && f !== null) {
|
|
4318
4318
|
var len = args.length + offset;
|
|
4319
|
-
if (len === 1) return
|
|
4319
|
+
if (len === 1) return f;
|
|
4320
4320
|
var objects = new Array(len);
|
|
4321
|
-
objects[0] = ss(
|
|
4321
|
+
objects[0] = ss(f);
|
|
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 f !== "string") {
|
|
4328
|
+
return f;
|
|
4329
4329
|
}
|
|
4330
4330
|
var argLen = args.length;
|
|
4331
|
-
if (argLen === 0) return
|
|
4331
|
+
if (argLen === 0) return f;
|
|
4332
4332
|
var str = "";
|
|
4333
4333
|
var a = 1 - offset;
|
|
4334
4334
|
var lastPos = -1;
|
|
4335
|
-
var flen =
|
|
4335
|
+
var flen = f && f.length || 0;
|
|
4336
4336
|
for (var i = 0; i < flen; ) {
|
|
4337
|
-
if (
|
|
4337
|
+
if (f.charCodeAt(i) === 37 && i + 1 < flen) {
|
|
4338
4338
|
lastPos = lastPos > -1 ? lastPos : 0;
|
|
4339
|
-
switch (
|
|
4339
|
+
switch (f.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 += f.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 += f.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 += f.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 += f.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 += f.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 f;
|
|
4413
4413
|
else if (lastPos < flen) {
|
|
4414
|
-
str +=
|
|
4414
|
+
str += f.slice(lastPos);
|
|
4415
4415
|
}
|
|
4416
4416
|
return str;
|
|
4417
4417
|
}
|
|
@@ -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, f) {
|
|
13192
13192
|
if (Array.isArray(xs)) {
|
|
13193
13193
|
for (const x of xs)
|
|
13194
|
-
|
|
13194
|
+
f(x);
|
|
13195
13195
|
} else {
|
|
13196
|
-
|
|
13196
|
+
f(xs);
|
|
13197
13197
|
}
|
|
13198
13198
|
}
|
|
13199
13199
|
exports2.eachItem = eachItem;
|
|
@@ -13240,10 +13240,10 @@ var require_util = __commonJS({
|
|
|
13240
13240
|
}
|
|
13241
13241
|
exports2.setEvaluated = setEvaluated;
|
|
13242
13242
|
var snippets = {};
|
|
13243
|
-
function useFunc(gen,
|
|
13243
|
+
function useFunc(gen, f) {
|
|
13244
13244
|
return gen.scopeValue("func", {
|
|
13245
|
-
ref:
|
|
13246
|
-
code: snippets[
|
|
13245
|
+
ref: f,
|
|
13246
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1._Code(f.code))
|
|
13247
13247
|
});
|
|
13248
13248
|
}
|
|
13249
13249
|
exports2.useFunc = useFunc;
|
|
@@ -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 f = formats[name];
|
|
18778
|
+
if (!f)
|
|
18779
18779
|
throw new Error(`Unknown format "${name}"`);
|
|
18780
|
-
return
|
|
18780
|
+
return f;
|
|
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 f of list)
|
|
18787
|
+
ajv.addFormat(f, fs3[f]);
|
|
18788
18788
|
}
|
|
18789
18789
|
module2.exports = exports2 = formatsPlugin;
|
|
18790
18790
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -21498,10 +21498,10 @@ var require_timestamp = __commonJS({
|
|
|
21498
21498
|
if (!matches)
|
|
21499
21499
|
return false;
|
|
21500
21500
|
const y = +matches[1];
|
|
21501
|
-
const
|
|
21501
|
+
const m2 = +matches[2];
|
|
21502
21502
|
const d = +matches[3];
|
|
21503
|
-
return
|
|
21504
|
-
|
|
21503
|
+
return m2 >= 1 && m2 <= 12 && d >= 1 && (d <= DAYS[m2] || // leap year: https://tools.ietf.org/html/rfc3339#appendix-C
|
|
21504
|
+
m2 === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0));
|
|
21505
21505
|
}
|
|
21506
21506
|
function validTime(str) {
|
|
21507
21507
|
const matches = TIME.exec(str);
|
|
@@ -23652,14 +23652,14 @@ var require_semver = __commonJS({
|
|
|
23652
23652
|
this.options = options;
|
|
23653
23653
|
this.loose = !!options.loose;
|
|
23654
23654
|
this.includePrerelease = !!options.includePrerelease;
|
|
23655
|
-
const
|
|
23656
|
-
if (!
|
|
23655
|
+
const m2 = version2.trim().match(options.loose ? re2[t.LOOSE] : re2[t.FULL]);
|
|
23656
|
+
if (!m2) {
|
|
23657
23657
|
throw new TypeError(`Invalid Version: ${version2}`);
|
|
23658
23658
|
}
|
|
23659
23659
|
this.raw = version2;
|
|
23660
|
-
this.major = +
|
|
23661
|
-
this.minor = +
|
|
23662
|
-
this.patch = +
|
|
23660
|
+
this.major = +m2[1];
|
|
23661
|
+
this.minor = +m2[2];
|
|
23662
|
+
this.patch = +m2[3];
|
|
23663
23663
|
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
23664
23664
|
throw new TypeError("Invalid major version");
|
|
23665
23665
|
}
|
|
@@ -23669,10 +23669,10 @@ var require_semver = __commonJS({
|
|
|
23669
23669
|
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
23670
23670
|
throw new TypeError("Invalid patch version");
|
|
23671
23671
|
}
|
|
23672
|
-
if (!
|
|
23672
|
+
if (!m2[4]) {
|
|
23673
23673
|
this.prerelease = [];
|
|
23674
23674
|
} else {
|
|
23675
|
-
this.prerelease =
|
|
23675
|
+
this.prerelease = m2[4].split(".").map((id2) => {
|
|
23676
23676
|
if (/^[0-9]+$/.test(id2)) {
|
|
23677
23677
|
const num = +id2;
|
|
23678
23678
|
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
@@ -23682,7 +23682,7 @@ var require_semver = __commonJS({
|
|
|
23682
23682
|
return id2;
|
|
23683
23683
|
});
|
|
23684
23684
|
}
|
|
23685
|
-
this.build =
|
|
23685
|
+
this.build = m2[5] ? m2[5].split(".") : [];
|
|
23686
23686
|
this.format();
|
|
23687
23687
|
}
|
|
23688
23688
|
format() {
|
|
@@ -24490,20 +24490,20 @@ var require_range = __commonJS({
|
|
|
24490
24490
|
};
|
|
24491
24491
|
var replaceTilde = (comp, options) => {
|
|
24492
24492
|
const r = options.loose ? re2[t.TILDELOOSE] : re2[t.TILDE];
|
|
24493
|
-
return comp.replace(r, (_,
|
|
24494
|
-
debug("tilde", comp, _,
|
|
24493
|
+
return comp.replace(r, (_, M2, m2, p, pr) => {
|
|
24494
|
+
debug("tilde", comp, _, M2, m2, p, pr);
|
|
24495
24495
|
let ret;
|
|
24496
|
-
if (isX(
|
|
24496
|
+
if (isX(M2)) {
|
|
24497
24497
|
ret = "";
|
|
24498
|
-
} else if (isX(
|
|
24499
|
-
ret = `>=${
|
|
24498
|
+
} else if (isX(m2)) {
|
|
24499
|
+
ret = `>=${M2}.0.0 <${+M2 + 1}.0.0-0`;
|
|
24500
24500
|
} else if (isX(p)) {
|
|
24501
|
-
ret = `>=${
|
|
24501
|
+
ret = `>=${M2}.${m2}.0 <${M2}.${+m2 + 1}.0-0`;
|
|
24502
24502
|
} else if (pr) {
|
|
24503
24503
|
debug("replaceTilde pr", pr);
|
|
24504
|
-
ret = `>=${
|
|
24504
|
+
ret = `>=${M2}.${m2}.${p}-${pr} <${M2}.${+m2 + 1}.0-0`;
|
|
24505
24505
|
} else {
|
|
24506
|
-
ret = `>=${
|
|
24506
|
+
ret = `>=${M2}.${m2}.${p} <${M2}.${+m2 + 1}.0-0`;
|
|
24507
24507
|
}
|
|
24508
24508
|
debug("tilde return", ret);
|
|
24509
24509
|
return ret;
|
|
@@ -24515,41 +24515,41 @@ var require_range = __commonJS({
|
|
|
24515
24515
|
var replaceCaret = (comp, options) => {
|
|
24516
24516
|
debug("caret", comp, options);
|
|
24517
24517
|
const r = options.loose ? re2[t.CARETLOOSE] : re2[t.CARET];
|
|
24518
|
-
const
|
|
24519
|
-
return comp.replace(r, (_,
|
|
24520
|
-
debug("caret", comp, _,
|
|
24518
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
24519
|
+
return comp.replace(r, (_, M2, m2, p, pr) => {
|
|
24520
|
+
debug("caret", comp, _, M2, m2, p, pr);
|
|
24521
24521
|
let ret;
|
|
24522
|
-
if (isX(
|
|
24522
|
+
if (isX(M2)) {
|
|
24523
24523
|
ret = "";
|
|
24524
|
-
} else if (isX(
|
|
24525
|
-
ret = `>=${
|
|
24524
|
+
} else if (isX(m2)) {
|
|
24525
|
+
ret = `>=${M2}.0.0${z} <${+M2 + 1}.0.0-0`;
|
|
24526
24526
|
} else if (isX(p)) {
|
|
24527
|
-
if (
|
|
24528
|
-
ret = `>=${
|
|
24527
|
+
if (M2 === "0") {
|
|
24528
|
+
ret = `>=${M2}.${m2}.0${z} <${M2}.${+m2 + 1}.0-0`;
|
|
24529
24529
|
} else {
|
|
24530
|
-
ret = `>=${
|
|
24530
|
+
ret = `>=${M2}.${m2}.0${z} <${+M2 + 1}.0.0-0`;
|
|
24531
24531
|
}
|
|
24532
24532
|
} else if (pr) {
|
|
24533
24533
|
debug("replaceCaret pr", pr);
|
|
24534
|
-
if (
|
|
24535
|
-
if (
|
|
24536
|
-
ret = `>=${
|
|
24534
|
+
if (M2 === "0") {
|
|
24535
|
+
if (m2 === "0") {
|
|
24536
|
+
ret = `>=${M2}.${m2}.${p}-${pr} <${M2}.${m2}.${+p + 1}-0`;
|
|
24537
24537
|
} else {
|
|
24538
|
-
ret = `>=${
|
|
24538
|
+
ret = `>=${M2}.${m2}.${p}-${pr} <${M2}.${+m2 + 1}.0-0`;
|
|
24539
24539
|
}
|
|
24540
24540
|
} else {
|
|
24541
|
-
ret = `>=${
|
|
24541
|
+
ret = `>=${M2}.${m2}.${p}-${pr} <${+M2 + 1}.0.0-0`;
|
|
24542
24542
|
}
|
|
24543
24543
|
} else {
|
|
24544
24544
|
debug("no pr");
|
|
24545
|
-
if (
|
|
24546
|
-
if (
|
|
24547
|
-
ret = `>=${
|
|
24545
|
+
if (M2 === "0") {
|
|
24546
|
+
if (m2 === "0") {
|
|
24547
|
+
ret = `>=${M2}.${m2}.${p}${z} <${M2}.${m2}.${+p + 1}-0`;
|
|
24548
24548
|
} else {
|
|
24549
|
-
ret = `>=${
|
|
24549
|
+
ret = `>=${M2}.${m2}.${p}${z} <${M2}.${+m2 + 1}.0-0`;
|
|
24550
24550
|
}
|
|
24551
24551
|
} else {
|
|
24552
|
-
ret = `>=${
|
|
24552
|
+
ret = `>=${M2}.${m2}.${p} <${+M2 + 1}.0.0-0`;
|
|
24553
24553
|
}
|
|
24554
24554
|
}
|
|
24555
24555
|
debug("caret return", ret);
|
|
@@ -24563,10 +24563,10 @@ var require_range = __commonJS({
|
|
|
24563
24563
|
var replaceXRange = (comp, options) => {
|
|
24564
24564
|
comp = comp.trim();
|
|
24565
24565
|
const r = options.loose ? re2[t.XRANGELOOSE] : re2[t.XRANGE];
|
|
24566
|
-
return comp.replace(r, (ret, gtlt,
|
|
24567
|
-
debug("xRange", comp, ret, gtlt,
|
|
24568
|
-
const xM = isX(
|
|
24569
|
-
const xm = xM || isX(
|
|
24566
|
+
return comp.replace(r, (ret, gtlt, M2, m2, p, pr) => {
|
|
24567
|
+
debug("xRange", comp, ret, gtlt, M2, m2, p, pr);
|
|
24568
|
+
const xM = isX(M2);
|
|
24569
|
+
const xm = xM || isX(m2);
|
|
24570
24570
|
const xp = xm || isX(p);
|
|
24571
24571
|
const anyX = xp;
|
|
24572
24572
|
if (gtlt === "=" && anyX) {
|
|
@@ -24581,35 +24581,35 @@ var require_range = __commonJS({
|
|
|
24581
24581
|
}
|
|
24582
24582
|
} else if (gtlt && anyX) {
|
|
24583
24583
|
if (xm) {
|
|
24584
|
-
|
|
24584
|
+
m2 = 0;
|
|
24585
24585
|
}
|
|
24586
24586
|
p = 0;
|
|
24587
24587
|
if (gtlt === ">") {
|
|
24588
24588
|
gtlt = ">=";
|
|
24589
24589
|
if (xm) {
|
|
24590
|
-
|
|
24591
|
-
|
|
24590
|
+
M2 = +M2 + 1;
|
|
24591
|
+
m2 = 0;
|
|
24592
24592
|
p = 0;
|
|
24593
24593
|
} else {
|
|
24594
|
-
|
|
24594
|
+
m2 = +m2 + 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
|
+
m2 = +m2 + 1;
|
|
24603
24603
|
}
|
|
24604
24604
|
}
|
|
24605
24605
|
if (gtlt === "<") {
|
|
24606
24606
|
pr = "-0";
|
|
24607
24607
|
}
|
|
24608
|
-
ret = `${gtlt +
|
|
24608
|
+
ret = `${gtlt + M2}.${m2}.${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}.${m2}.0${pr} <${M2}.${+m2 + 1}.0-0`;
|
|
24613
24613
|
}
|
|
24614
24614
|
debug("xRange return", ret);
|
|
24615
24615
|
return ret;
|
|
@@ -24708,18 +24708,18 @@ var require_comparator = __commonJS({
|
|
|
24708
24708
|
}
|
|
24709
24709
|
parse(comp) {
|
|
24710
24710
|
const r = this.options.loose ? re2[t.COMPARATORLOOSE] : re2[t.COMPARATOR];
|
|
24711
|
-
const
|
|
24712
|
-
if (!
|
|
24711
|
+
const m2 = comp.match(r);
|
|
24712
|
+
if (!m2) {
|
|
24713
24713
|
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
24714
24714
|
}
|
|
24715
|
-
this.operator =
|
|
24715
|
+
this.operator = m2[1] !== void 0 ? m2[1] : "";
|
|
24716
24716
|
if (this.operator === "=") {
|
|
24717
24717
|
this.operator = "";
|
|
24718
24718
|
}
|
|
24719
|
-
if (!
|
|
24719
|
+
if (!m2[2]) {
|
|
24720
24720
|
this.semver = ANY;
|
|
24721
24721
|
} else {
|
|
24722
|
-
this.semver = new SemVer(
|
|
24722
|
+
this.semver = new SemVer(m2[2], this.options.loose);
|
|
24723
24723
|
}
|
|
24724
24724
|
}
|
|
24725
24725
|
toString() {
|
|
@@ -26377,17 +26377,17 @@ var require_set_lookup = __commonJS({
|
|
|
26377
26377
|
var require_types4 = __commonJS({
|
|
26378
26378
|
"node_modules/.pnpm/ret@0.5.0/node_modules/ret/dist/types/index.js"(exports2) {
|
|
26379
26379
|
"use strict";
|
|
26380
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o,
|
|
26380
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
26381
26381
|
if (k2 === void 0) k2 = k;
|
|
26382
26382
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26383
|
-
return
|
|
26383
|
+
return m2[k];
|
|
26384
26384
|
} });
|
|
26385
|
-
} : function(o,
|
|
26385
|
+
} : function(o, m2, k, k2) {
|
|
26386
26386
|
if (k2 === void 0) k2 = k;
|
|
26387
|
-
o[k2] =
|
|
26387
|
+
o[k2] = m2[k];
|
|
26388
26388
|
});
|
|
26389
|
-
var __exportStar = exports2 && exports2.__exportStar || function(
|
|
26390
|
-
for (var p in
|
|
26389
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m2, exports3) {
|
|
26390
|
+
for (var p in m2) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m2, p);
|
|
26391
26391
|
};
|
|
26392
26392
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26393
26393
|
__exportStar(require_tokens(), exports2);
|
|
@@ -26447,14 +26447,14 @@ var require_sets = __commonJS({
|
|
|
26447
26447
|
var require_util2 = __commonJS({
|
|
26448
26448
|
"node_modules/.pnpm/ret@0.5.0/node_modules/ret/dist/util.js"(exports2) {
|
|
26449
26449
|
"use strict";
|
|
26450
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o,
|
|
26450
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
26451
26451
|
if (k2 === void 0) k2 = k;
|
|
26452
26452
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26453
|
-
return
|
|
26453
|
+
return m2[k];
|
|
26454
26454
|
} });
|
|
26455
|
-
} : function(o,
|
|
26455
|
+
} : function(o, m2, k, k2) {
|
|
26456
26456
|
if (k2 === void 0) k2 = k;
|
|
26457
|
-
o[k2] =
|
|
26457
|
+
o[k2] = m2[k];
|
|
26458
26458
|
});
|
|
26459
26459
|
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
|
|
26460
26460
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
@@ -26518,14 +26518,14 @@ var require_util2 = __commonJS({
|
|
|
26518
26518
|
var require_tokenizer = __commonJS({
|
|
26519
26519
|
"node_modules/.pnpm/ret@0.5.0/node_modules/ret/dist/tokenizer.js"(exports2) {
|
|
26520
26520
|
"use strict";
|
|
26521
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o,
|
|
26521
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
26522
26522
|
if (k2 === void 0) k2 = k;
|
|
26523
26523
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26524
|
-
return
|
|
26524
|
+
return m2[k];
|
|
26525
26525
|
} });
|
|
26526
|
-
} : function(o,
|
|
26526
|
+
} : function(o, m2, k, k2) {
|
|
26527
26527
|
if (k2 === void 0) k2 = k;
|
|
26528
|
-
o[k2] =
|
|
26528
|
+
o[k2] = m2[k];
|
|
26529
26529
|
});
|
|
26530
26530
|
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
|
|
26531
26531
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
@@ -26819,14 +26819,14 @@ var require_tokenizer = __commonJS({
|
|
|
26819
26819
|
var require_sets_lookup = __commonJS({
|
|
26820
26820
|
"node_modules/.pnpm/ret@0.5.0/node_modules/ret/dist/sets-lookup.js"(exports2) {
|
|
26821
26821
|
"use strict";
|
|
26822
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o,
|
|
26822
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
26823
26823
|
if (k2 === void 0) k2 = k;
|
|
26824
26824
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26825
|
-
return
|
|
26825
|
+
return m2[k];
|
|
26826
26826
|
} });
|
|
26827
|
-
} : function(o,
|
|
26827
|
+
} : function(o, m2, k, k2) {
|
|
26828
26828
|
if (k2 === void 0) k2 = k;
|
|
26829
|
-
o[k2] =
|
|
26829
|
+
o[k2] = m2[k];
|
|
26830
26830
|
});
|
|
26831
26831
|
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
|
|
26832
26832
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
@@ -26874,14 +26874,14 @@ var require_sets_lookup = __commonJS({
|
|
|
26874
26874
|
var require_write_set_tokens = __commonJS({
|
|
26875
26875
|
"node_modules/.pnpm/ret@0.5.0/node_modules/ret/dist/write-set-tokens.js"(exports2) {
|
|
26876
26876
|
"use strict";
|
|
26877
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o,
|
|
26877
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
26878
26878
|
if (k2 === void 0) k2 = k;
|
|
26879
26879
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26880
|
-
return
|
|
26880
|
+
return m2[k];
|
|
26881
26881
|
} });
|
|
26882
|
-
} : function(o,
|
|
26882
|
+
} : function(o, m2, k, k2) {
|
|
26883
26883
|
if (k2 === void 0) k2 = k;
|
|
26884
|
-
o[k2] =
|
|
26884
|
+
o[k2] = m2[k];
|
|
26885
26885
|
});
|
|
26886
26886
|
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
|
|
26887
26887
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
@@ -27027,17 +27027,17 @@ var require_reconstruct = __commonJS({
|
|
|
27027
27027
|
var require_dist3 = __commonJS({
|
|
27028
27028
|
"node_modules/.pnpm/ret@0.5.0/node_modules/ret/dist/index.js"(exports2, module2) {
|
|
27029
27029
|
"use strict";
|
|
27030
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o,
|
|
27030
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
27031
27031
|
if (k2 === void 0) k2 = k;
|
|
27032
27032
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
27033
|
-
return
|
|
27033
|
+
return m2[k];
|
|
27034
27034
|
} });
|
|
27035
|
-
} : function(o,
|
|
27035
|
+
} : function(o, m2, k, k2) {
|
|
27036
27036
|
if (k2 === void 0) k2 = k;
|
|
27037
|
-
o[k2] =
|
|
27037
|
+
o[k2] = m2[k];
|
|
27038
27038
|
});
|
|
27039
|
-
var __exportStar = exports2 && exports2.__exportStar || function(
|
|
27040
|
-
for (var p in
|
|
27039
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m2, exports3) {
|
|
27040
|
+
for (var p in m2) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m2, p);
|
|
27041
27041
|
};
|
|
27042
27042
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
27043
27043
|
exports2.types = void 0;
|
|
@@ -27162,7 +27162,7 @@ var require_pretty_print = __commonJS({
|
|
|
27162
27162
|
return fName;
|
|
27163
27163
|
}
|
|
27164
27164
|
function parseMeta(meta) {
|
|
27165
|
-
if (Array.isArray(meta)) return meta.map((
|
|
27165
|
+
if (Array.isArray(meta)) return meta.map((m2) => parseMeta(m2));
|
|
27166
27166
|
if (typeof meta === "symbol") return meta.toString();
|
|
27167
27167
|
if (typeof meta === "function") return parseFunctionName(meta);
|
|
27168
27168
|
return meta;
|
|
@@ -28551,10 +28551,10 @@ var require_find_my_way = __commonJS({
|
|
|
28551
28551
|
};
|
|
28552
28552
|
for (const i in httpMethods) {
|
|
28553
28553
|
if (!httpMethods.hasOwnProperty(i)) continue;
|
|
28554
|
-
const
|
|
28555
|
-
const methodName =
|
|
28554
|
+
const m2 = httpMethods[i];
|
|
28555
|
+
const methodName = m2.toLowerCase();
|
|
28556
28556
|
Router.prototype[methodName] = function(path3, handler, store) {
|
|
28557
|
-
return this.on(
|
|
28557
|
+
return this.on(m2, path3, handler, store);
|
|
28558
28558
|
};
|
|
28559
28559
|
}
|
|
28560
28560
|
Router.prototype.all = function(path3, handler, store) {
|
|
@@ -33051,8 +33051,8 @@ var require_getPluginName = __commonJS({
|
|
|
33051
33051
|
}
|
|
33052
33052
|
};
|
|
33053
33053
|
function extractPluginName(stack) {
|
|
33054
|
-
const
|
|
33055
|
-
return
|
|
33054
|
+
const m2 = stack.match(fpStackTracePattern);
|
|
33055
|
+
return m2 ? m2[1].split(/[/\\]/).slice(-1)[0].match(fileNamePattern)[1] : "anonymous";
|
|
33056
33056
|
}
|
|
33057
33057
|
module2.exports.extractPluginName = extractPluginName;
|
|
33058
33058
|
}
|
|
@@ -34806,8 +34806,8 @@ var require_util3 = __commonJS({
|
|
|
34806
34806
|
}
|
|
34807
34807
|
var KEEPALIVE_TIMEOUT_EXPR = /timeout=(\d+)/;
|
|
34808
34808
|
function parseKeepAliveTimeout(val) {
|
|
34809
|
-
const
|
|
34810
|
-
return
|
|
34809
|
+
const m2 = val.match(KEEPALIVE_TIMEOUT_EXPR);
|
|
34810
|
+
return m2 ? parseInt(m2[1], 10) * 1e3 : null;
|
|
34811
34811
|
}
|
|
34812
34812
|
function headerNameToString(value) {
|
|
34813
34813
|
return typeof value === "string" ? headerNameLowerCasedRecord[value] ?? value.toLowerCase() : tree.lookup(value) ?? value.toString("latin1").toLowerCase();
|
|
@@ -35009,11 +35009,11 @@ var require_util3 = __commonJS({
|
|
|
35009
35009
|
var rangeHeaderRegex = /^bytes (\d+)-(\d+)\/(\d+)?$/;
|
|
35010
35010
|
function parseRangeHeader(range) {
|
|
35011
35011
|
if (range == null || range === "") return { start: 0, end: null, size: null };
|
|
35012
|
-
const
|
|
35013
|
-
return
|
|
35014
|
-
start: parseInt(
|
|
35015
|
-
end:
|
|
35016
|
-
size:
|
|
35012
|
+
const m2 = range ? range.match(rangeHeaderRegex) : null;
|
|
35013
|
+
return m2 ? {
|
|
35014
|
+
start: parseInt(m2[1]),
|
|
35015
|
+
end: m2[2] ? parseInt(m2[2]) : null,
|
|
35016
|
+
size: m2[3] ? parseInt(m2[3]) : null
|
|
35017
35017
|
} : null;
|
|
35018
35018
|
}
|
|
35019
35019
|
function addListener(obj, name, listener) {
|
|
@@ -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(
|
|
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;
|
|
@@ -37461,8 +37461,8 @@ var require_webidl = __commonJS({
|
|
|
37461
37461
|
};
|
|
37462
37462
|
webidl.brandCheckMultiple = function(List) {
|
|
37463
37463
|
const prototypes = List.map((c) => webidl.util.MakeTypeAssertion(c));
|
|
37464
|
-
return (
|
|
37465
|
-
if (prototypes.every((typeCheck) => !typeCheck(
|
|
37464
|
+
return (V2) => {
|
|
37465
|
+
if (prototypes.every((typeCheck) => !typeCheck(V2))) {
|
|
37466
37466
|
const err = new TypeError("Illegal invocation");
|
|
37467
37467
|
err.code = "ERR_INVALID_THIS";
|
|
37468
37468
|
throw err;
|
|
@@ -37483,11 +37483,11 @@ var require_webidl = __commonJS({
|
|
|
37483
37483
|
message: "Illegal constructor"
|
|
37484
37484
|
});
|
|
37485
37485
|
};
|
|
37486
|
-
webidl.util.MakeTypeAssertion = function(
|
|
37487
|
-
return (
|
|
37486
|
+
webidl.util.MakeTypeAssertion = function(I) {
|
|
37487
|
+
return (O) => FunctionPrototypeSymbolHasInstance(I, O);
|
|
37488
37488
|
};
|
|
37489
|
-
webidl.util.Type = function(
|
|
37490
|
-
switch (typeof
|
|
37489
|
+
webidl.util.Type = function(V2) {
|
|
37490
|
+
switch (typeof V2) {
|
|
37491
37491
|
case "undefined":
|
|
37492
37492
|
return UNDEFINED;
|
|
37493
37493
|
case "boolean":
|
|
@@ -37502,7 +37502,7 @@ var require_webidl = __commonJS({
|
|
|
37502
37502
|
return BIGINT;
|
|
37503
37503
|
case "function":
|
|
37504
37504
|
case "object": {
|
|
37505
|
-
if (
|
|
37505
|
+
if (V2 === null) {
|
|
37506
37506
|
return NULL;
|
|
37507
37507
|
}
|
|
37508
37508
|
return OBJECT;
|
|
@@ -37541,7 +37541,7 @@ var require_webidl = __commonJS({
|
|
|
37541
37541
|
};
|
|
37542
37542
|
webidl.util.markAsUncloneable = markAsUncloneable || (() => {
|
|
37543
37543
|
});
|
|
37544
|
-
webidl.util.ConvertToInt = function(
|
|
37544
|
+
webidl.util.ConvertToInt = function(V2, bitLength, signedness, opts) {
|
|
37545
37545
|
let upperBound;
|
|
37546
37546
|
let lowerBound;
|
|
37547
37547
|
if (bitLength === 64) {
|
|
@@ -37558,7 +37558,7 @@ var require_webidl = __commonJS({
|
|
|
37558
37558
|
lowerBound = Math.pow(-2, bitLength) - 1;
|
|
37559
37559
|
upperBound = Math.pow(2, bitLength - 1) - 1;
|
|
37560
37560
|
}
|
|
37561
|
-
let x = Number(
|
|
37561
|
+
let x = Number(V2);
|
|
37562
37562
|
if (x === 0) {
|
|
37563
37563
|
x = 0;
|
|
37564
37564
|
}
|
|
@@ -37566,7 +37566,7 @@ var require_webidl = __commonJS({
|
|
|
37566
37566
|
if (Number.isNaN(x) || x === Number.POSITIVE_INFINITY || x === Number.NEGATIVE_INFINITY) {
|
|
37567
37567
|
throw webidl.errors.exception({
|
|
37568
37568
|
header: "Integer conversion",
|
|
37569
|
-
message: `Could not convert ${webidl.util.Stringify(
|
|
37569
|
+
message: `Could not convert ${webidl.util.Stringify(V2)} to an integer.`
|
|
37570
37570
|
});
|
|
37571
37571
|
}
|
|
37572
37572
|
x = webidl.util.IntegerPart(x);
|
|
@@ -37604,30 +37604,30 @@ var require_webidl = __commonJS({
|
|
|
37604
37604
|
}
|
|
37605
37605
|
return r;
|
|
37606
37606
|
};
|
|
37607
|
-
webidl.util.Stringify = function(
|
|
37608
|
-
const type = webidl.util.Type(
|
|
37607
|
+
webidl.util.Stringify = function(V2) {
|
|
37608
|
+
const type = webidl.util.Type(V2);
|
|
37609
37609
|
switch (type) {
|
|
37610
37610
|
case SYMBOL:
|
|
37611
|
-
return `Symbol(${
|
|
37611
|
+
return `Symbol(${V2.description})`;
|
|
37612
37612
|
case OBJECT:
|
|
37613
|
-
return inspect(
|
|
37613
|
+
return inspect(V2);
|
|
37614
37614
|
case STRING:
|
|
37615
|
-
return `"${
|
|
37615
|
+
return `"${V2}"`;
|
|
37616
37616
|
case BIGINT:
|
|
37617
|
-
return `${
|
|
37617
|
+
return `${V2}n`;
|
|
37618
37618
|
default:
|
|
37619
|
-
return `${
|
|
37619
|
+
return `${V2}`;
|
|
37620
37620
|
}
|
|
37621
37621
|
};
|
|
37622
37622
|
webidl.sequenceConverter = function(converter) {
|
|
37623
|
-
return (
|
|
37624
|
-
if (webidl.util.Type(
|
|
37623
|
+
return (V2, prefix, argument, Iterable) => {
|
|
37624
|
+
if (webidl.util.Type(V2) !== OBJECT) {
|
|
37625
37625
|
throw webidl.errors.exception({
|
|
37626
37626
|
header: prefix,
|
|
37627
|
-
message: `${argument} (${webidl.util.Stringify(
|
|
37627
|
+
message: `${argument} (${webidl.util.Stringify(V2)}) is not iterable.`
|
|
37628
37628
|
});
|
|
37629
37629
|
}
|
|
37630
|
-
const method = typeof Iterable === "function" ? Iterable() :
|
|
37630
|
+
const method = typeof Iterable === "function" ? Iterable() : V2?.[Symbol.iterator]?.();
|
|
37631
37631
|
const seq = [];
|
|
37632
37632
|
let index = 0;
|
|
37633
37633
|
if (method === void 0 || typeof method.next !== "function") {
|
|
@@ -37647,30 +37647,30 @@ var require_webidl = __commonJS({
|
|
|
37647
37647
|
};
|
|
37648
37648
|
};
|
|
37649
37649
|
webidl.recordConverter = function(keyConverter, valueConverter) {
|
|
37650
|
-
return (
|
|
37651
|
-
if (webidl.util.Type(
|
|
37650
|
+
return (O, prefix, argument) => {
|
|
37651
|
+
if (webidl.util.Type(O) !== OBJECT) {
|
|
37652
37652
|
throw webidl.errors.exception({
|
|
37653
37653
|
header: prefix,
|
|
37654
|
-
message: `${argument} ("${webidl.util.TypeValueToString(
|
|
37654
|
+
message: `${argument} ("${webidl.util.TypeValueToString(O)}") is not an Object.`
|
|
37655
37655
|
});
|
|
37656
37656
|
}
|
|
37657
37657
|
const result = {};
|
|
37658
|
-
if (!types.isProxy(
|
|
37659
|
-
const keys2 = [...Object.getOwnPropertyNames(
|
|
37658
|
+
if (!types.isProxy(O)) {
|
|
37659
|
+
const keys2 = [...Object.getOwnPropertyNames(O), ...Object.getOwnPropertySymbols(O)];
|
|
37660
37660
|
for (const key of keys2) {
|
|
37661
37661
|
const keyName = webidl.util.Stringify(key);
|
|
37662
37662
|
const typedKey = keyConverter(key, prefix, `Key ${keyName} in ${argument}`);
|
|
37663
|
-
const typedValue = valueConverter(
|
|
37663
|
+
const typedValue = valueConverter(O[key], prefix, `${argument}[${keyName}]`);
|
|
37664
37664
|
result[typedKey] = typedValue;
|
|
37665
37665
|
}
|
|
37666
37666
|
return result;
|
|
37667
37667
|
}
|
|
37668
|
-
const keys = Reflect.ownKeys(
|
|
37668
|
+
const keys = Reflect.ownKeys(O);
|
|
37669
37669
|
for (const key of keys) {
|
|
37670
|
-
const desc = Reflect.getOwnPropertyDescriptor(
|
|
37670
|
+
const desc = Reflect.getOwnPropertyDescriptor(O, key);
|
|
37671
37671
|
if (desc?.enumerable) {
|
|
37672
37672
|
const typedKey = keyConverter(key, prefix, argument);
|
|
37673
|
-
const typedValue = valueConverter(
|
|
37673
|
+
const typedValue = valueConverter(O[key], prefix, argument);
|
|
37674
37674
|
result[typedKey] = typedValue;
|
|
37675
37675
|
}
|
|
37676
37676
|
}
|
|
@@ -37678,14 +37678,14 @@ var require_webidl = __commonJS({
|
|
|
37678
37678
|
};
|
|
37679
37679
|
};
|
|
37680
37680
|
webidl.interfaceConverter = function(TypeCheck, name) {
|
|
37681
|
-
return (
|
|
37682
|
-
if (!TypeCheck(
|
|
37681
|
+
return (V2, prefix, argument) => {
|
|
37682
|
+
if (!TypeCheck(V2)) {
|
|
37683
37683
|
throw webidl.errors.exception({
|
|
37684
37684
|
header: prefix,
|
|
37685
|
-
message: `Expected ${argument} ("${webidl.util.Stringify(
|
|
37685
|
+
message: `Expected ${argument} ("${webidl.util.Stringify(V2)}") to be an instance of ${name}.`
|
|
37686
37686
|
});
|
|
37687
37687
|
}
|
|
37688
|
-
return
|
|
37688
|
+
return V2;
|
|
37689
37689
|
};
|
|
37690
37690
|
};
|
|
37691
37691
|
webidl.dictionaryConverter = function(converters) {
|
|
@@ -37727,11 +37727,11 @@ var require_webidl = __commonJS({
|
|
|
37727
37727
|
};
|
|
37728
37728
|
};
|
|
37729
37729
|
webidl.nullableConverter = function(converter) {
|
|
37730
|
-
return (
|
|
37731
|
-
if (
|
|
37732
|
-
return
|
|
37730
|
+
return (V2, prefix, argument) => {
|
|
37731
|
+
if (V2 === null) {
|
|
37732
|
+
return V2;
|
|
37733
37733
|
}
|
|
37734
|
-
return converter(
|
|
37734
|
+
return converter(V2, prefix, argument);
|
|
37735
37735
|
};
|
|
37736
37736
|
};
|
|
37737
37737
|
webidl.is.USVString = function(value) {
|
|
@@ -37744,26 +37744,26 @@ var require_webidl = __commonJS({
|
|
|
37744
37744
|
webidl.is.URL = webidl.util.MakeTypeAssertion(URL);
|
|
37745
37745
|
webidl.is.AbortSignal = webidl.util.MakeTypeAssertion(AbortSignal);
|
|
37746
37746
|
webidl.is.MessagePort = webidl.util.MakeTypeAssertion(MessagePort);
|
|
37747
|
-
webidl.converters.DOMString = function(
|
|
37748
|
-
if (
|
|
37747
|
+
webidl.converters.DOMString = function(V2, prefix, argument, opts) {
|
|
37748
|
+
if (V2 === null && opts?.legacyNullToEmptyString) {
|
|
37749
37749
|
return "";
|
|
37750
37750
|
}
|
|
37751
|
-
if (typeof
|
|
37751
|
+
if (typeof V2 === "symbol") {
|
|
37752
37752
|
throw webidl.errors.exception({
|
|
37753
37753
|
header: prefix,
|
|
37754
37754
|
message: `${argument} is a symbol, which cannot be converted to a DOMString.`
|
|
37755
37755
|
});
|
|
37756
37756
|
}
|
|
37757
|
-
return String(
|
|
37757
|
+
return String(V2);
|
|
37758
37758
|
};
|
|
37759
|
-
webidl.converters.ByteString = function(
|
|
37760
|
-
if (typeof
|
|
37759
|
+
webidl.converters.ByteString = function(V2, prefix, argument) {
|
|
37760
|
+
if (typeof V2 === "symbol") {
|
|
37761
37761
|
throw webidl.errors.exception({
|
|
37762
37762
|
header: prefix,
|
|
37763
37763
|
message: `${argument} is a symbol, which cannot be converted to a ByteString.`
|
|
37764
37764
|
});
|
|
37765
37765
|
}
|
|
37766
|
-
const x = String(
|
|
37766
|
+
const x = String(V2);
|
|
37767
37767
|
for (let index = 0; index < x.length; index++) {
|
|
37768
37768
|
if (x.charCodeAt(index) > 255) {
|
|
37769
37769
|
throw new TypeError(
|
|
@@ -37779,93 +37779,93 @@ var require_webidl = __commonJS({
|
|
|
37779
37779
|
}
|
|
37780
37780
|
return `${value}`.toWellFormed();
|
|
37781
37781
|
};
|
|
37782
|
-
webidl.converters.boolean = function(
|
|
37783
|
-
const x = Boolean(
|
|
37782
|
+
webidl.converters.boolean = function(V2) {
|
|
37783
|
+
const x = Boolean(V2);
|
|
37784
37784
|
return x;
|
|
37785
37785
|
};
|
|
37786
|
-
webidl.converters.any = function(
|
|
37787
|
-
return
|
|
37786
|
+
webidl.converters.any = function(V2) {
|
|
37787
|
+
return V2;
|
|
37788
37788
|
};
|
|
37789
|
-
webidl.converters["long long"] = function(
|
|
37790
|
-
const x = webidl.util.ConvertToInt(
|
|
37789
|
+
webidl.converters["long long"] = function(V2, prefix, argument) {
|
|
37790
|
+
const x = webidl.util.ConvertToInt(V2, 64, "signed", void 0, prefix, argument);
|
|
37791
37791
|
return x;
|
|
37792
37792
|
};
|
|
37793
|
-
webidl.converters["unsigned long long"] = function(
|
|
37794
|
-
const x = webidl.util.ConvertToInt(
|
|
37793
|
+
webidl.converters["unsigned long long"] = function(V2, prefix, argument) {
|
|
37794
|
+
const x = webidl.util.ConvertToInt(V2, 64, "unsigned", void 0, prefix, argument);
|
|
37795
37795
|
return x;
|
|
37796
37796
|
};
|
|
37797
|
-
webidl.converters["unsigned long"] = function(
|
|
37798
|
-
const x = webidl.util.ConvertToInt(
|
|
37797
|
+
webidl.converters["unsigned long"] = function(V2, prefix, argument) {
|
|
37798
|
+
const x = webidl.util.ConvertToInt(V2, 32, "unsigned", void 0, prefix, argument);
|
|
37799
37799
|
return x;
|
|
37800
37800
|
};
|
|
37801
|
-
webidl.converters["unsigned short"] = function(
|
|
37802
|
-
const x = webidl.util.ConvertToInt(
|
|
37801
|
+
webidl.converters["unsigned short"] = function(V2, prefix, argument, opts) {
|
|
37802
|
+
const x = webidl.util.ConvertToInt(V2, 16, "unsigned", opts, prefix, argument);
|
|
37803
37803
|
return x;
|
|
37804
37804
|
};
|
|
37805
|
-
webidl.converters.ArrayBuffer = function(
|
|
37806
|
-
if (webidl.util.Type(
|
|
37805
|
+
webidl.converters.ArrayBuffer = function(V2, prefix, argument, opts) {
|
|
37806
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isAnyArrayBuffer(V2)) {
|
|
37807
37807
|
throw webidl.errors.conversionFailed({
|
|
37808
37808
|
prefix,
|
|
37809
|
-
argument: `${argument} ("${webidl.util.Stringify(
|
|
37809
|
+
argument: `${argument} ("${webidl.util.Stringify(V2)}")`,
|
|
37810
37810
|
types: ["ArrayBuffer"]
|
|
37811
37811
|
});
|
|
37812
37812
|
}
|
|
37813
|
-
if (opts?.allowShared === false && types.isSharedArrayBuffer(
|
|
37813
|
+
if (opts?.allowShared === false && types.isSharedArrayBuffer(V2)) {
|
|
37814
37814
|
throw webidl.errors.exception({
|
|
37815
37815
|
header: "ArrayBuffer",
|
|
37816
37816
|
message: "SharedArrayBuffer is not allowed."
|
|
37817
37817
|
});
|
|
37818
37818
|
}
|
|
37819
|
-
if (
|
|
37819
|
+
if (V2.resizable || V2.growable) {
|
|
37820
37820
|
throw webidl.errors.exception({
|
|
37821
37821
|
header: "ArrayBuffer",
|
|
37822
37822
|
message: "Received a resizable ArrayBuffer."
|
|
37823
37823
|
});
|
|
37824
37824
|
}
|
|
37825
|
-
return
|
|
37825
|
+
return V2;
|
|
37826
37826
|
};
|
|
37827
|
-
webidl.converters.TypedArray = function(
|
|
37828
|
-
if (webidl.util.Type(
|
|
37827
|
+
webidl.converters.TypedArray = function(V2, T, prefix, name, opts) {
|
|
37828
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isTypedArray(V2) || V2.constructor.name !== T.name) {
|
|
37829
37829
|
throw webidl.errors.conversionFailed({
|
|
37830
37830
|
prefix,
|
|
37831
|
-
argument: `${name} ("${webidl.util.Stringify(
|
|
37831
|
+
argument: `${name} ("${webidl.util.Stringify(V2)}")`,
|
|
37832
37832
|
types: [T.name]
|
|
37833
37833
|
});
|
|
37834
37834
|
}
|
|
37835
|
-
if (opts?.allowShared === false && types.isSharedArrayBuffer(
|
|
37835
|
+
if (opts?.allowShared === false && types.isSharedArrayBuffer(V2.buffer)) {
|
|
37836
37836
|
throw webidl.errors.exception({
|
|
37837
37837
|
header: "ArrayBuffer",
|
|
37838
37838
|
message: "SharedArrayBuffer is not allowed."
|
|
37839
37839
|
});
|
|
37840
37840
|
}
|
|
37841
|
-
if (
|
|
37841
|
+
if (V2.buffer.resizable || V2.buffer.growable) {
|
|
37842
37842
|
throw webidl.errors.exception({
|
|
37843
37843
|
header: "ArrayBuffer",
|
|
37844
37844
|
message: "Received a resizable ArrayBuffer."
|
|
37845
37845
|
});
|
|
37846
37846
|
}
|
|
37847
|
-
return
|
|
37847
|
+
return V2;
|
|
37848
37848
|
};
|
|
37849
|
-
webidl.converters.DataView = function(
|
|
37850
|
-
if (webidl.util.Type(
|
|
37849
|
+
webidl.converters.DataView = function(V2, prefix, name, opts) {
|
|
37850
|
+
if (webidl.util.Type(V2) !== OBJECT || !types.isDataView(V2)) {
|
|
37851
37851
|
throw webidl.errors.exception({
|
|
37852
37852
|
header: prefix,
|
|
37853
37853
|
message: `${name} is not a DataView.`
|
|
37854
37854
|
});
|
|
37855
37855
|
}
|
|
37856
|
-
if (opts?.allowShared === false && types.isSharedArrayBuffer(
|
|
37856
|
+
if (opts?.allowShared === false && types.isSharedArrayBuffer(V2.buffer)) {
|
|
37857
37857
|
throw webidl.errors.exception({
|
|
37858
37858
|
header: "ArrayBuffer",
|
|
37859
37859
|
message: "SharedArrayBuffer is not allowed."
|
|
37860
37860
|
});
|
|
37861
37861
|
}
|
|
37862
|
-
if (
|
|
37862
|
+
if (V2.buffer.resizable || V2.buffer.growable) {
|
|
37863
37863
|
throw webidl.errors.exception({
|
|
37864
37864
|
header: "ArrayBuffer",
|
|
37865
37865
|
message: "Received a resizable ArrayBuffer."
|
|
37866
37866
|
});
|
|
37867
37867
|
}
|
|
37868
|
-
return
|
|
37868
|
+
return V2;
|
|
37869
37869
|
};
|
|
37870
37870
|
webidl.converters["sequence<ByteString>"] = webidl.sequenceConverter(
|
|
37871
37871
|
webidl.converters.ByteString
|
|
@@ -38306,11 +38306,11 @@ var require_util4 = __commonJS({
|
|
|
38306
38306
|
}
|
|
38307
38307
|
function tryUpgradeRequestToAPotentiallyTrustworthyURL(request) {
|
|
38308
38308
|
}
|
|
38309
|
-
function sameOrigin(
|
|
38310
|
-
if (
|
|
38309
|
+
function sameOrigin(A2, B2) {
|
|
38310
|
+
if (A2.origin === B2.origin && A2.origin === "null") {
|
|
38311
38311
|
return true;
|
|
38312
38312
|
}
|
|
38313
|
-
if (
|
|
38313
|
+
if (A2.protocol === B2.protocol && A2.hostname === B2.hostname && A2.port === B2.port) {
|
|
38314
38314
|
return true;
|
|
38315
38315
|
}
|
|
38316
38316
|
return false;
|
|
@@ -48264,19 +48264,19 @@ var require_headers = __commonJS({
|
|
|
48264
48264
|
enumerable: false
|
|
48265
48265
|
}
|
|
48266
48266
|
});
|
|
48267
|
-
webidl.converters.HeadersInit = function(
|
|
48268
|
-
if (webidl.util.Type(
|
|
48269
|
-
const iterator = Reflect.get(
|
|
48270
|
-
if (!util.types.isProxy(
|
|
48267
|
+
webidl.converters.HeadersInit = function(V2, prefix, argument) {
|
|
48268
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT) {
|
|
48269
|
+
const iterator = Reflect.get(V2, Symbol.iterator);
|
|
48270
|
+
if (!util.types.isProxy(V2) && iterator === Headers2.prototype.entries) {
|
|
48271
48271
|
try {
|
|
48272
|
-
return getHeadersList(
|
|
48272
|
+
return getHeadersList(V2).entriesList;
|
|
48273
48273
|
} catch {
|
|
48274
48274
|
}
|
|
48275
48275
|
}
|
|
48276
48276
|
if (typeof iterator === "function") {
|
|
48277
|
-
return webidl.converters["sequence<sequence<ByteString>>"](
|
|
48277
|
+
return webidl.converters["sequence<sequence<ByteString>>"](V2, prefix, argument, iterator.bind(V2));
|
|
48278
48278
|
}
|
|
48279
|
-
return webidl.converters["record<ByteString, ByteString>"](
|
|
48279
|
+
return webidl.converters["record<ByteString, ByteString>"](V2, prefix, argument);
|
|
48280
48280
|
}
|
|
48281
48281
|
throw webidl.errors.conversionFailed({
|
|
48282
48282
|
prefix: "Headers constructor",
|
|
@@ -48661,32 +48661,32 @@ var require_response2 = __commonJS({
|
|
|
48661
48661
|
}
|
|
48662
48662
|
return response;
|
|
48663
48663
|
}
|
|
48664
|
-
webidl.converters.XMLHttpRequestBodyInit = function(
|
|
48665
|
-
if (typeof
|
|
48666
|
-
return webidl.converters.USVString(
|
|
48664
|
+
webidl.converters.XMLHttpRequestBodyInit = function(V2, prefix, name) {
|
|
48665
|
+
if (typeof V2 === "string") {
|
|
48666
|
+
return webidl.converters.USVString(V2, prefix, name);
|
|
48667
48667
|
}
|
|
48668
|
-
if (webidl.is.Blob(
|
|
48669
|
-
return
|
|
48668
|
+
if (webidl.is.Blob(V2)) {
|
|
48669
|
+
return V2;
|
|
48670
48670
|
}
|
|
48671
|
-
if (ArrayBuffer.isView(
|
|
48672
|
-
return
|
|
48671
|
+
if (ArrayBuffer.isView(V2) || types.isArrayBuffer(V2)) {
|
|
48672
|
+
return V2;
|
|
48673
48673
|
}
|
|
48674
|
-
if (webidl.is.FormData(
|
|
48675
|
-
return
|
|
48674
|
+
if (webidl.is.FormData(V2)) {
|
|
48675
|
+
return V2;
|
|
48676
48676
|
}
|
|
48677
|
-
if (webidl.is.URLSearchParams(
|
|
48678
|
-
return
|
|
48677
|
+
if (webidl.is.URLSearchParams(V2)) {
|
|
48678
|
+
return V2;
|
|
48679
48679
|
}
|
|
48680
|
-
return webidl.converters.DOMString(
|
|
48680
|
+
return webidl.converters.DOMString(V2, prefix, name);
|
|
48681
48681
|
};
|
|
48682
|
-
webidl.converters.BodyInit = function(
|
|
48683
|
-
if (webidl.is.ReadableStream(
|
|
48684
|
-
return
|
|
48682
|
+
webidl.converters.BodyInit = function(V2, prefix, argument) {
|
|
48683
|
+
if (webidl.is.ReadableStream(V2)) {
|
|
48684
|
+
return V2;
|
|
48685
48685
|
}
|
|
48686
|
-
if (
|
|
48687
|
-
return
|
|
48686
|
+
if (V2?.[Symbol.asyncIterator]) {
|
|
48687
|
+
return V2;
|
|
48688
48688
|
}
|
|
48689
|
-
return webidl.converters.XMLHttpRequestBodyInit(
|
|
48689
|
+
return webidl.converters.XMLHttpRequestBodyInit(V2, prefix, argument);
|
|
48690
48690
|
};
|
|
48691
48691
|
webidl.converters.ResponseInit = webidl.dictionaryConverter([
|
|
48692
48692
|
{
|
|
@@ -49376,14 +49376,14 @@ var require_request4 = __commonJS({
|
|
|
49376
49376
|
}
|
|
49377
49377
|
});
|
|
49378
49378
|
webidl.is.Request = webidl.util.MakeTypeAssertion(Request);
|
|
49379
|
-
webidl.converters.RequestInfo = function(
|
|
49380
|
-
if (typeof
|
|
49381
|
-
return webidl.converters.USVString(
|
|
49379
|
+
webidl.converters.RequestInfo = function(V2, prefix, argument) {
|
|
49380
|
+
if (typeof V2 === "string") {
|
|
49381
|
+
return webidl.converters.USVString(V2);
|
|
49382
49382
|
}
|
|
49383
|
-
if (webidl.is.Request(
|
|
49384
|
-
return
|
|
49383
|
+
if (webidl.is.Request(V2)) {
|
|
49384
|
+
return V2;
|
|
49385
49385
|
}
|
|
49386
|
-
return webidl.converters.USVString(
|
|
49386
|
+
return webidl.converters.USVString(V2);
|
|
49387
49387
|
};
|
|
49388
49388
|
webidl.converters.RequestInit = webidl.dictionaryConverter([
|
|
49389
49389
|
{
|
|
@@ -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(
|
|
50556
|
-
const serializedA = URLSerializer(
|
|
50557
|
-
const serializedB = URLSerializer(
|
|
50555
|
+
function urlEquals(A2, B2, excludeFragment = false) {
|
|
50556
|
+
const serializedA = URLSerializer(A2, excludeFragment);
|
|
50557
|
+
const serializedB = URLSerializer(B2, excludeFragment);
|
|
50558
50558
|
return serializedA === serializedB;
|
|
50559
50559
|
}
|
|
50560
50560
|
function getFieldValues(header) {
|
|
@@ -53306,11 +53306,11 @@ var require_websocket = __commonJS({
|
|
|
53306
53306
|
webidl.converters["sequence<DOMString>"] = webidl.sequenceConverter(
|
|
53307
53307
|
webidl.converters.DOMString
|
|
53308
53308
|
);
|
|
53309
|
-
webidl.converters["DOMString or sequence<DOMString>"] = function(
|
|
53310
|
-
if (webidl.util.Type(
|
|
53311
|
-
return webidl.converters["sequence<DOMString>"](
|
|
53309
|
+
webidl.converters["DOMString or sequence<DOMString>"] = function(V2, prefix, argument) {
|
|
53310
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT && Symbol.iterator in V2) {
|
|
53311
|
+
return webidl.converters["sequence<DOMString>"](V2);
|
|
53312
53312
|
}
|
|
53313
|
-
return webidl.converters.DOMString(
|
|
53313
|
+
return webidl.converters.DOMString(V2, prefix, argument);
|
|
53314
53314
|
};
|
|
53315
53315
|
webidl.converters.WebSocketInit = webidl.dictionaryConverter([
|
|
53316
53316
|
{
|
|
@@ -53328,22 +53328,22 @@ var require_websocket = __commonJS({
|
|
|
53328
53328
|
converter: webidl.nullableConverter(webidl.converters.HeadersInit)
|
|
53329
53329
|
}
|
|
53330
53330
|
]);
|
|
53331
|
-
webidl.converters["DOMString or sequence<DOMString> or WebSocketInit"] = function(
|
|
53332
|
-
if (webidl.util.Type(
|
|
53333
|
-
return webidl.converters.WebSocketInit(
|
|
53331
|
+
webidl.converters["DOMString or sequence<DOMString> or WebSocketInit"] = function(V2) {
|
|
53332
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT && !(Symbol.iterator in V2)) {
|
|
53333
|
+
return webidl.converters.WebSocketInit(V2);
|
|
53334
53334
|
}
|
|
53335
|
-
return { protocols: webidl.converters["DOMString or sequence<DOMString>"](
|
|
53335
|
+
return { protocols: webidl.converters["DOMString or sequence<DOMString>"](V2) };
|
|
53336
53336
|
};
|
|
53337
|
-
webidl.converters.WebSocketSendData = function(
|
|
53338
|
-
if (webidl.util.Type(
|
|
53339
|
-
if (webidl.is.Blob(
|
|
53340
|
-
return
|
|
53337
|
+
webidl.converters.WebSocketSendData = function(V2) {
|
|
53338
|
+
if (webidl.util.Type(V2) === webidl.util.Types.OBJECT) {
|
|
53339
|
+
if (webidl.is.Blob(V2)) {
|
|
53340
|
+
return V2;
|
|
53341
53341
|
}
|
|
53342
|
-
if (ArrayBuffer.isView(
|
|
53343
|
-
return
|
|
53342
|
+
if (ArrayBuffer.isView(V2) || types.isArrayBuffer(V2)) {
|
|
53343
|
+
return V2;
|
|
53344
53344
|
}
|
|
53345
53345
|
}
|
|
53346
|
-
return webidl.converters.USVString(
|
|
53346
|
+
return webidl.converters.USVString(V2);
|
|
53347
53347
|
};
|
|
53348
53348
|
module2.exports = {
|
|
53349
53349
|
WebSocket
|
|
@@ -53706,7 +53706,7 @@ var require_websocketstream = __commonJS({
|
|
|
53706
53706
|
webidl.converters.WebSocketCloseInfo = webidl.dictionaryConverter([
|
|
53707
53707
|
{
|
|
53708
53708
|
key: "closeCode",
|
|
53709
|
-
converter: (
|
|
53709
|
+
converter: (V2) => webidl.converters["unsigned short"](V2, { enforceRange: true })
|
|
53710
53710
|
},
|
|
53711
53711
|
{
|
|
53712
53712
|
key: "reason",
|
|
@@ -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(f, args) {
|
|
54475
54475
|
try {
|
|
54476
|
-
return
|
|
54476
|
+
return f.apply(this, args);
|
|
54477
54477
|
} catch (e) {
|
|
54478
54478
|
wasm.__wbindgen_export_0(addHeapObject(e));
|
|
54479
54479
|
}
|
|
@@ -54957,7 +54957,7 @@ var initConfig = async () => {
|
|
|
54957
54957
|
return config;
|
|
54958
54958
|
};
|
|
54959
54959
|
|
|
54960
|
-
// node_modules/.pnpm/@musistudio+llms@1.0.
|
|
54960
|
+
// node_modules/.pnpm/@musistudio+llms@1.0.2_ws@8.18.3_zod@3.25.67/node_modules/@musistudio/llms/dist/esm/server.mjs
|
|
54961
54961
|
var import_fastify = __toESM(require_fastify(), 1);
|
|
54962
54962
|
var import_cors = __toESM(require_cors(), 1);
|
|
54963
54963
|
var import_fs = require("fs");
|
|
@@ -54965,18 +54965,18 @@ var import_path = require("path");
|
|
|
54965
54965
|
var import_dotenv = __toESM(require_main(), 1);
|
|
54966
54966
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
54967
54967
|
var import_undici = __toESM(require_undici(), 1);
|
|
54968
|
-
var
|
|
54968
|
+
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) {
|
|
54969
54969
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
54970
|
-
throw Error('Dynamic require of "' +
|
|
54970
|
+
throw Error('Dynamic require of "' + i + '" is not supported');
|
|
54971
54971
|
});
|
|
54972
54972
|
var j = class {
|
|
54973
54973
|
config = {};
|
|
54974
54974
|
options;
|
|
54975
54975
|
constructor(e = { jsonPath: "./config.json" }) {
|
|
54976
|
-
this.options = { envPath: e.envPath || ".env", jsonPath: e.jsonPath, useEnvFile:
|
|
54976
|
+
this.options = { envPath: e.envPath || ".env", jsonPath: e.jsonPath, useEnvFile: false, useJsonFile: e.useJsonFile !== false, useEnvironmentVariables: e.useEnvironmentVariables !== false, ...e }, this.loadConfig();
|
|
54977
54977
|
}
|
|
54978
54978
|
loadConfig() {
|
|
54979
|
-
this.options.initialConfig && (this.config = { ...this.config, ...this.options.initialConfig }), this.options.useEnvFile && this.loadEnvConfig(), this.options.useJsonFile && this.options.jsonPath && this.loadJsonConfig(), this.
|
|
54979
|
+
this.options.initialConfig && (this.config = { ...this.config, ...this.options.initialConfig }), this.options.useEnvFile && this.loadEnvConfig(), this.options.useJsonFile && this.options.jsonPath && this.loadJsonConfig(), this.config.LOG_FILE && (process.env.LOG_FILE = this.config.LOG_FILE), this.config.LOG && (process.env.LOG = this.config.LOG);
|
|
54980
54980
|
}
|
|
54981
54981
|
loadJsonConfig() {
|
|
54982
54982
|
if (!this.options.jsonPath) return;
|
|
@@ -55033,96 +55033,95 @@ var j = class {
|
|
|
55033
55033
|
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(", ")}`;
|
|
55034
55034
|
}
|
|
55035
55035
|
};
|
|
55036
|
-
|
|
55037
|
-
|
|
55038
|
-
|
|
55039
|
-
|
|
55040
|
-
|
|
55041
|
-
import_node_fs.default.appendFileSync(ie, n, "utf8");
|
|
55036
|
+
function m(...i) {
|
|
55037
|
+
if (console.log(...i), !(process.env.LOG === "true")) return;
|
|
55038
|
+
let n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${Array.isArray(i) ? i.map((r) => typeof r == "object" ? JSON.stringify(r) : String(r)).join(" ") : ""}
|
|
55039
|
+
`, o = process.env.LOG_FILE || "app.log";
|
|
55040
|
+
import_node_fs.default.appendFileSync(o, n, "utf8");
|
|
55042
55041
|
}
|
|
55043
|
-
function
|
|
55044
|
-
let o = new Error(
|
|
55042
|
+
function A(i, e = 500, t = "internal_error", n = "api_error") {
|
|
55043
|
+
let o = new Error(i);
|
|
55045
55044
|
return o.statusCode = e, o.code = t, o.type = n, o;
|
|
55046
55045
|
}
|
|
55047
|
-
async function X(
|
|
55048
|
-
e.log.error(
|
|
55049
|
-
let n =
|
|
55046
|
+
async function X(i, e, t) {
|
|
55047
|
+
e.log.error(i);
|
|
55048
|
+
let n = i.statusCode || 500, o = { error: { message: i.message || "Internal Server Error", type: i.type || "api_error", code: i.code || "internal_error" } };
|
|
55050
55049
|
return t.code(n).send(o);
|
|
55051
55050
|
}
|
|
55052
|
-
function Q(
|
|
55051
|
+
function Q(i, e, t) {
|
|
55053
55052
|
let n = new Headers({ "Content-Type": "application/json" });
|
|
55054
|
-
t.headers && Object.entries(t.headers).forEach(([
|
|
55055
|
-
n.set(
|
|
55053
|
+
t.headers && Object.entries(t.headers).forEach(([l, d]) => {
|
|
55054
|
+
n.set(l, d);
|
|
55056
55055
|
});
|
|
55057
55056
|
let o, r = AbortSignal.timeout(t.TIMEOUT ?? 60 * 1e3 * 60);
|
|
55058
55057
|
if (t.signal) {
|
|
55059
|
-
let
|
|
55060
|
-
t.signal.addEventListener("abort",
|
|
55058
|
+
let l = new AbortController(), d = () => l.abort();
|
|
55059
|
+
t.signal.addEventListener("abort", d), r.addEventListener("abort", d), o = l.signal;
|
|
55061
55060
|
} else o = r;
|
|
55062
|
-
let
|
|
55063
|
-
return t.httpsProxy && (
|
|
55061
|
+
let c = { method: "POST", headers: n, body: JSON.stringify(e), signal: o };
|
|
55062
|
+
return t.httpsProxy && (c.dispatcher = new import_undici.ProxyAgent(new URL(t.httpsProxy).toString())), m("final request:", typeof i == "string" ? i : i.toString(), t.httpsProxy, c), fetch(typeof i == "string" ? i : i.toString(), c);
|
|
55064
55063
|
}
|
|
55065
|
-
var Z = async (
|
|
55066
|
-
|
|
55067
|
-
let e =
|
|
55068
|
-
for (let { name: t, transformer: n } of e) n.endPoint &&
|
|
55069
|
-
let
|
|
55070
|
-
if (!
|
|
55071
|
-
let
|
|
55064
|
+
var Z = async (i) => {
|
|
55065
|
+
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() }));
|
|
55066
|
+
let e = i._server.transformerService.getTransformersWithEndpoint();
|
|
55067
|
+
for (let { name: t, transformer: n } of e) n.endPoint && i.post(n.endPoint, async (o, r) => {
|
|
55068
|
+
let c = o.body, l = o.provider, d = i._server.providerService.getProvider(l);
|
|
55069
|
+
if (!d) throw A(`Provider '${l}' not found`, 404, "provider_not_found");
|
|
55070
|
+
let a = c, p = {};
|
|
55072
55071
|
if (typeof n.transformRequestOut == "function") {
|
|
55073
|
-
let
|
|
55074
|
-
|
|
55072
|
+
let s = n.transformRequestOut(c);
|
|
55073
|
+
s.body ? (a = s.body, p = s.config || {}) : a = s;
|
|
55075
55074
|
}
|
|
55076
|
-
if (
|
|
55077
|
-
let g =
|
|
55075
|
+
if (d.transformer?.use?.length) for (let s of d.transformer.use) {
|
|
55076
|
+
let g = i._server.transformerService.getTransformer(s);
|
|
55078
55077
|
if (!g || typeof g.transformRequestIn != "function") continue;
|
|
55079
|
-
let
|
|
55080
|
-
|
|
55078
|
+
let y = g.transformRequestIn(a, d);
|
|
55079
|
+
y.body ? (a = y.body, p = { ...p, ...y.config }) : a = y;
|
|
55081
55080
|
}
|
|
55082
|
-
if (
|
|
55083
|
-
let g =
|
|
55084
|
-
!g || typeof g.transformRequestIn != "function" || (
|
|
55081
|
+
if (d.transformer?.[o.body.model]?.use?.length) for (let s of d.transformer[o.body.model].use) {
|
|
55082
|
+
let g = i._server.transformerService.getTransformer(s);
|
|
55083
|
+
!g || typeof g.transformRequestIn != "function" || (a = g.transformRequestIn(a, d));
|
|
55085
55084
|
}
|
|
55086
|
-
let
|
|
55085
|
+
let u = p.url || new URL(d.baseUrl), v = await Q(u, a, { httpsProxy: i._server.configService.getHttpsProxy(), ...p, headers: { Authorization: `Bearer ${d.apiKey}`, ...p?.headers || {} } });
|
|
55087
55086
|
if (!v.ok) {
|
|
55088
|
-
let
|
|
55089
|
-
throw
|
|
55087
|
+
let s = await v.text();
|
|
55088
|
+
throw m(`Error response from ${u}: ${s}`), A(`Error from provider: ${s}`, v.status, "provider_response_error");
|
|
55090
55089
|
}
|
|
55091
55090
|
let h = v;
|
|
55092
|
-
if (
|
|
55093
|
-
let g =
|
|
55091
|
+
if (d.transformer?.use?.length) for (let s of d.transformer.use) {
|
|
55092
|
+
let g = i._server.transformerService.getTransformer(s);
|
|
55094
55093
|
!g || typeof g.transformResponseOut != "function" || (h = await g.transformResponseOut(h));
|
|
55095
55094
|
}
|
|
55096
|
-
if (
|
|
55097
|
-
let g =
|
|
55095
|
+
if (d.transformer?.[o.body.model]?.use?.length) for (let s of d.transformer[o.body.model].use) {
|
|
55096
|
+
let g = i._server.transformerService.getTransformer(s);
|
|
55098
55097
|
!g || typeof g.transformResponseOut != "function" || (h = await g.transformResponseOut(h));
|
|
55099
55098
|
}
|
|
55100
|
-
return n.transformResponseIn && (h = await n.transformResponseIn(h)), h.ok || r.code(h.status),
|
|
55099
|
+
return n.transformResponseIn && (h = await n.transformResponseIn(h)), h.ok || r.code(h.status), c?.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();
|
|
55101
55100
|
});
|
|
55102
|
-
|
|
55103
|
-
let { name: o, type: r, baseUrl:
|
|
55104
|
-
if (!o?.trim()) throw
|
|
55105
|
-
if (!
|
|
55106
|
-
if (!
|
|
55107
|
-
if (!
|
|
55108
|
-
if (
|
|
55109
|
-
return
|
|
55110
|
-
}),
|
|
55111
|
-
let o =
|
|
55101
|
+
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) => {
|
|
55102
|
+
let { name: o, type: r, baseUrl: c, apiKey: l, models: d } = t.body;
|
|
55103
|
+
if (!o?.trim()) throw A("Provider name is required", 400, "invalid_request");
|
|
55104
|
+
if (!c || !ae(c)) throw A("Valid base URL is required", 400, "invalid_request");
|
|
55105
|
+
if (!l?.trim()) throw A("API key is required", 400, "invalid_request");
|
|
55106
|
+
if (!d || !Array.isArray(d) || d.length === 0) throw A("At least one model is required", 400, "invalid_request");
|
|
55107
|
+
if (i._server.providerService.getProvider(id)) throw A(`Provider with ID '${id}' already exists`, 400, "provider_exists");
|
|
55108
|
+
return i._server.providerService.registerProvider(t.body);
|
|
55109
|
+
}), 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) => {
|
|
55110
|
+
let o = i._server.providerService.getProvider(t.params.id);
|
|
55112
55111
|
return o || n.code(404).send({ error: "Provider not found" });
|
|
55113
|
-
}),
|
|
55114
|
-
let o =
|
|
55112
|
+
}), 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) => {
|
|
55113
|
+
let o = i._server.providerService.updateProvider(t.params.id, t.body);
|
|
55115
55114
|
return o || n.code(404).send({ error: "Provider not found" });
|
|
55116
|
-
}),
|
|
55115
|
+
}), 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" }));
|
|
55117
55116
|
};
|
|
55118
|
-
function
|
|
55117
|
+
function ae(i) {
|
|
55119
55118
|
try {
|
|
55120
|
-
return new URL(
|
|
55119
|
+
return new URL(i), true;
|
|
55121
55120
|
} catch {
|
|
55122
55121
|
return false;
|
|
55123
55122
|
}
|
|
55124
55123
|
}
|
|
55125
|
-
var
|
|
55124
|
+
var q = class {
|
|
55126
55125
|
constructor(e) {
|
|
55127
55126
|
this.providerService = e;
|
|
55128
55127
|
}
|
|
@@ -55159,7 +55158,7 @@ var J = class {
|
|
|
55159
55158
|
return this.providerService.getModelRoutes();
|
|
55160
55159
|
}
|
|
55161
55160
|
};
|
|
55162
|
-
var
|
|
55161
|
+
var J = class {
|
|
55163
55162
|
constructor(e) {
|
|
55164
55163
|
this.configService = e;
|
|
55165
55164
|
this.initializeCustomProviders();
|
|
@@ -55177,9 +55176,9 @@ var q = class {
|
|
|
55177
55176
|
e.forEach((t) => {
|
|
55178
55177
|
try {
|
|
55179
55178
|
if (!t.name || !t.api_base_url || !t.api_key) return;
|
|
55180
|
-
this.registerProvider({ name: t.name, baseUrl: t.api_base_url, apiKey: t.api_key, models: t.models || [], transformer: this.parseTransformerConfig(t.transformer) || {} }),
|
|
55179
|
+
this.registerProvider({ name: t.name, baseUrl: t.api_base_url, apiKey: t.api_key, models: t.models || [], transformer: this.parseTransformerConfig(t.transformer) || {} }), m(`${t.name} provider registered`);
|
|
55181
55180
|
} catch (n) {
|
|
55182
|
-
|
|
55181
|
+
m(`${t.name} provider registered error: ${n}`);
|
|
55183
55182
|
}
|
|
55184
55183
|
});
|
|
55185
55184
|
}
|
|
@@ -55201,11 +55200,11 @@ var q = class {
|
|
|
55201
55200
|
if (!n) return null;
|
|
55202
55201
|
let o = { ...n, ...t, updatedAt: /* @__PURE__ */ new Date() };
|
|
55203
55202
|
return this.providers.set(e, o), t.models && (n.models.forEach((r) => {
|
|
55204
|
-
let
|
|
55205
|
-
this.modelRoutes.delete(
|
|
55203
|
+
let c = `${n.id},${r}`;
|
|
55204
|
+
this.modelRoutes.delete(c), this.modelRoutes.delete(r);
|
|
55206
55205
|
}), t.models.forEach((r) => {
|
|
55207
|
-
let
|
|
55208
|
-
this.modelRoutes.set(
|
|
55206
|
+
let c = `${n.id},${r}`, l = { providerId: n.id, model: r, fullModel: c };
|
|
55207
|
+
this.modelRoutes.set(c, l), this.modelRoutes.has(r) || this.modelRoutes.set(r, l);
|
|
55209
55208
|
})), o;
|
|
55210
55209
|
}
|
|
55211
55210
|
deleteProvider(e) {
|
|
@@ -55254,37 +55253,37 @@ var q = class {
|
|
|
55254
55253
|
}), { object: "list", data: e };
|
|
55255
55254
|
}
|
|
55256
55255
|
};
|
|
55257
|
-
var
|
|
55256
|
+
var N = class {
|
|
55258
55257
|
name = "Anthropic";
|
|
55259
55258
|
endPoint = "/v1/messages";
|
|
55260
55259
|
transformRequestOut(e) {
|
|
55261
|
-
|
|
55260
|
+
m("Anthropic Request:", JSON.stringify(e, null, 2));
|
|
55262
55261
|
let t = [], n = [];
|
|
55263
55262
|
if (e.system) {
|
|
55264
55263
|
if (typeof e.system == "string") t.push({ role: "system", content: e.system });
|
|
55265
55264
|
else if (Array.isArray(e.system)) {
|
|
55266
|
-
let
|
|
55267
|
-
t.push(...
|
|
55268
|
-
}
|
|
55269
|
-
}
|
|
55270
|
-
return JSON.parse(JSON.stringify(e.messages || []))?.forEach((
|
|
55271
|
-
if (
|
|
55272
|
-
let
|
|
55273
|
-
if (typeof
|
|
55274
|
-
else if (Array.isArray(
|
|
55275
|
-
if (
|
|
55276
|
-
let
|
|
55277
|
-
|
|
55278
|
-
let h = { role: "tool", content: typeof
|
|
55265
|
+
let c = e.system.filter((l) => l.type === "text" && l.text).map((l) => ({ role: "system", content: l.text }));
|
|
55266
|
+
t.push(...c);
|
|
55267
|
+
}
|
|
55268
|
+
}
|
|
55269
|
+
return JSON.parse(JSON.stringify(e.messages || []))?.forEach((c, l) => {
|
|
55270
|
+
if (c.role === "user" || c.role === "assistant") {
|
|
55271
|
+
let d = { role: c.role, content: null };
|
|
55272
|
+
if (typeof c.content == "string") t.push({ role: c.role, content: c.content });
|
|
55273
|
+
else if (Array.isArray(c.content)) {
|
|
55274
|
+
if (c.role === "user") {
|
|
55275
|
+
let a = c.content.filter((u) => u.type === "tool_result" && u.tool_use_id);
|
|
55276
|
+
a.length && a.forEach((u, v) => {
|
|
55277
|
+
let h = { role: "tool", content: typeof u.content == "string" ? u.content : JSON.stringify(u.content), tool_call_id: u.tool_use_id };
|
|
55279
55278
|
t.push(h);
|
|
55280
55279
|
});
|
|
55281
|
-
let
|
|
55282
|
-
|
|
55283
|
-
} else if (
|
|
55284
|
-
let
|
|
55285
|
-
|
|
55286
|
-
let
|
|
55287
|
-
|
|
55280
|
+
let p = c.content.filter((u) => u.type === "text" && u.text);
|
|
55281
|
+
p.length && t.push({ role: "user", content: p });
|
|
55282
|
+
} else if (c.role === "assistant") {
|
|
55283
|
+
let a = c.content.filter((u) => u.type === "text" && u.text);
|
|
55284
|
+
a.length && t.push(...a.map((u) => ({ role: "assistant", content: u.text })));
|
|
55285
|
+
let p = c.content.filter((u) => u.type === "tool_use" && u.id);
|
|
55286
|
+
p.length && t.push({ role: "assistant", content: null, tool_calls: p.map((u) => ({ id: u.id, type: "function", function: { name: u.name, arguments: JSON.stringify(u.input || {}) } })) });
|
|
55288
55287
|
}
|
|
55289
55288
|
return;
|
|
55290
55289
|
}
|
|
@@ -55306,248 +55305,226 @@ var L = class {
|
|
|
55306
55305
|
}
|
|
55307
55306
|
async convertOpenAIStreamToAnthropic(e) {
|
|
55308
55307
|
return new ReadableStream({ async start(n) {
|
|
55309
|
-
let o = new TextEncoder(), r = `msg_${Date.now()}`,
|
|
55310
|
-
if (!
|
|
55311
|
-
n.enqueue(
|
|
55312
|
-
let
|
|
55313
|
-
|
|
55314
|
-
} catch (
|
|
55315
|
-
if (
|
|
55316
|
-
else throw
|
|
55317
|
-
}
|
|
55318
|
-
},
|
|
55319
|
-
if (!
|
|
55320
|
-
n.close(),
|
|
55321
|
-
} catch (
|
|
55322
|
-
if (
|
|
55323
|
-
else throw
|
|
55324
|
-
}
|
|
55325
|
-
},
|
|
55308
|
+
let o = new TextEncoder(), r = `msg_${Date.now()}`, c = "unknown", l = false, d = false, a = false, p = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), v = 0, h = 0, f = 0, s = false, g = false, y = 0, k = (S) => {
|
|
55309
|
+
if (!s) try {
|
|
55310
|
+
n.enqueue(S);
|
|
55311
|
+
let P = new TextDecoder().decode(S);
|
|
55312
|
+
m("send data:", P.trim());
|
|
55313
|
+
} catch (P) {
|
|
55314
|
+
if (P instanceof TypeError && P.message.includes("Controller is already closed")) s = true;
|
|
55315
|
+
else throw m(`send data error: ${P.message}`), P;
|
|
55316
|
+
}
|
|
55317
|
+
}, D = () => {
|
|
55318
|
+
if (!s) try {
|
|
55319
|
+
n.close(), s = true;
|
|
55320
|
+
} catch (S) {
|
|
55321
|
+
if (S instanceof TypeError && S.message.includes("Controller is already closed")) s = true;
|
|
55322
|
+
else throw S;
|
|
55323
|
+
}
|
|
55324
|
+
}, I = null;
|
|
55326
55325
|
try {
|
|
55327
|
-
|
|
55328
|
-
let
|
|
55329
|
-
for (; !
|
|
55330
|
-
let { done:
|
|
55331
|
-
if (
|
|
55332
|
-
|
|
55333
|
-
let
|
|
55326
|
+
I = e.getReader();
|
|
55327
|
+
let S = new TextDecoder(), P = "";
|
|
55328
|
+
for (; !s; ) {
|
|
55329
|
+
let { done: ee, value: te } = await I.read();
|
|
55330
|
+
if (ee) break;
|
|
55331
|
+
P += S.decode(te, { stream: true });
|
|
55332
|
+
let W = P.split(`
|
|
55334
55333
|
`);
|
|
55335
|
-
|
|
55336
|
-
for (let
|
|
55337
|
-
if (
|
|
55338
|
-
if (
|
|
55339
|
-
|
|
55340
|
-
|
|
55341
|
-
|
|
55342
|
-
|
|
55343
|
-
|
|
55344
|
-
|
|
55345
|
-
|
|
55346
|
-
|
|
55347
|
-
data: ${JSON.stringify(k)}
|
|
55334
|
+
P = W.pop() || "";
|
|
55335
|
+
for (let G of W) {
|
|
55336
|
+
if (s || a) break;
|
|
55337
|
+
if (!G.startsWith("data: ")) continue;
|
|
55338
|
+
let z = G.slice(6);
|
|
55339
|
+
if (z !== "[DONE]") try {
|
|
55340
|
+
let T = JSON.parse(z);
|
|
55341
|
+
if (v++, m("Original Response:", JSON.stringify(T, null, 2)), c = T.model || c, !l && !s && !a) {
|
|
55342
|
+
l = true;
|
|
55343
|
+
let b = { type: "message_start", message: { id: r, type: "message", role: "assistant", content: [], model: c, stop_reason: null, stop_sequence: null, usage: { input_tokens: 1, output_tokens: 1 } } };
|
|
55344
|
+
k(o.encode(`event: message_start
|
|
55345
|
+
data: ${JSON.stringify(b)}
|
|
55348
55346
|
|
|
55349
55347
|
`));
|
|
55350
|
-
|
|
55351
|
-
|
|
55352
|
-
|
|
55353
|
-
|
|
55354
|
-
|
|
55355
|
-
|
|
55356
|
-
|
|
55357
|
-
|
|
55358
|
-
let k = { type: "content_block_start", index: b.index || 0, content_block: { type: "thinking", thinking: "" } };
|
|
55359
|
-
S(o.encode(`event: content_block_start
|
|
55360
|
-
data: ${JSON.stringify(k)}
|
|
55348
|
+
}
|
|
55349
|
+
let x = T.choices?.[0];
|
|
55350
|
+
if (!x) continue;
|
|
55351
|
+
if (x?.delta?.thinking && !s && !a) {
|
|
55352
|
+
if (!g) {
|
|
55353
|
+
let b = { type: "content_block_start", index: y, content_block: { type: "thinking", thinking: "" } };
|
|
55354
|
+
k(o.encode(`event: content_block_start
|
|
55355
|
+
data: ${JSON.stringify(b)}
|
|
55361
55356
|
|
|
55362
55357
|
`)), g = true;
|
|
55363
|
-
|
|
55364
|
-
|
|
55365
|
-
|
|
55366
|
-
|
|
55367
|
-
data: ${JSON.stringify(
|
|
55358
|
+
}
|
|
55359
|
+
if (x.delta.thinking.signature) {
|
|
55360
|
+
let b = { type: "content_block_delta", index: y, delta: { type: "signature_delta", signature: x.delta.thinking.signature } };
|
|
55361
|
+
k(o.encode(`event: content_block_delta
|
|
55362
|
+
data: ${JSON.stringify(b)}
|
|
55368
55363
|
|
|
55369
55364
|
`));
|
|
55370
|
-
|
|
55371
|
-
|
|
55372
|
-
data: ${JSON.stringify(
|
|
55365
|
+
let _ = { type: "content_block_stop", index: y };
|
|
55366
|
+
k(o.encode(`event: content_block_stop
|
|
55367
|
+
data: ${JSON.stringify(_)}
|
|
55373
55368
|
|
|
55374
|
-
`))
|
|
55375
|
-
|
|
55376
|
-
|
|
55377
|
-
|
|
55378
|
-
data: ${JSON.stringify(
|
|
55369
|
+
`)), y++;
|
|
55370
|
+
} else if (x.delta.thinking.content) {
|
|
55371
|
+
let b = { type: "content_block_delta", index: y, delta: { type: "thinking_delta", thinking: x.delta.thinking.content || "" } };
|
|
55372
|
+
k(o.encode(`event: content_block_delta
|
|
55373
|
+
data: ${JSON.stringify(b)}
|
|
55379
55374
|
|
|
55380
55375
|
`));
|
|
55381
|
-
}
|
|
55382
55376
|
}
|
|
55383
|
-
|
|
55384
|
-
|
|
55385
|
-
|
|
55386
|
-
|
|
55387
|
-
|
|
55388
|
-
|
|
55389
|
-
|
|
55390
|
-
`));
|
|
55391
|
-
}
|
|
55392
|
-
if (!c && !i) {
|
|
55393
|
-
let k = { type: "content_block_delta", index: b.index || 0, delta: { type: "text_delta", text: b.delta.content } };
|
|
55394
|
-
S(o.encode(`event: content_block_delta
|
|
55395
|
-
data: ${JSON.stringify(k)}
|
|
55377
|
+
}
|
|
55378
|
+
if (x?.delta?.content && !s && !a) {
|
|
55379
|
+
if (h++, !d && !a) {
|
|
55380
|
+
d = true;
|
|
55381
|
+
let b = { type: "content_block_start", index: y, content_block: { type: "text", text: "" } };
|
|
55382
|
+
k(o.encode(`event: content_block_start
|
|
55383
|
+
data: ${JSON.stringify(b)}
|
|
55396
55384
|
|
|
55397
55385
|
`));
|
|
55398
|
-
}
|
|
55399
55386
|
}
|
|
55400
|
-
if (
|
|
55401
|
-
|
|
55402
|
-
|
|
55403
|
-
|
|
55404
|
-
if (c) break;
|
|
55405
|
-
let P = R.index ?? 0;
|
|
55406
|
-
if (k.has(P)) continue;
|
|
55407
|
-
if (k.add(P), !l.has(P)) {
|
|
55408
|
-
let y = p ? l.size + 1 : l.size;
|
|
55409
|
-
if (y !== 0) {
|
|
55410
|
-
let D = { type: "content_block_stop", index: y - 1 };
|
|
55411
|
-
S(o.encode(`event: content_block_stop
|
|
55412
|
-
data: ${JSON.stringify(D)}
|
|
55387
|
+
if (!s && !a) {
|
|
55388
|
+
let b = { type: "content_block_delta", index: y, delta: { type: "text_delta", text: x.delta.content } };
|
|
55389
|
+
k(o.encode(`event: content_block_delta
|
|
55390
|
+
data: ${JSON.stringify(b)}
|
|
55413
55391
|
|
|
55414
55392
|
`));
|
|
55415
|
-
|
|
55416
|
-
|
|
55417
|
-
|
|
55418
|
-
|
|
55419
|
-
|
|
55393
|
+
}
|
|
55394
|
+
}
|
|
55395
|
+
if (x?.delta?.tool_calls && !s && !a) {
|
|
55396
|
+
f++;
|
|
55397
|
+
let b = /* @__PURE__ */ new Set();
|
|
55398
|
+
for (let _ of x.delta.tool_calls) {
|
|
55399
|
+
if (s) break;
|
|
55400
|
+
let R = _.index ?? 0;
|
|
55401
|
+
if (b.has(R)) continue;
|
|
55402
|
+
if (b.add(R), !u.has(R)) {
|
|
55403
|
+
let C = d ? u.size + 1 : u.size;
|
|
55404
|
+
if (C !== 0) {
|
|
55405
|
+
m("content_block_stop2");
|
|
55406
|
+
let ne = { type: "content_block_stop", index: y };
|
|
55407
|
+
k(o.encode(`event: content_block_stop
|
|
55408
|
+
data: ${JSON.stringify(ne)}
|
|
55409
|
+
|
|
55410
|
+
`)), y++;
|
|
55411
|
+
}
|
|
55412
|
+
u.set(R, C);
|
|
55413
|
+
let E = _.id || `call_${Date.now()}_${R}`, w = _.function?.name || `tool_${R}`, O = { type: "content_block_start", index: y, content_block: { type: "tool_use", id: E, name: w, input: {} } };
|
|
55414
|
+
k(o.encode(`event: content_block_start
|
|
55415
|
+
data: ${JSON.stringify(O)}
|
|
55420
55416
|
|
|
55421
55417
|
`));
|
|
55422
|
-
|
|
55423
|
-
|
|
55424
|
-
|
|
55425
|
-
|
|
55426
|
-
|
|
55427
|
-
|
|
55428
|
-
|
|
55429
|
-
|
|
55430
|
-
|
|
55431
|
-
|
|
55432
|
-
|
|
55433
|
-
|
|
55434
|
-
w
|
|
55435
|
-
try {
|
|
55436
|
-
|
|
55437
|
-
|
|
55438
|
-
|
|
55439
|
-
} catch (D) {
|
|
55440
|
-
f("Tool call index:", P, "error", D.message);
|
|
55441
|
-
}
|
|
55442
|
-
} catch (T) {
|
|
55443
|
-
f("Tool call index:", P, "error", T.message);
|
|
55418
|
+
let L = { id: E, name: w, arguments: "", contentBlockIndex: C };
|
|
55419
|
+
p.set(R, L);
|
|
55420
|
+
} else if (_.id && _.function?.name) {
|
|
55421
|
+
let C = p.get(R);
|
|
55422
|
+
C.id.startsWith("call_") && C.name.startsWith("tool_") && (C.id = _.id, C.name = _.function.name);
|
|
55423
|
+
}
|
|
55424
|
+
if (_.function?.arguments && !s && !a) {
|
|
55425
|
+
if (u.get(R) === void 0) continue;
|
|
55426
|
+
let E = p.get(R);
|
|
55427
|
+
if (E) {
|
|
55428
|
+
E.arguments += _.function.arguments;
|
|
55429
|
+
try {
|
|
55430
|
+
let w = null, O = E.arguments.trim();
|
|
55431
|
+
if (O.startsWith("{") && O.endsWith("}")) try {
|
|
55432
|
+
w = JSON.parse(O);
|
|
55433
|
+
} catch (L) {
|
|
55434
|
+
m("Tool call index:", R, "error", L.message);
|
|
55444
55435
|
}
|
|
55436
|
+
} catch (w) {
|
|
55437
|
+
m("Tool call index:", R, "error", w.message);
|
|
55445
55438
|
}
|
|
55446
|
-
|
|
55447
|
-
|
|
55448
|
-
|
|
55449
|
-
|
|
55439
|
+
}
|
|
55440
|
+
try {
|
|
55441
|
+
let w = { type: "content_block_delta", index: y, delta: { type: "input_json_delta", partial_json: _.function.arguments } };
|
|
55442
|
+
k(o.encode(`event: content_block_delta
|
|
55443
|
+
data: ${JSON.stringify(w)}
|
|
55450
55444
|
|
|
55451
55445
|
`));
|
|
55452
|
-
|
|
55453
|
-
|
|
55454
|
-
|
|
55455
|
-
|
|
55456
|
-
data: ${JSON.stringify(
|
|
55446
|
+
} catch {
|
|
55447
|
+
try {
|
|
55448
|
+
let O = _.function.arguments.replace(/[\x00-\x1F\x7F-\x9F]/g, "").replace(/\\/g, "\\\\").replace(/"/g, '\\"'), L = { type: "content_block_delta", index: y, delta: { type: "input_json_delta", partial_json: O } };
|
|
55449
|
+
k(o.encode(`event: content_block_delta
|
|
55450
|
+
data: ${JSON.stringify(L)}
|
|
55457
55451
|
|
|
55458
55452
|
`));
|
|
55459
|
-
|
|
55460
|
-
|
|
55461
|
-
}
|
|
55453
|
+
} catch (O) {
|
|
55454
|
+
console.error(O);
|
|
55462
55455
|
}
|
|
55463
55456
|
}
|
|
55464
55457
|
}
|
|
55465
55458
|
}
|
|
55466
|
-
|
|
55467
|
-
|
|
55468
|
-
|
|
55469
|
-
|
|
55470
|
-
|
|
55471
|
-
|
|
55472
|
-
|
|
55473
|
-
}
|
|
55474
|
-
if (m > 0 && !c) {
|
|
55475
|
-
for (let [R, P] of l.entries()) {
|
|
55476
|
-
if (c) break;
|
|
55477
|
-
let H = u.get(R);
|
|
55478
|
-
if (H && H.arguments) try {
|
|
55479
|
-
let y = H.arguments.trim();
|
|
55480
|
-
y.startsWith("{") || (y = "{" + y), y.endsWith("}") || (y = y + "}"), JSON.parse(y);
|
|
55481
|
-
} catch (y) {
|
|
55482
|
-
f("Tool call final arguments parsing failed:", y.message, "original arguments:", H.arguments);
|
|
55483
|
-
}
|
|
55484
|
-
}
|
|
55485
|
-
let k = { type: "content_block_stop", index: l.size - 1 };
|
|
55486
|
-
S(o.encode(`event: content_block_stop
|
|
55487
|
-
data: ${JSON.stringify(k)}
|
|
55459
|
+
}
|
|
55460
|
+
if (x?.finish_reason && !s && !a) {
|
|
55461
|
+
if (a = true, h === 0 && f === 0 && console.error("Warning: No content in the stream response!"), (d || f > 0) && !s) {
|
|
55462
|
+
m("content_block_stop hasTextContentStarted");
|
|
55463
|
+
let b = { type: "content_block_stop", index: y };
|
|
55464
|
+
k(o.encode(`event: content_block_stop
|
|
55465
|
+
data: ${JSON.stringify(b)}
|
|
55488
55466
|
|
|
55489
55467
|
`));
|
|
55490
|
-
|
|
55491
|
-
|
|
55492
|
-
|
|
55493
|
-
|
|
55494
|
-
data: ${JSON.stringify(
|
|
55468
|
+
}
|
|
55469
|
+
if (!s) {
|
|
55470
|
+
let R = { type: "message_delta", delta: { stop_reason: { stop: "end_turn", length: "max_tokens", tool_calls: "tool_use", content_filter: "stop_sequence" }[x.finish_reason] || "end_turn", stop_sequence: null }, usage: { input_tokens: T.usage?.prompt_tokens || 0, output_tokens: T.usage?.completion_tokens || 0 } };
|
|
55471
|
+
k(o.encode(`event: message_delta
|
|
55472
|
+
data: ${JSON.stringify(R)}
|
|
55495
55473
|
|
|
55496
55474
|
`));
|
|
55497
|
-
|
|
55498
|
-
|
|
55499
|
-
|
|
55500
|
-
|
|
55501
|
-
data: ${JSON.stringify(
|
|
55475
|
+
}
|
|
55476
|
+
if (!s) {
|
|
55477
|
+
let b = { type: "message_stop" };
|
|
55478
|
+
k(o.encode(`event: message_stop
|
|
55479
|
+
data: ${JSON.stringify(b)}
|
|
55502
55480
|
|
|
55503
55481
|
`));
|
|
55504
|
-
}
|
|
55505
|
-
break;
|
|
55506
55482
|
}
|
|
55507
|
-
|
|
55508
|
-
f("parseError: ", A), _.errorChunks++;
|
|
55483
|
+
break;
|
|
55509
55484
|
}
|
|
55485
|
+
} catch (T) {
|
|
55486
|
+
m(`parseError: ${T.name} message: ${T.message} stack: ${T.stack} data: ${z}`);
|
|
55510
55487
|
}
|
|
55511
55488
|
}
|
|
55512
55489
|
}
|
|
55513
|
-
|
|
55514
|
-
} catch (
|
|
55515
|
-
if (!
|
|
55516
|
-
n.error(
|
|
55517
|
-
} catch (
|
|
55518
|
-
console.error(
|
|
55490
|
+
D();
|
|
55491
|
+
} catch (S) {
|
|
55492
|
+
if (!s) try {
|
|
55493
|
+
n.error(S);
|
|
55494
|
+
} catch (P) {
|
|
55495
|
+
console.error(P);
|
|
55519
55496
|
}
|
|
55520
55497
|
} finally {
|
|
55521
|
-
if (
|
|
55522
|
-
|
|
55523
|
-
} catch (
|
|
55524
|
-
console.error(
|
|
55498
|
+
if (I) try {
|
|
55499
|
+
I.releaseLock();
|
|
55500
|
+
} catch (S) {
|
|
55501
|
+
console.error(S);
|
|
55525
55502
|
}
|
|
55526
55503
|
}
|
|
55527
55504
|
}, cancel(n) {
|
|
55528
|
-
|
|
55505
|
+
m("cancle stream:", n);
|
|
55529
55506
|
} });
|
|
55530
55507
|
}
|
|
55531
55508
|
convertOpenAIResponseToAnthropic(e) {
|
|
55532
|
-
|
|
55509
|
+
m("Original OpenAI response:", JSON.stringify(e, null, 2));
|
|
55533
55510
|
let t = e.choices[0];
|
|
55534
55511
|
if (!t) throw new Error("No choices found in OpenAI response");
|
|
55535
55512
|
let n = [];
|
|
55536
|
-
t.message.content && n.push({ type: "text", text: t.message.content }), t.message.tool_calls && t.message.tool_calls.length > 0 && t.message.tool_calls.forEach((r,
|
|
55537
|
-
let
|
|
55513
|
+
t.message.content && n.push({ type: "text", text: t.message.content }), t.message.tool_calls && t.message.tool_calls.length > 0 && t.message.tool_calls.forEach((r, c) => {
|
|
55514
|
+
let l = {};
|
|
55538
55515
|
try {
|
|
55539
|
-
let
|
|
55540
|
-
typeof
|
|
55516
|
+
let d = r.function.arguments || "{}";
|
|
55517
|
+
typeof d == "object" ? l = d : typeof d == "string" && (l = JSON.parse(d));
|
|
55541
55518
|
} catch {
|
|
55542
|
-
|
|
55519
|
+
l = { text: r.function.arguments || "" };
|
|
55543
55520
|
}
|
|
55544
|
-
n.push({ type: "tool_use", id: r.id, name: r.function.name, input:
|
|
55521
|
+
n.push({ type: "tool_use", id: r.id, name: r.function.name, input: l });
|
|
55545
55522
|
});
|
|
55546
55523
|
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 } };
|
|
55547
|
-
return
|
|
55524
|
+
return m("Conversion complete, final Anthropic response:", JSON.stringify(o, null, 2)), o;
|
|
55548
55525
|
}
|
|
55549
55526
|
};
|
|
55550
|
-
var
|
|
55527
|
+
var M = class {
|
|
55551
55528
|
name = "gemini";
|
|
55552
55529
|
endPoint = "/v1beta/models/:modelAndAction";
|
|
55553
55530
|
transformRequestIn(e, t) {
|
|
@@ -55555,22 +55532,22 @@ var N = class {
|
|
|
55555
55532
|
let o;
|
|
55556
55533
|
n.role === "assistant" ? o = "model" : (["user", "system", "tool"].includes(n.role), o = "user");
|
|
55557
55534
|
let r = [];
|
|
55558
|
-
return typeof n.content == "string" ? r.push({ text: n.content }) : Array.isArray(n.content) && r.push(...n.content.map((
|
|
55559
|
-
if (
|
|
55560
|
-
})), Array.isArray(n.tool_calls) && r.push(...n.tool_calls.map((
|
|
55535
|
+
return typeof n.content == "string" ? r.push({ text: n.content }) : Array.isArray(n.content) && r.push(...n.content.map((c) => {
|
|
55536
|
+
if (c.type === "text") return { text: c.text || "" };
|
|
55537
|
+
})), Array.isArray(n.tool_calls) && r.push(...n.tool_calls.map((c) => ({ functionCall: { id: c.id || `tool_${Math.random().toString(36).substring(2, 15)}`, name: c.function.name, args: JSON.parse(c.function.arguments || "{}") } }))), { role: o, parts: r };
|
|
55561
55538
|
}), tools: [{ functionDeclarations: e.tools?.map((n) => (delete n.function.parameters?.$schema, delete n.function.parameters?.additionalProperties, n.function.parameters?.properties && Object.keys(n.function.parameters.properties).forEach((o) => {
|
|
55562
55539
|
delete n.function.parameters.properties[o].$schema, delete n.function.parameters.properties[o].additionalProperties, n.function.parameters.properties[o].items && typeof n.function.parameters.properties[o].items == "object" && (delete n.function.parameters.properties[o].items.$schema, delete n.function.parameters.properties[o].items.additionalProperties), n.function.parameters.properties[o].type === "string" && (["enum", "date-time"].includes(n.function.parameters.properties[o].format) || delete n.function.parameters.properties[o].format);
|
|
55563
55540
|
}), { 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 } } };
|
|
55564
55541
|
}
|
|
55565
55542
|
transformRequestOut(e) {
|
|
55566
|
-
let t = e.contents, n = e.tools, o = e.model, r = e.max_tokens,
|
|
55567
|
-
return Array.isArray(t) && t.forEach((
|
|
55568
|
-
typeof
|
|
55569
|
-
}), Array.isArray(n) && (
|
|
55570
|
-
Array.isArray(
|
|
55571
|
-
|
|
55543
|
+
let t = e.contents, n = e.tools, o = e.model, r = e.max_tokens, c = e.temperature, l = e.stream, d = e.tool_choice, a = { messages: [], model: o, max_tokens: r, temperature: c, stream: l, tool_choice: d };
|
|
55544
|
+
return Array.isArray(t) && t.forEach((p) => {
|
|
55545
|
+
typeof p == "string" ? a.messages.push({ role: "user", content: p }) : typeof p.text == "string" ? a.messages.push({ role: "user", content: p.text || null }) : p.role === "user" ? a.messages.push({ role: "user", content: p?.parts?.map((u) => ({ type: "text", text: u.text || "" })) || [] }) : p.role === "model" && a.messages.push({ role: "assistant", content: p?.parts?.map((u) => ({ type: "text", text: u.text || "" })) || [] });
|
|
55546
|
+
}), Array.isArray(n) && (a.tools = [], n.forEach((p) => {
|
|
55547
|
+
Array.isArray(p.functionDeclarations) && p.functionDeclarations.forEach((u) => {
|
|
55548
|
+
a.tools.push({ type: "function", function: { name: u.name, description: u.description, parameters: u.parameters } });
|
|
55572
55549
|
});
|
|
55573
|
-
})),
|
|
55550
|
+
})), a;
|
|
55574
55551
|
}
|
|
55575
55552
|
async transformResponseOut(e) {
|
|
55576
55553
|
if (e.headers.get("Content-Type")?.includes("application/json")) {
|
|
@@ -55580,23 +55557,23 @@ var N = class {
|
|
|
55580
55557
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55581
55558
|
if (!e.body) return e;
|
|
55582
55559
|
let t = new TextDecoder(), n = new TextEncoder(), o = new ReadableStream({ async start(r) {
|
|
55583
|
-
let
|
|
55560
|
+
let c = e.body.getReader();
|
|
55584
55561
|
try {
|
|
55585
55562
|
for (; ; ) {
|
|
55586
|
-
let { done:
|
|
55587
|
-
if (
|
|
55588
|
-
let
|
|
55589
|
-
if (
|
|
55563
|
+
let { done: l, value: d } = await c.read();
|
|
55564
|
+
if (l) break;
|
|
55565
|
+
let a = t.decode(d, { stream: true });
|
|
55566
|
+
if (a.startsWith("data: ")) a = a.slice(6).trim();
|
|
55590
55567
|
else break;
|
|
55591
|
-
|
|
55592
|
-
let
|
|
55593
|
-
`), tool_calls:
|
|
55594
|
-
|
|
55568
|
+
m("gemini chunk:", a), a = JSON.parse(a);
|
|
55569
|
+
let p = 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 || {}) } })), u = { choices: [{ delta: { role: "assistant", content: a.candidates[0].content.parts.filter((v) => v.text).map((v) => v.text).join(`
|
|
55570
|
+
`), tool_calls: p.length > 0 ? p : void 0 }, finish_reason: a.candidates[0].finishReason?.toLowerCase() || null, index: a.candidates[0].index || p.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" };
|
|
55571
|
+
m("gemini response:", JSON.stringify(u, null, 2)), r.enqueue(n.encode(`data: ${JSON.stringify(u)}
|
|
55595
55572
|
|
|
55596
55573
|
`));
|
|
55597
55574
|
}
|
|
55598
|
-
} catch (
|
|
55599
|
-
r.error(
|
|
55575
|
+
} catch (l) {
|
|
55576
|
+
r.error(l);
|
|
55600
55577
|
} finally {
|
|
55601
55578
|
r.close();
|
|
55602
55579
|
}
|
|
@@ -55606,7 +55583,7 @@ var N = class {
|
|
|
55606
55583
|
return e;
|
|
55607
55584
|
}
|
|
55608
55585
|
};
|
|
55609
|
-
var
|
|
55586
|
+
var H = class {
|
|
55610
55587
|
name = "deepseek";
|
|
55611
55588
|
transformRequestIn(e) {
|
|
55612
55589
|
return e.max_tokens && e.max_tokens > 8192 && (e.max_tokens = 8192), e;
|
|
@@ -55617,66 +55594,66 @@ var F = class {
|
|
|
55617
55594
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
55618
55595
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55619
55596
|
if (!e.body) return e;
|
|
55620
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = "", r = false,
|
|
55621
|
-
let
|
|
55597
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = "", r = false, c = new ReadableStream({ async start(l) {
|
|
55598
|
+
let d = e.body.getReader();
|
|
55622
55599
|
try {
|
|
55623
55600
|
for (; ; ) {
|
|
55624
|
-
let { done:
|
|
55625
|
-
if (
|
|
55626
|
-
let v = t.decode(
|
|
55601
|
+
let { done: a, value: p } = await d.read();
|
|
55602
|
+
if (a) break;
|
|
55603
|
+
let v = t.decode(p, { stream: true }).split(`
|
|
55627
55604
|
`);
|
|
55628
55605
|
for (let h of v) if (h.startsWith("data: ") && h.trim() !== "data: [DONE]") try {
|
|
55629
|
-
let
|
|
55630
|
-
if (
|
|
55631
|
-
o +=
|
|
55632
|
-
let
|
|
55633
|
-
delete
|
|
55634
|
-
let g = `data: ${JSON.stringify(
|
|
55606
|
+
let f = JSON.parse(h.slice(6));
|
|
55607
|
+
if (f.choices?.[0]?.delta?.reasoning_content) {
|
|
55608
|
+
o += f.choices[0].delta.reasoning_content;
|
|
55609
|
+
let s = { ...f, choices: [{ ...f.choices[0], delta: { ...f.choices[0].delta, thinking: { content: f.choices[0].delta.reasoning_content } } }] };
|
|
55610
|
+
delete s.choices[0].delta.reasoning_content;
|
|
55611
|
+
let g = `data: ${JSON.stringify(s)}
|
|
55635
55612
|
|
|
55636
55613
|
`;
|
|
55637
|
-
|
|
55614
|
+
l.enqueue(n.encode(g));
|
|
55638
55615
|
continue;
|
|
55639
55616
|
}
|
|
55640
|
-
if (
|
|
55617
|
+
if (f.choices?.[0]?.delta?.content && o && !r) {
|
|
55641
55618
|
r = true;
|
|
55642
|
-
let
|
|
55619
|
+
let s = Date.now().toString(), g = { ...f, choices: [{ ...f.choices[0], delta: { ...f.choices[0].delta, content: null, thinking: { content: o, signature: s } } }] };
|
|
55643
55620
|
delete g.choices[0].delta.reasoning_content;
|
|
55644
|
-
let
|
|
55621
|
+
let y = `data: ${JSON.stringify(g)}
|
|
55645
55622
|
|
|
55646
55623
|
`;
|
|
55647
|
-
|
|
55624
|
+
l.enqueue(n.encode(y));
|
|
55648
55625
|
}
|
|
55649
|
-
if (
|
|
55650
|
-
r &&
|
|
55651
|
-
let
|
|
55626
|
+
if (f.choices[0]?.delta?.reasoning_content && delete f.choices[0].delta.reasoning_content, f.choices?.[0]?.delta && Object.keys(f.choices[0].delta).length > 0) {
|
|
55627
|
+
r && f.choices[0].index++;
|
|
55628
|
+
let s = `data: ${JSON.stringify(f)}
|
|
55652
55629
|
|
|
55653
55630
|
`;
|
|
55654
|
-
|
|
55631
|
+
l.enqueue(n.encode(s));
|
|
55655
55632
|
}
|
|
55656
55633
|
} catch {
|
|
55657
|
-
|
|
55634
|
+
l.enqueue(n.encode(h + `
|
|
55658
55635
|
`));
|
|
55659
55636
|
}
|
|
55660
|
-
else
|
|
55637
|
+
else l.enqueue(n.encode(h + `
|
|
55661
55638
|
`));
|
|
55662
55639
|
}
|
|
55663
|
-
} catch (
|
|
55664
|
-
|
|
55640
|
+
} catch (a) {
|
|
55641
|
+
l.error(a);
|
|
55665
55642
|
} finally {
|
|
55666
55643
|
try {
|
|
55667
|
-
|
|
55668
|
-
} catch (
|
|
55669
|
-
console.error("Error releasing reader lock:",
|
|
55644
|
+
d.releaseLock();
|
|
55645
|
+
} catch (a) {
|
|
55646
|
+
console.error("Error releasing reader lock:", a);
|
|
55670
55647
|
}
|
|
55671
|
-
|
|
55648
|
+
l.close();
|
|
55672
55649
|
}
|
|
55673
55650
|
} });
|
|
55674
|
-
return new Response(
|
|
55651
|
+
return new Response(c, { status: e.status, statusText: e.statusText, headers: { "Content-Type": e.headers.get("Content-Type") || "text/plain", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
55675
55652
|
}
|
|
55676
55653
|
return e;
|
|
55677
55654
|
}
|
|
55678
55655
|
};
|
|
55679
|
-
var
|
|
55656
|
+
var $ = class {
|
|
55680
55657
|
name = "tooluse";
|
|
55681
55658
|
transformRequestIn(e) {
|
|
55682
55659
|
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.
|
|
@@ -55695,60 +55672,125 @@ Examples:
|
|
|
55695
55672
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
55696
55673
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55697
55674
|
if (!e.body) return e;
|
|
55698
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = -1, r = "",
|
|
55699
|
-
let
|
|
55675
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = -1, r = "", c = new ReadableStream({ async start(l) {
|
|
55676
|
+
let d = e.body.getReader();
|
|
55700
55677
|
try {
|
|
55701
55678
|
for (; ; ) {
|
|
55702
|
-
let { done:
|
|
55703
|
-
if (
|
|
55704
|
-
let v = t.decode(
|
|
55679
|
+
let { done: a, value: p } = await d.read();
|
|
55680
|
+
if (a) break;
|
|
55681
|
+
let v = t.decode(p, { stream: true }).split(`
|
|
55705
55682
|
`);
|
|
55706
55683
|
for (let h of v) if (h.startsWith("data: ") && h.trim() !== "data: [DONE]") try {
|
|
55707
|
-
let
|
|
55708
|
-
if (
|
|
55709
|
-
let
|
|
55710
|
-
if (
|
|
55711
|
-
o =
|
|
55684
|
+
let f = JSON.parse(h.slice(6));
|
|
55685
|
+
if (f.choices[0]?.delta?.tool_calls?.length) {
|
|
55686
|
+
let s = f.choices[0].delta.tool_calls[0];
|
|
55687
|
+
if (s.function?.name === "ExitTool") {
|
|
55688
|
+
o = s.index;
|
|
55712
55689
|
continue;
|
|
55713
|
-
} else if (o > -1 &&
|
|
55714
|
-
r +=
|
|
55690
|
+
} else if (o > -1 && s.index === o && s.function.arguments) {
|
|
55691
|
+
r += s.function.arguments;
|
|
55715
55692
|
try {
|
|
55716
55693
|
let g = JSON.parse(r);
|
|
55717
|
-
|
|
55718
|
-
let
|
|
55694
|
+
f.choices = [{ delta: { role: "assistant", content: g.response || "" } }];
|
|
55695
|
+
let y = `data: ${JSON.stringify(f)}
|
|
55719
55696
|
|
|
55720
55697
|
`;
|
|
55721
|
-
|
|
55698
|
+
l.enqueue(n.encode(y));
|
|
55722
55699
|
} catch {
|
|
55723
55700
|
}
|
|
55724
55701
|
continue;
|
|
55725
55702
|
}
|
|
55726
55703
|
}
|
|
55727
|
-
if (
|
|
55728
|
-
let
|
|
55704
|
+
if (f.choices?.[0]?.delta && Object.keys(f.choices[0].delta).length > 0) {
|
|
55705
|
+
let s = `data: ${JSON.stringify(f)}
|
|
55706
|
+
|
|
55707
|
+
`;
|
|
55708
|
+
l.enqueue(n.encode(s));
|
|
55709
|
+
}
|
|
55710
|
+
} catch {
|
|
55711
|
+
l.enqueue(n.encode(h + `
|
|
55712
|
+
`));
|
|
55713
|
+
}
|
|
55714
|
+
else l.enqueue(n.encode(h + `
|
|
55715
|
+
`));
|
|
55716
|
+
}
|
|
55717
|
+
} catch (a) {
|
|
55718
|
+
l.error(a);
|
|
55719
|
+
} finally {
|
|
55720
|
+
try {
|
|
55721
|
+
d.releaseLock();
|
|
55722
|
+
} catch (a) {
|
|
55723
|
+
console.error("Error releasing reader lock:", a);
|
|
55724
|
+
}
|
|
55725
|
+
l.close();
|
|
55726
|
+
}
|
|
55727
|
+
} });
|
|
55728
|
+
return new Response(c, { status: e.status, statusText: e.statusText, headers: { "Content-Type": e.headers.get("Content-Type") || "text/plain", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
55729
|
+
}
|
|
55730
|
+
return e;
|
|
55731
|
+
}
|
|
55732
|
+
};
|
|
55733
|
+
var F = class {
|
|
55734
|
+
name = "openrouter";
|
|
55735
|
+
async transformResponseOut(e) {
|
|
55736
|
+
if (e.headers.get("Content-Type")?.includes("application/json")) {
|
|
55737
|
+
let t = await e.json();
|
|
55738
|
+
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
55739
|
+
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55740
|
+
if (!e.body) return e;
|
|
55741
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = false, r = "", c = false, l = new ReadableStream({ async start(d) {
|
|
55742
|
+
let a = e.body.getReader();
|
|
55743
|
+
try {
|
|
55744
|
+
for (; ; ) {
|
|
55745
|
+
let { done: p, value: u } = await a.read();
|
|
55746
|
+
if (p) break;
|
|
55747
|
+
let h = t.decode(u, { stream: true }).split(`
|
|
55748
|
+
`);
|
|
55749
|
+
for (let f of h) if (f.startsWith("data: ") && f.trim() !== "data: [DONE]") try {
|
|
55750
|
+
let s = JSON.parse(f.slice(6));
|
|
55751
|
+
if (s.choices[0]?.delta?.content && !o && (o = true), s.choices?.[0]?.delta?.reasoning) {
|
|
55752
|
+
r += s.choices[0].delta.reasoning;
|
|
55753
|
+
let y = { ...s, choices: [{ ...s.choices[0], delta: { ...s.choices[0].delta, thinking: { content: s.choices[0].delta.reasoning } } }] };
|
|
55754
|
+
delete y.choices[0].delta.reasoning;
|
|
55755
|
+
let k = `data: ${JSON.stringify(y)}
|
|
55756
|
+
|
|
55757
|
+
`;
|
|
55758
|
+
d.enqueue(n.encode(k));
|
|
55759
|
+
continue;
|
|
55760
|
+
}
|
|
55761
|
+
if (s.choices?.[0]?.delta?.content && r && !c) {
|
|
55762
|
+
c = true;
|
|
55763
|
+
let y = Date.now().toString(), k = { ...s, choices: [{ ...s.choices[0], delta: { ...s.choices[0].delta, content: null, thinking: { content: r, signature: y } } }] };
|
|
55764
|
+
delete k.choices[0].delta.reasoning;
|
|
55765
|
+
let D = `data: ${JSON.stringify(k)}
|
|
55729
55766
|
|
|
55730
55767
|
`;
|
|
55731
|
-
d.enqueue(n.encode(
|
|
55768
|
+
d.enqueue(n.encode(D));
|
|
55732
55769
|
}
|
|
55770
|
+
s.choices[0]?.delta?.reasoning && delete s.choices[0].delta.reasoning, s.choices[0]?.delta?.tool_calls?.length && o && (s.choices[0].index += 1);
|
|
55771
|
+
let g = `data: ${JSON.stringify(s)}
|
|
55772
|
+
|
|
55773
|
+
`;
|
|
55774
|
+
d.enqueue(n.encode(g));
|
|
55733
55775
|
} catch {
|
|
55734
|
-
d.enqueue(n.encode(
|
|
55776
|
+
d.enqueue(n.encode(f + `
|
|
55735
55777
|
`));
|
|
55736
55778
|
}
|
|
55737
|
-
else d.enqueue(n.encode(
|
|
55779
|
+
else d.enqueue(n.encode(f + `
|
|
55738
55780
|
`));
|
|
55739
55781
|
}
|
|
55740
|
-
} catch (
|
|
55741
|
-
d.error(
|
|
55782
|
+
} catch (p) {
|
|
55783
|
+
d.error(p);
|
|
55742
55784
|
} finally {
|
|
55743
55785
|
try {
|
|
55744
|
-
|
|
55745
|
-
} catch (
|
|
55746
|
-
console.error("Error releasing reader lock:",
|
|
55786
|
+
a.releaseLock();
|
|
55787
|
+
} catch (p) {
|
|
55788
|
+
console.error("Error releasing reader lock:", p);
|
|
55747
55789
|
}
|
|
55748
55790
|
d.close();
|
|
55749
55791
|
}
|
|
55750
55792
|
} });
|
|
55751
|
-
return new Response(
|
|
55793
|
+
return new Response(l, { status: e.status, statusText: e.statusText, headers: { "Content-Type": e.headers.get("Content-Type") || "text/plain", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
55752
55794
|
}
|
|
55753
55795
|
return e;
|
|
55754
55796
|
}
|
|
@@ -55760,7 +55802,7 @@ var U = class {
|
|
|
55760
55802
|
}
|
|
55761
55803
|
transformers = /* @__PURE__ */ new Map();
|
|
55762
55804
|
registerTransformer(e, t) {
|
|
55763
|
-
this.transformers.set(e, t),
|
|
55805
|
+
this.transformers.set(e, t), m(`register transformer: ${e}${t.endPoint ? ` (endpoint: ${t.endPoint})` : " (no endpoint)"}`);
|
|
55764
55806
|
}
|
|
55765
55807
|
getTransformer(e) {
|
|
55766
55808
|
return this.transformers.get(e);
|
|
@@ -55789,7 +55831,7 @@ var U = class {
|
|
|
55789
55831
|
async registerTransformerFromConfig(e) {
|
|
55790
55832
|
try {
|
|
55791
55833
|
if (e.path) {
|
|
55792
|
-
let t =
|
|
55834
|
+
let t = V(e.path);
|
|
55793
55835
|
if (t) {
|
|
55794
55836
|
let n = new t(e.options);
|
|
55795
55837
|
if (!n.name) throw new Error(`Transformer instance from ${e.path} does not have a name property.`);
|
|
@@ -55798,22 +55840,22 @@ var U = class {
|
|
|
55798
55840
|
}
|
|
55799
55841
|
return false;
|
|
55800
55842
|
} catch (t) {
|
|
55801
|
-
return
|
|
55843
|
+
return m(`load transformer (${e.path}):`, t), false;
|
|
55802
55844
|
}
|
|
55803
55845
|
}
|
|
55804
55846
|
async initialize() {
|
|
55805
55847
|
try {
|
|
55806
55848
|
await this.registerDefaultTransformersInternal(), await this.loadFromConfig();
|
|
55807
55849
|
} catch (e) {
|
|
55808
|
-
|
|
55850
|
+
m("TransformerService init error:", e);
|
|
55809
55851
|
}
|
|
55810
55852
|
}
|
|
55811
55853
|
async registerDefaultTransformersInternal() {
|
|
55812
55854
|
try {
|
|
55813
|
-
let e = new
|
|
55814
|
-
this.registerTransformer(e.name, e), this.registerTransformer(t.name, t), this.registerTransformer(n.name, n), this.registerTransformer(o.name, o);
|
|
55855
|
+
let e = new N(), t = new M(), n = new H(), o = new $(), r = new F();
|
|
55856
|
+
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);
|
|
55815
55857
|
} catch (e) {
|
|
55816
|
-
|
|
55858
|
+
m("transformer regist error:", e);
|
|
55817
55859
|
}
|
|
55818
55860
|
}
|
|
55819
55861
|
async loadFromConfig() {
|
|
@@ -55821,18 +55863,18 @@ var U = class {
|
|
|
55821
55863
|
for (let t of e) await this.registerTransformerFromConfig(t);
|
|
55822
55864
|
}
|
|
55823
55865
|
};
|
|
55824
|
-
function
|
|
55825
|
-
let
|
|
55826
|
-
return
|
|
55866
|
+
function le() {
|
|
55867
|
+
let i = (0, import_fastify.default)({});
|
|
55868
|
+
return i.setErrorHandler(X), i.register(import_cors.default), i;
|
|
55827
55869
|
}
|
|
55828
|
-
var
|
|
55870
|
+
var B = class {
|
|
55829
55871
|
app;
|
|
55830
55872
|
configService;
|
|
55831
55873
|
llmService;
|
|
55832
55874
|
providerService;
|
|
55833
55875
|
transformerService;
|
|
55834
55876
|
constructor(e = {}) {
|
|
55835
|
-
this.configService = new j(
|
|
55877
|
+
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();
|
|
55836
55878
|
}
|
|
55837
55879
|
async register(e, t) {
|
|
55838
55880
|
await this.app.register(e, t);
|
|
@@ -55846,31 +55888,29 @@ var z = class {
|
|
|
55846
55888
|
try {
|
|
55847
55889
|
let r = n.body;
|
|
55848
55890
|
if (!r || !r.model) return o.code(400).send({ error: "Missing model in request body" });
|
|
55849
|
-
let [
|
|
55850
|
-
r.model =
|
|
55891
|
+
let [c, l] = r.model.split(",");
|
|
55892
|
+
r.model = l, n.provider = c;
|
|
55851
55893
|
return;
|
|
55852
55894
|
} catch (r) {
|
|
55853
55895
|
return n.log.error("Error in modelProviderMiddleware:", r), o.code(500).send({ error: "Internal server error" });
|
|
55854
55896
|
}
|
|
55855
55897
|
}), this.app.register(Z);
|
|
55856
55898
|
let e = await this.app.listen({ port: parseInt(this.configService.get("PORT") || "3000", 10), host: this.configService.get("HOST") || "127.0.0.1" });
|
|
55857
|
-
|
|
55899
|
+
m(`\u{1F680} LLMs API server listening on ${e}`);
|
|
55858
55900
|
let t = async (n) => {
|
|
55859
|
-
|
|
55901
|
+
m(`Received ${n}, shutting down gracefully...`), await this.app.close(), process.exit(0);
|
|
55860
55902
|
};
|
|
55861
55903
|
process.on("SIGINT", () => t("SIGINT")), process.on("SIGTERM", () => t("SIGTERM"));
|
|
55862
55904
|
} catch (e) {
|
|
55863
|
-
|
|
55905
|
+
m(`Error starting server: ${e}`), process.exit(1);
|
|
55864
55906
|
}
|
|
55865
55907
|
}
|
|
55866
55908
|
};
|
|
55867
|
-
var
|
|
55909
|
+
var Pt = B;
|
|
55868
55910
|
|
|
55869
55911
|
// src/server.ts
|
|
55870
55912
|
var createServer = (config) => {
|
|
55871
|
-
const server = new
|
|
55872
|
-
initialConfig: config
|
|
55873
|
-
});
|
|
55913
|
+
const server = new Pt(config);
|
|
55874
55914
|
return server;
|
|
55875
55915
|
};
|
|
55876
55916
|
|
|
@@ -56089,10 +56129,17 @@ async function run(options = {}) {
|
|
|
56089
56129
|
});
|
|
56090
56130
|
const servicePort = process.env.SERVICE_PORT ? parseInt(process.env.SERVICE_PORT) : port;
|
|
56091
56131
|
const server = createServer({
|
|
56092
|
-
|
|
56093
|
-
|
|
56094
|
-
|
|
56095
|
-
|
|
56132
|
+
jsonPath: CONFIG_FILE,
|
|
56133
|
+
initialConfig: {
|
|
56134
|
+
// ...config,
|
|
56135
|
+
providers: config.Providers || config.providers,
|
|
56136
|
+
PORT: servicePort,
|
|
56137
|
+
LOG_FILE: (0, import_path2.join)(
|
|
56138
|
+
(0, import_os.homedir)(),
|
|
56139
|
+
".claude-code-router",
|
|
56140
|
+
"claude-code-router.log"
|
|
56141
|
+
)
|
|
56142
|
+
}
|
|
56096
56143
|
});
|
|
56097
56144
|
server.addHook(
|
|
56098
56145
|
"preHandler",
|
|
@@ -56182,7 +56229,7 @@ async function executeCodeCommand(args = []) {
|
|
|
56182
56229
|
}
|
|
56183
56230
|
|
|
56184
56231
|
// package.json
|
|
56185
|
-
var version = "1.0.
|
|
56232
|
+
var version = "1.0.13";
|
|
56186
56233
|
|
|
56187
56234
|
// src/cli.ts
|
|
56188
56235
|
var import_child_process2 = require("child_process");
|