@gbozee/ultimate 0.0.2-next.67 → 0.0.2-next.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +125 -58
- package/dist/index.js +116 -63
- package/dist/mcp-client.cjs +61 -40
- package/dist/mcp-client.js +51 -33
- package/dist/mcp-server.cjs +140 -73
- package/dist/mcp-server.js +131 -78
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __returnValue = (v) => v;
|
|
34
|
+
function __exportSetter(name2, newValue) {
|
|
35
|
+
this[name2] = __returnValue.bind(null, newValue);
|
|
36
|
+
}
|
|
19
37
|
var __export = (target, all) => {
|
|
20
38
|
for (var name2 in all)
|
|
21
39
|
__defProp(target, name2, {
|
|
22
40
|
get: all[name2],
|
|
23
41
|
enumerable: true,
|
|
24
42
|
configurable: true,
|
|
25
|
-
set: (
|
|
43
|
+
set: __exportSetter.bind(all, name2)
|
|
26
44
|
});
|
|
27
45
|
};
|
|
28
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -198,10 +216,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
198
216
|
}
|
|
199
217
|
return output;
|
|
200
218
|
}
|
|
201
|
-
var ucs2encode = function
|
|
219
|
+
var ucs2encode = function ucs2encode2(array) {
|
|
202
220
|
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
203
221
|
};
|
|
204
|
-
var basicToDigit = function
|
|
222
|
+
var basicToDigit = function basicToDigit2(codePoint) {
|
|
205
223
|
if (codePoint - 48 < 10) {
|
|
206
224
|
return codePoint - 22;
|
|
207
225
|
}
|
|
@@ -213,10 +231,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
213
231
|
}
|
|
214
232
|
return base;
|
|
215
233
|
};
|
|
216
|
-
var digitToBasic = function
|
|
234
|
+
var digitToBasic = function digitToBasic2(digit, flag) {
|
|
217
235
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
218
236
|
};
|
|
219
|
-
var adapt = function
|
|
237
|
+
var adapt = function adapt2(delta, numPoints, firstTime) {
|
|
220
238
|
var k = 0;
|
|
221
239
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
222
240
|
delta += floor(delta / numPoints);
|
|
@@ -225,7 +243,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
225
243
|
}
|
|
226
244
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
227
245
|
};
|
|
228
|
-
var decode = function
|
|
246
|
+
var decode = function decode2(input) {
|
|
229
247
|
var output = [];
|
|
230
248
|
var inputLength = input.length;
|
|
231
249
|
var i = 0;
|
|
@@ -273,7 +291,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
273
291
|
}
|
|
274
292
|
return String.fromCodePoint.apply(String, output);
|
|
275
293
|
};
|
|
276
|
-
var encode = function
|
|
294
|
+
var encode = function encode2(input) {
|
|
277
295
|
var output = [];
|
|
278
296
|
input = ucs2decode(input);
|
|
279
297
|
var inputLength = input.length;
|
|
@@ -387,12 +405,12 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
387
405
|
}
|
|
388
406
|
return output.join("");
|
|
389
407
|
};
|
|
390
|
-
var toUnicode = function
|
|
408
|
+
var toUnicode = function toUnicode2(input) {
|
|
391
409
|
return mapDomain(input, function(string) {
|
|
392
410
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
393
411
|
});
|
|
394
412
|
};
|
|
395
|
-
var toASCII = function
|
|
413
|
+
var toASCII = function toASCII2(input) {
|
|
396
414
|
return mapDomain(input, function(string) {
|
|
397
415
|
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
398
416
|
});
|
|
@@ -789,13 +807,13 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
789
807
|
var handler = {
|
|
790
808
|
scheme: "http",
|
|
791
809
|
domainHost: true,
|
|
792
|
-
parse: function
|
|
810
|
+
parse: function parse2(components, options) {
|
|
793
811
|
if (!components.host) {
|
|
794
812
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
795
813
|
}
|
|
796
814
|
return components;
|
|
797
815
|
},
|
|
798
|
-
serialize: function
|
|
816
|
+
serialize: function serialize2(components, options) {
|
|
799
817
|
var secure = String(components.scheme).toLowerCase() === "https";
|
|
800
818
|
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
801
819
|
components.port = undefined;
|
|
@@ -818,7 +836,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
818
836
|
var handler$2 = {
|
|
819
837
|
scheme: "ws",
|
|
820
838
|
domainHost: true,
|
|
821
|
-
parse: function
|
|
839
|
+
parse: function parse2(components, options) {
|
|
822
840
|
var wsComponents = components;
|
|
823
841
|
wsComponents.secure = isSecure(wsComponents);
|
|
824
842
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -826,7 +844,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
826
844
|
wsComponents.query = undefined;
|
|
827
845
|
return wsComponents;
|
|
828
846
|
},
|
|
829
|
-
serialize: function
|
|
847
|
+
serialize: function serialize2(wsComponents, options) {
|
|
830
848
|
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
831
849
|
wsComponents.port = undefined;
|
|
832
850
|
}
|
|
@@ -994,7 +1012,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
994
1012
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
995
1013
|
var handler$6 = {
|
|
996
1014
|
scheme: "urn:uuid",
|
|
997
|
-
parse: function
|
|
1015
|
+
parse: function parse2(urnComponents, options) {
|
|
998
1016
|
var uuidComponents = urnComponents;
|
|
999
1017
|
uuidComponents.uuid = uuidComponents.nss;
|
|
1000
1018
|
uuidComponents.nss = undefined;
|
|
@@ -1003,7 +1021,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
1003
1021
|
}
|
|
1004
1022
|
return uuidComponents;
|
|
1005
1023
|
},
|
|
1006
|
-
serialize: function
|
|
1024
|
+
serialize: function serialize2(uuidComponents, options) {
|
|
1007
1025
|
var urnComponents = uuidComponents;
|
|
1008
1026
|
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
1009
1027
|
return urnComponents;
|
|
@@ -2449,7 +2467,7 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
2449
2467
|
|
|
2450
2468
|
// node_modules/ajv/lib/cache.js
|
|
2451
2469
|
var require_cache = __commonJS((exports, module) => {
|
|
2452
|
-
var Cache = module.exports = function
|
|
2470
|
+
var Cache = module.exports = function Cache2() {
|
|
2453
2471
|
this._cache = {};
|
|
2454
2472
|
};
|
|
2455
2473
|
Cache.prototype.put = function Cache_put(key, value) {
|
|
@@ -29653,17 +29671,6 @@ var require_db = __commonJS((exports, module) => {
|
|
|
29653
29671
|
};
|
|
29654
29672
|
});
|
|
29655
29673
|
|
|
29656
|
-
// node_modules/form-data/node_modules/mime-types/node_modules/mime-db/index.js
|
|
29657
|
-
var require_mime_db = __commonJS((exports, module) => {
|
|
29658
|
-
/*!
|
|
29659
|
-
* mime-db
|
|
29660
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
29661
|
-
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
|
29662
|
-
* MIT Licensed
|
|
29663
|
-
*/
|
|
29664
|
-
module.exports = require_db();
|
|
29665
|
-
});
|
|
29666
|
-
|
|
29667
29674
|
// node_modules/form-data/node_modules/mime-types/index.js
|
|
29668
29675
|
var require_mime_types = __commonJS((exports) => {
|
|
29669
29676
|
/*!
|
|
@@ -29672,7 +29679,7 @@ var require_mime_types = __commonJS((exports) => {
|
|
|
29672
29679
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
29673
29680
|
* MIT Licensed
|
|
29674
29681
|
*/
|
|
29675
|
-
var db =
|
|
29682
|
+
var db = require_db();
|
|
29676
29683
|
var extname = __require("path").extname;
|
|
29677
29684
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
29678
29685
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
@@ -30019,7 +30026,7 @@ var require_round = __commonJS((exports, module) => {
|
|
|
30019
30026
|
|
|
30020
30027
|
// node_modules/math-intrinsics/isNaN.js
|
|
30021
30028
|
var require_isNaN = __commonJS((exports, module) => {
|
|
30022
|
-
module.exports = Number.isNaN || function
|
|
30029
|
+
module.exports = Number.isNaN || function isNaN2(a) {
|
|
30023
30030
|
return a !== a;
|
|
30024
30031
|
};
|
|
30025
30032
|
});
|
|
@@ -30027,7 +30034,7 @@ var require_isNaN = __commonJS((exports, module) => {
|
|
|
30027
30034
|
// node_modules/math-intrinsics/sign.js
|
|
30028
30035
|
var require_sign = __commonJS((exports, module) => {
|
|
30029
30036
|
var $isNaN = require_isNaN();
|
|
30030
|
-
module.exports = function
|
|
30037
|
+
module.exports = function sign3(number2) {
|
|
30031
30038
|
if ($isNaN(number2) || number2 === 0) {
|
|
30032
30039
|
return number2;
|
|
30033
30040
|
}
|
|
@@ -30153,7 +30160,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
30153
30160
|
var toStr = Object.prototype.toString;
|
|
30154
30161
|
var max = Math.max;
|
|
30155
30162
|
var funcType = "[object Function]";
|
|
30156
|
-
var concatty = function
|
|
30163
|
+
var concatty = function concatty2(a, b) {
|
|
30157
30164
|
var arr = [];
|
|
30158
30165
|
for (var i2 = 0;i2 < a.length; i2 += 1) {
|
|
30159
30166
|
arr[i2] = a[i2];
|
|
@@ -30163,7 +30170,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
30163
30170
|
}
|
|
30164
30171
|
return arr;
|
|
30165
30172
|
};
|
|
30166
|
-
var slicy = function
|
|
30173
|
+
var slicy = function slicy2(arrLike, offset) {
|
|
30167
30174
|
var arr = [];
|
|
30168
30175
|
for (var i2 = offset || 0, j = 0;i2 < arrLike.length; i2 += 1, j += 1) {
|
|
30169
30176
|
arr[j] = arrLike[i2];
|
|
@@ -30204,7 +30211,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
30204
30211
|
}
|
|
30205
30212
|
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
30206
30213
|
if (target.prototype) {
|
|
30207
|
-
var Empty = function
|
|
30214
|
+
var Empty = function Empty2() {};
|
|
30208
30215
|
Empty.prototype = target.prototype;
|
|
30209
30216
|
bound.prototype = new Empty;
|
|
30210
30217
|
Empty.prototype = null;
|
|
@@ -30443,7 +30450,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
30443
30450
|
}
|
|
30444
30451
|
}
|
|
30445
30452
|
var errorProto;
|
|
30446
|
-
var doEval = function
|
|
30453
|
+
var doEval = function doEval2(name2) {
|
|
30447
30454
|
var value;
|
|
30448
30455
|
if (name2 === "%AsyncFunction%") {
|
|
30449
30456
|
value = getEvalledConstructor("async function () {}");
|
|
@@ -30452,12 +30459,12 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
30452
30459
|
} else if (name2 === "%AsyncGeneratorFunction%") {
|
|
30453
30460
|
value = getEvalledConstructor("async function* () {}");
|
|
30454
30461
|
} else if (name2 === "%AsyncGenerator%") {
|
|
30455
|
-
var fn =
|
|
30462
|
+
var fn = doEval2("%AsyncGeneratorFunction%");
|
|
30456
30463
|
if (fn) {
|
|
30457
30464
|
value = fn.prototype;
|
|
30458
30465
|
}
|
|
30459
30466
|
} else if (name2 === "%AsyncIteratorPrototype%") {
|
|
30460
|
-
var gen =
|
|
30467
|
+
var gen = doEval2("%AsyncGenerator%");
|
|
30461
30468
|
if (gen && getProto) {
|
|
30462
30469
|
value = getProto(gen.prototype);
|
|
30463
30470
|
}
|
|
@@ -30528,7 +30535,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
30528
30535
|
var $exec = bind.call($call, RegExp.prototype.exec);
|
|
30529
30536
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
30530
30537
|
var reEscapeChar = /\\(\\)?/g;
|
|
30531
|
-
var stringToPath = function
|
|
30538
|
+
var stringToPath = function stringToPath2(string2) {
|
|
30532
30539
|
var first = $strSlice(string2, 0, 1);
|
|
30533
30540
|
var last = $strSlice(string2, -1);
|
|
30534
30541
|
if (first === "%" && last !== "%") {
|
|
@@ -30542,7 +30549,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
30542
30549
|
});
|
|
30543
30550
|
return result;
|
|
30544
30551
|
};
|
|
30545
|
-
var getBaseIntrinsic = function
|
|
30552
|
+
var getBaseIntrinsic = function getBaseIntrinsic2(name2, allowMissing) {
|
|
30546
30553
|
var intrinsicName = name2;
|
|
30547
30554
|
var alias;
|
|
30548
30555
|
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
@@ -31570,7 +31577,7 @@ var require_axios = __commonJS((exports, module) => {
|
|
|
31570
31577
|
var zlib__default = /* @__PURE__ */ _interopDefaultLegacy(zlib);
|
|
31571
31578
|
var stream__default = /* @__PURE__ */ _interopDefaultLegacy(stream2);
|
|
31572
31579
|
function bind(fn, thisArg) {
|
|
31573
|
-
return function
|
|
31580
|
+
return function wrap3() {
|
|
31574
31581
|
return fn.apply(thisArg, arguments);
|
|
31575
31582
|
};
|
|
31576
31583
|
}
|
|
@@ -32152,7 +32159,7 @@ var require_axios = __commonJS((exports, module) => {
|
|
|
32152
32159
|
prototype.append = function append(name2, value) {
|
|
32153
32160
|
this._pairs.push([name2, value]);
|
|
32154
32161
|
};
|
|
32155
|
-
prototype.toString = function
|
|
32162
|
+
prototype.toString = function toString2(encoder2) {
|
|
32156
32163
|
const _encode = encoder2 ? function(value) {
|
|
32157
32164
|
return encoder2.call(this, value, encode$1);
|
|
32158
32165
|
} : encode$1;
|
|
@@ -33365,7 +33372,7 @@ var require_axios = __commonJS((exports, module) => {
|
|
|
33365
33372
|
return req;
|
|
33366
33373
|
}
|
|
33367
33374
|
};
|
|
33368
|
-
var httpAdapter = isHttpAdapterSupported && function
|
|
33375
|
+
var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config2) {
|
|
33369
33376
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
|
33370
33377
|
let { data, lookup, family, httpVersion = 1, http2Options } = config2;
|
|
33371
33378
|
const { responseType, responseEncoding } = config2;
|
|
@@ -34421,7 +34428,7 @@ var require_axios = __commonJS((exports, module) => {
|
|
|
34421
34428
|
}
|
|
34422
34429
|
var validators$1 = {};
|
|
34423
34430
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i2) => {
|
|
34424
|
-
validators$1[type] = function
|
|
34431
|
+
validators$1[type] = function validator2(thing) {
|
|
34425
34432
|
return typeof thing === type || "a" + (i2 < 1 ? "n " : " ") + type;
|
|
34426
34433
|
};
|
|
34427
34434
|
});
|
|
@@ -34717,7 +34724,7 @@ var require_axios = __commonJS((exports, module) => {
|
|
|
34717
34724
|
}
|
|
34718
34725
|
var CancelToken$1 = CancelToken;
|
|
34719
34726
|
function spread(callback) {
|
|
34720
|
-
return function
|
|
34727
|
+
return function wrap3(arr) {
|
|
34721
34728
|
return callback.apply(null, arr);
|
|
34722
34729
|
};
|
|
34723
34730
|
}
|
|
@@ -38300,7 +38307,7 @@ var require_stream = __commonJS((exports, module) => {
|
|
|
38300
38307
|
objectMode: false,
|
|
38301
38308
|
writableObjectMode: false
|
|
38302
38309
|
});
|
|
38303
|
-
ws.on("message", function
|
|
38310
|
+
ws.on("message", function message2(msg, isBinary) {
|
|
38304
38311
|
const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
38305
38312
|
if (!duplex.push(data))
|
|
38306
38313
|
ws.pause();
|
|
@@ -46994,7 +47001,7 @@ var require_axios2 = __commonJS((exports, module) => {
|
|
|
46994
47001
|
var zlib__default = /* @__PURE__ */ _interopDefaultLegacy(zlib);
|
|
46995
47002
|
var stream__default = /* @__PURE__ */ _interopDefaultLegacy(stream2);
|
|
46996
47003
|
function bind(fn, thisArg) {
|
|
46997
|
-
return function
|
|
47004
|
+
return function wrap3() {
|
|
46998
47005
|
return fn.apply(thisArg, arguments);
|
|
46999
47006
|
};
|
|
47000
47007
|
}
|
|
@@ -47572,7 +47579,7 @@ var require_axios2 = __commonJS((exports, module) => {
|
|
|
47572
47579
|
prototype.append = function append(name2, value2) {
|
|
47573
47580
|
this._pairs.push([name2, value2]);
|
|
47574
47581
|
};
|
|
47575
|
-
prototype.toString = function
|
|
47582
|
+
prototype.toString = function toString2(encoder2) {
|
|
47576
47583
|
const _encode = encoder2 ? function(value2) {
|
|
47577
47584
|
return encoder2.call(this, value2, encode$1);
|
|
47578
47585
|
} : encode$1;
|
|
@@ -48632,7 +48639,7 @@ var require_axios2 = __commonJS((exports, module) => {
|
|
|
48632
48639
|
};
|
|
48633
48640
|
};
|
|
48634
48641
|
var buildAddressEntry = (address, family) => resolveFamily(utils$1.isObject(address) ? address : { address, family });
|
|
48635
|
-
var httpAdapter = isHttpAdapterSupported && function
|
|
48642
|
+
var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config2) {
|
|
48636
48643
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
|
48637
48644
|
let { data, lookup, family } = config2;
|
|
48638
48645
|
const { responseType, responseEncoding } = config2;
|
|
@@ -49583,7 +49590,7 @@ var require_axios2 = __commonJS((exports, module) => {
|
|
|
49583
49590
|
}
|
|
49584
49591
|
var validators$1 = {};
|
|
49585
49592
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i2) => {
|
|
49586
|
-
validators$1[type] = function
|
|
49593
|
+
validators$1[type] = function validator2(thing) {
|
|
49587
49594
|
return typeof thing === type || "a" + (i2 < 1 ? "n " : " ") + type;
|
|
49588
49595
|
};
|
|
49589
49596
|
});
|
|
@@ -49880,7 +49887,7 @@ var require_axios2 = __commonJS((exports, module) => {
|
|
|
49880
49887
|
}
|
|
49881
49888
|
var CancelToken$1 = CancelToken;
|
|
49882
49889
|
function spread(callback) {
|
|
49883
|
-
return function
|
|
49890
|
+
return function wrap3(arr) {
|
|
49884
49891
|
return callback.apply(null, arr);
|
|
49885
49892
|
};
|
|
49886
49893
|
}
|
|
@@ -69122,7 +69129,7 @@ function cookieSerialize(t, s, i) {
|
|
|
69122
69129
|
a += "; Path=" + n.path;
|
|
69123
69130
|
}
|
|
69124
69131
|
if (n.expires) {
|
|
69125
|
-
if (!function
|
|
69132
|
+
if (!function isDate2(e2) {
|
|
69126
69133
|
return Object.prototype.toString.call(e2) === "[object Date]" || e2 instanceof Date;
|
|
69127
69134
|
}(n.expires) || isNaN(n.expires.valueOf()))
|
|
69128
69135
|
throw new TypeError("option expires is invalid");
|
|
@@ -75402,6 +75409,7 @@ function transformTradesToExchangeType({
|
|
|
75402
75409
|
trades,
|
|
75403
75410
|
take_profit,
|
|
75404
75411
|
stop_loss,
|
|
75412
|
+
stop_losses,
|
|
75405
75413
|
kind
|
|
75406
75414
|
}) {
|
|
75407
75415
|
const currentTime = Date.now();
|
|
@@ -75486,7 +75494,8 @@ function transformTradesToExchangeType({
|
|
|
75486
75494
|
});
|
|
75487
75495
|
nextOrderId++;
|
|
75488
75496
|
}
|
|
75489
|
-
|
|
75497
|
+
const effectiveStops = stop_losses && stop_losses.length > 0 ? stop_losses : stop_loss && stop_loss.quantity > 0 ? [stop_loss] : [];
|
|
75498
|
+
for (const sl of effectiveStops) {
|
|
75490
75499
|
const slSide = kind === "long" ? "sell" : "buy";
|
|
75491
75500
|
const slPositionSide = kind.toUpperCase();
|
|
75492
75501
|
result.push({
|
|
@@ -75502,28 +75511,29 @@ function transformTradesToExchangeType({
|
|
|
75502
75511
|
orderId: nextOrderId,
|
|
75503
75512
|
order_id: nextOrderId,
|
|
75504
75513
|
order_type: "future",
|
|
75505
|
-
origQty:
|
|
75514
|
+
origQty: sl.quantity,
|
|
75506
75515
|
origType: "LIMIT",
|
|
75507
75516
|
positionSide: slPositionSide,
|
|
75508
|
-
price:
|
|
75517
|
+
price: sl.price,
|
|
75509
75518
|
priceMatch: "NONE",
|
|
75510
75519
|
priceProtect: false,
|
|
75511
|
-
qty:
|
|
75512
|
-
quantity:
|
|
75520
|
+
qty: sl.quantity,
|
|
75521
|
+
quantity: sl.quantity,
|
|
75513
75522
|
reduceOnly: true,
|
|
75514
75523
|
selfTradePreventionMode: "EXPIRE_MAKER",
|
|
75515
75524
|
side: slSide,
|
|
75516
75525
|
status: "NEW",
|
|
75517
|
-
stop:
|
|
75518
|
-
stopPrice:
|
|
75526
|
+
stop: sl.price,
|
|
75527
|
+
stopPrice: sl.price,
|
|
75519
75528
|
symbol: undefined,
|
|
75520
75529
|
time: currentTime,
|
|
75521
75530
|
timeInForce: "GTC",
|
|
75522
|
-
triggerPrice:
|
|
75531
|
+
triggerPrice: sl.price,
|
|
75523
75532
|
type: "LIMIT",
|
|
75524
75533
|
updateTime: currentTime,
|
|
75525
75534
|
workingType: "CONTRACT_PRICE"
|
|
75526
75535
|
});
|
|
75536
|
+
nextOrderId++;
|
|
75527
75537
|
}
|
|
75528
75538
|
return result;
|
|
75529
75539
|
}
|
|
@@ -75541,7 +75551,7 @@ function transformExchangeOrderToTradeWithValidation(orders, options) {
|
|
|
75541
75551
|
} = options || {};
|
|
75542
75552
|
const trades = [];
|
|
75543
75553
|
let take_profit;
|
|
75544
|
-
|
|
75554
|
+
const stop_losses = [];
|
|
75545
75555
|
orders.forEach((order, index) => {
|
|
75546
75556
|
if (validatePrice && (typeof order.price !== "number" || order.price <= 0)) {
|
|
75547
75557
|
throw new Error(`Invalid price at index ${index}: ${order.price}. Price must be a positive number`);
|
|
@@ -75559,11 +75569,11 @@ function transformExchangeOrderToTradeWithValidation(orders, options) {
|
|
|
75559
75569
|
};
|
|
75560
75570
|
return;
|
|
75561
75571
|
}
|
|
75562
|
-
if (isStopLossOrder(order)
|
|
75563
|
-
|
|
75572
|
+
if (isStopLossOrder(order)) {
|
|
75573
|
+
stop_losses.push({
|
|
75564
75574
|
price: order.price,
|
|
75565
75575
|
quantity: order.quantity
|
|
75566
|
-
};
|
|
75576
|
+
});
|
|
75567
75577
|
return;
|
|
75568
75578
|
}
|
|
75569
75579
|
trades.push({
|
|
@@ -75572,7 +75582,7 @@ function transformExchangeOrderToTradeWithValidation(orders, options) {
|
|
|
75572
75582
|
avg_size: order.quantity,
|
|
75573
75583
|
neg_pnl: 0,
|
|
75574
75584
|
avg_entry: order.price,
|
|
75575
|
-
stop:
|
|
75585
|
+
stop: stop_losses[0]?.price || order.stop || defaultStop,
|
|
75576
75586
|
reverse_avg_entry: order.price,
|
|
75577
75587
|
reverse_avg_quantity: order.quantity,
|
|
75578
75588
|
fee: 0,
|
|
@@ -75582,7 +75592,8 @@ function transformExchangeOrderToTradeWithValidation(orders, options) {
|
|
|
75582
75592
|
return {
|
|
75583
75593
|
trades,
|
|
75584
75594
|
take_profit,
|
|
75585
|
-
stop_loss
|
|
75595
|
+
stop_loss: stop_losses[0],
|
|
75596
|
+
stop_losses
|
|
75586
75597
|
};
|
|
75587
75598
|
}
|
|
75588
75599
|
function updatePositionBasedOffTpOrSl({
|
|
@@ -75593,7 +75604,7 @@ function updatePositionBasedOffTpOrSl({
|
|
|
75593
75604
|
}) {
|
|
75594
75605
|
const position2 = positions[kind];
|
|
75595
75606
|
const side_orders = orders.filter((o) => o.positionSide.toLowerCase() === kind);
|
|
75596
|
-
const { trades, take_profit, stop_loss } = transformExchangeOrderToTradeWithValidation(side_orders, {
|
|
75607
|
+
const { trades, take_profit, stop_loss, stop_losses } = transformExchangeOrderToTradeWithValidation(side_orders, {
|
|
75597
75608
|
validatePrice: false,
|
|
75598
75609
|
validateQuantity: false,
|
|
75599
75610
|
defaultStop: 0
|
|
@@ -75619,25 +75630,41 @@ function updatePositionBasedOffTpOrSl({
|
|
|
75619
75630
|
orders: transformTradesToExchangeType({
|
|
75620
75631
|
trades,
|
|
75621
75632
|
kind,
|
|
75622
|
-
stop_loss
|
|
75633
|
+
stop_loss,
|
|
75634
|
+
stop_losses
|
|
75623
75635
|
}),
|
|
75624
75636
|
changed: "tp"
|
|
75625
75637
|
};
|
|
75626
75638
|
}
|
|
75627
75639
|
}
|
|
75628
|
-
|
|
75629
|
-
|
|
75630
|
-
|
|
75631
|
-
|
|
75640
|
+
const all_stops = stop_losses && stop_losses.length > 0 ? stop_losses : stop_loss && stop_loss.quantity ? [stop_loss] : [];
|
|
75641
|
+
if (all_stops.length > 0) {
|
|
75642
|
+
const sorted_stops = [...all_stops].sort((a, b) => kind === "long" ? b.price - a.price : a.price - b.price);
|
|
75643
|
+
const triggered = [];
|
|
75644
|
+
const remaining = [];
|
|
75645
|
+
for (const sl of sorted_stops) {
|
|
75646
|
+
const should_close = kind === "long" ? current_price <= sl.price : current_price >= sl.price;
|
|
75647
|
+
if (should_close) {
|
|
75648
|
+
triggered.push(sl);
|
|
75649
|
+
} else {
|
|
75650
|
+
remaining.push(sl);
|
|
75651
|
+
}
|
|
75652
|
+
}
|
|
75653
|
+
if (triggered.length > 0) {
|
|
75654
|
+
const totalStopQty = triggered.reduce((sum, sl) => sum + sl.quantity, 0);
|
|
75655
|
+
position2.quantity = Math.max(0, position2.quantity - totalStopQty);
|
|
75632
75656
|
if (position2.quantity === 0) {
|
|
75633
75657
|
position2.entry = 0;
|
|
75634
75658
|
}
|
|
75659
|
+
const furthestTriggered = kind === "long" ? Math.min(...triggered.map((sl) => sl.price)) : Math.max(...triggered.map((sl) => sl.price));
|
|
75660
|
+
const remainingTrades = trades.filter((t2) => kind === "long" ? t2.entry < furthestTriggered : t2.entry > furthestTriggered);
|
|
75635
75661
|
return {
|
|
75636
75662
|
position: position2,
|
|
75637
75663
|
orders: transformTradesToExchangeType({
|
|
75638
|
-
trades:
|
|
75664
|
+
trades: remainingTrades,
|
|
75639
75665
|
kind,
|
|
75640
|
-
take_profit
|
|
75666
|
+
take_profit,
|
|
75667
|
+
stop_losses: remaining.length > 0 ? remaining : undefined
|
|
75641
75668
|
}),
|
|
75642
75669
|
changed: "sl",
|
|
75643
75670
|
trades
|
|
@@ -80454,11 +80481,13 @@ async function updateDbDetails(client, payload, current_account_info, new_payloa
|
|
|
80454
80481
|
price: position2.stop_loss,
|
|
80455
80482
|
quantity: position2.stop_quantity
|
|
80456
80483
|
} : undefined);
|
|
80484
|
+
const stop_losses = new_payload.stop_losses;
|
|
80457
80485
|
const as_exchange_orders = new_payload.raw ? new_payload.orders : transformTradesToExchangeType({
|
|
80458
80486
|
trades: new_payload.orders,
|
|
80459
80487
|
kind: payload.kind,
|
|
80460
80488
|
take_profit,
|
|
80461
|
-
stop_loss
|
|
80489
|
+
stop_loss,
|
|
80490
|
+
stop_losses
|
|
80462
80491
|
});
|
|
80463
80492
|
const reverse_kind = payload.kind === "long" ? "short" : "long";
|
|
80464
80493
|
const reverse_orders = current_account_info.config.trades.exchange_info.open_orders.filter((o) => {
|
|
@@ -80555,6 +80584,19 @@ async function fetchDBExchangeData(client, symbol, options) {
|
|
|
80555
80584
|
short: short_result.trades
|
|
80556
80585
|
};
|
|
80557
80586
|
}
|
|
80587
|
+
const stop_losses_by_kind = {
|
|
80588
|
+
long: [],
|
|
80589
|
+
short: []
|
|
80590
|
+
};
|
|
80591
|
+
for (const o of orders) {
|
|
80592
|
+
const k = o.positionSide?.toLowerCase();
|
|
80593
|
+
if (k && (o.isStop || o.stopPrice > 0)) {
|
|
80594
|
+
stop_losses_by_kind[k].push({
|
|
80595
|
+
price: o.stopPrice || o.stop || o.price,
|
|
80596
|
+
quantity: o.origQty || o.quantity
|
|
80597
|
+
});
|
|
80598
|
+
}
|
|
80599
|
+
}
|
|
80558
80600
|
return {
|
|
80559
80601
|
orders,
|
|
80560
80602
|
symbol_config,
|
|
@@ -80564,11 +80606,12 @@ async function fetchDBExchangeData(client, symbol, options) {
|
|
|
80564
80606
|
trades,
|
|
80565
80607
|
drift,
|
|
80566
80608
|
priceChanged,
|
|
80609
|
+
stop_losses_by_kind,
|
|
80567
80610
|
raw_data: live_exchange_details?.data
|
|
80568
80611
|
};
|
|
80569
80612
|
}
|
|
80570
80613
|
async function reconcileEngineState(client, symbol, options) {
|
|
80571
|
-
const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged } = await fetchDBExchangeData(client, symbol, options);
|
|
80614
|
+
const { positions, symbol_config, current_price, raw_data, trades, drift, priceChanged, stop_losses_by_kind } = await fetchDBExchangeData(client, symbol, options);
|
|
80572
80615
|
const long_generator = new TradeEngine({
|
|
80573
80616
|
position: {
|
|
80574
80617
|
kind: "long",
|
|
@@ -80613,7 +80656,13 @@ async function reconcileEngineState(client, symbol, options) {
|
|
|
80613
80656
|
state.position.quantity = 0;
|
|
80614
80657
|
tp = { price: 0, quantity: 0 };
|
|
80615
80658
|
}
|
|
80616
|
-
|
|
80659
|
+
const kind_stops = stop_losses_by_kind[kind];
|
|
80660
|
+
await updateDbDetails(client, { kind, symbol }, raw_data, {
|
|
80661
|
+
take_profit: tp,
|
|
80662
|
+
position: _position,
|
|
80663
|
+
orders: state_trades,
|
|
80664
|
+
stop_losses: kind_stops.length > 0 ? kind_stops : undefined
|
|
80665
|
+
});
|
|
80617
80666
|
changed = true;
|
|
80618
80667
|
}
|
|
80619
80668
|
}
|
|
@@ -80781,10 +80830,14 @@ async function placeStopOrder3(client, payload) {
|
|
|
80781
80830
|
price: order.stop,
|
|
80782
80831
|
quantity: order.quantity
|
|
80783
80832
|
};
|
|
80784
|
-
const { trades } = transformExchangeOrderToTradeWithValidation(sameKindOrders, {
|
|
80833
|
+
const { trades, stop_losses: existingStops } = transformExchangeOrderToTradeWithValidation(sameKindOrders, {
|
|
80785
80834
|
validateQuantity: false,
|
|
80786
80835
|
validatePrice: false
|
|
80787
80836
|
});
|
|
80837
|
+
const all_stop_losses = [
|
|
80838
|
+
...existingStops || [],
|
|
80839
|
+
stop_loss
|
|
80840
|
+
];
|
|
80788
80841
|
return savePaperDetails(client, {
|
|
80789
80842
|
kind: order.kind,
|
|
80790
80843
|
symbol: payload.symbol,
|
|
@@ -80793,7 +80846,7 @@ async function placeStopOrder3(client, payload) {
|
|
|
80793
80846
|
}, {
|
|
80794
80847
|
position: {},
|
|
80795
80848
|
orders: trades,
|
|
80796
|
-
|
|
80849
|
+
stop_losses: all_stop_losses
|
|
80797
80850
|
});
|
|
80798
80851
|
}
|
|
80799
80852
|
async function placeTpOrder3(client, payload) {
|