@musistudio/claude-code-router 1.0.14 → 1.0.16
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/README.md +9 -2
- package/dist/cli.js +615 -580
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -270,7 +270,7 @@ var require_queue = __commonJS({
|
|
|
270
270
|
queue.drained = drained;
|
|
271
271
|
return queue;
|
|
272
272
|
function push(value) {
|
|
273
|
-
var
|
|
273
|
+
var p2 = new Promise(function(resolve, reject) {
|
|
274
274
|
pushCb(value, function(err, result) {
|
|
275
275
|
if (err) {
|
|
276
276
|
reject(err);
|
|
@@ -279,11 +279,11 @@ var require_queue = __commonJS({
|
|
|
279
279
|
resolve(result);
|
|
280
280
|
});
|
|
281
281
|
});
|
|
282
|
-
|
|
283
|
-
return
|
|
282
|
+
p2.catch(noop);
|
|
283
|
+
return p2;
|
|
284
284
|
}
|
|
285
285
|
function unshift(value) {
|
|
286
|
-
var
|
|
286
|
+
var p2 = new Promise(function(resolve, reject) {
|
|
287
287
|
unshiftCb(value, function(err, result) {
|
|
288
288
|
if (err) {
|
|
289
289
|
reject(err);
|
|
@@ -292,11 +292,11 @@ var require_queue = __commonJS({
|
|
|
292
292
|
resolve(result);
|
|
293
293
|
});
|
|
294
294
|
});
|
|
295
|
-
|
|
296
|
-
return
|
|
295
|
+
p2.catch(noop);
|
|
296
|
+
return p2;
|
|
297
297
|
}
|
|
298
298
|
function drained() {
|
|
299
|
-
var
|
|
299
|
+
var p2 = new Promise(function(resolve) {
|
|
300
300
|
process.nextTick(function() {
|
|
301
301
|
if (queue.idle()) {
|
|
302
302
|
resolve();
|
|
@@ -310,7 +310,7 @@ var require_queue = __commonJS({
|
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
});
|
|
313
|
-
return
|
|
313
|
+
return p2;
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
module2.exports = fastqueue;
|
|
@@ -918,8 +918,8 @@ var require_thenify = __commonJS({
|
|
|
918
918
|
}
|
|
919
919
|
debug("thenify");
|
|
920
920
|
return (resolve, reject) => {
|
|
921
|
-
const
|
|
922
|
-
return
|
|
921
|
+
const p2 = this._loadRegistered();
|
|
922
|
+
return p2.then(() => {
|
|
923
923
|
this[kThenifyDoNotWrap] = true;
|
|
924
924
|
return resolve(this._server);
|
|
925
925
|
}, reject);
|
|
@@ -3644,11 +3644,11 @@ var require_parse = __commonJS({
|
|
|
3644
3644
|
const wildcards = [];
|
|
3645
3645
|
var wcLen = 0;
|
|
3646
3646
|
const secret = paths.reduce(function(o, strPath, ix) {
|
|
3647
|
-
var path3 = strPath.match(rx).map((
|
|
3647
|
+
var path3 = strPath.match(rx).map((p2) => p2.replace(/'|"|`/g, ""));
|
|
3648
3648
|
const leadingBracket = strPath[0] === "[";
|
|
3649
|
-
path3 = path3.map((
|
|
3650
|
-
if (
|
|
3651
|
-
else return
|
|
3649
|
+
path3 = path3.map((p2) => {
|
|
3650
|
+
if (p2[0] === "[") return p2.substr(1, p2.length - 2);
|
|
3651
|
+
else return p2;
|
|
3652
3652
|
});
|
|
3653
3653
|
const star = path3.indexOf("*");
|
|
3654
3654
|
if (star > -1) {
|
|
@@ -3722,14 +3722,14 @@ var require_redactor = __commonJS({
|
|
|
3722
3722
|
const { index, input } = match;
|
|
3723
3723
|
if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1)));
|
|
3724
3724
|
}
|
|
3725
|
-
var existence = hops.map((
|
|
3725
|
+
var existence = hops.map((p2) => `o${delim}${p2}`).join(" && ");
|
|
3726
3726
|
if (existence.length === 0) existence += `o${delim}${path3} != null`;
|
|
3727
3727
|
else existence += ` && o${delim}${path3} != null`;
|
|
3728
3728
|
const circularDetection = `
|
|
3729
3729
|
switch (true) {
|
|
3730
|
-
${hops.reverse().map((
|
|
3731
|
-
case o${delim}${
|
|
3732
|
-
secret[${escPath}].circle = ${JSON.stringify(
|
|
3730
|
+
${hops.reverse().map((p2) => `
|
|
3731
|
+
case o${delim}${p2} === censor:
|
|
3732
|
+
secret[${escPath}].circle = ${JSON.stringify(p2)}
|
|
3733
3733
|
break
|
|
3734
3734
|
`).join("\n")}
|
|
3735
3735
|
}
|
|
@@ -3928,12 +3928,12 @@ var require_modifiers = __commonJS({
|
|
|
3928
3928
|
}
|
|
3929
3929
|
}
|
|
3930
3930
|
}
|
|
3931
|
-
function get(o,
|
|
3931
|
+
function get(o, p2) {
|
|
3932
3932
|
var i = -1;
|
|
3933
|
-
var l =
|
|
3933
|
+
var l = p2.length;
|
|
3934
3934
|
var n = o;
|
|
3935
3935
|
while (n != null && ++i < l) {
|
|
3936
|
-
n = n[
|
|
3936
|
+
n = n[p2[i]];
|
|
3937
3937
|
}
|
|
3938
3938
|
return n;
|
|
3939
3939
|
}
|
|
@@ -13236,7 +13236,7 @@ var require_util = __commonJS({
|
|
|
13236
13236
|
}
|
|
13237
13237
|
exports2.evaluatedPropsToName = evaluatedPropsToName;
|
|
13238
13238
|
function setEvaluated(gen, props, ps) {
|
|
13239
|
-
Object.keys(ps).forEach((
|
|
13239
|
+
Object.keys(ps).forEach((p2) => gen.assign((0, codegen_1._)`${props}${(0, codegen_1.getProperty)(p2)}`, true));
|
|
13240
13240
|
}
|
|
13241
13241
|
exports2.setEvaluated = setEvaluated;
|
|
13242
13242
|
var snippets = {};
|
|
@@ -13809,11 +13809,11 @@ var require_code2 = __commonJS({
|
|
|
13809
13809
|
}
|
|
13810
13810
|
exports2.noPropertyInData = noPropertyInData;
|
|
13811
13811
|
function allSchemaProperties(schemaMap) {
|
|
13812
|
-
return schemaMap ? Object.keys(schemaMap).filter((
|
|
13812
|
+
return schemaMap ? Object.keys(schemaMap).filter((p2) => p2 !== "__proto__") : [];
|
|
13813
13813
|
}
|
|
13814
13814
|
exports2.allSchemaProperties = allSchemaProperties;
|
|
13815
13815
|
function schemaProperties(it, schemaMap) {
|
|
13816
|
-
return allSchemaProperties(schemaMap).filter((
|
|
13816
|
+
return allSchemaProperties(schemaMap).filter((p2) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p2]));
|
|
13817
13817
|
}
|
|
13818
13818
|
exports2.schemaProperties = schemaProperties;
|
|
13819
13819
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
@@ -14291,12 +14291,12 @@ var require_resolve = __commonJS({
|
|
|
14291
14291
|
function getFullPath(resolver, id2 = "", normalize) {
|
|
14292
14292
|
if (normalize !== false)
|
|
14293
14293
|
id2 = normalizeId(id2);
|
|
14294
|
-
const
|
|
14295
|
-
return _getFullPath(resolver,
|
|
14294
|
+
const p2 = resolver.parse(id2);
|
|
14295
|
+
return _getFullPath(resolver, p2);
|
|
14296
14296
|
}
|
|
14297
14297
|
exports2.getFullPath = getFullPath;
|
|
14298
|
-
function _getFullPath(resolver,
|
|
14299
|
-
const serialized = resolver.serialize(
|
|
14298
|
+
function _getFullPath(resolver, p2) {
|
|
14299
|
+
const serialized = resolver.serialize(p2);
|
|
14300
14300
|
return serialized.split("#")[0] + "#";
|
|
14301
14301
|
}
|
|
14302
14302
|
exports2._getFullPath = _getFullPath;
|
|
@@ -15071,11 +15071,11 @@ var require_compile = __commonJS({
|
|
|
15071
15071
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
15072
15072
|
}
|
|
15073
15073
|
function resolveSchema(root, ref) {
|
|
15074
|
-
const
|
|
15075
|
-
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver,
|
|
15074
|
+
const p2 = this.opts.uriResolver.parse(ref);
|
|
15075
|
+
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p2);
|
|
15076
15076
|
let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root.baseId, void 0);
|
|
15077
15077
|
if (Object.keys(root.schema).length > 0 && refPath === baseId) {
|
|
15078
|
-
return getJsonPointer.call(this,
|
|
15078
|
+
return getJsonPointer.call(this, p2, root);
|
|
15079
15079
|
}
|
|
15080
15080
|
const id2 = (0, resolve_1.normalizeId)(refPath);
|
|
15081
15081
|
const schOrRef = this.refs[id2] || this.schemas[id2];
|
|
@@ -15083,7 +15083,7 @@ var require_compile = __commonJS({
|
|
|
15083
15083
|
const sch = resolveSchema.call(this, root, schOrRef);
|
|
15084
15084
|
if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
|
|
15085
15085
|
return;
|
|
15086
|
-
return getJsonPointer.call(this,
|
|
15086
|
+
return getJsonPointer.call(this, p2, sch);
|
|
15087
15087
|
}
|
|
15088
15088
|
if (typeof (schOrRef === null || schOrRef === void 0 ? void 0 : schOrRef.schema) !== "object")
|
|
15089
15089
|
return;
|
|
@@ -15097,7 +15097,7 @@ var require_compile = __commonJS({
|
|
|
15097
15097
|
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
15098
15098
|
return new SchemaEnv({ schema, schemaId, root, baseId });
|
|
15099
15099
|
}
|
|
15100
|
-
return getJsonPointer.call(this,
|
|
15100
|
+
return getJsonPointer.call(this, p2, schOrRef);
|
|
15101
15101
|
}
|
|
15102
15102
|
exports2.resolveSchema = resolveSchema;
|
|
15103
15103
|
var PREVENT_SCOPE_CHANGE = /* @__PURE__ */ new Set([
|
|
@@ -16048,9 +16048,9 @@ var require_core = __commonJS({
|
|
|
16048
16048
|
this.addSchema(_schema, ref, meta);
|
|
16049
16049
|
}
|
|
16050
16050
|
async function _loadSchema(ref) {
|
|
16051
|
-
const
|
|
16052
|
-
if (
|
|
16053
|
-
return
|
|
16051
|
+
const p2 = this._loading[ref];
|
|
16052
|
+
if (p2)
|
|
16053
|
+
return p2;
|
|
16054
16054
|
try {
|
|
16055
16055
|
return await (this._loading[ref] = loadSchema(ref));
|
|
16056
16056
|
} finally {
|
|
@@ -17523,12 +17523,12 @@ var require_additionalProperties = __commonJS({
|
|
|
17523
17523
|
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
|
|
17524
17524
|
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key);
|
|
17525
17525
|
} else if (props.length) {
|
|
17526
|
-
definedProp = (0, codegen_1.or)(...props.map((
|
|
17526
|
+
definedProp = (0, codegen_1.or)(...props.map((p2) => (0, codegen_1._)`${key} === ${p2}`));
|
|
17527
17527
|
} else {
|
|
17528
17528
|
definedProp = codegen_1.nil;
|
|
17529
17529
|
}
|
|
17530
17530
|
if (patProps.length) {
|
|
17531
|
-
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((
|
|
17531
|
+
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p2) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p2)}.test(${key})`));
|
|
17532
17532
|
}
|
|
17533
17533
|
return (0, codegen_1.not)(definedProp);
|
|
17534
17534
|
}
|
|
@@ -17608,7 +17608,7 @@ var require_properties = __commonJS({
|
|
|
17608
17608
|
if (it.opts.unevaluated && allProps.length && it.props !== true) {
|
|
17609
17609
|
it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props);
|
|
17610
17610
|
}
|
|
17611
|
-
const properties = allProps.filter((
|
|
17611
|
+
const properties = allProps.filter((p2) => !(0, util_1.alwaysValidSchema)(it, schema[p2]));
|
|
17612
17612
|
if (properties.length === 0)
|
|
17613
17613
|
return;
|
|
17614
17614
|
const valid = gen.name("valid");
|
|
@@ -17658,7 +17658,7 @@ var require_patternProperties = __commonJS({
|
|
|
17658
17658
|
const { gen, schema, data, parentSchema, it } = cxt;
|
|
17659
17659
|
const { opts } = it;
|
|
17660
17660
|
const patterns = (0, code_1.allSchemaProperties)(schema);
|
|
17661
|
-
const alwaysValidPatterns = patterns.filter((
|
|
17661
|
+
const alwaysValidPatterns = patterns.filter((p2) => (0, util_1.alwaysValidSchema)(it, schema[p2]));
|
|
17662
17662
|
if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) {
|
|
17663
17663
|
return;
|
|
17664
17664
|
}
|
|
@@ -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 m = +matches[2];
|
|
21502
21502
|
const d = +matches[3];
|
|
21503
|
-
return
|
|
21504
|
-
|
|
21503
|
+
return m >= 1 && m <= 12 && d >= 1 && (d <= DAYS[m] || // leap year: https://tools.ietf.org/html/rfc3339#appendix-C
|
|
21504
|
+
m === 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);
|
|
@@ -21778,8 +21778,8 @@ var require_properties2 = __commonJS({
|
|
|
21778
21778
|
const optProps = parentSchema.optionalProperties;
|
|
21779
21779
|
if (!(props && optProps))
|
|
21780
21780
|
return false;
|
|
21781
|
-
for (const
|
|
21782
|
-
if (Object.prototype.hasOwnProperty.call(optProps,
|
|
21781
|
+
for (const p2 in props) {
|
|
21782
|
+
if (Object.prototype.hasOwnProperty.call(optProps, p2))
|
|
21783
21783
|
return true;
|
|
21784
21784
|
}
|
|
21785
21785
|
return false;
|
|
@@ -21787,10 +21787,10 @@ var require_properties2 = __commonJS({
|
|
|
21787
21787
|
function schemaProperties(keyword) {
|
|
21788
21788
|
const schema = parentSchema[keyword];
|
|
21789
21789
|
const allPs = schema ? (0, code_1.allSchemaProperties)(schema) : [];
|
|
21790
|
-
if (it.jtdDiscriminator && allPs.some((
|
|
21790
|
+
if (it.jtdDiscriminator && allPs.some((p2) => p2 === it.jtdDiscriminator)) {
|
|
21791
21791
|
throw new Error(`JTD: discriminator tag used in ${keyword}`);
|
|
21792
21792
|
}
|
|
21793
|
-
const ps = allPs.filter((
|
|
21793
|
+
const ps = allPs.filter((p2) => !(0, util_1.alwaysValidSchema)(it, schema[p2]));
|
|
21794
21794
|
return [allPs, ps];
|
|
21795
21795
|
}
|
|
21796
21796
|
function validateProps(props, keyword, required) {
|
|
@@ -21841,7 +21841,7 @@ var require_properties2 = __commonJS({
|
|
|
21841
21841
|
}
|
|
21842
21842
|
} else if (props.length || jtdDiscriminator !== void 0) {
|
|
21843
21843
|
const ps = jtdDiscriminator === void 0 ? props : [jtdDiscriminator].concat(props);
|
|
21844
|
-
additional = (0, codegen_1.and)(...ps.map((
|
|
21844
|
+
additional = (0, codegen_1.and)(...ps.map((p2) => (0, codegen_1._)`${key} !== ${p2}`));
|
|
21845
21845
|
} else {
|
|
21846
21846
|
additional = true;
|
|
21847
21847
|
}
|
|
@@ -22397,7 +22397,7 @@ var require_serialize = __commonJS({
|
|
|
22397
22397
|
serializeCode({ ...cxt, schema: propSchema, data: value });
|
|
22398
22398
|
}
|
|
22399
22399
|
function isAdditional(key, ps) {
|
|
22400
|
-
return ps.length ? (0, codegen_1.and)(...ps.map((
|
|
22400
|
+
return ps.length ? (0, codegen_1.and)(...ps.map((p2) => (0, codegen_1._)`${key} !== ${p2}`)) : true;
|
|
22401
22401
|
}
|
|
22402
22402
|
}
|
|
22403
22403
|
function serializeType(cxt) {
|
|
@@ -22839,7 +22839,7 @@ var require_parse2 = __commonJS({
|
|
|
22839
22839
|
});
|
|
22840
22840
|
if (properties) {
|
|
22841
22841
|
const hasProp = (0, code_1.hasPropFunc)(gen);
|
|
22842
|
-
const allProps = (0, codegen_1.and)(...Object.keys(properties).map((
|
|
22842
|
+
const allProps = (0, codegen_1.and)(...Object.keys(properties).map((p2) => (0, codegen_1._)`${hasProp}.call(${data}, ${p2})`));
|
|
22843
22843
|
gen.if((0, codegen_1.not)(allProps), () => parsingError(cxt, (0, codegen_1.str)`missing required properties`));
|
|
22844
22844
|
}
|
|
22845
22845
|
}
|
|
@@ -23504,7 +23504,7 @@ var require_re = __commonJS({
|
|
|
23504
23504
|
} = require_constants2();
|
|
23505
23505
|
var debug = require_debug2();
|
|
23506
23506
|
exports2 = module2.exports = {};
|
|
23507
|
-
var
|
|
23507
|
+
var re = exports2.re = [];
|
|
23508
23508
|
var safeRe = exports2.safeRe = [];
|
|
23509
23509
|
var src = exports2.src = [];
|
|
23510
23510
|
var safeSrc = exports2.safeSrc = [];
|
|
@@ -23529,7 +23529,7 @@ var require_re = __commonJS({
|
|
|
23529
23529
|
t[name] = index;
|
|
23530
23530
|
src[index] = value;
|
|
23531
23531
|
safeSrc[index] = safe;
|
|
23532
|
-
|
|
23532
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
23533
23533
|
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
23534
23534
|
};
|
|
23535
23535
|
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
@@ -23628,7 +23628,7 @@ var require_semver = __commonJS({
|
|
|
23628
23628
|
"use strict";
|
|
23629
23629
|
var debug = require_debug2();
|
|
23630
23630
|
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants2();
|
|
23631
|
-
var { safeRe:
|
|
23631
|
+
var { safeRe: re, t } = require_re();
|
|
23632
23632
|
var parseOptions = require_parse_options();
|
|
23633
23633
|
var { compareIdentifiers } = require_identifiers();
|
|
23634
23634
|
var SemVer = class _SemVer {
|
|
@@ -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 m = version2.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
23656
|
+
if (!m) {
|
|
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 = +m[1];
|
|
23661
|
+
this.minor = +m[2];
|
|
23662
|
+
this.patch = +m[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 (!m[4]) {
|
|
23673
23673
|
this.prerelease = [];
|
|
23674
23674
|
} else {
|
|
23675
|
-
this.prerelease =
|
|
23675
|
+
this.prerelease = m[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 = m[5] ? m[5].split(".") : [];
|
|
23686
23686
|
this.format();
|
|
23687
23687
|
}
|
|
23688
23688
|
format() {
|
|
@@ -23773,7 +23773,7 @@ var require_semver = __commonJS({
|
|
|
23773
23773
|
throw new Error("invalid increment argument: identifier is empty");
|
|
23774
23774
|
}
|
|
23775
23775
|
if (identifier) {
|
|
23776
|
-
const match = `-${identifier}`.match(this.options.loose ?
|
|
23776
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
23777
23777
|
if (!match || match[1] !== identifier) {
|
|
23778
23778
|
throw new Error(`invalid identifier: ${identifier}`);
|
|
23779
23779
|
}
|
|
@@ -24222,7 +24222,7 @@ var require_coerce = __commonJS({
|
|
|
24222
24222
|
"use strict";
|
|
24223
24223
|
var SemVer = require_semver();
|
|
24224
24224
|
var parse = require_parse3();
|
|
24225
|
-
var { safeRe:
|
|
24225
|
+
var { safeRe: re, t } = require_re();
|
|
24226
24226
|
var coerce = (version2, options) => {
|
|
24227
24227
|
if (version2 instanceof SemVer) {
|
|
24228
24228
|
return version2;
|
|
@@ -24236,9 +24236,9 @@ var require_coerce = __commonJS({
|
|
|
24236
24236
|
options = options || {};
|
|
24237
24237
|
let match = null;
|
|
24238
24238
|
if (!options.rtl) {
|
|
24239
|
-
match = version2.match(options.includePrerelease ?
|
|
24239
|
+
match = version2.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
24240
24240
|
} else {
|
|
24241
|
-
const coerceRtlRegex = options.includePrerelease ?
|
|
24241
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
24242
24242
|
let next;
|
|
24243
24243
|
while ((next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
|
|
24244
24244
|
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
@@ -24377,20 +24377,20 @@ var require_range = __commonJS({
|
|
|
24377
24377
|
return cached;
|
|
24378
24378
|
}
|
|
24379
24379
|
const loose = this.options.loose;
|
|
24380
|
-
const hr = loose ?
|
|
24380
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
24381
24381
|
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
24382
24382
|
debug("hyphen replace", range);
|
|
24383
|
-
range = range.replace(
|
|
24383
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
24384
24384
|
debug("comparator trim", range);
|
|
24385
|
-
range = range.replace(
|
|
24385
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
24386
24386
|
debug("tilde trim", range);
|
|
24387
|
-
range = range.replace(
|
|
24387
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
24388
24388
|
debug("caret trim", range);
|
|
24389
24389
|
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
24390
24390
|
if (loose) {
|
|
24391
24391
|
rangeList = rangeList.filter((comp) => {
|
|
24392
24392
|
debug("loose invalid filter", comp, this.options);
|
|
24393
|
-
return !!comp.match(
|
|
24393
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
24394
24394
|
});
|
|
24395
24395
|
}
|
|
24396
24396
|
debug("range list", rangeList);
|
|
@@ -24451,7 +24451,7 @@ var require_range = __commonJS({
|
|
|
24451
24451
|
var debug = require_debug2();
|
|
24452
24452
|
var SemVer = require_semver();
|
|
24453
24453
|
var {
|
|
24454
|
-
safeRe:
|
|
24454
|
+
safeRe: re,
|
|
24455
24455
|
t,
|
|
24456
24456
|
comparatorTrimReplace,
|
|
24457
24457
|
tildeTrimReplace,
|
|
@@ -24489,21 +24489,21 @@ var require_range = __commonJS({
|
|
|
24489
24489
|
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
24490
24490
|
};
|
|
24491
24491
|
var replaceTilde = (comp, options) => {
|
|
24492
|
-
const r = options.loose ?
|
|
24493
|
-
return comp.replace(r, (_,
|
|
24494
|
-
debug("tilde", comp, _,
|
|
24492
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
24493
|
+
return comp.replace(r, (_, M, m, p2, pr) => {
|
|
24494
|
+
debug("tilde", comp, _, M, m, p2, pr);
|
|
24495
24495
|
let ret;
|
|
24496
|
-
if (isX(
|
|
24496
|
+
if (isX(M)) {
|
|
24497
24497
|
ret = "";
|
|
24498
|
-
} else if (isX(
|
|
24499
|
-
ret = `>=${
|
|
24500
|
-
} else if (isX(
|
|
24501
|
-
ret = `>=${
|
|
24498
|
+
} else if (isX(m)) {
|
|
24499
|
+
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
24500
|
+
} else if (isX(p2)) {
|
|
24501
|
+
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
24502
24502
|
} else if (pr) {
|
|
24503
24503
|
debug("replaceTilde pr", pr);
|
|
24504
|
-
ret = `>=${
|
|
24504
|
+
ret = `>=${M}.${m}.${p2}-${pr} <${M}.${+m + 1}.0-0`;
|
|
24505
24505
|
} else {
|
|
24506
|
-
ret = `>=${
|
|
24506
|
+
ret = `>=${M}.${m}.${p2} <${M}.${+m + 1}.0-0`;
|
|
24507
24507
|
}
|
|
24508
24508
|
debug("tilde return", ret);
|
|
24509
24509
|
return ret;
|
|
@@ -24514,42 +24514,42 @@ var require_range = __commonJS({
|
|
|
24514
24514
|
};
|
|
24515
24515
|
var replaceCaret = (comp, options) => {
|
|
24516
24516
|
debug("caret", comp, options);
|
|
24517
|
-
const r = options.loose ?
|
|
24517
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
24518
24518
|
const z = options.includePrerelease ? "-0" : "";
|
|
24519
|
-
return comp.replace(r, (_,
|
|
24520
|
-
debug("caret", comp, _,
|
|
24519
|
+
return comp.replace(r, (_, M, m, p2, pr) => {
|
|
24520
|
+
debug("caret", comp, _, M, m, p2, pr);
|
|
24521
24521
|
let ret;
|
|
24522
|
-
if (isX(
|
|
24522
|
+
if (isX(M)) {
|
|
24523
24523
|
ret = "";
|
|
24524
|
-
} else if (isX(
|
|
24525
|
-
ret = `>=${
|
|
24526
|
-
} else if (isX(
|
|
24527
|
-
if (
|
|
24528
|
-
ret = `>=${
|
|
24524
|
+
} else if (isX(m)) {
|
|
24525
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
24526
|
+
} else if (isX(p2)) {
|
|
24527
|
+
if (M === "0") {
|
|
24528
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
24529
24529
|
} else {
|
|
24530
|
-
ret = `>=${
|
|
24530
|
+
ret = `>=${M}.${m}.0${z} <${+M + 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 (M === "0") {
|
|
24535
|
+
if (m === "0") {
|
|
24536
|
+
ret = `>=${M}.${m}.${p2}-${pr} <${M}.${m}.${+p2 + 1}-0`;
|
|
24537
24537
|
} else {
|
|
24538
|
-
ret = `>=${
|
|
24538
|
+
ret = `>=${M}.${m}.${p2}-${pr} <${M}.${+m + 1}.0-0`;
|
|
24539
24539
|
}
|
|
24540
24540
|
} else {
|
|
24541
|
-
ret = `>=${
|
|
24541
|
+
ret = `>=${M}.${m}.${p2}-${pr} <${+M + 1}.0.0-0`;
|
|
24542
24542
|
}
|
|
24543
24543
|
} else {
|
|
24544
24544
|
debug("no pr");
|
|
24545
|
-
if (
|
|
24546
|
-
if (
|
|
24547
|
-
ret = `>=${
|
|
24545
|
+
if (M === "0") {
|
|
24546
|
+
if (m === "0") {
|
|
24547
|
+
ret = `>=${M}.${m}.${p2}${z} <${M}.${m}.${+p2 + 1}-0`;
|
|
24548
24548
|
} else {
|
|
24549
|
-
ret = `>=${
|
|
24549
|
+
ret = `>=${M}.${m}.${p2}${z} <${M}.${+m + 1}.0-0`;
|
|
24550
24550
|
}
|
|
24551
24551
|
} else {
|
|
24552
|
-
ret = `>=${
|
|
24552
|
+
ret = `>=${M}.${m}.${p2} <${+M + 1}.0.0-0`;
|
|
24553
24553
|
}
|
|
24554
24554
|
}
|
|
24555
24555
|
debug("caret return", ret);
|
|
@@ -24562,12 +24562,12 @@ var require_range = __commonJS({
|
|
|
24562
24562
|
};
|
|
24563
24563
|
var replaceXRange = (comp, options) => {
|
|
24564
24564
|
comp = comp.trim();
|
|
24565
|
-
const r = options.loose ?
|
|
24566
|
-
return comp.replace(r, (ret, gtlt,
|
|
24567
|
-
debug("xRange", comp, ret, gtlt,
|
|
24568
|
-
const xM = isX(
|
|
24569
|
-
const xm = xM || isX(
|
|
24570
|
-
const xp = xm || isX(
|
|
24565
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
24566
|
+
return comp.replace(r, (ret, gtlt, M, m, p2, pr) => {
|
|
24567
|
+
debug("xRange", comp, ret, gtlt, M, m, p2, pr);
|
|
24568
|
+
const xM = isX(M);
|
|
24569
|
+
const xm = xM || isX(m);
|
|
24570
|
+
const xp = xm || isX(p2);
|
|
24571
24571
|
const anyX = xp;
|
|
24572
24572
|
if (gtlt === "=" && anyX) {
|
|
24573
24573
|
gtlt = "";
|
|
@@ -24581,35 +24581,35 @@ var require_range = __commonJS({
|
|
|
24581
24581
|
}
|
|
24582
24582
|
} else if (gtlt && anyX) {
|
|
24583
24583
|
if (xm) {
|
|
24584
|
-
|
|
24584
|
+
m = 0;
|
|
24585
24585
|
}
|
|
24586
|
-
|
|
24586
|
+
p2 = 0;
|
|
24587
24587
|
if (gtlt === ">") {
|
|
24588
24588
|
gtlt = ">=";
|
|
24589
24589
|
if (xm) {
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24590
|
+
M = +M + 1;
|
|
24591
|
+
m = 0;
|
|
24592
|
+
p2 = 0;
|
|
24593
24593
|
} else {
|
|
24594
|
-
|
|
24595
|
-
|
|
24594
|
+
m = +m + 1;
|
|
24595
|
+
p2 = 0;
|
|
24596
24596
|
}
|
|
24597
24597
|
} else if (gtlt === "<=") {
|
|
24598
24598
|
gtlt = "<";
|
|
24599
24599
|
if (xm) {
|
|
24600
|
-
|
|
24600
|
+
M = +M + 1;
|
|
24601
24601
|
} else {
|
|
24602
|
-
|
|
24602
|
+
m = +m + 1;
|
|
24603
24603
|
}
|
|
24604
24604
|
}
|
|
24605
24605
|
if (gtlt === "<") {
|
|
24606
24606
|
pr = "-0";
|
|
24607
24607
|
}
|
|
24608
|
-
ret = `${gtlt +
|
|
24608
|
+
ret = `${gtlt + M}.${m}.${p2}${pr}`;
|
|
24609
24609
|
} else if (xm) {
|
|
24610
|
-
ret = `>=${
|
|
24610
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
24611
24611
|
} else if (xp) {
|
|
24612
|
-
ret = `>=${
|
|
24612
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
24613
24613
|
}
|
|
24614
24614
|
debug("xRange return", ret);
|
|
24615
24615
|
return ret;
|
|
@@ -24617,11 +24617,11 @@ var require_range = __commonJS({
|
|
|
24617
24617
|
};
|
|
24618
24618
|
var replaceStars = (comp, options) => {
|
|
24619
24619
|
debug("replaceStars", comp, options);
|
|
24620
|
-
return comp.trim().replace(
|
|
24620
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
24621
24621
|
};
|
|
24622
24622
|
var replaceGTE0 = (comp, options) => {
|
|
24623
24623
|
debug("replaceGTE0", comp, options);
|
|
24624
|
-
return comp.trim().replace(
|
|
24624
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
24625
24625
|
};
|
|
24626
24626
|
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
24627
24627
|
if (isX(fM)) {
|
|
@@ -24707,19 +24707,19 @@ var require_comparator = __commonJS({
|
|
|
24707
24707
|
debug("comp", this);
|
|
24708
24708
|
}
|
|
24709
24709
|
parse(comp) {
|
|
24710
|
-
const r = this.options.loose ?
|
|
24711
|
-
const
|
|
24712
|
-
if (!
|
|
24710
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
24711
|
+
const m = comp.match(r);
|
|
24712
|
+
if (!m) {
|
|
24713
24713
|
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
24714
24714
|
}
|
|
24715
|
-
this.operator =
|
|
24715
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
24716
24716
|
if (this.operator === "=") {
|
|
24717
24717
|
this.operator = "";
|
|
24718
24718
|
}
|
|
24719
|
-
if (!
|
|
24719
|
+
if (!m[2]) {
|
|
24720
24720
|
this.semver = ANY;
|
|
24721
24721
|
} else {
|
|
24722
|
-
this.semver = new SemVer(
|
|
24722
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
24723
24723
|
}
|
|
24724
24724
|
}
|
|
24725
24725
|
toString() {
|
|
@@ -24781,7 +24781,7 @@ var require_comparator = __commonJS({
|
|
|
24781
24781
|
};
|
|
24782
24782
|
module2.exports = Comparator;
|
|
24783
24783
|
var parseOptions = require_parse_options();
|
|
24784
|
-
var { safeRe:
|
|
24784
|
+
var { safeRe: re, t } = require_re();
|
|
24785
24785
|
var cmp = require_cmp();
|
|
24786
24786
|
var debug = require_debug2();
|
|
24787
24787
|
var SemVer = require_semver();
|
|
@@ -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, m, k, k2) {
|
|
26381
26381
|
if (k2 === void 0) k2 = k;
|
|
26382
26382
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26383
|
-
return
|
|
26383
|
+
return m[k];
|
|
26384
26384
|
} });
|
|
26385
|
-
} : function(o,
|
|
26385
|
+
} : function(o, m, k, k2) {
|
|
26386
26386
|
if (k2 === void 0) k2 = k;
|
|
26387
|
-
o[k2] =
|
|
26387
|
+
o[k2] = m[k];
|
|
26388
26388
|
});
|
|
26389
|
-
var __exportStar = exports2 && exports2.__exportStar || function(
|
|
26390
|
-
for (var
|
|
26389
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
26390
|
+
for (var p2 in m) if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p2)) __createBinding(exports3, m, p2);
|
|
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, m, k, k2) {
|
|
26451
26451
|
if (k2 === void 0) k2 = k;
|
|
26452
26452
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26453
|
-
return
|
|
26453
|
+
return m[k];
|
|
26454
26454
|
} });
|
|
26455
|
-
} : function(o,
|
|
26455
|
+
} : function(o, m, k, k2) {
|
|
26456
26456
|
if (k2 === void 0) k2 = k;
|
|
26457
|
-
o[k2] =
|
|
26457
|
+
o[k2] = m[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 });
|
|
@@ -26498,13 +26498,13 @@ var require_util2 = __commonJS({
|
|
|
26498
26498
|
let tokens = [], rs, c;
|
|
26499
26499
|
const regexp = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;
|
|
26500
26500
|
while ((rs = regexp.exec(str)) !== null) {
|
|
26501
|
-
const
|
|
26501
|
+
const p2 = (_g = (_f = (_e = (_d = (_c = (_b = (_a = rs[1] && sets.words()) !== null && _a !== void 0 ? _a : rs[2] && sets.ints()) !== null && _b !== void 0 ? _b : rs[3] && sets.whitespace()) !== null && _c !== void 0 ? _c : rs[4] && sets.notWords()) !== null && _d !== void 0 ? _d : rs[5] && sets.notInts()) !== null && _e !== void 0 ? _e : rs[6] && sets.notWhitespace()) !== null && _f !== void 0 ? _f : rs[7] && {
|
|
26502
26502
|
type: types_1.types.RANGE,
|
|
26503
26503
|
from: (rs[8] || rs[9]).charCodeAt(0),
|
|
26504
26504
|
to: (c = rs[10]).charCodeAt(c.length - 1)
|
|
26505
26505
|
}) !== null && _g !== void 0 ? _g : (c = rs[16]) && { type: types_1.types.CHAR, value: c.charCodeAt(0) };
|
|
26506
|
-
if (
|
|
26507
|
-
tokens.push(
|
|
26506
|
+
if (p2) {
|
|
26507
|
+
tokens.push(p2);
|
|
26508
26508
|
} else {
|
|
26509
26509
|
return [tokens, regexp.lastIndex];
|
|
26510
26510
|
}
|
|
@@ -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, m, k, k2) {
|
|
26522
26522
|
if (k2 === void 0) k2 = k;
|
|
26523
26523
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26524
|
-
return
|
|
26524
|
+
return m[k];
|
|
26525
26525
|
} });
|
|
26526
|
-
} : function(o,
|
|
26526
|
+
} : function(o, m, k, k2) {
|
|
26527
26527
|
if (k2 === void 0) k2 = k;
|
|
26528
|
-
o[k2] =
|
|
26528
|
+
o[k2] = m[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, m, k, k2) {
|
|
26823
26823
|
if (k2 === void 0) k2 = k;
|
|
26824
26824
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26825
|
-
return
|
|
26825
|
+
return m[k];
|
|
26826
26826
|
} });
|
|
26827
|
-
} : function(o,
|
|
26827
|
+
} : function(o, m, k, k2) {
|
|
26828
26828
|
if (k2 === void 0) k2 = k;
|
|
26829
|
-
o[k2] =
|
|
26829
|
+
o[k2] = m[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, m, k, k2) {
|
|
26878
26878
|
if (k2 === void 0) k2 = k;
|
|
26879
26879
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
26880
|
-
return
|
|
26880
|
+
return m[k];
|
|
26881
26881
|
} });
|
|
26882
|
-
} : function(o,
|
|
26882
|
+
} : function(o, m, k, k2) {
|
|
26883
26883
|
if (k2 === void 0) k2 = k;
|
|
26884
|
-
o[k2] =
|
|
26884
|
+
o[k2] = m[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, m, k, k2) {
|
|
27031
27031
|
if (k2 === void 0) k2 = k;
|
|
27032
27032
|
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
27033
|
-
return
|
|
27033
|
+
return m[k];
|
|
27034
27034
|
} });
|
|
27035
|
-
} : function(o,
|
|
27035
|
+
} : function(o, m, k, k2) {
|
|
27036
27036
|
if (k2 === void 0) k2 = k;
|
|
27037
|
-
o[k2] =
|
|
27037
|
+
o[k2] = m[k];
|
|
27038
27038
|
});
|
|
27039
|
-
var __exportStar = exports2 && exports2.__exportStar || function(
|
|
27040
|
-
for (var
|
|
27039
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
27040
|
+
for (var p2 in m) if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p2)) __createBinding(exports3, m, p2);
|
|
27041
27041
|
};
|
|
27042
27042
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
27043
27043
|
exports2.types = void 0;
|
|
@@ -27063,13 +27063,13 @@ var require_safe_regex2 = __commonJS({
|
|
|
27063
27063
|
"use strict";
|
|
27064
27064
|
var parse = require_dist3();
|
|
27065
27065
|
var types = parse.types;
|
|
27066
|
-
function safeRegex(
|
|
27066
|
+
function safeRegex(re, opts) {
|
|
27067
27067
|
if (!opts) opts = {};
|
|
27068
27068
|
const replimit = opts.limit === void 0 ? 25 : opts.limit;
|
|
27069
|
-
if (isRegExp(
|
|
27070
|
-
else if (typeof
|
|
27069
|
+
if (isRegExp(re)) re = re.source;
|
|
27070
|
+
else if (typeof re !== "string") re = String(re);
|
|
27071
27071
|
try {
|
|
27072
|
-
|
|
27072
|
+
re = parse(re);
|
|
27073
27073
|
} catch {
|
|
27074
27074
|
return false;
|
|
27075
27075
|
}
|
|
@@ -27097,7 +27097,7 @@ var require_safe_regex2 = __commonJS({
|
|
|
27097
27097
|
if (!ok) return false;
|
|
27098
27098
|
}
|
|
27099
27099
|
return true;
|
|
27100
|
-
}(
|
|
27100
|
+
}(re, 0);
|
|
27101
27101
|
}
|
|
27102
27102
|
function isRegExp(x) {
|
|
27103
27103
|
return {}.toString.call(x) === "[object RegExp]";
|
|
@@ -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((m) => parseMeta(m));
|
|
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 m = httpMethods[i];
|
|
28555
|
+
const methodName = m.toLowerCase();
|
|
28556
28556
|
Router.prototype[methodName] = function(path3, handler, store) {
|
|
28557
|
-
return this.on(
|
|
28557
|
+
return this.on(m, 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 m = stack.match(fpStackTracePattern);
|
|
33055
|
+
return m ? m[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 m = val.match(KEEPALIVE_TIMEOUT_EXPR);
|
|
34810
|
+
return m ? parseInt(m[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 m = range ? range.match(rangeHeaderRegex) : null;
|
|
35013
|
+
return m ? {
|
|
35014
|
+
start: parseInt(m[1]),
|
|
35015
|
+
end: m[2] ? parseInt(m[2]) : null,
|
|
35016
|
+
size: m[3] ? parseInt(m[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(V2,
|
|
37456
|
-
if (!FunctionPrototypeSymbolHasInstance(
|
|
37455
|
+
webidl.brandCheck = function(V2, I2) {
|
|
37456
|
+
if (!FunctionPrototypeSymbolHasInstance(I2, V2)) {
|
|
37457
37457
|
const err = new TypeError("Illegal invocation");
|
|
37458
37458
|
err.code = "ERR_INVALID_THIS";
|
|
37459
37459
|
throw err;
|
|
@@ -37483,8 +37483,8 @@ var require_webidl = __commonJS({
|
|
|
37483
37483
|
message: "Illegal constructor"
|
|
37484
37484
|
});
|
|
37485
37485
|
};
|
|
37486
|
-
webidl.util.MakeTypeAssertion = function(
|
|
37487
|
-
return (O) => FunctionPrototypeSymbolHasInstance(
|
|
37486
|
+
webidl.util.MakeTypeAssertion = function(I2) {
|
|
37487
|
+
return (O) => FunctionPrototypeSymbolHasInstance(I2, O);
|
|
37488
37488
|
};
|
|
37489
37489
|
webidl.util.Type = function(V2) {
|
|
37490
37490
|
switch (typeof V2) {
|
|
@@ -38306,11 +38306,11 @@ var require_util4 = __commonJS({
|
|
|
38306
38306
|
}
|
|
38307
38307
|
function tryUpgradeRequestToAPotentiallyTrustworthyURL(request) {
|
|
38308
38308
|
}
|
|
38309
|
-
function sameOrigin(A2,
|
|
38310
|
-
if (A2.origin ===
|
|
38309
|
+
function sameOrigin(A2, B) {
|
|
38310
|
+
if (A2.origin === B.origin && A2.origin === "null") {
|
|
38311
38311
|
return true;
|
|
38312
38312
|
}
|
|
38313
|
-
if (A2.protocol ===
|
|
38313
|
+
if (A2.protocol === B.protocol && A2.hostname === B.hostname && A2.port === B.port) {
|
|
38314
38314
|
return true;
|
|
38315
38315
|
}
|
|
38316
38316
|
return false;
|
|
@@ -39607,7 +39607,7 @@ var require_client_h1 = __commonJS({
|
|
|
39607
39607
|
* @param {number} len
|
|
39608
39608
|
* @returns {number}
|
|
39609
39609
|
*/
|
|
39610
|
-
wasm_on_url: (
|
|
39610
|
+
wasm_on_url: (p2, at, len) => {
|
|
39611
39611
|
return 0;
|
|
39612
39612
|
},
|
|
39613
39613
|
/**
|
|
@@ -39616,8 +39616,8 @@ var require_client_h1 = __commonJS({
|
|
|
39616
39616
|
* @param {number} len
|
|
39617
39617
|
* @returns {number}
|
|
39618
39618
|
*/
|
|
39619
|
-
wasm_on_status: (
|
|
39620
|
-
assert(currentParser.ptr ===
|
|
39619
|
+
wasm_on_status: (p2, at, len) => {
|
|
39620
|
+
assert(currentParser.ptr === p2);
|
|
39621
39621
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39622
39622
|
return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39623
39623
|
},
|
|
@@ -39625,8 +39625,8 @@ var require_client_h1 = __commonJS({
|
|
|
39625
39625
|
* @param {number} p
|
|
39626
39626
|
* @returns {number}
|
|
39627
39627
|
*/
|
|
39628
|
-
wasm_on_message_begin: (
|
|
39629
|
-
assert(currentParser.ptr ===
|
|
39628
|
+
wasm_on_message_begin: (p2) => {
|
|
39629
|
+
assert(currentParser.ptr === p2);
|
|
39630
39630
|
return currentParser.onMessageBegin();
|
|
39631
39631
|
},
|
|
39632
39632
|
/**
|
|
@@ -39635,8 +39635,8 @@ var require_client_h1 = __commonJS({
|
|
|
39635
39635
|
* @param {number} len
|
|
39636
39636
|
* @returns {number}
|
|
39637
39637
|
*/
|
|
39638
|
-
wasm_on_header_field: (
|
|
39639
|
-
assert(currentParser.ptr ===
|
|
39638
|
+
wasm_on_header_field: (p2, at, len) => {
|
|
39639
|
+
assert(currentParser.ptr === p2);
|
|
39640
39640
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39641
39641
|
return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39642
39642
|
},
|
|
@@ -39646,8 +39646,8 @@ var require_client_h1 = __commonJS({
|
|
|
39646
39646
|
* @param {number} len
|
|
39647
39647
|
* @returns {number}
|
|
39648
39648
|
*/
|
|
39649
|
-
wasm_on_header_value: (
|
|
39650
|
-
assert(currentParser.ptr ===
|
|
39649
|
+
wasm_on_header_value: (p2, at, len) => {
|
|
39650
|
+
assert(currentParser.ptr === p2);
|
|
39651
39651
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39652
39652
|
return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39653
39653
|
},
|
|
@@ -39658,8 +39658,8 @@ var require_client_h1 = __commonJS({
|
|
|
39658
39658
|
* @param {0|1} shouldKeepAlive
|
|
39659
39659
|
* @returns {number}
|
|
39660
39660
|
*/
|
|
39661
|
-
wasm_on_headers_complete: (
|
|
39662
|
-
assert(currentParser.ptr ===
|
|
39661
|
+
wasm_on_headers_complete: (p2, statusCode, upgrade, shouldKeepAlive) => {
|
|
39662
|
+
assert(currentParser.ptr === p2);
|
|
39663
39663
|
return currentParser.onHeadersComplete(statusCode, upgrade === 1, shouldKeepAlive === 1);
|
|
39664
39664
|
},
|
|
39665
39665
|
/**
|
|
@@ -39668,8 +39668,8 @@ var require_client_h1 = __commonJS({
|
|
|
39668
39668
|
* @param {number} len
|
|
39669
39669
|
* @returns {number}
|
|
39670
39670
|
*/
|
|
39671
|
-
wasm_on_body: (
|
|
39672
|
-
assert(currentParser.ptr ===
|
|
39671
|
+
wasm_on_body: (p2, at, len) => {
|
|
39672
|
+
assert(currentParser.ptr === p2);
|
|
39673
39673
|
const start = at - currentBufferPtr + currentBufferRef.byteOffset;
|
|
39674
39674
|
return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len));
|
|
39675
39675
|
},
|
|
@@ -39677,8 +39677,8 @@ var require_client_h1 = __commonJS({
|
|
|
39677
39677
|
* @param {number} p
|
|
39678
39678
|
* @returns {number}
|
|
39679
39679
|
*/
|
|
39680
|
-
wasm_on_message_complete: (
|
|
39681
|
-
assert(currentParser.ptr ===
|
|
39680
|
+
wasm_on_message_complete: (p2) => {
|
|
39681
|
+
assert(currentParser.ptr === p2);
|
|
39682
39682
|
return currentParser.onMessageComplete();
|
|
39683
39683
|
}
|
|
39684
39684
|
}
|
|
@@ -42207,7 +42207,7 @@ var require_balanced_pool = __commonJS({
|
|
|
42207
42207
|
return this;
|
|
42208
42208
|
}
|
|
42209
42209
|
get upstreams() {
|
|
42210
|
-
return this[kClients].filter((dispatcher) => dispatcher.closed !== true && dispatcher.destroyed !== true).map((
|
|
42210
|
+
return this[kClients].filter((dispatcher) => dispatcher.closed !== true && dispatcher.destroyed !== true).map((p2) => p2[kUrl].origin);
|
|
42211
42211
|
}
|
|
42212
42212
|
[kGetDispatcher]() {
|
|
42213
42213
|
if (this[kClients].length === 0) {
|
|
@@ -48573,12 +48573,12 @@ var require_response2 = __commonJS({
|
|
|
48573
48573
|
...state
|
|
48574
48574
|
};
|
|
48575
48575
|
return new Proxy(response, {
|
|
48576
|
-
get(target,
|
|
48577
|
-
return
|
|
48576
|
+
get(target, p2) {
|
|
48577
|
+
return p2 in state ? state[p2] : target[p2];
|
|
48578
48578
|
},
|
|
48579
|
-
set(target,
|
|
48580
|
-
assert(!(
|
|
48581
|
-
target[
|
|
48579
|
+
set(target, p2, value) {
|
|
48580
|
+
assert(!(p2 in state));
|
|
48581
|
+
target[p2] = value;
|
|
48582
48582
|
return true;
|
|
48583
48583
|
}
|
|
48584
48584
|
});
|
|
@@ -49581,18 +49581,18 @@ var require_fetch = __commonJS({
|
|
|
49581
49581
|
}
|
|
49582
49582
|
function fetch2(input, init = void 0) {
|
|
49583
49583
|
webidl.argumentLengthCheck(arguments, 1, "globalThis.fetch");
|
|
49584
|
-
let
|
|
49584
|
+
let p2 = createDeferredPromise();
|
|
49585
49585
|
let requestObject;
|
|
49586
49586
|
try {
|
|
49587
49587
|
requestObject = new Request(input, init);
|
|
49588
49588
|
} catch (e) {
|
|
49589
|
-
|
|
49590
|
-
return
|
|
49589
|
+
p2.reject(e);
|
|
49590
|
+
return p2.promise;
|
|
49591
49591
|
}
|
|
49592
49592
|
const request = getRequestState(requestObject);
|
|
49593
49593
|
if (requestObject.signal.aborted) {
|
|
49594
|
-
abortFetch(
|
|
49595
|
-
return
|
|
49594
|
+
abortFetch(p2, request, null, requestObject.signal.reason);
|
|
49595
|
+
return p2.promise;
|
|
49596
49596
|
}
|
|
49597
49597
|
const globalObject = request.client.globalObject;
|
|
49598
49598
|
if (globalObject?.constructor?.name === "ServiceWorkerGlobalScope") {
|
|
@@ -49608,7 +49608,7 @@ var require_fetch = __commonJS({
|
|
|
49608
49608
|
assert(controller != null);
|
|
49609
49609
|
controller.abort(requestObject.signal.reason);
|
|
49610
49610
|
const realResponse = responseObject?.deref();
|
|
49611
|
-
abortFetch(
|
|
49611
|
+
abortFetch(p2, request, realResponse, requestObject.signal.reason);
|
|
49612
49612
|
}
|
|
49613
49613
|
);
|
|
49614
49614
|
const processResponse = (response) => {
|
|
@@ -49616,16 +49616,16 @@ var require_fetch = __commonJS({
|
|
|
49616
49616
|
return;
|
|
49617
49617
|
}
|
|
49618
49618
|
if (response.aborted) {
|
|
49619
|
-
abortFetch(
|
|
49619
|
+
abortFetch(p2, request, responseObject, controller.serializedAbortReason);
|
|
49620
49620
|
return;
|
|
49621
49621
|
}
|
|
49622
49622
|
if (response.type === "error") {
|
|
49623
|
-
|
|
49623
|
+
p2.reject(new TypeError("fetch failed", { cause: response.error }));
|
|
49624
49624
|
return;
|
|
49625
49625
|
}
|
|
49626
49626
|
responseObject = new WeakRef(fromInnerResponse(response, "immutable"));
|
|
49627
|
-
|
|
49628
|
-
|
|
49627
|
+
p2.resolve(responseObject.deref());
|
|
49628
|
+
p2 = null;
|
|
49629
49629
|
};
|
|
49630
49630
|
controller = fetching({
|
|
49631
49631
|
request,
|
|
@@ -49634,7 +49634,7 @@ var require_fetch = __commonJS({
|
|
|
49634
49634
|
dispatcher: getRequestDispatcher(requestObject)
|
|
49635
49635
|
// undici
|
|
49636
49636
|
});
|
|
49637
|
-
return
|
|
49637
|
+
return p2.promise;
|
|
49638
49638
|
}
|
|
49639
49639
|
function finalizeAndReportTiming(response, initiatorType = "other") {
|
|
49640
49640
|
if (response.type === "error" && response.aborted) {
|
|
@@ -49672,9 +49672,9 @@ var require_fetch = __commonJS({
|
|
|
49672
49672
|
);
|
|
49673
49673
|
}
|
|
49674
49674
|
var markResourceTiming = performance.markResourceTiming;
|
|
49675
|
-
function abortFetch(
|
|
49676
|
-
if (
|
|
49677
|
-
|
|
49675
|
+
function abortFetch(p2, request, responseObject, error) {
|
|
49676
|
+
if (p2) {
|
|
49677
|
+
p2.reject(error);
|
|
49678
49678
|
}
|
|
49679
49679
|
if (request.body?.stream != null && isReadable(request.body.stream)) {
|
|
49680
49680
|
request.body.stream.cancel(error).catch((err) => {
|
|
@@ -50552,9 +50552,9 @@ var require_util5 = __commonJS({
|
|
|
50552
50552
|
var assert = require("node:assert");
|
|
50553
50553
|
var { URLSerializer } = require_data_url();
|
|
50554
50554
|
var { isValidHeaderName } = require_util4();
|
|
50555
|
-
function urlEquals(A2,
|
|
50555
|
+
function urlEquals(A2, B, excludeFragment = false) {
|
|
50556
50556
|
const serializedA = URLSerializer(A2, excludeFragment);
|
|
50557
|
-
const serializedB = URLSerializer(
|
|
50557
|
+
const serializedB = URLSerializer(B, excludeFragment);
|
|
50558
50558
|
return serializedA === serializedB;
|
|
50559
50559
|
}
|
|
50560
50560
|
function getFieldValues(header) {
|
|
@@ -50607,11 +50607,11 @@ var require_cache3 = __commonJS({
|
|
|
50607
50607
|
webidl.argumentLengthCheck(arguments, 1, prefix);
|
|
50608
50608
|
request = webidl.converters.RequestInfo(request, prefix, "request");
|
|
50609
50609
|
options = webidl.converters.CacheQueryOptions(options, prefix, "options");
|
|
50610
|
-
const
|
|
50611
|
-
if (
|
|
50610
|
+
const p2 = this.#internalMatchAll(request, options, 1);
|
|
50611
|
+
if (p2.length === 0) {
|
|
50612
50612
|
return;
|
|
50613
50613
|
}
|
|
50614
|
-
return
|
|
50614
|
+
return p2[0];
|
|
50615
50615
|
}
|
|
50616
50616
|
async matchAll(request = void 0, options = {}) {
|
|
50617
50617
|
webidl.brandCheck(this, _Cache);
|
|
@@ -50702,8 +50702,8 @@ var require_cache3 = __commonJS({
|
|
|
50702
50702
|
}));
|
|
50703
50703
|
responsePromises.push(responsePromise.promise);
|
|
50704
50704
|
}
|
|
50705
|
-
const
|
|
50706
|
-
const responses = await
|
|
50705
|
+
const p2 = Promise.all(responsePromises);
|
|
50706
|
+
const responses = await p2;
|
|
50707
50707
|
const operations = [];
|
|
50708
50708
|
let index = 0;
|
|
50709
50709
|
for (const response of responses) {
|
|
@@ -53005,10 +53005,10 @@ var require_websocket = __commonJS({
|
|
|
53005
53005
|
if (typeof protocols === "string") {
|
|
53006
53006
|
protocols = [protocols];
|
|
53007
53007
|
}
|
|
53008
|
-
if (protocols.length !== new Set(protocols.map((
|
|
53008
|
+
if (protocols.length !== new Set(protocols.map((p2) => p2.toLowerCase())).size) {
|
|
53009
53009
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53010
53010
|
}
|
|
53011
|
-
if (protocols.length > 0 && !protocols.every((
|
|
53011
|
+
if (protocols.length > 0 && !protocols.every((p2) => isValidSubprotocol(p2))) {
|
|
53012
53012
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53013
53013
|
}
|
|
53014
53014
|
this.#url = new URL(urlRecord.href);
|
|
@@ -53496,10 +53496,10 @@ var require_websocketstream = __commonJS({
|
|
|
53496
53496
|
const baseURL = environmentSettingsObject.settingsObject.baseUrl;
|
|
53497
53497
|
const urlRecord = getURLRecord(url, baseURL);
|
|
53498
53498
|
const protocols = options.protocols;
|
|
53499
|
-
if (protocols.length !== new Set(protocols.map((
|
|
53499
|
+
if (protocols.length !== new Set(protocols.map((p2) => p2.toLowerCase())).size) {
|
|
53500
53500
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53501
53501
|
}
|
|
53502
|
-
if (protocols.length > 0 && !protocols.every((
|
|
53502
|
+
if (protocols.length > 0 && !protocols.every((p2) => isValidSubprotocol(p2))) {
|
|
53503
53503
|
throw new DOMException("Invalid Sec-WebSocket-Protocol value", "SyntaxError");
|
|
53504
53504
|
}
|
|
53505
53505
|
this.#url = urlRecord.toString();
|
|
@@ -54927,20 +54927,21 @@ var readConfigFile = async () => {
|
|
|
54927
54927
|
const config = await import_promises.default.readFile(CONFIG_FILE, "utf-8");
|
|
54928
54928
|
return JSON.parse(config);
|
|
54929
54929
|
} catch {
|
|
54930
|
-
const
|
|
54931
|
-
const
|
|
54932
|
-
const
|
|
54930
|
+
const name = await question("Enter Provider Name: ");
|
|
54931
|
+
const apiKey = await question("Enter Provider API KEY: ");
|
|
54932
|
+
const baseUrl = await question("Enter Provider URL: ");
|
|
54933
|
+
const model = await question("Enter MODEL Name: ");
|
|
54933
54934
|
const config = Object.assign({}, DEFAULT_CONFIG, {
|
|
54934
54935
|
Providers: [
|
|
54935
54936
|
{
|
|
54936
|
-
name
|
|
54937
|
+
name,
|
|
54937
54938
|
api_base_url: baseUrl,
|
|
54938
54939
|
api_key: apiKey,
|
|
54939
54940
|
models: [model]
|
|
54940
54941
|
}
|
|
54941
54942
|
],
|
|
54942
54943
|
Router: {
|
|
54943
|
-
default:
|
|
54944
|
+
default: `${name},${model}`
|
|
54944
54945
|
}
|
|
54945
54946
|
});
|
|
54946
54947
|
await writeConfigFile(config);
|
|
@@ -54957,7 +54958,7 @@ var initConfig = async () => {
|
|
|
54957
54958
|
return config;
|
|
54958
54959
|
};
|
|
54959
54960
|
|
|
54960
|
-
// node_modules/.pnpm/@musistudio+llms@1.0.
|
|
54961
|
+
// node_modules/.pnpm/@musistudio+llms@1.0.5_ws@8.18.3_zod@3.25.67/node_modules/@musistudio/llms/dist/esm/server.mjs
|
|
54961
54962
|
var import_fastify = __toESM(require_fastify(), 1);
|
|
54962
54963
|
var import_cors = __toESM(require_cors(), 1);
|
|
54963
54964
|
var import_fs = require("fs");
|
|
@@ -54965,11 +54966,12 @@ var import_path = require("path");
|
|
|
54965
54966
|
var import_dotenv = __toESM(require_main(), 1);
|
|
54966
54967
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
54967
54968
|
var import_undici = __toESM(require_undici(), 1);
|
|
54968
|
-
var
|
|
54969
|
+
var import_node_module = __toESM(require("node:module"), 1);
|
|
54970
|
+
var W = ((a) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(a, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : a)(function(a) {
|
|
54969
54971
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
54970
|
-
throw Error('Dynamic require of "' +
|
|
54972
|
+
throw Error('Dynamic require of "' + a + '" is not supported');
|
|
54971
54973
|
});
|
|
54972
|
-
var
|
|
54974
|
+
var N = class {
|
|
54973
54975
|
config = {};
|
|
54974
54976
|
options;
|
|
54975
54977
|
constructor(e = { jsonPath: "./config.json" }) {
|
|
@@ -55033,95 +55035,85 @@ var j = class {
|
|
|
55033
55035
|
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
55036
|
}
|
|
55035
55037
|
};
|
|
55036
|
-
function
|
|
55037
|
-
if (console.log(...
|
|
55038
|
-
let n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${Array.isArray(
|
|
55038
|
+
function p(...a) {
|
|
55039
|
+
if (console.log(...a), !(process.env.LOG === "true")) return;
|
|
55040
|
+
let n = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${Array.isArray(a) ? a.map((r) => typeof r == "object" ? JSON.stringify(r) : String(r)).join(" ") : ""}
|
|
55039
55041
|
`, o = process.env.LOG_FILE || "app.log";
|
|
55040
55042
|
import_node_fs.default.appendFileSync(o, n, "utf8");
|
|
55041
55043
|
}
|
|
55042
|
-
function A(
|
|
55043
|
-
let o = new Error(
|
|
55044
|
+
function A(a, e = 500, t = "internal_error", n = "api_error") {
|
|
55045
|
+
let o = new Error(a);
|
|
55044
55046
|
return o.statusCode = e, o.code = t, o.type = n, o;
|
|
55045
55047
|
}
|
|
55046
|
-
async function
|
|
55047
|
-
e.log.error(
|
|
55048
|
-
let n =
|
|
55048
|
+
async function Z(a, e, t) {
|
|
55049
|
+
e.log.error(a);
|
|
55050
|
+
let n = a.statusCode || 500, o = { error: { message: a.message || "Internal Server Error", type: a.type || "api_error", code: a.code || "internal_error" } };
|
|
55049
55051
|
return t.code(n).send(o);
|
|
55050
55052
|
}
|
|
55051
|
-
function
|
|
55053
|
+
function ee(a, e, t) {
|
|
55052
55054
|
let n = new Headers({ "Content-Type": "application/json" });
|
|
55053
|
-
t.headers && Object.entries(t.headers).forEach(([
|
|
55054
|
-
n.set(
|
|
55055
|
+
t.headers && Object.entries(t.headers).forEach(([u, d]) => {
|
|
55056
|
+
n.set(u, d);
|
|
55055
55057
|
});
|
|
55056
55058
|
let o, r = AbortSignal.timeout(t.TIMEOUT ?? 60 * 1e3 * 60);
|
|
55057
55059
|
if (t.signal) {
|
|
55058
|
-
let
|
|
55059
|
-
t.signal.addEventListener("abort", d), r.addEventListener("abort", d), o =
|
|
55060
|
+
let u = new AbortController(), d = () => u.abort();
|
|
55061
|
+
t.signal.addEventListener("abort", d), r.addEventListener("abort", d), o = u.signal;
|
|
55060
55062
|
} else o = r;
|
|
55061
|
-
let
|
|
55062
|
-
return t.httpsProxy && (
|
|
55063
|
+
let l = { method: "POST", headers: n, body: JSON.stringify(e), signal: o };
|
|
55064
|
+
return t.httpsProxy && (l.dispatcher = new import_undici.ProxyAgent(new URL(t.httpsProxy).toString())), p("final request:", typeof a == "string" ? a : a.toString(), t.httpsProxy, l), fetch(typeof a == "string" ? a : a.toString(), l);
|
|
55063
55065
|
}
|
|
55064
|
-
var
|
|
55065
|
-
|
|
55066
|
-
let e =
|
|
55067
|
-
for (let { name: t, transformer: n } of e) n.endPoint &&
|
|
55068
|
-
let
|
|
55069
|
-
if (!d) throw A(`Provider '${
|
|
55070
|
-
let
|
|
55066
|
+
var te = async (a) => {
|
|
55067
|
+
a.get("/", async (t, n) => ({ message: "LLMs API", version: "1.0.0" })), a.get("/health", async (t, n) => ({ status: "ok", timestamp: (/* @__PURE__ */ new Date()).toISOString() }));
|
|
55068
|
+
let e = a._server.transformerService.getTransformersWithEndpoint();
|
|
55069
|
+
for (let { name: t, transformer: n } of e) n.endPoint && a.post(n.endPoint, async (o, r) => {
|
|
55070
|
+
let l = o.body, u = o.provider, d = a._server.providerService.getProvider(u);
|
|
55071
|
+
if (!d) throw A(`Provider '${u}' not found`, 404, "provider_not_found");
|
|
55072
|
+
let i = l, c = {};
|
|
55071
55073
|
if (typeof n.transformRequestOut == "function") {
|
|
55072
|
-
let s = n.transformRequestOut(
|
|
55073
|
-
s.body ? (
|
|
55074
|
-
}
|
|
55075
|
-
if (d.transformer?.use?.length) for (let s of d.transformer.use) {
|
|
55076
|
-
|
|
55077
|
-
|
|
55078
|
-
|
|
55079
|
-
|
|
55080
|
-
|
|
55081
|
-
|
|
55082
|
-
|
|
55083
|
-
|
|
55084
|
-
|
|
55085
|
-
|
|
55086
|
-
|
|
55087
|
-
|
|
55088
|
-
|
|
55089
|
-
|
|
55090
|
-
let h = v;
|
|
55091
|
-
if (d.transformer?.use?.length) for (let s of d.transformer.use) {
|
|
55092
|
-
let g = i._server.transformerService.getTransformer(s);
|
|
55093
|
-
!g || typeof g.transformResponseOut != "function" || (h = await g.transformResponseOut(h));
|
|
55094
|
-
}
|
|
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);
|
|
55097
|
-
!g || typeof g.transformResponseOut != "function" || (h = await g.transformResponseOut(h));
|
|
55098
|
-
}
|
|
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();
|
|
55074
|
+
let s = await n.transformRequestOut(l);
|
|
55075
|
+
s.body ? (i = s.body, c = s.config || {}) : i = s;
|
|
55076
|
+
}
|
|
55077
|
+
if (p("use transformers:", d.transformer?.use), d.transformer?.use?.length) for (let s of d.transformer.use) {
|
|
55078
|
+
if (!s || typeof s.transformRequestIn != "function") continue;
|
|
55079
|
+
let _ = await s.transformRequestIn(i, d);
|
|
55080
|
+
_.body ? (i = _.body, c = { ...c, ..._.config }) : i = _;
|
|
55081
|
+
}
|
|
55082
|
+
if (d.transformer?.[o.body.model]?.use?.length) for (let s of d.transformer[o.body.model].use) !s || typeof s.transformRequestIn != "function" || (i = await s.transformRequestIn(i, d));
|
|
55083
|
+
let h = c.url || new URL(d.baseUrl), g = await ee(h, i, { httpsProxy: a._server.configService.getHttpsProxy(), ...c, headers: { Authorization: `Bearer ${d.apiKey}`, ...c?.headers || {} } });
|
|
55084
|
+
if (!g.ok) {
|
|
55085
|
+
let s = await g.text();
|
|
55086
|
+
throw p(`Error response from ${h}: ${s}`), A(`Error from provider: ${s}`, g.status, "provider_response_error");
|
|
55087
|
+
}
|
|
55088
|
+
let m = g;
|
|
55089
|
+
if (d.transformer?.use?.length) for (let s of d.transformer.use) !s || typeof s.transformResponseOut != "function" || (m = await s.transformResponseOut(m));
|
|
55090
|
+
if (d.transformer?.[o.body.model]?.use?.length) for (let s of d.transformer[o.body.model].use) !s || typeof s.transformResponseOut != "function" || (m = await s.transformResponseOut(m));
|
|
55091
|
+
return n.transformResponseIn && (m = await n.transformResponseIn(m)), m.ok || r.code(m.status), l?.stream === true ? (r.header("Content-Type", "text/event-stream"), r.header("Cache-Control", "no-cache"), r.header("Connection", "keep-alive"), r.send(m.body)) : m.json();
|
|
55100
55092
|
});
|
|
55101
|
-
|
|
55102
|
-
let { name: o, type: r, baseUrl:
|
|
55093
|
+
a.post("/providers", { schema: { body: { type: "object", properties: { id: { type: "string" }, name: { type: "string" }, type: { type: "string", enum: ["openai", "anthropic"] }, baseUrl: { type: "string" }, apiKey: { type: "string" }, models: { type: "array", items: { type: "string" } } }, required: ["id", "name", "type", "baseUrl", "apiKey", "models"] } } }, async (t, n) => {
|
|
55094
|
+
let { name: o, type: r, baseUrl: l, apiKey: u, models: d } = t.body;
|
|
55103
55095
|
if (!o?.trim()) throw A("Provider name is required", 400, "invalid_request");
|
|
55104
|
-
if (!
|
|
55105
|
-
if (!
|
|
55096
|
+
if (!l || !le(l)) throw A("Valid base URL is required", 400, "invalid_request");
|
|
55097
|
+
if (!u?.trim()) throw A("API key is required", 400, "invalid_request");
|
|
55106
55098
|
if (!d || !Array.isArray(d) || d.length === 0) throw A("At least one model is required", 400, "invalid_request");
|
|
55107
|
-
if (
|
|
55108
|
-
return
|
|
55109
|
-
}),
|
|
55110
|
-
let o =
|
|
55099
|
+
if (a._server.providerService.getProvider(id)) throw A(`Provider with ID '${id}' already exists`, 400, "provider_exists");
|
|
55100
|
+
return a._server.providerService.registerProvider(t.body);
|
|
55101
|
+
}), a.get("/providers", async (t, n) => a._server.providerService.getProviders()), a.get("/providers/:id", { schema: { params: { type: "object", properties: { id: { type: "string" } }, required: ["id"] } } }, async (t, n) => {
|
|
55102
|
+
let o = a._server.providerService.getProvider(t.params.id);
|
|
55111
55103
|
return o || n.code(404).send({ error: "Provider not found" });
|
|
55112
|
-
}),
|
|
55113
|
-
let o =
|
|
55104
|
+
}), a.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) => {
|
|
55105
|
+
let o = a._server.providerService.updateProvider(t.params.id, t.body);
|
|
55114
55106
|
return o || n.code(404).send({ error: "Provider not found" });
|
|
55115
|
-
}),
|
|
55107
|
+
}), a.delete("/providers/:id", { schema: { params: { type: "object", properties: { id: { type: "string" } }, required: ["id"] } } }, async (t, n) => a._server.providerService.deleteProvider(t.params.id) ? { message: "Provider deleted successfully" } : n.code(404).send({ error: "Provider not found" })), a.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) => a._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" }));
|
|
55116
55108
|
};
|
|
55117
|
-
function
|
|
55109
|
+
function le(a) {
|
|
55118
55110
|
try {
|
|
55119
|
-
return new URL(
|
|
55111
|
+
return new URL(a), true;
|
|
55120
55112
|
} catch {
|
|
55121
55113
|
return false;
|
|
55122
55114
|
}
|
|
55123
55115
|
}
|
|
55124
|
-
var
|
|
55116
|
+
var H = class {
|
|
55125
55117
|
constructor(e) {
|
|
55126
55118
|
this.providerService = e;
|
|
55127
55119
|
}
|
|
@@ -55158,9 +55150,10 @@ var q = class {
|
|
|
55158
55150
|
return this.providerService.getModelRoutes();
|
|
55159
55151
|
}
|
|
55160
55152
|
};
|
|
55161
|
-
var
|
|
55162
|
-
constructor(e) {
|
|
55153
|
+
var $ = class {
|
|
55154
|
+
constructor(e, t) {
|
|
55163
55155
|
this.configService = e;
|
|
55156
|
+
this.transformerService = t;
|
|
55164
55157
|
this.initializeCustomProviders();
|
|
55165
55158
|
}
|
|
55166
55159
|
providers = /* @__PURE__ */ new Map();
|
|
@@ -55176,9 +55169,24 @@ var J = class {
|
|
|
55176
55169
|
e.forEach((t) => {
|
|
55177
55170
|
try {
|
|
55178
55171
|
if (!t.name || !t.api_base_url || !t.api_key) return;
|
|
55179
|
-
|
|
55172
|
+
let n = {};
|
|
55173
|
+
t.transformer && Object.keys(t.transformer).forEach((o) => {
|
|
55174
|
+
o === "use" ? Array.isArray(t.transformer.use) && (n.use = t.transformer.use.map((r) => {
|
|
55175
|
+
if (Array.isArray(r) && typeof r[0] == "string") {
|
|
55176
|
+
let l = this.transformerService.getTransformer(r[0]);
|
|
55177
|
+
if (l) return new l(r[1]);
|
|
55178
|
+
}
|
|
55179
|
+
if (typeof r == "string") return this.transformerService.getTransformer(r);
|
|
55180
|
+
}).filter((r) => typeof r < "u")) : Array.isArray(t.transformer[o]?.use) && (n[o] = { use: t.transformer[o].use.map((r) => {
|
|
55181
|
+
if (Array.isArray(r) && typeof r[0] == "string") {
|
|
55182
|
+
let l = this.transformerService.getTransformer(r[0]);
|
|
55183
|
+
if (l) return new l(r[1]);
|
|
55184
|
+
}
|
|
55185
|
+
if (typeof r == "string") return this.transformerService.getTransformer(r);
|
|
55186
|
+
}).filter((r) => typeof r < "u") });
|
|
55187
|
+
}), console.log("providerConfig: ", t.name, n.use), this.registerProvider({ name: t.name, baseUrl: t.api_base_url, apiKey: t.api_key, models: t.models || [], transformer: t.transformer ? n : void 0 }), p(`${t.name} provider registered`);
|
|
55180
55188
|
} catch (n) {
|
|
55181
|
-
|
|
55189
|
+
p(`${t.name} provider registered error: ${n}`);
|
|
55182
55190
|
}
|
|
55183
55191
|
});
|
|
55184
55192
|
}
|
|
@@ -55200,35 +55208,34 @@ var J = class {
|
|
|
55200
55208
|
if (!n) return null;
|
|
55201
55209
|
let o = { ...n, ...t, updatedAt: /* @__PURE__ */ new Date() };
|
|
55202
55210
|
return this.providers.set(e, o), t.models && (n.models.forEach((r) => {
|
|
55203
|
-
let
|
|
55204
|
-
this.modelRoutes.delete(
|
|
55211
|
+
let l = `${n.id},${r}`;
|
|
55212
|
+
this.modelRoutes.delete(l), this.modelRoutes.delete(r);
|
|
55205
55213
|
}), t.models.forEach((r) => {
|
|
55206
|
-
let
|
|
55207
|
-
this.modelRoutes.set(
|
|
55214
|
+
let l = `${n.name},${r}`, u = { provider: n.name, model: r, fullModel: l };
|
|
55215
|
+
this.modelRoutes.set(l, u), this.modelRoutes.has(r) || this.modelRoutes.set(r, u);
|
|
55208
55216
|
})), o;
|
|
55209
55217
|
}
|
|
55210
55218
|
deleteProvider(e) {
|
|
55211
55219
|
let t = this.providers.get(e);
|
|
55212
55220
|
return t ? (t.models.forEach((n) => {
|
|
55213
|
-
let o = `${t.
|
|
55221
|
+
let o = `${t.name},${n}`;
|
|
55214
55222
|
this.modelRoutes.delete(o), this.modelRoutes.delete(n);
|
|
55215
55223
|
}), this.providers.delete(e), true) : false;
|
|
55216
55224
|
}
|
|
55217
55225
|
toggleProvider(e, t) {
|
|
55218
|
-
|
|
55219
|
-
return n ? (n.enabled = t, n.updatedAt = /* @__PURE__ */ new Date(), true) : false;
|
|
55226
|
+
return !!this.providers.get(e);
|
|
55220
55227
|
}
|
|
55221
55228
|
resolveModelRoute(e) {
|
|
55222
55229
|
let t = this.modelRoutes.get(e);
|
|
55223
55230
|
if (!t) return null;
|
|
55224
|
-
let n = this.providers.get(t.
|
|
55225
|
-
return
|
|
55231
|
+
let n = this.providers.get(t.provider);
|
|
55232
|
+
return n ? { provider: n, originalModel: e, targetModel: t.model } : null;
|
|
55226
55233
|
}
|
|
55227
55234
|
getAvailableModelNames() {
|
|
55228
55235
|
let e = [];
|
|
55229
55236
|
return this.providers.forEach((t) => {
|
|
55230
|
-
t.
|
|
55231
|
-
e.push(n), e.push(`${t.
|
|
55237
|
+
t.models.forEach((n) => {
|
|
55238
|
+
e.push(n), e.push(`${t.name},${n}`);
|
|
55232
55239
|
});
|
|
55233
55240
|
}), e;
|
|
55234
55241
|
}
|
|
@@ -55247,43 +55254,43 @@ var J = class {
|
|
|
55247
55254
|
async getAvailableModels() {
|
|
55248
55255
|
let e = [];
|
|
55249
55256
|
return this.providers.forEach((t) => {
|
|
55250
|
-
t.
|
|
55251
|
-
e.push({ id: n, object: "model",
|
|
55257
|
+
t.models.forEach((n) => {
|
|
55258
|
+
e.push({ id: n, object: "model", owned_by: t.name, provider: t.name }), e.push({ id: `${t.name},${n}`, object: "model", owned_by: t.name, provider: t.name });
|
|
55252
55259
|
});
|
|
55253
55260
|
}), { object: "list", data: e };
|
|
55254
55261
|
}
|
|
55255
55262
|
};
|
|
55256
|
-
var
|
|
55263
|
+
var F = class {
|
|
55257
55264
|
name = "Anthropic";
|
|
55258
55265
|
endPoint = "/v1/messages";
|
|
55259
55266
|
transformRequestOut(e) {
|
|
55260
|
-
|
|
55261
|
-
let t = []
|
|
55267
|
+
p("Anthropic Request:", JSON.stringify(e, null, 2));
|
|
55268
|
+
let t = [];
|
|
55262
55269
|
if (e.system) {
|
|
55263
55270
|
if (typeof e.system == "string") t.push({ role: "system", content: e.system });
|
|
55264
55271
|
else if (Array.isArray(e.system)) {
|
|
55265
|
-
let
|
|
55266
|
-
t.push(
|
|
55267
|
-
}
|
|
55268
|
-
}
|
|
55269
|
-
return JSON.parse(JSON.stringify(e.messages || []))?.forEach((
|
|
55270
|
-
if (
|
|
55271
|
-
let
|
|
55272
|
-
if (typeof
|
|
55273
|
-
else if (Array.isArray(
|
|
55274
|
-
if (
|
|
55275
|
-
let
|
|
55276
|
-
|
|
55277
|
-
let
|
|
55278
|
-
t.push(
|
|
55272
|
+
let r = e.system.filter((l) => l.type === "text" && l.text).map((l) => ({ type: "text", text: l.text, cache_control: l.cache_control }));
|
|
55273
|
+
t.push({ role: "system", content: r });
|
|
55274
|
+
}
|
|
55275
|
+
}
|
|
55276
|
+
return JSON.parse(JSON.stringify(e.messages || []))?.forEach((r, l) => {
|
|
55277
|
+
if (r.role === "user" || r.role === "assistant") {
|
|
55278
|
+
let u = { role: r.role, content: null };
|
|
55279
|
+
if (typeof r.content == "string") t.push({ role: r.role, content: r.content });
|
|
55280
|
+
else if (Array.isArray(r.content)) {
|
|
55281
|
+
if (r.role === "user") {
|
|
55282
|
+
let d = r.content.filter((c) => c.type === "tool_result" && c.tool_use_id);
|
|
55283
|
+
d.length && d.forEach((c, h) => {
|
|
55284
|
+
let g = { role: "tool", content: typeof c.content == "string" ? c.content : JSON.stringify(c.content), tool_call_id: c.tool_use_id, cache_control: c.cache_control };
|
|
55285
|
+
t.push(g);
|
|
55279
55286
|
});
|
|
55280
|
-
let
|
|
55281
|
-
|
|
55282
|
-
} else if (
|
|
55283
|
-
let
|
|
55284
|
-
|
|
55285
|
-
let
|
|
55286
|
-
|
|
55287
|
+
let i = r.content.filter((c) => c.type === "text" && c.text);
|
|
55288
|
+
i.length && t.push({ role: "user", content: i });
|
|
55289
|
+
} else if (r.role === "assistant") {
|
|
55290
|
+
let d = r.content.filter((c) => c.type === "text" && c.text);
|
|
55291
|
+
d.length && t.push(...d.map((c) => ({ role: "assistant", content: c.text })));
|
|
55292
|
+
let i = r.content.filter((c) => c.type === "tool_use" && c.id);
|
|
55293
|
+
i.length && t.push({ role: "assistant", content: null, tool_calls: i.map((c) => ({ id: c.id, type: "function", function: { name: c.name, arguments: JSON.stringify(c.input || {}) } })) });
|
|
55287
55294
|
}
|
|
55288
55295
|
return;
|
|
55289
55296
|
}
|
|
@@ -55305,148 +55312,148 @@ var N = class {
|
|
|
55305
55312
|
}
|
|
55306
55313
|
async convertOpenAIStreamToAnthropic(e) {
|
|
55307
55314
|
return new ReadableStream({ async start(n) {
|
|
55308
|
-
let o = new TextEncoder(), r = `msg_${Date.now()}`,
|
|
55315
|
+
let o = new TextEncoder(), r = `msg_${Date.now()}`, l = "unknown", u = false, d = false, i = false, c = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = 0, m = 0, f = 0, s = false, _ = false, y = 0, v = (x) => {
|
|
55309
55316
|
if (!s) try {
|
|
55310
|
-
n.enqueue(
|
|
55311
|
-
let
|
|
55312
|
-
|
|
55313
|
-
} catch (
|
|
55314
|
-
if (
|
|
55315
|
-
else throw
|
|
55316
|
-
}
|
|
55317
|
-
},
|
|
55317
|
+
n.enqueue(x);
|
|
55318
|
+
let C = new TextDecoder().decode(x);
|
|
55319
|
+
p("send data:", C.trim());
|
|
55320
|
+
} catch (C) {
|
|
55321
|
+
if (C instanceof TypeError && C.message.includes("Controller is already closed")) s = true;
|
|
55322
|
+
else throw p(`send data error: ${C.message}`), C;
|
|
55323
|
+
}
|
|
55324
|
+
}, z = () => {
|
|
55318
55325
|
if (!s) try {
|
|
55319
55326
|
n.close(), s = true;
|
|
55320
|
-
} catch (
|
|
55321
|
-
if (
|
|
55322
|
-
else throw
|
|
55327
|
+
} catch (x) {
|
|
55328
|
+
if (x instanceof TypeError && x.message.includes("Controller is already closed")) s = true;
|
|
55329
|
+
else throw x;
|
|
55323
55330
|
}
|
|
55324
|
-
},
|
|
55331
|
+
}, M = null;
|
|
55325
55332
|
try {
|
|
55326
|
-
|
|
55327
|
-
let
|
|
55333
|
+
M = e.getReader();
|
|
55334
|
+
let x = new TextDecoder(), C = "";
|
|
55328
55335
|
for (; !s; ) {
|
|
55329
|
-
let { done:
|
|
55330
|
-
if (
|
|
55331
|
-
|
|
55332
|
-
let
|
|
55336
|
+
let { done: oe, value: re } = await M.read();
|
|
55337
|
+
if (oe) break;
|
|
55338
|
+
C += x.decode(re, { stream: true });
|
|
55339
|
+
let K = C.split(`
|
|
55333
55340
|
`);
|
|
55334
|
-
|
|
55335
|
-
for (let
|
|
55336
|
-
if (s ||
|
|
55337
|
-
if (!
|
|
55338
|
-
let
|
|
55339
|
-
if (
|
|
55340
|
-
let
|
|
55341
|
-
if (
|
|
55342
|
-
|
|
55343
|
-
let
|
|
55344
|
-
|
|
55345
|
-
data: ${JSON.stringify(
|
|
55341
|
+
C = K.pop() || "";
|
|
55342
|
+
for (let Y of K) {
|
|
55343
|
+
if (s || i) break;
|
|
55344
|
+
if (!Y.startsWith("data: ")) continue;
|
|
55345
|
+
let B = Y.slice(6);
|
|
55346
|
+
if (B !== "[DONE]") try {
|
|
55347
|
+
let P = JSON.parse(B);
|
|
55348
|
+
if (g++, p("Original Response:", JSON.stringify(P, null, 2)), l = P.model || l, !u && !s && !i) {
|
|
55349
|
+
u = true;
|
|
55350
|
+
let k = { type: "message_start", message: { id: r, type: "message", role: "assistant", content: [], model: l, stop_reason: null, stop_sequence: null, usage: { input_tokens: 1, output_tokens: 1 } } };
|
|
55351
|
+
v(o.encode(`event: message_start
|
|
55352
|
+
data: ${JSON.stringify(k)}
|
|
55346
55353
|
|
|
55347
55354
|
`));
|
|
55348
55355
|
}
|
|
55349
|
-
let
|
|
55350
|
-
if (!
|
|
55351
|
-
if (
|
|
55352
|
-
if (!
|
|
55353
|
-
let
|
|
55354
|
-
|
|
55355
|
-
data: ${JSON.stringify(
|
|
55356
|
-
|
|
55357
|
-
`)),
|
|
55356
|
+
let S = P.choices?.[0];
|
|
55357
|
+
if (!S) continue;
|
|
55358
|
+
if (S?.delta?.thinking && !s && !i) {
|
|
55359
|
+
if (!_) {
|
|
55360
|
+
let k = { type: "content_block_start", index: y, content_block: { type: "thinking", thinking: "" } };
|
|
55361
|
+
v(o.encode(`event: content_block_start
|
|
55362
|
+
data: ${JSON.stringify(k)}
|
|
55363
|
+
|
|
55364
|
+
`)), _ = true;
|
|
55358
55365
|
}
|
|
55359
|
-
if (
|
|
55360
|
-
let
|
|
55361
|
-
|
|
55362
|
-
data: ${JSON.stringify(
|
|
55366
|
+
if (S.delta.thinking.signature) {
|
|
55367
|
+
let k = { type: "content_block_delta", index: y, delta: { type: "signature_delta", signature: S.delta.thinking.signature } };
|
|
55368
|
+
v(o.encode(`event: content_block_delta
|
|
55369
|
+
data: ${JSON.stringify(k)}
|
|
55363
55370
|
|
|
55364
55371
|
`));
|
|
55365
|
-
let
|
|
55366
|
-
|
|
55367
|
-
data: ${JSON.stringify(
|
|
55372
|
+
let b = { type: "content_block_stop", index: y };
|
|
55373
|
+
v(o.encode(`event: content_block_stop
|
|
55374
|
+
data: ${JSON.stringify(b)}
|
|
55368
55375
|
|
|
55369
55376
|
`)), y++;
|
|
55370
|
-
} else if (
|
|
55371
|
-
let
|
|
55372
|
-
|
|
55373
|
-
data: ${JSON.stringify(
|
|
55377
|
+
} else if (S.delta.thinking.content) {
|
|
55378
|
+
let k = { type: "content_block_delta", index: y, delta: { type: "thinking_delta", thinking: S.delta.thinking.content || "" } };
|
|
55379
|
+
v(o.encode(`event: content_block_delta
|
|
55380
|
+
data: ${JSON.stringify(k)}
|
|
55374
55381
|
|
|
55375
55382
|
`));
|
|
55376
55383
|
}
|
|
55377
55384
|
}
|
|
55378
|
-
if (
|
|
55379
|
-
if (
|
|
55385
|
+
if (S?.delta?.content && !s && !i) {
|
|
55386
|
+
if (m++, !d && !i) {
|
|
55380
55387
|
d = true;
|
|
55381
|
-
let
|
|
55382
|
-
|
|
55383
|
-
data: ${JSON.stringify(
|
|
55388
|
+
let k = { type: "content_block_start", index: y, content_block: { type: "text", text: "" } };
|
|
55389
|
+
v(o.encode(`event: content_block_start
|
|
55390
|
+
data: ${JSON.stringify(k)}
|
|
55384
55391
|
|
|
55385
55392
|
`));
|
|
55386
55393
|
}
|
|
55387
|
-
if (!s && !
|
|
55388
|
-
let
|
|
55389
|
-
|
|
55390
|
-
data: ${JSON.stringify(
|
|
55394
|
+
if (!s && !i) {
|
|
55395
|
+
let k = { type: "content_block_delta", index: y, delta: { type: "text_delta", text: S.delta.content } };
|
|
55396
|
+
v(o.encode(`event: content_block_delta
|
|
55397
|
+
data: ${JSON.stringify(k)}
|
|
55391
55398
|
|
|
55392
55399
|
`));
|
|
55393
55400
|
}
|
|
55394
55401
|
}
|
|
55395
|
-
if (
|
|
55402
|
+
if (S?.delta?.tool_calls && !s && !i) {
|
|
55396
55403
|
f++;
|
|
55397
|
-
let
|
|
55398
|
-
for (let
|
|
55404
|
+
let k = /* @__PURE__ */ new Set();
|
|
55405
|
+
for (let b of S.delta.tool_calls) {
|
|
55399
55406
|
if (s) break;
|
|
55400
|
-
let R =
|
|
55401
|
-
if (
|
|
55402
|
-
if (
|
|
55403
|
-
let
|
|
55404
|
-
if (
|
|
55405
|
-
|
|
55406
|
-
let
|
|
55407
|
-
|
|
55408
|
-
data: ${JSON.stringify(
|
|
55407
|
+
let R = b.index ?? 0;
|
|
55408
|
+
if (k.has(R)) continue;
|
|
55409
|
+
if (k.add(R), !h.has(R)) {
|
|
55410
|
+
let T = d ? h.size + 1 : h.size;
|
|
55411
|
+
if (T !== 0) {
|
|
55412
|
+
p("content_block_stop2");
|
|
55413
|
+
let se = { type: "content_block_stop", index: y };
|
|
55414
|
+
v(o.encode(`event: content_block_stop
|
|
55415
|
+
data: ${JSON.stringify(se)}
|
|
55409
55416
|
|
|
55410
55417
|
`)), y++;
|
|
55411
55418
|
}
|
|
55412
|
-
|
|
55413
|
-
let E =
|
|
55414
|
-
|
|
55419
|
+
h.set(R, T);
|
|
55420
|
+
let E = b.id || `call_${Date.now()}_${R}`, w = b.function?.name || `tool_${R}`, O = { type: "content_block_start", index: y, content_block: { type: "tool_use", id: E, name: w, input: {} } };
|
|
55421
|
+
v(o.encode(`event: content_block_start
|
|
55415
55422
|
data: ${JSON.stringify(O)}
|
|
55416
55423
|
|
|
55417
55424
|
`));
|
|
55418
|
-
let L = { id: E, name: w, arguments: "", contentBlockIndex:
|
|
55419
|
-
|
|
55420
|
-
} else if (
|
|
55421
|
-
let
|
|
55422
|
-
|
|
55425
|
+
let L = { id: E, name: w, arguments: "", contentBlockIndex: T };
|
|
55426
|
+
c.set(R, L);
|
|
55427
|
+
} else if (b.id && b.function?.name) {
|
|
55428
|
+
let T = c.get(R);
|
|
55429
|
+
T.id.startsWith("call_") && T.name.startsWith("tool_") && (T.id = b.id, T.name = b.function.name);
|
|
55423
55430
|
}
|
|
55424
|
-
if (
|
|
55425
|
-
if (
|
|
55426
|
-
let E =
|
|
55431
|
+
if (b.function?.arguments && !s && !i) {
|
|
55432
|
+
if (h.get(R) === void 0) continue;
|
|
55433
|
+
let E = c.get(R);
|
|
55427
55434
|
if (E) {
|
|
55428
|
-
E.arguments +=
|
|
55435
|
+
E.arguments += b.function.arguments;
|
|
55429
55436
|
try {
|
|
55430
55437
|
let w = null, O = E.arguments.trim();
|
|
55431
55438
|
if (O.startsWith("{") && O.endsWith("}")) try {
|
|
55432
55439
|
w = JSON.parse(O);
|
|
55433
55440
|
} catch (L) {
|
|
55434
|
-
|
|
55441
|
+
p("Tool call index:", R, "error", L.message);
|
|
55435
55442
|
}
|
|
55436
55443
|
} catch (w) {
|
|
55437
|
-
|
|
55444
|
+
p("Tool call index:", R, "error", w.message);
|
|
55438
55445
|
}
|
|
55439
55446
|
}
|
|
55440
55447
|
try {
|
|
55441
|
-
let w = { type: "content_block_delta", index: y, delta: { type: "input_json_delta", partial_json:
|
|
55442
|
-
|
|
55448
|
+
let w = { type: "content_block_delta", index: y, delta: { type: "input_json_delta", partial_json: b.function.arguments } };
|
|
55449
|
+
v(o.encode(`event: content_block_delta
|
|
55443
55450
|
data: ${JSON.stringify(w)}
|
|
55444
55451
|
|
|
55445
55452
|
`));
|
|
55446
55453
|
} catch {
|
|
55447
55454
|
try {
|
|
55448
|
-
let O =
|
|
55449
|
-
|
|
55455
|
+
let O = b.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 } };
|
|
55456
|
+
v(o.encode(`event: content_block_delta
|
|
55450
55457
|
data: ${JSON.stringify(L)}
|
|
55451
55458
|
|
|
55452
55459
|
`));
|
|
@@ -55457,74 +55464,74 @@ data: ${JSON.stringify(L)}
|
|
|
55457
55464
|
}
|
|
55458
55465
|
}
|
|
55459
55466
|
}
|
|
55460
|
-
if (
|
|
55461
|
-
if (
|
|
55462
|
-
|
|
55463
|
-
let
|
|
55464
|
-
|
|
55465
|
-
data: ${JSON.stringify(
|
|
55467
|
+
if (S?.finish_reason && !s && !i) {
|
|
55468
|
+
if (i = true, m === 0 && f === 0 && console.error("Warning: No content in the stream response!"), (d || f > 0) && !s) {
|
|
55469
|
+
p("content_block_stop hasTextContentStarted");
|
|
55470
|
+
let k = { type: "content_block_stop", index: y };
|
|
55471
|
+
v(o.encode(`event: content_block_stop
|
|
55472
|
+
data: ${JSON.stringify(k)}
|
|
55466
55473
|
|
|
55467
55474
|
`));
|
|
55468
55475
|
}
|
|
55469
55476
|
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" }[
|
|
55471
|
-
|
|
55477
|
+
let R = { type: "message_delta", delta: { stop_reason: { stop: "end_turn", length: "max_tokens", tool_calls: "tool_use", content_filter: "stop_sequence" }[S.finish_reason] || "end_turn", stop_sequence: null }, usage: { input_tokens: P.usage?.prompt_tokens || 0, output_tokens: P.usage?.completion_tokens || 0 } };
|
|
55478
|
+
v(o.encode(`event: message_delta
|
|
55472
55479
|
data: ${JSON.stringify(R)}
|
|
55473
55480
|
|
|
55474
55481
|
`));
|
|
55475
55482
|
}
|
|
55476
55483
|
if (!s) {
|
|
55477
|
-
let
|
|
55478
|
-
|
|
55479
|
-
data: ${JSON.stringify(
|
|
55484
|
+
let k = { type: "message_stop" };
|
|
55485
|
+
v(o.encode(`event: message_stop
|
|
55486
|
+
data: ${JSON.stringify(k)}
|
|
55480
55487
|
|
|
55481
55488
|
`));
|
|
55482
55489
|
}
|
|
55483
55490
|
break;
|
|
55484
55491
|
}
|
|
55485
|
-
} catch (
|
|
55486
|
-
|
|
55492
|
+
} catch (P) {
|
|
55493
|
+
p(`parseError: ${P.name} message: ${P.message} stack: ${P.stack} data: ${B}`);
|
|
55487
55494
|
}
|
|
55488
55495
|
}
|
|
55489
55496
|
}
|
|
55490
|
-
|
|
55491
|
-
} catch (
|
|
55497
|
+
z();
|
|
55498
|
+
} catch (x) {
|
|
55492
55499
|
if (!s) try {
|
|
55493
|
-
n.error(
|
|
55494
|
-
} catch (
|
|
55495
|
-
console.error(
|
|
55500
|
+
n.error(x);
|
|
55501
|
+
} catch (C) {
|
|
55502
|
+
console.error(C);
|
|
55496
55503
|
}
|
|
55497
55504
|
} finally {
|
|
55498
|
-
if (
|
|
55499
|
-
|
|
55500
|
-
} catch (
|
|
55501
|
-
console.error(
|
|
55505
|
+
if (M) try {
|
|
55506
|
+
M.releaseLock();
|
|
55507
|
+
} catch (x) {
|
|
55508
|
+
console.error(x);
|
|
55502
55509
|
}
|
|
55503
55510
|
}
|
|
55504
55511
|
}, cancel(n) {
|
|
55505
|
-
|
|
55512
|
+
p("cancle stream:", n);
|
|
55506
55513
|
} });
|
|
55507
55514
|
}
|
|
55508
55515
|
convertOpenAIResponseToAnthropic(e) {
|
|
55509
|
-
|
|
55516
|
+
p("Original OpenAI response:", JSON.stringify(e, null, 2));
|
|
55510
55517
|
let t = e.choices[0];
|
|
55511
55518
|
if (!t) throw new Error("No choices found in OpenAI response");
|
|
55512
55519
|
let n = [];
|
|
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,
|
|
55514
|
-
let
|
|
55520
|
+
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, l) => {
|
|
55521
|
+
let u = {};
|
|
55515
55522
|
try {
|
|
55516
55523
|
let d = r.function.arguments || "{}";
|
|
55517
|
-
typeof d == "object" ?
|
|
55524
|
+
typeof d == "object" ? u = d : typeof d == "string" && (u = JSON.parse(d));
|
|
55518
55525
|
} catch {
|
|
55519
|
-
|
|
55526
|
+
u = { text: r.function.arguments || "" };
|
|
55520
55527
|
}
|
|
55521
|
-
n.push({ type: "tool_use", id: r.id, name: r.function.name, input:
|
|
55528
|
+
n.push({ type: "tool_use", id: r.id, name: r.function.name, input: u });
|
|
55522
55529
|
});
|
|
55523
55530
|
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 } };
|
|
55524
|
-
return
|
|
55531
|
+
return p("Conversion complete, final Anthropic response:", JSON.stringify(o, null, 2)), o;
|
|
55525
55532
|
}
|
|
55526
55533
|
};
|
|
55527
|
-
var
|
|
55534
|
+
var I = class {
|
|
55528
55535
|
name = "gemini";
|
|
55529
55536
|
endPoint = "/v1beta/models/:modelAndAction";
|
|
55530
55537
|
transformRequestIn(e, t) {
|
|
@@ -55532,22 +55539,22 @@ var M = class {
|
|
|
55532
55539
|
let o;
|
|
55533
55540
|
n.role === "assistant" ? o = "model" : (["user", "system", "tool"].includes(n.role), o = "user");
|
|
55534
55541
|
let r = [];
|
|
55535
|
-
return typeof n.content == "string" ? r.push({ text: n.content }) : Array.isArray(n.content) && r.push(...n.content.map((
|
|
55536
|
-
if (
|
|
55537
|
-
})), Array.isArray(n.tool_calls) && r.push(...n.tool_calls.map((
|
|
55542
|
+
return typeof n.content == "string" ? r.push({ text: n.content }) : Array.isArray(n.content) && r.push(...n.content.map((l) => {
|
|
55543
|
+
if (l.type === "text") return { text: l.text || "" };
|
|
55544
|
+
})), Array.isArray(n.tool_calls) && r.push(...n.tool_calls.map((l) => ({ functionCall: { id: l.id || `tool_${Math.random().toString(36).substring(2, 15)}`, name: l.function.name, args: JSON.parse(l.function.arguments || "{}") } }))), { role: o, parts: r };
|
|
55538
55545
|
}), 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) => {
|
|
55539
55546
|
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);
|
|
55540
55547
|
}), { 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 } } };
|
|
55541
55548
|
}
|
|
55542
55549
|
transformRequestOut(e) {
|
|
55543
|
-
let t = e.contents, n = e.tools, o = e.model, r = e.max_tokens,
|
|
55544
|
-
return Array.isArray(t) && t.forEach((
|
|
55545
|
-
typeof
|
|
55546
|
-
}), Array.isArray(n) && (
|
|
55547
|
-
Array.isArray(
|
|
55548
|
-
|
|
55550
|
+
let t = e.contents, n = e.tools, o = e.model, r = e.max_tokens, l = e.temperature, u = e.stream, d = e.tool_choice, i = { messages: [], model: o, max_tokens: r, temperature: l, stream: u, tool_choice: d };
|
|
55551
|
+
return Array.isArray(t) && t.forEach((c) => {
|
|
55552
|
+
typeof c == "string" ? i.messages.push({ role: "user", content: c }) : typeof c.text == "string" ? i.messages.push({ role: "user", content: c.text || null }) : c.role === "user" ? i.messages.push({ role: "user", content: c?.parts?.map((h) => ({ type: "text", text: h.text || "" })) || [] }) : c.role === "model" && i.messages.push({ role: "assistant", content: c?.parts?.map((h) => ({ type: "text", text: h.text || "" })) || [] });
|
|
55553
|
+
}), Array.isArray(n) && (i.tools = [], n.forEach((c) => {
|
|
55554
|
+
Array.isArray(c.functionDeclarations) && c.functionDeclarations.forEach((h) => {
|
|
55555
|
+
i.tools.push({ type: "function", function: { name: h.name, description: h.description, parameters: h.parameters } });
|
|
55549
55556
|
});
|
|
55550
|
-
})),
|
|
55557
|
+
})), i;
|
|
55551
55558
|
}
|
|
55552
55559
|
async transformResponseOut(e) {
|
|
55553
55560
|
if (e.headers.get("Content-Type")?.includes("application/json")) {
|
|
@@ -55557,23 +55564,23 @@ var M = class {
|
|
|
55557
55564
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55558
55565
|
if (!e.body) return e;
|
|
55559
55566
|
let t = new TextDecoder(), n = new TextEncoder(), o = new ReadableStream({ async start(r) {
|
|
55560
|
-
let
|
|
55567
|
+
let l = e.body.getReader();
|
|
55561
55568
|
try {
|
|
55562
55569
|
for (; ; ) {
|
|
55563
|
-
let { done:
|
|
55564
|
-
if (
|
|
55565
|
-
let
|
|
55566
|
-
if (
|
|
55570
|
+
let { done: u, value: d } = await l.read();
|
|
55571
|
+
if (u) break;
|
|
55572
|
+
let i = t.decode(d, { stream: true });
|
|
55573
|
+
if (i.startsWith("data: ")) i = i.slice(6).trim();
|
|
55567
55574
|
else break;
|
|
55568
|
-
|
|
55569
|
-
let
|
|
55570
|
-
`), tool_calls:
|
|
55571
|
-
|
|
55575
|
+
p("gemini chunk:", i), i = JSON.parse(i);
|
|
55576
|
+
let c = i.candidates[0].content.parts.filter((g) => g.functionCall).map((g) => ({ id: g.functionCall?.id || `tool_${Math.random().toString(36).substring(2, 15)}`, type: "function", function: { name: g.functionCall?.name, arguments: JSON.stringify(g.functionCall?.args || {}) } })), h = { choices: [{ delta: { role: "assistant", content: i.candidates[0].content.parts.filter((g) => g.text).map((g) => g.text).join(`
|
|
55577
|
+
`), tool_calls: c.length > 0 ? c : void 0 }, finish_reason: i.candidates[0].finishReason?.toLowerCase() || null, index: i.candidates[0].index || c.length > 0 ? 1 : 0, logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: i.responseId || "", model: i.modelVersion || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1" };
|
|
55578
|
+
p("gemini response:", JSON.stringify(h, null, 2)), r.enqueue(n.encode(`data: ${JSON.stringify(h)}
|
|
55572
55579
|
|
|
55573
55580
|
`));
|
|
55574
55581
|
}
|
|
55575
|
-
} catch (
|
|
55576
|
-
r.error(
|
|
55582
|
+
} catch (u) {
|
|
55583
|
+
r.error(u);
|
|
55577
55584
|
} finally {
|
|
55578
55585
|
r.close();
|
|
55579
55586
|
}
|
|
@@ -55583,7 +55590,7 @@ var M = class {
|
|
|
55583
55590
|
return e;
|
|
55584
55591
|
}
|
|
55585
55592
|
};
|
|
55586
|
-
var
|
|
55593
|
+
var j = class {
|
|
55587
55594
|
name = "deepseek";
|
|
55588
55595
|
transformRequestIn(e) {
|
|
55589
55596
|
return e.max_tokens && e.max_tokens > 8192 && (e.max_tokens = 8192), e;
|
|
@@ -55594,66 +55601,66 @@ var H = class {
|
|
|
55594
55601
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
55595
55602
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55596
55603
|
if (!e.body) return e;
|
|
55597
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = "", r = false,
|
|
55604
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = "", r = false, l = new ReadableStream({ async start(u) {
|
|
55598
55605
|
let d = e.body.getReader();
|
|
55599
55606
|
try {
|
|
55600
55607
|
for (; ; ) {
|
|
55601
|
-
let { done:
|
|
55602
|
-
if (
|
|
55603
|
-
let
|
|
55608
|
+
let { done: i, value: c } = await d.read();
|
|
55609
|
+
if (i) break;
|
|
55610
|
+
let g = t.decode(c, { stream: true }).split(`
|
|
55604
55611
|
`);
|
|
55605
|
-
for (let
|
|
55606
|
-
let f = JSON.parse(
|
|
55612
|
+
for (let m of g) if (m.startsWith("data: ") && m.trim() !== "data: [DONE]") try {
|
|
55613
|
+
let f = JSON.parse(m.slice(6));
|
|
55607
55614
|
if (f.choices?.[0]?.delta?.reasoning_content) {
|
|
55608
55615
|
o += f.choices[0].delta.reasoning_content;
|
|
55609
55616
|
let s = { ...f, choices: [{ ...f.choices[0], delta: { ...f.choices[0].delta, thinking: { content: f.choices[0].delta.reasoning_content } } }] };
|
|
55610
55617
|
delete s.choices[0].delta.reasoning_content;
|
|
55611
|
-
let
|
|
55618
|
+
let _ = `data: ${JSON.stringify(s)}
|
|
55612
55619
|
|
|
55613
55620
|
`;
|
|
55614
|
-
|
|
55621
|
+
u.enqueue(n.encode(_));
|
|
55615
55622
|
continue;
|
|
55616
55623
|
}
|
|
55617
55624
|
if (f.choices?.[0]?.delta?.content && o && !r) {
|
|
55618
55625
|
r = true;
|
|
55619
|
-
let s = Date.now().toString(),
|
|
55620
|
-
delete
|
|
55621
|
-
let y = `data: ${JSON.stringify(
|
|
55626
|
+
let s = Date.now().toString(), _ = { ...f, choices: [{ ...f.choices[0], delta: { ...f.choices[0].delta, content: null, thinking: { content: o, signature: s } } }] };
|
|
55627
|
+
delete _.choices[0].delta.reasoning_content;
|
|
55628
|
+
let y = `data: ${JSON.stringify(_)}
|
|
55622
55629
|
|
|
55623
55630
|
`;
|
|
55624
|
-
|
|
55631
|
+
u.enqueue(n.encode(y));
|
|
55625
55632
|
}
|
|
55626
55633
|
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
55634
|
r && f.choices[0].index++;
|
|
55628
55635
|
let s = `data: ${JSON.stringify(f)}
|
|
55629
55636
|
|
|
55630
55637
|
`;
|
|
55631
|
-
|
|
55638
|
+
u.enqueue(n.encode(s));
|
|
55632
55639
|
}
|
|
55633
55640
|
} catch {
|
|
55634
|
-
|
|
55641
|
+
u.enqueue(n.encode(m + `
|
|
55635
55642
|
`));
|
|
55636
55643
|
}
|
|
55637
|
-
else
|
|
55644
|
+
else u.enqueue(n.encode(m + `
|
|
55638
55645
|
`));
|
|
55639
55646
|
}
|
|
55640
|
-
} catch (
|
|
55641
|
-
|
|
55647
|
+
} catch (i) {
|
|
55648
|
+
u.error(i);
|
|
55642
55649
|
} finally {
|
|
55643
55650
|
try {
|
|
55644
55651
|
d.releaseLock();
|
|
55645
|
-
} catch (
|
|
55646
|
-
console.error("Error releasing reader lock:",
|
|
55652
|
+
} catch (i) {
|
|
55653
|
+
console.error("Error releasing reader lock:", i);
|
|
55647
55654
|
}
|
|
55648
|
-
|
|
55655
|
+
u.close();
|
|
55649
55656
|
}
|
|
55650
55657
|
} });
|
|
55651
|
-
return new Response(
|
|
55658
|
+
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" } });
|
|
55652
55659
|
}
|
|
55653
55660
|
return e;
|
|
55654
55661
|
}
|
|
55655
55662
|
};
|
|
55656
|
-
var
|
|
55663
|
+
var q = class {
|
|
55657
55664
|
name = "tooluse";
|
|
55658
55665
|
transformRequestIn(e) {
|
|
55659
55666
|
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.
|
|
@@ -55672,16 +55679,16 @@ Examples:
|
|
|
55672
55679
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
55673
55680
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55674
55681
|
if (!e.body) return e;
|
|
55675
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = -1, r = "",
|
|
55682
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = -1, r = "", l = new ReadableStream({ async start(u) {
|
|
55676
55683
|
let d = e.body.getReader();
|
|
55677
55684
|
try {
|
|
55678
55685
|
for (; ; ) {
|
|
55679
|
-
let { done:
|
|
55680
|
-
if (
|
|
55681
|
-
let
|
|
55686
|
+
let { done: i, value: c } = await d.read();
|
|
55687
|
+
if (i) break;
|
|
55688
|
+
let g = t.decode(c, { stream: true }).split(`
|
|
55682
55689
|
`);
|
|
55683
|
-
for (let
|
|
55684
|
-
let f = JSON.parse(
|
|
55690
|
+
for (let m of g) if (m.startsWith("data: ") && m.trim() !== "data: [DONE]") try {
|
|
55691
|
+
let f = JSON.parse(m.slice(6));
|
|
55685
55692
|
if (f.choices[0]?.delta?.tool_calls?.length) {
|
|
55686
55693
|
let s = f.choices[0].delta.tool_calls[0];
|
|
55687
55694
|
if (s.function?.name === "ExitTool") {
|
|
@@ -55690,12 +55697,12 @@ Examples:
|
|
|
55690
55697
|
} else if (o > -1 && s.index === o && s.function.arguments) {
|
|
55691
55698
|
r += s.function.arguments;
|
|
55692
55699
|
try {
|
|
55693
|
-
let
|
|
55694
|
-
f.choices = [{ delta: { role: "assistant", content:
|
|
55700
|
+
let _ = JSON.parse(r);
|
|
55701
|
+
f.choices = [{ delta: { role: "assistant", content: _.response || "" } }];
|
|
55695
55702
|
let y = `data: ${JSON.stringify(f)}
|
|
55696
55703
|
|
|
55697
55704
|
`;
|
|
55698
|
-
|
|
55705
|
+
u.enqueue(n.encode(y));
|
|
55699
55706
|
} catch {
|
|
55700
55707
|
}
|
|
55701
55708
|
continue;
|
|
@@ -55705,73 +55712,80 @@ Examples:
|
|
|
55705
55712
|
let s = `data: ${JSON.stringify(f)}
|
|
55706
55713
|
|
|
55707
55714
|
`;
|
|
55708
|
-
|
|
55715
|
+
u.enqueue(n.encode(s));
|
|
55709
55716
|
}
|
|
55710
55717
|
} catch {
|
|
55711
|
-
|
|
55718
|
+
u.enqueue(n.encode(m + `
|
|
55712
55719
|
`));
|
|
55713
55720
|
}
|
|
55714
|
-
else
|
|
55721
|
+
else u.enqueue(n.encode(m + `
|
|
55715
55722
|
`));
|
|
55716
55723
|
}
|
|
55717
|
-
} catch (
|
|
55718
|
-
|
|
55724
|
+
} catch (i) {
|
|
55725
|
+
u.error(i);
|
|
55719
55726
|
} finally {
|
|
55720
55727
|
try {
|
|
55721
55728
|
d.releaseLock();
|
|
55722
|
-
} catch (
|
|
55723
|
-
console.error("Error releasing reader lock:",
|
|
55729
|
+
} catch (i) {
|
|
55730
|
+
console.error("Error releasing reader lock:", i);
|
|
55724
55731
|
}
|
|
55725
|
-
|
|
55732
|
+
u.close();
|
|
55726
55733
|
}
|
|
55727
55734
|
} });
|
|
55728
|
-
return new Response(
|
|
55735
|
+
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" } });
|
|
55729
55736
|
}
|
|
55730
55737
|
return e;
|
|
55731
55738
|
}
|
|
55732
55739
|
};
|
|
55733
|
-
var
|
|
55740
|
+
var J = class {
|
|
55734
55741
|
name = "openrouter";
|
|
55742
|
+
transformRequestIn(e) {
|
|
55743
|
+
return e.model.includes("claude") || e.messages.forEach((t) => {
|
|
55744
|
+
Array.isArray(t.content) ? t.content.forEach((n) => {
|
|
55745
|
+
n.cache_control && delete n.cache_control;
|
|
55746
|
+
}) : t.cache_control && delete t.cache_control;
|
|
55747
|
+
}), e;
|
|
55748
|
+
}
|
|
55735
55749
|
async transformResponseOut(e) {
|
|
55736
55750
|
if (e.headers.get("Content-Type")?.includes("application/json")) {
|
|
55737
55751
|
let t = await e.json();
|
|
55738
55752
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
55739
55753
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
55740
55754
|
if (!e.body) return e;
|
|
55741
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = false, r = "",
|
|
55742
|
-
let
|
|
55755
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = false, r = "", l = false, u = new ReadableStream({ async start(d) {
|
|
55756
|
+
let i = e.body.getReader();
|
|
55743
55757
|
try {
|
|
55744
55758
|
for (; ; ) {
|
|
55745
|
-
let { done:
|
|
55746
|
-
if (
|
|
55747
|
-
let
|
|
55759
|
+
let { done: c, value: h } = await i.read();
|
|
55760
|
+
if (c) break;
|
|
55761
|
+
let m = t.decode(h, { stream: true }).split(`
|
|
55748
55762
|
`);
|
|
55749
|
-
for (let f of
|
|
55763
|
+
for (let f of m) if (f.startsWith("data: ") && f.trim() !== "data: [DONE]") try {
|
|
55750
55764
|
let s = JSON.parse(f.slice(6));
|
|
55751
55765
|
if (s.choices[0]?.delta?.content && !o && (o = true), s.choices?.[0]?.delta?.reasoning) {
|
|
55752
55766
|
r += s.choices[0].delta.reasoning;
|
|
55753
55767
|
let y = { ...s, choices: [{ ...s.choices[0], delta: { ...s.choices[0].delta, thinking: { content: s.choices[0].delta.reasoning } } }] };
|
|
55754
55768
|
delete y.choices[0].delta.reasoning;
|
|
55755
|
-
let
|
|
55769
|
+
let v = `data: ${JSON.stringify(y)}
|
|
55756
55770
|
|
|
55757
55771
|
`;
|
|
55758
|
-
d.enqueue(n.encode(
|
|
55772
|
+
d.enqueue(n.encode(v));
|
|
55759
55773
|
continue;
|
|
55760
55774
|
}
|
|
55761
|
-
if (s.choices?.[0]?.delta?.content && r && !
|
|
55762
|
-
|
|
55763
|
-
let y = Date.now().toString(),
|
|
55764
|
-
delete
|
|
55765
|
-
let
|
|
55775
|
+
if (s.choices?.[0]?.delta?.content && r && !l) {
|
|
55776
|
+
l = true;
|
|
55777
|
+
let y = Date.now().toString(), v = { ...s, choices: [{ ...s.choices[0], delta: { ...s.choices[0].delta, content: null, thinking: { content: r, signature: y } } }] };
|
|
55778
|
+
delete v.choices[0].delta.reasoning;
|
|
55779
|
+
let z = `data: ${JSON.stringify(v)}
|
|
55766
55780
|
|
|
55767
55781
|
`;
|
|
55768
|
-
d.enqueue(n.encode(
|
|
55782
|
+
d.enqueue(n.encode(z));
|
|
55769
55783
|
}
|
|
55770
55784
|
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
|
|
55785
|
+
let _ = `data: ${JSON.stringify(s)}
|
|
55772
55786
|
|
|
55773
55787
|
`;
|
|
55774
|
-
d.enqueue(n.encode(
|
|
55788
|
+
d.enqueue(n.encode(_));
|
|
55775
55789
|
} catch {
|
|
55776
55790
|
d.enqueue(n.encode(f + `
|
|
55777
55791
|
`));
|
|
@@ -55779,30 +55793,41 @@ var F = class {
|
|
|
55779
55793
|
else d.enqueue(n.encode(f + `
|
|
55780
55794
|
`));
|
|
55781
55795
|
}
|
|
55782
|
-
} catch (
|
|
55783
|
-
d.error(
|
|
55796
|
+
} catch (c) {
|
|
55797
|
+
d.error(c);
|
|
55784
55798
|
} finally {
|
|
55785
55799
|
try {
|
|
55786
|
-
|
|
55787
|
-
} catch (
|
|
55788
|
-
console.error("Error releasing reader lock:",
|
|
55800
|
+
i.releaseLock();
|
|
55801
|
+
} catch (c) {
|
|
55802
|
+
console.error("Error releasing reader lock:", c);
|
|
55789
55803
|
}
|
|
55790
55804
|
d.close();
|
|
55791
55805
|
}
|
|
55792
55806
|
} });
|
|
55793
|
-
return new Response(
|
|
55807
|
+
return new Response(u, { status: e.status, statusText: e.statusText, headers: { "Content-Type": e.headers.get("Content-Type") || "text/plain", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
55794
55808
|
}
|
|
55795
55809
|
return e;
|
|
55796
55810
|
}
|
|
55797
55811
|
};
|
|
55798
55812
|
var U = class {
|
|
55813
|
+
constructor(e) {
|
|
55814
|
+
this.options = e;
|
|
55815
|
+
this.max_tokens = this.options?.max_tokens;
|
|
55816
|
+
}
|
|
55817
|
+
static TransformerName = "maxtoken";
|
|
55818
|
+
max_tokens;
|
|
55819
|
+
transformRequestIn(e) {
|
|
55820
|
+
return e.max_tokens && e.max_tokens > this.max_tokens && (e.max_tokens = this.max_tokens), e;
|
|
55821
|
+
}
|
|
55822
|
+
};
|
|
55823
|
+
var ne = { AnthropicTransformer: F, GeminiTransformer: I, DeepseekTransformer: j, TooluseTransformer: q, OpenrouterTransformer: J, MaxTokenTransformer: U };
|
|
55824
|
+
var D = class {
|
|
55799
55825
|
constructor(e) {
|
|
55800
55826
|
this.configService = e;
|
|
55801
|
-
this.initialize();
|
|
55802
55827
|
}
|
|
55803
55828
|
transformers = /* @__PURE__ */ new Map();
|
|
55804
55829
|
registerTransformer(e, t) {
|
|
55805
|
-
this.transformers.set(e, t),
|
|
55830
|
+
this.transformers.set(e, t), p(`register transformer: ${e}${t.endPoint ? ` (endpoint: ${t.endPoint})` : " (no endpoint)"}`);
|
|
55806
55831
|
}
|
|
55807
55832
|
getTransformer(e) {
|
|
55808
55833
|
return this.transformers.get(e);
|
|
@@ -55830,32 +55855,40 @@ var U = class {
|
|
|
55830
55855
|
}
|
|
55831
55856
|
async registerTransformerFromConfig(e) {
|
|
55832
55857
|
try {
|
|
55833
|
-
|
|
55834
|
-
|
|
55835
|
-
|
|
55836
|
-
|
|
55837
|
-
|
|
55838
|
-
|
|
55858
|
+
let t = import_node_module.default._load;
|
|
55859
|
+
if (import_node_module.default._load = function(n, o, r) {
|
|
55860
|
+
return n === "claude-code-router" ? { log: p } : t.apply(import_node_module.default, arguments);
|
|
55861
|
+
}, e.path) {
|
|
55862
|
+
let n = W(W.resolve(e.path));
|
|
55863
|
+
if (n) {
|
|
55864
|
+
let o = new n(e.options);
|
|
55865
|
+
if (!o.name) throw new Error(`Transformer instance from ${e.path} does not have a name property.`);
|
|
55866
|
+
return this.registerTransformer(o.name, o), true;
|
|
55839
55867
|
}
|
|
55840
55868
|
}
|
|
55841
55869
|
return false;
|
|
55842
55870
|
} catch (t) {
|
|
55843
|
-
return
|
|
55871
|
+
return p(`load transformer (${e.path}) error:`, t.message, t.stack), false;
|
|
55844
55872
|
}
|
|
55845
55873
|
}
|
|
55846
55874
|
async initialize() {
|
|
55847
55875
|
try {
|
|
55848
55876
|
await this.registerDefaultTransformersInternal(), await this.loadFromConfig();
|
|
55849
55877
|
} catch (e) {
|
|
55850
|
-
|
|
55878
|
+
p("TransformerService init error:", e);
|
|
55851
55879
|
}
|
|
55852
55880
|
}
|
|
55853
55881
|
async registerDefaultTransformersInternal() {
|
|
55854
55882
|
try {
|
|
55855
|
-
|
|
55856
|
-
|
|
55883
|
+
Object.values(ne).forEach((e) => {
|
|
55884
|
+
if ("TransformerName" in e && typeof e.TransformerName == "string") this.registerTransformer(e.TransformerName, e);
|
|
55885
|
+
else {
|
|
55886
|
+
let t = new e();
|
|
55887
|
+
this.registerTransformer(t.name, t);
|
|
55888
|
+
}
|
|
55889
|
+
});
|
|
55857
55890
|
} catch (e) {
|
|
55858
|
-
|
|
55891
|
+
p("transformer regist error:", e);
|
|
55859
55892
|
}
|
|
55860
55893
|
}
|
|
55861
55894
|
async loadFromConfig() {
|
|
@@ -55863,18 +55896,20 @@ var U = class {
|
|
|
55863
55896
|
for (let t of e) await this.registerTransformerFromConfig(t);
|
|
55864
55897
|
}
|
|
55865
55898
|
};
|
|
55866
|
-
function
|
|
55867
|
-
let
|
|
55868
|
-
return
|
|
55899
|
+
function pe() {
|
|
55900
|
+
let a = (0, import_fastify.default)({});
|
|
55901
|
+
return a.setErrorHandler(Z), a.register(import_cors.default), a;
|
|
55869
55902
|
}
|
|
55870
|
-
var
|
|
55903
|
+
var G = class {
|
|
55871
55904
|
app;
|
|
55872
55905
|
configService;
|
|
55873
55906
|
llmService;
|
|
55874
55907
|
providerService;
|
|
55875
55908
|
transformerService;
|
|
55876
55909
|
constructor(e = {}) {
|
|
55877
|
-
this.configService = new
|
|
55910
|
+
this.configService = new N(e), this.transformerService = new D(this.configService), this.transformerService.initialize().finally(() => {
|
|
55911
|
+
this.providerService = new $(this.configService, this.transformerService), this.llmService = new H(this.providerService);
|
|
55912
|
+
}), this.app = pe();
|
|
55878
55913
|
}
|
|
55879
55914
|
async register(e, t) {
|
|
55880
55915
|
await this.app.register(e, t);
|
|
@@ -55888,29 +55923,29 @@ var B = class {
|
|
|
55888
55923
|
try {
|
|
55889
55924
|
let r = n.body;
|
|
55890
55925
|
if (!r || !r.model) return o.code(400).send({ error: "Missing model in request body" });
|
|
55891
|
-
let [
|
|
55892
|
-
r.model =
|
|
55926
|
+
let [l, u] = r.model.split(",");
|
|
55927
|
+
r.model = u, n.provider = l;
|
|
55893
55928
|
return;
|
|
55894
55929
|
} catch (r) {
|
|
55895
55930
|
return n.log.error("Error in modelProviderMiddleware:", r), o.code(500).send({ error: "Internal server error" });
|
|
55896
55931
|
}
|
|
55897
|
-
}), this.app.register(
|
|
55932
|
+
}), this.app.register(te);
|
|
55898
55933
|
let e = await this.app.listen({ port: parseInt(this.configService.get("PORT") || "3000", 10), host: this.configService.get("HOST") || "127.0.0.1" });
|
|
55899
|
-
|
|
55934
|
+
p(`\u{1F680} LLMs API server listening on ${e}`);
|
|
55900
55935
|
let t = async (n) => {
|
|
55901
|
-
|
|
55936
|
+
p(`Received ${n}, shutting down gracefully...`), await this.app.close(), process.exit(0);
|
|
55902
55937
|
};
|
|
55903
55938
|
process.on("SIGINT", () => t("SIGINT")), process.on("SIGTERM", () => t("SIGTERM"));
|
|
55904
55939
|
} catch (e) {
|
|
55905
|
-
|
|
55940
|
+
p(`Error starting server: ${e}`), process.exit(1);
|
|
55906
55941
|
}
|
|
55907
55942
|
}
|
|
55908
55943
|
};
|
|
55909
|
-
var
|
|
55944
|
+
var At = G;
|
|
55910
55945
|
|
|
55911
55946
|
// src/server.ts
|
|
55912
55947
|
var createServer = (config) => {
|
|
55913
|
-
const server = new
|
|
55948
|
+
const server = new At(config);
|
|
55914
55949
|
return server;
|
|
55915
55950
|
};
|
|
55916
55951
|
|
|
@@ -55943,15 +55978,15 @@ var getUseModel = (req, tokenCount, config) => {
|
|
|
55943
55978
|
if (req.body.model.includes(",")) {
|
|
55944
55979
|
return req.body.model;
|
|
55945
55980
|
}
|
|
55946
|
-
if (tokenCount > 1e3 * 60) {
|
|
55981
|
+
if (tokenCount > 1e3 * 60 && config.Router.longContext) {
|
|
55947
55982
|
log("Using long context model due to token count:", tokenCount);
|
|
55948
55983
|
return config.Router.longContext;
|
|
55949
55984
|
}
|
|
55950
|
-
if (req.body.model?.startsWith("claude-3-5-haiku")) {
|
|
55985
|
+
if (req.body.model?.startsWith("claude-3-5-haiku") && config.Router.background) {
|
|
55951
55986
|
log("Using background model for ", req.body.model);
|
|
55952
55987
|
return config.Router.background;
|
|
55953
55988
|
}
|
|
55954
|
-
if (req.body.thinking) {
|
|
55989
|
+
if (req.body.thinking && config.Router.think) {
|
|
55955
55990
|
log("Using think model for ", req.body.thinking);
|
|
55956
55991
|
return config.Router.think;
|
|
55957
55992
|
}
|
|
@@ -56229,7 +56264,7 @@ async function executeCodeCommand(args = []) {
|
|
|
56229
56264
|
}
|
|
56230
56265
|
|
|
56231
56266
|
// package.json
|
|
56232
|
-
var version = "1.0.
|
|
56267
|
+
var version = "1.0.16";
|
|
56233
56268
|
|
|
56234
56269
|
// src/cli.ts
|
|
56235
56270
|
var import_child_process2 = require("child_process");
|