@musistudio/claude-code-router 1.0.68 → 1.0.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/cli.js +928 -922
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -67756,7 +67756,7 @@ var require_package3 = __commonJS({
|
|
|
67756
67756
|
"package.json"(exports2, module2) {
|
|
67757
67757
|
module2.exports = {
|
|
67758
67758
|
name: "@musistudio/claude-code-router",
|
|
67759
|
-
version: "1.0.
|
|
67759
|
+
version: "1.0.69",
|
|
67760
67760
|
description: "Use Claude Code without an Anthropics account and route it to another LLM provider",
|
|
67761
67761
|
bin: {
|
|
67762
67762
|
ccr: "dist/cli.js"
|
|
@@ -67776,7 +67776,7 @@ var require_package3 = __commonJS({
|
|
|
67776
67776
|
license: "MIT",
|
|
67777
67777
|
dependencies: {
|
|
67778
67778
|
"@fastify/static": "^8.2.0",
|
|
67779
|
-
"@musistudio/llms": "^1.0.
|
|
67779
|
+
"@musistudio/llms": "^1.0.43",
|
|
67780
67780
|
"@inquirer/prompts": "^5.0.0",
|
|
67781
67781
|
dotenv: "^16.4.7",
|
|
67782
67782
|
"find-process": "^2.0.0",
|
|
@@ -70931,7 +70931,7 @@ var import_os2 = require("os");
|
|
|
70931
70931
|
var import_path5 = require("path");
|
|
70932
70932
|
init_utils();
|
|
70933
70933
|
|
|
70934
|
-
// node_modules/.pnpm/@musistudio+llms@1.0.
|
|
70934
|
+
// node_modules/.pnpm/@musistudio+llms@1.0.43_ws@8.18.3/node_modules/@musistudio/llms/dist/esm/server.mjs
|
|
70935
70935
|
var import_node_fs = require("node:fs");
|
|
70936
70936
|
var import_node_path4 = require("node:path");
|
|
70937
70937
|
var import_node_stream = __toESM(require("node:stream"), 1);
|
|
@@ -71568,19 +71568,19 @@ var Nf = z((dA, If) => {
|
|
|
71568
71568
|
var jf = z((hA, qf) => {
|
|
71569
71569
|
var Wa = La();
|
|
71570
71570
|
qf.exports = function(e, t, n) {
|
|
71571
|
-
let o = [], i = "", u, l,
|
|
71572
|
-
if (t != null && typeof t == "object" && !Array.isArray(t) && (n = t.space,
|
|
71571
|
+
let o = [], i = "", u, l, d = "", h;
|
|
71572
|
+
if (t != null && typeof t == "object" && !Array.isArray(t) && (n = t.space, h = t.quote, t = t.replacer), typeof t == "function") l = t;
|
|
71573
71573
|
else if (Array.isArray(t)) {
|
|
71574
71574
|
u = [];
|
|
71575
|
-
for (let
|
|
71575
|
+
for (let E of t) {
|
|
71576
71576
|
let p;
|
|
71577
|
-
typeof
|
|
71577
|
+
typeof E == "string" ? p = E : (typeof E == "number" || E instanceof String || E instanceof Number) && (p = String(E)), p !== void 0 && u.indexOf(p) < 0 && u.push(p);
|
|
71578
71578
|
}
|
|
71579
71579
|
}
|
|
71580
|
-
return n instanceof Number ? n = Number(n) : n instanceof String && (n = String(n)), typeof n == "number" ? n > 0 && (n = Math.min(10, Math.floor(n)),
|
|
71581
|
-
function
|
|
71582
|
-
let y = p[
|
|
71583
|
-
switch (y != null && (typeof y.toJSON5 == "function" ? y = y.toJSON5(
|
|
71580
|
+
return n instanceof Number ? n = Number(n) : n instanceof String && (n = String(n)), typeof n == "number" ? n > 0 && (n = Math.min(10, Math.floor(n)), d = " ".substr(0, n)) : typeof n == "string" && (d = n.substr(0, 10)), f("", { "": e });
|
|
71581
|
+
function f(E, p) {
|
|
71582
|
+
let y = p[E];
|
|
71583
|
+
switch (y != null && (typeof y.toJSON5 == "function" ? y = y.toJSON5(E) : typeof y.toJSON == "function" && (y = y.toJSON(E))), l && (y = l.call(p, E, y)), y instanceof Number ? y = Number(y) : y instanceof String ? y = String(y) : y instanceof Boolean && (y = y.valueOf()), y) {
|
|
71584
71584
|
case null:
|
|
71585
71585
|
return "null";
|
|
71586
71586
|
case true:
|
|
@@ -71592,17 +71592,17 @@ var jf = z((hA, qf) => {
|
|
|
71592
71592
|
if (typeof y == "number") return String(y);
|
|
71593
71593
|
if (typeof y == "object") return Array.isArray(y) ? b(y) : A(y);
|
|
71594
71594
|
}
|
|
71595
|
-
function g(
|
|
71595
|
+
function g(E) {
|
|
71596
71596
|
let p = { "'": 0.1, '"': 0.2 }, y = { "'": "\\'", '"': '\\"', "\\": "\\\\", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", " ": "\\t", "\v": "\\v", "\0": "\\0", "\u2028": "\\u2028", "\u2029": "\\u2029" }, T = "";
|
|
71597
|
-
for (let S = 0; S <
|
|
71598
|
-
let F =
|
|
71597
|
+
for (let S = 0; S < E.length; S++) {
|
|
71598
|
+
let F = E[S];
|
|
71599
71599
|
switch (F) {
|
|
71600
71600
|
case "'":
|
|
71601
71601
|
case '"':
|
|
71602
71602
|
p[F]++, T += F;
|
|
71603
71603
|
continue;
|
|
71604
71604
|
case "\0":
|
|
71605
|
-
if (Wa.isDigit(
|
|
71605
|
+
if (Wa.isDigit(E[S + 1])) {
|
|
71606
71606
|
T += "\\x00";
|
|
71607
71607
|
continue;
|
|
71608
71608
|
}
|
|
@@ -71618,60 +71618,60 @@ var jf = z((hA, qf) => {
|
|
|
71618
71618
|
}
|
|
71619
71619
|
T += F;
|
|
71620
71620
|
}
|
|
71621
|
-
let
|
|
71622
|
-
return T = T.replace(new RegExp(
|
|
71621
|
+
let w = h || Object.keys(p).reduce((S, F) => p[S] < p[F] ? S : F);
|
|
71622
|
+
return T = T.replace(new RegExp(w, "g"), y[w]), w + T + w;
|
|
71623
71623
|
}
|
|
71624
|
-
function A(
|
|
71625
|
-
if (o.indexOf(
|
|
71626
|
-
o.push(
|
|
71624
|
+
function A(E) {
|
|
71625
|
+
if (o.indexOf(E) >= 0) throw TypeError("Converting circular structure to JSON5");
|
|
71626
|
+
o.push(E);
|
|
71627
71627
|
let p = i;
|
|
71628
|
-
i = i +
|
|
71629
|
-
let y = u || Object.keys(
|
|
71628
|
+
i = i + d;
|
|
71629
|
+
let y = u || Object.keys(E), T = [];
|
|
71630
71630
|
for (let S of y) {
|
|
71631
|
-
let F =
|
|
71631
|
+
let F = f(S, E);
|
|
71632
71632
|
if (F !== void 0) {
|
|
71633
71633
|
let B = P(S) + ":";
|
|
71634
|
-
|
|
71634
|
+
d !== "" && (B += " "), B += F, T.push(B);
|
|
71635
71635
|
}
|
|
71636
71636
|
}
|
|
71637
|
-
let
|
|
71638
|
-
if (T.length === 0)
|
|
71637
|
+
let w;
|
|
71638
|
+
if (T.length === 0) w = "{}";
|
|
71639
71639
|
else {
|
|
71640
71640
|
let S;
|
|
71641
|
-
if (
|
|
71641
|
+
if (d === "") S = T.join(","), w = "{" + S + "}";
|
|
71642
71642
|
else {
|
|
71643
71643
|
let F = `,
|
|
71644
71644
|
` + i;
|
|
71645
|
-
S = T.join(F),
|
|
71645
|
+
S = T.join(F), w = `{
|
|
71646
71646
|
` + i + S + `,
|
|
71647
71647
|
` + p + "}";
|
|
71648
71648
|
}
|
|
71649
71649
|
}
|
|
71650
|
-
return o.pop(), i = p,
|
|
71650
|
+
return o.pop(), i = p, w;
|
|
71651
71651
|
}
|
|
71652
|
-
function P(
|
|
71653
|
-
if (
|
|
71654
|
-
let p = String.fromCodePoint(
|
|
71655
|
-
if (!Wa.isIdStartChar(p)) return g(
|
|
71656
|
-
for (let y = p.length; y <
|
|
71657
|
-
return
|
|
71652
|
+
function P(E) {
|
|
71653
|
+
if (E.length === 0) return g(E, true);
|
|
71654
|
+
let p = String.fromCodePoint(E.codePointAt(0));
|
|
71655
|
+
if (!Wa.isIdStartChar(p)) return g(E, true);
|
|
71656
|
+
for (let y = p.length; y < E.length; y++) if (!Wa.isIdContinueChar(String.fromCodePoint(E.codePointAt(y)))) return g(E, true);
|
|
71657
|
+
return E;
|
|
71658
71658
|
}
|
|
71659
|
-
function b(
|
|
71660
|
-
if (o.indexOf(
|
|
71661
|
-
o.push(
|
|
71659
|
+
function b(E) {
|
|
71660
|
+
if (o.indexOf(E) >= 0) throw TypeError("Converting circular structure to JSON5");
|
|
71661
|
+
o.push(E);
|
|
71662
71662
|
let p = i;
|
|
71663
|
-
i = i +
|
|
71663
|
+
i = i + d;
|
|
71664
71664
|
let y = [];
|
|
71665
|
-
for (let
|
|
71666
|
-
let S =
|
|
71665
|
+
for (let w = 0; w < E.length; w++) {
|
|
71666
|
+
let S = f(String(w), E);
|
|
71667
71667
|
y.push(S !== void 0 ? S : "null");
|
|
71668
71668
|
}
|
|
71669
71669
|
let T;
|
|
71670
71670
|
if (y.length === 0) T = "[]";
|
|
71671
|
-
else if (
|
|
71671
|
+
else if (d === "") T = "[" + y.join(",") + "]";
|
|
71672
71672
|
else {
|
|
71673
|
-
let
|
|
71674
|
-
` + i, S = y.join(
|
|
71673
|
+
let w = `,
|
|
71674
|
+
` + i, S = y.join(w);
|
|
71675
71675
|
T = `[
|
|
71676
71676
|
` + i + S + `,
|
|
71677
71677
|
` + p + "]";
|
|
@@ -71704,8 +71704,8 @@ var Ka = z((YA, nd) => {
|
|
|
71704
71704
|
return e[t];
|
|
71705
71705
|
};
|
|
71706
71706
|
nd.exports = function r() {
|
|
71707
|
-
var e, t, n, o, i, u, l = arguments[0],
|
|
71708
|
-
for (typeof l == "boolean" && (
|
|
71707
|
+
var e, t, n, o, i, u, l = arguments[0], d = 1, h = arguments.length, f = false;
|
|
71708
|
+
for (typeof l == "boolean" && (f = l, l = arguments[1] || {}, d = 2), (l == null || typeof l != "object" && typeof l != "function") && (l = {}); d < h; ++d) if (e = arguments[d], e != null) for (t in e) n = td(l, t), o = td(e, t), l !== o && (f && o && (Zf(o) || (i = Qf(o))) ? (i ? (i = false, u = n && Qf(n) ? n : []) : u = n && Zf(n) ? n : {}, ed(l, { name: t, newValue: r(f, u, o) })) : typeof o < "u" && ed(l, { name: t, newValue: o }));
|
|
71709
71709
|
return l;
|
|
71710
71710
|
};
|
|
71711
71711
|
});
|
|
@@ -71925,21 +71925,21 @@ var hd = z((rD, dd) => {
|
|
|
71925
71925
|
});
|
|
71926
71926
|
var ru = z((nD, pd) => {
|
|
71927
71927
|
function I0(r) {
|
|
71928
|
-
t.debug = t, t.default = t, t.coerce =
|
|
71929
|
-
t[
|
|
71928
|
+
t.debug = t, t.default = t, t.coerce = d, t.disable = u, t.enable = o, t.enabled = l, t.humanize = hd(), t.destroy = h, Object.keys(r).forEach((f) => {
|
|
71929
|
+
t[f] = r[f];
|
|
71930
71930
|
}), t.names = [], t.skips = [], t.formatters = {};
|
|
71931
|
-
function e(
|
|
71931
|
+
function e(f) {
|
|
71932
71932
|
let g = 0;
|
|
71933
|
-
for (let A = 0; A <
|
|
71933
|
+
for (let A = 0; A < f.length; A++) g = (g << 5) - g + f.charCodeAt(A), g |= 0;
|
|
71934
71934
|
return t.colors[Math.abs(g) % t.colors.length];
|
|
71935
71935
|
}
|
|
71936
71936
|
t.selectColor = e;
|
|
71937
|
-
function t(
|
|
71937
|
+
function t(f) {
|
|
71938
71938
|
let g, A = null, P, b;
|
|
71939
|
-
function
|
|
71940
|
-
if (!
|
|
71941
|
-
let y =
|
|
71942
|
-
y.diff =
|
|
71939
|
+
function E(...p) {
|
|
71940
|
+
if (!E.enabled) return;
|
|
71941
|
+
let y = E, T = Number(/* @__PURE__ */ new Date()), w = T - (g || T);
|
|
71942
|
+
y.diff = w, y.prev = g, y.curr = T, g = T, p[0] = t.coerce(p[0]), typeof p[0] != "string" && p.unshift("%O");
|
|
71943
71943
|
let S = 0;
|
|
71944
71944
|
p[0] = p[0].replace(/%([a-zA-Z%])/g, (B, G) => {
|
|
71945
71945
|
if (B === "%%") return "%";
|
|
@@ -71952,40 +71952,40 @@ var ru = z((nD, pd) => {
|
|
|
71952
71952
|
return B;
|
|
71953
71953
|
}), t.formatArgs.call(y, p), (y.log || t.log).apply(y, p);
|
|
71954
71954
|
}
|
|
71955
|
-
return
|
|
71955
|
+
return E.namespace = f, E.useColors = t.useColors(), E.color = t.selectColor(f), E.extend = n, E.destroy = t.destroy, Object.defineProperty(E, "enabled", { enumerable: true, configurable: false, get: () => A !== null ? A : (P !== t.namespaces && (P = t.namespaces, b = t.enabled(f)), b), set: (p) => {
|
|
71956
71956
|
A = p;
|
|
71957
|
-
} }), typeof t.init == "function" && t.init(
|
|
71957
|
+
} }), typeof t.init == "function" && t.init(E), E;
|
|
71958
71958
|
}
|
|
71959
|
-
function n(
|
|
71960
|
-
let A = t(this.namespace + (typeof g > "u" ? ":" : g) +
|
|
71959
|
+
function n(f, g) {
|
|
71960
|
+
let A = t(this.namespace + (typeof g > "u" ? ":" : g) + f);
|
|
71961
71961
|
return A.log = this.log, A;
|
|
71962
71962
|
}
|
|
71963
|
-
function o(
|
|
71964
|
-
t.save(
|
|
71965
|
-
let g = (typeof
|
|
71963
|
+
function o(f) {
|
|
71964
|
+
t.save(f), t.namespaces = f, t.names = [], t.skips = [];
|
|
71965
|
+
let g = (typeof f == "string" ? f : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
71966
71966
|
for (let A of g) A[0] === "-" ? t.skips.push(A.slice(1)) : t.names.push(A);
|
|
71967
71967
|
}
|
|
71968
|
-
function i(
|
|
71969
|
-
let A = 0, P = 0, b = -1,
|
|
71970
|
-
for (; A <
|
|
71971
|
-
else if (b !== -1) P = b + 1,
|
|
71968
|
+
function i(f, g) {
|
|
71969
|
+
let A = 0, P = 0, b = -1, E = 0;
|
|
71970
|
+
for (; A < f.length; ) if (P < g.length && (g[P] === f[A] || g[P] === "*")) g[P] === "*" ? (b = P, E = A, P++) : (A++, P++);
|
|
71971
|
+
else if (b !== -1) P = b + 1, E++, A = E;
|
|
71972
71972
|
else return false;
|
|
71973
71973
|
for (; P < g.length && g[P] === "*"; ) P++;
|
|
71974
71974
|
return P === g.length;
|
|
71975
71975
|
}
|
|
71976
71976
|
function u() {
|
|
71977
|
-
let
|
|
71978
|
-
return t.enable(""),
|
|
71977
|
+
let f = [...t.names, ...t.skips.map((g) => "-" + g)].join(",");
|
|
71978
|
+
return t.enable(""), f;
|
|
71979
71979
|
}
|
|
71980
|
-
function l(
|
|
71981
|
-
for (let g of t.skips) if (i(
|
|
71982
|
-
for (let g of t.names) if (i(
|
|
71980
|
+
function l(f) {
|
|
71981
|
+
for (let g of t.skips) if (i(f, g)) return false;
|
|
71982
|
+
for (let g of t.names) if (i(f, g)) return true;
|
|
71983
71983
|
return false;
|
|
71984
71984
|
}
|
|
71985
|
-
function f
|
|
71986
|
-
return
|
|
71985
|
+
function d(f) {
|
|
71986
|
+
return f instanceof Error ? f.stack || f.message : f;
|
|
71987
71987
|
}
|
|
71988
|
-
function
|
|
71988
|
+
function h() {
|
|
71989
71989
|
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
71990
71990
|
}
|
|
71991
71991
|
return t.enable(t.load()), t;
|
|
@@ -72266,8 +72266,8 @@ var Rd = z((ft) => {
|
|
|
72266
72266
|
Promise.resolve().then(() => this.connect(e, o)).then((l) => {
|
|
72267
72267
|
if (this.decrementSockets(i, u), l instanceof Sd.Agent) try {
|
|
72268
72268
|
return l.addRequest(e, o);
|
|
72269
|
-
} catch (
|
|
72270
|
-
return n(
|
|
72269
|
+
} catch (d) {
|
|
72270
|
+
return n(d);
|
|
72271
72271
|
}
|
|
72272
72272
|
this[Jt].currentSocket = l, super.createSocket(e, t, n);
|
|
72273
72273
|
}, (l) => {
|
|
@@ -72306,20 +72306,20 @@ var kd = z((Dn) => {
|
|
|
72306
72306
|
return new Promise((e, t) => {
|
|
72307
72307
|
let n = 0, o = [];
|
|
72308
72308
|
function i() {
|
|
72309
|
-
let
|
|
72310
|
-
|
|
72309
|
+
let f = r.read();
|
|
72310
|
+
f ? h(f) : r.once("readable", i);
|
|
72311
72311
|
}
|
|
72312
72312
|
function u() {
|
|
72313
|
-
r.removeListener("end", l), r.removeListener("error",
|
|
72313
|
+
r.removeListener("end", l), r.removeListener("error", d), r.removeListener("readable", i);
|
|
72314
72314
|
}
|
|
72315
72315
|
function l() {
|
|
72316
72316
|
u(), Oo("onend"), t(new Error("Proxy connection ended before receiving CONNECT response"));
|
|
72317
72317
|
}
|
|
72318
|
-
function f
|
|
72319
|
-
u(), Oo("onerror %o",
|
|
72318
|
+
function d(f) {
|
|
72319
|
+
u(), Oo("onerror %o", f), t(f);
|
|
72320
72320
|
}
|
|
72321
|
-
function
|
|
72322
|
-
o.push(
|
|
72321
|
+
function h(f) {
|
|
72322
|
+
o.push(f), n += f.length;
|
|
72323
72323
|
let g = Buffer.concat(o, n), A = g.indexOf(`\r
|
|
72324
72324
|
\r
|
|
72325
72325
|
`);
|
|
@@ -72330,17 +72330,17 @@ var kd = z((Dn) => {
|
|
|
72330
72330
|
let P = g.slice(0, A).toString("ascii").split(`\r
|
|
72331
72331
|
`), b = P.shift();
|
|
72332
72332
|
if (!b) return r.destroy(), t(new Error("No header received from proxy CONNECT response"));
|
|
72333
|
-
let
|
|
72334
|
-
for (let
|
|
72335
|
-
if (!
|
|
72336
|
-
let S =
|
|
72337
|
-
if (S === -1) return r.destroy(), t(new Error(`Invalid header from proxy CONNECT response: "${
|
|
72338
|
-
let F =
|
|
72333
|
+
let E = b.split(" "), p = +E[1], y = E.slice(2).join(" "), T = {};
|
|
72334
|
+
for (let w of P) {
|
|
72335
|
+
if (!w) continue;
|
|
72336
|
+
let S = w.indexOf(":");
|
|
72337
|
+
if (S === -1) return r.destroy(), t(new Error(`Invalid header from proxy CONNECT response: "${w}"`));
|
|
72338
|
+
let F = w.slice(0, S).toLowerCase(), B = w.slice(S + 1).trimStart(), G = T[F];
|
|
72339
72339
|
typeof G == "string" ? T[F] = [G, B] : Array.isArray(G) ? G.push(B) : T[F] = B;
|
|
72340
72340
|
}
|
|
72341
72341
|
Oo("got proxy server response: %o %o", b, T), u(), e({ connect: { statusCode: p, statusText: y, headers: T }, buffered: g });
|
|
72342
72342
|
}
|
|
72343
|
-
r.on("error",
|
|
72343
|
+
r.on("error", d), r.on("end", l), i();
|
|
72344
72344
|
});
|
|
72345
72345
|
}
|
|
72346
72346
|
Dn.parseProxyResponse = f_;
|
|
@@ -72389,15 +72389,15 @@ var Id = z((At) => {
|
|
|
72389
72389
|
i.Host = `${u}:${t.port}`, i["Proxy-Connection"] || (i["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close");
|
|
72390
72390
|
for (let A of Object.keys(i)) l += `${A}: ${i[A]}\r
|
|
72391
72391
|
`;
|
|
72392
|
-
let
|
|
72392
|
+
let d = (0, __.parseProxyResponse)(o);
|
|
72393
72393
|
o.write(`${l}\r
|
|
72394
72394
|
`);
|
|
72395
|
-
let { connect:
|
|
72396
|
-
if (e.emit("proxyConnect",
|
|
72395
|
+
let { connect: h, buffered: f } = await d;
|
|
72396
|
+
if (e.emit("proxyConnect", h), this.emit("proxyConnect", h, e), h.statusCode === 200) return e.once("socket", C_), t.secureEndpoint ? (as("Upgrading socket connection to TLS"), Fd.connect({ ...Pd(Od(t), "host", "path", "port"), socket: o })) : o;
|
|
72397
72397
|
o.destroy();
|
|
72398
72398
|
let g = new Po.Socket({ writable: false });
|
|
72399
72399
|
return g.readable = true, e.once("socket", (A) => {
|
|
72400
|
-
as("Replaying proxy buffer for failed request"), (0, p_.default)(A.listenerCount("data") > 0), A.push(
|
|
72400
|
+
as("Replaying proxy buffer for failed request"), (0, p_.default)(A.listenerCount("data") > 0), A.push(f), A.push(null);
|
|
72401
72401
|
}), g;
|
|
72402
72402
|
}
|
|
72403
72403
|
};
|
|
@@ -72418,10 +72418,10 @@ function b_(r) {
|
|
|
72418
72418
|
let e = r.indexOf(",");
|
|
72419
72419
|
if (e === -1 || e <= 4) throw new TypeError("malformed data: URI");
|
|
72420
72420
|
let t = r.substring(5, e).split(";"), n = "", o = false, i = t[0] || "text/plain", u = i;
|
|
72421
|
-
for (let
|
|
72421
|
+
for (let f = 1; f < t.length; f++) t[f] === "base64" ? o = true : t[f] && (u += `;${t[f]}`, t[f].indexOf("charset=") === 0 && (n = t[f].substring(8)));
|
|
72422
72422
|
!t[0] && !n.length && (u += ";charset=US-ASCII", n = "US-ASCII");
|
|
72423
|
-
let l = o ? "base64" : "ascii",
|
|
72424
|
-
return
|
|
72423
|
+
let l = o ? "base64" : "ascii", d = unescape(r.substring(e + 1)), h = Buffer.from(d, l);
|
|
72424
|
+
return h.type = i, h.typeFull = u, h.charset = n, h;
|
|
72425
72425
|
}
|
|
72426
72426
|
var Nd;
|
|
72427
72427
|
var qd = Me(() => {
|
|
@@ -72445,13 +72445,13 @@ var Ld = z((Bo, jd) => {
|
|
|
72445
72445
|
}
|
|
72446
72446
|
}
|
|
72447
72447
|
let i = Promise, u = Promise.prototype.then, l = Promise.reject.bind(i);
|
|
72448
|
-
function f(s) {
|
|
72449
|
-
return new i(s);
|
|
72450
|
-
}
|
|
72451
72448
|
function d(s) {
|
|
72452
|
-
return
|
|
72449
|
+
return new i(s);
|
|
72453
72450
|
}
|
|
72454
72451
|
function h(s) {
|
|
72452
|
+
return d((a) => a(s));
|
|
72453
|
+
}
|
|
72454
|
+
function f(s) {
|
|
72455
72455
|
return l(s);
|
|
72456
72456
|
}
|
|
72457
72457
|
function g(s, a, c) {
|
|
@@ -72466,7 +72466,7 @@ var Ld = z((Bo, jd) => {
|
|
|
72466
72466
|
function b(s, a) {
|
|
72467
72467
|
A(s, void 0, a);
|
|
72468
72468
|
}
|
|
72469
|
-
function
|
|
72469
|
+
function E(s, a, c) {
|
|
72470
72470
|
return g(s, a, c);
|
|
72471
72471
|
}
|
|
72472
72472
|
function p(s) {
|
|
@@ -72475,7 +72475,7 @@ var Ld = z((Bo, jd) => {
|
|
|
72475
72475
|
let y = (s) => {
|
|
72476
72476
|
if (typeof queueMicrotask == "function") y = queueMicrotask;
|
|
72477
72477
|
else {
|
|
72478
|
-
let a =
|
|
72478
|
+
let a = h(void 0);
|
|
72479
72479
|
y = (c) => g(a, c);
|
|
72480
72480
|
}
|
|
72481
72481
|
return y(s);
|
|
@@ -72484,11 +72484,11 @@ var Ld = z((Bo, jd) => {
|
|
|
72484
72484
|
if (typeof s != "function") throw new TypeError("Argument is not a function");
|
|
72485
72485
|
return Function.prototype.apply.call(s, a, c);
|
|
72486
72486
|
}
|
|
72487
|
-
function
|
|
72487
|
+
function w(s, a, c) {
|
|
72488
72488
|
try {
|
|
72489
|
-
return
|
|
72489
|
+
return h(T(s, a, c));
|
|
72490
72490
|
} catch (_) {
|
|
72491
|
-
return
|
|
72491
|
+
return f(_);
|
|
72492
72492
|
}
|
|
72493
72493
|
}
|
|
72494
72494
|
let S = 16384;
|
|
@@ -72532,7 +72532,7 @@ var Ld = z((Bo, jd) => {
|
|
|
72532
72532
|
return new TypeError("Cannot " + s + " a stream using a released reader");
|
|
72533
72533
|
}
|
|
72534
72534
|
function Ae(s) {
|
|
72535
|
-
s._closedPromise =
|
|
72535
|
+
s._closedPromise = d((a, c) => {
|
|
72536
72536
|
s._closedPromise_resolve = a, s._closedPromise_reject = c;
|
|
72537
72537
|
});
|
|
72538
72538
|
}
|
|
@@ -72618,15 +72618,15 @@ var Ld = z((Bo, jd) => {
|
|
|
72618
72618
|
de(this, a), this._readRequests = new F();
|
|
72619
72619
|
}
|
|
72620
72620
|
get closed() {
|
|
72621
|
-
return Y(this) ? this._closedPromise :
|
|
72621
|
+
return Y(this) ? this._closedPromise : f(Ie("closed"));
|
|
72622
72622
|
}
|
|
72623
72623
|
cancel(a = void 0) {
|
|
72624
|
-
return Y(this) ? this._ownerReadableStream === void 0 ?
|
|
72624
|
+
return Y(this) ? this._ownerReadableStream === void 0 ? f(Ce("cancel")) : fe(this, a) : f(Ie("cancel"));
|
|
72625
72625
|
}
|
|
72626
72626
|
read() {
|
|
72627
|
-
if (!Y(this)) return
|
|
72628
|
-
if (this._ownerReadableStream === void 0) return
|
|
72629
|
-
let a, c, _ =
|
|
72627
|
+
if (!Y(this)) return f(Ie("read"));
|
|
72628
|
+
if (this._ownerReadableStream === void 0) return f(Ce("read from"));
|
|
72629
|
+
let a, c, _ = d((j, U) => {
|
|
72630
72630
|
a = j, c = U;
|
|
72631
72631
|
});
|
|
72632
72632
|
return Q(this, { _chunkSteps: (j) => a({ value: j, done: false }), _closeSteps: () => a({ value: void 0, done: true }), _errorSteps: (j) => c(j) }), _;
|
|
@@ -72666,15 +72666,15 @@ var Ld = z((Bo, jd) => {
|
|
|
72666
72666
|
}
|
|
72667
72667
|
next() {
|
|
72668
72668
|
let a = () => this._nextSteps();
|
|
72669
|
-
return this._ongoingPromise = this._ongoingPromise ?
|
|
72669
|
+
return this._ongoingPromise = this._ongoingPromise ? E(this._ongoingPromise, a, a) : a(), this._ongoingPromise;
|
|
72670
72670
|
}
|
|
72671
72671
|
return(a) {
|
|
72672
72672
|
let c = () => this._returnSteps(a);
|
|
72673
|
-
return this._ongoingPromise ?
|
|
72673
|
+
return this._ongoingPromise ? E(this._ongoingPromise, c, c) : c();
|
|
72674
72674
|
}
|
|
72675
72675
|
_nextSteps() {
|
|
72676
72676
|
if (this._isFinished) return Promise.resolve({ value: void 0, done: true });
|
|
72677
|
-
let a = this._reader, c, _, v =
|
|
72677
|
+
let a = this._reader, c, _, v = d((U, K) => {
|
|
72678
72678
|
c = U, _ = K;
|
|
72679
72679
|
});
|
|
72680
72680
|
return Q(a, { _chunkSteps: (U) => {
|
|
@@ -72691,15 +72691,15 @@ var Ld = z((Bo, jd) => {
|
|
|
72691
72691
|
let c = this._reader;
|
|
72692
72692
|
if (!this._preventCancel) {
|
|
72693
72693
|
let _ = fe(c, a);
|
|
72694
|
-
return Ee(c),
|
|
72694
|
+
return Ee(c), E(_, () => ({ value: a, done: true }));
|
|
72695
72695
|
}
|
|
72696
|
-
return Ee(c),
|
|
72696
|
+
return Ee(c), h({ value: a, done: true });
|
|
72697
72697
|
}
|
|
72698
72698
|
}
|
|
72699
72699
|
let je = { next() {
|
|
72700
|
-
return on(this) ? this._asyncIteratorImpl.next() :
|
|
72700
|
+
return on(this) ? this._asyncIteratorImpl.next() : f(an("next"));
|
|
72701
72701
|
}, return(s) {
|
|
72702
|
-
return on(this) ? this._asyncIteratorImpl.return(s) :
|
|
72702
|
+
return on(this) ? this._asyncIteratorImpl.return(s) : f(an("return"));
|
|
72703
72703
|
} };
|
|
72704
72704
|
Object.setPrototypeOf(je, be);
|
|
72705
72705
|
function sn(s, a) {
|
|
@@ -73118,12 +73118,12 @@ var Ld = z((Bo, jd) => {
|
|
|
73118
73118
|
function Ml(s, a, c, _, v, j, U) {
|
|
73119
73119
|
a._controlledReadableByteStream = s, a._pullAgain = false, a._pulling = false, a._byobRequest = null, a._queue = a._queueTotalSize = void 0, br(a), a._closeRequested = false, a._started = false, a._strategyHWM = j, a._pullAlgorithm = _, a._cancelAlgorithm = v, a._autoAllocateChunkSize = U, a._pendingPullIntos = new F(), s._readableStreamController = a;
|
|
73120
73120
|
let K = c();
|
|
73121
|
-
A(
|
|
73121
|
+
A(h(K), () => (a._started = true, Ur(a), null), (ie) => (bt(a, ie), null));
|
|
73122
73122
|
}
|
|
73123
73123
|
function Sg(s, a, c) {
|
|
73124
73124
|
let _ = Object.create(sr.prototype), v, j, U;
|
|
73125
73125
|
a.start !== void 0 ? v = () => a.start(_) : v = () => {
|
|
73126
|
-
}, a.pull !== void 0 ? j = () => a.pull(_) : j = () =>
|
|
73126
|
+
}, a.pull !== void 0 ? j = () => a.pull(_) : j = () => h(void 0), a.cancel !== void 0 ? U = (ie) => a.cancel(ie) : U = () => h(void 0);
|
|
73127
73127
|
let K = a.autoAllocateChunkSize;
|
|
73128
73128
|
if (K === 0) throw new TypeError("autoAllocateChunkSize must be greater than 0");
|
|
73129
73129
|
Ml(s, _, v, j, U, c, K);
|
|
@@ -73176,30 +73176,30 @@ var Ld = z((Bo, jd) => {
|
|
|
73176
73176
|
de(this, a), this._readIntoRequests = new F();
|
|
73177
73177
|
}
|
|
73178
73178
|
get closed() {
|
|
73179
|
-
return Mr(this) ? this._closedPromise :
|
|
73179
|
+
return Mr(this) ? this._closedPromise : f(Hs("closed"));
|
|
73180
73180
|
}
|
|
73181
73181
|
cancel(a = void 0) {
|
|
73182
|
-
return Mr(this) ? this._ownerReadableStream === void 0 ?
|
|
73182
|
+
return Mr(this) ? this._ownerReadableStream === void 0 ? f(Ce("cancel")) : fe(this, a) : f(Hs("cancel"));
|
|
73183
73183
|
}
|
|
73184
73184
|
read(a, c = {}) {
|
|
73185
|
-
if (!Mr(this)) return
|
|
73186
|
-
if (!ArrayBuffer.isView(a)) return
|
|
73187
|
-
if (a.byteLength === 0) return
|
|
73188
|
-
if (a.buffer.byteLength === 0) return
|
|
73189
|
-
if (Cr(a.buffer)) return
|
|
73185
|
+
if (!Mr(this)) return f(Hs("read"));
|
|
73186
|
+
if (!ArrayBuffer.isView(a)) return f(new TypeError("view must be an array buffer view"));
|
|
73187
|
+
if (a.byteLength === 0) return f(new TypeError("view must have non-zero byteLength"));
|
|
73188
|
+
if (a.buffer.byteLength === 0) return f(new TypeError("view's buffer must have non-zero byteLength"));
|
|
73189
|
+
if (Cr(a.buffer)) return f(new TypeError("view's buffer has been detached"));
|
|
73190
73190
|
let _;
|
|
73191
73191
|
try {
|
|
73192
73192
|
_ = kg(c, "options");
|
|
73193
73193
|
} catch (te) {
|
|
73194
|
-
return
|
|
73194
|
+
return f(te);
|
|
73195
73195
|
}
|
|
73196
73196
|
let v = _.min;
|
|
73197
|
-
if (v === 0) return
|
|
73197
|
+
if (v === 0) return f(new TypeError("options.min must be greater than 0"));
|
|
73198
73198
|
if (_g(a)) {
|
|
73199
|
-
if (v > a.byteLength) return
|
|
73200
|
-
} else if (v > a.length) return
|
|
73201
|
-
if (this._ownerReadableStream === void 0) return
|
|
73202
|
-
let j, U, K =
|
|
73199
|
+
if (v > a.byteLength) return f(new RangeError("options.min must be less than or equal to view's byteLength"));
|
|
73200
|
+
} else if (v > a.length) return f(new RangeError("options.min must be less than or equal to view's length"));
|
|
73201
|
+
if (this._ownerReadableStream === void 0) return f(Ce("read from"));
|
|
73202
|
+
let j, U, K = d((te, ce) => {
|
|
73203
73203
|
j = te, U = ce;
|
|
73204
73204
|
});
|
|
73205
73205
|
return Wl(this, a, v, { _chunkSteps: (te) => j({ value: te, done: false }), _closeSteps: (te) => j({ value: te, done: true }), _errorSteps: (te) => U(te) }), K;
|
|
@@ -73255,16 +73255,16 @@ var Ld = z((Bo, jd) => {
|
|
|
73255
73255
|
return { abort: c === void 0 ? void 0 : Bg(c, s, `${a} has member 'abort' that`), close: _ === void 0 ? void 0 : Ig(_, s, `${a} has member 'close' that`), start: v === void 0 ? void 0 : Ng(v, s, `${a} has member 'start' that`), write: U === void 0 ? void 0 : qg(U, s, `${a} has member 'write' that`), type: j };
|
|
73256
73256
|
}
|
|
73257
73257
|
function Bg(s, a, c) {
|
|
73258
|
-
return ge(s, c), (_) =>
|
|
73258
|
+
return ge(s, c), (_) => w(s, a, [_]);
|
|
73259
73259
|
}
|
|
73260
73260
|
function Ig(s, a, c) {
|
|
73261
|
-
return ge(s, c), () =>
|
|
73261
|
+
return ge(s, c), () => w(s, a, []);
|
|
73262
73262
|
}
|
|
73263
73263
|
function Ng(s, a, c) {
|
|
73264
73264
|
return ge(s, c), (_) => T(s, a, [_]);
|
|
73265
73265
|
}
|
|
73266
73266
|
function qg(s, a, c) {
|
|
73267
|
-
return ge(s, c), (_, v) =>
|
|
73267
|
+
return ge(s, c), (_, v) => w(s, a, [_, v]);
|
|
73268
73268
|
}
|
|
73269
73269
|
function zl(s, a) {
|
|
73270
73270
|
if (!cn(s)) throw new TypeError(`${a} is not a WritableStream.`);
|
|
@@ -73294,10 +73294,10 @@ var Ld = z((Bo, jd) => {
|
|
|
73294
73294
|
return ln(this);
|
|
73295
73295
|
}
|
|
73296
73296
|
abort(a = void 0) {
|
|
73297
|
-
return cn(this) ? ln(this) ?
|
|
73297
|
+
return cn(this) ? ln(this) ? f(new TypeError("Cannot abort a stream that already has a writer")) : Js(this, a) : f(Ys("abort"));
|
|
73298
73298
|
}
|
|
73299
73299
|
close() {
|
|
73300
|
-
return cn(this) ? ln(this) ?
|
|
73300
|
+
return cn(this) ? ln(this) ? f(new TypeError("Cannot close a stream that already has a writer")) : Gt(this) ? f(new TypeError("Cannot close an already-closing stream")) : Yl(this) : f(Ys("close"));
|
|
73301
73301
|
}
|
|
73302
73302
|
getWriter() {
|
|
73303
73303
|
if (!cn(this)) throw Ys("getWriter");
|
|
@@ -73325,29 +73325,29 @@ var Ld = z((Bo, jd) => {
|
|
|
73325
73325
|
}
|
|
73326
73326
|
function Js(s, a) {
|
|
73327
73327
|
var c;
|
|
73328
|
-
if (s._state === "closed" || s._state === "errored") return
|
|
73328
|
+
if (s._state === "closed" || s._state === "errored") return h(void 0);
|
|
73329
73329
|
s._writableStreamController._abortReason = a, (c = s._writableStreamController._abortController) === null || c === void 0 || c.abort(a);
|
|
73330
73330
|
let _ = s._state;
|
|
73331
|
-
if (_ === "closed" || _ === "errored") return
|
|
73331
|
+
if (_ === "closed" || _ === "errored") return h(void 0);
|
|
73332
73332
|
if (s._pendingAbortRequest !== void 0) return s._pendingAbortRequest._promise;
|
|
73333
73333
|
let v = false;
|
|
73334
73334
|
_ === "erroring" && (v = true, a = void 0);
|
|
73335
|
-
let j =
|
|
73335
|
+
let j = d((U, K) => {
|
|
73336
73336
|
s._pendingAbortRequest = { _promise: void 0, _resolve: U, _reject: K, _reason: a, _wasAlreadyErroring: v };
|
|
73337
73337
|
});
|
|
73338
73338
|
return s._pendingAbortRequest._promise = j, v || Ea(s, a), j;
|
|
73339
73339
|
}
|
|
73340
73340
|
function Yl(s) {
|
|
73341
73341
|
let a = s._state;
|
|
73342
|
-
if (a === "closed" || a === "errored") return
|
|
73343
|
-
let c =
|
|
73342
|
+
if (a === "closed" || a === "errored") return f(new TypeError(`The stream (in ${a} state) is not in the writable state and cannot be closed`));
|
|
73343
|
+
let c = d((v, j) => {
|
|
73344
73344
|
let U = { _resolve: v, _reject: j };
|
|
73345
73345
|
s._closeRequest = U;
|
|
73346
73346
|
}), _ = s._writer;
|
|
73347
73347
|
return _ !== void 0 && s._backpressure && a === "writable" && ka(_), ty(s._writableStreamController), c;
|
|
73348
73348
|
}
|
|
73349
73349
|
function $g(s) {
|
|
73350
|
-
return
|
|
73350
|
+
return d((c, _) => {
|
|
73351
73351
|
let v = { _resolve: c, _reject: _ };
|
|
73352
73352
|
s._writeRequests.push(v);
|
|
73353
73353
|
});
|
|
@@ -73431,7 +73431,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73431
73431
|
}
|
|
73432
73432
|
}
|
|
73433
73433
|
get closed() {
|
|
73434
|
-
return $r(this) ? this._closedPromise :
|
|
73434
|
+
return $r(this) ? this._closedPromise : f(Hr("closed"));
|
|
73435
73435
|
}
|
|
73436
73436
|
get desiredSize() {
|
|
73437
73437
|
if (!$r(this)) throw Hr("desiredSize");
|
|
@@ -73439,22 +73439,22 @@ var Ld = z((Bo, jd) => {
|
|
|
73439
73439
|
return Zg(this);
|
|
73440
73440
|
}
|
|
73441
73441
|
get ready() {
|
|
73442
|
-
return $r(this) ? this._readyPromise :
|
|
73442
|
+
return $r(this) ? this._readyPromise : f(Hr("ready"));
|
|
73443
73443
|
}
|
|
73444
73444
|
abort(a = void 0) {
|
|
73445
|
-
return $r(this) ? this._ownerWritableStream === void 0 ?
|
|
73445
|
+
return $r(this) ? this._ownerWritableStream === void 0 ? f(es("abort")) : Yg(this, a) : f(Hr("abort"));
|
|
73446
73446
|
}
|
|
73447
73447
|
close() {
|
|
73448
|
-
if (!$r(this)) return
|
|
73448
|
+
if (!$r(this)) return f(Hr("close"));
|
|
73449
73449
|
let a = this._ownerWritableStream;
|
|
73450
|
-
return a === void 0 ?
|
|
73450
|
+
return a === void 0 ? f(es("close")) : Gt(a) ? f(new TypeError("Cannot close an already-closing stream")) : Xl(this);
|
|
73451
73451
|
}
|
|
73452
73452
|
releaseLock() {
|
|
73453
73453
|
if (!$r(this)) throw Hr("releaseLock");
|
|
73454
73454
|
this._ownerWritableStream !== void 0 && Zl(this);
|
|
73455
73455
|
}
|
|
73456
73456
|
write(a = void 0) {
|
|
73457
|
-
return $r(this) ? this._ownerWritableStream === void 0 ?
|
|
73457
|
+
return $r(this) ? this._ownerWritableStream === void 0 ? f(es("write to")) : ef(this, a) : f(Hr("write"));
|
|
73458
73458
|
}
|
|
73459
73459
|
}
|
|
73460
73460
|
Object.defineProperties(or.prototype, { abort: { enumerable: true }, close: { enumerable: true }, releaseLock: { enumerable: true }, write: { enumerable: true }, closed: { enumerable: true }, desiredSize: { enumerable: true }, ready: { enumerable: true } }), o(or.prototype.abort, "abort"), o(or.prototype.close, "close"), o(or.prototype.releaseLock, "releaseLock"), o(or.prototype.write, "write"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(or.prototype, Symbol.toStringTag, { value: "WritableStreamDefaultWriter", configurable: true });
|
|
@@ -73471,7 +73471,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73471
73471
|
}
|
|
73472
73472
|
function Xg(s) {
|
|
73473
73473
|
let a = s._ownerWritableStream, c = a._state;
|
|
73474
|
-
return Gt(a) || c === "closed" ?
|
|
73474
|
+
return Gt(a) || c === "closed" ? h(void 0) : c === "errored" ? f(a._storedError) : Xl(s);
|
|
73475
73475
|
}
|
|
73476
73476
|
function Qg(s, a) {
|
|
73477
73477
|
s._closedPromiseState === "pending" ? va(s, a) : ay(s, a);
|
|
@@ -73489,11 +73489,11 @@ var Ld = z((Bo, jd) => {
|
|
|
73489
73489
|
}
|
|
73490
73490
|
function ef(s, a) {
|
|
73491
73491
|
let c = s._ownerWritableStream, _ = c._writableStreamController, v = ry(_, a);
|
|
73492
|
-
if (c !== s._ownerWritableStream) return
|
|
73492
|
+
if (c !== s._ownerWritableStream) return f(es("write to"));
|
|
73493
73493
|
let j = c._state;
|
|
73494
|
-
if (j === "errored") return
|
|
73495
|
-
if (Gt(c) || j === "closed") return
|
|
73496
|
-
if (j === "erroring") return
|
|
73494
|
+
if (j === "errored") return f(c._storedError);
|
|
73495
|
+
if (Gt(c) || j === "closed") return f(new TypeError("The stream is closing or closed and cannot be written to"));
|
|
73496
|
+
if (j === "erroring") return f(c._storedError);
|
|
73497
73497
|
let U = $g(c);
|
|
73498
73498
|
return ny(_, a, v), U;
|
|
73499
73499
|
}
|
|
@@ -73531,13 +73531,13 @@ var Ld = z((Bo, jd) => {
|
|
|
73531
73531
|
a._controlledWritableStream = s, s._writableStreamController = a, a._queue = void 0, a._queueTotalSize = void 0, br(a), a._abortReason = void 0, a._abortController = Ug(), a._started = false, a._strategySizeAlgorithm = K, a._strategyHWM = U, a._writeAlgorithm = _, a._closeAlgorithm = v, a._abortAlgorithm = j;
|
|
73532
73532
|
let ie = Sa(a);
|
|
73533
73533
|
Aa(s, ie);
|
|
73534
|
-
let te = c(), ce =
|
|
73534
|
+
let te = c(), ce = h(te);
|
|
73535
73535
|
A(ce, () => (a._started = true, Ks(a), null), (me) => (a._started = true, ba(s, me), null));
|
|
73536
73536
|
}
|
|
73537
73537
|
function ey(s, a, c, _) {
|
|
73538
73538
|
let v = Object.create(fn.prototype), j, U, K, ie;
|
|
73539
73539
|
a.start !== void 0 ? j = () => a.start(v) : j = () => {
|
|
73540
|
-
}, a.write !== void 0 ? U = (te) => a.write(te, v) : U = () =>
|
|
73540
|
+
}, a.write !== void 0 ? U = (te) => a.write(te, v) : U = () => h(void 0), a.close !== void 0 ? K = () => a.close() : K = () => h(void 0), a.abort !== void 0 ? ie = (te) => a.abort(te) : ie = () => h(void 0), rf(s, v, j, U, K, ie, c, _);
|
|
73541
73541
|
}
|
|
73542
73542
|
function Vs(s) {
|
|
73543
73543
|
s._writeAlgorithm = void 0, s._closeAlgorithm = void 0, s._abortAlgorithm = void 0, s._strategySizeAlgorithm = void 0;
|
|
@@ -73623,7 +73623,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73623
73623
|
return new TypeError("Cannot " + s + " a stream using a released writer");
|
|
73624
73624
|
}
|
|
73625
73625
|
function Xs(s) {
|
|
73626
|
-
s._closedPromise =
|
|
73626
|
+
s._closedPromise = d((a, c) => {
|
|
73627
73627
|
s._closedPromise_resolve = a, s._closedPromise_reject = c, s._closedPromiseState = "pending";
|
|
73628
73628
|
});
|
|
73629
73629
|
}
|
|
@@ -73643,7 +73643,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73643
73643
|
s._closedPromise_resolve !== void 0 && (s._closedPromise_resolve(void 0), s._closedPromise_resolve = void 0, s._closedPromise_reject = void 0, s._closedPromiseState = "resolved");
|
|
73644
73644
|
}
|
|
73645
73645
|
function Qs(s) {
|
|
73646
|
-
s._readyPromise =
|
|
73646
|
+
s._readyPromise = d((a, c) => {
|
|
73647
73647
|
s._readyPromise_resolve = a, s._readyPromise_reject = c;
|
|
73648
73648
|
}), s._readyPromiseState = "pending";
|
|
73649
73649
|
}
|
|
@@ -73693,13 +73693,13 @@ var Ld = z((Bo, jd) => {
|
|
|
73693
73693
|
function lf(s, a, c, _, v, j) {
|
|
73694
73694
|
let U = L(s), K = Vl(a);
|
|
73695
73695
|
s._disturbed = true;
|
|
73696
|
-
let ie = false, te =
|
|
73697
|
-
return
|
|
73696
|
+
let ie = false, te = h(void 0);
|
|
73697
|
+
return d((ce, me) => {
|
|
73698
73698
|
let Re;
|
|
73699
73699
|
if (j !== void 0) {
|
|
73700
73700
|
if (Re = () => {
|
|
73701
73701
|
let re = j.reason !== void 0 ? j.reason : new py("Aborted", "AbortError"), ye = [];
|
|
73702
|
-
_ || ye.push(() => a._state === "writable" ? Js(a, re) :
|
|
73702
|
+
_ || ye.push(() => a._state === "writable" ? Js(a, re) : h(void 0)), v || ye.push(() => s._state === "readable" ? Ot(s, re) : h(void 0)), rt(() => Promise.all(ye.map((Fe) => Fe())), true, re);
|
|
73703
73703
|
}, j.aborted) {
|
|
73704
73704
|
Re();
|
|
73705
73705
|
return;
|
|
@@ -73707,7 +73707,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73707
73707
|
j.addEventListener("abort", Re);
|
|
73708
73708
|
}
|
|
73709
73709
|
function Pt() {
|
|
73710
|
-
return
|
|
73710
|
+
return d((re, ye) => {
|
|
73711
73711
|
function Fe(lt) {
|
|
73712
73712
|
lt ? re() : g(mn(), Fe, ye);
|
|
73713
73713
|
}
|
|
@@ -73715,7 +73715,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73715
73715
|
});
|
|
73716
73716
|
}
|
|
73717
73717
|
function mn() {
|
|
73718
|
-
return ie ?
|
|
73718
|
+
return ie ? h(true) : g(K._readyPromise, () => d((re, ye) => {
|
|
73719
73719
|
Q(U, { _chunkSteps: (Fe) => {
|
|
73720
73720
|
te = g(ef(K, Fe), void 0, e), re(false);
|
|
73721
73721
|
}, _closeSteps: () => re(true), _errorSteps: ye });
|
|
@@ -73851,12 +73851,12 @@ var Ld = z((Bo, jd) => {
|
|
|
73851
73851
|
function df(s, a, c, _, v, j, U) {
|
|
73852
73852
|
a._controlledReadableStream = s, a._queue = void 0, a._queueTotalSize = void 0, br(a), a._started = false, a._closeRequested = false, a._pullAgain = false, a._pulling = false, a._strategySizeAlgorithm = U, a._strategyHWM = j, a._pullAlgorithm = _, a._cancelAlgorithm = v, s._readableStreamController = a;
|
|
73853
73853
|
let K = c();
|
|
73854
|
-
A(
|
|
73854
|
+
A(h(K), () => (a._started = true, ts(a), null), (ie) => (Ft(a, ie), null));
|
|
73855
73855
|
}
|
|
73856
73856
|
function gy(s, a, c, _) {
|
|
73857
73857
|
let v = Object.create(ir.prototype), j, U, K;
|
|
73858
73858
|
a.start !== void 0 ? j = () => a.start(v) : j = () => {
|
|
73859
|
-
}, a.pull !== void 0 ? U = () => a.pull(v) : U = () =>
|
|
73859
|
+
}, a.pull !== void 0 ? U = () => a.pull(v) : U = () => h(void 0), a.cancel !== void 0 ? K = (ie) => a.cancel(ie) : K = () => h(void 0), df(s, v, j, U, K, c, _);
|
|
73860
73860
|
}
|
|
73861
73861
|
function to(s) {
|
|
73862
73862
|
return new TypeError(`ReadableStreamDefaultController.prototype.${s} can only be used on a ReadableStreamDefaultController`);
|
|
@@ -73865,11 +73865,11 @@ var Ld = z((Bo, jd) => {
|
|
|
73865
73865
|
return Lr(s._readableStreamController) ? Cy(s) : _y(s);
|
|
73866
73866
|
}
|
|
73867
73867
|
function _y(s, a) {
|
|
73868
|
-
let c = L(s), _ = false, v = false, j = false, U = false, K, ie, te, ce, me, Re =
|
|
73868
|
+
let c = L(s), _ = false, v = false, j = false, U = false, K, ie, te, ce, me, Re = d((Qe) => {
|
|
73869
73869
|
me = Qe;
|
|
73870
73870
|
});
|
|
73871
73871
|
function Pt() {
|
|
73872
|
-
return _ ? (v = true,
|
|
73872
|
+
return _ ? (v = true, h(void 0)) : (_ = true, Q(c, { _chunkSteps: (rt) => {
|
|
73873
73873
|
y(() => {
|
|
73874
73874
|
v = false;
|
|
73875
73875
|
let Et = rt, ur = rt;
|
|
@@ -73879,7 +73879,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73879
73879
|
_ = false, j || Gr(te._readableStreamController), U || Gr(ce._readableStreamController), (!j || !U) && me(void 0);
|
|
73880
73880
|
}, _errorSteps: () => {
|
|
73881
73881
|
_ = false;
|
|
73882
|
-
} }),
|
|
73882
|
+
} }), h(void 0));
|
|
73883
73883
|
}
|
|
73884
73884
|
function mn(Qe) {
|
|
73885
73885
|
if (j = true, K = Qe, U) {
|
|
@@ -73900,7 +73900,7 @@ var Ld = z((Bo, jd) => {
|
|
|
73900
73900
|
return te = rs(ar, Pt, mn), ce = rs(ar, Pt, Tr), b(c._closedPromise, (Qe) => (Ft(te._readableStreamController, Qe), Ft(ce._readableStreamController, Qe), (!j || !U) && me(void 0), null)), [te, ce];
|
|
73901
73901
|
}
|
|
73902
73902
|
function Cy(s) {
|
|
73903
|
-
let a = L(s), c = false, _ = false, v = false, j = false, U = false, K, ie, te, ce, me, Re =
|
|
73903
|
+
let a = L(s), c = false, _ = false, v = false, j = false, U = false, K, ie, te, ce, me, Re = d((re) => {
|
|
73904
73904
|
me = re;
|
|
73905
73905
|
});
|
|
73906
73906
|
function Pt(re) {
|
|
@@ -73954,16 +73954,16 @@ var Ld = z((Bo, jd) => {
|
|
|
73954
73954
|
} });
|
|
73955
73955
|
}
|
|
73956
73956
|
function ar() {
|
|
73957
|
-
if (c) return _ = true,
|
|
73957
|
+
if (c) return _ = true, h(void 0);
|
|
73958
73958
|
c = true;
|
|
73959
73959
|
let re = ya(te._readableStreamController);
|
|
73960
|
-
return re === null ? mn() : Tr(re._view, false),
|
|
73960
|
+
return re === null ? mn() : Tr(re._view, false), h(void 0);
|
|
73961
73961
|
}
|
|
73962
73962
|
function Qe() {
|
|
73963
|
-
if (c) return v = true,
|
|
73963
|
+
if (c) return v = true, h(void 0);
|
|
73964
73964
|
c = true;
|
|
73965
73965
|
let re = ya(ce._readableStreamController);
|
|
73966
|
-
return re === null ? mn() : Tr(re._view, true),
|
|
73966
|
+
return re === null ? mn() : Tr(re._view, true), h(void 0);
|
|
73967
73967
|
}
|
|
73968
73968
|
function rt(re) {
|
|
73969
73969
|
if (j = true, K = re, U) {
|
|
@@ -73996,10 +73996,10 @@ var Ld = z((Bo, jd) => {
|
|
|
73996
73996
|
try {
|
|
73997
73997
|
U = hg(c);
|
|
73998
73998
|
} catch (ie) {
|
|
73999
|
-
return
|
|
73999
|
+
return f(ie);
|
|
74000
74000
|
}
|
|
74001
|
-
let K =
|
|
74002
|
-
return
|
|
74001
|
+
let K = h(U);
|
|
74002
|
+
return E(K, (ie) => {
|
|
74003
74003
|
if (!t(ie)) throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
|
|
74004
74004
|
if (pg(ie)) Gr(a._readableStreamController);
|
|
74005
74005
|
else {
|
|
@@ -74013,17 +74013,17 @@ var Ld = z((Bo, jd) => {
|
|
|
74013
74013
|
try {
|
|
74014
74014
|
ie = qs(K, "return");
|
|
74015
74015
|
} catch (me) {
|
|
74016
|
-
return
|
|
74016
|
+
return f(me);
|
|
74017
74017
|
}
|
|
74018
|
-
if (ie === void 0) return
|
|
74018
|
+
if (ie === void 0) return h(void 0);
|
|
74019
74019
|
let te;
|
|
74020
74020
|
try {
|
|
74021
74021
|
te = T(ie, K, [U]);
|
|
74022
74022
|
} catch (me) {
|
|
74023
|
-
return
|
|
74023
|
+
return f(me);
|
|
74024
74024
|
}
|
|
74025
|
-
let ce =
|
|
74026
|
-
return
|
|
74025
|
+
let ce = h(te);
|
|
74026
|
+
return E(ce, (me) => {
|
|
74027
74027
|
if (!t(me)) throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
|
|
74028
74028
|
});
|
|
74029
74029
|
}
|
|
@@ -74036,9 +74036,9 @@ var Ld = z((Bo, jd) => {
|
|
|
74036
74036
|
try {
|
|
74037
74037
|
j = s.read();
|
|
74038
74038
|
} catch (U) {
|
|
74039
|
-
return
|
|
74039
|
+
return f(U);
|
|
74040
74040
|
}
|
|
74041
|
-
return
|
|
74041
|
+
return E(j, (U) => {
|
|
74042
74042
|
if (!t(U)) throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
|
|
74043
74043
|
if (U.done) Gr(a._readableStreamController);
|
|
74044
74044
|
else {
|
|
@@ -74049,9 +74049,9 @@ var Ld = z((Bo, jd) => {
|
|
|
74049
74049
|
}
|
|
74050
74050
|
function v(j) {
|
|
74051
74051
|
try {
|
|
74052
|
-
return
|
|
74052
|
+
return h(s.cancel(j));
|
|
74053
74053
|
} catch (U) {
|
|
74054
|
-
return
|
|
74054
|
+
return f(U);
|
|
74055
74055
|
}
|
|
74056
74056
|
}
|
|
74057
74057
|
return a = rs(c, _, v, 0), a;
|
|
@@ -74062,10 +74062,10 @@ var Ld = z((Bo, jd) => {
|
|
|
74062
74062
|
return { autoAllocateChunkSize: _ === void 0 ? void 0 : k(_, `${a} has member 'autoAllocateChunkSize' that`), cancel: v === void 0 ? void 0 : Sy(v, c, `${a} has member 'cancel' that`), pull: j === void 0 ? void 0 : Ty(j, c, `${a} has member 'pull' that`), start: U === void 0 ? void 0 : vy(U, c, `${a} has member 'start' that`), type: K === void 0 ? void 0 : Ry(K, `${a} has member 'type' that`) };
|
|
74063
74063
|
}
|
|
74064
74064
|
function Sy(s, a, c) {
|
|
74065
|
-
return ge(s, c), (_) =>
|
|
74065
|
+
return ge(s, c), (_) => w(s, a, [_]);
|
|
74066
74066
|
}
|
|
74067
74067
|
function Ty(s, a, c) {
|
|
74068
|
-
return ge(s, c), (_) =>
|
|
74068
|
+
return ge(s, c), (_) => w(s, a, [_]);
|
|
74069
74069
|
}
|
|
74070
74070
|
function vy(s, a, c) {
|
|
74071
74071
|
return ge(s, c), (_) => T(s, a, [_]);
|
|
@@ -74110,7 +74110,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74110
74110
|
return Dr(this);
|
|
74111
74111
|
}
|
|
74112
74112
|
cancel(a = void 0) {
|
|
74113
|
-
return Ar(this) ? Dr(this) ?
|
|
74113
|
+
return Ar(this) ? Dr(this) ? f(new TypeError("Cannot cancel a stream that already has a reader")) : Ot(this, a) : f(Wr("cancel"));
|
|
74114
74114
|
}
|
|
74115
74115
|
getReader(a = void 0) {
|
|
74116
74116
|
if (!Ar(this)) throw Wr("getReader");
|
|
@@ -74126,16 +74126,16 @@ var Ld = z((Bo, jd) => {
|
|
|
74126
74126
|
return p(j), _.readable;
|
|
74127
74127
|
}
|
|
74128
74128
|
pipeTo(a, c = {}) {
|
|
74129
|
-
if (!Ar(this)) return
|
|
74130
|
-
if (a === void 0) return
|
|
74131
|
-
if (!cn(a)) return
|
|
74129
|
+
if (!Ar(this)) return f(Wr("pipeTo"));
|
|
74130
|
+
if (a === void 0) return f("Parameter 1 is required in 'pipeTo'.");
|
|
74131
|
+
if (!cn(a)) return f(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));
|
|
74132
74132
|
let _;
|
|
74133
74133
|
try {
|
|
74134
74134
|
_ = hf(c, "Second parameter");
|
|
74135
74135
|
} catch (v) {
|
|
74136
|
-
return
|
|
74136
|
+
return f(v);
|
|
74137
74137
|
}
|
|
74138
|
-
return Dr(this) ?
|
|
74138
|
+
return Dr(this) ? f(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")) : ln(a) ? f(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")) : lf(this, a, _.preventClose, _.preventAbort, _.preventCancel, _.signal);
|
|
74139
74139
|
}
|
|
74140
74140
|
tee() {
|
|
74141
74141
|
if (!Ar(this)) throw Wr("tee");
|
|
@@ -74177,8 +74177,8 @@ var Ld = z((Bo, jd) => {
|
|
|
74177
74177
|
return s._reader !== void 0;
|
|
74178
74178
|
}
|
|
74179
74179
|
function Ot(s, a) {
|
|
74180
|
-
if (s._disturbed = true, s._state === "closed") return
|
|
74181
|
-
if (s._state === "errored") return
|
|
74180
|
+
if (s._disturbed = true, s._state === "closed") return h(void 0);
|
|
74181
|
+
if (s._state === "errored") return f(s._storedError);
|
|
74182
74182
|
ns(s);
|
|
74183
74183
|
let c = s._reader;
|
|
74184
74184
|
if (c !== void 0 && Mr(c)) {
|
|
@@ -74188,7 +74188,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74188
74188
|
});
|
|
74189
74189
|
}
|
|
74190
74190
|
let _ = s._readableStreamController[Z](a);
|
|
74191
|
-
return
|
|
74191
|
+
return E(_, e);
|
|
74192
74192
|
}
|
|
74193
74193
|
function ns(s) {
|
|
74194
74194
|
s._state = "closed";
|
|
@@ -74263,16 +74263,16 @@ var Ld = z((Bo, jd) => {
|
|
|
74263
74263
|
return { cancel: c === void 0 ? void 0 : Ny(c, s, `${a} has member 'cancel' that`), flush: _ === void 0 ? void 0 : xy(_, s, `${a} has member 'flush' that`), readableType: v, start: j === void 0 ? void 0 : By(j, s, `${a} has member 'start' that`), transform: U === void 0 ? void 0 : Iy(U, s, `${a} has member 'transform' that`), writableType: K };
|
|
74264
74264
|
}
|
|
74265
74265
|
function xy(s, a, c) {
|
|
74266
|
-
return ge(s, c), (_) =>
|
|
74266
|
+
return ge(s, c), (_) => w(s, a, [_]);
|
|
74267
74267
|
}
|
|
74268
74268
|
function By(s, a, c) {
|
|
74269
74269
|
return ge(s, c), (_) => T(s, a, [_]);
|
|
74270
74270
|
}
|
|
74271
74271
|
function Iy(s, a, c) {
|
|
74272
|
-
return ge(s, c), (_, v) =>
|
|
74272
|
+
return ge(s, c), (_, v) => w(s, a, [_, v]);
|
|
74273
74273
|
}
|
|
74274
74274
|
function Ny(s, a, c) {
|
|
74275
|
-
return ge(s, c), (_) =>
|
|
74275
|
+
return ge(s, c), (_) => w(s, a, [_]);
|
|
74276
74276
|
}
|
|
74277
74277
|
class so {
|
|
74278
74278
|
constructor(a = {}, c = {}, _ = {}) {
|
|
@@ -74280,7 +74280,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74280
74280
|
let v = Ws(c, "Second parameter"), j = Ws(_, "Third parameter"), U = Py(a, "First parameter");
|
|
74281
74281
|
if (U.readableType !== void 0) throw new RangeError("Invalid readableType specified");
|
|
74282
74282
|
if (U.writableType !== void 0) throw new RangeError("Invalid writableType specified");
|
|
74283
|
-
let K = Qn(j, 0), ie = Gs(j), te = Qn(v, 1), ce = Gs(v), me, Re =
|
|
74283
|
+
let K = Qn(j, 0), ie = Gs(j), te = Qn(v, 1), ce = Gs(v), me, Re = d((Pt) => {
|
|
74284
74284
|
me = Pt;
|
|
74285
74285
|
});
|
|
74286
74286
|
qy(this, Re, te, ce, K, ie), Ly(this, U), U.start !== void 0 ? me(U.start(this._transformStreamController)) : me(void 0);
|
|
@@ -74330,7 +74330,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74330
74330
|
s._backpressure && oo(s, false);
|
|
74331
74331
|
}
|
|
74332
74332
|
function oo(s, a) {
|
|
74333
|
-
s._backpressureChangePromise !== void 0 && s._backpressureChangePromise_resolve(), s._backpressureChangePromise =
|
|
74333
|
+
s._backpressureChangePromise !== void 0 && s._backpressureChangePromise_resolve(), s._backpressureChangePromise = d((c) => {
|
|
74334
74334
|
s._backpressureChangePromise_resolve = c;
|
|
74335
74335
|
}), s._backpressure = a;
|
|
74336
74336
|
}
|
|
@@ -74367,11 +74367,11 @@ var Ld = z((Bo, jd) => {
|
|
|
74367
74367
|
let c = Object.create(Sr.prototype), _, v, j;
|
|
74368
74368
|
a.transform !== void 0 ? _ = (U) => a.transform(U, c) : _ = (U) => {
|
|
74369
74369
|
try {
|
|
74370
|
-
return Sf(c, U),
|
|
74370
|
+
return Sf(c, U), h(void 0);
|
|
74371
74371
|
} catch (K) {
|
|
74372
|
-
return
|
|
74372
|
+
return f(K);
|
|
74373
74373
|
}
|
|
74374
|
-
}, a.flush !== void 0 ? v = () => a.flush(c) : v = () =>
|
|
74374
|
+
}, a.flush !== void 0 ? v = () => a.flush(c) : v = () => h(void 0), a.cancel !== void 0 ? j = (U) => a.cancel(U) : j = () => h(void 0), jy(s, c, _, v, j);
|
|
74375
74375
|
}
|
|
74376
74376
|
function ao(s) {
|
|
74377
74377
|
s._transformAlgorithm = void 0, s._flushAlgorithm = void 0, s._cancelAlgorithm = void 0;
|
|
@@ -74391,7 +74391,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74391
74391
|
}
|
|
74392
74392
|
function Tf(s, a) {
|
|
74393
74393
|
let c = s._transformAlgorithm(a);
|
|
74394
|
-
return
|
|
74394
|
+
return E(c, void 0, (_) => {
|
|
74395
74395
|
throw Df(s._controlledTransformStream, _), _;
|
|
74396
74396
|
});
|
|
74397
74397
|
}
|
|
@@ -74405,7 +74405,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74405
74405
|
let c = s._transformStreamController;
|
|
74406
74406
|
if (s._backpressure) {
|
|
74407
74407
|
let _ = s._backpressureChangePromise;
|
|
74408
|
-
return
|
|
74408
|
+
return E(_, () => {
|
|
74409
74409
|
let v = s._writable;
|
|
74410
74410
|
if (v._state === "erroring") throw v._storedError;
|
|
74411
74411
|
return Tf(c, a);
|
|
@@ -74417,7 +74417,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74417
74417
|
let c = s._transformStreamController;
|
|
74418
74418
|
if (c._finishPromise !== void 0) return c._finishPromise;
|
|
74419
74419
|
let _ = s._readable;
|
|
74420
|
-
c._finishPromise =
|
|
74420
|
+
c._finishPromise = d((j, U) => {
|
|
74421
74421
|
c._finishPromise_resolve = j, c._finishPromise_reject = U;
|
|
74422
74422
|
});
|
|
74423
74423
|
let v = c._cancelAlgorithm(a);
|
|
@@ -74427,7 +74427,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74427
74427
|
let a = s._transformStreamController;
|
|
74428
74428
|
if (a._finishPromise !== void 0) return a._finishPromise;
|
|
74429
74429
|
let c = s._readable;
|
|
74430
|
-
a._finishPromise =
|
|
74430
|
+
a._finishPromise = d((v, j) => {
|
|
74431
74431
|
a._finishPromise_resolve = v, a._finishPromise_reject = j;
|
|
74432
74432
|
});
|
|
74433
74433
|
let _ = a._flushAlgorithm();
|
|
@@ -74440,7 +74440,7 @@ var Ld = z((Bo, jd) => {
|
|
|
74440
74440
|
let c = s._transformStreamController;
|
|
74441
74441
|
if (c._finishPromise !== void 0) return c._finishPromise;
|
|
74442
74442
|
let _ = s._writable;
|
|
74443
|
-
c._finishPromise =
|
|
74443
|
+
c._finishPromise = d((j, U) => {
|
|
74444
74444
|
c._finishPromise_resolve = j, c._finishPromise_reject = U;
|
|
74445
74445
|
});
|
|
74446
74446
|
let v = c._cancelAlgorithm(a);
|
|
@@ -74555,18 +74555,18 @@ var us = Me(() => {
|
|
|
74555
74555
|
} });
|
|
74556
74556
|
}
|
|
74557
74557
|
slice(e = 0, t = this.size, n = "") {
|
|
74558
|
-
let { size: o } = this, i = e < 0 ? Math.max(o + e, 0) : Math.min(e, o), u = t < 0 ? Math.max(o + t, 0) : Math.min(t, o), l = Math.max(u - i, 0),
|
|
74559
|
-
for (let A of
|
|
74560
|
-
if (
|
|
74558
|
+
let { size: o } = this, i = e < 0 ? Math.max(o + e, 0) : Math.min(e, o), u = t < 0 ? Math.max(o + t, 0) : Math.min(t, o), l = Math.max(u - i, 0), d = this.#e, h = [], f = 0;
|
|
74559
|
+
for (let A of d) {
|
|
74560
|
+
if (f >= l) break;
|
|
74561
74561
|
let P = ArrayBuffer.isView(A) ? A.byteLength : A.size;
|
|
74562
74562
|
if (i && P <= i) i -= P, u -= P;
|
|
74563
74563
|
else {
|
|
74564
74564
|
let b;
|
|
74565
|
-
ArrayBuffer.isView(A) ? (b = A.subarray(i, Math.min(P, u)),
|
|
74565
|
+
ArrayBuffer.isView(A) ? (b = A.subarray(i, Math.min(P, u)), f += b.byteLength) : (b = A.slice(i, Math.min(P, u)), f += b.size), u -= P, h.push(b), i = 0;
|
|
74566
74566
|
}
|
|
74567
74567
|
}
|
|
74568
74568
|
let g = new uu([], { type: String(n).toLowerCase() });
|
|
74569
|
-
return g.#r = l, g.#e =
|
|
74569
|
+
return g.#r = l, g.#e = h, g;
|
|
74570
74570
|
}
|
|
74571
74571
|
get [Symbol.toStringTag]() {
|
|
74572
74572
|
return "Blob";
|
|
@@ -74778,18 +74778,18 @@ async function N_(r, e) {
|
|
|
74778
74778
|
if (!/multipart/i.test(e)) throw new TypeError("Failed to fetch");
|
|
74779
74779
|
let t = e.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
|
74780
74780
|
if (!t) throw new TypeError("no or bad content-type header, no multipart boundary");
|
|
74781
|
-
let n = new mu(t[1] || t[2]), o, i, u, l,
|
|
74781
|
+
let n = new mu(t[1] || t[2]), o, i, u, l, d, h, f = [], g = new kr(), A = (y) => {
|
|
74782
74782
|
u += p.decode(y, { stream: true });
|
|
74783
74783
|
}, P = (y) => {
|
|
74784
|
-
|
|
74784
|
+
f.push(y);
|
|
74785
74785
|
}, b = () => {
|
|
74786
|
-
let y = new Rr(
|
|
74786
|
+
let y = new Rr(f, h, { type: d });
|
|
74787
74787
|
g.append(l, y);
|
|
74788
|
-
},
|
|
74788
|
+
}, E = () => {
|
|
74789
74789
|
g.append(l, u);
|
|
74790
74790
|
}, p = new TextDecoder("utf-8");
|
|
74791
74791
|
p.decode(), n.onPartBegin = function() {
|
|
74792
|
-
n.onPartData = A, n.onPartEnd =
|
|
74792
|
+
n.onPartData = A, n.onPartEnd = E, o = "", i = "", u = "", l = "", d = "", h = null, f.length = 0;
|
|
74793
74793
|
}, n.onHeaderField = function(y) {
|
|
74794
74794
|
o += p.decode(y, { stream: true });
|
|
74795
74795
|
}, n.onHeaderValue = function(y) {
|
|
@@ -74797,8 +74797,8 @@ async function N_(r, e) {
|
|
|
74797
74797
|
}, n.onHeaderEnd = function() {
|
|
74798
74798
|
if (i += p.decode(), o = o.toLowerCase(), o === "content-disposition") {
|
|
74799
74799
|
let y = i.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
|
74800
|
-
y && (l = y[2] || y[3] || ""),
|
|
74801
|
-
} else o === "content-type" && (
|
|
74800
|
+
y && (l = y[2] || y[3] || ""), h = I_(i), h && (n.onPartData = P, n.onPartEnd = b);
|
|
74801
|
+
} else o === "content-type" && (d = i);
|
|
74802
74802
|
i = "", o = "";
|
|
74803
74803
|
};
|
|
74804
74804
|
for await (let y of r) n.write(y);
|
|
@@ -74831,76 +74831,76 @@ var ah = Me(() => {
|
|
|
74831
74831
|
this.boundary = t, this.lookbehind = new Uint8Array(this.boundary.length + 8), this.state = Oe.START_BOUNDARY;
|
|
74832
74832
|
}
|
|
74833
74833
|
write(e) {
|
|
74834
|
-
let t = 0, n = e.length, o = this.index, { lookbehind: i, boundary: u, boundaryChars: l, index:
|
|
74834
|
+
let t = 0, n = e.length, o = this.index, { lookbehind: i, boundary: u, boundaryChars: l, index: d, state: h, flags: f } = this, g = this.boundary.length, A = g - 1, P = e.length, b, E, p = (S) => {
|
|
74835
74835
|
this[S + "Mark"] = t;
|
|
74836
74836
|
}, y = (S) => {
|
|
74837
74837
|
delete this[S + "Mark"];
|
|
74838
74838
|
}, T = (S, F, B, G) => {
|
|
74839
74839
|
(F === void 0 || F !== B) && this[S](G && G.subarray(F, B));
|
|
74840
|
-
},
|
|
74840
|
+
}, w = (S, F) => {
|
|
74841
74841
|
let B = S + "Mark";
|
|
74842
74842
|
B in this && (F ? (T(S, this[B], t, e), delete this[B]) : (T(S, this[B], e.length, e), this[B] = 0));
|
|
74843
74843
|
};
|
|
74844
|
-
for (t = 0; t < n; t++) switch (b = e[t],
|
|
74844
|
+
for (t = 0; t < n; t++) switch (b = e[t], h) {
|
|
74845
74845
|
case Oe.START_BOUNDARY:
|
|
74846
|
-
if (
|
|
74847
|
-
if (b === fs3)
|
|
74846
|
+
if (d === u.length - 2) {
|
|
74847
|
+
if (b === fs3) f |= Fr.LAST_BOUNDARY;
|
|
74848
74848
|
else if (b !== Mo) return;
|
|
74849
|
-
|
|
74849
|
+
d++;
|
|
74850
74850
|
break;
|
|
74851
|
-
} else if (
|
|
74852
|
-
if (
|
|
74853
|
-
else if (!(
|
|
74851
|
+
} else if (d - 1 === u.length - 2) {
|
|
74852
|
+
if (f & Fr.LAST_BOUNDARY && b === fs3) h = Oe.END, f = 0;
|
|
74853
|
+
else if (!(f & Fr.LAST_BOUNDARY) && b === Uo) d = 0, T("onPartBegin"), h = Oe.HEADER_FIELD_START;
|
|
74854
74854
|
else return;
|
|
74855
74855
|
break;
|
|
74856
74856
|
}
|
|
74857
|
-
b !== u[
|
|
74857
|
+
b !== u[d + 2] && (d = -2), b === u[d + 2] && d++;
|
|
74858
74858
|
break;
|
|
74859
74859
|
case Oe.HEADER_FIELD_START:
|
|
74860
|
-
|
|
74860
|
+
h = Oe.HEADER_FIELD, p("onHeaderField"), d = 0;
|
|
74861
74861
|
case Oe.HEADER_FIELD:
|
|
74862
74862
|
if (b === Mo) {
|
|
74863
|
-
y("onHeaderField"),
|
|
74863
|
+
y("onHeaderField"), h = Oe.HEADERS_ALMOST_DONE;
|
|
74864
74864
|
break;
|
|
74865
74865
|
}
|
|
74866
|
-
if (
|
|
74866
|
+
if (d++, b === fs3) break;
|
|
74867
74867
|
if (b === O_) {
|
|
74868
|
-
if (
|
|
74869
|
-
|
|
74868
|
+
if (d === 1) return;
|
|
74869
|
+
w("onHeaderField", true), h = Oe.HEADER_VALUE_START;
|
|
74870
74870
|
break;
|
|
74871
74871
|
}
|
|
74872
|
-
if (
|
|
74872
|
+
if (E = B_(b), E < P_ || E > x_) return;
|
|
74873
74873
|
break;
|
|
74874
74874
|
case Oe.HEADER_VALUE_START:
|
|
74875
74875
|
if (b === F_) break;
|
|
74876
|
-
p("onHeaderValue"),
|
|
74876
|
+
p("onHeaderValue"), h = Oe.HEADER_VALUE;
|
|
74877
74877
|
case Oe.HEADER_VALUE:
|
|
74878
|
-
b === Mo && (
|
|
74878
|
+
b === Mo && (w("onHeaderValue", true), T("onHeaderEnd"), h = Oe.HEADER_VALUE_ALMOST_DONE);
|
|
74879
74879
|
break;
|
|
74880
74880
|
case Oe.HEADER_VALUE_ALMOST_DONE:
|
|
74881
74881
|
if (b !== Uo) return;
|
|
74882
|
-
|
|
74882
|
+
h = Oe.HEADER_FIELD_START;
|
|
74883
74883
|
break;
|
|
74884
74884
|
case Oe.HEADERS_ALMOST_DONE:
|
|
74885
74885
|
if (b !== Uo) return;
|
|
74886
|
-
T("onHeadersEnd"),
|
|
74886
|
+
T("onHeadersEnd"), h = Oe.PART_DATA_START;
|
|
74887
74887
|
break;
|
|
74888
74888
|
case Oe.PART_DATA_START:
|
|
74889
|
-
|
|
74889
|
+
h = Oe.PART_DATA, p("onPartData");
|
|
74890
74890
|
case Oe.PART_DATA:
|
|
74891
|
-
if (o =
|
|
74891
|
+
if (o = d, d === 0) {
|
|
74892
74892
|
for (t += A; t < P && !(e[t] in l); ) t += g;
|
|
74893
74893
|
t -= A, b = e[t];
|
|
74894
74894
|
}
|
|
74895
|
-
if (
|
|
74896
|
-
else if (
|
|
74897
|
-
else if (
|
|
74898
|
-
if (
|
|
74899
|
-
|
|
74895
|
+
if (d < u.length) u[d] === b ? (d === 0 && w("onPartData", true), d++) : d = 0;
|
|
74896
|
+
else if (d === u.length) d++, b === Mo ? f |= Fr.PART_BOUNDARY : b === fs3 ? f |= Fr.LAST_BOUNDARY : d = 0;
|
|
74897
|
+
else if (d - 1 === u.length) if (f & Fr.PART_BOUNDARY) {
|
|
74898
|
+
if (d = 0, b === Uo) {
|
|
74899
|
+
f &= ~Fr.PART_BOUNDARY, T("onPartEnd"), T("onPartBegin"), h = Oe.HEADER_FIELD_START;
|
|
74900
74900
|
break;
|
|
74901
74901
|
}
|
|
74902
|
-
} else
|
|
74903
|
-
if (
|
|
74902
|
+
} else f & Fr.LAST_BOUNDARY && b === fs3 ? (T("onPartEnd"), h = Oe.END, f = 0) : d = 0;
|
|
74903
|
+
if (d > 0) i[d - 1] = b;
|
|
74904
74904
|
else if (o > 0) {
|
|
74905
74905
|
let S = new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
|
|
74906
74906
|
T("onPartData", 0, o, S), o = 0, p("onPartData"), t--;
|
|
@@ -74909,9 +74909,9 @@ var ah = Me(() => {
|
|
|
74909
74909
|
case Oe.END:
|
|
74910
74910
|
break;
|
|
74911
74911
|
default:
|
|
74912
|
-
throw new Error(`Unexpected state entered: ${
|
|
74912
|
+
throw new Error(`Unexpected state entered: ${h}`);
|
|
74913
74913
|
}
|
|
74914
|
-
|
|
74914
|
+
w("onHeaderField"), w("onHeaderValue"), w("onPartData"), this.index = d, this.state = h, this.flags = f;
|
|
74915
74915
|
}
|
|
74916
74916
|
end() {
|
|
74917
74917
|
if (this.state === Oe.HEADER_FIELD_START && this.index === 0 || this.state === Oe.PART_DATA && this.index === this.boundary.length) this.onPartEnd();
|
|
@@ -75264,18 +75264,18 @@ var Dh = Me(() => {
|
|
|
75264
75264
|
super(i, { size: t.size || e.size || 0 });
|
|
75265
75265
|
let u = new at(t.headers || e.headers || {});
|
|
75266
75266
|
if (i !== null && !u.has("Content-Type")) {
|
|
75267
|
-
let
|
|
75268
|
-
|
|
75267
|
+
let h = $o(i, this);
|
|
75268
|
+
h && u.set("Content-Type", h);
|
|
75269
75269
|
}
|
|
75270
75270
|
let l = hs(e) ? e.signal : null;
|
|
75271
75271
|
if ("signal" in t && (l = t.signal), l != null && !Jd(l)) throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
|
|
75272
|
-
let
|
|
75273
|
-
if (
|
|
75274
|
-
else if (
|
|
75275
|
-
let
|
|
75276
|
-
|
|
75277
|
-
} else
|
|
75278
|
-
this[We] = { method: o, redirect: t.redirect || e.redirect || "follow", headers: u, parsedURL: n, signal: l, referrer:
|
|
75272
|
+
let d = t.referrer == null ? e.referrer : t.referrer;
|
|
75273
|
+
if (d === "") d = "no-referrer";
|
|
75274
|
+
else if (d) {
|
|
75275
|
+
let h = new URL(d);
|
|
75276
|
+
d = /^about:(\/\/)?client$/.test(h) ? "client" : h;
|
|
75277
|
+
} else d = void 0;
|
|
75278
|
+
this[We] = { method: o, redirect: t.redirect || e.redirect || "follow", headers: u, parsedURL: n, signal: l, referrer: d }, this.follow = t.follow === void 0 ? e.follow === void 0 ? 20 : e.follow : t.follow, this.compress = t.compress === void 0 ? e.compress === void 0 ? true : e.compress : t.compress, this.counter = t.counter || e.counter || 0, this.agent = t.agent || e.agent, this.highWaterMark = t.highWaterMark || e.highWaterMark || 16384, this.insecureHTTPParser = t.insecureHTTPParser || e.insecureHTTPParser || false, this.referrerPolicy = t.referrerPolicy || e.referrerPolicy || "";
|
|
75279
75279
|
}
|
|
75280
75280
|
get method() {
|
|
75281
75281
|
return this[We].method;
|
|
@@ -75342,44 +75342,44 @@ async function Eu(r, e) {
|
|
|
75342
75342
|
let o = new Pr(r, e), { parsedURL: i, options: u } = Ah(o);
|
|
75343
75343
|
if (!V_.has(i.protocol)) throw new TypeError(`node-fetch cannot load ${r}. URL scheme "${i.protocol.replace(/:$/, "")}" is not supported.`);
|
|
75344
75344
|
if (i.protocol === "data:") {
|
|
75345
|
-
let b = Nd(o.url),
|
|
75346
|
-
t(
|
|
75345
|
+
let b = Nd(o.url), E = new dt(b, { headers: { "Content-Type": b.typeFull } });
|
|
75346
|
+
t(E);
|
|
75347
75347
|
return;
|
|
75348
75348
|
}
|
|
75349
|
-
let l = (i.protocol === "https:" ? import_node_https.default : import_node_http2.default).request, { signal:
|
|
75349
|
+
let l = (i.protocol === "https:" ? import_node_https.default : import_node_http2.default).request, { signal: d } = o, h = null, f = () => {
|
|
75350
75350
|
let b = new ps("The operation was aborted.");
|
|
75351
|
-
n(b), o.body && o.body instanceof import_node_stream2.default.Readable && o.body.destroy(b), !(!
|
|
75351
|
+
n(b), o.body && o.body instanceof import_node_stream2.default.Readable && o.body.destroy(b), !(!h || !h.body) && h.body.emit("error", b);
|
|
75352
75352
|
};
|
|
75353
|
-
if (
|
|
75354
|
-
|
|
75353
|
+
if (d && d.aborted) {
|
|
75354
|
+
f();
|
|
75355
75355
|
return;
|
|
75356
75356
|
}
|
|
75357
75357
|
let g = () => {
|
|
75358
|
-
|
|
75358
|
+
f(), P();
|
|
75359
75359
|
}, A = l(i.toString(), u);
|
|
75360
|
-
|
|
75360
|
+
d && d.addEventListener("abort", g);
|
|
75361
75361
|
let P = () => {
|
|
75362
|
-
A.abort(),
|
|
75362
|
+
A.abort(), d && d.removeEventListener("abort", g);
|
|
75363
75363
|
};
|
|
75364
75364
|
A.on("error", (b) => {
|
|
75365
75365
|
n(new et(`request to ${o.url} failed, reason: ${b.message}`, "system", b)), P();
|
|
75366
75366
|
}), K_(A, (b) => {
|
|
75367
|
-
|
|
75367
|
+
h && h.body && h.body.destroy(b);
|
|
75368
75368
|
}), process.version < "v14" && A.on("socket", (b) => {
|
|
75369
|
-
let
|
|
75369
|
+
let E;
|
|
75370
75370
|
b.prependListener("end", () => {
|
|
75371
|
-
|
|
75371
|
+
E = b._eventsCount;
|
|
75372
75372
|
}), b.prependListener("close", (p) => {
|
|
75373
|
-
if (
|
|
75373
|
+
if (h && E < b._eventsCount && !p) {
|
|
75374
75374
|
let y = new Error("Premature close");
|
|
75375
|
-
y.code = "ERR_STREAM_PREMATURE_CLOSE",
|
|
75375
|
+
y.code = "ERR_STREAM_PREMATURE_CLOSE", h.body.emit("error", y);
|
|
75376
75376
|
}
|
|
75377
75377
|
});
|
|
75378
75378
|
}), A.on("response", (b) => {
|
|
75379
75379
|
A.setTimeout(0);
|
|
75380
|
-
let
|
|
75380
|
+
let E = hh(b.rawHeaders);
|
|
75381
75381
|
if (ds(b.statusCode)) {
|
|
75382
|
-
let S =
|
|
75382
|
+
let S = E.get("Location"), F = null;
|
|
75383
75383
|
try {
|
|
75384
75384
|
F = S === null ? null : new URL(S, o.url);
|
|
75385
75385
|
} catch {
|
|
@@ -75407,7 +75407,7 @@ async function Eu(r, e) {
|
|
|
75407
75407
|
return;
|
|
75408
75408
|
}
|
|
75409
75409
|
(b.statusCode === 303 || (b.statusCode === 301 || b.statusCode === 302) && o.method === "POST") && (B.method = "GET", B.body = void 0, B.headers.delete("content-length"));
|
|
75410
|
-
let G = wh(
|
|
75410
|
+
let G = wh(E);
|
|
75411
75411
|
G && (B.referrerPolicy = G), t(Eu(new Pr(F, B))), P();
|
|
75412
75412
|
return;
|
|
75413
75413
|
}
|
|
@@ -75415,23 +75415,23 @@ async function Eu(r, e) {
|
|
|
75415
75415
|
return n(new TypeError(`Redirect option '${o.redirect}' is not a valid value of RequestRedirect`));
|
|
75416
75416
|
}
|
|
75417
75417
|
}
|
|
75418
|
-
|
|
75419
|
-
|
|
75418
|
+
d && b.once("end", () => {
|
|
75419
|
+
d.removeEventListener("abort", g);
|
|
75420
75420
|
});
|
|
75421
75421
|
let p = (0, import_node_stream2.pipeline)(b, new import_node_stream2.PassThrough(), (S) => {
|
|
75422
75422
|
S && n(S);
|
|
75423
75423
|
});
|
|
75424
75424
|
process.version < "v12.10" && b.on("aborted", g);
|
|
75425
|
-
let y = { url: o.url, status: b.statusCode, statusText: b.statusMessage, headers:
|
|
75425
|
+
let y = { url: o.url, status: b.statusCode, statusText: b.statusMessage, headers: E, size: o.size, counter: o.counter, highWaterMark: o.highWaterMark }, T = E.get("Content-Encoding");
|
|
75426
75426
|
if (!o.compress || o.method === "HEAD" || T === null || b.statusCode === 204 || b.statusCode === 304) {
|
|
75427
|
-
|
|
75427
|
+
h = new dt(p, y), t(h);
|
|
75428
75428
|
return;
|
|
75429
75429
|
}
|
|
75430
|
-
let
|
|
75430
|
+
let w = { flush: import_node_zlib.default.Z_SYNC_FLUSH, finishFlush: import_node_zlib.default.Z_SYNC_FLUSH };
|
|
75431
75431
|
if (T === "gzip" || T === "x-gzip") {
|
|
75432
|
-
p = (0, import_node_stream2.pipeline)(p, import_node_zlib.default.createGunzip(
|
|
75432
|
+
p = (0, import_node_stream2.pipeline)(p, import_node_zlib.default.createGunzip(w), (S) => {
|
|
75433
75433
|
S && n(S);
|
|
75434
|
-
}),
|
|
75434
|
+
}), h = new dt(p, y), t(h);
|
|
75435
75435
|
return;
|
|
75436
75436
|
}
|
|
75437
75437
|
if (T === "deflate" || T === "x-deflate") {
|
|
@@ -75443,19 +75443,19 @@ async function Eu(r, e) {
|
|
|
75443
75443
|
B && n(B);
|
|
75444
75444
|
}) : p = (0, import_node_stream2.pipeline)(p, import_node_zlib.default.createInflateRaw(), (B) => {
|
|
75445
75445
|
B && n(B);
|
|
75446
|
-
}),
|
|
75446
|
+
}), h = new dt(p, y), t(h);
|
|
75447
75447
|
}), S.once("end", () => {
|
|
75448
|
-
|
|
75448
|
+
h || (h = new dt(p, y), t(h));
|
|
75449
75449
|
});
|
|
75450
75450
|
return;
|
|
75451
75451
|
}
|
|
75452
75452
|
if (T === "br") {
|
|
75453
75453
|
p = (0, import_node_stream2.pipeline)(p, import_node_zlib.default.createBrotliDecompress(), (S) => {
|
|
75454
75454
|
S && n(S);
|
|
75455
|
-
}),
|
|
75455
|
+
}), h = new dt(p, y), t(h);
|
|
75456
75456
|
return;
|
|
75457
75457
|
}
|
|
75458
|
-
|
|
75458
|
+
h = new dt(p, y), t(h);
|
|
75459
75459
|
}), fh(A, o).catch(n);
|
|
75460
75460
|
});
|
|
75461
75461
|
}
|
|
@@ -75469,14 +75469,14 @@ function K_(r, e) {
|
|
|
75469
75469
|
}), r.on("socket", (u) => {
|
|
75470
75470
|
let l = () => {
|
|
75471
75471
|
if (n && !o) {
|
|
75472
|
-
let
|
|
75473
|
-
|
|
75472
|
+
let h = new Error("Premature close");
|
|
75473
|
+
h.code = "ERR_STREAM_PREMATURE_CLOSE", e(h);
|
|
75474
75474
|
}
|
|
75475
|
-
},
|
|
75476
|
-
o = import_node_buffer2.Buffer.compare(
|
|
75475
|
+
}, d = (h) => {
|
|
75476
|
+
o = import_node_buffer2.Buffer.compare(h.slice(-5), t) === 0, !o && i && (o = import_node_buffer2.Buffer.compare(i.slice(-3), t.slice(0, 3)) === 0 && import_node_buffer2.Buffer.compare(h.slice(-2), t.slice(3)) === 0), i = h;
|
|
75477
75477
|
};
|
|
75478
|
-
u.prependListener("close", l), u.on("data",
|
|
75479
|
-
u.removeListener("close", l), u.removeListener("data",
|
|
75478
|
+
u.prependListener("close", l), u.on("data", d), r.on("close", () => {
|
|
75479
|
+
u.removeListener("close", l), u.removeListener("data", d);
|
|
75480
75480
|
});
|
|
75481
75481
|
});
|
|
75482
75482
|
}
|
|
@@ -75597,7 +75597,7 @@ var Ph = z((Fn) => {
|
|
|
75597
75597
|
n.url = n.url + l + u;
|
|
75598
75598
|
} else {
|
|
75599
75599
|
let u = n.url instanceof URL ? n.url : new URL(n.url);
|
|
75600
|
-
for (let [l,
|
|
75600
|
+
for (let [l, d] of new URLSearchParams(n.params)) u.searchParams.append(l, d);
|
|
75601
75601
|
n.url = u;
|
|
75602
75602
|
}
|
|
75603
75603
|
typeof e.maxContentLength == "number" && (n.size = e.maxContentLength), typeof e.maxRedirects == "number" && (n.follow = e.maxRedirects);
|
|
@@ -75700,7 +75700,7 @@ var ze = z((tt) => {
|
|
|
75700
75700
|
var wu = z((Bh, Ko) => {
|
|
75701
75701
|
(function(r) {
|
|
75702
75702
|
"use strict";
|
|
75703
|
-
var e, t = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, n = Math.ceil, o = Math.floor, i = "[BigNumber Error] ", u = i + "Number primitive has more than 15 significant digits: ", l = 1e14,
|
|
75703
|
+
var e, t = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, n = Math.ceil, o = Math.floor, i = "[BigNumber Error] ", u = i + "Number primitive has more than 15 significant digits: ", l = 1e14, d = 14, h = 9007199254740991, f = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], g = 1e7, A = 1e9;
|
|
75704
75704
|
function P(F) {
|
|
75705
75705
|
var B, G, Z, H = W.prototype = { constructor: W, toString: null, valueOf: null }, ae = new W(1), de = 20, fe = 4, Ee = -7, Ce = 21, Ae = -1e7, oe = 1e7, he = false, J = 1, V = 0, se = { prefix: "", groupSize: 3, secondaryGroupSize: 0, groupSeparator: ",", decimalSeparator: ".", fractionGroupSize: 0, fractionGroupSeparator: "\xA0", suffix: "" }, Ue = "0123456789abcdefghijklmnopqrstuvwxyz", ve = true;
|
|
75706
75706
|
function W(m, C) {
|
|
@@ -75746,13 +75746,13 @@ var wu = z((Bh, Ko) => {
|
|
|
75746
75746
|
for (L = 0; q.charCodeAt(L) === 48; L++) ;
|
|
75747
75747
|
for (O = q.length; q.charCodeAt(--O) === 48; ) ;
|
|
75748
75748
|
if (q = q.slice(L, ++O)) {
|
|
75749
|
-
if (O -= L, R && W.DEBUG && O > 15 && (m >
|
|
75749
|
+
if (O -= L, R && W.DEBUG && O > 15 && (m > h || m !== o(m))) throw Error(u + I.s * m);
|
|
75750
75750
|
if ((x = x - L - 1) > oe) I.c = I.e = null;
|
|
75751
75751
|
else if (x < Ae) I.c = [I.e = 0];
|
|
75752
75752
|
else {
|
|
75753
|
-
if (I.e = x, I.c = [], L = (x + 1) %
|
|
75754
|
-
for (L && I.c.push(+q.slice(0, L)), O -=
|
|
75755
|
-
L =
|
|
75753
|
+
if (I.e = x, I.c = [], L = (x + 1) % d, x < 0 && (L += d), L < O) {
|
|
75754
|
+
for (L && I.c.push(+q.slice(0, L)), O -= d; L < O; ) I.c.push(+q.slice(L, L += d));
|
|
75755
|
+
L = d - (q = q.slice(L)).length;
|
|
75756
75756
|
} else L -= O;
|
|
75757
75757
|
for (; L--; q += "0") ;
|
|
75758
75758
|
I.c.push(+q);
|
|
@@ -75785,7 +75785,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75785
75785
|
if (k === 0 && N.length === 1) return true;
|
|
75786
75786
|
break e;
|
|
75787
75787
|
}
|
|
75788
|
-
if (C = (k + 1) %
|
|
75788
|
+
if (C = (k + 1) % d, C < 1 && (C += d), String(N[0]).length == C) {
|
|
75789
75789
|
for (C = 0; C < N.length; C++) if (D = N[C], D < 0 || D >= l || D !== o(D)) break e;
|
|
75790
75790
|
if (D !== 0) return true;
|
|
75791
75791
|
}
|
|
@@ -75804,7 +75804,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75804
75804
|
};
|
|
75805
75805
|
return function(D) {
|
|
75806
75806
|
var N, k, x, L, R, O = 0, q = [], I = new W(ae);
|
|
75807
|
-
if (D == null ? D = de : y(D, 0, A), L = n(D /
|
|
75807
|
+
if (D == null ? D = de : y(D, 0, A), L = n(D / d), he) if (crypto.getRandomValues) {
|
|
75808
75808
|
for (N = crypto.getRandomValues(new Uint32Array(L *= 2)); O < L; ) R = N[O] * 131072 + (N[O + 1] >>> 11), R >= 9e15 ? (k = crypto.getRandomValues(new Uint32Array(2)), N[O] = k[0], N[O + 1] = k[1]) : (q.push(R % 1e14), O += 2);
|
|
75809
75809
|
O = L / 2;
|
|
75810
75810
|
} else if (crypto.randomBytes) {
|
|
@@ -75812,12 +75812,12 @@ var wu = z((Bh, Ko) => {
|
|
|
75812
75812
|
O = L / 7;
|
|
75813
75813
|
} else throw he = false, Error(i + "crypto unavailable");
|
|
75814
75814
|
if (!he) for (; O < L; ) R = C(), R < 9e15 && (q[O++] = R % 1e14);
|
|
75815
|
-
for (L = q[--O], D %=
|
|
75815
|
+
for (L = q[--O], D %= d, L && D && (R = f[d - D], q[O] = o(L / R) * R); q[O] === 0; q.pop(), O--) ;
|
|
75816
75816
|
if (O < 0) q = [x = 0];
|
|
75817
75817
|
else {
|
|
75818
|
-
for (x = -1; q[0] === 0; q.splice(0, 1), x -=
|
|
75818
|
+
for (x = -1; q[0] === 0; q.splice(0, 1), x -= d) ;
|
|
75819
75819
|
for (O = 1, R = q[0]; R >= 10; R /= 10, O++) ;
|
|
75820
|
-
O <
|
|
75820
|
+
O < d && (x -= d - O);
|
|
75821
75821
|
}
|
|
75822
75822
|
return I.e = x, I.c = q, I;
|
|
75823
75823
|
};
|
|
@@ -75835,7 +75835,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75835
75835
|
}
|
|
75836
75836
|
return function(D, N, k, x, L) {
|
|
75837
75837
|
var R, O, q, I, M, Y, Q, we, Pe = D.indexOf("."), Ie = de, be = fe;
|
|
75838
|
-
for (Pe >= 0 && (I = V, V = 0, D = D.replace(".", ""), we = new W(N), Y = we.pow(D.length - Pe), V = I, we.c = C(S(
|
|
75838
|
+
for (Pe >= 0 && (I = V, V = 0, D = D.replace(".", ""), we = new W(N), Y = we.pow(D.length - Pe), V = I, we.c = C(S(E(Y.c), Y.e, "0"), 10, k, m), we.e = we.c.length), Q = C(D, N, k, L ? (R = Ue, m) : (R = m, Ue)), q = I = Q.length; Q[--I] == 0; Q.pop()) ;
|
|
75839
75839
|
if (!Q[0]) return R.charAt(0);
|
|
75840
75840
|
if (Pe < 0 ? --q : (Y.c = Q, Y.e = q, Y.s = x, Y = B(Y, we, Ie, be, k), Q = Y.c, M = Y.r, q = Y.e), O = q + Ie + 1, Pe = Q[O], I = k / 2, M = M || O < 0 || Q[O + 1] != null, M = be < 4 ? (Pe != null || M) && (be == 0 || be == (Y.s < 0 ? 3 : 2)) : Pe > I || Pe == I && (be == 4 || M || be == 6 && Q[O - 1] & 1 || be == (Y.s < 0 ? 8 : 7)), O < 1 || !Q[0]) D = M ? S(R.charAt(1), -Ie, R.charAt(0)) : R.charAt(0);
|
|
75841
75841
|
else {
|
|
@@ -75868,7 +75868,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75868
75868
|
return function(N, k, x, L, R) {
|
|
75869
75869
|
var O, q, I, M, Y, Q, we, Pe, Ie, be, De, je, sn, on, an, ct, rr, Ve = N.s == k.s ? 1 : -1, Le = N.c, Se = k.c;
|
|
75870
75870
|
if (!Le || !Le[0] || !Se || !Se[0]) return new W(!N.s || !k.s || (Le ? Se && Le[0] == Se[0] : !Se) ? NaN : Le && Le[0] == 0 || !Se ? Ve * 0 : Ve / 0);
|
|
75871
|
-
for (Pe = new W(Ve), Ie = Pe.c = [], q = N.e - k.e, Ve = x + q + 1, R || (R = l, q = b(N.e /
|
|
75871
|
+
for (Pe = new W(Ve), Ie = Pe.c = [], q = N.e - k.e, Ve = x + q + 1, R || (R = l, q = b(N.e / d) - b(k.e / d), Ve = Ve / d | 0), I = 0; Se[I] == (Le[I] || 0); I++) ;
|
|
75872
75872
|
if (Se[I] > (Le[I] || 0) && q--, Ve < 0) Ie.push(1), M = true;
|
|
75873
75873
|
else {
|
|
75874
75874
|
for (on = Le.length, ct = Se.length, I = 0, Ve += 2, Y = o(R / (Se[0] + 1)), Y > 1 && (Se = m(Se, Y, R), Le = m(Le, Y, R), ct = Se.length, on = Le.length), sn = ct, be = Le.slice(0, ct), De = be.length; De < ct; be[De++] = 0) ;
|
|
@@ -75885,7 +75885,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75885
75885
|
}
|
|
75886
75886
|
if (R == l) {
|
|
75887
75887
|
for (I = 1, Ve = Ie[0]; Ve >= 10; Ve /= 10, I++) ;
|
|
75888
|
-
ke(Pe, x + (Pe.e = I + q *
|
|
75888
|
+
ke(Pe, x + (Pe.e = I + q * d - 1) + 1, L, M);
|
|
75889
75889
|
} else Pe.e = q, Pe.r = +M;
|
|
75890
75890
|
return Pe;
|
|
75891
75891
|
};
|
|
@@ -75893,10 +75893,10 @@ var wu = z((Bh, Ko) => {
|
|
|
75893
75893
|
function ue(m, C, D, N) {
|
|
75894
75894
|
var k, x, L, R, O;
|
|
75895
75895
|
if (D == null ? D = fe : y(D, 0, 8), !m.c) return m.toString();
|
|
75896
|
-
if (k = m.c[0], L = m.e, C == null) O =
|
|
75897
|
-
else if (m = ke(new W(m), C, D), x = m.e, O =
|
|
75896
|
+
if (k = m.c[0], L = m.e, C == null) O = E(m.c), O = N == 1 || N == 2 && (L <= Ee || L >= Ce) ? w(O, L) : S(O, L, "0");
|
|
75897
|
+
else if (m = ke(new W(m), C, D), x = m.e, O = E(m.c), R = O.length, N == 1 || N == 2 && (C <= x || x <= Ee)) {
|
|
75898
75898
|
for (; R < C; O += "0", R++) ;
|
|
75899
|
-
O =
|
|
75899
|
+
O = w(O, x);
|
|
75900
75900
|
} else if (C -= L + (N === 2 && x > L), O = S(O, x, "0"), x + 1 > R) {
|
|
75901
75901
|
if (--C > 0) for (O += "."; C--; O += "0") ;
|
|
75902
75902
|
} else if (C += x - R, C > 0) for (x + 1 == R && (O += "."); C--; O += "0") ;
|
|
@@ -75909,7 +75909,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75909
75909
|
function ut(m, C, D) {
|
|
75910
75910
|
for (var N = 1, k = C.length; !C[--k]; C.pop()) ;
|
|
75911
75911
|
for (k = C[0]; k >= 10; k /= 10, N++) ;
|
|
75912
|
-
return (D = N + D *
|
|
75912
|
+
return (D = N + D * d - 1) > oe ? m.c = m.e = null : D < Ae ? m.c = [m.e = 0] : (m.e = D, m.c = C), m;
|
|
75913
75913
|
}
|
|
75914
75914
|
Z = /* @__PURE__ */ (function() {
|
|
75915
75915
|
var m = /^(-?)0([xbo])(?=\w[\w.]*$)/i, C = /^([^.]+)\.$/, D = /^\.([^.]+)$/, N = /^-?(Infinity|NaN)$/, k = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
@@ -75927,21 +75927,21 @@ var wu = z((Bh, Ko) => {
|
|
|
75927
75927
|
};
|
|
75928
75928
|
})();
|
|
75929
75929
|
function ke(m, C, D, N) {
|
|
75930
|
-
var k, x, L, R, O, q, I, M = m.c, Y =
|
|
75930
|
+
var k, x, L, R, O, q, I, M = m.c, Y = f;
|
|
75931
75931
|
if (M) {
|
|
75932
75932
|
e: {
|
|
75933
75933
|
for (k = 1, R = M[0]; R >= 10; R /= 10, k++) ;
|
|
75934
|
-
if (x = C - k, x < 0) x +=
|
|
75935
|
-
else if (q = n((x + 1) /
|
|
75934
|
+
if (x = C - k, x < 0) x += d, L = C, O = M[q = 0], I = o(O / Y[k - L - 1] % 10);
|
|
75935
|
+
else if (q = n((x + 1) / d), q >= M.length) if (N) {
|
|
75936
75936
|
for (; M.length <= q; M.push(0)) ;
|
|
75937
|
-
O = I = 0, k = 1, x %=
|
|
75937
|
+
O = I = 0, k = 1, x %= d, L = x - d + 1;
|
|
75938
75938
|
} else break e;
|
|
75939
75939
|
else {
|
|
75940
75940
|
for (O = R = M[q], k = 1; R >= 10; R /= 10, k++) ;
|
|
75941
|
-
x %=
|
|
75941
|
+
x %= d, L = x - d + k, I = L < 0 ? 0 : o(O / Y[k - L - 1] % 10);
|
|
75942
75942
|
}
|
|
75943
|
-
if (N = N || C < 0 || M[q + 1] != null || (L < 0 ? O : O % Y[k - L - 1]), N = D < 4 ? (I || N) && (D == 0 || D == (m.s < 0 ? 3 : 2)) : I > 5 || I == 5 && (D == 4 || N || D == 6 && (x > 0 ? L > 0 ? O / Y[k - L] : 0 : M[q - 1]) % 10 & 1 || D == (m.s < 0 ? 8 : 7)), C < 1 || !M[0]) return M.length = 0, N ? (C -= m.e + 1, M[0] = Y[(
|
|
75944
|
-
if (x == 0 ? (M.length = q, R = 1, q--) : (M.length = q + 1, R = Y[
|
|
75943
|
+
if (N = N || C < 0 || M[q + 1] != null || (L < 0 ? O : O % Y[k - L - 1]), N = D < 4 ? (I || N) && (D == 0 || D == (m.s < 0 ? 3 : 2)) : I > 5 || I == 5 && (D == 4 || N || D == 6 && (x > 0 ? L > 0 ? O / Y[k - L] : 0 : M[q - 1]) % 10 & 1 || D == (m.s < 0 ? 8 : 7)), C < 1 || !M[0]) return M.length = 0, N ? (C -= m.e + 1, M[0] = Y[(d - C % d) % d], m.e = -C || 0) : M[0] = m.e = 0, m;
|
|
75944
|
+
if (x == 0 ? (M.length = q, R = 1, q--) : (M.length = q + 1, R = Y[d - x], M[q] = L > 0 ? o(O / Y[k - L] % Y[L]) * R : 0), N) for (; ; ) if (q == 0) {
|
|
75945
75945
|
for (x = 1, L = M[0]; L >= 10; L /= 10, x++) ;
|
|
75946
75946
|
for (L = M[0] += R, R = 1; L >= 10; L /= 10, R++) ;
|
|
75947
75947
|
x != R && (m.e++, M[0] == l && (M[0] = 1));
|
|
@@ -75958,7 +75958,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75958
75958
|
}
|
|
75959
75959
|
function Ne(m) {
|
|
75960
75960
|
var C, D = m.e;
|
|
75961
|
-
return D === null ? m.toString() : (C =
|
|
75961
|
+
return D === null ? m.toString() : (C = E(m.c), C = D <= Ee || D >= Ce ? w(C, D) : S(C, D, "0"), m.s < 0 ? "-" + C : C);
|
|
75962
75962
|
}
|
|
75963
75963
|
return H.absoluteValue = H.abs = function() {
|
|
75964
75964
|
var m = new W(this);
|
|
@@ -75969,7 +75969,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75969
75969
|
var D, N, k, x = this;
|
|
75970
75970
|
if (m != null) return y(m, 0, A), C == null ? C = fe : y(C, 0, 8), ke(new W(x), m + x.e + 1, C);
|
|
75971
75971
|
if (!(D = x.c)) return null;
|
|
75972
|
-
if (N = ((k = D.length - 1) - b(this.e /
|
|
75972
|
+
if (N = ((k = D.length - 1) - b(this.e / d)) * d, k = D[k]) for (; k % 10 == 0; k /= 10, N--) ;
|
|
75973
75973
|
return N < 0 && (N = 0), N;
|
|
75974
75974
|
}, H.dividedBy = H.div = function(m, C) {
|
|
75975
75975
|
return B(this, new W(m, C), de, fe);
|
|
@@ -75984,7 +75984,7 @@ var wu = z((Bh, Ko) => {
|
|
|
75984
75984
|
N = !O && M.isInteger() && C.isInteger(), N && (M = M.mod(C));
|
|
75985
75985
|
} else {
|
|
75986
75986
|
if (m.e > 9 && (M.e > 0 || M.e < -1 || (M.e == 0 ? M.c[0] > 1 || R && M.c[1] >= 24e7 : M.c[0] < 8e13 || R && M.c[0] <= 9999975e7))) return x = M.s < 0 && T(m) ? -0 : 0, M.e > -1 && (x = 1 / x), new W(O ? 1 / x : x);
|
|
75987
|
-
V && (x = n(V /
|
|
75987
|
+
V && (x = n(V / d + 2));
|
|
75988
75988
|
}
|
|
75989
75989
|
for (R ? (D = new W(0.5), O && (m.s = 1), q = T(m)) : (k = Math.abs(+Ne(m)), q = k % 2), I = new W(ae); ; ) {
|
|
75990
75990
|
if (q) {
|
|
@@ -76014,7 +76014,7 @@ var wu = z((Bh, Ko) => {
|
|
|
76014
76014
|
}, H.isGreaterThanOrEqualTo = H.gte = function(m, C) {
|
|
76015
76015
|
return (C = p(this, new W(m, C))) === 1 || C === 0;
|
|
76016
76016
|
}, H.isInteger = function() {
|
|
76017
|
-
return !!this.c && b(this.e /
|
|
76017
|
+
return !!this.c && b(this.e / d) > this.c.length - 2;
|
|
76018
76018
|
}, H.isLessThan = H.lt = function(m, C) {
|
|
76019
76019
|
return p(this, new W(m, C)) < 0;
|
|
76020
76020
|
}, H.isLessThanOrEqualTo = H.lte = function(m, C) {
|
|
@@ -76031,7 +76031,7 @@ var wu = z((Bh, Ko) => {
|
|
|
76031
76031
|
var D, N, k, x, L = this, R = L.s;
|
|
76032
76032
|
if (m = new W(m, C), C = m.s, !R || !C) return new W(NaN);
|
|
76033
76033
|
if (R != C) return m.s = -C, L.plus(m);
|
|
76034
|
-
var O = L.e /
|
|
76034
|
+
var O = L.e / d, q = m.e / d, I = L.c, M = m.c;
|
|
76035
76035
|
if (!O || !q) {
|
|
76036
76036
|
if (!I || !M) return I ? (m.s = -C, m) : new W(M ? L : NaN);
|
|
76037
76037
|
if (!I[0] || !M[0]) return M[0] ? (m.s = -C, m) : new W(I[0] ? L : fe == 3 ? -0 : 0);
|
|
@@ -76059,7 +76059,7 @@ var wu = z((Bh, Ko) => {
|
|
|
76059
76059
|
}, H.multipliedBy = H.times = function(m, C) {
|
|
76060
76060
|
var D, N, k, x, L, R, O, q, I, M, Y, Q, we, Pe, Ie, be = this, De = be.c, je = (m = new W(m, C)).c;
|
|
76061
76061
|
if (!De || !je || !De[0] || !je[0]) return !be.s || !m.s || De && !De[0] && !je || je && !je[0] && !De ? m.c = m.e = m.s = null : (m.s *= be.s, !De || !je ? m.c = m.e = null : (m.c = [0], m.e = 0)), m;
|
|
76062
|
-
for (N = b(be.e /
|
|
76062
|
+
for (N = b(be.e / d) + b(m.e / d), m.s *= be.s, O = De.length, M = je.length, O < M && (we = De, De = je, je = we, k = O, O = M, M = k), k = O + M, we = []; k--; we.push(0)) ;
|
|
76063
76063
|
for (Pe = l, Ie = g, k = M; --k >= 0; ) {
|
|
76064
76064
|
for (D = 0, Y = je[k] % Ie, Q = je[k] / Ie | 0, L = O, x = k + L; x > k; ) q = De[--L] % Ie, I = De[L] / Ie | 0, R = Q * q + I * Y, q = Y * q + R % Ie * Ie + we[x] + D, D = (q / Pe | 0) + (R / Ie | 0) + Q * I, we[x--] = q % Pe;
|
|
76065
76065
|
we[x] = D;
|
|
@@ -76072,7 +76072,7 @@ var wu = z((Bh, Ko) => {
|
|
|
76072
76072
|
var D, N = this, k = N.s;
|
|
76073
76073
|
if (m = new W(m, C), C = m.s, !k || !C) return new W(NaN);
|
|
76074
76074
|
if (k != C) return m.s = -C, N.minus(m);
|
|
76075
|
-
var x = N.e /
|
|
76075
|
+
var x = N.e / d, L = m.e / d, R = N.c, O = m.c;
|
|
76076
76076
|
if (!x || !L) {
|
|
76077
76077
|
if (!R || !O) return new W(k / 0);
|
|
76078
76078
|
if (!R[0] || !O[0]) return O[0] ? m : new W(R[0] ? N : k * 0);
|
|
@@ -76087,18 +76087,18 @@ var wu = z((Bh, Ko) => {
|
|
|
76087
76087
|
var D, N, k, x = this;
|
|
76088
76088
|
if (m != null && m !== !!m) return y(m, 1, A), C == null ? C = fe : y(C, 0, 8), ke(new W(x), m, C);
|
|
76089
76089
|
if (!(D = x.c)) return null;
|
|
76090
|
-
if (k = D.length - 1, N = k *
|
|
76090
|
+
if (k = D.length - 1, N = k * d + 1, k = D[k]) {
|
|
76091
76091
|
for (; k % 10 == 0; k /= 10, N--) ;
|
|
76092
76092
|
for (k = D[0]; k >= 10; k /= 10, N++) ;
|
|
76093
76093
|
}
|
|
76094
76094
|
return m && x.e + 1 > N && (N = x.e + 1), N;
|
|
76095
76095
|
}, H.shiftedBy = function(m) {
|
|
76096
|
-
return y(m, -
|
|
76096
|
+
return y(m, -h, h), this.times("1e" + m);
|
|
76097
76097
|
}, H.squareRoot = H.sqrt = function() {
|
|
76098
76098
|
var m, C, D, N, k, x = this, L = x.c, R = x.s, O = x.e, q = de + 4, I = new W("0.5");
|
|
76099
76099
|
if (R !== 1 || !L || !L[0]) return new W(!R || R < 0 && (!L || L[0]) ? NaN : L ? x : 1 / 0);
|
|
76100
|
-
if (R = Math.sqrt(+Ne(x)), R == 0 || R == 1 / 0 ? (C =
|
|
76101
|
-
for (O = D.e, R = O + q, R < 3 && (R = 0); ; ) if (k = D, D = I.times(k.plus(B(x, k, q, 1))),
|
|
76100
|
+
if (R = Math.sqrt(+Ne(x)), R == 0 || R == 1 / 0 ? (C = E(L), (C.length + O) % 2 == 0 && (C += "0"), R = Math.sqrt(+C), O = b((O + 1) / 2) - (O < 0 || O % 2), R == 1 / 0 ? C = "5e" + O : (C = R.toExponential(), C = C.slice(0, C.indexOf("e") + 1) + O), D = new W(C)) : D = new W(R + ""), D.c[0]) {
|
|
76101
|
+
for (O = D.e, R = O + q, R < 3 && (R = 0); ; ) if (k = D, D = I.times(k.plus(B(x, k, q, 1))), E(k.c).slice(0, R) === (C = E(D.c)).slice(0, R)) if (D.e < O && --R, C = C.slice(R - 3, R + 1), C == "9999" || !N && C == "4999") {
|
|
76102
76102
|
if (!N && (ke(k, k.e + de + 2, 0), k.times(k).eq(x))) {
|
|
76103
76103
|
D = k;
|
|
76104
76104
|
break;
|
|
@@ -76131,7 +76131,7 @@ var wu = z((Bh, Ko) => {
|
|
|
76131
76131
|
var C, D, N, k, x, L, R, O, q, I, M, Y, Q = this, we = Q.c;
|
|
76132
76132
|
if (m != null && (R = new W(m), !R.isInteger() && (R.c || R.s !== 1) || R.lt(ae))) throw Error(i + "Argument " + (R.isInteger() ? "out of range: " : "not an integer: ") + Ne(R));
|
|
76133
76133
|
if (!we) return new W(Q);
|
|
76134
|
-
for (C = new W(ae), q = D = new W(ae), N = O = new W(ae), Y =
|
|
76134
|
+
for (C = new W(ae), q = D = new W(ae), N = O = new W(ae), Y = E(we), x = C.e = Y.length - Q.e - 1, C.c[0] = f[(L = x % d) < 0 ? d + L : L], m = !m || R.comparedTo(C) > 0 ? x > 0 ? C : q : R, L = oe, oe = 1 / 0, R = new W(Y), O.c[0] = 0; I = B(R, C, 0, 1), k = D.plus(I.times(N)), k.comparedTo(m) != 1; ) D = N, N = k, q = O.plus(I.times(k = q)), O = k, C = R.minus(I.times(k = C)), R = k;
|
|
76135
76135
|
return k = B(m.minus(D), N, 0, 1), O = O.plus(k.times(q)), D = D.plus(k.times(N)), O.s = q.s = Q.s, x = x * 2, M = B(q, N, x, fe).minus(Q).abs().comparedTo(B(O, D, x, fe).minus(Q).abs()) < 1 ? [q, N] : [O, D], oe = L, M;
|
|
76136
76136
|
}, H.toNumber = function() {
|
|
76137
76137
|
return +Ne(this);
|
|
@@ -76139,7 +76139,7 @@ var wu = z((Bh, Ko) => {
|
|
|
76139
76139
|
return m != null && y(m, 1, A), ue(this, m, C, 2);
|
|
76140
76140
|
}, H.toString = function(m) {
|
|
76141
76141
|
var C, D = this, N = D.s, k = D.e;
|
|
76142
|
-
return k === null ? N ? (C = "Infinity", N < 0 && (C = "-" + C)) : C = "NaN" : (m == null ? C = k <= Ee || k >= Ce ? E(
|
|
76142
|
+
return k === null ? N ? (C = "Infinity", N < 0 && (C = "-" + C)) : C = "NaN" : (m == null ? C = k <= Ee || k >= Ce ? w(E(D.c), k) : S(E(D.c), k, "0") : m === 10 && ve ? (D = ke(new W(D), de + k + 1, fe), C = S(E(D.c), D.e, "0")) : (y(m, 2, Ue.length, "Base"), C = G(S(E(D.c), k, "0"), 10, m, N, true)), N < 0 && D.c[0] && (C = "-" + C)), C;
|
|
76143
76143
|
}, H.valueOf = H.toJSON = function() {
|
|
76144
76144
|
return Ne(this);
|
|
76145
76145
|
}, H._isBigNumber = true, F != null && W.set(F), W;
|
|
@@ -76148,9 +76148,9 @@ var wu = z((Bh, Ko) => {
|
|
|
76148
76148
|
var B = F | 0;
|
|
76149
76149
|
return F > 0 || F === B ? B : B - 1;
|
|
76150
76150
|
}
|
|
76151
|
-
function
|
|
76151
|
+
function E(F) {
|
|
76152
76152
|
for (var B, G, Z = 1, H = F.length, ae = F[0] + ""; Z < H; ) {
|
|
76153
|
-
for (B = F[Z++] + "", G =
|
|
76153
|
+
for (B = F[Z++] + "", G = d - B.length; G--; B = "0" + B) ;
|
|
76154
76154
|
ae += B;
|
|
76155
76155
|
}
|
|
76156
76156
|
for (H = ae.length; ae.charCodeAt(--H) === 48; ) ;
|
|
@@ -76171,9 +76171,9 @@ var wu = z((Bh, Ko) => {
|
|
|
76171
76171
|
}
|
|
76172
76172
|
function T(F) {
|
|
76173
76173
|
var B = F.c.length - 1;
|
|
76174
|
-
return b(F.e /
|
|
76174
|
+
return b(F.e / d) == B && F.c[B] % 2 != 0;
|
|
76175
76175
|
}
|
|
76176
|
-
function
|
|
76176
|
+
function w(F, B) {
|
|
76177
76177
|
return (F.length > 1 ? F.charAt(0) + "." + F.slice(1) : F) + (B < 0 ? "e" : "e+") + B;
|
|
76178
76178
|
}
|
|
76179
76179
|
function S(F, B, G) {
|
|
@@ -76196,19 +76196,19 @@ var jh = z((FS, qh) => {
|
|
|
76196
76196
|
var Ih = wu(), Nh = qh.exports;
|
|
76197
76197
|
(function() {
|
|
76198
76198
|
"use strict";
|
|
76199
|
-
function r(
|
|
76200
|
-
return
|
|
76199
|
+
function r(h) {
|
|
76200
|
+
return h < 10 ? "0" + h : h;
|
|
76201
76201
|
}
|
|
76202
76202
|
var e = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, t = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, n, o, i = { "\b": "\\b", " ": "\\t", "\n": "\\n", "\f": "\\f", "\r": "\\r", '"': '\\"', "\\": "\\\\" }, u;
|
|
76203
|
-
function l(
|
|
76204
|
-
return t.lastIndex = 0, t.test(
|
|
76205
|
-
var g = i[
|
|
76206
|
-
return typeof g == "string" ? g : "\\u" + ("0000" +
|
|
76207
|
-
}) + '"' : '"' +
|
|
76208
|
-
}
|
|
76209
|
-
function
|
|
76210
|
-
var g, A, P, b,
|
|
76211
|
-
switch (y && typeof y == "object" && typeof y.toJSON == "function" && (y = y.toJSON(
|
|
76203
|
+
function l(h) {
|
|
76204
|
+
return t.lastIndex = 0, t.test(h) ? '"' + h.replace(t, function(f) {
|
|
76205
|
+
var g = i[f];
|
|
76206
|
+
return typeof g == "string" ? g : "\\u" + ("0000" + f.charCodeAt(0).toString(16)).slice(-4);
|
|
76207
|
+
}) + '"' : '"' + h + '"';
|
|
76208
|
+
}
|
|
76209
|
+
function d(h, f) {
|
|
76210
|
+
var g, A, P, b, E = n, p, y = f[h], T = y != null && (y instanceof Ih || Ih.isBigNumber(y));
|
|
76211
|
+
switch (y && typeof y == "object" && typeof y.toJSON == "function" && (y = y.toJSON(h)), typeof u == "function" && (y = u.call(f, h, y)), typeof y) {
|
|
76212
76212
|
case "string":
|
|
76213
76213
|
return T ? y : l(y);
|
|
76214
76214
|
case "number":
|
|
@@ -76220,29 +76220,29 @@ var jh = z((FS, qh) => {
|
|
|
76220
76220
|
case "object":
|
|
76221
76221
|
if (!y) return "null";
|
|
76222
76222
|
if (n += o, p = [], Object.prototype.toString.apply(y) === "[object Array]") {
|
|
76223
|
-
for (b = y.length, g = 0; g < b; g += 1) p[g] =
|
|
76223
|
+
for (b = y.length, g = 0; g < b; g += 1) p[g] = d(g, y) || "null";
|
|
76224
76224
|
return P = p.length === 0 ? "[]" : n ? `[
|
|
76225
76225
|
` + n + p.join(`,
|
|
76226
76226
|
` + n) + `
|
|
76227
|
-
` +
|
|
76227
|
+
` + E + "]" : "[" + p.join(",") + "]", n = E, P;
|
|
76228
76228
|
}
|
|
76229
|
-
if (u && typeof u == "object") for (b = u.length, g = 0; g < b; g += 1) typeof u[g] == "string" && (A = u[g], P =
|
|
76230
|
-
else Object.keys(y).forEach(function(
|
|
76231
|
-
var S =
|
|
76232
|
-
S && p.push(l(
|
|
76229
|
+
if (u && typeof u == "object") for (b = u.length, g = 0; g < b; g += 1) typeof u[g] == "string" && (A = u[g], P = d(A, y), P && p.push(l(A) + (n ? ": " : ":") + P));
|
|
76230
|
+
else Object.keys(y).forEach(function(w) {
|
|
76231
|
+
var S = d(w, y);
|
|
76232
|
+
S && p.push(l(w) + (n ? ": " : ":") + S);
|
|
76233
76233
|
});
|
|
76234
76234
|
return P = p.length === 0 ? "{}" : n ? `{
|
|
76235
76235
|
` + n + p.join(`,
|
|
76236
76236
|
` + n) + `
|
|
76237
|
-
` +
|
|
76237
|
+
` + E + "}" : "{" + p.join(",") + "}", n = E, P;
|
|
76238
76238
|
}
|
|
76239
76239
|
}
|
|
76240
|
-
typeof Nh.stringify != "function" && (Nh.stringify = function(
|
|
76240
|
+
typeof Nh.stringify != "function" && (Nh.stringify = function(h, f, g) {
|
|
76241
76241
|
var A;
|
|
76242
76242
|
if (n = "", o = "", typeof g == "number") for (A = 0; A < g; A += 1) o += " ";
|
|
76243
76243
|
else typeof g == "string" && (o = g);
|
|
76244
|
-
if (u =
|
|
76245
|
-
return
|
|
76244
|
+
if (u = f, f && typeof f != "function" && (typeof f != "object" || typeof f.length != "number")) throw new Error("JSON.stringify");
|
|
76245
|
+
return d("", { "": h });
|
|
76246
76246
|
});
|
|
76247
76247
|
})();
|
|
76248
76248
|
});
|
|
@@ -76257,32 +76257,32 @@ var Uh = z((OS, Lh) => {
|
|
|
76257
76257
|
else throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${r.protoAction}`);
|
|
76258
76258
|
}
|
|
76259
76259
|
var t, n, o = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: `
|
|
76260
|
-
`, r: "\r", t: " " }, i, u = function(
|
|
76261
|
-
throw { name: "SyntaxError", message:
|
|
76262
|
-
}, l = function(
|
|
76263
|
-
return
|
|
76264
|
-
},
|
|
76265
|
-
var
|
|
76260
|
+
`, r: "\r", t: " " }, i, u = function(E) {
|
|
76261
|
+
throw { name: "SyntaxError", message: E, at: t, text: i };
|
|
76262
|
+
}, l = function(E) {
|
|
76263
|
+
return E && E !== n && u("Expected '" + E + "' instead of '" + n + "'"), n = i.charAt(t), t += 1, n;
|
|
76264
|
+
}, d = function() {
|
|
76265
|
+
var E, p = "";
|
|
76266
76266
|
for (n === "-" && (p = "-", l("-")); n >= "0" && n <= "9"; ) p += n, l();
|
|
76267
76267
|
if (n === ".") for (p += "."; l() && n >= "0" && n <= "9"; ) p += n;
|
|
76268
76268
|
if (n === "e" || n === "E") for (p += n, l(), (n === "-" || n === "+") && (p += n, l()); n >= "0" && n <= "9"; ) p += n, l();
|
|
76269
|
-
if (
|
|
76270
|
-
else return Yo == null && (Yo = wu()), p.length > 15 ? e.storeAsString ? p : e.useNativeBigInt ? BigInt(p) : new Yo(p) : e.alwaysParseAsBig ? e.useNativeBigInt ? BigInt(
|
|
76271
|
-
},
|
|
76272
|
-
var
|
|
76273
|
-
if (n === '"') for (var
|
|
76274
|
-
if (n === '"') return t - 1 >
|
|
76269
|
+
if (E = +p, !isFinite(E)) u("Bad number");
|
|
76270
|
+
else return Yo == null && (Yo = wu()), p.length > 15 ? e.storeAsString ? p : e.useNativeBigInt ? BigInt(p) : new Yo(p) : e.alwaysParseAsBig ? e.useNativeBigInt ? BigInt(E) : new Yo(E) : E;
|
|
76271
|
+
}, h = function() {
|
|
76272
|
+
var E, p, y = "", T;
|
|
76273
|
+
if (n === '"') for (var w = t; l(); ) {
|
|
76274
|
+
if (n === '"') return t - 1 > w && (y += i.substring(w, t - 1)), l(), y;
|
|
76275
76275
|
if (n === "\\") {
|
|
76276
|
-
if (t - 1 >
|
|
76277
|
-
for (T = 0, p = 0; p < 4 && (
|
|
76276
|
+
if (t - 1 > w && (y += i.substring(w, t - 1)), l(), n === "u") {
|
|
76277
|
+
for (T = 0, p = 0; p < 4 && (E = parseInt(l(), 16), !!isFinite(E)); p += 1) T = T * 16 + E;
|
|
76278
76278
|
y += String.fromCharCode(T);
|
|
76279
76279
|
} else if (typeof o[n] == "string") y += o[n];
|
|
76280
76280
|
else break;
|
|
76281
|
-
|
|
76281
|
+
w = t;
|
|
76282
76282
|
}
|
|
76283
76283
|
}
|
|
76284
76284
|
u("Bad string");
|
|
76285
|
-
},
|
|
76285
|
+
}, f = function() {
|
|
76286
76286
|
for (; n && n <= " "; ) l();
|
|
76287
76287
|
}, g = function() {
|
|
76288
76288
|
switch (n) {
|
|
@@ -76295,46 +76295,46 @@ var Uh = z((OS, Lh) => {
|
|
|
76295
76295
|
}
|
|
76296
76296
|
u("Unexpected '" + n + "'");
|
|
76297
76297
|
}, A, P = function() {
|
|
76298
|
-
var
|
|
76298
|
+
var E = [];
|
|
76299
76299
|
if (n === "[") {
|
|
76300
|
-
if (l("["),
|
|
76300
|
+
if (l("["), f(), n === "]") return l("]"), E;
|
|
76301
76301
|
for (; n; ) {
|
|
76302
|
-
if (
|
|
76303
|
-
l(","),
|
|
76302
|
+
if (E.push(A()), f(), n === "]") return l("]"), E;
|
|
76303
|
+
l(","), f();
|
|
76304
76304
|
}
|
|
76305
76305
|
}
|
|
76306
76306
|
u("Bad array");
|
|
76307
76307
|
}, b = function() {
|
|
76308
|
-
var
|
|
76308
|
+
var E, p = /* @__PURE__ */ Object.create(null);
|
|
76309
76309
|
if (n === "{") {
|
|
76310
|
-
if (l("{"),
|
|
76310
|
+
if (l("{"), f(), n === "}") return l("}"), p;
|
|
76311
76311
|
for (; n; ) {
|
|
76312
|
-
if (
|
|
76313
|
-
l(","),
|
|
76312
|
+
if (E = h(), f(), l(":"), e.strict === true && Object.hasOwnProperty.call(p, E) && u('Duplicate key "' + E + '"'), oC.test(E) === true ? e.protoAction === "error" ? u("Object contains forbidden prototype property") : e.protoAction === "ignore" ? A() : p[E] = A() : iC.test(E) === true ? e.constructorAction === "error" ? u("Object contains forbidden constructor property") : e.constructorAction === "ignore" ? A() : p[E] = A() : p[E] = A(), f(), n === "}") return l("}"), p;
|
|
76313
|
+
l(","), f();
|
|
76314
76314
|
}
|
|
76315
76315
|
}
|
|
76316
76316
|
u("Bad object");
|
|
76317
76317
|
};
|
|
76318
76318
|
return A = function() {
|
|
76319
|
-
switch (
|
|
76319
|
+
switch (f(), n) {
|
|
76320
76320
|
case "{":
|
|
76321
76321
|
return b();
|
|
76322
76322
|
case "[":
|
|
76323
76323
|
return P();
|
|
76324
76324
|
case '"':
|
|
76325
|
-
return
|
|
76325
|
+
return h();
|
|
76326
76326
|
case "-":
|
|
76327
|
-
return
|
|
76327
|
+
return d();
|
|
76328
76328
|
default:
|
|
76329
|
-
return n >= "0" && n <= "9" ?
|
|
76329
|
+
return n >= "0" && n <= "9" ? d() : g();
|
|
76330
76330
|
}
|
|
76331
|
-
}, function(
|
|
76331
|
+
}, function(E, p) {
|
|
76332
76332
|
var y;
|
|
76333
|
-
return i =
|
|
76334
|
-
var F, B, G =
|
|
76333
|
+
return i = E + "", t = 0, n = " ", y = A(), f(), n && u("Syntax error"), typeof p == "function" ? (function T(w, S) {
|
|
76334
|
+
var F, B, G = w[S];
|
|
76335
76335
|
return G && typeof G == "object" && Object.keys(G).forEach(function(Z) {
|
|
76336
76336
|
B = T(G, Z), B !== void 0 ? G[Z] = B : delete G[Z];
|
|
76337
|
-
}), p.call(
|
|
76337
|
+
}), p.call(w, S, G);
|
|
76338
76338
|
})({ "": y }, "") : y;
|
|
76339
76339
|
};
|
|
76340
76340
|
};
|
|
@@ -76518,10 +76518,10 @@ var ep = z((Te) => {
|
|
|
76518
76518
|
l = (o = t.severity) !== null && o !== void 0 ? o : jt.DEFAULT;
|
|
76519
76519
|
break;
|
|
76520
76520
|
}
|
|
76521
|
-
let
|
|
76522
|
-
delete
|
|
76523
|
-
let
|
|
76524
|
-
console.error("%s [%s|%s] %s%s", u, i, l,
|
|
76521
|
+
let d = Qh.formatWithOptions({ colors: ht.Colours.enabled }, ...n), h = Object.assign({}, t);
|
|
76522
|
+
delete h.severity;
|
|
76523
|
+
let f = Object.getOwnPropertyNames(h).length ? JSON.stringify(h) : "", g = f ? `${ht.Colours.grey}${f}${ht.Colours.reset}` : "";
|
|
76524
|
+
console.error("%s [%s|%s] %s%s", u, i, l, d, f ? ` ${g}` : "");
|
|
76525
76525
|
} : () => {
|
|
76526
76526
|
};
|
|
76527
76527
|
}
|
|
@@ -76562,8 +76562,8 @@ var ep = z((Te) => {
|
|
|
76562
76562
|
let n = (t = this.upstream) === null || t === void 0 ? void 0 : t.makeLogger(e);
|
|
76563
76563
|
return (o, ...i) => {
|
|
76564
76564
|
var u;
|
|
76565
|
-
let l = (u = o.severity) !== null && u !== void 0 ? u : jt.INFO,
|
|
76566
|
-
n ? n(o,
|
|
76565
|
+
let l = (u = o.severity) !== null && u !== void 0 ? u : jt.INFO, d = Object.assign({ severity: l, message: Qh.format(...i) }, o), h = JSON.stringify(d);
|
|
76566
|
+
n ? n(o, h) : console.log("%s", h);
|
|
76567
76567
|
};
|
|
76568
76568
|
}
|
|
76569
76569
|
setFilters() {
|
|
@@ -76690,17 +76690,17 @@ var _s = z((ne) => {
|
|
|
76690
76690
|
new Headers(g.headers).forEach((A, P) => o.set(P, A)), i = g.metadataKey, u = g.params || u, t = g.noResponseRetries || t, n = g.fastFail || n;
|
|
76691
76691
|
} else i = r;
|
|
76692
76692
|
typeof e == "string" ? i += `/${e}` : (DC(e), e.property && (i += `/${e.property}`), new Headers(e.headers).forEach((g, A) => o.set(A, g)), u = e.params || u);
|
|
76693
|
-
let l = n ? SC : Fu.request,
|
|
76694
|
-
tp.info("instance request %j",
|
|
76695
|
-
let
|
|
76696
|
-
tp.info("instance metadata is %s",
|
|
76697
|
-
let
|
|
76698
|
-
if (
|
|
76699
|
-
if (typeof
|
|
76700
|
-
return EC.parse(
|
|
76693
|
+
let l = n ? SC : Fu.request, d = { url: `${Ou()}/${i}`, headers: o, retryConfig: { noResponseRetries: t }, params: u, responseType: "text", timeout: sp() };
|
|
76694
|
+
tp.info("instance request %j", d);
|
|
76695
|
+
let h = await l(d);
|
|
76696
|
+
tp.info("instance metadata is %s", h.data);
|
|
76697
|
+
let f = h.headers.get(ne.HEADER_NAME);
|
|
76698
|
+
if (f !== ne.HEADER_VALUE) throw new RangeError(`Invalid response from metadata service: incorrect ${ne.HEADER_NAME} header. Expected '${ne.HEADER_VALUE}', got ${f ? `'${f}'` : "no header"}`);
|
|
76699
|
+
if (typeof h.data == "string") try {
|
|
76700
|
+
return EC.parse(h.data);
|
|
76701
76701
|
} catch {
|
|
76702
76702
|
}
|
|
76703
|
-
return
|
|
76703
|
+
return h.data;
|
|
76704
76704
|
}
|
|
76705
76705
|
async function SC(r) {
|
|
76706
76706
|
let e = { ...r, url: r.url?.toString().replace(Ou(), Ou(ne.SECONDARY_HOST_ADDRESS)) }, t = (0, Fu.request)(r), n = (0, Fu.request)(e);
|
|
@@ -76793,9 +76793,9 @@ var ap = z((ei) => {
|
|
|
76793
76793
|
return (e + t) * 3 / 4 - t;
|
|
76794
76794
|
}
|
|
76795
76795
|
function NC(r) {
|
|
76796
|
-
var e, t = ip(r), n = t[0], o = t[1], i = new xC(IC(r, n, o)), u = 0, l = o > 0 ? n - 4 : n,
|
|
76797
|
-
for (
|
|
76798
|
-
return o === 2 && (e = St[r.charCodeAt(
|
|
76796
|
+
var e, t = ip(r), n = t[0], o = t[1], i = new xC(IC(r, n, o)), u = 0, l = o > 0 ? n - 4 : n, d;
|
|
76797
|
+
for (d = 0; d < l; d += 4) e = St[r.charCodeAt(d)] << 18 | St[r.charCodeAt(d + 1)] << 12 | St[r.charCodeAt(d + 2)] << 6 | St[r.charCodeAt(d + 3)], i[u++] = e >> 16 & 255, i[u++] = e >> 8 & 255, i[u++] = e & 255;
|
|
76798
|
+
return o === 2 && (e = St[r.charCodeAt(d)] << 2 | St[r.charCodeAt(d + 1)] >> 4, i[u++] = e & 255), o === 1 && (e = St[r.charCodeAt(d)] << 10 | St[r.charCodeAt(d + 1)] << 4 | St[r.charCodeAt(d + 2)] >> 2, i[u++] = e >> 8 & 255, i[u++] = e & 255), i;
|
|
76799
76799
|
}
|
|
76800
76800
|
function qC(r) {
|
|
76801
76801
|
return Kt[r >> 18 & 63] + Kt[r >> 12 & 63] + Kt[r >> 6 & 63] + Kt[r & 63];
|
|
@@ -76994,18 +76994,18 @@ var Uu = z((GS, bp) => {
|
|
|
76994
76994
|
var l = r[i++];
|
|
76995
76995
|
if (o - i - 2 < l) throw new Error('"r" specified length of "' + l + '", only "' + (o - i - 2) + '" available');
|
|
76996
76996
|
if (n < l) throw new Error('"r" specified length of "' + l + '", max of "' + n + '" is acceptable');
|
|
76997
|
-
var
|
|
76997
|
+
var d = i;
|
|
76998
76998
|
if (i += l, r[i++] !== ii) throw new Error('Could not find expected "int" for "s"');
|
|
76999
|
-
var
|
|
77000
|
-
if (o - i !==
|
|
77001
|
-
if (n <
|
|
77002
|
-
var
|
|
77003
|
-
if (i +=
|
|
77004
|
-
var g = t - l, A = t -
|
|
76999
|
+
var h = r[i++];
|
|
77000
|
+
if (o - i !== h) throw new Error('"s" specified length of "' + h + '", expected "' + (o - i) + '"');
|
|
77001
|
+
if (n < h) throw new Error('"s" specified length of "' + h + '", max of "' + n + '" is acceptable');
|
|
77002
|
+
var f = i;
|
|
77003
|
+
if (i += h, i !== o) throw new Error('Expected to consume entire buffer, but "' + (o - i) + '" bytes remain');
|
|
77004
|
+
var g = t - l, A = t - h, P = si.allocUnsafe(g + l + A + h);
|
|
77005
77005
|
for (i = 0; i < g; ++i) P[i] = 0;
|
|
77006
|
-
r.copy(P, i,
|
|
77006
|
+
r.copy(P, i, d + Math.max(-g, 0), d + l), i = t;
|
|
77007
77007
|
for (var b = i; i < b + A; ++i) P[i] = 0;
|
|
77008
|
-
return r.copy(P, i,
|
|
77008
|
+
return r.copy(P, i, f + Math.max(-A, 0), f + h), P = P.toString("base64"), P = eb(P), P;
|
|
77009
77009
|
}
|
|
77010
77010
|
function mp(r, e, t) {
|
|
77011
77011
|
for (var n = 0; e + n < t && r[e + n] === 0; ) ++n;
|
|
@@ -77016,8 +77016,8 @@ var Uu = z((GS, bp) => {
|
|
|
77016
77016
|
r = Cp(r);
|
|
77017
77017
|
var t = gp(e), n = r.length;
|
|
77018
77018
|
if (n !== t * 2) throw new TypeError('"' + e + '" signatures must be "' + t * 2 + '" bytes, saw "' + n + '"');
|
|
77019
|
-
var o = mp(r, 0, t), i = mp(r, t, r.length), u = t - o, l = t - i,
|
|
77020
|
-
return
|
|
77019
|
+
var o = mp(r, 0, t), i = mp(r, t, r.length), u = t - o, l = t - i, d = 2 + u + 1 + 1 + l, h = d < oi, f = si.allocUnsafe((h ? 2 : 3) + d), g = 0;
|
|
77020
|
+
return f[g++] = _p, h ? f[g++] = d : (f[g++] = oi | 1, f[g++] = d & 255), f[g++] = ii, f[g++] = u, o < 0 ? (f[g++] = 0, g += r.copy(f, g, 0, t)) : g += r.copy(f, g, o, t), f[g++] = ii, f[g++] = l, i < 0 ? (f[g++] = 0, r.copy(f, g, t)) : r.copy(f, g, t + i), f;
|
|
77021
77021
|
}
|
|
77022
77022
|
bp.exports = { derToJose: tb, joseToDer: rb };
|
|
77023
77023
|
});
|
|
@@ -77259,8 +77259,8 @@ var rn = z((Xt) => {
|
|
|
77259
77259
|
async getTokenAsync(e) {
|
|
77260
77260
|
let t = this.endpoints.oauth2TokenUrl.toString(), n = new Headers(), o = { client_id: e.client_id || this._clientId, code_verifier: e.codeVerifier, code: e.code, grant_type: "authorization_code", redirect_uri: e.redirect_uri || this.redirectUri };
|
|
77261
77261
|
if (this.clientAuthentication === bs.ClientSecretBasic) {
|
|
77262
|
-
let
|
|
77263
|
-
n.set("authorization", `Basic ${
|
|
77262
|
+
let d = Buffer.from(`${this._clientId}:${this._clientSecret}`);
|
|
77263
|
+
n.set("authorization", `Basic ${d.toString("base64")}`);
|
|
77264
77264
|
}
|
|
77265
77265
|
this.clientAuthentication === bs.ClientSecretPost && (o.client_secret = this._clientSecret);
|
|
77266
77266
|
let i = { ...r.RETRY_CONFIG, method: "POST", url: t, data: new URLSearchParams((0, vp.removeUndefinedValuesInObject)(o)), headers: n };
|
|
@@ -77326,8 +77326,8 @@ var rn = z((Xt) => {
|
|
|
77326
77326
|
let l = await this.processAndValidateRefreshHandler();
|
|
77327
77327
|
if (l?.access_token) {
|
|
77328
77328
|
this.setCredentials(l);
|
|
77329
|
-
let
|
|
77330
|
-
return { headers: this.addSharedMetadataHeaders(
|
|
77329
|
+
let d = new Headers({ authorization: "Bearer " + this.credentials.access_token });
|
|
77330
|
+
return { headers: this.addSharedMetadataHeaders(d) };
|
|
77331
77331
|
}
|
|
77332
77332
|
}
|
|
77333
77333
|
if (this.apiKey) return { headers: new Headers({ "X-Goog-Api-Key": this.apiKey }) };
|
|
@@ -77335,8 +77335,8 @@ var rn = z((Xt) => {
|
|
|
77335
77335
|
try {
|
|
77336
77336
|
n = await this.refreshToken(t.refresh_token), o = n.tokens;
|
|
77337
77337
|
} catch (l) {
|
|
77338
|
-
let
|
|
77339
|
-
throw
|
|
77338
|
+
let d = l;
|
|
77339
|
+
throw d.response && (d.response.status === 403 || d.response.status === 404) && (d.message = `Could not refresh access token: ${d.message}`), d;
|
|
77340
77340
|
}
|
|
77341
77341
|
let i = this.credentials;
|
|
77342
77342
|
i.token_type = i.token_type || "Bearer", o.refresh_token = i.refresh_token, this.credentials = o;
|
|
@@ -77375,11 +77375,11 @@ var rn = z((Xt) => {
|
|
|
77375
77375
|
} catch (n) {
|
|
77376
77376
|
let o = n.response;
|
|
77377
77377
|
if (o) {
|
|
77378
|
-
let i = o.status, u = this.credentials && this.credentials.access_token && this.credentials.refresh_token && (!this.credentials.expiry_date || this.forceRefreshOnFailure), l = this.credentials && this.credentials.access_token && !this.credentials.refresh_token && (!this.credentials.expiry_date || this.forceRefreshOnFailure) && this.refreshHandler,
|
|
77379
|
-
if (!t &&
|
|
77380
|
-
if (!t &&
|
|
77381
|
-
let
|
|
77382
|
-
return
|
|
77378
|
+
let i = o.status, u = this.credentials && this.credentials.access_token && this.credentials.refresh_token && (!this.credentials.expiry_date || this.forceRefreshOnFailure), l = this.credentials && this.credentials.access_token && !this.credentials.refresh_token && (!this.credentials.expiry_date || this.forceRefreshOnFailure) && this.refreshHandler, d = o.config.data instanceof yb.Readable, h = i === 401 || i === 403;
|
|
77379
|
+
if (!t && h && !d && u) return await this.refreshAccessTokenAsync(), this.requestAsync(e, true);
|
|
77380
|
+
if (!t && h && !d && l) {
|
|
77381
|
+
let f = await this.processAndValidateRefreshHandler();
|
|
77382
|
+
return f?.access_token && this.setCredentials(f), this.requestAsync(e, true);
|
|
77383
77383
|
}
|
|
77384
77384
|
}
|
|
77385
77385
|
throw n;
|
|
@@ -77418,15 +77418,15 @@ var rn = z((Xt) => {
|
|
|
77418
77418
|
throw new Error(`Unsupported certificate format ${t}`);
|
|
77419
77419
|
}
|
|
77420
77420
|
try {
|
|
77421
|
-
let
|
|
77422
|
-
In.AuthClient.setMethodName(
|
|
77423
|
-
} catch (
|
|
77424
|
-
throw
|
|
77421
|
+
let h = { ...r.RETRY_CONFIG, url: o };
|
|
77422
|
+
In.AuthClient.setMethodName(h, "getFederatedSignonCertsAsync"), n = await this.transporter.request(h);
|
|
77423
|
+
} catch (h) {
|
|
77424
|
+
throw h instanceof Error && (h.message = `Failed to retrieve verification certificates: ${h.message}`), h;
|
|
77425
77425
|
}
|
|
77426
77426
|
let i = n?.headers.get("cache-control"), u = -1;
|
|
77427
77427
|
if (i) {
|
|
77428
|
-
let
|
|
77429
|
-
|
|
77428
|
+
let h = /max-age=(?<maxAge>[0-9]+)/.exec(i)?.groups?.maxAge;
|
|
77429
|
+
h && (u = Number(h) * 1e3);
|
|
77430
77430
|
}
|
|
77431
77431
|
let l = {};
|
|
77432
77432
|
switch (t) {
|
|
@@ -77434,13 +77434,13 @@ var rn = z((Xt) => {
|
|
|
77434
77434
|
l = n.data;
|
|
77435
77435
|
break;
|
|
77436
77436
|
case mr.JWK:
|
|
77437
|
-
for (let
|
|
77437
|
+
for (let h of n.data.keys) l[h.kid] = h;
|
|
77438
77438
|
break;
|
|
77439
77439
|
default:
|
|
77440
77440
|
throw new Error(`Unsupported certificate format ${t}`);
|
|
77441
77441
|
}
|
|
77442
|
-
let
|
|
77443
|
-
return this.certificateExpiry = u === -1 ? null : new Date(
|
|
77442
|
+
let d = /* @__PURE__ */ new Date();
|
|
77443
|
+
return this.certificateExpiry = u === -1 ? null : new Date(d.getTime() + u), this.certificateCache = l, this.certificateCacheFormat = t, { certs: l, format: t, res: n };
|
|
77444
77444
|
}
|
|
77445
77445
|
getIapPublicKeys(e) {
|
|
77446
77446
|
if (e) this.getIapPublicKeysAsync().then((t) => e(null, t.pubkeys, t.res), e);
|
|
@@ -77464,39 +77464,39 @@ var rn = z((Xt) => {
|
|
|
77464
77464
|
i || (i = r.DEFAULT_MAX_TOKEN_LIFETIME_SECS_);
|
|
77465
77465
|
let l = e.split(".");
|
|
77466
77466
|
if (l.length !== 3) throw new Error("Wrong number of segments in token: " + e);
|
|
77467
|
-
let
|
|
77467
|
+
let d = l[0] + "." + l[1], h = l[2], f, g;
|
|
77468
77468
|
try {
|
|
77469
|
-
|
|
77470
|
-
} catch (
|
|
77471
|
-
throw
|
|
77469
|
+
f = JSON.parse(u.decodeBase64StringUtf8(l[0]));
|
|
77470
|
+
} catch (w) {
|
|
77471
|
+
throw w instanceof Error && (w.message = `Can't parse token envelope: ${l[0]}': ${w.message}`), w;
|
|
77472
77472
|
}
|
|
77473
|
-
if (!
|
|
77473
|
+
if (!f) throw new Error("Can't parse token envelope: " + l[0]);
|
|
77474
77474
|
try {
|
|
77475
77475
|
g = JSON.parse(u.decodeBase64StringUtf8(l[1]));
|
|
77476
|
-
} catch (
|
|
77477
|
-
throw
|
|
77476
|
+
} catch (w) {
|
|
77477
|
+
throw w instanceof Error && (w.message = `Can't parse token payload '${l[0]}`), w;
|
|
77478
77478
|
}
|
|
77479
77479
|
if (!g) throw new Error("Can't parse token payload: " + l[1]);
|
|
77480
|
-
if (!Object.prototype.hasOwnProperty.call(t,
|
|
77481
|
-
let A = t[
|
|
77482
|
-
if (
|
|
77480
|
+
if (!Object.prototype.hasOwnProperty.call(t, f.kid)) throw new Error("No pem found for envelope: " + JSON.stringify(f));
|
|
77481
|
+
let A = t[f.kid];
|
|
77482
|
+
if (f.alg === "ES256" && (h = _b.joseToDer(h, "ES256").toString("base64")), !await u.verify(A, d, h)) throw new Error("Invalid token signature: " + e);
|
|
77483
77483
|
if (!g.iat) throw new Error("No issue time in token: " + JSON.stringify(g));
|
|
77484
77484
|
if (!g.exp) throw new Error("No expiration time in token: " + JSON.stringify(g));
|
|
77485
77485
|
let b = Number(g.iat);
|
|
77486
77486
|
if (isNaN(b)) throw new Error("iat field using invalid format");
|
|
77487
|
-
let
|
|
77488
|
-
if (isNaN(
|
|
77487
|
+
let E = Number(g.exp);
|
|
77488
|
+
if (isNaN(E)) throw new Error("exp field using invalid format");
|
|
77489
77489
|
let p = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
77490
|
-
if (
|
|
77491
|
-
let y = b - r.CLOCK_SKEW_SECS_, T =
|
|
77490
|
+
if (E >= p + i) throw new Error("Expiration time too far in future: " + JSON.stringify(g));
|
|
77491
|
+
let y = b - r.CLOCK_SKEW_SECS_, T = E + r.CLOCK_SKEW_SECS_;
|
|
77492
77492
|
if (p < y) throw new Error("Token used too early, " + p + " < " + y + ": " + JSON.stringify(g));
|
|
77493
77493
|
if (p > T) throw new Error("Token used too late, " + p + " > " + T + ": " + JSON.stringify(g));
|
|
77494
77494
|
if (o && o.indexOf(g.iss) < 0) throw new Error("Invalid issuer, expected one of [" + o + "], but got " + g.iss);
|
|
77495
77495
|
if (typeof n < "u" && n !== null) {
|
|
77496
|
-
let
|
|
77497
|
-
if (n.constructor === Array ? S = n.indexOf(
|
|
77496
|
+
let w = g.aud, S = false;
|
|
77497
|
+
if (n.constructor === Array ? S = n.indexOf(w) > -1 : S = w === n, !S) throw new Error("Wrong recipient, payload audience != requiredAudience");
|
|
77498
77498
|
}
|
|
77499
|
-
return new Cb.LoginTicket(
|
|
77499
|
+
return new Cb.LoginTicket(f, g);
|
|
77500
77500
|
}
|
|
77501
77501
|
async processAndValidateRefreshHandler() {
|
|
77502
77502
|
if (this.refreshHandler) {
|
|
@@ -77900,14 +77900,14 @@ var Em = z((gi) => {
|
|
|
77900
77900
|
if (typeof WeakMap == "function") var t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
|
|
77901
77901
|
return (mi = function(i, u) {
|
|
77902
77902
|
if (!u && i && i.__esModule) return i;
|
|
77903
|
-
var l,
|
|
77904
|
-
if (i === null || yr(i) != "object" && typeof i != "function") return
|
|
77903
|
+
var l, d, h = { __proto__: null, default: i };
|
|
77904
|
+
if (i === null || yr(i) != "object" && typeof i != "function") return h;
|
|
77905
77905
|
if (l = u ? n : t) {
|
|
77906
77906
|
if (l.has(i)) return l.get(i);
|
|
77907
|
-
l.set(i,
|
|
77907
|
+
l.set(i, h);
|
|
77908
77908
|
}
|
|
77909
|
-
for (var
|
|
77910
|
-
return
|
|
77909
|
+
for (var f in i) f !== "default" && {}.hasOwnProperty.call(i, f) && ((d = (l = Object.defineProperty) && Object.getOwnPropertyDescriptor(i, f)) && (d.get || d.set) ? l(h, f, d) : h[f] = i[f]);
|
|
77910
|
+
return h;
|
|
77911
77911
|
})(r, e);
|
|
77912
77912
|
}
|
|
77913
77913
|
function yr(r) {
|
|
@@ -78033,9 +78033,9 @@ var Em = z((gi) => {
|
|
|
78033
78033
|
}
|
|
78034
78034
|
function _t() {
|
|
78035
78035
|
var r, e, t = typeof Symbol == "function" ? Symbol : {}, n = t.iterator || "@@iterator", o = t.toStringTag || "@@toStringTag";
|
|
78036
|
-
function i(P, b,
|
|
78036
|
+
function i(P, b, E, p) {
|
|
78037
78037
|
var y = b && b.prototype instanceof l ? b : l, T = Object.create(y.prototype);
|
|
78038
|
-
return yt(T, "_invoke", (function(
|
|
78038
|
+
return yt(T, "_invoke", (function(w, S, F) {
|
|
78039
78039
|
var B, G, Z, H = 0, ae = F || [], de = false, fe = { p: 0, n: 0, v: r, a: Ee, f: Ee.bind(r, 4), d: function(Ae, oe) {
|
|
78040
78040
|
return B = Ae, G = 0, Z = r, fe.n = oe, u;
|
|
78041
78041
|
} };
|
|
@@ -78059,7 +78059,7 @@ var Em = z((gi) => {
|
|
|
78059
78059
|
Z = e.value, G < 2 && (G = 0);
|
|
78060
78060
|
} else G === 1 && (e = B.return) && e.call(B), G < 2 && (Z = TypeError("The iterator does not provide a '" + Ce + "' method"), G = 1);
|
|
78061
78061
|
B = r;
|
|
78062
|
-
} else if ((e = (de = fe.n < 0) ? Z :
|
|
78062
|
+
} else if ((e = (de = fe.n < 0) ? Z : w.call(S, fe)) !== u) break;
|
|
78063
78063
|
} catch (he) {
|
|
78064
78064
|
B = r, G = 1, Z = he;
|
|
78065
78065
|
} finally {
|
|
@@ -78068,23 +78068,23 @@ var Em = z((gi) => {
|
|
|
78068
78068
|
}
|
|
78069
78069
|
return { value: e, done: de };
|
|
78070
78070
|
};
|
|
78071
|
-
})(P,
|
|
78071
|
+
})(P, E, p), true), T;
|
|
78072
78072
|
}
|
|
78073
78073
|
var u = {};
|
|
78074
78074
|
function l() {
|
|
78075
78075
|
}
|
|
78076
|
-
function f() {
|
|
78077
|
-
}
|
|
78078
78076
|
function d() {
|
|
78079
78077
|
}
|
|
78078
|
+
function h() {
|
|
78079
|
+
}
|
|
78080
78080
|
e = Object.getPrototypeOf;
|
|
78081
|
-
var
|
|
78081
|
+
var f = [][n] ? e(e([][n]())) : (yt(e = {}, n, function() {
|
|
78082
78082
|
return this;
|
|
78083
|
-
}), e), g =
|
|
78083
|
+
}), e), g = h.prototype = l.prototype = Object.create(f);
|
|
78084
78084
|
function A(P) {
|
|
78085
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(P,
|
|
78085
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(P, h) : (P.__proto__ = h, yt(P, o, "GeneratorFunction")), P.prototype = Object.create(g), P;
|
|
78086
78086
|
}
|
|
78087
|
-
return
|
|
78087
|
+
return d.prototype = h, yt(g, "constructor", h), yt(h, "constructor", d), d.displayName = "GeneratorFunction", yt(h, o, "GeneratorFunction"), yt(g), yt(g, o, "Generator"), yt(g, n, function() {
|
|
78088
78088
|
return this;
|
|
78089
78089
|
}), yt(g, "toString", function() {
|
|
78090
78090
|
return "[object Generator]";
|
|
@@ -78099,36 +78099,36 @@ var Em = z((gi) => {
|
|
|
78099
78099
|
} catch {
|
|
78100
78100
|
o = 0;
|
|
78101
78101
|
}
|
|
78102
|
-
yt = function(u, l,
|
|
78103
|
-
if (l) o ? o(u, l, { value:
|
|
78102
|
+
yt = function(u, l, d, h) {
|
|
78103
|
+
if (l) o ? o(u, l, { value: d, enumerable: !h, configurable: !h, writable: !h }) : u[l] = d;
|
|
78104
78104
|
else {
|
|
78105
|
-
var
|
|
78105
|
+
var f = function(A, P) {
|
|
78106
78106
|
yt(u, A, function(b) {
|
|
78107
78107
|
return this._invoke(A, P, b);
|
|
78108
78108
|
});
|
|
78109
78109
|
};
|
|
78110
|
-
|
|
78110
|
+
f("next", 0), f("throw", 1), f("return", 2);
|
|
78111
78111
|
}
|
|
78112
78112
|
}, yt(r, e, t, n);
|
|
78113
78113
|
}
|
|
78114
78114
|
function fm(r, e, t, n, o, i, u) {
|
|
78115
78115
|
try {
|
|
78116
|
-
var l = r[i](u),
|
|
78117
|
-
} catch (
|
|
78118
|
-
return void t(
|
|
78116
|
+
var l = r[i](u), d = l.value;
|
|
78117
|
+
} catch (h) {
|
|
78118
|
+
return void t(h);
|
|
78119
78119
|
}
|
|
78120
|
-
l.done ? e(
|
|
78120
|
+
l.done ? e(d) : Promise.resolve(d).then(n, o);
|
|
78121
78121
|
}
|
|
78122
78122
|
function Un(r) {
|
|
78123
78123
|
return function() {
|
|
78124
78124
|
var e = this, t = arguments;
|
|
78125
78125
|
return new Promise(function(n, o) {
|
|
78126
78126
|
var i = r.apply(e, t);
|
|
78127
|
-
function u(
|
|
78128
|
-
fm(i, n, o, u, l, "next",
|
|
78127
|
+
function u(d) {
|
|
78128
|
+
fm(i, n, o, u, l, "next", d);
|
|
78129
78129
|
}
|
|
78130
|
-
function l(
|
|
78131
|
-
fm(i, n, o, u, l, "throw",
|
|
78130
|
+
function l(d) {
|
|
78131
|
+
fm(i, n, o, u, l, "throw", d);
|
|
78132
78132
|
}
|
|
78133
78133
|
u(void 0);
|
|
78134
78134
|
});
|
|
@@ -78181,7 +78181,7 @@ var Em = z((gi) => {
|
|
|
78181
78181
|
return $t(Qt, this, pm).call(this, n);
|
|
78182
78182
|
} }, { key: "getCredentials", value: (function() {
|
|
78183
78183
|
var e = Un(_t().m(function n(o) {
|
|
78184
|
-
var i, u, l,
|
|
78184
|
+
var i, u, l, d, h, f, g;
|
|
78185
78185
|
return _t().w(function(A) {
|
|
78186
78186
|
for (; ; ) switch (A.n) {
|
|
78187
78187
|
case 0:
|
|
@@ -78190,17 +78190,17 @@ var Em = z((gi) => {
|
|
|
78190
78190
|
case 1:
|
|
78191
78191
|
return A.n = 2, dm(o, "utf8");
|
|
78192
78192
|
case 2:
|
|
78193
|
-
if (u = A.v, l = JSON.parse(u),
|
|
78193
|
+
if (u = A.v, l = JSON.parse(u), d = l.private_key, h = l.client_email, !(!d || !h)) {
|
|
78194
78194
|
A.n = 3;
|
|
78195
78195
|
break;
|
|
78196
78196
|
}
|
|
78197
78197
|
throw new Ts("private_key and client_email are required.", "MISSING_CREDENTIALS");
|
|
78198
78198
|
case 3:
|
|
78199
|
-
return A.a(2, { privateKey:
|
|
78199
|
+
return A.a(2, { privateKey: d, clientEmail: h });
|
|
78200
78200
|
case 4:
|
|
78201
78201
|
return A.n = 5, dm(o, "utf8");
|
|
78202
78202
|
case 5:
|
|
78203
|
-
return
|
|
78203
|
+
return f = A.v, A.a(2, { privateKey: f });
|
|
78204
78204
|
case 6:
|
|
78205
78205
|
throw new Ts("*.p12 certificates are not supported after v6.1.2. Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.", "UNKNOWN_CERTIFICATE_TYPE");
|
|
78206
78206
|
case 7:
|
|
@@ -78319,7 +78319,7 @@ var Em = z((gi) => {
|
|
|
78319
78319
|
}
|
|
78320
78320
|
function mc() {
|
|
78321
78321
|
return mc = Un(_t().m(function r() {
|
|
78322
|
-
var e, t, n, o, i, u, l,
|
|
78322
|
+
var e, t, n, o, i, u, l, d, h, f;
|
|
78323
78323
|
return _t().w(function(g) {
|
|
78324
78324
|
for (; ; ) switch (g.n) {
|
|
78325
78325
|
case 0:
|
|
@@ -78327,7 +78327,7 @@ var Em = z((gi) => {
|
|
|
78327
78327
|
case 2:
|
|
78328
78328
|
return i = g.v, this.rawToken = i.data, this.expiresAt = i.data.expires_in === null || i.data.expires_in === void 0 ? void 0 : (e + i.data.expires_in) * 1e3, g.a(2, this.rawToken);
|
|
78329
78329
|
case 3:
|
|
78330
|
-
throw g.p = 3,
|
|
78330
|
+
throw g.p = 3, f = g.v, this.rawToken = void 0, this.tokenExpires = void 0, d = f.response && (u = f.response) !== null && u !== void 0 && u.data ? (l = f.response) === null || l === void 0 ? void 0 : l.data : {}, d.error && (h = d.error_description ? ": ".concat(d.error_description) : "", f.message = "".concat(d.error).concat(h)), f;
|
|
78331
78331
|
case 4:
|
|
78332
78332
|
return g.a(2);
|
|
78333
78333
|
}
|
|
@@ -78357,12 +78357,12 @@ var _c = z((yi) => {
|
|
|
78357
78357
|
getRequestHeaders(e, t, n) {
|
|
78358
78358
|
let o = this.getCachedKey(e, n), i = this.cache.get(o), u = Date.now();
|
|
78359
78359
|
if (i && i.expiration - u > this.eagerRefreshThresholdMillis) return new Headers(i.headers);
|
|
78360
|
-
let l = Math.floor(Date.now() / 1e3),
|
|
78361
|
-
if (Array.isArray(n) && (n = n.join(" ")), n ?
|
|
78362
|
-
for (let b in
|
|
78360
|
+
let l = Math.floor(Date.now() / 1e3), d = r.getExpirationTime(l), h;
|
|
78361
|
+
if (Array.isArray(n) && (n = n.join(" ")), n ? h = { iss: this.email, sub: this.email, scope: n, exp: d, iat: l } : h = { iss: this.email, sub: this.email, aud: e, exp: d, iat: l }, t) {
|
|
78362
|
+
for (let b in h) if (t[b]) throw new Error(`The '${b}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.`);
|
|
78363
78363
|
}
|
|
78364
|
-
let
|
|
78365
|
-
return this.cache.set(o, { expiration:
|
|
78364
|
+
let f = this.keyId ? { ...wm, kid: this.keyId } : wm, g = Object.assign(h, t), A = DE.sign({ header: f, payload: g, secret: this.key }), P = new Headers({ authorization: `Bearer ${A}` });
|
|
78365
|
+
return this.cache.set(o, { expiration: d * 1e3, headers: P }), P;
|
|
78366
78366
|
}
|
|
78367
78367
|
static getExpirationTime(e) {
|
|
78368
78368
|
return e + 3600;
|
|
@@ -78644,8 +78644,8 @@ var Tc = z((ks) => {
|
|
|
78644
78644
|
let u = new Error(i);
|
|
78645
78645
|
if (e) {
|
|
78646
78646
|
let l = Object.keys(e);
|
|
78647
|
-
e.stack && l.push("stack"), l.forEach((
|
|
78648
|
-
|
|
78647
|
+
e.stack && l.push("stack"), l.forEach((d) => {
|
|
78648
|
+
d !== "message" && Object.defineProperty(u, d, { value: e[d], writable: false, enumerable: true });
|
|
78649
78649
|
});
|
|
78650
78650
|
}
|
|
78651
78651
|
return u;
|
|
@@ -78704,11 +78704,11 @@ var Ir = z((vt) => {
|
|
|
78704
78704
|
if (n && n !== vt.EXTERNAL_ACCOUNT_TYPE) throw new Error(`Expected "${vt.EXTERNAL_ACCOUNT_TYPE}" type but received "${e.type}"`);
|
|
78705
78705
|
let o = t.get("client_id"), i = t.get("client_secret");
|
|
78706
78706
|
this.tokenUrl = t.get("token_url") ?? JE.replace("{universeDomain}", this.universeDomain);
|
|
78707
|
-
let u = t.get("subject_token_type"), l = t.get("workforce_pool_user_project"),
|
|
78707
|
+
let u = t.get("subject_token_type"), l = t.get("workforce_pool_user_project"), d = t.get("service_account_impersonation_url"), h = t.get("service_account_impersonation"), f = (0, Tm.originalOrCamelOptions)(h).get("token_lifetime_seconds");
|
|
78708
78708
|
this.cloudResourceManagerURL = new URL(t.get("cloud_resource_manager_url") || `https://cloudresourcemanager.${this.universeDomain}/v1/projects/`), o && (this.clientAuth = { confidentialClientType: "basic", clientId: o, clientSecret: i }), this.stsCredential = new UE.StsCredentials({ tokenExchangeEndpoint: this.tokenUrl, clientAuthentication: this.clientAuth }), this.scopes = t.get("scopes") || [kc], this.cachedAccessToken = null, this.audience = t.get("audience"), this.subjectTokenType = u, this.workforcePoolUserProject = l;
|
|
78709
78709
|
let g = new RegExp(WE);
|
|
78710
78710
|
if (this.workforcePoolUserProject && !this.audience.match(g)) throw new Error("workforcePoolUserProject should not be set for non-workforce pool credentials.");
|
|
78711
|
-
this.serviceAccountImpersonationUrl =
|
|
78711
|
+
this.serviceAccountImpersonationUrl = d, this.serviceAccountImpersonationLifetime = f, this.serviceAccountImpersonationLifetime ? this.configLifetimeRequested = true : (this.configLifetimeRequested = false, this.serviceAccountImpersonationLifetime = GE), this.projectNumber = this.getProjectNumber(this.audience), this.supplierContext = { audience: this.audience, subjectTokenType: this.subjectTokenType, transporter: this.transporter };
|
|
78712
78712
|
}
|
|
78713
78713
|
getServiceAccountEmail() {
|
|
78714
78714
|
if (this.serviceAccountImpersonationUrl) {
|
|
@@ -78934,18 +78934,18 @@ var km = z((Ct) => {
|
|
|
78934
78934
|
let t = new Ti.X509Certificate(e);
|
|
78935
78935
|
if (!this.trustChainPath) return JSON.stringify([t.raw.toString("base64")]);
|
|
78936
78936
|
try {
|
|
78937
|
-
let i = ((await Si.promises.readFile(this.trustChainPath, "utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g) ?? []).map((
|
|
78937
|
+
let i = ((await Si.promises.readFile(this.trustChainPath, "utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g) ?? []).map((d, h) => {
|
|
78938
78938
|
try {
|
|
78939
|
-
return new Ti.X509Certificate(
|
|
78940
|
-
} catch (
|
|
78941
|
-
let g =
|
|
78942
|
-
throw new Rt(`Failed to parse certificate at index ${
|
|
78939
|
+
return new Ti.X509Certificate(d);
|
|
78940
|
+
} catch (f) {
|
|
78941
|
+
let g = f instanceof Error ? f.message : String(f);
|
|
78942
|
+
throw new Rt(`Failed to parse certificate at index ${h} in trust chain file ${this.trustChainPath}: ${g}`);
|
|
78943
78943
|
}
|
|
78944
|
-
}), u = i.findIndex((
|
|
78944
|
+
}), u = i.findIndex((d) => t.raw.equals(d.raw)), l;
|
|
78945
78945
|
if (u === -1) l = [t, ...i];
|
|
78946
78946
|
else if (u === 0) l = i;
|
|
78947
78947
|
else throw new Rt(`Leaf certificate exists in the trust chain but is not the first entry (found at index ${u}).`);
|
|
78948
|
-
return JSON.stringify(l.map((
|
|
78948
|
+
return JSON.stringify(l.map((d) => d.raw.toString("base64")));
|
|
78949
78949
|
} catch (n) {
|
|
78950
78950
|
if (n instanceof Rt) throw n;
|
|
78951
78951
|
let o = n instanceof Error ? n.message : String(n);
|
|
@@ -78968,13 +78968,13 @@ var jc = z((vi) => {
|
|
|
78968
78968
|
if (n && o) throw new Error("Only one of credential source or subject token supplier can be specified.");
|
|
78969
78969
|
if (o) this.subjectTokenSupplier = o, this.credentialSourceType = "programmatic";
|
|
78970
78970
|
else {
|
|
78971
|
-
let i = (0, Nc.originalOrCamelOptions)(n), u = (0, Nc.originalOrCamelOptions)(i.get("format")), l = u.get("type") || "text",
|
|
78971
|
+
let i = (0, Nc.originalOrCamelOptions)(n), u = (0, Nc.originalOrCamelOptions)(i.get("format")), l = u.get("type") || "text", d = u.get("subject_token_field_name");
|
|
78972
78972
|
if (l !== "json" && l !== "text") throw new Error(`Invalid credential_source format "${l}"`);
|
|
78973
|
-
if (l === "json" && !
|
|
78974
|
-
let
|
|
78975
|
-
if (
|
|
78976
|
-
if (
|
|
78977
|
-
else if (
|
|
78973
|
+
if (l === "json" && !d) throw new Error("Missing subject_token_field_name for JSON credential_source format");
|
|
78974
|
+
let h = i.get("file"), f = i.get("url"), g = i.get("certificate"), A = i.get("headers");
|
|
78975
|
+
if (h && f || f && g || h && g) throw new Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.');
|
|
78976
|
+
if (h) this.credentialSourceType = "file", this.subjectTokenSupplier = new ZE.FileSubjectTokenSupplier({ filePath: h, formatType: l, subjectTokenFieldName: d });
|
|
78977
|
+
else if (f) this.credentialSourceType = "url", this.subjectTokenSupplier = new ew.UrlSubjectTokenSupplier({ url: f, formatType: l, subjectTokenFieldName: d, headers: A, additionalGaxiosOptions: r.RETRY_CONFIG });
|
|
78978
78978
|
else if (g) {
|
|
78979
78979
|
this.credentialSourceType = "certificate";
|
|
78980
78980
|
let P = new Fm.CertificateSubjectTokenSupplier({ useDefaultCertificateConfig: g.use_default_certificate_config, certificateConfigLocation: g.certificate_config_location, trustChainPath: g.trust_chain_path });
|
|
@@ -79006,11 +79006,11 @@ var Uc = z((ki) => {
|
|
|
79006
79006
|
}
|
|
79007
79007
|
async getRequestOptions(e) {
|
|
79008
79008
|
if (!e.url) throw new RangeError('"url" is required in "amzOptions"');
|
|
79009
|
-
let t = typeof e.data == "object" ? JSON.stringify(e.data) : e.data, n = e.url, o = e.method || "GET", i = e.body || t, u = e.headers, l = await this.getCredentials(),
|
|
79009
|
+
let t = typeof e.data == "object" ? JSON.stringify(e.data) : e.data, n = e.url, o = e.method || "GET", i = e.body || t, u = e.headers, l = await this.getCredentials(), d = new URL(n);
|
|
79010
79010
|
if (typeof i != "string" && i !== void 0) throw new TypeError(`'requestPayload' is expected to be a string if provided. Got: ${i}`);
|
|
79011
|
-
let
|
|
79012
|
-
l.token && Ri.Gaxios.mergeHeaders(
|
|
79013
|
-
let g = { url: n, method: o, headers:
|
|
79011
|
+
let h = await sw({ crypto: this.crypto, host: d.host, canonicalUri: d.pathname, canonicalQuerystring: d.search.slice(1), method: o, region: this.region, securityCredentials: l, requestPayload: i, additionalAmzHeaders: u }), f = Ri.Gaxios.mergeHeaders(h.amzDate ? { "x-amz-date": h.amzDate } : {}, { authorization: h.authorizationHeader, host: d.host }, u || {});
|
|
79012
|
+
l.token && Ri.Gaxios.mergeHeaders(f, { "x-amz-security-token": l.token });
|
|
79013
|
+
let g = { url: n, method: o, headers: f };
|
|
79014
79014
|
return i !== void 0 && (g.body = i), g;
|
|
79015
79015
|
}
|
|
79016
79016
|
};
|
|
@@ -79025,20 +79025,20 @@ var Uc = z((ki) => {
|
|
|
79025
79025
|
async function sw(r) {
|
|
79026
79026
|
let e = Ri.Gaxios.mergeHeaders(r.additionalAmzHeaders), t = r.requestPayload || "", n = r.host.split(".")[0], o = /* @__PURE__ */ new Date(), i = o.toISOString().replace(/[-:]/g, "").replace(/\.[0-9]+/, ""), u = o.toISOString().replace(/[-]/g, "").replace(/T.*/, "");
|
|
79027
79027
|
r.securityCredentials.token && e.set("x-amz-security-token", r.securityCredentials.token);
|
|
79028
|
-
let l = Ri.Gaxios.mergeHeaders({ host: r.host }, e.has("date") ? {} : { "x-amz-date": i }, e),
|
|
79029
|
-
|
|
79030
|
-
|
|
79028
|
+
let l = Ri.Gaxios.mergeHeaders({ host: r.host }, e.has("date") ? {} : { "x-amz-date": i }, e), d = "", h = [...l.keys()].sort();
|
|
79029
|
+
h.forEach((T) => {
|
|
79030
|
+
d += `${T}:${l.get(T)}
|
|
79031
79031
|
`;
|
|
79032
79032
|
});
|
|
79033
|
-
let
|
|
79033
|
+
let f = h.join(";"), g = await r.crypto.sha256DigestHex(t), A = `${r.method.toUpperCase()}
|
|
79034
79034
|
${r.canonicalUri}
|
|
79035
79035
|
${r.canonicalQuerystring}
|
|
79036
|
+
${d}
|
|
79036
79037
|
${f}
|
|
79037
|
-
${h}
|
|
79038
79038
|
${g}`, P = `${u}/${r.region}/${n}/${rw}`, b = `${Pm}
|
|
79039
79039
|
${i}
|
|
79040
79040
|
${P}
|
|
79041
|
-
` + await r.crypto.sha256DigestHex(A),
|
|
79041
|
+
` + await r.crypto.sha256DigestHex(A), E = await nw(r.crypto, r.securityCredentials.secretAccessKey, u, r.region, n), p = await Fs(r.crypto, E, b), y = `${Pm} Credential=${r.securityCredentials.accessKeyId}/${P}, SignedHeaders=${f}, Signature=${(0, xm.fromArrayBufferToHex)(p)}`;
|
|
79042
79042
|
return { amzDate: e.has("date") ? void 0 : i, authorizationHeader: y, canonicalQuerystring: r.canonicalQuerystring };
|
|
79043
79043
|
}
|
|
79044
79044
|
});
|
|
@@ -79114,8 +79114,8 @@ var Hc = z((Pi) => {
|
|
|
79114
79114
|
else {
|
|
79115
79115
|
let i = (0, Im.originalOrCamelOptions)(n);
|
|
79116
79116
|
this.environmentId = i.get("environment_id");
|
|
79117
|
-
let u = i.get("region_url"), l = i.get("url"),
|
|
79118
|
-
this.awsSecurityCredentialsSupplier = new aw.DefaultAwsSecurityCredentialsSupplier({ regionUrl: u, securityCredentialsUrl: l, imdsV2SessionTokenUrl:
|
|
79117
|
+
let u = i.get("region_url"), l = i.get("url"), d = i.get("imdsv2_session_token_url");
|
|
79118
|
+
this.awsSecurityCredentialsSupplier = new aw.DefaultAwsSecurityCredentialsSupplier({ regionUrl: u, securityCredentialsUrl: l, imdsV2SessionTokenUrl: d }), this.regionalCredVerificationUrl = i.get("regional_cred_verification_url"), this.credentialSourceType = "aws", this.validateEnvironmentId();
|
|
79119
79119
|
}
|
|
79120
79120
|
this.awsRequestSigner = null, this.region = "";
|
|
79121
79121
|
}
|
|
@@ -79229,10 +79229,10 @@ var Xc = z((Gn) => {
|
|
|
79229
79229
|
let u = setTimeout(() => (o.removeAllListeners(), o.kill(), n(new Error("The executable failed to finish within the timeout specified."))), this.timeoutMillis);
|
|
79230
79230
|
o.on("close", (l) => {
|
|
79231
79231
|
if (clearTimeout(u), l === 0) try {
|
|
79232
|
-
let
|
|
79233
|
-
return t(
|
|
79234
|
-
} catch (
|
|
79235
|
-
return
|
|
79232
|
+
let d = JSON.parse(i), h = new nn.ExecutableResponse(d);
|
|
79233
|
+
return t(h);
|
|
79234
|
+
} catch (d) {
|
|
79235
|
+
return d instanceof nn.ExecutableResponseError ? n(d) : n(new nn.ExecutableResponseError(`The executable returned an invalid response: ${i}`));
|
|
79236
79236
|
}
|
|
79237
79237
|
else return n(new Li(i, l.toString()));
|
|
79238
79238
|
});
|
|
@@ -79947,36 +79947,36 @@ async function Hf(r, e, t) {
|
|
|
79947
79947
|
}
|
|
79948
79948
|
function Gf(r, e, t, n, o) {
|
|
79949
79949
|
let i = new Headers({ "Content-Type": "application/json" });
|
|
79950
|
-
t.headers && Object.entries(t.headers).forEach(([
|
|
79951
|
-
|
|
79950
|
+
t.headers && Object.entries(t.headers).forEach(([h, f]) => {
|
|
79951
|
+
f && i.set(h, f);
|
|
79952
79952
|
});
|
|
79953
79953
|
let u, l = AbortSignal.timeout(t.TIMEOUT ?? 60 * 1e3 * 60);
|
|
79954
79954
|
if (t.signal) {
|
|
79955
|
-
let
|
|
79956
|
-
t.signal.addEventListener("abort",
|
|
79955
|
+
let h = new AbortController(), f = () => h.abort();
|
|
79956
|
+
t.signal.addEventListener("abort", f), l.addEventListener("abort", f), u = h.signal;
|
|
79957
79957
|
} else u = l;
|
|
79958
|
-
let
|
|
79959
|
-
return t.httpsProxy && (
|
|
79958
|
+
let d = { method: "POST", headers: i, body: JSON.stringify(e), signal: u };
|
|
79959
|
+
return t.httpsProxy && (d.dispatcher = new import_undici.ProxyAgent(new URL(t.httpsProxy).toString())), n?.debug({ reqId: o.req.id, request: d, headers: Object.fromEntries(i.entries()), requestUrl: typeof r == "string" ? r : r.toString(), useProxy: t.httpsProxy }, "final request"), fetch(typeof r == "string" ? r : r.toString(), d);
|
|
79960
79960
|
}
|
|
79961
|
-
var Wf = "1.0.
|
|
79961
|
+
var Wf = "1.0.43";
|
|
79962
79962
|
async function f0(r, e, t, n) {
|
|
79963
79963
|
let o = r.body, i = r.provider, u = t._server.providerService.getProvider(i);
|
|
79964
79964
|
if (!u) throw nt(`Provider '${i}' not found`, 404, "provider_not_found");
|
|
79965
|
-
let { requestBody: l, config:
|
|
79965
|
+
let { requestBody: l, config: d, bypass: h } = await d0(o, u, n, r.headers, { req: r }), f = await p0(l, d, u, t, h, n, { req: r }), g = await m0(l, f, u, n, h, { req: r });
|
|
79966
79966
|
return g0(g, e, o);
|
|
79967
79967
|
}
|
|
79968
79968
|
async function d0(r, e, t, n, o) {
|
|
79969
79969
|
let i = r, u = {}, l = false;
|
|
79970
79970
|
if (l = h0(e, t, r), l && (n instanceof Headers ? n.delete("content-length") : delete n["content-length"], u.headers = n), !l && typeof t.transformRequestOut == "function") {
|
|
79971
|
-
let
|
|
79972
|
-
|
|
79971
|
+
let d = await t.transformRequestOut(i);
|
|
79972
|
+
d.body ? (i = d.body, u = d.config || {}) : i = d;
|
|
79973
79973
|
}
|
|
79974
|
-
if (!l && e.transformer?.use?.length) for (let
|
|
79975
|
-
if (!
|
|
79976
|
-
let
|
|
79977
|
-
|
|
79974
|
+
if (!l && e.transformer?.use?.length) for (let d of e.transformer.use) {
|
|
79975
|
+
if (!d || typeof d.transformRequestIn != "function") continue;
|
|
79976
|
+
let h = await d.transformRequestIn(i, e, o);
|
|
79977
|
+
h.body ? (i = h.body, u = { ...u, ...h.config }) : i = h;
|
|
79978
79978
|
}
|
|
79979
|
-
if (!l && e.transformer?.[r.model]?.use?.length) for (let
|
|
79979
|
+
if (!l && e.transformer?.[r.model]?.use?.length) for (let d of e.transformer[r.model].use) !d || typeof d.transformRequestIn != "function" || (i = await d.transformRequestIn(i, e, o));
|
|
79980
79980
|
return { requestBody: i, config: u, bypass: l };
|
|
79981
79981
|
}
|
|
79982
79982
|
function h0(r, e, t) {
|
|
@@ -79985,21 +79985,21 @@ function h0(r, e, t) {
|
|
|
79985
79985
|
async function p0(r, e, t, n, o, i, u) {
|
|
79986
79986
|
let l = e.url || new URL(t.baseUrl);
|
|
79987
79987
|
if (o && typeof i.auth == "function") {
|
|
79988
|
-
let
|
|
79989
|
-
if (
|
|
79990
|
-
r =
|
|
79988
|
+
let f = await i.auth(r, t);
|
|
79989
|
+
if (f.body) {
|
|
79990
|
+
r = f.body;
|
|
79991
79991
|
let g = e.headers || {};
|
|
79992
|
-
|
|
79993
|
-
} else r =
|
|
79992
|
+
f.config?.headers && (g = { ...g, ...f.config.headers }, delete g.host, delete f.config.headers), e = { ...e, ...f.config, headers: g };
|
|
79993
|
+
} else r = f;
|
|
79994
79994
|
}
|
|
79995
|
-
let
|
|
79996
|
-
|
|
79997
|
-
let
|
|
79998
|
-
if (!
|
|
79999
|
-
let
|
|
80000
|
-
throw nt(`Error from provider(${t.name},${r.model}: ${
|
|
79995
|
+
let d = { ...e?.headers || {} };
|
|
79996
|
+
for (let f in d) (d[f] === "undefined" || ["authorization", "Authorization"].includes(f) && d[f]?.includes("undefined")) && delete d[f];
|
|
79997
|
+
let h = await Gf(l, r, { httpsProxy: n._server.configService.getHttpsProxy(), ...e, headers: JSON.parse(JSON.stringify(d)) }, n.log, u);
|
|
79998
|
+
if (!h.ok) {
|
|
79999
|
+
let f = await h.text();
|
|
80000
|
+
throw nt(`Error from provider(${t.name},${r.model}: ${h.status}): ${f}`, h.status, "provider_response_error");
|
|
80001
80001
|
}
|
|
80002
|
-
return
|
|
80002
|
+
return h;
|
|
80003
80003
|
}
|
|
80004
80004
|
async function m0(r, e, t, n, o, i) {
|
|
80005
80005
|
let u = e;
|
|
@@ -80254,19 +80254,19 @@ var bo = class {
|
|
|
80254
80254
|
}
|
|
80255
80255
|
if (Array.isArray(i.content)) {
|
|
80256
80256
|
if (i.role === "user") {
|
|
80257
|
-
let l = i.content.filter((
|
|
80258
|
-
l.length && l.forEach((
|
|
80259
|
-
let g = { role: "tool", content: typeof
|
|
80257
|
+
let l = i.content.filter((h) => h.type === "tool_result" && h.tool_use_id);
|
|
80258
|
+
l.length && l.forEach((h, f) => {
|
|
80259
|
+
let g = { role: "tool", content: typeof h.content == "string" ? h.content : JSON.stringify(h.content), tool_call_id: h.tool_use_id, cache_control: h.cache_control };
|
|
80260
80260
|
t.push(g);
|
|
80261
80261
|
});
|
|
80262
|
-
let
|
|
80263
|
-
|
|
80262
|
+
let d = i.content.filter((h) => h.type === "text" && h.text || h.type === "image" && h.source);
|
|
80263
|
+
d.length && t.push({ role: "user", content: d.map((h) => h?.type === "image" ? { type: "image_url", image_url: { url: h.source?.type === "base64" ? Kf(h.source.data, h.source.media_type) : h.source.url }, media_type: h.source.media_type } : h) });
|
|
80264
80264
|
} else if (i.role === "assistant") {
|
|
80265
|
-
let l = { role: "assistant", content: "" },
|
|
80266
|
-
|
|
80265
|
+
let l = { role: "assistant", content: "" }, d = i.content.filter((f) => f.type === "text" && f.text);
|
|
80266
|
+
d.length && (l.content = d.map((f) => f.text).join(`
|
|
80267
80267
|
`));
|
|
80268
|
-
let
|
|
80269
|
-
|
|
80268
|
+
let h = i.content.filter((f) => f.type === "tool_use" && f.id);
|
|
80269
|
+
h.length && (l.tool_calls = h.map((f) => ({ id: f.id, type: "function", function: { name: f.name, arguments: JSON.stringify(f.input || {}) } }))), t.push(l);
|
|
80270
80270
|
}
|
|
80271
80271
|
return;
|
|
80272
80272
|
}
|
|
@@ -80290,9 +80290,9 @@ var bo = class {
|
|
|
80290
80290
|
}
|
|
80291
80291
|
async convertOpenAIStreamToAnthropic(e, t) {
|
|
80292
80292
|
return new ReadableStream({ start: async (o) => {
|
|
80293
|
-
let i = new TextEncoder(), u = `msg_${Date.now()}`, l = null,
|
|
80294
|
-
let H =
|
|
80295
|
-
return
|
|
80293
|
+
let i = new TextEncoder(), u = `msg_${Date.now()}`, l = null, d = "unknown", h = false, f = false, g = false, A = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), b = 0, E = 0, p = 0, y = false, T = false, w = 0, S = -1, F = () => {
|
|
80294
|
+
let H = w;
|
|
80295
|
+
return w++, H;
|
|
80296
80296
|
}, B = (H) => {
|
|
80297
80297
|
if (!y) try {
|
|
80298
80298
|
o.enqueue(H);
|
|
@@ -80352,9 +80352,9 @@ data: ${JSON.stringify(J)}
|
|
|
80352
80352
|
`));
|
|
80353
80353
|
continue;
|
|
80354
80354
|
}
|
|
80355
|
-
if (
|
|
80356
|
-
|
|
80357
|
-
let J = { type: "message_start", message: { id: u, type: "message", role: "assistant", content: [], model:
|
|
80355
|
+
if (d = oe.model || d, !h && !y && !g) {
|
|
80356
|
+
h = true;
|
|
80357
|
+
let J = { type: "message_start", message: { id: u, type: "message", role: "assistant", content: [], model: d, stop_reason: null, stop_sequence: null, usage: { input_tokens: 0, output_tokens: 0 } } };
|
|
80358
80358
|
B(i.encode(`event: message_start
|
|
80359
80359
|
data: ${JSON.stringify(J)}
|
|
80360
80360
|
|
|
@@ -80390,15 +80390,15 @@ data: ${JSON.stringify(J)}
|
|
|
80390
80390
|
}
|
|
80391
80391
|
}
|
|
80392
80392
|
if (he?.delta?.content && !y && !g) {
|
|
80393
|
-
if (
|
|
80393
|
+
if (E++, S >= 0 && !f) {
|
|
80394
80394
|
let V = { type: "content_block_stop", index: S };
|
|
80395
80395
|
B(i.encode(`event: content_block_stop
|
|
80396
80396
|
data: ${JSON.stringify(V)}
|
|
80397
80397
|
|
|
80398
80398
|
`)), S = -1;
|
|
80399
80399
|
}
|
|
80400
|
-
if (!
|
|
80401
|
-
|
|
80400
|
+
if (!f && !g) {
|
|
80401
|
+
f = true;
|
|
80402
80402
|
let J = F(), V = { type: "content_block_start", index: J, content_block: { type: "text", text: "" } };
|
|
80403
80403
|
B(i.encode(`event: content_block_start
|
|
80404
80404
|
data: ${JSON.stringify(V)}
|
|
@@ -80414,12 +80414,12 @@ data: ${JSON.stringify(J)}
|
|
|
80414
80414
|
}
|
|
80415
80415
|
}
|
|
80416
80416
|
if (he?.delta?.annotations?.length && !y && !g) {
|
|
80417
|
-
if (S >= 0 &&
|
|
80417
|
+
if (S >= 0 && f) {
|
|
80418
80418
|
let J = { type: "content_block_stop", index: S };
|
|
80419
80419
|
B(i.encode(`event: content_block_stop
|
|
80420
80420
|
data: ${JSON.stringify(J)}
|
|
80421
80421
|
|
|
80422
|
-
`)), S = -1,
|
|
80422
|
+
`)), S = -1, f = false;
|
|
80423
80423
|
}
|
|
80424
80424
|
he?.delta?.annotations.forEach((J) => {
|
|
80425
80425
|
let V = F(), se = { type: "content_block_start", index: V, content_block: { type: "web_search_tool_result", tool_use_id: `srvtoolu_${Wt()}`, content: [{ type: "web_search_result", title: J.url_citation.title, url: J.url_citation.url }] } };
|
|
@@ -80488,7 +80488,7 @@ data: ${JSON.stringify(ut)}
|
|
|
80488
80488
|
}
|
|
80489
80489
|
}
|
|
80490
80490
|
if (he?.finish_reason && !y && !g) {
|
|
80491
|
-
if (
|
|
80491
|
+
if (E === 0 && p === 0 && console.error("Warning: No content in the stream response!"), S >= 0) {
|
|
80492
80492
|
let J = { type: "content_block_stop", index: S };
|
|
80493
80493
|
B(i.encode(`event: content_block_stop
|
|
80494
80494
|
data: ${JSON.stringify(J)}
|
|
@@ -80532,14 +80532,14 @@ data: ${JSON.stringify(J)}
|
|
|
80532
80532
|
o.push({ type: "server_tool_use", id: u, name: "web_search", input: { query: "" } }), o.push({ type: "web_search_tool_result", tool_use_id: u, content: n.message.annotations.map((l) => ({ type: "web_search_result", url: l.url_citation.url, title: l.url_citation.title })) });
|
|
80533
80533
|
}
|
|
80534
80534
|
n.message.content && o.push({ type: "text", text: n.message.content }), n.message.tool_calls && n.message.tool_calls.length > 0 && n.message.tool_calls.forEach((u, l) => {
|
|
80535
|
-
let
|
|
80535
|
+
let d = {};
|
|
80536
80536
|
try {
|
|
80537
|
-
let
|
|
80538
|
-
typeof
|
|
80537
|
+
let h = u.function.arguments || "{}";
|
|
80538
|
+
typeof h == "object" ? d = h : typeof h == "string" && (d = JSON.parse(h));
|
|
80539
80539
|
} catch {
|
|
80540
|
-
|
|
80540
|
+
d = { text: u.function.arguments || "" };
|
|
80541
80541
|
}
|
|
80542
|
-
o.push({ type: "tool_use", id: u.id, name: u.function.name, input:
|
|
80542
|
+
o.push({ type: "tool_use", id: u.id, name: u.function.name, input: d });
|
|
80543
80543
|
}), n.message?.thinking?.content && o.push({ type: "thinking", thinking: n.message.thinking.content, signature: n.message.thinking.signature });
|
|
80544
80544
|
let i = { id: e.id, type: "message", role: "assistant", model: e.model, content: o, stop_reason: n.finish_reason === "stop" ? "end_turn" : n.finish_reason === "length" ? "max_tokens" : n.finish_reason === "tool_calls" ? "tool_use" : n.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 } };
|
|
80545
80545
|
return this.logger.debug({ reqId: t.req.id, result: i }, "Conversion complete, final Anthropic response"), i;
|
|
@@ -80571,23 +80571,23 @@ function is(r) {
|
|
|
80571
80571
|
for (let [u, l] of Object.entries(r)) if (l != null) if (u == "type") {
|
|
80572
80572
|
if (l === "null") throw new Error("type: null can not be the only possible type for the field.");
|
|
80573
80573
|
if (Array.isArray(l)) continue;
|
|
80574
|
-
let
|
|
80575
|
-
e.type = Object.values(Cn).includes(
|
|
80574
|
+
let d = l.toUpperCase();
|
|
80575
|
+
e.type = Object.values(Cn).includes(d) ? d : Cn.TYPE_UNSPECIFIED;
|
|
80576
80576
|
} else if (t.includes(u)) e[u] = is(l);
|
|
80577
80577
|
else if (n.includes(u)) {
|
|
80578
|
-
let
|
|
80579
|
-
for (let
|
|
80580
|
-
if (
|
|
80578
|
+
let d = [];
|
|
80579
|
+
for (let h of l) {
|
|
80580
|
+
if (h.type == "null") {
|
|
80581
80581
|
e.nullable = true;
|
|
80582
80582
|
continue;
|
|
80583
80583
|
}
|
|
80584
|
-
|
|
80584
|
+
d.push(is(h));
|
|
80585
80585
|
}
|
|
80586
|
-
e[u] =
|
|
80586
|
+
e[u] = d;
|
|
80587
80587
|
} else if (o.includes(u)) {
|
|
80588
|
-
let
|
|
80589
|
-
for (let [
|
|
80590
|
-
e[u] =
|
|
80588
|
+
let d = {};
|
|
80589
|
+
for (let [h, f] of Object.entries(l)) d[h] = is(f);
|
|
80590
|
+
e[u] = d;
|
|
80591
80591
|
} else {
|
|
80592
80592
|
if (u === "additionalProperties") continue;
|
|
80593
80593
|
e[u] = l;
|
|
@@ -80604,11 +80604,11 @@ function Eo(r) {
|
|
|
80604
80604
|
let i = { contents: r.messages.map((u) => {
|
|
80605
80605
|
let l;
|
|
80606
80606
|
u.role === "assistant" ? l = "model" : (["user", "system", "tool"].includes(u.role), l = "user");
|
|
80607
|
-
let
|
|
80608
|
-
return typeof u.content == "string" ?
|
|
80609
|
-
if (
|
|
80610
|
-
if (
|
|
80611
|
-
})), Array.isArray(u.tool_calls) &&
|
|
80607
|
+
let d = [];
|
|
80608
|
+
return typeof u.content == "string" ? d.push({ text: u.content }) : Array.isArray(u.content) ? d.push(...u.content.map((h) => {
|
|
80609
|
+
if (h.type === "text") return { text: h.text || "" };
|
|
80610
|
+
if (h.type === "image_url") return h.image_url.url.startsWith("http") ? { file_data: { mime_type: h.media_type, file_uri: h.image_url.url } } : { inlineData: { mime_type: h.media_type, data: h.image_url.url?.split(",")?.pop() || h.image_url.url } };
|
|
80611
|
+
})) : u.content && typeof u.content == "object" && (u.content.text ? d.push({ text: u.content.text }) : d.push({ text: JSON.stringify(u.content) })), Array.isArray(u.tool_calls) && d.push(...u.tool_calls.map((h) => ({ functionCall: { id: h.id || `tool_${Math.random().toString(36).substring(2, 15)}`, name: h.function.name, args: JSON.parse(h.function.arguments || "{}") } }))), d.length === 0 && d.push({ text: "" }), { role: l, parts: d };
|
|
80612
80612
|
}), tools: e.length ? e : void 0 };
|
|
80613
80613
|
if (r.tool_choice) {
|
|
80614
80614
|
let u = { functionCallingConfig: {} };
|
|
@@ -80617,14 +80617,14 @@ function Eo(r) {
|
|
|
80617
80617
|
return i;
|
|
80618
80618
|
}
|
|
80619
80619
|
function wo(r) {
|
|
80620
|
-
let e = r.contents, t = r.tools, n = r.model, o = r.max_tokens, i = r.temperature, u = r.stream, l = r.tool_choice,
|
|
80621
|
-
return Array.isArray(e) && e.forEach((
|
|
80622
|
-
typeof
|
|
80623
|
-
}), Array.isArray(t) && (
|
|
80624
|
-
Array.isArray(
|
|
80625
|
-
|
|
80620
|
+
let e = r.contents, t = r.tools, n = r.model, o = r.max_tokens, i = r.temperature, u = r.stream, l = r.tool_choice, d = { messages: [], model: n, max_tokens: o, temperature: i, stream: u, tool_choice: l };
|
|
80621
|
+
return Array.isArray(e) && e.forEach((h) => {
|
|
80622
|
+
typeof h == "string" ? d.messages.push({ role: "user", content: h }) : typeof h.text == "string" ? d.messages.push({ role: "user", content: h.text || null }) : h.role === "user" ? d.messages.push({ role: "user", content: h?.parts?.map((f) => ({ type: "text", text: f.text || "" })) || [] }) : h.role === "model" && d.messages.push({ role: "assistant", content: h?.parts?.map((f) => ({ type: "text", text: f.text || "" })) || [] });
|
|
80623
|
+
}), Array.isArray(t) && (d.tools = [], t.forEach((h) => {
|
|
80624
|
+
Array.isArray(h.functionDeclarations) && h.functionDeclarations.forEach((f) => {
|
|
80625
|
+
d.tools.push({ type: "function", function: { name: f.name, description: f.description, parameters: f.parameters } });
|
|
80626
80626
|
});
|
|
80627
|
-
})),
|
|
80627
|
+
})), d;
|
|
80628
80628
|
}
|
|
80629
80629
|
async function Ao(r, e, t) {
|
|
80630
80630
|
if (r.headers.get("Content-Type")?.includes("application/json")) {
|
|
@@ -80633,47 +80633,47 @@ async function Ao(r, e, t) {
|
|
|
80633
80633
|
return new Response(JSON.stringify(i), { status: r.status, statusText: r.statusText, headers: r.headers });
|
|
80634
80634
|
} else if (r.headers.get("Content-Type")?.includes("stream")) {
|
|
80635
80635
|
if (!r.body) return r;
|
|
80636
|
-
let n = new TextDecoder(), o = new TextEncoder(), i = (l,
|
|
80636
|
+
let n = new TextDecoder(), o = new TextEncoder(), i = (l, d) => {
|
|
80637
80637
|
if (l.startsWith("data: ")) {
|
|
80638
|
-
let
|
|
80639
|
-
if (
|
|
80640
|
-
t?.debug({ chunkStr:
|
|
80638
|
+
let h = l.slice(6).trim();
|
|
80639
|
+
if (h) {
|
|
80640
|
+
t?.debug({ chunkStr: h }, `${e} chunk:`);
|
|
80641
80641
|
try {
|
|
80642
|
-
let
|
|
80643
|
-
if (!
|
|
80644
|
-
log("Invalid chunk structure:",
|
|
80642
|
+
let f = JSON.parse(h);
|
|
80643
|
+
if (!f.candidates || !f.candidates[0]) {
|
|
80644
|
+
log("Invalid chunk structure:", h);
|
|
80645
80645
|
return;
|
|
80646
80646
|
}
|
|
80647
|
-
let g =
|
|
80648
|
-
`) || "", tool_calls: P.length > 0 ? P : void 0 }, finish_reason: g.finishReason?.toLowerCase() || null, index: g.index || (P.length > 0 ? 1 : 0), logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id:
|
|
80649
|
-
g?.groundingMetadata?.groundingChunks?.length && (
|
|
80650
|
-
let T = g?.groundingMetadata?.groundingSupports?.filter((
|
|
80647
|
+
let g = f.candidates[0], A = g.content?.parts || [], P = A.filter((p) => p.functionCall).map((p) => ({ id: p.functionCall?.id || `tool_${Math.random().toString(36).substring(2, 15)}`, type: "function", function: { name: p.functionCall?.name, arguments: JSON.stringify(p.functionCall?.args || {}) } })), E = { choices: [{ delta: { role: "assistant", content: A.filter((p) => p.text).map((p) => p.text).join(`
|
|
80648
|
+
`) || "", tool_calls: P.length > 0 ? P : void 0 }, finish_reason: g.finishReason?.toLowerCase() || null, index: g.index || (P.length > 0 ? 1 : 0), logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: f.responseId || "", model: f.modelVersion || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1", usage: { completion_tokens: f.usageMetadata?.candidatesTokenCount || 0, prompt_tokens: f.usageMetadata?.promptTokenCount || 0, cached_content_token_count: f.usageMetadata?.cachedContentTokenCount || null, total_tokens: f.usageMetadata?.totalTokenCount || 0 } };
|
|
80649
|
+
g?.groundingMetadata?.groundingChunks?.length && (E.choices[0].delta.annotations = g.groundingMetadata.groundingChunks.map((p, y) => {
|
|
80650
|
+
let T = g?.groundingMetadata?.groundingSupports?.filter((w) => w.groundingChunkIndices?.includes(y));
|
|
80651
80651
|
return { type: "url_citation", url_citation: { url: p?.web?.uri || "", title: p?.web?.title || "", content: T?.[0]?.segment?.text || "", start_index: T?.[0]?.segment?.startIndex || 0, end_index: T?.[0]?.segment?.endIndex || 0 } };
|
|
80652
|
-
})),
|
|
80652
|
+
})), d.enqueue(o.encode(`data: ${JSON.stringify(E)}
|
|
80653
80653
|
|
|
80654
80654
|
`));
|
|
80655
|
-
} catch (
|
|
80656
|
-
t?.error(`Error parsing ${e} stream chunk`,
|
|
80655
|
+
} catch (f) {
|
|
80656
|
+
t?.error(`Error parsing ${e} stream chunk`, h, f.message);
|
|
80657
80657
|
}
|
|
80658
80658
|
}
|
|
80659
80659
|
}
|
|
80660
80660
|
}, u = new ReadableStream({ async start(l) {
|
|
80661
|
-
let
|
|
80661
|
+
let d = r.body.getReader(), h = "";
|
|
80662
80662
|
try {
|
|
80663
80663
|
for (; ; ) {
|
|
80664
|
-
let { done:
|
|
80665
|
-
if (
|
|
80666
|
-
|
|
80664
|
+
let { done: f, value: g } = await d.read();
|
|
80665
|
+
if (f) {
|
|
80666
|
+
h && i(h, l);
|
|
80667
80667
|
break;
|
|
80668
80668
|
}
|
|
80669
|
-
|
|
80670
|
-
let A =
|
|
80669
|
+
h += n.decode(g, { stream: true });
|
|
80670
|
+
let A = h.split(`
|
|
80671
80671
|
`);
|
|
80672
|
-
|
|
80672
|
+
h = A.pop() || "";
|
|
80673
80673
|
for (let P of A) i(P, l);
|
|
80674
80674
|
}
|
|
80675
|
-
} catch (
|
|
80676
|
-
l.error(
|
|
80675
|
+
} catch (f) {
|
|
80676
|
+
l.error(f);
|
|
80677
80677
|
} finally {
|
|
80678
80678
|
l.close();
|
|
80679
80679
|
}
|
|
@@ -80709,8 +80709,8 @@ var Hi = class {
|
|
|
80709
80709
|
async transformRequestIn(e, t) {
|
|
80710
80710
|
let n = process.env.GOOGLE_CLOUD_PROJECT, o = process.env.GOOGLE_CLOUD_LOCATION || "us-central1";
|
|
80711
80711
|
if (!n && process.env.GOOGLE_APPLICATION_CREDENTIALS) try {
|
|
80712
|
-
let l = (await import("fs")).readFileSync(process.env.GOOGLE_APPLICATION_CREDENTIALS, "utf8"),
|
|
80713
|
-
|
|
80712
|
+
let l = (await import("fs")).readFileSync(process.env.GOOGLE_APPLICATION_CREDENTIALS, "utf8"), d = JSON.parse(l);
|
|
80713
|
+
d && d.project_id && (n = d.project_id);
|
|
80714
80714
|
} catch (u) {
|
|
80715
80715
|
console.error("Error extracting project_id from GOOGLE_APPLICATION_CREDENTIALS:", u);
|
|
80716
80716
|
}
|
|
@@ -80734,14 +80734,14 @@ var Gi = class {
|
|
|
80734
80734
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
80735
80735
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
80736
80736
|
if (!e.body) return e;
|
|
80737
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = "", i = false, u = "", l = new ReadableStream({ async start(
|
|
80738
|
-
let
|
|
80739
|
-
let
|
|
80737
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = "", i = false, u = "", l = new ReadableStream({ async start(d) {
|
|
80738
|
+
let h = e.body.getReader(), f = (A, P, b) => {
|
|
80739
|
+
let E = A.split(`
|
|
80740
80740
|
`);
|
|
80741
|
-
for (let p of
|
|
80741
|
+
for (let p of E) p.trim() && P.enqueue(b.encode(p + `
|
|
80742
80742
|
`));
|
|
80743
80743
|
}, g = (A, P) => {
|
|
80744
|
-
let { controller: b, encoder:
|
|
80744
|
+
let { controller: b, encoder: E } = P;
|
|
80745
80745
|
if (A.startsWith("data: ") && A.trim() !== "data: [DONE]") try {
|
|
80746
80746
|
let p = JSON.parse(A.slice(6));
|
|
80747
80747
|
if (p.choices?.[0]?.delta?.reasoning_content) {
|
|
@@ -80751,60 +80751,60 @@ var Gi = class {
|
|
|
80751
80751
|
let T = `data: ${JSON.stringify(y)}
|
|
80752
80752
|
|
|
80753
80753
|
`;
|
|
80754
|
-
b.enqueue(
|
|
80754
|
+
b.enqueue(E.encode(T));
|
|
80755
80755
|
return;
|
|
80756
80756
|
}
|
|
80757
80757
|
if (p.choices?.[0]?.delta?.content && P.reasoningContent() && !P.isReasoningComplete()) {
|
|
80758
80758
|
P.setReasoningComplete(true);
|
|
80759
80759
|
let y = Date.now().toString(), T = { ...p, choices: [{ ...p.choices[0], delta: { ...p.choices[0].delta, content: null, thinking: { content: P.reasoningContent(), signature: y } } }] };
|
|
80760
80760
|
delete T.choices[0].delta.reasoning_content;
|
|
80761
|
-
let
|
|
80761
|
+
let w = `data: ${JSON.stringify(T)}
|
|
80762
80762
|
|
|
80763
80763
|
`;
|
|
80764
|
-
b.enqueue(
|
|
80764
|
+
b.enqueue(E.encode(w));
|
|
80765
80765
|
}
|
|
80766
80766
|
if (p.choices[0]?.delta?.reasoning_content && delete p.choices[0].delta.reasoning_content, p.choices?.[0]?.delta && Object.keys(p.choices[0].delta).length > 0) {
|
|
80767
80767
|
P.isReasoningComplete() && p.choices[0].index++;
|
|
80768
80768
|
let y = `data: ${JSON.stringify(p)}
|
|
80769
80769
|
|
|
80770
80770
|
`;
|
|
80771
|
-
b.enqueue(
|
|
80771
|
+
b.enqueue(E.encode(y));
|
|
80772
80772
|
}
|
|
80773
80773
|
} catch {
|
|
80774
|
-
b.enqueue(
|
|
80774
|
+
b.enqueue(E.encode(A + `
|
|
80775
80775
|
`));
|
|
80776
80776
|
}
|
|
80777
|
-
else b.enqueue(
|
|
80777
|
+
else b.enqueue(E.encode(A + `
|
|
80778
80778
|
`));
|
|
80779
80779
|
};
|
|
80780
80780
|
try {
|
|
80781
80781
|
for (; ; ) {
|
|
80782
|
-
let { done: A, value: P } = await
|
|
80782
|
+
let { done: A, value: P } = await h.read();
|
|
80783
80783
|
if (A) {
|
|
80784
|
-
u.trim() &&
|
|
80784
|
+
u.trim() && f(u, d, n);
|
|
80785
80785
|
break;
|
|
80786
80786
|
}
|
|
80787
80787
|
let b = t.decode(P, { stream: true });
|
|
80788
80788
|
u += b;
|
|
80789
|
-
let
|
|
80789
|
+
let E = u.split(`
|
|
80790
80790
|
`);
|
|
80791
|
-
u =
|
|
80792
|
-
for (let p of
|
|
80793
|
-
g(p, { controller:
|
|
80791
|
+
u = E.pop() || "";
|
|
80792
|
+
for (let p of E) if (p.trim()) try {
|
|
80793
|
+
g(p, { controller: d, encoder: n, reasoningContent: () => o, appendReasoningContent: (y) => o += y, isReasoningComplete: () => i, setReasoningComplete: (y) => i = y });
|
|
80794
80794
|
} catch (y) {
|
|
80795
|
-
console.error("Error processing line:", p, y),
|
|
80795
|
+
console.error("Error processing line:", p, y), d.enqueue(n.encode(p + `
|
|
80796
80796
|
`));
|
|
80797
80797
|
}
|
|
80798
80798
|
}
|
|
80799
80799
|
} catch (A) {
|
|
80800
|
-
console.error("Stream error:", A),
|
|
80800
|
+
console.error("Stream error:", A), d.error(A);
|
|
80801
80801
|
} finally {
|
|
80802
80802
|
try {
|
|
80803
|
-
|
|
80803
|
+
h.releaseLock();
|
|
80804
80804
|
} catch (A) {
|
|
80805
80805
|
console.error("Error releasing reader lock:", A);
|
|
80806
80806
|
}
|
|
80807
|
-
|
|
80807
|
+
d.close();
|
|
80808
80808
|
}
|
|
80809
80809
|
} });
|
|
80810
80810
|
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" } });
|
|
@@ -80831,18 +80831,18 @@ Examples:
|
|
|
80831
80831
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
80832
80832
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
80833
80833
|
if (!e.body) return e;
|
|
80834
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = -1, i = "", u = "", l = new ReadableStream({ async start(
|
|
80835
|
-
let
|
|
80836
|
-
let
|
|
80834
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = -1, i = "", u = "", l = new ReadableStream({ async start(d) {
|
|
80835
|
+
let h = e.body.getReader(), f = (A, P, b) => {
|
|
80836
|
+
let E = A.split(`
|
|
80837
80837
|
`);
|
|
80838
|
-
for (let p of
|
|
80838
|
+
for (let p of E) p.trim() && P.enqueue(b.encode(p + `
|
|
80839
80839
|
`));
|
|
80840
80840
|
}, g = (A, P) => {
|
|
80841
|
-
let { controller: b, encoder:
|
|
80841
|
+
let { controller: b, encoder: E, exitToolIndex: p, setExitToolIndex: y, appendExitToolResponse: T } = P;
|
|
80842
80842
|
if (A.startsWith("data: ") && A.trim() !== "data: [DONE]") try {
|
|
80843
|
-
let
|
|
80844
|
-
if (
|
|
80845
|
-
let S =
|
|
80843
|
+
let w = JSON.parse(A.slice(6));
|
|
80844
|
+
if (w.choices[0]?.delta?.tool_calls?.length) {
|
|
80845
|
+
let S = w.choices[0].delta.tool_calls[0];
|
|
80846
80846
|
if (S.function?.name === "ExitTool") {
|
|
80847
80847
|
y(S.index);
|
|
80848
80848
|
return;
|
|
@@ -80850,57 +80850,57 @@ Examples:
|
|
|
80850
80850
|
T(S.function.arguments);
|
|
80851
80851
|
try {
|
|
80852
80852
|
let F = JSON.parse(P.exitToolResponse());
|
|
80853
|
-
|
|
80854
|
-
let B = `data: ${JSON.stringify(
|
|
80853
|
+
w.choices = [{ delta: { role: "assistant", content: F.response || "" } }];
|
|
80854
|
+
let B = `data: ${JSON.stringify(w)}
|
|
80855
80855
|
|
|
80856
80856
|
`;
|
|
80857
|
-
b.enqueue(
|
|
80857
|
+
b.enqueue(E.encode(B));
|
|
80858
80858
|
} catch {
|
|
80859
80859
|
}
|
|
80860
80860
|
return;
|
|
80861
80861
|
}
|
|
80862
80862
|
}
|
|
80863
|
-
if (
|
|
80864
|
-
let S = `data: ${JSON.stringify(
|
|
80863
|
+
if (w.choices?.[0]?.delta && Object.keys(w.choices[0].delta).length > 0) {
|
|
80864
|
+
let S = `data: ${JSON.stringify(w)}
|
|
80865
80865
|
|
|
80866
80866
|
`;
|
|
80867
|
-
b.enqueue(
|
|
80867
|
+
b.enqueue(E.encode(S));
|
|
80868
80868
|
}
|
|
80869
80869
|
} catch {
|
|
80870
|
-
b.enqueue(
|
|
80870
|
+
b.enqueue(E.encode(A + `
|
|
80871
80871
|
`));
|
|
80872
80872
|
}
|
|
80873
|
-
else b.enqueue(
|
|
80873
|
+
else b.enqueue(E.encode(A + `
|
|
80874
80874
|
`));
|
|
80875
80875
|
};
|
|
80876
80876
|
try {
|
|
80877
80877
|
for (; ; ) {
|
|
80878
|
-
let { done: A, value: P } = await
|
|
80878
|
+
let { done: A, value: P } = await h.read();
|
|
80879
80879
|
if (A) {
|
|
80880
|
-
u.trim() &&
|
|
80880
|
+
u.trim() && f(u, d, n);
|
|
80881
80881
|
break;
|
|
80882
80882
|
}
|
|
80883
80883
|
let b = t.decode(P, { stream: true });
|
|
80884
80884
|
u += b;
|
|
80885
|
-
let
|
|
80885
|
+
let E = u.split(`
|
|
80886
80886
|
`);
|
|
80887
|
-
u =
|
|
80888
|
-
for (let p of
|
|
80889
|
-
g(p, { controller:
|
|
80887
|
+
u = E.pop() || "";
|
|
80888
|
+
for (let p of E) if (p.trim()) try {
|
|
80889
|
+
g(p, { controller: d, encoder: n, exitToolIndex: () => o, setExitToolIndex: (y) => o = y, exitToolResponse: () => i, appendExitToolResponse: (y) => i += y });
|
|
80890
80890
|
} catch (y) {
|
|
80891
|
-
console.error("Error processing line:", p, y),
|
|
80891
|
+
console.error("Error processing line:", p, y), d.enqueue(n.encode(p + `
|
|
80892
80892
|
`));
|
|
80893
80893
|
}
|
|
80894
80894
|
}
|
|
80895
80895
|
} catch (A) {
|
|
80896
|
-
console.error("Stream error:", A),
|
|
80896
|
+
console.error("Stream error:", A), d.error(A);
|
|
80897
80897
|
} finally {
|
|
80898
80898
|
try {
|
|
80899
|
-
|
|
80899
|
+
h.releaseLock();
|
|
80900
80900
|
} catch (A) {
|
|
80901
80901
|
console.error("Error releasing reader lock:", A);
|
|
80902
80902
|
}
|
|
80903
|
-
|
|
80903
|
+
d.close();
|
|
80904
80904
|
}
|
|
80905
80905
|
} });
|
|
80906
80906
|
return new Response(l, { status: e.status, statusText: e.statusText, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
@@ -80930,23 +80930,23 @@ var Ji = class {
|
|
|
80930
80930
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
80931
80931
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
80932
80932
|
if (!e.body) return e;
|
|
80933
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = false, i = "", u = false, l = false,
|
|
80934
|
-
let g = e.body.getReader(), A = (b,
|
|
80933
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = false, i = "", u = false, l = false, d = "", h = new ReadableStream({ async start(f) {
|
|
80934
|
+
let g = e.body.getReader(), A = (b, E, p) => {
|
|
80935
80935
|
let y = b.split(`
|
|
80936
80936
|
`);
|
|
80937
|
-
for (let T of y) T.trim() &&
|
|
80937
|
+
for (let T of y) T.trim() && E.enqueue(p.encode(T + `
|
|
80938
80938
|
`));
|
|
80939
|
-
}, P = (b,
|
|
80940
|
-
let { controller: p, encoder: y } =
|
|
80939
|
+
}, P = (b, E) => {
|
|
80940
|
+
let { controller: p, encoder: y } = E;
|
|
80941
80941
|
if (b.startsWith("data: ") && b.trim() !== "data: [DONE]") {
|
|
80942
80942
|
let T = b.slice(6);
|
|
80943
80943
|
try {
|
|
80944
|
-
let
|
|
80945
|
-
if (
|
|
80944
|
+
let w = JSON.parse(T);
|
|
80945
|
+
if (w.usage && (this.logger?.debug({ usage: w.usage, hasToolCall: l }, "usage"), w.choices[0].finish_reason = l ? "tool_calls" : "stop"), w.choices?.[0]?.finish_reason === "error" && p.enqueue(y.encode(`data: ${JSON.stringify({ error: w.choices?.[0].error })}
|
|
80946
80946
|
|
|
80947
|
-
`)),
|
|
80948
|
-
|
|
80949
|
-
let F = { ...
|
|
80947
|
+
`)), w.choices?.[0]?.delta?.content && !E.hasTextContent() && E.setHasTextContent(true), w.choices?.[0]?.delta?.reasoning) {
|
|
80948
|
+
E.appendReasoningContent(w.choices[0].delta.reasoning);
|
|
80949
|
+
let F = { ...w, choices: [{ ...w.choices?.[0], delta: { ...w.choices[0].delta, thinking: { content: w.choices[0].delta.reasoning } } }] };
|
|
80950
80950
|
F.choices?.[0]?.delta && delete F.choices[0].delta.reasoning;
|
|
80951
80951
|
let B = `data: ${JSON.stringify(F)}
|
|
80952
80952
|
|
|
@@ -80954,19 +80954,19 @@ var Ji = class {
|
|
|
80954
80954
|
p.enqueue(y.encode(B));
|
|
80955
80955
|
return;
|
|
80956
80956
|
}
|
|
80957
|
-
if (
|
|
80958
|
-
|
|
80959
|
-
let F = Date.now().toString(), B = { ...
|
|
80957
|
+
if (w.choices?.[0]?.delta?.content && E.reasoningContent() && !E.isReasoningComplete()) {
|
|
80958
|
+
E.setReasoningComplete(true);
|
|
80959
|
+
let F = Date.now().toString(), B = { ...w, choices: [{ ...w.choices?.[0], delta: { ...w.choices[0].delta, content: null, thinking: { content: E.reasoningContent(), signature: F } } }] };
|
|
80960
80960
|
B.choices?.[0]?.delta && delete B.choices[0].delta.reasoning;
|
|
80961
80961
|
let G = `data: ${JSON.stringify(B)}
|
|
80962
80962
|
|
|
80963
80963
|
`;
|
|
80964
80964
|
p.enqueue(y.encode(G));
|
|
80965
80965
|
}
|
|
80966
|
-
|
|
80966
|
+
w.choices?.[0]?.delta?.reasoning && delete w.choices[0].delta.reasoning, w.choices?.[0]?.delta?.tool_calls?.length && !Number.isNaN(parseInt(w.choices?.[0]?.delta?.tool_calls[0].id, 10)) && w.choices?.[0]?.delta?.tool_calls.forEach((F) => {
|
|
80967
80967
|
F.id = `call_${Wt()}`;
|
|
80968
|
-
}),
|
|
80969
|
-
let S = `data: ${JSON.stringify(
|
|
80968
|
+
}), w.choices?.[0]?.delta?.tool_calls?.length && !l && (l = true), w.choices?.[0]?.delta?.tool_calls?.length && E.hasTextContent() && (typeof w.choices[0].index == "number" ? w.choices[0].index += 1 : w.choices[0].index = 1);
|
|
80969
|
+
let S = `data: ${JSON.stringify(w)}
|
|
80970
80970
|
|
|
80971
80971
|
`;
|
|
80972
80972
|
p.enqueue(y.encode(S));
|
|
@@ -80979,55 +80979,55 @@ var Ji = class {
|
|
|
80979
80979
|
};
|
|
80980
80980
|
try {
|
|
80981
80981
|
for (; ; ) {
|
|
80982
|
-
let { done: b, value:
|
|
80982
|
+
let { done: b, value: E } = await g.read();
|
|
80983
80983
|
if (b) {
|
|
80984
|
-
|
|
80984
|
+
d.trim() && A(d, f, n);
|
|
80985
80985
|
break;
|
|
80986
80986
|
}
|
|
80987
|
-
if (!
|
|
80987
|
+
if (!E || E.length === 0) continue;
|
|
80988
80988
|
let p;
|
|
80989
80989
|
try {
|
|
80990
|
-
p = t.decode(
|
|
80990
|
+
p = t.decode(E, { stream: true });
|
|
80991
80991
|
} catch (T) {
|
|
80992
80992
|
console.warn("Failed to decode chunk", T);
|
|
80993
80993
|
continue;
|
|
80994
80994
|
}
|
|
80995
80995
|
if (p.length === 0) continue;
|
|
80996
|
-
if (
|
|
80996
|
+
if (d += p, d.length > 1e6) {
|
|
80997
80997
|
console.warn("Buffer size exceeds limit, processing partial data");
|
|
80998
|
-
let T =
|
|
80998
|
+
let T = d.split(`
|
|
80999
80999
|
`);
|
|
81000
|
-
|
|
81001
|
-
for (let
|
|
81002
|
-
P(
|
|
81000
|
+
d = T.pop() || "";
|
|
81001
|
+
for (let w of T) if (w.trim()) try {
|
|
81002
|
+
P(w, { controller: f, encoder: n, hasTextContent: () => o, setHasTextContent: (S) => o = S, reasoningContent: () => i, appendReasoningContent: (S) => i += S, isReasoningComplete: () => u, setReasoningComplete: (S) => u = S });
|
|
81003
81003
|
} catch (S) {
|
|
81004
|
-
console.error("Error processing line:",
|
|
81004
|
+
console.error("Error processing line:", w, S), f.enqueue(n.encode(w + `
|
|
81005
81005
|
`));
|
|
81006
81006
|
}
|
|
81007
81007
|
continue;
|
|
81008
81008
|
}
|
|
81009
|
-
let y =
|
|
81009
|
+
let y = d.split(`
|
|
81010
81010
|
`);
|
|
81011
|
-
|
|
81011
|
+
d = y.pop() || "";
|
|
81012
81012
|
for (let T of y) if (T.trim()) try {
|
|
81013
|
-
P(T, { controller:
|
|
81014
|
-
} catch (
|
|
81015
|
-
console.error("Error processing line:", T,
|
|
81013
|
+
P(T, { controller: f, encoder: n, hasTextContent: () => o, setHasTextContent: (w) => o = w, reasoningContent: () => i, appendReasoningContent: (w) => i += w, isReasoningComplete: () => u, setReasoningComplete: (w) => u = w });
|
|
81014
|
+
} catch (w) {
|
|
81015
|
+
console.error("Error processing line:", T, w), f.enqueue(n.encode(T + `
|
|
81016
81016
|
`));
|
|
81017
81017
|
}
|
|
81018
81018
|
}
|
|
81019
81019
|
} catch (b) {
|
|
81020
|
-
console.error("Stream error:", b),
|
|
81020
|
+
console.error("Stream error:", b), f.error(b);
|
|
81021
81021
|
} finally {
|
|
81022
81022
|
try {
|
|
81023
81023
|
g.releaseLock();
|
|
81024
81024
|
} catch (b) {
|
|
81025
81025
|
console.error("Error releasing reader lock:", b);
|
|
81026
81026
|
}
|
|
81027
|
-
|
|
81027
|
+
f.close();
|
|
81028
81028
|
}
|
|
81029
81029
|
} });
|
|
81030
|
-
return new Response(
|
|
81030
|
+
return new Response(h, { status: e.status, statusText: e.statusText, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
81031
81031
|
}
|
|
81032
81032
|
return e;
|
|
81033
81033
|
}
|
|
@@ -81060,14 +81060,14 @@ var Vi = class {
|
|
|
81060
81060
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
81061
81061
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
81062
81062
|
if (!e.body) return e;
|
|
81063
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = false, i = "", u = false, l = "",
|
|
81064
|
-
let
|
|
81063
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = false, i = "", u = false, l = "", d = new ReadableStream({ async start(h) {
|
|
81064
|
+
let f = e.body.getReader(), g = (P, b, E) => {
|
|
81065
81065
|
let p = P.split(`
|
|
81066
81066
|
`);
|
|
81067
|
-
for (let y of p) y.trim() && b.enqueue(
|
|
81067
|
+
for (let y of p) y.trim() && b.enqueue(E.encode(y + `
|
|
81068
81068
|
`));
|
|
81069
81069
|
}, A = (P, b) => {
|
|
81070
|
-
let { controller:
|
|
81070
|
+
let { controller: E, encoder: p } = b;
|
|
81071
81071
|
if (P.startsWith("data: ") && P.trim() !== "data: [DONE]") {
|
|
81072
81072
|
let y = P.slice(6);
|
|
81073
81073
|
try {
|
|
@@ -81076,42 +81076,42 @@ var Vi = class {
|
|
|
81076
81076
|
T.choices?.[0]?.delta?.content && !b.hasTextContent() && b.setHasTextContent(true), T.choices?.[0]?.delta?.tool_calls?.length && T.choices?.[0]?.delta?.tool_calls.forEach((S) => {
|
|
81077
81077
|
S.id = `call_${Wt()}`;
|
|
81078
81078
|
}), T.choices?.[0]?.delta?.tool_calls?.length && b.hasTextContent() && (typeof T.choices[0].index == "number" ? T.choices[0].index += 1 : T.choices[0].index = 1);
|
|
81079
|
-
let
|
|
81079
|
+
let w = `data: ${JSON.stringify(T)}
|
|
81080
81080
|
|
|
81081
81081
|
`;
|
|
81082
|
-
|
|
81082
|
+
E.enqueue(p.encode(w));
|
|
81083
81083
|
} catch {
|
|
81084
|
-
|
|
81084
|
+
E.enqueue(p.encode(P + `
|
|
81085
81085
|
`));
|
|
81086
81086
|
}
|
|
81087
|
-
} else
|
|
81087
|
+
} else E.enqueue(p.encode(P + `
|
|
81088
81088
|
`));
|
|
81089
81089
|
};
|
|
81090
81090
|
try {
|
|
81091
81091
|
for (; ; ) {
|
|
81092
|
-
let { done: P, value: b } = await
|
|
81092
|
+
let { done: P, value: b } = await f.read();
|
|
81093
81093
|
if (P) {
|
|
81094
|
-
l.trim() && g(l,
|
|
81094
|
+
l.trim() && g(l, h, n);
|
|
81095
81095
|
break;
|
|
81096
81096
|
}
|
|
81097
81097
|
if (!b || b.length === 0) continue;
|
|
81098
|
-
let
|
|
81098
|
+
let E;
|
|
81099
81099
|
try {
|
|
81100
|
-
|
|
81100
|
+
E = t.decode(b, { stream: true });
|
|
81101
81101
|
} catch (y) {
|
|
81102
81102
|
console.warn("Failed to decode chunk", y);
|
|
81103
81103
|
continue;
|
|
81104
81104
|
}
|
|
81105
|
-
if (
|
|
81106
|
-
if (l +=
|
|
81105
|
+
if (E.length === 0) continue;
|
|
81106
|
+
if (l += E, l.length > 1e6) {
|
|
81107
81107
|
console.warn("Buffer size exceeds limit, processing partial data");
|
|
81108
81108
|
let y = l.split(`
|
|
81109
81109
|
`);
|
|
81110
81110
|
l = y.pop() || "";
|
|
81111
81111
|
for (let T of y) if (T.trim()) try {
|
|
81112
|
-
A(T, { controller:
|
|
81113
|
-
} catch (
|
|
81114
|
-
console.error("Error processing line:", T,
|
|
81112
|
+
A(T, { controller: h, encoder: n, hasTextContent: () => o, setHasTextContent: (w) => o = w, reasoningContent: () => i, appendReasoningContent: (w) => i += w, isReasoningComplete: () => u, setReasoningComplete: (w) => u = w });
|
|
81113
|
+
} catch (w) {
|
|
81114
|
+
console.error("Error processing line:", T, w), h.enqueue(n.encode(T + `
|
|
81115
81115
|
`));
|
|
81116
81116
|
}
|
|
81117
81117
|
continue;
|
|
@@ -81120,24 +81120,24 @@ var Vi = class {
|
|
|
81120
81120
|
`);
|
|
81121
81121
|
l = p.pop() || "";
|
|
81122
81122
|
for (let y of p) if (y.trim()) try {
|
|
81123
|
-
A(y, { controller:
|
|
81123
|
+
A(y, { controller: h, encoder: n, hasTextContent: () => o, setHasTextContent: (T) => o = T, reasoningContent: () => i, appendReasoningContent: (T) => i += T, isReasoningComplete: () => u, setReasoningComplete: (T) => u = T });
|
|
81124
81124
|
} catch (T) {
|
|
81125
|
-
console.error("Error processing line:", y, T),
|
|
81125
|
+
console.error("Error processing line:", y, T), h.enqueue(n.encode(y + `
|
|
81126
81126
|
`));
|
|
81127
81127
|
}
|
|
81128
81128
|
}
|
|
81129
81129
|
} catch (P) {
|
|
81130
|
-
console.error("Stream error:", P),
|
|
81130
|
+
console.error("Stream error:", P), h.error(P);
|
|
81131
81131
|
} finally {
|
|
81132
81132
|
try {
|
|
81133
|
-
|
|
81133
|
+
f.releaseLock();
|
|
81134
81134
|
} catch (P) {
|
|
81135
81135
|
console.error("Error releasing reader lock:", P);
|
|
81136
81136
|
}
|
|
81137
|
-
|
|
81137
|
+
h.close();
|
|
81138
81138
|
}
|
|
81139
81139
|
} });
|
|
81140
|
-
return new Response(
|
|
81140
|
+
return new Response(d, { status: e.status, statusText: e.statusText, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
81141
81141
|
}
|
|
81142
81142
|
return e;
|
|
81143
81143
|
}
|
|
@@ -81239,20 +81239,20 @@ var nA = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: `
|
|
|
81239
81239
|
`, r: "\r", t: " " };
|
|
81240
81240
|
function wl(r) {
|
|
81241
81241
|
let e = 0, t = "";
|
|
81242
|
-
|
|
81242
|
+
h(["```", "[```", "{```"]), i() || Ce(), h(["```", "```]", "```}"]);
|
|
81243
81243
|
let o = g(",");
|
|
81244
81244
|
for (o && u(), _l(r[e]) && ig(t) ? (o || (t = kt(t, ",")), y()) : o && (t = Kn(t, ",")); r[e] === "}" || r[e] === "]"; ) e++, u();
|
|
81245
81245
|
if (e >= r.length) return t;
|
|
81246
81246
|
Ee();
|
|
81247
81247
|
function i() {
|
|
81248
81248
|
u();
|
|
81249
|
-
let J =
|
|
81249
|
+
let J = E() || p() || T() || S() || F() || G(false) || Z();
|
|
81250
81250
|
return u(), J;
|
|
81251
81251
|
}
|
|
81252
81252
|
function u() {
|
|
81253
81253
|
let J = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, V = e, se = l(J);
|
|
81254
81254
|
do
|
|
81255
|
-
se =
|
|
81255
|
+
se = d(), se && (se = l(J));
|
|
81256
81256
|
while (se);
|
|
81257
81257
|
return e > V;
|
|
81258
81258
|
}
|
|
@@ -81263,7 +81263,7 @@ function wl(r) {
|
|
|
81263
81263
|
else break;
|
|
81264
81264
|
return se.length > 0 ? (t += se, true) : false;
|
|
81265
81265
|
}
|
|
81266
|
-
function
|
|
81266
|
+
function d() {
|
|
81267
81267
|
if (r[e] === "/" && r[e + 1] === "*") {
|
|
81268
81268
|
for (; e < r.length && !sA(r, e); ) e++;
|
|
81269
81269
|
return e += 2, true;
|
|
@@ -81275,14 +81275,14 @@ function wl(r) {
|
|
|
81275
81275
|
}
|
|
81276
81276
|
return false;
|
|
81277
81277
|
}
|
|
81278
|
-
function
|
|
81279
|
-
if (
|
|
81278
|
+
function h(J) {
|
|
81279
|
+
if (f(J)) {
|
|
81280
81280
|
if (hl(r[e])) for (; e < r.length && pl(r[e]); ) e++;
|
|
81281
81281
|
return u(), true;
|
|
81282
81282
|
}
|
|
81283
81283
|
return false;
|
|
81284
81284
|
}
|
|
81285
|
-
function
|
|
81285
|
+
function f(J) {
|
|
81286
81286
|
for (let V of J) {
|
|
81287
81287
|
let se = e + V.length;
|
|
81288
81288
|
if (r.slice(e, se) === V) return e = se, true;
|
|
@@ -81301,7 +81301,7 @@ function wl(r) {
|
|
|
81301
81301
|
function b() {
|
|
81302
81302
|
return u(), r[e] === "." && r[e + 1] === "." && r[e + 2] === "." ? (e += 3, u(), A(","), true) : false;
|
|
81303
81303
|
}
|
|
81304
|
-
function
|
|
81304
|
+
function E() {
|
|
81305
81305
|
if (r[e] === "{") {
|
|
81306
81306
|
t += "{", e++, u(), A(",") && u();
|
|
81307
81307
|
let J = true;
|
|
@@ -81350,14 +81350,14 @@ ${t}
|
|
|
81350
81350
|
if (e === V) return ue = kt(ue, '"'), t += ue, true;
|
|
81351
81351
|
if (Ue(r[e])) {
|
|
81352
81352
|
let ge = e, ut = ue.length;
|
|
81353
|
-
if (ue += '"', e++, t += ue, u(false), J || e >= r.length || Is(r[e]) || Ns(r[e]) || qr(r[e])) return
|
|
81353
|
+
if (ue += '"', e++, t += ue, u(false), J || e >= r.length || Is(r[e]) || Ns(r[e]) || qr(r[e])) return w(), true;
|
|
81354
81354
|
let ke = H(ge - 1), Ne = r.charAt(ke);
|
|
81355
81355
|
if (Ne === ",") return e = ve, t = t.substring(0, W), T(false, ke);
|
|
81356
81356
|
if (Is(Ne)) return e = ve, t = t.substring(0, W), T(true);
|
|
81357
81357
|
t = t.substring(0, W), e = ge + 1, ue = `${ue.substring(0, ut)}\\${ue.substring(ut)}`;
|
|
81358
81358
|
} else if (J && yl(r[e])) {
|
|
81359
81359
|
if (r[e - 1] === ":" && ml.test(r.substring(ve + 1, e + 2))) for (; e < r.length && gl.test(r[e]); ) ue += r[e], e++;
|
|
81360
|
-
return ue = kt(ue, '"'), t += ue,
|
|
81360
|
+
return ue = kt(ue, '"'), t += ue, w(), true;
|
|
81361
81361
|
} else if (r[e] === "\\") {
|
|
81362
81362
|
let ge = r.charAt(e + 1);
|
|
81363
81363
|
if (nA[ge] !== void 0) ue += r.slice(e, e + 2), e += 2;
|
|
@@ -81375,7 +81375,7 @@ ${t}
|
|
|
81375
81375
|
}
|
|
81376
81376
|
return false;
|
|
81377
81377
|
}
|
|
81378
|
-
function
|
|
81378
|
+
function w() {
|
|
81379
81379
|
let J = false;
|
|
81380
81380
|
for (u(); r[e] === "+"; ) {
|
|
81381
81381
|
J = true, e++, u(), t = Kn(t, '"', true);
|
|
@@ -81498,27 +81498,27 @@ var Xi = class {
|
|
|
81498
81498
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
81499
81499
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
81500
81500
|
if (!e.body) return e;
|
|
81501
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = {}, i = false, u = "", l = false,
|
|
81501
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = {}, i = false, u = "", l = false, d = false, h = "", f = new ReadableStream({ async start(g) {
|
|
81502
81502
|
let A = e.body.getReader(), P = (p, y, T) => {
|
|
81503
|
-
let
|
|
81503
|
+
let w = p.split(`
|
|
81504
81504
|
`);
|
|
81505
|
-
for (let S of
|
|
81505
|
+
for (let S of w) S.trim() && y.enqueue(T.encode(S + `
|
|
81506
81506
|
`));
|
|
81507
81507
|
}, b = (p, y, T) => {
|
|
81508
|
-
let
|
|
81508
|
+
let w = "";
|
|
81509
81509
|
try {
|
|
81510
|
-
|
|
81510
|
+
w = Al(o.arguments || "", this.logger);
|
|
81511
81511
|
} catch (G) {
|
|
81512
|
-
console.error(`${G.message} ${G.stack} \u5DE5\u5177\u8C03\u7528\u53C2\u6570\u89E3\u6790\u5931\u8D25: ${JSON.stringify(o)}`),
|
|
81512
|
+
console.error(`${G.message} ${G.stack} \u5DE5\u5177\u8C03\u7528\u53C2\u6570\u89E3\u6790\u5931\u8D25: ${JSON.stringify(o)}`), w = o.arguments || "";
|
|
81513
81513
|
}
|
|
81514
|
-
let S = { role: "assistant", tool_calls: [{ function: { name: o.name, arguments:
|
|
81514
|
+
let S = { role: "assistant", tool_calls: [{ function: { name: o.name, arguments: w }, id: o.id, index: o.index, type: "function" }] }, F = { ...p, choices: [{ ...p.choices[0], delta: S }] };
|
|
81515
81515
|
F.choices[0].delta.content !== void 0 && delete F.choices[0].delta.content;
|
|
81516
81516
|
let B = `data: ${JSON.stringify(F)}
|
|
81517
81517
|
|
|
81518
81518
|
`;
|
|
81519
81519
|
y.enqueue(T.encode(B));
|
|
81520
|
-
},
|
|
81521
|
-
let { controller: T, encoder:
|
|
81520
|
+
}, E = (p, y) => {
|
|
81521
|
+
let { controller: T, encoder: w } = y;
|
|
81522
81522
|
if (p.startsWith("data: ") && p.trim() !== "data: [DONE]") {
|
|
81523
81523
|
let S = p.slice(6);
|
|
81524
81524
|
try {
|
|
@@ -81530,37 +81530,37 @@ var Xi = class {
|
|
|
81530
81530
|
let Z = `data: ${JSON.stringify(F)}
|
|
81531
81531
|
|
|
81532
81532
|
`;
|
|
81533
|
-
T.enqueue(
|
|
81533
|
+
T.enqueue(w.encode(Z));
|
|
81534
81534
|
return;
|
|
81535
81535
|
} else if (o.index === G.index) {
|
|
81536
81536
|
G.function?.arguments && (o.arguments += G.function.arguments);
|
|
81537
81537
|
return;
|
|
81538
81538
|
} else {
|
|
81539
|
-
b(F, T,
|
|
81539
|
+
b(F, T, w), o = { index: G.index, name: G.function?.name || "", id: G.id || "", arguments: G.function?.arguments || "" };
|
|
81540
81540
|
return;
|
|
81541
81541
|
}
|
|
81542
81542
|
}
|
|
81543
81543
|
if (F.choices?.[0]?.finish_reason === "tool_calls" && o.index !== void 0) {
|
|
81544
|
-
b(F, T,
|
|
81544
|
+
b(F, T, w), o = {};
|
|
81545
81545
|
return;
|
|
81546
81546
|
}
|
|
81547
81547
|
F.choices?.[0]?.delta?.tool_calls?.length && y.hasTextContent() && (typeof F.choices[0].index == "number" ? F.choices[0].index += 1 : F.choices[0].index = 1);
|
|
81548
81548
|
let B = `data: ${JSON.stringify(F)}
|
|
81549
81549
|
|
|
81550
81550
|
`;
|
|
81551
|
-
T.enqueue(
|
|
81551
|
+
T.enqueue(w.encode(B));
|
|
81552
81552
|
} catch {
|
|
81553
|
-
T.enqueue(
|
|
81553
|
+
T.enqueue(w.encode(p + `
|
|
81554
81554
|
`));
|
|
81555
81555
|
}
|
|
81556
|
-
} else T.enqueue(
|
|
81556
|
+
} else T.enqueue(w.encode(p + `
|
|
81557
81557
|
`));
|
|
81558
81558
|
};
|
|
81559
81559
|
try {
|
|
81560
81560
|
for (; ; ) {
|
|
81561
81561
|
let { done: p, value: y } = await A.read();
|
|
81562
81562
|
if (p) {
|
|
81563
|
-
|
|
81563
|
+
h.trim() && P(h, g, n);
|
|
81564
81564
|
break;
|
|
81565
81565
|
}
|
|
81566
81566
|
if (!y || y.length === 0) continue;
|
|
@@ -81572,24 +81572,24 @@ var Xi = class {
|
|
|
81572
81572
|
continue;
|
|
81573
81573
|
}
|
|
81574
81574
|
if (T.length === 0) continue;
|
|
81575
|
-
if (
|
|
81575
|
+
if (h += T, h.length > 1e6) {
|
|
81576
81576
|
console.warn("Buffer size exceeds limit, processing partial data");
|
|
81577
|
-
let S =
|
|
81577
|
+
let S = h.split(`
|
|
81578
81578
|
`);
|
|
81579
|
-
|
|
81579
|
+
h = S.pop() || "";
|
|
81580
81580
|
for (let F of S) if (F.trim()) try {
|
|
81581
|
-
|
|
81581
|
+
E(F, { controller: g, encoder: n, hasTextContent: () => i, setHasTextContent: (B) => i = B, reasoningContent: () => u, appendReasoningContent: (B) => u += B, isReasoningComplete: () => l, setReasoningComplete: (B) => l = B });
|
|
81582
81582
|
} catch (B) {
|
|
81583
81583
|
console.error("Error processing line:", F, B), g.enqueue(n.encode(F + `
|
|
81584
81584
|
`));
|
|
81585
81585
|
}
|
|
81586
81586
|
continue;
|
|
81587
81587
|
}
|
|
81588
|
-
let
|
|
81588
|
+
let w = h.split(`
|
|
81589
81589
|
`);
|
|
81590
|
-
|
|
81591
|
-
for (let S of
|
|
81592
|
-
|
|
81590
|
+
h = w.pop() || "";
|
|
81591
|
+
for (let S of w) if (S.trim()) try {
|
|
81592
|
+
E(S, { controller: g, encoder: n, hasTextContent: () => i, setHasTextContent: (F) => i = F, reasoningContent: () => u, appendReasoningContent: (F) => u += F, isReasoningComplete: () => l, setReasoningComplete: (F) => l = F });
|
|
81593
81593
|
} catch (F) {
|
|
81594
81594
|
console.error("Error processing line:", S, F), g.enqueue(n.encode(S + `
|
|
81595
81595
|
`));
|
|
@@ -81606,7 +81606,7 @@ var Xi = class {
|
|
|
81606
81606
|
g.close();
|
|
81607
81607
|
}
|
|
81608
81608
|
} });
|
|
81609
|
-
return new Response(
|
|
81609
|
+
return new Response(f, { status: e.status, statusText: e.statusText, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
81610
81610
|
}
|
|
81611
81611
|
return e;
|
|
81612
81612
|
}
|
|
@@ -81628,14 +81628,14 @@ var Qi = class {
|
|
|
81628
81628
|
return t.choices[0]?.message.reasoning_content && (t.thinking = { content: t.choices[0]?.message.reasoning_content }), new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
81629
81629
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
81630
81630
|
if (!e.body) return e;
|
|
81631
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = "", i = false, u = "", l = new ReadableStream({ async start(
|
|
81632
|
-
let
|
|
81633
|
-
let
|
|
81631
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = "", i = false, u = "", l = new ReadableStream({ async start(d) {
|
|
81632
|
+
let h = e.body.getReader(), f = (A, P, b) => {
|
|
81633
|
+
let E = A.split(`
|
|
81634
81634
|
`);
|
|
81635
|
-
for (let p of
|
|
81635
|
+
for (let p of E) p.trim() && P.enqueue(b.encode(p + `
|
|
81636
81636
|
`));
|
|
81637
81637
|
}, g = (A, P) => {
|
|
81638
|
-
let { controller: b, encoder:
|
|
81638
|
+
let { controller: b, encoder: E } = P;
|
|
81639
81639
|
if (this.logger?.debug({ line: A }, "Processing reason line"), A.startsWith("data: ") && A.trim() !== "data: [DONE]") try {
|
|
81640
81640
|
let p = JSON.parse(A.slice(6));
|
|
81641
81641
|
if (console.log(JSON.stringify(p)), p.choices?.[0]?.delta?.reasoning_content) {
|
|
@@ -81645,60 +81645,60 @@ var Qi = class {
|
|
|
81645
81645
|
let T = `data: ${JSON.stringify(y)}
|
|
81646
81646
|
|
|
81647
81647
|
`;
|
|
81648
|
-
b.enqueue(
|
|
81648
|
+
b.enqueue(E.encode(T));
|
|
81649
81649
|
return;
|
|
81650
81650
|
}
|
|
81651
81651
|
if ((p.choices?.[0]?.delta?.content || p.choices?.[0]?.delta?.tool_calls) && P.reasoningContent() && !P.isReasoningComplete()) {
|
|
81652
81652
|
P.setReasoningComplete(true);
|
|
81653
81653
|
let y = Date.now().toString(), T = { ...p, choices: [{ ...p.choices[0], delta: { ...p.choices[0].delta, content: null, thinking: { content: P.reasoningContent(), signature: y } } }] };
|
|
81654
81654
|
delete T.choices[0].delta.reasoning_content;
|
|
81655
|
-
let
|
|
81655
|
+
let w = `data: ${JSON.stringify(T)}
|
|
81656
81656
|
|
|
81657
81657
|
`;
|
|
81658
|
-
b.enqueue(
|
|
81658
|
+
b.enqueue(E.encode(w));
|
|
81659
81659
|
}
|
|
81660
81660
|
if (p.choices?.[0]?.delta?.reasoning_content && delete p.choices[0].delta.reasoning_content, p.choices?.[0]?.delta && Object.keys(p.choices[0].delta).length > 0) {
|
|
81661
81661
|
P.isReasoningComplete() && p.choices[0].index++;
|
|
81662
81662
|
let y = `data: ${JSON.stringify(p)}
|
|
81663
81663
|
|
|
81664
81664
|
`;
|
|
81665
|
-
b.enqueue(
|
|
81665
|
+
b.enqueue(E.encode(y));
|
|
81666
81666
|
}
|
|
81667
81667
|
} catch {
|
|
81668
|
-
b.enqueue(
|
|
81668
|
+
b.enqueue(E.encode(A + `
|
|
81669
81669
|
`));
|
|
81670
81670
|
}
|
|
81671
|
-
else b.enqueue(
|
|
81671
|
+
else b.enqueue(E.encode(A + `
|
|
81672
81672
|
`));
|
|
81673
81673
|
};
|
|
81674
81674
|
try {
|
|
81675
81675
|
for (; ; ) {
|
|
81676
|
-
let { done: A, value: P } = await
|
|
81676
|
+
let { done: A, value: P } = await h.read();
|
|
81677
81677
|
if (A) {
|
|
81678
|
-
u.trim() &&
|
|
81678
|
+
u.trim() && f(u, d, n);
|
|
81679
81679
|
break;
|
|
81680
81680
|
}
|
|
81681
81681
|
let b = t.decode(P, { stream: true });
|
|
81682
81682
|
u += b;
|
|
81683
|
-
let
|
|
81683
|
+
let E = u.split(`
|
|
81684
81684
|
`);
|
|
81685
|
-
u =
|
|
81686
|
-
for (let p of
|
|
81687
|
-
g(p, { controller:
|
|
81685
|
+
u = E.pop() || "";
|
|
81686
|
+
for (let p of E) if (p.trim()) try {
|
|
81687
|
+
g(p, { controller: d, encoder: n, reasoningContent: () => o, appendReasoningContent: (y) => o += y, isReasoningComplete: () => i, setReasoningComplete: (y) => i = y });
|
|
81688
81688
|
} catch (y) {
|
|
81689
|
-
console.error("Error processing line:", p, y),
|
|
81689
|
+
console.error("Error processing line:", p, y), d.enqueue(n.encode(p + `
|
|
81690
81690
|
`));
|
|
81691
81691
|
}
|
|
81692
81692
|
}
|
|
81693
81693
|
} catch (A) {
|
|
81694
|
-
console.error("Stream error:", A),
|
|
81694
|
+
console.error("Stream error:", A), d.error(A);
|
|
81695
81695
|
} finally {
|
|
81696
81696
|
try {
|
|
81697
|
-
|
|
81697
|
+
h.releaseLock();
|
|
81698
81698
|
} catch (A) {
|
|
81699
81699
|
console.error("Error releasing reader lock:", A);
|
|
81700
81700
|
}
|
|
81701
|
-
|
|
81701
|
+
d.close();
|
|
81702
81702
|
}
|
|
81703
81703
|
} });
|
|
81704
81704
|
return new Response(l, { status: e.status, statusText: e.statusText, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
@@ -81731,8 +81731,8 @@ function ug(r) {
|
|
|
81731
81731
|
let e = [];
|
|
81732
81732
|
for (let n = 0; n < r.messages.length; n++) {
|
|
81733
81733
|
let o = r.messages[n], i = n === r.messages.length - 1, u = o.role === "assistant", l = [];
|
|
81734
|
-
typeof o.content == "string" ? l.push({ type: "text", text: o.content }) : Array.isArray(o.content) && o.content.forEach((
|
|
81735
|
-
|
|
81734
|
+
typeof o.content == "string" ? l.push({ type: "text", text: o.content }) : Array.isArray(o.content) && o.content.forEach((d) => {
|
|
81735
|
+
d.type === "text" ? l.push({ type: "text", text: d.text || "" }) : d.type === "image_url" && l.push({ type: "image", source: { type: "base64", media_type: d.media_type || "image/jpeg", data: d.image_url.url } });
|
|
81736
81736
|
}), !(!i && l.length === 0 && !o.tool_calls && !o.content) && (i && u && l.length === 0 && o.tool_calls && l.push({ type: "text", text: "" }), e.push({ role: o.role === "assistant" ? "assistant" : "user", content: l }));
|
|
81737
81737
|
}
|
|
81738
81738
|
let t = { anthropic_version: "vertex-2023-10-16", messages: e, max_tokens: r.max_tokens || 1e3, stream: r.stream || false, ...r.temperature && { temperature: r.temperature } };
|
|
@@ -81753,64 +81753,64 @@ async function lg(r, e, t) {
|
|
|
81753
81753
|
return new Response(JSON.stringify(i), { status: r.status, statusText: r.statusText, headers: r.headers });
|
|
81754
81754
|
} else if (r.headers.get("Content-Type")?.includes("stream")) {
|
|
81755
81755
|
if (!r.body) return r;
|
|
81756
|
-
let n = new TextDecoder(), o = new TextEncoder(), i = (l,
|
|
81756
|
+
let n = new TextDecoder(), o = new TextEncoder(), i = (l, d) => {
|
|
81757
81757
|
if (l.startsWith("data: ")) {
|
|
81758
|
-
let
|
|
81759
|
-
if (
|
|
81760
|
-
t?.debug({ chunkStr:
|
|
81758
|
+
let h = l.slice(6).trim();
|
|
81759
|
+
if (h) {
|
|
81760
|
+
t?.debug({ chunkStr: h }, `${e} chunk:`);
|
|
81761
81761
|
try {
|
|
81762
|
-
let
|
|
81763
|
-
if (
|
|
81764
|
-
let g = { choices: [{ delta: { role: "assistant", content:
|
|
81765
|
-
|
|
81762
|
+
let f = JSON.parse(h);
|
|
81763
|
+
if (f.type === "content_block_delta" && f.delta?.type === "text_delta") {
|
|
81764
|
+
let g = { choices: [{ delta: { role: "assistant", content: f.delta.text || "" }, finish_reason: null, index: 0, logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: f.id || "", model: f.model || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1", usage: { completion_tokens: f.usage?.output_tokens || 0, prompt_tokens: f.usage?.input_tokens || 0, total_tokens: (f.usage?.input_tokens || 0) + (f.usage?.output_tokens || 0) } };
|
|
81765
|
+
d.enqueue(o.encode(`data: ${JSON.stringify(g)}
|
|
81766
81766
|
|
|
81767
81767
|
`));
|
|
81768
|
-
} else if (
|
|
81769
|
-
let g = { choices: [{ delta: { tool_calls: [{ index:
|
|
81770
|
-
|
|
81768
|
+
} else if (f.type === "content_block_delta" && f.delta?.type === "input_json_delta") {
|
|
81769
|
+
let g = { choices: [{ delta: { tool_calls: [{ index: f.index || 0, function: { arguments: f.delta.partial_json || "" } }] }, finish_reason: null, index: 0, logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: f.id || "", model: f.model || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1", usage: { completion_tokens: f.usage?.output_tokens || 0, prompt_tokens: f.usage?.input_tokens || 0, total_tokens: (f.usage?.input_tokens || 0) + (f.usage?.output_tokens || 0) } };
|
|
81770
|
+
d.enqueue(o.encode(`data: ${JSON.stringify(g)}
|
|
81771
81771
|
|
|
81772
81772
|
`));
|
|
81773
|
-
} else if (
|
|
81774
|
-
let g = { choices: [{ delta: { tool_calls: [{ index:
|
|
81775
|
-
|
|
81773
|
+
} else if (f.type === "content_block_start" && f.content_block?.type === "tool_use") {
|
|
81774
|
+
let g = { choices: [{ delta: { tool_calls: [{ index: f.index || 0, id: f.content_block.id, type: "function", function: { name: f.content_block.name, arguments: "" } }] }, finish_reason: null, index: 0, logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: f.id || "", model: f.model || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1", usage: { completion_tokens: f.usage?.output_tokens || 0, prompt_tokens: f.usage?.input_tokens || 0, total_tokens: (f.usage?.input_tokens || 0) + (f.usage?.output_tokens || 0) } };
|
|
81775
|
+
d.enqueue(o.encode(`data: ${JSON.stringify(g)}
|
|
81776
81776
|
|
|
81777
81777
|
`));
|
|
81778
|
-
} else if (
|
|
81779
|
-
let g = { choices: [{ delta: {}, finish_reason:
|
|
81780
|
-
|
|
81778
|
+
} else if (f.type === "message_delta") {
|
|
81779
|
+
let g = { choices: [{ delta: {}, finish_reason: f.delta?.stop_reason === "tool_use" ? "tool_calls" : f.delta?.stop_reason === "max_tokens" ? "length" : f.delta?.stop_reason === "stop_sequence" ? "content_filter" : "stop", index: 0, logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: f.id || "", model: f.model || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1", usage: { completion_tokens: f.usage?.output_tokens || 0, prompt_tokens: f.usage?.input_tokens || 0, total_tokens: (f.usage?.input_tokens || 0) + (f.usage?.output_tokens || 0) } };
|
|
81780
|
+
d.enqueue(o.encode(`data: ${JSON.stringify(g)}
|
|
81781
81781
|
|
|
81782
81782
|
`));
|
|
81783
|
-
} else if (
|
|
81783
|
+
} else if (f.type === "message_stop") d.enqueue(o.encode(`data: [DONE]
|
|
81784
81784
|
|
|
81785
81785
|
`));
|
|
81786
81786
|
else {
|
|
81787
|
-
let g = { choices: [{ delta: { role: "assistant", content:
|
|
81788
|
-
|
|
81787
|
+
let g = { choices: [{ delta: { role: "assistant", content: f.content?.[0]?.text || "" }, finish_reason: f.stop_reason?.toLowerCase() || null, index: 0, logprobs: null }], created: parseInt((/* @__PURE__ */ new Date()).getTime() / 1e3 + "", 10), id: f.id || "", model: f.model || "", object: "chat.completion.chunk", system_fingerprint: "fp_a49d71b8a1", usage: { completion_tokens: f.usage?.output_tokens || 0, prompt_tokens: f.usage?.input_tokens || 0, total_tokens: (f.usage?.input_tokens || 0) + (f.usage?.output_tokens || 0) } };
|
|
81788
|
+
d.enqueue(o.encode(`data: ${JSON.stringify(g)}
|
|
81789
81789
|
|
|
81790
81790
|
`));
|
|
81791
81791
|
}
|
|
81792
|
-
} catch (
|
|
81793
|
-
t?.error(`Error parsing ${e} stream chunk`,
|
|
81792
|
+
} catch (f) {
|
|
81793
|
+
t?.error(`Error parsing ${e} stream chunk`, h, f.message);
|
|
81794
81794
|
}
|
|
81795
81795
|
}
|
|
81796
81796
|
}
|
|
81797
81797
|
}, u = new ReadableStream({ async start(l) {
|
|
81798
|
-
let
|
|
81798
|
+
let d = r.body.getReader(), h = "";
|
|
81799
81799
|
try {
|
|
81800
81800
|
for (; ; ) {
|
|
81801
|
-
let { done:
|
|
81802
|
-
if (
|
|
81803
|
-
|
|
81801
|
+
let { done: f, value: g } = await d.read();
|
|
81802
|
+
if (f) {
|
|
81803
|
+
h && i(h, l);
|
|
81804
81804
|
break;
|
|
81805
81805
|
}
|
|
81806
|
-
|
|
81807
|
-
let A =
|
|
81806
|
+
h += n.decode(g, { stream: true });
|
|
81807
|
+
let A = h.split(`
|
|
81808
81808
|
`);
|
|
81809
|
-
|
|
81809
|
+
h = A.pop() || "";
|
|
81810
81810
|
for (let P of A) i(P, l);
|
|
81811
81811
|
}
|
|
81812
|
-
} catch (
|
|
81813
|
-
l.error(
|
|
81812
|
+
} catch (f) {
|
|
81813
|
+
l.error(f);
|
|
81814
81814
|
} finally {
|
|
81815
81815
|
l.close();
|
|
81816
81816
|
}
|
|
@@ -81835,8 +81835,8 @@ var ta = class {
|
|
|
81835
81835
|
async transformRequestIn(e, t) {
|
|
81836
81836
|
let n = process.env.GOOGLE_CLOUD_PROJECT, o = process.env.GOOGLE_CLOUD_LOCATION || "us-east5";
|
|
81837
81837
|
if (!n && process.env.GOOGLE_APPLICATION_CREDENTIALS) try {
|
|
81838
|
-
let l = (await import("fs")).readFileSync(process.env.GOOGLE_APPLICATION_CREDENTIALS, "utf8"),
|
|
81839
|
-
|
|
81838
|
+
let l = (await import("fs")).readFileSync(process.env.GOOGLE_APPLICATION_CREDENTIALS, "utf8"), d = JSON.parse(l);
|
|
81839
|
+
d && d.project_id && (n = d.project_id);
|
|
81840
81840
|
} catch (u) {
|
|
81841
81841
|
console.error("Error extracting project_id from GOOGLE_APPLICATION_CREDENTIALS:", u);
|
|
81842
81842
|
}
|
|
@@ -81923,23 +81923,23 @@ var ia = class {
|
|
|
81923
81923
|
return new Response(JSON.stringify(t), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
81924
81924
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
81925
81925
|
if (!e.body) return e;
|
|
81926
|
-
let t = new TextDecoder(), n = new TextEncoder(), o = false, i = "", u = false, l = false,
|
|
81927
|
-
let g = e.body.getReader(), A = (b,
|
|
81926
|
+
let t = new TextDecoder(), n = new TextEncoder(), o = false, i = "", u = false, l = false, d = "", h = new ReadableStream({ async start(f) {
|
|
81927
|
+
let g = e.body.getReader(), A = (b, E, p) => {
|
|
81928
81928
|
let y = b.split(`
|
|
81929
81929
|
`);
|
|
81930
|
-
for (let T of y) T.trim() &&
|
|
81930
|
+
for (let T of y) T.trim() && E.enqueue(p.encode(T + `
|
|
81931
81931
|
`));
|
|
81932
|
-
}, P = (b,
|
|
81933
|
-
let { controller: p, encoder: y } =
|
|
81932
|
+
}, P = (b, E) => {
|
|
81933
|
+
let { controller: p, encoder: y } = E;
|
|
81934
81934
|
if (b.startsWith("data: ") && b.trim() !== "data: [DONE]") {
|
|
81935
81935
|
let T = b.slice(6);
|
|
81936
81936
|
try {
|
|
81937
|
-
let
|
|
81938
|
-
if (
|
|
81937
|
+
let w = JSON.parse(T);
|
|
81938
|
+
if (w.usage && (this.logger?.debug({ usage: w.usage, hasToolCall: l }, "usage"), w.choices[0].finish_reason = l ? "tool_calls" : "stop"), w.choices?.[0]?.finish_reason === "error" && p.enqueue(y.encode(`data: ${JSON.stringify({ error: w.choices?.[0].error })}
|
|
81939
81939
|
|
|
81940
|
-
`)),
|
|
81941
|
-
|
|
81942
|
-
let F = { ...
|
|
81940
|
+
`)), w.choices?.[0]?.delta?.content && !E.hasTextContent() && E.setHasTextContent(true), w.choices?.[0]?.delta?.reasoning) {
|
|
81941
|
+
E.appendReasoningContent(w.choices[0].delta.reasoning);
|
|
81942
|
+
let F = { ...w, choices: [{ ...w.choices?.[0], delta: { ...w.choices[0].delta, thinking: { content: w.choices[0].delta.reasoning } } }] };
|
|
81943
81943
|
F.choices?.[0]?.delta && delete F.choices[0].delta.reasoning;
|
|
81944
81944
|
let B = `data: ${JSON.stringify(F)}
|
|
81945
81945
|
|
|
@@ -81947,19 +81947,19 @@ var ia = class {
|
|
|
81947
81947
|
p.enqueue(y.encode(B));
|
|
81948
81948
|
return;
|
|
81949
81949
|
}
|
|
81950
|
-
if (
|
|
81951
|
-
|
|
81952
|
-
let F = Date.now().toString(), B = { ...
|
|
81950
|
+
if (w.choices?.[0]?.delta?.content && E.reasoningContent() && !E.isReasoningComplete()) {
|
|
81951
|
+
E.setReasoningComplete(true);
|
|
81952
|
+
let F = Date.now().toString(), B = { ...w, choices: [{ ...w.choices?.[0], delta: { ...w.choices[0].delta, content: null, thinking: { content: E.reasoningContent(), signature: F } } }] };
|
|
81953
81953
|
B.choices?.[0]?.delta && delete B.choices[0].delta.reasoning;
|
|
81954
81954
|
let G = `data: ${JSON.stringify(B)}
|
|
81955
81955
|
|
|
81956
81956
|
`;
|
|
81957
81957
|
p.enqueue(y.encode(G));
|
|
81958
81958
|
}
|
|
81959
|
-
|
|
81959
|
+
w.choices?.[0]?.delta?.reasoning && delete w.choices[0].delta.reasoning, w.choices?.[0]?.delta?.tool_calls?.length && !Number.isNaN(parseInt(w.choices?.[0]?.delta?.tool_calls[0].id, 10)) && w.choices?.[0]?.delta?.tool_calls.forEach((F) => {
|
|
81960
81960
|
F.id = `call_${Wt()}`;
|
|
81961
|
-
}),
|
|
81962
|
-
let S = `data: ${JSON.stringify(
|
|
81961
|
+
}), w.choices?.[0]?.delta?.tool_calls?.length && !l && (l = true), w.choices?.[0]?.delta?.tool_calls?.length && E.hasTextContent() && (typeof w.choices[0].index == "number" ? w.choices[0].index += 1 : w.choices[0].index = 1);
|
|
81962
|
+
let S = `data: ${JSON.stringify(w)}
|
|
81963
81963
|
|
|
81964
81964
|
`;
|
|
81965
81965
|
p.enqueue(y.encode(S));
|
|
@@ -81972,55 +81972,55 @@ var ia = class {
|
|
|
81972
81972
|
};
|
|
81973
81973
|
try {
|
|
81974
81974
|
for (; ; ) {
|
|
81975
|
-
let { done: b, value:
|
|
81975
|
+
let { done: b, value: E } = await g.read();
|
|
81976
81976
|
if (b) {
|
|
81977
|
-
|
|
81977
|
+
d.trim() && A(d, f, n);
|
|
81978
81978
|
break;
|
|
81979
81979
|
}
|
|
81980
|
-
if (!
|
|
81980
|
+
if (!E || E.length === 0) continue;
|
|
81981
81981
|
let p;
|
|
81982
81982
|
try {
|
|
81983
|
-
p = t.decode(
|
|
81983
|
+
p = t.decode(E, { stream: true });
|
|
81984
81984
|
} catch (T) {
|
|
81985
81985
|
console.warn("Failed to decode chunk", T);
|
|
81986
81986
|
continue;
|
|
81987
81987
|
}
|
|
81988
81988
|
if (p.length === 0) continue;
|
|
81989
|
-
if (
|
|
81989
|
+
if (d += p, d.length > 1e6) {
|
|
81990
81990
|
console.warn("Buffer size exceeds limit, processing partial data");
|
|
81991
|
-
let T =
|
|
81991
|
+
let T = d.split(`
|
|
81992
81992
|
`);
|
|
81993
|
-
|
|
81994
|
-
for (let
|
|
81995
|
-
P(
|
|
81993
|
+
d = T.pop() || "";
|
|
81994
|
+
for (let w of T) if (w.trim()) try {
|
|
81995
|
+
P(w, { controller: f, encoder: n, hasTextContent: () => o, setHasTextContent: (S) => o = S, reasoningContent: () => i, appendReasoningContent: (S) => i += S, isReasoningComplete: () => u, setReasoningComplete: (S) => u = S });
|
|
81996
81996
|
} catch (S) {
|
|
81997
|
-
console.error("Error processing line:",
|
|
81997
|
+
console.error("Error processing line:", w, S), f.enqueue(n.encode(w + `
|
|
81998
81998
|
`));
|
|
81999
81999
|
}
|
|
82000
82000
|
continue;
|
|
82001
82001
|
}
|
|
82002
|
-
let y =
|
|
82002
|
+
let y = d.split(`
|
|
82003
82003
|
`);
|
|
82004
|
-
|
|
82004
|
+
d = y.pop() || "";
|
|
82005
82005
|
for (let T of y) if (T.trim()) try {
|
|
82006
|
-
P(T, { controller:
|
|
82007
|
-
} catch (
|
|
82008
|
-
console.error("Error processing line:", T,
|
|
82006
|
+
P(T, { controller: f, encoder: n, hasTextContent: () => o, setHasTextContent: (w) => o = w, reasoningContent: () => i, appendReasoningContent: (w) => i += w, isReasoningComplete: () => u, setReasoningComplete: (w) => u = w });
|
|
82007
|
+
} catch (w) {
|
|
82008
|
+
console.error("Error processing line:", T, w), f.enqueue(n.encode(T + `
|
|
82009
82009
|
`));
|
|
82010
82010
|
}
|
|
82011
82011
|
}
|
|
82012
82012
|
} catch (b) {
|
|
82013
|
-
console.error("Stream error:", b),
|
|
82013
|
+
console.error("Stream error:", b), f.error(b);
|
|
82014
82014
|
} finally {
|
|
82015
82015
|
try {
|
|
82016
82016
|
g.releaseLock();
|
|
82017
82017
|
} catch (b) {
|
|
82018
82018
|
console.error("Error releasing reader lock:", b);
|
|
82019
82019
|
}
|
|
82020
|
-
|
|
82020
|
+
f.close();
|
|
82021
82021
|
}
|
|
82022
82022
|
} });
|
|
82023
|
-
return new Response(
|
|
82023
|
+
return new Response(h, { status: e.status, statusText: e.statusText, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive" } });
|
|
82024
82024
|
}
|
|
82025
82025
|
return e;
|
|
82026
82026
|
}
|
|
@@ -82074,41 +82074,41 @@ var aa = class {
|
|
|
82074
82074
|
return new Response(JSON.stringify(n), { status: e.status, statusText: e.statusText, headers: e.headers });
|
|
82075
82075
|
} else if (t.includes("text/event-stream")) {
|
|
82076
82076
|
if (!e.body) return e;
|
|
82077
|
-
let n = new TextDecoder(), o = new TextEncoder(), i = "", u = false, l = this,
|
|
82078
|
-
let
|
|
82077
|
+
let n = new TextDecoder(), o = new TextEncoder(), i = "", u = false, l = this, d = new ReadableStream({ async start(h) {
|
|
82078
|
+
let f = e.body.getReader(), g = -1, A = "", P = (b) => (b !== A && (g++, A = b), g);
|
|
82079
82079
|
try {
|
|
82080
82080
|
for (; ; ) {
|
|
82081
|
-
let { done: b, value:
|
|
82081
|
+
let { done: b, value: E } = await f.read();
|
|
82082
82082
|
if (b) {
|
|
82083
|
-
u ||
|
|
82083
|
+
u || h.enqueue(o.encode(`data: [DONE]
|
|
82084
82084
|
|
|
82085
82085
|
`));
|
|
82086
82086
|
break;
|
|
82087
82087
|
}
|
|
82088
|
-
let p = n.decode(
|
|
82088
|
+
let p = n.decode(E, { stream: true });
|
|
82089
82089
|
i += p;
|
|
82090
82090
|
let y = i.split(/\r?\n/);
|
|
82091
82091
|
i = y.pop() || "";
|
|
82092
82092
|
for (let T of y) if (T.trim()) try {
|
|
82093
82093
|
if (T.startsWith("event: ")) continue;
|
|
82094
82094
|
if (T.startsWith("data: ")) {
|
|
82095
|
-
let
|
|
82096
|
-
if (
|
|
82097
|
-
u = true,
|
|
82095
|
+
let w = T.slice(5).trim();
|
|
82096
|
+
if (w === "[DONE]") {
|
|
82097
|
+
u = true, h.enqueue(o.encode(`data: [DONE]
|
|
82098
82098
|
|
|
82099
82099
|
`));
|
|
82100
82100
|
continue;
|
|
82101
82101
|
}
|
|
82102
82102
|
try {
|
|
82103
|
-
let S = JSON.parse(
|
|
82103
|
+
let S = JSON.parse(w);
|
|
82104
82104
|
if (S.type === "response.output_text.delta") {
|
|
82105
82105
|
let F = { id: S.item_id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model, choices: [{ index: P(S.type), delta: { content: S.delta || "" }, finish_reason: null }] };
|
|
82106
|
-
|
|
82106
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(F)}
|
|
82107
82107
|
|
|
82108
82108
|
`));
|
|
82109
82109
|
} else if (S.type === "response.output_item.added" && S.item?.type === "function_call") {
|
|
82110
82110
|
let F = { id: S.item.call_id || S.item.id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model || "gpt-5-codex-", choices: [{ index: P(S.type), delta: { role: "assistant", tool_calls: [{ index: 0, id: S.item.call_id || S.item.id, function: { name: S.item.name || "", arguments: "" }, type: "function" }] }, finish_reason: null }] };
|
|
82111
|
-
|
|
82111
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(F)}
|
|
82112
82112
|
|
|
82113
82113
|
`));
|
|
82114
82114
|
} else if (S.type === "response.output_item.added" && S.item?.type === "message") {
|
|
@@ -82119,63 +82119,63 @@ var aa = class {
|
|
|
82119
82119
|
let B = { role: "assistant" };
|
|
82120
82120
|
if (F.length === 1 && F[0].type === "text" ? B.content = F[0].text : F.length > 0 && (B.content = F), B.content) {
|
|
82121
82121
|
let G = { id: S.item.id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model, choices: [{ index: P(S.type), delta: B, finish_reason: null }] };
|
|
82122
|
-
|
|
82122
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(G)}
|
|
82123
82123
|
|
|
82124
82124
|
`));
|
|
82125
82125
|
}
|
|
82126
82126
|
} else if (S.type === "response.output_text.annotation.added") {
|
|
82127
82127
|
let F = { id: S.item_id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model || "gpt-5-codex", choices: [{ index: P(S.type), delta: { annotations: [{ type: "url_citation", url_citation: { url: S.annotation?.url || "", title: S.annotation?.title || "", content: "", start_index: S.annotation?.start_index || 0, end_index: S.annotation?.end_index || 0 } }] }, finish_reason: null }] };
|
|
82128
|
-
|
|
82128
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(F)}
|
|
82129
82129
|
|
|
82130
82130
|
`));
|
|
82131
82131
|
} else if (S.type === "response.function_call_arguments.delta") {
|
|
82132
82132
|
let F = { id: S.item_id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model || "gpt-5-codex-", choices: [{ index: P(S.type), delta: { tool_calls: [{ index: 0, function: { arguments: S.delta || "" } }] }, finish_reason: null }] };
|
|
82133
|
-
|
|
82133
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(F)}
|
|
82134
82134
|
|
|
82135
82135
|
`));
|
|
82136
82136
|
} else if (S.type === "response.completed") {
|
|
82137
82137
|
let F = S.response?.output?.some((G) => G.type === "function_call") ? "tool_calls" : "stop", B = { id: S.response?.id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model || "gpt-5-codex-", choices: [{ index: 0, delta: {}, finish_reason: F }] };
|
|
82138
|
-
|
|
82138
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(B)}
|
|
82139
82139
|
|
|
82140
82140
|
`)), u = true;
|
|
82141
82141
|
} else if (S.type === "response.reasoning_summary_text.delta") {
|
|
82142
82142
|
let F = { id: S.item_id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model, choices: [{ index: P(S.type), delta: { thinking: { content: S.delta || "" } }, finish_reason: null }] };
|
|
82143
|
-
|
|
82143
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(F)}
|
|
82144
82144
|
|
|
82145
82145
|
`));
|
|
82146
82146
|
} else if (S.type === "response.reasoning_summary_part.done" && S.part) {
|
|
82147
82147
|
let F = { id: S.item_id || "chatcmpl-" + Date.now(), object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), model: S.response?.model, choices: [{ index: g, delta: { thinking: { signature: S.item_id } }, finish_reason: null }] };
|
|
82148
|
-
|
|
82148
|
+
h.enqueue(o.encode(`data: ${JSON.stringify(F)}
|
|
82149
82149
|
|
|
82150
82150
|
`));
|
|
82151
82151
|
}
|
|
82152
82152
|
} catch {
|
|
82153
|
-
|
|
82153
|
+
h.enqueue(o.encode(T + `
|
|
82154
82154
|
`));
|
|
82155
82155
|
}
|
|
82156
|
-
} else
|
|
82156
|
+
} else h.enqueue(o.encode(T + `
|
|
82157
82157
|
`));
|
|
82158
|
-
} catch (
|
|
82159
|
-
console.error("Error processing line:", T,
|
|
82158
|
+
} catch (w) {
|
|
82159
|
+
console.error("Error processing line:", T, w), h.enqueue(o.encode(T + `
|
|
82160
82160
|
`));
|
|
82161
82161
|
}
|
|
82162
82162
|
}
|
|
82163
|
-
i.trim() &&
|
|
82164
|
-
`)), u ||
|
|
82163
|
+
i.trim() && h.enqueue(o.encode(i + `
|
|
82164
|
+
`)), u || h.enqueue(o.encode(`data: [DONE]
|
|
82165
82165
|
|
|
82166
82166
|
`));
|
|
82167
82167
|
} catch (b) {
|
|
82168
|
-
console.error("Stream error:", b),
|
|
82168
|
+
console.error("Stream error:", b), h.error(b);
|
|
82169
82169
|
} finally {
|
|
82170
82170
|
try {
|
|
82171
|
-
|
|
82171
|
+
f.releaseLock();
|
|
82172
82172
|
} catch (b) {
|
|
82173
82173
|
console.error("Error releasing reader lock:", b);
|
|
82174
82174
|
}
|
|
82175
|
-
|
|
82175
|
+
h.close();
|
|
82176
82176
|
}
|
|
82177
82177
|
} });
|
|
82178
|
-
return new Response(
|
|
82178
|
+
return new Response(d, { status: e.status, statusText: e.statusText, headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive", "Access-Control-Allow-Origin": "*" } });
|
|
82179
82179
|
}
|
|
82180
82180
|
return e;
|
|
82181
82181
|
}
|
|
@@ -82190,24 +82190,24 @@ var aa = class {
|
|
|
82190
82190
|
return null;
|
|
82191
82191
|
}
|
|
82192
82192
|
convertResponseToChat(e) {
|
|
82193
|
-
let t = e.output?.find((
|
|
82194
|
-
t?.content?.length && t?.content[0].annotations && (o = t.content[0].annotations.map((
|
|
82193
|
+
let t = e.output?.find((h) => h.type === "message"), n = e.output?.find((h) => h.type === "function_call"), o;
|
|
82194
|
+
t?.content?.length && t?.content[0].annotations && (o = t.content[0].annotations.map((h) => ({ type: "url_citation", url_citation: { url: h.url || "", title: h.title || "", content: "", start_index: h.start_index || 0, end_index: h.end_index || 0 } }))), this.logger.debug({ data: o, type: "url_citation" });
|
|
82195
82195
|
let i = null, u = null, l = null;
|
|
82196
82196
|
if (t && t.reasoning && (l = { content: t.reasoning }), t && t.content) {
|
|
82197
|
-
let
|
|
82197
|
+
let h = [], f = [];
|
|
82198
82198
|
if (t.content.forEach((g) => {
|
|
82199
|
-
if (g.type === "output_text")
|
|
82199
|
+
if (g.type === "output_text") h.push(g.text || "");
|
|
82200
82200
|
else if (g.type === "output_image") {
|
|
82201
82201
|
let A = this.buildImageContent({ url: g.image_url, mime_type: g.mime_type });
|
|
82202
|
-
A &&
|
|
82202
|
+
A && f.push(A);
|
|
82203
82203
|
} else if (g.type === "output_image_base64") {
|
|
82204
82204
|
let A = this.buildImageContent({ b64_json: g.image_base64, mime_type: g.mime_type });
|
|
82205
|
-
A &&
|
|
82205
|
+
A && f.push(A);
|
|
82206
82206
|
}
|
|
82207
|
-
}),
|
|
82207
|
+
}), f.length > 0) {
|
|
82208
82208
|
let g = [];
|
|
82209
|
-
|
|
82210
|
-
} else i =
|
|
82209
|
+
h.length > 0 && g.push({ type: "text", text: h.join("") }), g.push(...f), i = g;
|
|
82210
|
+
} else i = h.join("");
|
|
82211
82211
|
}
|
|
82212
82212
|
return n && (u = [{ id: n.call_id || n.id, function: { name: n.name, arguments: n.arguments }, type: "function" }]), { id: e.id || "chatcmpl-" + Date.now(), object: "chat.completion", created: e.created_at, model: e.model, choices: [{ index: 0, message: { role: "assistant", content: i || null, tool_calls: u, thinking: l, annotations: o }, logprobs: null, finish_reason: u ? "tool_calls" : "stop" }], usage: e.usage ? { prompt_tokens: e.usage.input_tokens || 0, completion_tokens: e.usage.output_tokens || 0, total_tokens: e.usage.total_tokens || 0 } : null };
|
|
82213
82213
|
}
|
|
@@ -82244,17 +82244,17 @@ var ua = class {
|
|
|
82244
82244
|
} else if (e.headers.get("Content-Type")?.includes("stream")) {
|
|
82245
82245
|
if (!e.body) return e;
|
|
82246
82246
|
let o = new TextDecoder(), i = new TextEncoder(), u = new ReadableStream({ async start(l) {
|
|
82247
|
-
let
|
|
82248
|
-
if (typeof
|
|
82247
|
+
let d = e.body.getReader(), h = "", f = "SEARCHING", g = "", A = "", P = (b, E) => {
|
|
82248
|
+
if (typeof E != "string") {
|
|
82249
82249
|
b.choices?.[0]?.delta && Object.keys(b.choices[0].delta).length > 0 && !b.choices[0].delta.content && l.enqueue(i.encode(`data: ${JSON.stringify(b)}
|
|
82250
82250
|
|
|
82251
82251
|
`));
|
|
82252
82252
|
return;
|
|
82253
82253
|
}
|
|
82254
|
-
let p = g +
|
|
82255
|
-
for (g = ""; p.length > 0; ) if (
|
|
82254
|
+
let p = g + E;
|
|
82255
|
+
for (g = ""; p.length > 0; ) if (f === "SEARCHING") {
|
|
82256
82256
|
let y = p.indexOf(t);
|
|
82257
|
-
if (y !== -1) p = p.substring(y + t.length),
|
|
82257
|
+
if (y !== -1) p = p.substring(y + t.length), f = "REASONING";
|
|
82258
82258
|
else {
|
|
82259
82259
|
for (let T = t.length - 1; T > 0; T--) if (p.endsWith(t.substring(0, T))) {
|
|
82260
82260
|
g = p.substring(p.length - T);
|
|
@@ -82262,7 +82262,7 @@ var ua = class {
|
|
|
82262
82262
|
}
|
|
82263
82263
|
p = "";
|
|
82264
82264
|
}
|
|
82265
|
-
} else if (
|
|
82265
|
+
} else if (f === "REASONING") {
|
|
82266
82266
|
let y = p.indexOf(n);
|
|
82267
82267
|
if (y !== -1) {
|
|
82268
82268
|
let T = p.substring(0, y);
|
|
@@ -82274,34 +82274,34 @@ var ua = class {
|
|
|
82274
82274
|
|
|
82275
82275
|
`));
|
|
82276
82276
|
}
|
|
82277
|
-
let
|
|
82278
|
-
delete
|
|
82279
|
-
let S = { ...b, choices: [{ ...b.choices[0], delta:
|
|
82277
|
+
let w = { ...b.choices[0].delta, thinking: { signature: (/* @__PURE__ */ new Date()).getTime().toString() } };
|
|
82278
|
+
delete w.content;
|
|
82279
|
+
let S = { ...b, choices: [{ ...b.choices[0], delta: w }] };
|
|
82280
82280
|
l.enqueue(i.encode(`data: ${JSON.stringify(S)}
|
|
82281
82281
|
|
|
82282
|
-
`)), p = p.substring(y + n.length),
|
|
82282
|
+
`)), p = p.substring(y + n.length), f = "FINAL";
|
|
82283
82283
|
} else {
|
|
82284
82284
|
let T = p;
|
|
82285
|
-
for (let
|
|
82286
|
-
g = p.substring(p.length -
|
|
82285
|
+
for (let w = n.length - 1; w > 0; w--) if (p.endsWith(n.substring(0, w))) {
|
|
82286
|
+
g = p.substring(p.length - w), T = p.substring(0, p.length - w);
|
|
82287
82287
|
break;
|
|
82288
82288
|
}
|
|
82289
82289
|
if (T.length > 0) {
|
|
82290
|
-
let
|
|
82291
|
-
delete
|
|
82292
|
-
let S = { ...b, choices: [{ ...b.choices[0], delta:
|
|
82290
|
+
let w = { ...b.choices[0].delta, thinking: { content: T } };
|
|
82291
|
+
delete w.content;
|
|
82292
|
+
let S = { ...b, choices: [{ ...b.choices[0], delta: w }] };
|
|
82293
82293
|
l.enqueue(i.encode(`data: ${JSON.stringify(S)}
|
|
82294
82294
|
|
|
82295
82295
|
`));
|
|
82296
82296
|
}
|
|
82297
82297
|
p = "";
|
|
82298
82298
|
}
|
|
82299
|
-
} else if (
|
|
82299
|
+
} else if (f === "FINAL") {
|
|
82300
82300
|
if (p.length > 0) if (/^\s*$/.test(p)) A += p;
|
|
82301
82301
|
else {
|
|
82302
|
-
let T = A + p,
|
|
82303
|
-
|
|
82304
|
-
let S = { ...b, choices: [{ ...b.choices[0], delta:
|
|
82302
|
+
let T = A + p, w = { ...b.choices[0].delta, content: T };
|
|
82303
|
+
w.thinking && delete w.thinking;
|
|
82304
|
+
let S = { ...b, choices: [{ ...b.choices[0], delta: w }] };
|
|
82305
82305
|
l.enqueue(i.encode(`data: ${JSON.stringify(S)}
|
|
82306
82306
|
|
|
82307
82307
|
`)), A = "";
|
|
@@ -82311,13 +82311,13 @@ var ua = class {
|
|
|
82311
82311
|
};
|
|
82312
82312
|
try {
|
|
82313
82313
|
for (; ; ) {
|
|
82314
|
-
let { done: b, value:
|
|
82314
|
+
let { done: b, value: E } = await d.read();
|
|
82315
82315
|
if (b) break;
|
|
82316
|
-
let p = o.decode(
|
|
82317
|
-
|
|
82318
|
-
let y =
|
|
82316
|
+
let p = o.decode(E, { stream: true });
|
|
82317
|
+
h += p;
|
|
82318
|
+
let y = h.split(`
|
|
82319
82319
|
`);
|
|
82320
|
-
|
|
82320
|
+
h = y.pop() || "";
|
|
82321
82321
|
for (let T of y) if (T.trim()) {
|
|
82322
82322
|
if (T.trim() === "data: [DONE]") {
|
|
82323
82323
|
l.enqueue(i.encode(T + `
|
|
@@ -82326,8 +82326,8 @@ var ua = class {
|
|
|
82326
82326
|
break;
|
|
82327
82327
|
}
|
|
82328
82328
|
if (T.startsWith("data:")) try {
|
|
82329
|
-
let
|
|
82330
|
-
P(
|
|
82329
|
+
let w = JSON.parse(T.slice(5));
|
|
82330
|
+
P(w, w.choices?.[0]?.delta?.content);
|
|
82331
82331
|
} catch {
|
|
82332
82332
|
l.enqueue(i.encode(T + `
|
|
82333
82333
|
`));
|
|
@@ -82340,10 +82340,16 @@ var ua = class {
|
|
|
82340
82340
|
console.error("Stream error:", b), l.error(b);
|
|
82341
82341
|
} finally {
|
|
82342
82342
|
try {
|
|
82343
|
-
|
|
82343
|
+
d.releaseLock();
|
|
82344
82344
|
} catch (b) {
|
|
82345
82345
|
console.error("Error releasing reader lock:", b);
|
|
82346
82346
|
}
|
|
82347
|
+
if (f === "REASONING") {
|
|
82348
|
+
let E = { choices: [{ delta: { thinking: { signature: (/* @__PURE__ */ new Date()).getTime().toString() } } }] };
|
|
82349
|
+
l.enqueue(i.encode(`data: ${JSON.stringify(E)}
|
|
82350
|
+
|
|
82351
|
+
`));
|
|
82352
|
+
}
|
|
82347
82353
|
l.close();
|
|
82348
82354
|
}
|
|
82349
82355
|
} });
|