6838 lines
215 KiB
JavaScript
6838 lines
215 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: 5090ef85429ba5da.685e3e4591.js
|
|
* Module id: 87030
|
|
* For reading/searching only; this factory depends on the original Turbopack runtime.
|
|
*/
|
|
|
|
const moduleFactory = (e) => {
|
|
"use strict";
|
|
var t,
|
|
n,
|
|
r,
|
|
s,
|
|
i,
|
|
a,
|
|
o,
|
|
l = e.i(23741),
|
|
u = e.i(197895),
|
|
d = e.i(361769),
|
|
c =
|
|
((t = function (e, n) {
|
|
return (t =
|
|
Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array &&
|
|
function (e, t) {
|
|
e.__proto__ = t;
|
|
}) ||
|
|
function (e, t) {
|
|
for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
|
|
})(e, n);
|
|
}),
|
|
function (e, n) {
|
|
function r() {
|
|
this.constructor = e;
|
|
}
|
|
t(e, n),
|
|
(e.prototype =
|
|
null === n
|
|
? Object.create(n)
|
|
: ((r.prototype = n.prototype), new r()));
|
|
}),
|
|
p = Object.prototype.hasOwnProperty;
|
|
function h(e, t) {
|
|
return p.call(e, t);
|
|
}
|
|
function f(e) {
|
|
if (Array.isArray(e)) {
|
|
for (var t = Array(e.length), n = 0; n < t.length; n++) t[n] = "" + n;
|
|
return t;
|
|
}
|
|
if (Object.keys) return Object.keys(e);
|
|
var r = [];
|
|
for (var s in e) h(e, s) && r.push(s);
|
|
return r;
|
|
}
|
|
function g(e) {
|
|
switch (typeof e) {
|
|
case "object":
|
|
return JSON.parse(JSON.stringify(e));
|
|
case "undefined":
|
|
return null;
|
|
default:
|
|
return e;
|
|
}
|
|
}
|
|
function m(e) {
|
|
for (var t, n = 0, r = e.length; n < r; ) {
|
|
if ((t = e.charCodeAt(n)) >= 48 && t <= 57) {
|
|
n++;
|
|
continue;
|
|
}
|
|
return !1;
|
|
}
|
|
return !0;
|
|
}
|
|
function v(e) {
|
|
return -1 === e.indexOf("/") && -1 === e.indexOf("~")
|
|
? e
|
|
: e.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
}
|
|
function y(e) {
|
|
return e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
}
|
|
function _(e, t) {
|
|
var n = [e];
|
|
for (var r in t) {
|
|
var s = "object" == typeof t[r] ? JSON.stringify(t[r], null, 2) : t[r];
|
|
void 0 !== s && n.push(r + ": " + s);
|
|
}
|
|
return n.join("\n");
|
|
}
|
|
var E = (function (e) {
|
|
function t(t, n, r, s, i) {
|
|
var a = this.constructor,
|
|
o =
|
|
e.call(
|
|
this,
|
|
_(t, { name: n, index: r, operation: s, tree: i }),
|
|
) || this;
|
|
return (
|
|
(o.name = n),
|
|
(o.index = r),
|
|
(o.operation = s),
|
|
(o.tree = i),
|
|
Object.setPrototypeOf(o, a.prototype),
|
|
(o.message = _(t, { name: n, index: r, operation: s, tree: i })),
|
|
o
|
|
);
|
|
}
|
|
return c(t, e), t;
|
|
})(Error),
|
|
b = {
|
|
add: function (e, t, n) {
|
|
return (e[t] = this.value), { newDocument: n };
|
|
},
|
|
remove: function (e, t, n) {
|
|
var r = e[t];
|
|
return delete e[t], { newDocument: n, removed: r };
|
|
},
|
|
replace: function (e, t, n) {
|
|
var r = e[t];
|
|
return (e[t] = this.value), { newDocument: n, removed: r };
|
|
},
|
|
move: function (e, t, n) {
|
|
var r = S(n, this.path);
|
|
r && (r = g(r));
|
|
var s = A(n, { op: "remove", path: this.from }).removed;
|
|
return (
|
|
A(n, { op: "add", path: this.path, value: s }),
|
|
{ newDocument: n, removed: r }
|
|
);
|
|
},
|
|
copy: function (e, t, n) {
|
|
var r = S(n, this.from);
|
|
return (
|
|
A(n, { op: "add", path: this.path, value: g(r) }),
|
|
{ newDocument: n }
|
|
);
|
|
},
|
|
test: function (e, t, n) {
|
|
return { newDocument: n, test: C(e[t], this.value) };
|
|
},
|
|
_get: function (e, t, n) {
|
|
return (this.value = e[t]), { newDocument: n };
|
|
},
|
|
},
|
|
T = {
|
|
add: function (e, t, n) {
|
|
return (
|
|
m(t) ? e.splice(t, 0, this.value) : (e[t] = this.value),
|
|
{ newDocument: n, index: t }
|
|
);
|
|
},
|
|
remove: function (e, t, n) {
|
|
return { newDocument: n, removed: e.splice(t, 1)[0] };
|
|
},
|
|
replace: function (e, t, n) {
|
|
var r = e[t];
|
|
return (e[t] = this.value), { newDocument: n, removed: r };
|
|
},
|
|
move: b.move,
|
|
copy: b.copy,
|
|
test: b.test,
|
|
_get: b._get,
|
|
};
|
|
function S(e, t) {
|
|
if ("" == t) return e;
|
|
var n = { op: "_get", path: t };
|
|
return A(e, n), n.value;
|
|
}
|
|
function A(e, t, n, r, s, i) {
|
|
if (
|
|
(void 0 === n && (n = !1),
|
|
void 0 === r && (r = !0),
|
|
void 0 === s && (s = !0),
|
|
void 0 === i && (i = 0),
|
|
n && ("function" == typeof n ? n(t, 0, e, t.path) : w(t, 0)),
|
|
"" === t.path)
|
|
) {
|
|
var a = { newDocument: e };
|
|
if ("add" === t.op) return (a.newDocument = t.value), a;
|
|
if ("replace" === t.op)
|
|
return (a.newDocument = t.value), (a.removed = e), a;
|
|
if ("move" === t.op || "copy" === t.op)
|
|
return (
|
|
(a.newDocument = S(e, t.from)),
|
|
"move" === t.op && (a.removed = e),
|
|
a
|
|
);
|
|
else if ("test" === t.op) {
|
|
if (((a.test = C(e, t.value)), !1 === a.test))
|
|
throw new E(
|
|
"Test operation failed",
|
|
"TEST_OPERATION_FAILED",
|
|
i,
|
|
t,
|
|
e,
|
|
);
|
|
return (a.newDocument = e), a;
|
|
} else if ("remove" === t.op)
|
|
return (a.removed = e), (a.newDocument = null), a;
|
|
else if ("_get" === t.op) return (t.value = e), a;
|
|
else if (!n) return a;
|
|
else
|
|
throw new E(
|
|
"Operation `op` property is not one of operations defined in RFC-6902",
|
|
"OPERATION_OP_INVALID",
|
|
i,
|
|
t,
|
|
e,
|
|
);
|
|
}
|
|
r || (e = g(e));
|
|
var o = (t.path || "").split("/"),
|
|
l = e,
|
|
u = 1,
|
|
d = o.length,
|
|
c = void 0,
|
|
p = void 0,
|
|
h = void 0;
|
|
for (h = "function" == typeof n ? n : w; ; ) {
|
|
if (
|
|
((p = o[u]) && -1 != p.indexOf("~") && (p = y(p)),
|
|
s &&
|
|
("__proto__" == p ||
|
|
("prototype" == p && u > 0 && "constructor" == o[u - 1])))
|
|
)
|
|
throw TypeError(
|
|
"JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README",
|
|
);
|
|
if (
|
|
(n &&
|
|
void 0 === c &&
|
|
(void 0 === l[p]
|
|
? (c = o.slice(0, u).join("/"))
|
|
: u == d - 1 && (c = t.path),
|
|
void 0 !== c && h(t, 0, e, c)),
|
|
u++,
|
|
Array.isArray(l))
|
|
) {
|
|
if ("-" === p) p = l.length;
|
|
else if (n && !m(p))
|
|
throw new E(
|
|
"Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index",
|
|
"OPERATION_PATH_ILLEGAL_ARRAY_INDEX",
|
|
i,
|
|
t,
|
|
e,
|
|
);
|
|
else m(p) && (p = ~~p);
|
|
if (u >= d) {
|
|
if (n && "add" === t.op && p > l.length)
|
|
throw new E(
|
|
"The specified index MUST NOT be greater than the number of elements in the array",
|
|
"OPERATION_VALUE_OUT_OF_BOUNDS",
|
|
i,
|
|
t,
|
|
e,
|
|
);
|
|
var a = T[t.op].call(t, l, p, e);
|
|
if (!1 === a.test)
|
|
throw new E(
|
|
"Test operation failed",
|
|
"TEST_OPERATION_FAILED",
|
|
i,
|
|
t,
|
|
e,
|
|
);
|
|
return a;
|
|
}
|
|
} else if (u >= d) {
|
|
var a = b[t.op].call(t, l, p, e);
|
|
if (!1 === a.test)
|
|
throw new E(
|
|
"Test operation failed",
|
|
"TEST_OPERATION_FAILED",
|
|
i,
|
|
t,
|
|
e,
|
|
);
|
|
return a;
|
|
}
|
|
if (((l = l[p]), n && u < d && (!l || "object" != typeof l)))
|
|
throw new E(
|
|
"Cannot perform operation at the desired path",
|
|
"OPERATION_PATH_UNRESOLVABLE",
|
|
i,
|
|
t,
|
|
e,
|
|
);
|
|
}
|
|
}
|
|
function N(e, t, n, r, s) {
|
|
if (
|
|
(void 0 === r && (r = !0),
|
|
void 0 === s && (s = !0),
|
|
n && !Array.isArray(t))
|
|
)
|
|
throw new E("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
r || (e = g(e));
|
|
for (var i = Array(t.length), a = 0, o = t.length; a < o; a++)
|
|
(i[a] = A(e, t[a], n, !0, s, a)), (e = i[a].newDocument);
|
|
return (i.newDocument = e), i;
|
|
}
|
|
function I(e, t, n) {
|
|
var r = A(e, t);
|
|
if (!1 === r.test)
|
|
throw new E("Test operation failed", "TEST_OPERATION_FAILED", n, t, e);
|
|
return r.newDocument;
|
|
}
|
|
function w(e, t, n, r) {
|
|
if ("object" != typeof e || null === e || Array.isArray(e))
|
|
throw new E(
|
|
"Operation is not an object",
|
|
"OPERATION_NOT_AN_OBJECT",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
if (b[e.op]) {
|
|
if ("string" != typeof e.path)
|
|
throw new E(
|
|
"Operation `path` property is not a string",
|
|
"OPERATION_PATH_INVALID",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
else if (0 !== e.path.indexOf("/") && e.path.length > 0)
|
|
throw new E(
|
|
'Operation `path` property must start with "/"',
|
|
"OPERATION_PATH_INVALID",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
else if (
|
|
("move" === e.op || "copy" === e.op) &&
|
|
"string" != typeof e.from
|
|
)
|
|
throw new E(
|
|
"Operation `from` property is not present (applicable in `move` and `copy` operations)",
|
|
"OPERATION_FROM_REQUIRED",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
else if (
|
|
("add" === e.op || "replace" === e.op || "test" === e.op) &&
|
|
void 0 === e.value
|
|
)
|
|
throw new E(
|
|
"Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",
|
|
"OPERATION_VALUE_REQUIRED",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
else if (
|
|
("add" === e.op || "replace" === e.op || "test" === e.op) &&
|
|
(function e(t) {
|
|
if (void 0 === t) return !0;
|
|
if (t) {
|
|
if (Array.isArray(t)) {
|
|
for (var n = 0, r = t.length; n < r; n++)
|
|
if (e(t[n])) return !0;
|
|
} else if ("object" == typeof t) {
|
|
for (var s = f(t), i = s.length, a = 0; a < i; a++)
|
|
if (e(t[s[a]])) return !0;
|
|
}
|
|
}
|
|
return !1;
|
|
})(e.value)
|
|
)
|
|
throw new E(
|
|
"Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",
|
|
"OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
else if (n) {
|
|
if ("add" == e.op) {
|
|
var s = e.path.split("/").length,
|
|
i = r.split("/").length;
|
|
if (s !== i + 1 && s !== i)
|
|
throw new E(
|
|
"Cannot perform an `add` operation at the desired path",
|
|
"OPERATION_PATH_CANNOT_ADD",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
} else if (
|
|
"replace" === e.op ||
|
|
"remove" === e.op ||
|
|
"_get" === e.op
|
|
) {
|
|
if (e.path !== r)
|
|
throw new E(
|
|
"Cannot perform the operation at a path that does not exist",
|
|
"OPERATION_PATH_UNRESOLVABLE",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
} else if ("move" === e.op || "copy" === e.op) {
|
|
var a = O([{ op: "_get", path: e.from, value: void 0 }], n);
|
|
if (a && "OPERATION_PATH_UNRESOLVABLE" === a.name)
|
|
throw new E(
|
|
"Cannot perform the operation from a path that does not exist",
|
|
"OPERATION_FROM_UNRESOLVABLE",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
}
|
|
}
|
|
} else
|
|
throw new E(
|
|
"Operation `op` property is not one of operations defined in RFC-6902",
|
|
"OPERATION_OP_INVALID",
|
|
t,
|
|
e,
|
|
n,
|
|
);
|
|
}
|
|
function O(e, t, n) {
|
|
try {
|
|
if (!Array.isArray(e))
|
|
throw new E(
|
|
"Patch sequence must be an array",
|
|
"SEQUENCE_NOT_AN_ARRAY",
|
|
);
|
|
if (t) N(g(t), g(e), n || !0);
|
|
else {
|
|
n = n || w;
|
|
for (var r = 0; r < e.length; r++) n(e[r], r, t, void 0);
|
|
}
|
|
} catch (e) {
|
|
if (e instanceof E) return e;
|
|
throw e;
|
|
}
|
|
}
|
|
function C(e, t) {
|
|
if (e === t) return !0;
|
|
if (e && t && "object" == typeof e && "object" == typeof t) {
|
|
var n,
|
|
r,
|
|
s,
|
|
i = Array.isArray(e),
|
|
a = Array.isArray(t);
|
|
if (i && a) {
|
|
if ((r = e.length) != t.length) return !1;
|
|
for (n = r; 0 != n--; ) if (!C(e[n], t[n])) return !1;
|
|
return !0;
|
|
}
|
|
if (i != a) return !1;
|
|
var o = Object.keys(e);
|
|
if ((r = o.length) !== Object.keys(t).length) return !1;
|
|
for (n = r; 0 != n--; ) if (!t.hasOwnProperty(o[n])) return !1;
|
|
for (n = r; 0 != n--; ) if (!C(e[(s = o[n])], t[s])) return !1;
|
|
return !0;
|
|
}
|
|
return e != e && t != t;
|
|
}
|
|
e.s(
|
|
[
|
|
"JsonPatchError",
|
|
() => E,
|
|
"_areEquals",
|
|
() => C,
|
|
"applyOperation",
|
|
() => A,
|
|
"applyPatch",
|
|
() => N,
|
|
"applyReducer",
|
|
() => I,
|
|
"deepClone",
|
|
() => g,
|
|
"getValueByPointer",
|
|
() => S,
|
|
"validate",
|
|
() => O,
|
|
"validator",
|
|
() => w,
|
|
],
|
|
88848,
|
|
);
|
|
var R = new WeakMap(),
|
|
k = function (e) {
|
|
(this.observers = new Map()), (this.obj = e);
|
|
},
|
|
x = function (e, t) {
|
|
(this.callback = e), (this.observer = t);
|
|
};
|
|
function P(e, t) {
|
|
t.unobserve();
|
|
}
|
|
function M(e, t) {
|
|
var n = R.get(e);
|
|
if (n) {
|
|
var r,
|
|
s = n.observers.get(t);
|
|
r = s && s.observer;
|
|
} else (n = new k(e)), R.set(e, n);
|
|
if (r) return r;
|
|
if (((r = {}), (n.value = g(e)), t)) {
|
|
(r.callback = t), (r.next = null);
|
|
var i = function () {
|
|
L(r);
|
|
},
|
|
a = function () {
|
|
clearTimeout(r.next), (r.next = setTimeout(i));
|
|
};
|
|
"u" > typeof window &&
|
|
(window.addEventListener("mouseup", a),
|
|
window.addEventListener("keyup", a),
|
|
window.addEventListener("mousedown", a),
|
|
window.addEventListener("keydown", a),
|
|
window.addEventListener("change", a));
|
|
}
|
|
return (
|
|
(r.patches = []),
|
|
(r.object = e),
|
|
(r.unobserve = function () {
|
|
var e, t;
|
|
L(r),
|
|
clearTimeout(r.next),
|
|
(e = n),
|
|
(t = r),
|
|
e.observers.delete(t.callback),
|
|
"u" > typeof window &&
|
|
(window.removeEventListener("mouseup", a),
|
|
window.removeEventListener("keyup", a),
|
|
window.removeEventListener("mousedown", a),
|
|
window.removeEventListener("keydown", a),
|
|
window.removeEventListener("change", a));
|
|
}),
|
|
n.observers.set(t, new x(t, r)),
|
|
r
|
|
);
|
|
}
|
|
function L(e, t) {
|
|
void 0 === t && (t = !1);
|
|
var n = R.get(e.object);
|
|
D(n.value, e.object, e.patches, "", t),
|
|
e.patches.length && N(n.value, e.patches);
|
|
var r = e.patches;
|
|
return r.length > 0 && ((e.patches = []), e.callback && e.callback(r)), r;
|
|
}
|
|
function D(e, t, n, r, s) {
|
|
if (t !== e) {
|
|
"function" == typeof t.toJSON && (t = t.toJSON());
|
|
for (var i = f(t), a = f(e), o = !1, l = a.length - 1; l >= 0; l--) {
|
|
var u = a[l],
|
|
d = e[u];
|
|
if (
|
|
h(t, u) &&
|
|
(void 0 !== t[u] || void 0 === d || !1 !== Array.isArray(t))
|
|
) {
|
|
var c = t[u];
|
|
"object" == typeof d &&
|
|
null != d &&
|
|
"object" == typeof c &&
|
|
null != c &&
|
|
Array.isArray(d) === Array.isArray(c)
|
|
? D(d, c, n, r + "/" + v(u), s)
|
|
: d !== c &&
|
|
(s && n.push({ op: "test", path: r + "/" + v(u), value: g(d) }),
|
|
n.push({ op: "replace", path: r + "/" + v(u), value: g(c) }));
|
|
} else
|
|
Array.isArray(e) === Array.isArray(t)
|
|
? (s && n.push({ op: "test", path: r + "/" + v(u), value: g(d) }),
|
|
n.push({ op: "remove", path: r + "/" + v(u) }),
|
|
(o = !0))
|
|
: (s && n.push({ op: "test", path: r, value: e }),
|
|
n.push({ op: "replace", path: r, value: t }));
|
|
}
|
|
if (o || i.length != a.length)
|
|
for (var l = 0; l < i.length; l++) {
|
|
var u = i[l];
|
|
h(e, u) ||
|
|
void 0 === t[u] ||
|
|
n.push({ op: "add", path: r + "/" + v(u), value: g(t[u]) });
|
|
}
|
|
}
|
|
}
|
|
function j(e, t, n) {
|
|
void 0 === n && (n = !1);
|
|
var r = [];
|
|
return D(e, t, r, "", n), r;
|
|
}
|
|
e.s(
|
|
[
|
|
"compare",
|
|
() => j,
|
|
"generate",
|
|
() => L,
|
|
"observe",
|
|
() => M,
|
|
"unobserve",
|
|
() => P,
|
|
],
|
|
328065,
|
|
),
|
|
Object.assign({}, e.i(88848), e.i(328065), {
|
|
JsonPatchError: E,
|
|
deepClone: g,
|
|
escapePathComponent: v,
|
|
unescapePathComponent: y,
|
|
});
|
|
var Z = e.i(824627);
|
|
function U(e) {
|
|
return "function" == typeof e;
|
|
}
|
|
function G(e) {
|
|
var t = e(function (e) {
|
|
Error.call(e), (e.stack = Error().stack);
|
|
});
|
|
return (
|
|
(t.prototype = Object.create(Error.prototype)),
|
|
(t.prototype.constructor = t),
|
|
t
|
|
);
|
|
}
|
|
var F = G(function (e) {
|
|
return function (t) {
|
|
e(this),
|
|
(this.message = t
|
|
? t.length +
|
|
" errors occurred during unsubscription:\n" +
|
|
t
|
|
.map(function (e, t) {
|
|
return t + 1 + ") " + e.toString();
|
|
})
|
|
.join("\n ")
|
|
: ""),
|
|
(this.name = "UnsubscriptionError"),
|
|
(this.errors = t);
|
|
};
|
|
});
|
|
function $(e, t) {
|
|
if (e) {
|
|
var n = e.indexOf(t);
|
|
0 <= n && e.splice(n, 1);
|
|
}
|
|
}
|
|
var V = (function () {
|
|
var e;
|
|
function t(e) {
|
|
(this.initialTeardown = e),
|
|
(this.closed = !1),
|
|
(this._parentage = null),
|
|
(this._finalizers = null);
|
|
}
|
|
return (
|
|
(t.prototype.unsubscribe = function () {
|
|
if (!this.closed) {
|
|
this.closed = !0;
|
|
var e,
|
|
t,
|
|
n,
|
|
r,
|
|
s,
|
|
i = this._parentage;
|
|
if (i)
|
|
if (((this._parentage = null), Array.isArray(i)))
|
|
try {
|
|
for (
|
|
var a = (0, Z.__values)(i), o = a.next();
|
|
!o.done;
|
|
o = a.next()
|
|
)
|
|
o.value.remove(this);
|
|
} catch (t) {
|
|
e = { error: t };
|
|
} finally {
|
|
try {
|
|
o && !o.done && (t = a.return) && t.call(a);
|
|
} finally {
|
|
if (e) throw e.error;
|
|
}
|
|
}
|
|
else i.remove(this);
|
|
var l = this.initialTeardown;
|
|
if (U(l))
|
|
try {
|
|
l();
|
|
} catch (e) {
|
|
s = e instanceof F ? e.errors : [e];
|
|
}
|
|
var u = this._finalizers;
|
|
if (u) {
|
|
this._finalizers = null;
|
|
try {
|
|
for (
|
|
var d = (0, Z.__values)(u), c = d.next();
|
|
!c.done;
|
|
c = d.next()
|
|
) {
|
|
var p = c.value;
|
|
try {
|
|
K(p);
|
|
} catch (e) {
|
|
(s = null != s ? s : []),
|
|
e instanceof F
|
|
? (s = (0, Z.__spreadArray)(
|
|
(0, Z.__spreadArray)([], (0, Z.__read)(s)),
|
|
(0, Z.__read)(e.errors),
|
|
))
|
|
: s.push(e);
|
|
}
|
|
}
|
|
} catch (e) {
|
|
n = { error: e };
|
|
} finally {
|
|
try {
|
|
c && !c.done && (r = d.return) && r.call(d);
|
|
} finally {
|
|
if (n) throw n.error;
|
|
}
|
|
}
|
|
}
|
|
if (s) throw new F(s);
|
|
}
|
|
}),
|
|
(t.prototype.add = function (e) {
|
|
var n;
|
|
if (e && e !== this)
|
|
if (this.closed) K(e);
|
|
else {
|
|
if (e instanceof t) {
|
|
if (e.closed || e._hasParent(this)) return;
|
|
e._addParent(this);
|
|
}
|
|
(this._finalizers =
|
|
null != (n = this._finalizers) ? n : []).push(e);
|
|
}
|
|
}),
|
|
(t.prototype._hasParent = function (e) {
|
|
var t = this._parentage;
|
|
return t === e || (Array.isArray(t) && t.includes(e));
|
|
}),
|
|
(t.prototype._addParent = function (e) {
|
|
var t = this._parentage;
|
|
this._parentage = Array.isArray(t)
|
|
? (t.push(e), t)
|
|
: t
|
|
? [t, e]
|
|
: e;
|
|
}),
|
|
(t.prototype._removeParent = function (e) {
|
|
var t = this._parentage;
|
|
t === e ? (this._parentage = null) : Array.isArray(t) && $(t, e);
|
|
}),
|
|
(t.prototype.remove = function (e) {
|
|
var n = this._finalizers;
|
|
n && $(n, e), e instanceof t && e._removeParent(this);
|
|
}),
|
|
((e = new t()).closed = !0),
|
|
(t.EMPTY = e),
|
|
t
|
|
);
|
|
})(),
|
|
z = V.EMPTY;
|
|
function H(e) {
|
|
return (
|
|
e instanceof V ||
|
|
(e && "closed" in e && U(e.remove) && U(e.add) && U(e.unsubscribe))
|
|
);
|
|
}
|
|
function K(e) {
|
|
U(e) ? e() : e.unsubscribe();
|
|
}
|
|
var B = void 0,
|
|
J = {
|
|
setTimeout: function (e, t) {
|
|
for (var n = [], r = 2; r < arguments.length; r++)
|
|
n[r - 2] = arguments[r];
|
|
var s = J.delegate;
|
|
return (null == s ? void 0 : s.setTimeout)
|
|
? s.setTimeout.apply(
|
|
s,
|
|
(0, Z.__spreadArray)([e, t], (0, Z.__read)(n)),
|
|
)
|
|
: setTimeout.apply(
|
|
void 0,
|
|
(0, Z.__spreadArray)([e, t], (0, Z.__read)(n)),
|
|
);
|
|
},
|
|
clearTimeout: function (e) {
|
|
var t = J.delegate;
|
|
return ((null == t ? void 0 : t.clearTimeout) || clearTimeout)(e);
|
|
},
|
|
delegate: void 0,
|
|
};
|
|
function X(e) {
|
|
J.setTimeout(function () {
|
|
!1;
|
|
throw e;
|
|
});
|
|
}
|
|
function W() {}
|
|
var Y = q("C", void 0, void 0);
|
|
function q(e, t, n) {
|
|
return { kind: e, value: t, error: n };
|
|
}
|
|
var Q = null;
|
|
function ee(e) {
|
|
var t, n, r, s;
|
|
1;
|
|
e();
|
|
}
|
|
var et = (function (e) {
|
|
function t(t) {
|
|
var n = e.call(this) || this;
|
|
return (
|
|
(n.isStopped = !1),
|
|
t ? ((n.destination = t), H(t) && t.add(n)) : (n.destination = el),
|
|
n
|
|
);
|
|
}
|
|
return (
|
|
(0, Z.__extends)(t, e),
|
|
(t.create = function (e, t, n) {
|
|
return new ei(e, t, n);
|
|
}),
|
|
(t.prototype.next = function (e) {
|
|
this.isStopped ? eo(q("N", e, void 0), this) : this._next(e);
|
|
}),
|
|
(t.prototype.error = function (e) {
|
|
this.isStopped
|
|
? eo(q("E", void 0, e), this)
|
|
: ((this.isStopped = !0), this._error(e));
|
|
}),
|
|
(t.prototype.complete = function () {
|
|
this.isStopped
|
|
? eo(Y, this)
|
|
: ((this.isStopped = !0), this._complete());
|
|
}),
|
|
(t.prototype.unsubscribe = function () {
|
|
this.closed ||
|
|
((this.isStopped = !0),
|
|
e.prototype.unsubscribe.call(this),
|
|
(this.destination = null));
|
|
}),
|
|
(t.prototype._next = function (e) {
|
|
this.destination.next(e);
|
|
}),
|
|
(t.prototype._error = function (e) {
|
|
try {
|
|
this.destination.error(e);
|
|
} finally {
|
|
this.unsubscribe();
|
|
}
|
|
}),
|
|
(t.prototype._complete = function () {
|
|
try {
|
|
this.destination.complete();
|
|
} finally {
|
|
this.unsubscribe();
|
|
}
|
|
}),
|
|
t
|
|
);
|
|
})(V),
|
|
en = Function.prototype.bind;
|
|
function er(e, t) {
|
|
return en.call(e, t);
|
|
}
|
|
var es = (function () {
|
|
function e(e) {
|
|
this.partialObserver = e;
|
|
}
|
|
return (
|
|
(e.prototype.next = function (e) {
|
|
var t = this.partialObserver;
|
|
if (t.next)
|
|
try {
|
|
t.next(e);
|
|
} catch (e) {
|
|
ea(e);
|
|
}
|
|
}),
|
|
(e.prototype.error = function (e) {
|
|
var t = this.partialObserver;
|
|
if (t.error)
|
|
try {
|
|
t.error(e);
|
|
} catch (e) {
|
|
ea(e);
|
|
}
|
|
else ea(e);
|
|
}),
|
|
(e.prototype.complete = function () {
|
|
var e = this.partialObserver;
|
|
if (e.complete)
|
|
try {
|
|
e.complete();
|
|
} catch (e) {
|
|
ea(e);
|
|
}
|
|
}),
|
|
e
|
|
);
|
|
})(),
|
|
ei = (function (e) {
|
|
function t(t, n, r) {
|
|
var s,
|
|
i,
|
|
a = e.call(this) || this;
|
|
return (
|
|
U(t) || !t
|
|
? (s = {
|
|
next: null != t ? t : void 0,
|
|
error: null != n ? n : void 0,
|
|
complete: null != r ? r : void 0,
|
|
})
|
|
: (s = t),
|
|
(a.destination = new es(s)),
|
|
a
|
|
);
|
|
}
|
|
return (0, Z.__extends)(t, e), t;
|
|
})(et);
|
|
function ea(e) {
|
|
1;
|
|
X(e);
|
|
}
|
|
function eo(e, t) {}
|
|
var el = {
|
|
closed: !0,
|
|
next: W,
|
|
error: function (e) {
|
|
throw e;
|
|
},
|
|
complete: W,
|
|
},
|
|
eu = ("function" == typeof Symbol && Symbol.observable) || "@@observable";
|
|
function ed(e) {
|
|
return e;
|
|
}
|
|
function ec() {
|
|
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
|
|
return ep(e);
|
|
}
|
|
function ep(e) {
|
|
return 0 === e.length
|
|
? ed
|
|
: 1 === e.length
|
|
? e[0]
|
|
: function (t) {
|
|
return e.reduce(function (e, t) {
|
|
return t(e);
|
|
}, t);
|
|
};
|
|
}
|
|
var eh = (function () {
|
|
function e(e) {
|
|
e && (this._subscribe = e);
|
|
}
|
|
return (
|
|
(e.prototype.lift = function (t) {
|
|
var n = new e();
|
|
return (n.source = this), (n.operator = t), n;
|
|
}),
|
|
(e.prototype.subscribe = function (e, t, n) {
|
|
var r = this,
|
|
s = !(function (e) {
|
|
return (
|
|
(e && e instanceof et) ||
|
|
(e && U(e.next) && U(e.error) && U(e.complete) && H(e))
|
|
);
|
|
})(e)
|
|
? new ei(e, t, n)
|
|
: e;
|
|
return (
|
|
ee(function () {
|
|
var e = r.operator,
|
|
t = r.source;
|
|
s.add(
|
|
e ? e.call(s, t) : t ? r._subscribe(s) : r._trySubscribe(s),
|
|
);
|
|
}),
|
|
s
|
|
);
|
|
}),
|
|
(e.prototype._trySubscribe = function (e) {
|
|
try {
|
|
return this._subscribe(e);
|
|
} catch (t) {
|
|
e.error(t);
|
|
}
|
|
}),
|
|
(e.prototype.forEach = function (e, t) {
|
|
var n = this;
|
|
return new (t = ef(t))(function (t, r) {
|
|
var s = new ei({
|
|
next: function (t) {
|
|
try {
|
|
e(t);
|
|
} catch (e) {
|
|
r(e), s.unsubscribe();
|
|
}
|
|
},
|
|
error: r,
|
|
complete: t,
|
|
});
|
|
n.subscribe(s);
|
|
});
|
|
}),
|
|
(e.prototype._subscribe = function (e) {
|
|
var t;
|
|
return null == (t = this.source) ? void 0 : t.subscribe(e);
|
|
}),
|
|
(e.prototype[eu] = function () {
|
|
return this;
|
|
}),
|
|
(e.prototype.pipe = function () {
|
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
e[t] = arguments[t];
|
|
return ep(e)(this);
|
|
}),
|
|
(e.prototype.toPromise = function (e) {
|
|
var t = this;
|
|
return new (e = ef(e))(function (e, n) {
|
|
var r;
|
|
t.subscribe(
|
|
function (e) {
|
|
return (r = e);
|
|
},
|
|
function (e) {
|
|
return n(e);
|
|
},
|
|
function () {
|
|
return e(r);
|
|
},
|
|
);
|
|
});
|
|
}),
|
|
(e.create = function (t) {
|
|
return new e(t);
|
|
}),
|
|
e
|
|
);
|
|
})();
|
|
function ef(e) {
|
|
var t;
|
|
return null != (t = null != e ? e : B) ? t : Promise;
|
|
}
|
|
e.s(["Observable", () => eh], 142164);
|
|
var eg = new eh(function (e) {
|
|
return e.complete();
|
|
});
|
|
e.s(["EMPTY", () => eg], 870010);
|
|
var em = G(function (e) {
|
|
return function () {
|
|
e(this),
|
|
(this.name = "ObjectUnsubscribedError"),
|
|
(this.message = "object unsubscribed");
|
|
};
|
|
}),
|
|
ev = (function (e) {
|
|
function t() {
|
|
var t = e.call(this) || this;
|
|
return (
|
|
(t.closed = !1),
|
|
(t.currentObservers = null),
|
|
(t.observers = []),
|
|
(t.isStopped = !1),
|
|
(t.hasError = !1),
|
|
(t.thrownError = null),
|
|
t
|
|
);
|
|
}
|
|
return (
|
|
(0, Z.__extends)(t, e),
|
|
(t.prototype.lift = function (e) {
|
|
var t = new ey(this, this);
|
|
return (t.operator = e), t;
|
|
}),
|
|
(t.prototype._throwIfClosed = function () {
|
|
if (this.closed) throw new em();
|
|
}),
|
|
(t.prototype.next = function (e) {
|
|
var t = this;
|
|
ee(function () {
|
|
var n, r;
|
|
if ((t._throwIfClosed(), !t.isStopped)) {
|
|
t.currentObservers ||
|
|
(t.currentObservers = Array.from(t.observers));
|
|
try {
|
|
for (
|
|
var s = (0, Z.__values)(t.currentObservers), i = s.next();
|
|
!i.done;
|
|
i = s.next()
|
|
)
|
|
i.value.next(e);
|
|
} catch (e) {
|
|
n = { error: e };
|
|
} finally {
|
|
try {
|
|
i && !i.done && (r = s.return) && r.call(s);
|
|
} finally {
|
|
if (n) throw n.error;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}),
|
|
(t.prototype.error = function (e) {
|
|
var t = this;
|
|
ee(function () {
|
|
if ((t._throwIfClosed(), !t.isStopped)) {
|
|
(t.hasError = t.isStopped = !0), (t.thrownError = e);
|
|
for (var n = t.observers; n.length; ) n.shift().error(e);
|
|
}
|
|
});
|
|
}),
|
|
(t.prototype.complete = function () {
|
|
var e = this;
|
|
ee(function () {
|
|
if ((e._throwIfClosed(), !e.isStopped)) {
|
|
e.isStopped = !0;
|
|
for (var t = e.observers; t.length; ) t.shift().complete();
|
|
}
|
|
});
|
|
}),
|
|
(t.prototype.unsubscribe = function () {
|
|
(this.isStopped = this.closed = !0),
|
|
(this.observers = this.currentObservers = null);
|
|
}),
|
|
Object.defineProperty(t.prototype, "observed", {
|
|
get: function () {
|
|
var e;
|
|
return (null == (e = this.observers) ? void 0 : e.length) > 0;
|
|
},
|
|
enumerable: !1,
|
|
configurable: !0,
|
|
}),
|
|
(t.prototype._trySubscribe = function (t) {
|
|
return (
|
|
this._throwIfClosed(), e.prototype._trySubscribe.call(this, t)
|
|
);
|
|
}),
|
|
(t.prototype._subscribe = function (e) {
|
|
return (
|
|
this._throwIfClosed(),
|
|
this._checkFinalizedStatuses(e),
|
|
this._innerSubscribe(e)
|
|
);
|
|
}),
|
|
(t.prototype._innerSubscribe = function (e) {
|
|
var t = this,
|
|
n = this.hasError,
|
|
r = this.isStopped,
|
|
s = this.observers;
|
|
return n || r
|
|
? z
|
|
: ((this.currentObservers = null),
|
|
s.push(e),
|
|
new V(function () {
|
|
(t.currentObservers = null), $(s, e);
|
|
}));
|
|
}),
|
|
(t.prototype._checkFinalizedStatuses = function (e) {
|
|
var t = this.hasError,
|
|
n = this.thrownError,
|
|
r = this.isStopped;
|
|
t ? e.error(n) : r && e.complete();
|
|
}),
|
|
(t.prototype.asObservable = function () {
|
|
var e = new eh();
|
|
return (e.source = this), e;
|
|
}),
|
|
(t.create = function (e, t) {
|
|
return new ey(e, t);
|
|
}),
|
|
t
|
|
);
|
|
})(eh),
|
|
ey = (function (e) {
|
|
function t(t, n) {
|
|
var r = e.call(this) || this;
|
|
return (r.destination = t), (r.source = n), r;
|
|
}
|
|
return (
|
|
(0, Z.__extends)(t, e),
|
|
(t.prototype.next = function (e) {
|
|
var t, n;
|
|
null == (n = null == (t = this.destination) ? void 0 : t.next) ||
|
|
n.call(t, e);
|
|
}),
|
|
(t.prototype.error = function (e) {
|
|
var t, n;
|
|
null == (n = null == (t = this.destination) ? void 0 : t.error) ||
|
|
n.call(t, e);
|
|
}),
|
|
(t.prototype.complete = function () {
|
|
var e, t;
|
|
null ==
|
|
(t = null == (e = this.destination) ? void 0 : e.complete) ||
|
|
t.call(e);
|
|
}),
|
|
(t.prototype._subscribe = function (e) {
|
|
var t, n;
|
|
return null !=
|
|
(n = null == (t = this.source) ? void 0 : t.subscribe(e))
|
|
? n
|
|
: z;
|
|
}),
|
|
t
|
|
);
|
|
})(ev);
|
|
e.s(["Subject", () => ev], 657179);
|
|
var e_ = {
|
|
now: function () {
|
|
return (e_.delegate || Date).now();
|
|
},
|
|
delegate: void 0,
|
|
},
|
|
eE = (function (e) {
|
|
function t(t, n, r) {
|
|
void 0 === t && (t = 1 / 0),
|
|
void 0 === n && (n = 1 / 0),
|
|
void 0 === r && (r = e_);
|
|
var s = e.call(this) || this;
|
|
return (
|
|
(s._bufferSize = t),
|
|
(s._windowTime = n),
|
|
(s._timestampProvider = r),
|
|
(s._buffer = []),
|
|
(s._infiniteTimeWindow = !0),
|
|
(s._infiniteTimeWindow = n === 1 / 0),
|
|
(s._bufferSize = Math.max(1, t)),
|
|
(s._windowTime = Math.max(1, n)),
|
|
s
|
|
);
|
|
}
|
|
return (
|
|
(0, Z.__extends)(t, e),
|
|
(t.prototype.next = function (t) {
|
|
var n = this.isStopped,
|
|
r = this._buffer,
|
|
s = this._infiniteTimeWindow,
|
|
i = this._timestampProvider,
|
|
a = this._windowTime;
|
|
!n && (r.push(t), s || r.push(i.now() + a)),
|
|
this._trimBuffer(),
|
|
e.prototype.next.call(this, t);
|
|
}),
|
|
(t.prototype._subscribe = function (e) {
|
|
this._throwIfClosed(), this._trimBuffer();
|
|
for (
|
|
var t = this._innerSubscribe(e),
|
|
n = this._infiniteTimeWindow,
|
|
r = this._buffer.slice(),
|
|
s = 0;
|
|
s < r.length && !e.closed;
|
|
s += n ? 1 : 2
|
|
)
|
|
e.next(r[s]);
|
|
return this._checkFinalizedStatuses(e), t;
|
|
}),
|
|
(t.prototype._trimBuffer = function () {
|
|
var e = this._bufferSize,
|
|
t = this._timestampProvider,
|
|
n = this._buffer,
|
|
r = this._infiniteTimeWindow,
|
|
s = (r ? 1 : 2) * e;
|
|
if ((e < 1 / 0 && s < n.length && n.splice(0, n.length - s), !r)) {
|
|
for (
|
|
var i = t.now(), a = 0, o = 1;
|
|
o < n.length && n[o] <= i;
|
|
o += 2
|
|
)
|
|
a = o;
|
|
a && n.splice(0, a + 1);
|
|
}
|
|
}),
|
|
t
|
|
);
|
|
})(ev),
|
|
eb = function (e) {
|
|
return e && "number" == typeof e.length && "function" != typeof e;
|
|
};
|
|
function eT(e) {
|
|
return U(null == e ? void 0 : e.then);
|
|
}
|
|
function eS(e) {
|
|
return (
|
|
Symbol.asyncIterator && U(null == e ? void 0 : e[Symbol.asyncIterator])
|
|
);
|
|
}
|
|
function eA(e) {
|
|
return TypeError(
|
|
"You provided " +
|
|
(null !== e && "object" == typeof e
|
|
? "an invalid object"
|
|
: "'" + e + "'") +
|
|
" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.",
|
|
);
|
|
}
|
|
var eN =
|
|
"function" == typeof Symbol && Symbol.iterator
|
|
? Symbol.iterator
|
|
: "@@iterator";
|
|
function eI(e) {
|
|
return U(null == e ? void 0 : e[eN]);
|
|
}
|
|
function ew(e) {
|
|
return (0, Z.__asyncGenerator)(this, arguments, function () {
|
|
var t, n, r;
|
|
return (0, Z.__generator)(this, function (s) {
|
|
switch (s.label) {
|
|
case 0:
|
|
(t = e.getReader()), (s.label = 1);
|
|
case 1:
|
|
s.trys.push([1, , 9, 10]), (s.label = 2);
|
|
case 2:
|
|
return [4, (0, Z.__await)(t.read())];
|
|
case 3:
|
|
if (((r = (n = s.sent()).value), !n.done)) return [3, 5];
|
|
return [4, (0, Z.__await)(void 0)];
|
|
case 4:
|
|
return [2, s.sent()];
|
|
case 5:
|
|
return [4, (0, Z.__await)(r)];
|
|
case 6:
|
|
return [4, s.sent()];
|
|
case 7:
|
|
return s.sent(), [3, 2];
|
|
case 8:
|
|
return [3, 10];
|
|
case 9:
|
|
return t.releaseLock(), [7];
|
|
case 10:
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
}
|
|
function eO(e) {
|
|
return U(null == e ? void 0 : e.getReader);
|
|
}
|
|
function eC(e) {
|
|
if (e instanceof eh) return e;
|
|
if (null != e) {
|
|
var t, n, r, s;
|
|
if (U(e[eu])) {
|
|
return (
|
|
(t = e),
|
|
new eh(function (e) {
|
|
var n = t[eu]();
|
|
if (U(n.subscribe)) return n.subscribe(e);
|
|
throw TypeError(
|
|
"Provided object does not correctly implement Symbol.observable",
|
|
);
|
|
})
|
|
);
|
|
}
|
|
if (eb(e)) {
|
|
return (
|
|
(n = e),
|
|
new eh(function (e) {
|
|
for (var t = 0; t < n.length && !e.closed; t++) e.next(n[t]);
|
|
e.complete();
|
|
})
|
|
);
|
|
}
|
|
if (eT(e)) {
|
|
return (
|
|
(r = e),
|
|
new eh(function (e) {
|
|
r.then(
|
|
function (t) {
|
|
e.closed || (e.next(t), e.complete());
|
|
},
|
|
function (t) {
|
|
return e.error(t);
|
|
},
|
|
).then(null, X);
|
|
})
|
|
);
|
|
}
|
|
if (eS(e)) return eR(e);
|
|
if (eI(e)) {
|
|
return (
|
|
(s = e),
|
|
new eh(function (e) {
|
|
var t, n;
|
|
try {
|
|
for (
|
|
var r = (0, Z.__values)(s), i = r.next();
|
|
!i.done;
|
|
i = r.next()
|
|
) {
|
|
var a = i.value;
|
|
if ((e.next(a), e.closed)) return;
|
|
}
|
|
} catch (e) {
|
|
t = { error: e };
|
|
} finally {
|
|
try {
|
|
i && !i.done && (n = r.return) && n.call(r);
|
|
} finally {
|
|
if (t) throw t.error;
|
|
}
|
|
}
|
|
e.complete();
|
|
})
|
|
);
|
|
}
|
|
if (eO(e)) return eR(ew(e));
|
|
}
|
|
throw eA(e);
|
|
}
|
|
function eR(e) {
|
|
return new eh(function (t) {
|
|
(function (e, t) {
|
|
var n, r, s, i;
|
|
return (0, Z.__awaiter)(this, void 0, void 0, function () {
|
|
var a;
|
|
return (0, Z.__generator)(this, function (o) {
|
|
switch (o.label) {
|
|
case 0:
|
|
o.trys.push([0, 5, 6, 11]),
|
|
(n = (0, Z.__asyncValues)(e)),
|
|
(o.label = 1);
|
|
case 1:
|
|
return [4, n.next()];
|
|
case 2:
|
|
if ((r = o.sent()).done) return [3, 4];
|
|
if (((a = r.value), t.next(a), t.closed)) return [2];
|
|
o.label = 3;
|
|
case 3:
|
|
return [3, 1];
|
|
case 4:
|
|
return [3, 11];
|
|
case 5:
|
|
return (s = { error: o.sent() }), [3, 11];
|
|
case 6:
|
|
if (
|
|
(o.trys.push([6, , 9, 10]),
|
|
!(r && !r.done && (i = n.return)))
|
|
)
|
|
return [3, 8];
|
|
return [4, i.call(n)];
|
|
case 7:
|
|
o.sent(), (o.label = 8);
|
|
case 8:
|
|
return [3, 10];
|
|
case 9:
|
|
if (s) throw s.error;
|
|
return [7];
|
|
case 10:
|
|
return [7];
|
|
case 11:
|
|
return t.complete(), [2];
|
|
}
|
|
});
|
|
});
|
|
})(e, t).catch(function (e) {
|
|
return t.error(e);
|
|
});
|
|
});
|
|
}
|
|
function ek(e) {
|
|
return function (t) {
|
|
if (U(null == t ? void 0 : t.lift))
|
|
return t.lift(function (t) {
|
|
try {
|
|
return e(t, this);
|
|
} catch (e) {
|
|
this.error(e);
|
|
}
|
|
});
|
|
throw TypeError("Unable to lift unknown Observable type");
|
|
};
|
|
}
|
|
function ex(e) {
|
|
return ek(function (t, n) {
|
|
try {
|
|
t.subscribe(n);
|
|
} finally {
|
|
n.add(e);
|
|
}
|
|
});
|
|
}
|
|
function eP(e, t, n, r, s) {
|
|
void 0 === r && (r = 0), void 0 === s && (s = !1);
|
|
var i = t.schedule(function () {
|
|
n(), s ? e.add(this.schedule(null, r)) : this.unsubscribe();
|
|
}, r);
|
|
if ((e.add(i), !s)) return i;
|
|
}
|
|
function eM(e, t, n, r, s) {
|
|
return new eL(e, t, n, r, s);
|
|
}
|
|
var eL = (function (e) {
|
|
function t(t, n, r, s, i, a) {
|
|
var o = e.call(this, t) || this;
|
|
return (
|
|
(o.onFinalize = i),
|
|
(o.shouldUnsubscribe = a),
|
|
(o._next = n
|
|
? function (e) {
|
|
try {
|
|
n(e);
|
|
} catch (e) {
|
|
t.error(e);
|
|
}
|
|
}
|
|
: e.prototype._next),
|
|
(o._error = s
|
|
? function (e) {
|
|
try {
|
|
s(e);
|
|
} catch (e) {
|
|
t.error(e);
|
|
} finally {
|
|
this.unsubscribe();
|
|
}
|
|
}
|
|
: e.prototype._error),
|
|
(o._complete = r
|
|
? function () {
|
|
try {
|
|
r();
|
|
} catch (e) {
|
|
t.error(e);
|
|
} finally {
|
|
this.unsubscribe();
|
|
}
|
|
}
|
|
: e.prototype._complete),
|
|
o
|
|
);
|
|
}
|
|
return (
|
|
(0, Z.__extends)(t, e),
|
|
(t.prototype.unsubscribe = function () {
|
|
var t;
|
|
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
var n = this.closed;
|
|
e.prototype.unsubscribe.call(this),
|
|
n || null == (t = this.onFinalize) || t.call(this);
|
|
}
|
|
}),
|
|
t
|
|
);
|
|
})(et);
|
|
function eD(e, t) {
|
|
return (
|
|
void 0 === t && (t = 0),
|
|
ek(function (n, r) {
|
|
n.subscribe(
|
|
eM(
|
|
r,
|
|
function (n) {
|
|
return eP(
|
|
r,
|
|
e,
|
|
function () {
|
|
return r.next(n);
|
|
},
|
|
t,
|
|
);
|
|
},
|
|
function () {
|
|
return eP(
|
|
r,
|
|
e,
|
|
function () {
|
|
return r.complete();
|
|
},
|
|
t,
|
|
);
|
|
},
|
|
function (n) {
|
|
return eP(
|
|
r,
|
|
e,
|
|
function () {
|
|
return r.error(n);
|
|
},
|
|
t,
|
|
);
|
|
},
|
|
),
|
|
);
|
|
})
|
|
);
|
|
}
|
|
function ej(e, t) {
|
|
return (
|
|
void 0 === t && (t = 0),
|
|
ek(function (n, r) {
|
|
r.add(
|
|
e.schedule(function () {
|
|
return n.subscribe(r);
|
|
}, t),
|
|
);
|
|
})
|
|
);
|
|
}
|
|
function eZ(e, t) {
|
|
if (!e) throw Error("Iterable cannot be null");
|
|
return new eh(function (n) {
|
|
eP(n, t, function () {
|
|
var r = e[Symbol.asyncIterator]();
|
|
eP(
|
|
n,
|
|
t,
|
|
function () {
|
|
r.next().then(function (e) {
|
|
e.done ? n.complete() : n.next(e.value);
|
|
});
|
|
},
|
|
0,
|
|
!0,
|
|
);
|
|
});
|
|
});
|
|
}
|
|
function eU(e, t) {
|
|
return t
|
|
? (function (e, t) {
|
|
if (null != e) {
|
|
if (U(e[eu])) return eC(e).pipe(ej(t), eD(t));
|
|
if (eb(e))
|
|
return new eh(function (n) {
|
|
var r = 0;
|
|
return t.schedule(function () {
|
|
r === e.length
|
|
? n.complete()
|
|
: (n.next(e[r++]), n.closed || this.schedule());
|
|
});
|
|
});
|
|
if (eT(e)) return eC(e).pipe(ej(t), eD(t));
|
|
if (eS(e)) return eZ(e, t);
|
|
if (eI(e))
|
|
return new eh(function (n) {
|
|
var r;
|
|
return (
|
|
eP(n, t, function () {
|
|
(r = e[eN]()),
|
|
eP(
|
|
n,
|
|
t,
|
|
function () {
|
|
var e, t, s;
|
|
try {
|
|
(t = (e = r.next()).value), (s = e.done);
|
|
} catch (e) {
|
|
n.error(e);
|
|
return;
|
|
}
|
|
s ? n.complete() : n.next(t);
|
|
},
|
|
0,
|
|
!0,
|
|
);
|
|
}),
|
|
function () {
|
|
return U(null == r ? void 0 : r.return) && r.return();
|
|
}
|
|
);
|
|
});
|
|
if (eO(e)) return eZ(ew(e), t);
|
|
}
|
|
throw eA(e);
|
|
})(e, t)
|
|
: eC(e);
|
|
}
|
|
var eG = G(function (e) {
|
|
return function () {
|
|
e(this),
|
|
(this.name = "EmptyError"),
|
|
(this.message = "no elements in sequence");
|
|
};
|
|
});
|
|
function eF(e, t) {
|
|
var n = "object" == typeof t;
|
|
return new Promise(function (r, s) {
|
|
var i,
|
|
a = !1;
|
|
e.subscribe({
|
|
next: function (e) {
|
|
(i = e), (a = !0);
|
|
},
|
|
error: s,
|
|
complete: function () {
|
|
a ? r(i) : n ? r(t.defaultValue) : s(new eG());
|
|
},
|
|
});
|
|
});
|
|
}
|
|
function e$(e, t) {
|
|
return ek(function (n, r) {
|
|
var s = 0;
|
|
n.subscribe(
|
|
eM(r, function (n) {
|
|
r.next(e.call(t, n, s++));
|
|
}),
|
|
);
|
|
});
|
|
}
|
|
function eV(e, t, n) {
|
|
return (void 0 === n && (n = 1 / 0), U(t))
|
|
? eV(function (n, r) {
|
|
return e$(function (e, s) {
|
|
return t(n, e, r, s);
|
|
})(eC(e(n, r)));
|
|
}, n)
|
|
: ("number" == typeof t && (n = t),
|
|
ek(function (t, r) {
|
|
var s, i, a, o, l, u, d, c;
|
|
return (
|
|
(s = n),
|
|
(i = []),
|
|
(a = 0),
|
|
(o = 0),
|
|
(l = !1),
|
|
(u = function () {
|
|
!l || i.length || a || r.complete();
|
|
}),
|
|
(d = function (e) {
|
|
return a < s ? c(e) : i.push(e);
|
|
}),
|
|
(c = function (t) {
|
|
a++;
|
|
var n = !1;
|
|
eC(e(t, o++)).subscribe(
|
|
eM(
|
|
r,
|
|
function (e) {
|
|
r.next(e);
|
|
},
|
|
function () {
|
|
n = !0;
|
|
},
|
|
void 0,
|
|
function () {
|
|
if (n)
|
|
try {
|
|
for (a--; i.length && a < s; )
|
|
!(function () {
|
|
var e = i.shift();
|
|
c(e);
|
|
})();
|
|
u();
|
|
} catch (e) {
|
|
r.error(e);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}),
|
|
t.subscribe(
|
|
eM(r, d, function () {
|
|
(l = !0), u();
|
|
}),
|
|
),
|
|
function () {}
|
|
);
|
|
}));
|
|
}
|
|
function ez() {
|
|
for (var e, t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
|
|
var r = (e = t[t.length - 1]) && U(e.schedule) ? t.pop() : void 0;
|
|
return eU(t, r);
|
|
}
|
|
function eH(e, t) {
|
|
var n = U(e)
|
|
? e
|
|
: function () {
|
|
return e;
|
|
},
|
|
r = function (e) {
|
|
return e.error(n());
|
|
};
|
|
return new eh(
|
|
t
|
|
? function (e) {
|
|
return t.schedule(r, 0, e);
|
|
}
|
|
: r,
|
|
);
|
|
}
|
|
function eK(e) {
|
|
return ek(function (t, n) {
|
|
var r,
|
|
s = null,
|
|
i = !1;
|
|
(s = t.subscribe(
|
|
eM(n, void 0, void 0, function (a) {
|
|
(r = eC(e(a, eK(e)(t)))),
|
|
s ? (s.unsubscribe(), (s = null), r.subscribe(n)) : (i = !0);
|
|
}),
|
|
)),
|
|
i && (s.unsubscribe(), (s = null), r.subscribe(n));
|
|
});
|
|
}
|
|
function eB(e, t) {
|
|
return U(t) ? eV(e, t, 1) : eV(e, 1);
|
|
}
|
|
function eJ(e) {
|
|
return ek(function (t, n) {
|
|
eC(e).subscribe(
|
|
eM(
|
|
n,
|
|
function () {
|
|
return n.complete();
|
|
},
|
|
W,
|
|
),
|
|
),
|
|
n.closed || t.subscribe(n);
|
|
});
|
|
}
|
|
function eX(e, t, n) {
|
|
var r = U(e) || t || n ? { next: e, error: t, complete: n } : e;
|
|
return r
|
|
? ek(function (e, t) {
|
|
null == (n = r.subscribe) || n.call(r);
|
|
var n,
|
|
s = !0;
|
|
e.subscribe(
|
|
eM(
|
|
t,
|
|
function (e) {
|
|
var n;
|
|
null == (n = r.next) || n.call(r, e), t.next(e);
|
|
},
|
|
function () {
|
|
var e;
|
|
(s = !1), null == (e = r.complete) || e.call(r), t.complete();
|
|
},
|
|
function (e) {
|
|
var n;
|
|
(s = !1), null == (n = r.error) || n.call(r, e), t.error(e);
|
|
},
|
|
function () {
|
|
var e, t;
|
|
s && (null == (e = r.unsubscribe) || e.call(r)),
|
|
null == (t = r.finalize) || t.call(r);
|
|
},
|
|
),
|
|
);
|
|
})
|
|
: ed;
|
|
}
|
|
function eW(e) {
|
|
return " \r\n ".indexOf(e) >= 0;
|
|
}
|
|
function eY(e) {
|
|
for (
|
|
var t,
|
|
n,
|
|
r,
|
|
s = ["topLevel"],
|
|
i = 0,
|
|
a = function (e) {
|
|
return s.push(e);
|
|
},
|
|
o = function (e) {
|
|
return (s[s.length - 1] = e);
|
|
},
|
|
l = function (e) {
|
|
null == t && ((t = i), (n = s.length), (r = e));
|
|
},
|
|
u = function (e) {
|
|
e === r && ((t = void 0), (n = void 0), (r = void 0));
|
|
},
|
|
d = function () {
|
|
return s.pop();
|
|
},
|
|
c = function () {
|
|
return i--;
|
|
},
|
|
p = function (e) {
|
|
if ("0" <= e && e <= "9") return void a("number");
|
|
switch (e) {
|
|
case '"':
|
|
a("string");
|
|
return;
|
|
case "-":
|
|
a("numberNeedsDigit");
|
|
return;
|
|
case "t":
|
|
a("true");
|
|
return;
|
|
case "f":
|
|
a("false");
|
|
return;
|
|
case "n":
|
|
a("null");
|
|
return;
|
|
case "[":
|
|
a("arrayNeedsValue");
|
|
return;
|
|
case "{":
|
|
a("objectNeedsKey");
|
|
return;
|
|
}
|
|
},
|
|
h = e.length;
|
|
i < h;
|
|
i++
|
|
) {
|
|
var f = e[i];
|
|
switch (s[s.length - 1]) {
|
|
case "topLevel":
|
|
p(f);
|
|
break;
|
|
case "string":
|
|
switch (f) {
|
|
case '"':
|
|
d();
|
|
break;
|
|
case "\\":
|
|
l("stringEscape"), a("stringEscaped");
|
|
}
|
|
break;
|
|
case "stringEscaped":
|
|
"u" === f ? a("stringUnicode") : (u("stringEscape"), d());
|
|
break;
|
|
case "stringUnicode":
|
|
i - e.lastIndexOf("u", i) == 4 && (u("stringEscape"), d());
|
|
break;
|
|
case "number":
|
|
"." === f
|
|
? o("numberNeedsDigit")
|
|
: "e" === f || "E" === f
|
|
? o("numberNeedsExponent")
|
|
: (f < "0" || f > "9") && (c(), d());
|
|
break;
|
|
case "numberNeedsDigit":
|
|
o("number");
|
|
break;
|
|
case "numberNeedsExponent":
|
|
o("+" === f || "-" === f ? "numberNeedsDigit" : "number");
|
|
break;
|
|
case "true":
|
|
case "false":
|
|
case "null":
|
|
(f < "a" || f > "z") && (c(), d());
|
|
break;
|
|
case "arrayNeedsValue":
|
|
"]" === f
|
|
? d()
|
|
: eW(f) || (u("collectionItem"), o("arrayNeedsComma"), p(f));
|
|
break;
|
|
case "arrayNeedsComma":
|
|
"]" === f
|
|
? d()
|
|
: "," === f && (l("collectionItem"), o("arrayNeedsValue"));
|
|
break;
|
|
case "objectNeedsKey":
|
|
"}" === f
|
|
? d()
|
|
: '"' === f &&
|
|
(l("collectionItem"), o("objectNeedsColon"), a("string"));
|
|
break;
|
|
case "objectNeedsColon":
|
|
":" === f && o("objectNeedsValue");
|
|
break;
|
|
case "objectNeedsValue":
|
|
eW(f) || (u("collectionItem"), o("objectNeedsComma"), p(f));
|
|
break;
|
|
case "objectNeedsComma":
|
|
"}" === f
|
|
? d()
|
|
: "," === f && (l("collectionItem"), o("objectNeedsKey"));
|
|
}
|
|
}
|
|
null != n && (s.length = n);
|
|
for (
|
|
var g = [null != t ? e.slice(0, t) : e],
|
|
m = function (t) {
|
|
return g.push(t.slice(e.length - e.lastIndexOf(t[0])));
|
|
},
|
|
v = s.length - 1;
|
|
v >= 0;
|
|
v--
|
|
)
|
|
switch (s[v]) {
|
|
case "string":
|
|
g.push('"');
|
|
break;
|
|
case "numberNeedsDigit":
|
|
case "numberNeedsExponent":
|
|
g.push("0");
|
|
break;
|
|
case "true":
|
|
m("true");
|
|
break;
|
|
case "false":
|
|
m("false");
|
|
break;
|
|
case "null":
|
|
m("null");
|
|
break;
|
|
case "arrayNeedsValue":
|
|
case "arrayNeedsComma":
|
|
g.push("]");
|
|
break;
|
|
case "objectNeedsKey":
|
|
case "objectNeedsColon":
|
|
case "objectNeedsValue":
|
|
case "objectNeedsComma":
|
|
g.push("}");
|
|
}
|
|
return g.join("");
|
|
}
|
|
function eq() {
|
|
let e = 0,
|
|
t = 0;
|
|
for (let n = 0; n < 28; n += 7) {
|
|
let r = this.buf[this.pos++];
|
|
if (((e |= (127 & r) << n), (128 & r) == 0))
|
|
return this.assertBounds(), [e, t];
|
|
}
|
|
let n = this.buf[this.pos++];
|
|
if (((e |= (15 & n) << 28), (t = (112 & n) >> 4), (128 & n) == 0))
|
|
return this.assertBounds(), [e, t];
|
|
for (let n = 3; n <= 31; n += 7) {
|
|
let r = this.buf[this.pos++];
|
|
if (((t |= (127 & r) << n), (128 & r) == 0))
|
|
return this.assertBounds(), [e, t];
|
|
}
|
|
throw Error("invalid varint");
|
|
}
|
|
function eQ(e, t, n) {
|
|
for (let r = 0; r < 28; r += 7) {
|
|
let s = e >>> r,
|
|
i = s >>> 7 != 0 || 0 != t,
|
|
a = (i ? 128 | s : s) & 255;
|
|
if ((n.push(a), !i)) return;
|
|
}
|
|
let r = ((e >>> 28) & 15) | ((7 & t) << 4),
|
|
s = t >> 3 != 0;
|
|
if ((n.push((s ? 128 | r : r) & 255), s)) {
|
|
for (let e = 3; e < 31; e += 7) {
|
|
let r = t >>> e,
|
|
s = r >>> 7 != 0,
|
|
i = (s ? 128 | r : r) & 255;
|
|
if ((n.push(i), !s)) return;
|
|
}
|
|
n.push((t >>> 31) & 1);
|
|
}
|
|
}
|
|
function e0(e) {
|
|
let t = "-" === e[0];
|
|
t && (e = e.slice(1));
|
|
let n = 0,
|
|
r = 0;
|
|
function s(t, s) {
|
|
let i = Number(e.slice(t, s));
|
|
(r *= 1e6),
|
|
(n = 1e6 * n + i) >= 0x100000000 &&
|
|
((r += (n / 0x100000000) | 0), (n %= 0x100000000));
|
|
}
|
|
return (
|
|
s(-24, -18), s(-18, -12), s(-12, -6), s(-6), t ? e3(n, r) : e2(n, r)
|
|
);
|
|
}
|
|
function e1(e, t) {
|
|
if ((({ lo: e, hi: t } = { lo: e >>> 0, hi: t >>> 0 }), t <= 2097151))
|
|
return String(0x100000000 * t + e);
|
|
let n = 0xffffff & e,
|
|
r = ((e >>> 24) | (t << 8)) & 0xffffff,
|
|
s = (t >> 16) & 65535,
|
|
i = n + 6777216 * r + 6710656 * s,
|
|
a = r + 8147497 * s,
|
|
o = 2 * s;
|
|
return (
|
|
i >= 1e7 && ((a += Math.floor(i / 1e7)), (i %= 1e7)),
|
|
a >= 1e7 && ((o += Math.floor(a / 1e7)), (a %= 1e7)),
|
|
o.toString() + e4(a) + e4(i)
|
|
);
|
|
}
|
|
function e2(e, t) {
|
|
return { lo: 0 | e, hi: 0 | t };
|
|
}
|
|
function e3(e, t) {
|
|
return (t = ~t), e ? (e = ~e + 1) : (t += 1), e2(e, t);
|
|
}
|
|
e.s(["catchError", () => eK], 153766),
|
|
e.s(["tap", () => eX], 548833),
|
|
e.s(["default", () => eY], 87030);
|
|
let e4 = (e) => {
|
|
let t = String(e);
|
|
return "0000000".slice(t.length) + t;
|
|
};
|
|
function e9(e, t) {
|
|
if (e >= 0) {
|
|
for (; e > 127; ) t.push((127 & e) | 128), (e >>>= 7);
|
|
t.push(e);
|
|
} else {
|
|
for (let n = 0; n < 9; n++) t.push((127 & e) | 128), (e >>= 7);
|
|
t.push(1);
|
|
}
|
|
}
|
|
function e8() {
|
|
let e = this.buf[this.pos++],
|
|
t = 127 & e;
|
|
if (
|
|
(128 & e) == 0 ||
|
|
((t |= (127 & (e = this.buf[this.pos++])) << 7), (128 & e) == 0) ||
|
|
((t |= (127 & (e = this.buf[this.pos++])) << 14), (128 & e) == 0) ||
|
|
((t |= (127 & (e = this.buf[this.pos++])) << 21), (128 & e) == 0)
|
|
)
|
|
return this.assertBounds(), t;
|
|
t |= (15 & (e = this.buf[this.pos++])) << 28;
|
|
for (let t = 5; (128 & e) != 0 && t < 10; t++) e = this.buf[this.pos++];
|
|
if ((128 & e) != 0) throw Error("invalid varint");
|
|
return this.assertBounds(), t >>> 0;
|
|
}
|
|
let e6 = (function () {
|
|
let e = new DataView(new ArrayBuffer(8));
|
|
if (
|
|
"function" == typeof BigInt &&
|
|
"function" == typeof e.getBigInt64 &&
|
|
"function" == typeof e.getBigUint64 &&
|
|
"function" == typeof e.setBigInt64 &&
|
|
"function" == typeof e.setBigUint64 &&
|
|
(globalThis.Deno ||
|
|
"object" != typeof l.default ||
|
|
"object" != typeof l.default.env ||
|
|
"1" !== l.default.env.BUF_BIGINT_DISABLE)
|
|
) {
|
|
let t = BigInt("-9223372036854775808"),
|
|
n = BigInt("9223372036854775807"),
|
|
r = BigInt("0"),
|
|
s = BigInt("18446744073709551615");
|
|
return {
|
|
zero: BigInt(0),
|
|
supported: !0,
|
|
parse(e) {
|
|
let r = "bigint" == typeof e ? e : BigInt(e);
|
|
if (r > n || r < t) throw Error(`invalid int64: ${e}`);
|
|
return r;
|
|
},
|
|
uParse(e) {
|
|
let t = "bigint" == typeof e ? e : BigInt(e);
|
|
if (t > s || t < r) throw Error(`invalid uint64: ${e}`);
|
|
return t;
|
|
},
|
|
enc(t) {
|
|
return (
|
|
e.setBigInt64(0, this.parse(t), !0),
|
|
{ lo: e.getInt32(0, !0), hi: e.getInt32(4, !0) }
|
|
);
|
|
},
|
|
uEnc(t) {
|
|
return (
|
|
e.setBigInt64(0, this.uParse(t), !0),
|
|
{ lo: e.getInt32(0, !0), hi: e.getInt32(4, !0) }
|
|
);
|
|
},
|
|
dec: (t, n) => (
|
|
e.setInt32(0, t, !0), e.setInt32(4, n, !0), e.getBigInt64(0, !0)
|
|
),
|
|
uDec: (t, n) => (
|
|
e.setInt32(0, t, !0), e.setInt32(4, n, !0), e.getBigUint64(0, !0)
|
|
),
|
|
};
|
|
}
|
|
return {
|
|
zero: "0",
|
|
supported: !1,
|
|
parse: (e) => ("string" != typeof e && (e = e.toString()), e7(e), e),
|
|
uParse: (e) => ("string" != typeof e && (e = e.toString()), e5(e), e),
|
|
enc: (e) => ("string" != typeof e && (e = e.toString()), e7(e), e0(e)),
|
|
uEnc: (e) => ("string" != typeof e && (e = e.toString()), e5(e), e0(e)),
|
|
dec: (e, t) => {
|
|
let n, r, s;
|
|
return (
|
|
(r = 0x80000000 & (n = e2(e, t)).hi) && (n = e3(n.lo, n.hi)),
|
|
(s = e1(n.lo, n.hi)),
|
|
r ? "-" + s : s
|
|
);
|
|
},
|
|
uDec: (e, t) => e1(e, t),
|
|
};
|
|
})();
|
|
function e7(e) {
|
|
if (!/^-?[0-9]+$/.test(e)) throw Error("invalid int64: " + e);
|
|
}
|
|
function e5(e) {
|
|
if (!/^[0-9]+$/.test(e)) throw Error("invalid uint64: " + e);
|
|
}
|
|
let te = Symbol.for("@bufbuild/protobuf/text-encoding");
|
|
function tt() {
|
|
if (void 0 == globalThis[te]) {
|
|
let e = new globalThis.TextEncoder(),
|
|
t = new globalThis.TextDecoder();
|
|
globalThis[te] = {
|
|
encodeUtf8: (t) => e.encode(t),
|
|
decodeUtf8: (e) => t.decode(e),
|
|
checkUtf8(e) {
|
|
try {
|
|
return encodeURIComponent(e), !0;
|
|
} catch (e) {
|
|
return !1;
|
|
}
|
|
},
|
|
};
|
|
}
|
|
return globalThis[te];
|
|
}
|
|
((n = o || (o = {}))[(n.Varint = 0)] = "Varint"),
|
|
(n[(n.Bit64 = 1)] = "Bit64"),
|
|
(n[(n.LengthDelimited = 2)] = "LengthDelimited"),
|
|
(n[(n.StartGroup = 3)] = "StartGroup"),
|
|
(n[(n.EndGroup = 4)] = "EndGroup"),
|
|
(n[(n.Bit32 = 5)] = "Bit32");
|
|
class tn {
|
|
constructor(e = tt().encodeUtf8) {
|
|
(this.encodeUtf8 = e),
|
|
(this.stack = []),
|
|
(this.chunks = []),
|
|
(this.buf = []);
|
|
}
|
|
finish() {
|
|
this.buf.length &&
|
|
(this.chunks.push(new Uint8Array(this.buf)), (this.buf = []));
|
|
let e = 0;
|
|
for (let t = 0; t < this.chunks.length; t++) e += this.chunks[t].length;
|
|
let t = new Uint8Array(e),
|
|
n = 0;
|
|
for (let e = 0; e < this.chunks.length; e++)
|
|
t.set(this.chunks[e], n), (n += this.chunks[e].length);
|
|
return (this.chunks = []), t;
|
|
}
|
|
fork() {
|
|
return (
|
|
this.stack.push({ chunks: this.chunks, buf: this.buf }),
|
|
(this.chunks = []),
|
|
(this.buf = []),
|
|
this
|
|
);
|
|
}
|
|
join() {
|
|
let e = this.finish(),
|
|
t = this.stack.pop();
|
|
if (!t) throw Error("invalid state, fork stack empty");
|
|
return (
|
|
(this.chunks = t.chunks),
|
|
(this.buf = t.buf),
|
|
this.uint32(e.byteLength),
|
|
this.raw(e)
|
|
);
|
|
}
|
|
tag(e, t) {
|
|
return this.uint32(((e << 3) | t) >>> 0);
|
|
}
|
|
raw(e) {
|
|
return (
|
|
this.buf.length &&
|
|
(this.chunks.push(new Uint8Array(this.buf)), (this.buf = [])),
|
|
this.chunks.push(e),
|
|
this
|
|
);
|
|
}
|
|
uint32(e) {
|
|
for (ti(e); e > 127; ) this.buf.push((127 & e) | 128), (e >>>= 7);
|
|
return this.buf.push(e), this;
|
|
}
|
|
int32(e) {
|
|
return ts(e), e9(e, this.buf), this;
|
|
}
|
|
bool(e) {
|
|
return this.buf.push(+!!e), this;
|
|
}
|
|
bytes(e) {
|
|
return this.uint32(e.byteLength), this.raw(e);
|
|
}
|
|
string(e) {
|
|
let t = this.encodeUtf8(e);
|
|
return this.uint32(t.byteLength), this.raw(t);
|
|
}
|
|
float(e) {
|
|
var t = e;
|
|
if ("string" == typeof t) {
|
|
let e = t;
|
|
if (Number.isNaN((t = Number(t))) && "NaN" !== e)
|
|
throw Error("invalid float32: " + e);
|
|
} else if ("number" != typeof t)
|
|
throw Error("invalid float32: " + typeof t);
|
|
if (
|
|
Number.isFinite(t) &&
|
|
(t > 34028234663852886e22 || t < -34028234663852886e22)
|
|
)
|
|
throw Error("invalid float32: " + t);
|
|
let n = new Uint8Array(4);
|
|
return new DataView(n.buffer).setFloat32(0, e, !0), this.raw(n);
|
|
}
|
|
double(e) {
|
|
let t = new Uint8Array(8);
|
|
return new DataView(t.buffer).setFloat64(0, e, !0), this.raw(t);
|
|
}
|
|
fixed32(e) {
|
|
ti(e);
|
|
let t = new Uint8Array(4);
|
|
return new DataView(t.buffer).setUint32(0, e, !0), this.raw(t);
|
|
}
|
|
sfixed32(e) {
|
|
ts(e);
|
|
let t = new Uint8Array(4);
|
|
return new DataView(t.buffer).setInt32(0, e, !0), this.raw(t);
|
|
}
|
|
sint32(e) {
|
|
return ts(e), e9((e = ((e << 1) ^ (e >> 31)) >>> 0), this.buf), this;
|
|
}
|
|
sfixed64(e) {
|
|
let t = new Uint8Array(8),
|
|
n = new DataView(t.buffer),
|
|
r = e6.enc(e);
|
|
return n.setInt32(0, r.lo, !0), n.setInt32(4, r.hi, !0), this.raw(t);
|
|
}
|
|
fixed64(e) {
|
|
let t = new Uint8Array(8),
|
|
n = new DataView(t.buffer),
|
|
r = e6.uEnc(e);
|
|
return n.setInt32(0, r.lo, !0), n.setInt32(4, r.hi, !0), this.raw(t);
|
|
}
|
|
int64(e) {
|
|
let t = e6.enc(e);
|
|
return eQ(t.lo, t.hi, this.buf), this;
|
|
}
|
|
sint64(e) {
|
|
let t = e6.enc(e),
|
|
n = t.hi >> 31;
|
|
return (
|
|
eQ((t.lo << 1) ^ n, ((t.hi << 1) | (t.lo >>> 31)) ^ n, this.buf), this
|
|
);
|
|
}
|
|
uint64(e) {
|
|
let t = e6.uEnc(e);
|
|
return eQ(t.lo, t.hi, this.buf), this;
|
|
}
|
|
}
|
|
class tr {
|
|
constructor(e, t = tt().decodeUtf8) {
|
|
(this.decodeUtf8 = t),
|
|
(this.varint64 = eq),
|
|
(this.uint32 = e8),
|
|
(this.buf = e),
|
|
(this.len = e.length),
|
|
(this.pos = 0),
|
|
(this.view = new DataView(e.buffer, e.byteOffset, e.byteLength));
|
|
}
|
|
tag() {
|
|
let e = this.uint32(),
|
|
t = e >>> 3,
|
|
n = 7 & e;
|
|
if (t <= 0 || n < 0 || n > 5)
|
|
throw Error("illegal tag: field no " + t + " wire type " + n);
|
|
return [t, n];
|
|
}
|
|
skip(e, t) {
|
|
let n = this.pos;
|
|
switch (e) {
|
|
case o.Varint:
|
|
for (; 128 & this.buf[this.pos++]; );
|
|
break;
|
|
case o.Bit64:
|
|
this.pos += 4;
|
|
case o.Bit32:
|
|
this.pos += 4;
|
|
break;
|
|
case o.LengthDelimited:
|
|
let r = this.uint32();
|
|
this.pos += r;
|
|
break;
|
|
case o.StartGroup:
|
|
for (;;) {
|
|
let [e, n] = this.tag();
|
|
if (n === o.EndGroup) {
|
|
if (void 0 !== t && e !== t)
|
|
throw Error("invalid end group tag");
|
|
break;
|
|
}
|
|
this.skip(n, e);
|
|
}
|
|
break;
|
|
default:
|
|
throw Error("cant skip wire type " + e);
|
|
}
|
|
return this.assertBounds(), this.buf.subarray(n, this.pos);
|
|
}
|
|
assertBounds() {
|
|
if (this.pos > this.len) throw RangeError("premature EOF");
|
|
}
|
|
int32() {
|
|
return 0 | this.uint32();
|
|
}
|
|
sint32() {
|
|
let e = this.uint32();
|
|
return (e >>> 1) ^ -(1 & e);
|
|
}
|
|
int64() {
|
|
return e6.dec(...this.varint64());
|
|
}
|
|
uint64() {
|
|
return e6.uDec(...this.varint64());
|
|
}
|
|
sint64() {
|
|
let [e, t] = this.varint64(),
|
|
n = -(1 & e);
|
|
return (
|
|
(e = ((e >>> 1) | ((1 & t) << 31)) ^ n),
|
|
(t = (t >>> 1) ^ n),
|
|
e6.dec(e, t)
|
|
);
|
|
}
|
|
bool() {
|
|
let [e, t] = this.varint64();
|
|
return 0 !== e || 0 !== t;
|
|
}
|
|
fixed32() {
|
|
return this.view.getUint32((this.pos += 4) - 4, !0);
|
|
}
|
|
sfixed32() {
|
|
return this.view.getInt32((this.pos += 4) - 4, !0);
|
|
}
|
|
fixed64() {
|
|
return e6.uDec(this.sfixed32(), this.sfixed32());
|
|
}
|
|
sfixed64() {
|
|
return e6.dec(this.sfixed32(), this.sfixed32());
|
|
}
|
|
float() {
|
|
return this.view.getFloat32((this.pos += 4) - 4, !0);
|
|
}
|
|
double() {
|
|
return this.view.getFloat64((this.pos += 8) - 8, !0);
|
|
}
|
|
bytes() {
|
|
let e = this.uint32(),
|
|
t = this.pos;
|
|
return (
|
|
(this.pos += e), this.assertBounds(), this.buf.subarray(t, t + e)
|
|
);
|
|
}
|
|
string() {
|
|
return this.decodeUtf8(this.bytes());
|
|
}
|
|
}
|
|
function ts(e) {
|
|
if ("string" == typeof e) e = Number(e);
|
|
else if ("number" != typeof e) throw Error("invalid int32: " + typeof e);
|
|
if (!Number.isInteger(e) || e > 0x7fffffff || e < -0x80000000)
|
|
throw Error("invalid int32: " + e);
|
|
}
|
|
function ti(e) {
|
|
if ("string" == typeof e) e = Number(e);
|
|
else if ("number" != typeof e) throw Error("invalid uint32: " + typeof e);
|
|
if (!Number.isInteger(e) || e > 0xffffffff || e < 0)
|
|
throw Error("invalid uint32: " + e);
|
|
}
|
|
let ta =
|
|
(((r = {})[(r.NULL_VALUE = 0)] = "NULL_VALUE"),
|
|
(r[(r.UNRECOGNIZED = -1)] = "UNRECOGNIZED"),
|
|
r);
|
|
function to() {
|
|
return { fields: {} };
|
|
}
|
|
let tl = {
|
|
encode: (e, t = new tn()) => (
|
|
Object.entries(e.fields).forEach(([e, n]) => {
|
|
void 0 !== n &&
|
|
td.encode({ key: e, value: n }, t.uint32(10).fork()).join();
|
|
}),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = to();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1: {
|
|
if (10 !== e) break;
|
|
let t = td.decode(n, n.uint32());
|
|
void 0 !== t.value && (s.fields[t.key] = t.value);
|
|
continue;
|
|
}
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tl.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = to();
|
|
return (
|
|
(t.fields = Object.entries(e.fields ?? {}).reduce(
|
|
(e, [t, n]) => (void 0 !== n && (e[t] = n), e),
|
|
{},
|
|
)),
|
|
t
|
|
);
|
|
},
|
|
wrap(e) {
|
|
let t = to();
|
|
if (void 0 !== e) for (let n of Object.keys(e)) t.fields[n] = e[n];
|
|
return t;
|
|
},
|
|
unwrap(e) {
|
|
let t = {};
|
|
if (e.fields) for (let n of Object.keys(e.fields)) t[n] = e.fields[n];
|
|
return t;
|
|
},
|
|
};
|
|
function tu() {
|
|
return { key: "", value: void 0 };
|
|
}
|
|
let td = {
|
|
encode: (e, t = new tn()) => (
|
|
"" !== e.key && t.uint32(10).string(e.key),
|
|
void 0 !== e.value &&
|
|
tp.encode(tp.wrap(e.value), t.uint32(18).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tu();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.key = n.string();
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.value = tp.unwrap(tp.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => td.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tu();
|
|
return (t.key = e.key ?? ""), (t.value = e.value ?? void 0), t;
|
|
},
|
|
};
|
|
function tc() {
|
|
return {
|
|
nullValue: void 0,
|
|
numberValue: void 0,
|
|
stringValue: void 0,
|
|
boolValue: void 0,
|
|
structValue: void 0,
|
|
listValue: void 0,
|
|
};
|
|
}
|
|
let tp = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.nullValue && t.uint32(8).int32(e.nullValue),
|
|
void 0 !== e.numberValue && t.uint32(17).double(e.numberValue),
|
|
void 0 !== e.stringValue && t.uint32(26).string(e.stringValue),
|
|
void 0 !== e.boolValue && t.uint32(32).bool(e.boolValue),
|
|
void 0 !== e.structValue &&
|
|
tl.encode(tl.wrap(e.structValue), t.uint32(42).fork()).join(),
|
|
void 0 !== e.listValue &&
|
|
tf.encode(tf.wrap(e.listValue), t.uint32(50).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tc();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (8 !== e) break;
|
|
s.nullValue = n.int32();
|
|
continue;
|
|
case 2:
|
|
if (17 !== e) break;
|
|
s.numberValue = n.double();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.stringValue = n.string();
|
|
continue;
|
|
case 4:
|
|
if (32 !== e) break;
|
|
s.boolValue = n.bool();
|
|
continue;
|
|
case 5:
|
|
if (42 !== e) break;
|
|
s.structValue = tl.unwrap(tl.decode(n, n.uint32()));
|
|
continue;
|
|
case 6:
|
|
if (50 !== e) break;
|
|
s.listValue = tf.unwrap(tf.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tp.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tc();
|
|
return (
|
|
(t.nullValue = e.nullValue ?? void 0),
|
|
(t.numberValue = e.numberValue ?? void 0),
|
|
(t.stringValue = e.stringValue ?? void 0),
|
|
(t.boolValue = e.boolValue ?? void 0),
|
|
(t.structValue = e.structValue ?? void 0),
|
|
(t.listValue = e.listValue ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
wrap(e) {
|
|
let t = tc();
|
|
if (null === e) t.nullValue = ta.NULL_VALUE;
|
|
else if ("boolean" == typeof e) t.boolValue = e;
|
|
else if ("number" == typeof e) t.numberValue = e;
|
|
else if ("string" == typeof e) t.stringValue = e;
|
|
else if (globalThis.Array.isArray(e)) t.listValue = e;
|
|
else if ("object" == typeof e) t.structValue = e;
|
|
else if (void 0 !== e)
|
|
throw new globalThis.Error("Unsupported any value type: " + typeof e);
|
|
return t;
|
|
},
|
|
unwrap(e) {
|
|
if (void 0 !== e.stringValue) return e.stringValue;
|
|
if (e?.numberValue !== void 0) return e.numberValue;
|
|
if (e?.boolValue !== void 0) return e.boolValue;
|
|
if (e?.structValue !== void 0) return e.structValue;
|
|
if (e?.listValue !== void 0) return e.listValue;
|
|
else if (e?.nullValue !== void 0) return null;
|
|
},
|
|
};
|
|
function th() {
|
|
return { values: [] };
|
|
}
|
|
let tf = {
|
|
encode(e, t = new tn()) {
|
|
for (let n of e.values)
|
|
tp.encode(tp.wrap(n), t.uint32(10).fork()).join();
|
|
return t;
|
|
},
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = th();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.values.push(tp.unwrap(tp.decode(n, n.uint32())));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tf.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = th();
|
|
return (t.values = e.values?.map((e) => e) || []), t;
|
|
},
|
|
wrap(e) {
|
|
let t = th();
|
|
return (t.values = e ?? []), t;
|
|
},
|
|
unwrap: (e) =>
|
|
e?.hasOwnProperty("values") && globalThis.Array.isArray(e.values)
|
|
? e.values
|
|
: e,
|
|
},
|
|
tg =
|
|
(((s = {})[(s.ADD = 0)] = "ADD"),
|
|
(s[(s.REMOVE = 1)] = "REMOVE"),
|
|
(s[(s.REPLACE = 2)] = "REPLACE"),
|
|
(s[(s.MOVE = 3)] = "MOVE"),
|
|
(s[(s.COPY = 4)] = "COPY"),
|
|
(s[(s.TEST = 5)] = "TEST"),
|
|
(s[(s.UNRECOGNIZED = -1)] = "UNRECOGNIZED"),
|
|
s);
|
|
function tm() {
|
|
return { op: 0, path: "", from: void 0, value: void 0 };
|
|
}
|
|
let tv = {
|
|
encode: (e, t = new tn()) => (
|
|
0 !== e.op && t.uint32(8).int32(e.op),
|
|
"" !== e.path && t.uint32(18).string(e.path),
|
|
void 0 !== e.from && t.uint32(26).string(e.from),
|
|
void 0 !== e.value &&
|
|
tp.encode(tp.wrap(e.value), t.uint32(34).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tm();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (8 !== e) break;
|
|
s.op = n.int32();
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.path = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.from = n.string();
|
|
continue;
|
|
case 4:
|
|
if (34 !== e) break;
|
|
s.value = tp.unwrap(tp.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tv.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tm();
|
|
return (
|
|
(t.op = e.op ?? 0),
|
|
(t.path = e.path ?? ""),
|
|
(t.from = e.from ?? void 0),
|
|
(t.value = e.value ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function ty() {
|
|
return { id: "", type: "", function: void 0 };
|
|
}
|
|
let t_ = {
|
|
encode: (e, t = new tn()) => (
|
|
"" !== e.id && t.uint32(10).string(e.id),
|
|
"" !== e.type && t.uint32(18).string(e.type),
|
|
void 0 !== e.function &&
|
|
tb.encode(e.function, t.uint32(26).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = ty();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.id = n.string();
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.type = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.function = tb.decode(n, n.uint32());
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => t_.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = ty();
|
|
return (
|
|
(t.id = e.id ?? ""),
|
|
(t.type = e.type ?? ""),
|
|
(t.function =
|
|
void 0 !== e.function && null !== e.function
|
|
? tb.fromPartial(e.function)
|
|
: void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tE() {
|
|
return { name: "", arguments: "" };
|
|
}
|
|
let tb = {
|
|
encode: (e, t = new tn()) => (
|
|
"" !== e.name && t.uint32(10).string(e.name),
|
|
"" !== e.arguments && t.uint32(18).string(e.arguments),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tE();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.name = n.string();
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.arguments = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tb.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tE();
|
|
return (t.name = e.name ?? ""), (t.arguments = e.arguments ?? ""), t;
|
|
},
|
|
};
|
|
function tT() {
|
|
return {
|
|
id: "",
|
|
role: "",
|
|
content: void 0,
|
|
name: void 0,
|
|
toolCalls: [],
|
|
toolCallId: void 0,
|
|
error: void 0,
|
|
};
|
|
}
|
|
let tS = {
|
|
encode(e, t = new tn()) {
|
|
for (let n of ("" !== e.id && t.uint32(10).string(e.id),
|
|
"" !== e.role && t.uint32(18).string(e.role),
|
|
void 0 !== e.content && t.uint32(26).string(e.content),
|
|
void 0 !== e.name && t.uint32(34).string(e.name),
|
|
e.toolCalls))
|
|
t_.encode(n, t.uint32(42).fork()).join();
|
|
return (
|
|
void 0 !== e.toolCallId && t.uint32(50).string(e.toolCallId),
|
|
void 0 !== e.error && t.uint32(58).string(e.error),
|
|
t
|
|
);
|
|
},
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tT();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.id = n.string();
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.role = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.content = n.string();
|
|
continue;
|
|
case 4:
|
|
if (34 !== e) break;
|
|
s.name = n.string();
|
|
continue;
|
|
case 5:
|
|
if (42 !== e) break;
|
|
s.toolCalls.push(t_.decode(n, n.uint32()));
|
|
continue;
|
|
case 6:
|
|
if (50 !== e) break;
|
|
s.toolCallId = n.string();
|
|
continue;
|
|
case 7:
|
|
if (58 !== e) break;
|
|
s.error = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tS.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tT();
|
|
return (
|
|
(t.id = e.id ?? ""),
|
|
(t.role = e.role ?? ""),
|
|
(t.content = e.content ?? void 0),
|
|
(t.name = e.name ?? void 0),
|
|
(t.toolCalls = e.toolCalls?.map((e) => t_.fromPartial(e)) || []),
|
|
(t.toolCallId = e.toolCallId ?? void 0),
|
|
(t.error = e.error ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
},
|
|
tA =
|
|
(((i = {})[(i.TEXT_MESSAGE_START = 0)] = "TEXT_MESSAGE_START"),
|
|
(i[(i.TEXT_MESSAGE_CONTENT = 1)] = "TEXT_MESSAGE_CONTENT"),
|
|
(i[(i.TEXT_MESSAGE_END = 2)] = "TEXT_MESSAGE_END"),
|
|
(i[(i.TOOL_CALL_START = 3)] = "TOOL_CALL_START"),
|
|
(i[(i.TOOL_CALL_ARGS = 4)] = "TOOL_CALL_ARGS"),
|
|
(i[(i.TOOL_CALL_END = 5)] = "TOOL_CALL_END"),
|
|
(i[(i.STATE_SNAPSHOT = 6)] = "STATE_SNAPSHOT"),
|
|
(i[(i.STATE_DELTA = 7)] = "STATE_DELTA"),
|
|
(i[(i.MESSAGES_SNAPSHOT = 8)] = "MESSAGES_SNAPSHOT"),
|
|
(i[(i.RAW = 9)] = "RAW"),
|
|
(i[(i.CUSTOM = 10)] = "CUSTOM"),
|
|
(i[(i.RUN_STARTED = 11)] = "RUN_STARTED"),
|
|
(i[(i.RUN_FINISHED = 12)] = "RUN_FINISHED"),
|
|
(i[(i.RUN_ERROR = 13)] = "RUN_ERROR"),
|
|
(i[(i.STEP_STARTED = 14)] = "STEP_STARTED"),
|
|
(i[(i.STEP_FINISHED = 15)] = "STEP_FINISHED"),
|
|
(i[(i.UNRECOGNIZED = -1)] = "UNRECOGNIZED"),
|
|
i);
|
|
function tN() {
|
|
return { type: 0, timestamp: void 0, rawEvent: void 0 };
|
|
}
|
|
let tI = {
|
|
encode: (e, t = new tn()) => (
|
|
0 !== e.type && t.uint32(8).int32(e.type),
|
|
void 0 !== e.timestamp && t.uint32(16).int64(e.timestamp),
|
|
void 0 !== e.rawEvent &&
|
|
tp.encode(tp.wrap(e.rawEvent), t.uint32(26).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tN();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (8 !== e) break;
|
|
s.type = n.int32();
|
|
continue;
|
|
case 2:
|
|
if (16 !== e) break;
|
|
s.timestamp = (function (e) {
|
|
let t = globalThis.Number(e.toString());
|
|
if (t > globalThis.Number.MAX_SAFE_INTEGER)
|
|
throw new globalThis.Error(
|
|
"Value is larger than Number.MAX_SAFE_INTEGER",
|
|
);
|
|
if (t < globalThis.Number.MIN_SAFE_INTEGER)
|
|
throw new globalThis.Error(
|
|
"Value is smaller than Number.MIN_SAFE_INTEGER",
|
|
);
|
|
return t;
|
|
})(n.int64());
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.rawEvent = tp.unwrap(tp.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tI.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tN();
|
|
return (
|
|
(t.type = e.type ?? 0),
|
|
(t.timestamp = e.timestamp ?? void 0),
|
|
(t.rawEvent = e.rawEvent ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tw() {
|
|
return { baseEvent: void 0, messageId: "", role: void 0 };
|
|
}
|
|
let tO = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.messageId && t.uint32(18).string(e.messageId),
|
|
void 0 !== e.role && t.uint32(26).string(e.role),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tw();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.messageId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.role = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tO.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tw();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.messageId = e.messageId ?? ""),
|
|
(t.role = e.role ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tC() {
|
|
return { baseEvent: void 0, messageId: "", delta: "" };
|
|
}
|
|
let tR = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.messageId && t.uint32(18).string(e.messageId),
|
|
"" !== e.delta && t.uint32(26).string(e.delta),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tC();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.messageId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.delta = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tR.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tC();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.messageId = e.messageId ?? ""),
|
|
(t.delta = e.delta ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tk() {
|
|
return { baseEvent: void 0, messageId: "" };
|
|
}
|
|
let tx = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.messageId && t.uint32(18).string(e.messageId),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tk();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.messageId = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tx.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tk();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.messageId = e.messageId ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tP() {
|
|
return {
|
|
baseEvent: void 0,
|
|
toolCallId: "",
|
|
toolCallName: "",
|
|
parentMessageId: void 0,
|
|
};
|
|
}
|
|
let tM = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.toolCallId && t.uint32(18).string(e.toolCallId),
|
|
"" !== e.toolCallName && t.uint32(26).string(e.toolCallName),
|
|
void 0 !== e.parentMessageId && t.uint32(34).string(e.parentMessageId),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tP();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.toolCallId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.toolCallName = n.string();
|
|
continue;
|
|
case 4:
|
|
if (34 !== e) break;
|
|
s.parentMessageId = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tM.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tP();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.toolCallId = e.toolCallId ?? ""),
|
|
(t.toolCallName = e.toolCallName ?? ""),
|
|
(t.parentMessageId = e.parentMessageId ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tL() {
|
|
return { baseEvent: void 0, toolCallId: "", delta: "" };
|
|
}
|
|
let tD = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.toolCallId && t.uint32(18).string(e.toolCallId),
|
|
"" !== e.delta && t.uint32(26).string(e.delta),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tL();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.toolCallId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.delta = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tD.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tL();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.toolCallId = e.toolCallId ?? ""),
|
|
(t.delta = e.delta ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tj() {
|
|
return { baseEvent: void 0, toolCallId: "" };
|
|
}
|
|
let tZ = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.toolCallId && t.uint32(18).string(e.toolCallId),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tj();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.toolCallId = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tZ.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tj();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.toolCallId = e.toolCallId ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tU() {
|
|
return { baseEvent: void 0, snapshot: void 0 };
|
|
}
|
|
let tG = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
void 0 !== e.snapshot &&
|
|
tp.encode(tp.wrap(e.snapshot), t.uint32(18).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tU();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.snapshot = tp.unwrap(tp.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tG.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tU();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.snapshot = e.snapshot ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tF() {
|
|
return { baseEvent: void 0, delta: [] };
|
|
}
|
|
let t$ = {
|
|
encode(e, t = new tn()) {
|
|
for (let n of (void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
e.delta))
|
|
tv.encode(n, t.uint32(18).fork()).join();
|
|
return t;
|
|
},
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tF();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.delta.push(tv.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => t$.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tF();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.delta = e.delta?.map((e) => tv.fromPartial(e)) || []),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tV() {
|
|
return { baseEvent: void 0, messages: [] };
|
|
}
|
|
let tz = {
|
|
encode(e, t = new tn()) {
|
|
for (let n of (void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
e.messages))
|
|
tS.encode(n, t.uint32(18).fork()).join();
|
|
return t;
|
|
},
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tV();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.messages.push(tS.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tz.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tV();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.messages = e.messages?.map((e) => tS.fromPartial(e)) || []),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tH() {
|
|
return { baseEvent: void 0, event: void 0, source: void 0 };
|
|
}
|
|
let tK = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
void 0 !== e.event &&
|
|
tp.encode(tp.wrap(e.event), t.uint32(18).fork()).join(),
|
|
void 0 !== e.source && t.uint32(26).string(e.source),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tH();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.event = tp.unwrap(tp.decode(n, n.uint32()));
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.source = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tK.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tH();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.event = e.event ?? void 0),
|
|
(t.source = e.source ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tB() {
|
|
return { baseEvent: void 0, name: "", value: void 0 };
|
|
}
|
|
let tJ = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.name && t.uint32(18).string(e.name),
|
|
void 0 !== e.value &&
|
|
tp.encode(tp.wrap(e.value), t.uint32(26).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tB();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.name = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.value = tp.unwrap(tp.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tJ.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tB();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.name = e.name ?? ""),
|
|
(t.value = e.value ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tX() {
|
|
return { baseEvent: void 0, threadId: "", runId: "" };
|
|
}
|
|
let tW = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.threadId && t.uint32(18).string(e.threadId),
|
|
"" !== e.runId && t.uint32(26).string(e.runId),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tX();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.threadId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.runId = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tW.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tX();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.threadId = e.threadId ?? ""),
|
|
(t.runId = e.runId ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tY() {
|
|
return { baseEvent: void 0, threadId: "", runId: "", result: void 0 };
|
|
}
|
|
let tq = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.threadId && t.uint32(18).string(e.threadId),
|
|
"" !== e.runId && t.uint32(26).string(e.runId),
|
|
void 0 !== e.result &&
|
|
tp.encode(tp.wrap(e.result), t.uint32(34).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tY();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.threadId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.runId = n.string();
|
|
continue;
|
|
case 4:
|
|
if (34 !== e) break;
|
|
s.result = tp.unwrap(tp.decode(n, n.uint32()));
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => tq.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tY();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.threadId = e.threadId ?? ""),
|
|
(t.runId = e.runId ?? ""),
|
|
(t.result = e.result ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function tQ() {
|
|
return { baseEvent: void 0, code: void 0, message: "" };
|
|
}
|
|
let t0 = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
void 0 !== e.code && t.uint32(18).string(e.code),
|
|
"" !== e.message && t.uint32(26).string(e.message),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = tQ();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.code = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.message = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => t0.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = tQ();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.code = e.code ?? void 0),
|
|
(t.message = e.message ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function t1() {
|
|
return { baseEvent: void 0, stepName: "" };
|
|
}
|
|
let t2 = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.stepName && t.uint32(18).string(e.stepName),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = t1();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.stepName = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => t2.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = t1();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.stepName = e.stepName ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function t3() {
|
|
return { baseEvent: void 0, stepName: "" };
|
|
}
|
|
let t4 = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
"" !== e.stepName && t.uint32(18).string(e.stepName),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = t3();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.stepName = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => t4.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = t3();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.stepName = e.stepName ?? ""),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function t9() {
|
|
return {
|
|
baseEvent: void 0,
|
|
messageId: void 0,
|
|
role: void 0,
|
|
delta: void 0,
|
|
};
|
|
}
|
|
let t8 = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
void 0 !== e.messageId && t.uint32(18).string(e.messageId),
|
|
void 0 !== e.role && t.uint32(26).string(e.role),
|
|
void 0 !== e.delta && t.uint32(34).string(e.delta),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = t9();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.messageId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.role = n.string();
|
|
continue;
|
|
case 4:
|
|
if (34 !== e) break;
|
|
s.delta = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => t8.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = t9();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.messageId = e.messageId ?? void 0),
|
|
(t.role = e.role ?? void 0),
|
|
(t.delta = e.delta ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function t6() {
|
|
return {
|
|
baseEvent: void 0,
|
|
toolCallId: void 0,
|
|
toolCallName: void 0,
|
|
parentMessageId: void 0,
|
|
delta: void 0,
|
|
};
|
|
}
|
|
let t7 = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.baseEvent &&
|
|
tI.encode(e.baseEvent, t.uint32(10).fork()).join(),
|
|
void 0 !== e.toolCallId && t.uint32(18).string(e.toolCallId),
|
|
void 0 !== e.toolCallName && t.uint32(26).string(e.toolCallName),
|
|
void 0 !== e.parentMessageId && t.uint32(34).string(e.parentMessageId),
|
|
void 0 !== e.delta && t.uint32(42).string(e.delta),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = t6();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.baseEvent = tI.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.toolCallId = n.string();
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.toolCallName = n.string();
|
|
continue;
|
|
case 4:
|
|
if (34 !== e) break;
|
|
s.parentMessageId = n.string();
|
|
continue;
|
|
case 5:
|
|
if (42 !== e) break;
|
|
s.delta = n.string();
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => t7.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = t6();
|
|
return (
|
|
(t.baseEvent =
|
|
void 0 !== e.baseEvent && null !== e.baseEvent
|
|
? tI.fromPartial(e.baseEvent)
|
|
: void 0),
|
|
(t.toolCallId = e.toolCallId ?? void 0),
|
|
(t.toolCallName = e.toolCallName ?? void 0),
|
|
(t.parentMessageId = e.parentMessageId ?? void 0),
|
|
(t.delta = e.delta ?? void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
function t5() {
|
|
return {
|
|
textMessageStart: void 0,
|
|
textMessageContent: void 0,
|
|
textMessageEnd: void 0,
|
|
toolCallStart: void 0,
|
|
toolCallArgs: void 0,
|
|
toolCallEnd: void 0,
|
|
stateSnapshot: void 0,
|
|
stateDelta: void 0,
|
|
messagesSnapshot: void 0,
|
|
raw: void 0,
|
|
custom: void 0,
|
|
runStarted: void 0,
|
|
runFinished: void 0,
|
|
runError: void 0,
|
|
stepStarted: void 0,
|
|
stepFinished: void 0,
|
|
textMessageChunk: void 0,
|
|
toolCallChunk: void 0,
|
|
};
|
|
}
|
|
let ne = {
|
|
encode: (e, t = new tn()) => (
|
|
void 0 !== e.textMessageStart &&
|
|
tO.encode(e.textMessageStart, t.uint32(10).fork()).join(),
|
|
void 0 !== e.textMessageContent &&
|
|
tR.encode(e.textMessageContent, t.uint32(18).fork()).join(),
|
|
void 0 !== e.textMessageEnd &&
|
|
tx.encode(e.textMessageEnd, t.uint32(26).fork()).join(),
|
|
void 0 !== e.toolCallStart &&
|
|
tM.encode(e.toolCallStart, t.uint32(34).fork()).join(),
|
|
void 0 !== e.toolCallArgs &&
|
|
tD.encode(e.toolCallArgs, t.uint32(42).fork()).join(),
|
|
void 0 !== e.toolCallEnd &&
|
|
tZ.encode(e.toolCallEnd, t.uint32(50).fork()).join(),
|
|
void 0 !== e.stateSnapshot &&
|
|
tG.encode(e.stateSnapshot, t.uint32(58).fork()).join(),
|
|
void 0 !== e.stateDelta &&
|
|
t$.encode(e.stateDelta, t.uint32(66).fork()).join(),
|
|
void 0 !== e.messagesSnapshot &&
|
|
tz.encode(e.messagesSnapshot, t.uint32(74).fork()).join(),
|
|
void 0 !== e.raw && tK.encode(e.raw, t.uint32(82).fork()).join(),
|
|
void 0 !== e.custom && tJ.encode(e.custom, t.uint32(90).fork()).join(),
|
|
void 0 !== e.runStarted &&
|
|
tW.encode(e.runStarted, t.uint32(98).fork()).join(),
|
|
void 0 !== e.runFinished &&
|
|
tq.encode(e.runFinished, t.uint32(106).fork()).join(),
|
|
void 0 !== e.runError &&
|
|
t0.encode(e.runError, t.uint32(114).fork()).join(),
|
|
void 0 !== e.stepStarted &&
|
|
t2.encode(e.stepStarted, t.uint32(122).fork()).join(),
|
|
void 0 !== e.stepFinished &&
|
|
t4.encode(e.stepFinished, t.uint32(130).fork()).join(),
|
|
void 0 !== e.textMessageChunk &&
|
|
t8.encode(e.textMessageChunk, t.uint32(138).fork()).join(),
|
|
void 0 !== e.toolCallChunk &&
|
|
t7.encode(e.toolCallChunk, t.uint32(146).fork()).join(),
|
|
t
|
|
),
|
|
decode(e, t) {
|
|
let n = e instanceof tr ? e : new tr(e),
|
|
r = void 0 === t ? n.len : n.pos + t,
|
|
s = t5();
|
|
for (; n.pos < r; ) {
|
|
let e = n.uint32();
|
|
switch (e >>> 3) {
|
|
case 1:
|
|
if (10 !== e) break;
|
|
s.textMessageStart = tO.decode(n, n.uint32());
|
|
continue;
|
|
case 2:
|
|
if (18 !== e) break;
|
|
s.textMessageContent = tR.decode(n, n.uint32());
|
|
continue;
|
|
case 3:
|
|
if (26 !== e) break;
|
|
s.textMessageEnd = tx.decode(n, n.uint32());
|
|
continue;
|
|
case 4:
|
|
if (34 !== e) break;
|
|
s.toolCallStart = tM.decode(n, n.uint32());
|
|
continue;
|
|
case 5:
|
|
if (42 !== e) break;
|
|
s.toolCallArgs = tD.decode(n, n.uint32());
|
|
continue;
|
|
case 6:
|
|
if (50 !== e) break;
|
|
s.toolCallEnd = tZ.decode(n, n.uint32());
|
|
continue;
|
|
case 7:
|
|
if (58 !== e) break;
|
|
s.stateSnapshot = tG.decode(n, n.uint32());
|
|
continue;
|
|
case 8:
|
|
if (66 !== e) break;
|
|
s.stateDelta = t$.decode(n, n.uint32());
|
|
continue;
|
|
case 9:
|
|
if (74 !== e) break;
|
|
s.messagesSnapshot = tz.decode(n, n.uint32());
|
|
continue;
|
|
case 10:
|
|
if (82 !== e) break;
|
|
s.raw = tK.decode(n, n.uint32());
|
|
continue;
|
|
case 11:
|
|
if (90 !== e) break;
|
|
s.custom = tJ.decode(n, n.uint32());
|
|
continue;
|
|
case 12:
|
|
if (98 !== e) break;
|
|
s.runStarted = tW.decode(n, n.uint32());
|
|
continue;
|
|
case 13:
|
|
if (106 !== e) break;
|
|
s.runFinished = tq.decode(n, n.uint32());
|
|
continue;
|
|
case 14:
|
|
if (114 !== e) break;
|
|
s.runError = t0.decode(n, n.uint32());
|
|
continue;
|
|
case 15:
|
|
if (122 !== e) break;
|
|
s.stepStarted = t2.decode(n, n.uint32());
|
|
continue;
|
|
case 16:
|
|
if (130 !== e) break;
|
|
s.stepFinished = t4.decode(n, n.uint32());
|
|
continue;
|
|
case 17:
|
|
if (138 !== e) break;
|
|
s.textMessageChunk = t8.decode(n, n.uint32());
|
|
continue;
|
|
case 18:
|
|
if (146 !== e) break;
|
|
s.toolCallChunk = t7.decode(n, n.uint32());
|
|
continue;
|
|
}
|
|
if ((7 & e) == 4 || 0 === e) break;
|
|
n.skip(7 & e);
|
|
}
|
|
return s;
|
|
},
|
|
create: (e) => ne.fromPartial(e ?? {}),
|
|
fromPartial(e) {
|
|
let t = t5();
|
|
return (
|
|
(t.textMessageStart =
|
|
void 0 !== e.textMessageStart && null !== e.textMessageStart
|
|
? tO.fromPartial(e.textMessageStart)
|
|
: void 0),
|
|
(t.textMessageContent =
|
|
void 0 !== e.textMessageContent && null !== e.textMessageContent
|
|
? tR.fromPartial(e.textMessageContent)
|
|
: void 0),
|
|
(t.textMessageEnd =
|
|
void 0 !== e.textMessageEnd && null !== e.textMessageEnd
|
|
? tx.fromPartial(e.textMessageEnd)
|
|
: void 0),
|
|
(t.toolCallStart =
|
|
void 0 !== e.toolCallStart && null !== e.toolCallStart
|
|
? tM.fromPartial(e.toolCallStart)
|
|
: void 0),
|
|
(t.toolCallArgs =
|
|
void 0 !== e.toolCallArgs && null !== e.toolCallArgs
|
|
? tD.fromPartial(e.toolCallArgs)
|
|
: void 0),
|
|
(t.toolCallEnd =
|
|
void 0 !== e.toolCallEnd && null !== e.toolCallEnd
|
|
? tZ.fromPartial(e.toolCallEnd)
|
|
: void 0),
|
|
(t.stateSnapshot =
|
|
void 0 !== e.stateSnapshot && null !== e.stateSnapshot
|
|
? tG.fromPartial(e.stateSnapshot)
|
|
: void 0),
|
|
(t.stateDelta =
|
|
void 0 !== e.stateDelta && null !== e.stateDelta
|
|
? t$.fromPartial(e.stateDelta)
|
|
: void 0),
|
|
(t.messagesSnapshot =
|
|
void 0 !== e.messagesSnapshot && null !== e.messagesSnapshot
|
|
? tz.fromPartial(e.messagesSnapshot)
|
|
: void 0),
|
|
(t.raw =
|
|
void 0 !== e.raw && null !== e.raw
|
|
? tK.fromPartial(e.raw)
|
|
: void 0),
|
|
(t.custom =
|
|
void 0 !== e.custom && null !== e.custom
|
|
? tJ.fromPartial(e.custom)
|
|
: void 0),
|
|
(t.runStarted =
|
|
void 0 !== e.runStarted && null !== e.runStarted
|
|
? tW.fromPartial(e.runStarted)
|
|
: void 0),
|
|
(t.runFinished =
|
|
void 0 !== e.runFinished && null !== e.runFinished
|
|
? tq.fromPartial(e.runFinished)
|
|
: void 0),
|
|
(t.runError =
|
|
void 0 !== e.runError && null !== e.runError
|
|
? t0.fromPartial(e.runError)
|
|
: void 0),
|
|
(t.stepStarted =
|
|
void 0 !== e.stepStarted && null !== e.stepStarted
|
|
? t2.fromPartial(e.stepStarted)
|
|
: void 0),
|
|
(t.stepFinished =
|
|
void 0 !== e.stepFinished && null !== e.stepFinished
|
|
? t4.fromPartial(e.stepFinished)
|
|
: void 0),
|
|
(t.textMessageChunk =
|
|
void 0 !== e.textMessageChunk && null !== e.textMessageChunk
|
|
? t8.fromPartial(e.textMessageChunk)
|
|
: void 0),
|
|
(t.toolCallChunk =
|
|
void 0 !== e.toolCallChunk && null !== e.toolCallChunk
|
|
? t7.fromPartial(e.toolCallChunk)
|
|
: void 0),
|
|
t
|
|
);
|
|
},
|
|
};
|
|
var nt = e.i(832356);
|
|
let nn =
|
|
/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,
|
|
nr = (e) => {
|
|
if ("string" != typeof e)
|
|
throw TypeError("Invalid argument expected string");
|
|
let t = e.match(nn);
|
|
if (!t)
|
|
throw Error(`Invalid argument not valid semver ('${e}' received)`);
|
|
return t.shift(), t;
|
|
},
|
|
ns = (e) => "*" === e || "x" === e || "X" === e,
|
|
ni = (e) => {
|
|
let t = parseInt(e, 10);
|
|
return isNaN(t) ? e : t;
|
|
},
|
|
na = (e, t) => {
|
|
let n, r;
|
|
if (ns(e) || ns(t)) return 0;
|
|
let [s, i] =
|
|
typeof (n = ni(e)) != typeof (r = ni(t))
|
|
? [String(n), String(r)]
|
|
: [n, r];
|
|
return s > i ? 1 : s < i ? -1 : 0;
|
|
},
|
|
no = (e, t) => {
|
|
for (let n = 0; n < Math.max(e.length, t.length); n++) {
|
|
let r = na(e[n] || "0", t[n] || "0");
|
|
if (0 !== r) return r;
|
|
}
|
|
return 0;
|
|
},
|
|
nl = (e, t) => {
|
|
let n = nr(e),
|
|
r = nr(t),
|
|
s = n.pop(),
|
|
i = r.pop(),
|
|
a = no(n, r);
|
|
return 0 !== a
|
|
? a
|
|
: s && i
|
|
? no(s.split("."), i.split("."))
|
|
: s || i
|
|
? s
|
|
? -1
|
|
: 1
|
|
: 0;
|
|
},
|
|
nu = (e) => {
|
|
if ("function" == typeof structuredClone) return structuredClone(e);
|
|
try {
|
|
return JSON.parse(JSON.stringify(e));
|
|
} catch {
|
|
return { ...e };
|
|
}
|
|
};
|
|
function nd() {
|
|
return (0, u.v4)();
|
|
}
|
|
async function nc(e, t, n, r) {
|
|
let s = t,
|
|
i = n,
|
|
a;
|
|
for (let t of e)
|
|
try {
|
|
let e = await r(t, nu(s), nu(i));
|
|
if (void 0 === e) continue;
|
|
if (
|
|
(void 0 !== e.messages && (s = e.messages),
|
|
void 0 !== e.state && (i = e.state),
|
|
(a = e.stopPropagation),
|
|
!0 === a)
|
|
)
|
|
break;
|
|
} catch (e) {
|
|
void 0 !== l.default.env.VITEST_WORKER_ID ||
|
|
console.error("Subscriber error:", e);
|
|
continue;
|
|
}
|
|
return {
|
|
...(JSON.stringify(s) === JSON.stringify(t) ? {} : { messages: s }),
|
|
...(JSON.stringify(i) === JSON.stringify(n) ? {} : { state: i }),
|
|
...(void 0 === a ? {} : { stopPropagation: a }),
|
|
};
|
|
}
|
|
let np = (e, t, n, r) => {
|
|
var s, i;
|
|
let a = nu(n.messages),
|
|
o = nu(e.state),
|
|
l = {},
|
|
u = (e) => {
|
|
void 0 !== e.messages &&
|
|
((a = e.messages), (l.messages = e.messages)),
|
|
void 0 !== e.state && ((o = e.state), (l.state = e.state));
|
|
},
|
|
c = () => {
|
|
let e = nu(l);
|
|
return (
|
|
(l = {}), void 0 !== e.messages || void 0 !== e.state ? ez(e) : eg
|
|
);
|
|
};
|
|
return t.pipe(
|
|
eB(async (t) => {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onEvent?.({
|
|
event: t,
|
|
agent: n,
|
|
input: e,
|
|
messages: s,
|
|
state: i,
|
|
}),
|
|
);
|
|
if ((u(s), !0 === s.stopPropagation)) return c();
|
|
switch (t.type) {
|
|
case d.EventType.TEXT_MESSAGE_START: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onTextMessageStartEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation)) {
|
|
let { messageId: e, role: n = "assistant" } = t;
|
|
a.find((t) => t.id === e) ||
|
|
(a.push({ id: e, role: n, content: "" }),
|
|
u({ messages: a }));
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.TEXT_MESSAGE_CONTENT: {
|
|
let { messageId: s, delta: i } = t,
|
|
l = a.find((e) => e.id === s);
|
|
if (!l)
|
|
return (
|
|
console.warn(
|
|
`TEXT_MESSAGE_CONTENT: No message found with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
let d = await nc(r, a, o, (r, s, i) =>
|
|
r.onTextMessageContentEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
textMessageBuffer:
|
|
"string" == typeof l.content ? l.content : "",
|
|
}),
|
|
);
|
|
return (
|
|
u(d),
|
|
!0 !== d.stopPropagation &&
|
|
((l.content = `${"string" == typeof l.content ? l.content : ""}${i}`),
|
|
u({ messages: a })),
|
|
c()
|
|
);
|
|
}
|
|
case d.EventType.TEXT_MESSAGE_END: {
|
|
let { messageId: s } = t,
|
|
i = a.find((e) => e.id === s);
|
|
return (
|
|
i
|
|
? (u(
|
|
await nc(r, a, o, (r, s, a) =>
|
|
r.onTextMessageEndEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: a,
|
|
agent: n,
|
|
input: e,
|
|
textMessageBuffer:
|
|
"string" == typeof i.content ? i.content : "",
|
|
}),
|
|
),
|
|
),
|
|
await Promise.all(
|
|
r.map((t) => {
|
|
t.onNewMessage?.({
|
|
message: i,
|
|
messages: a,
|
|
state: o,
|
|
agent: n,
|
|
input: e,
|
|
});
|
|
}),
|
|
))
|
|
: console.warn(
|
|
`TEXT_MESSAGE_END: No message found with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
}
|
|
case d.EventType.TOOL_CALL_START: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onToolCallStartEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation)) {
|
|
let {
|
|
toolCallId: e,
|
|
toolCallName: n,
|
|
parentMessageId: r,
|
|
} = t,
|
|
s;
|
|
r && a.length > 0 && a[a.length - 1].id === r
|
|
? (s = a[a.length - 1])
|
|
: ((s = { id: r || e, role: "assistant", toolCalls: [] }),
|
|
a.push(s)),
|
|
(s.toolCalls ??= []),
|
|
s.toolCalls.push({
|
|
id: e,
|
|
type: "function",
|
|
function: { name: n, arguments: "" },
|
|
}),
|
|
u({ messages: a });
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.TOOL_CALL_ARGS: {
|
|
let { toolCallId: s, delta: i } = t,
|
|
l = a.find((e) => e.toolCalls?.some((e) => e.id === s));
|
|
if (!l)
|
|
return (
|
|
console.warn(
|
|
`TOOL_CALL_ARGS: No message found containing tool call with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
let d = l.toolCalls?.find((e) => e.id === s);
|
|
if (!d)
|
|
return (
|
|
console.warn(
|
|
`TOOL_CALL_ARGS: No tool call found with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
let p = await nc(r, a, o, (r, s, i) => {
|
|
let a = d.function.arguments,
|
|
o = d.function.name,
|
|
l = {};
|
|
try {
|
|
l = eY(a);
|
|
} catch {}
|
|
return r.onToolCallArgsEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
toolCallBuffer: a,
|
|
toolCallName: o,
|
|
partialToolCallArgs: l,
|
|
});
|
|
});
|
|
return (
|
|
u(p),
|
|
!0 !== p.stopPropagation &&
|
|
((d.function.arguments += i), u({ messages: a })),
|
|
c()
|
|
);
|
|
}
|
|
case d.EventType.TOOL_CALL_END: {
|
|
let { toolCallId: s } = t,
|
|
i = a.find((e) => e.toolCalls?.some((e) => e.id === s));
|
|
if (!i)
|
|
return (
|
|
console.warn(
|
|
`TOOL_CALL_END: No message found containing tool call with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
let l = i.toolCalls?.find((e) => e.id === s);
|
|
return (
|
|
l
|
|
? (u(
|
|
await nc(r, a, o, (r, s, i) => {
|
|
let a = l.function.arguments,
|
|
o = l.function.name,
|
|
u = {};
|
|
try {
|
|
u = JSON.parse(a);
|
|
} catch {}
|
|
return r.onToolCallEndEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
toolCallName: o,
|
|
toolCallArgs: u,
|
|
});
|
|
}),
|
|
),
|
|
await Promise.all(
|
|
r.map((t) => {
|
|
t.onNewToolCall?.({
|
|
toolCall: l,
|
|
messages: a,
|
|
state: o,
|
|
agent: n,
|
|
input: e,
|
|
});
|
|
}),
|
|
))
|
|
: console.warn(
|
|
`TOOL_CALL_END: No tool call found with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
}
|
|
case d.EventType.TOOL_CALL_RESULT: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onToolCallResultEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation)) {
|
|
let { messageId: s, toolCallId: i, content: l, role: d } = t,
|
|
c = { id: s, toolCallId: i, role: d || "tool", content: l };
|
|
a.push(c),
|
|
await Promise.all(
|
|
r.map((t) => {
|
|
t.onNewMessage?.({
|
|
message: c,
|
|
messages: a,
|
|
state: o,
|
|
agent: n,
|
|
input: e,
|
|
});
|
|
}),
|
|
),
|
|
u({ messages: a });
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.STATE_SNAPSHOT: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onStateSnapshotEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation)) {
|
|
let { snapshot: e } = t;
|
|
u({ state: (o = e) });
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.STATE_DELTA: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onStateDeltaEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation)) {
|
|
let { delta: e } = t;
|
|
try {
|
|
(o = N(o, e, !0, !1).newDocument), u({ state: o });
|
|
} catch (n) {
|
|
let t = n instanceof Error ? n.message : String(n);
|
|
console.warn(`Failed to apply state patch:
|
|
Current state: ${JSON.stringify(o, null, 2)}
|
|
Patch operations: ${JSON.stringify(e, null, 2)}
|
|
Error: ${t}`);
|
|
}
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.MESSAGES_SNAPSHOT: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onMessagesSnapshotEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation)) {
|
|
let { messages: e } = t;
|
|
u({ messages: (a = e) });
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.ACTIVITY_SNAPSHOT: {
|
|
let s = a.findIndex((e) => e.id === t.messageId),
|
|
i = s >= 0 ? a[s] : void 0,
|
|
l = i?.role === "activity" ? i : void 0,
|
|
d = t.replace ?? !0,
|
|
p = await nc(r, a, o, (r, s, a) =>
|
|
r.onActivitySnapshotEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: a,
|
|
agent: n,
|
|
input: e,
|
|
activityMessage: l,
|
|
existingMessage: i,
|
|
}),
|
|
);
|
|
if ((u(p), !0 !== p.stopPropagation)) {
|
|
let i = {
|
|
id: t.messageId,
|
|
role: "activity",
|
|
activityType: t.activityType,
|
|
content: nu(t.content),
|
|
},
|
|
c;
|
|
-1 === s
|
|
? (a.push(i), (c = i))
|
|
: l
|
|
? d &&
|
|
(a[s] = {
|
|
...l,
|
|
activityType: t.activityType,
|
|
content: nu(t.content),
|
|
})
|
|
: d && ((a[s] = i), (c = i)),
|
|
u({ messages: a }),
|
|
c &&
|
|
(await Promise.all(
|
|
r.map((t) =>
|
|
t.onNewMessage?.({
|
|
message: c,
|
|
messages: a,
|
|
state: o,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
));
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.ACTIVITY_DELTA: {
|
|
let s = a.findIndex((e) => e.id === t.messageId);
|
|
if (-1 === s)
|
|
return (
|
|
console.warn(
|
|
`ACTIVITY_DELTA: No message found with ID '${t.messageId}' to apply patch`,
|
|
),
|
|
c()
|
|
);
|
|
let i = a[s];
|
|
if ("activity" !== i.role)
|
|
return (
|
|
console.warn(
|
|
`ACTIVITY_DELTA: Message '${t.messageId}' is not an activity message`,
|
|
),
|
|
c()
|
|
);
|
|
let l = await nc(r, a, o, (r, s, a) =>
|
|
r.onActivityDeltaEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: a,
|
|
agent: n,
|
|
input: e,
|
|
activityMessage: i,
|
|
}),
|
|
);
|
|
if ((u(l), !0 !== l.stopPropagation))
|
|
try {
|
|
let e = nu(i.content ?? {}),
|
|
n = N(e, t.patch ?? [], !0, !1).newDocument;
|
|
(a[s] = {
|
|
...i,
|
|
content: nu(n),
|
|
activityType: t.activityType,
|
|
}),
|
|
u({ messages: a });
|
|
} catch (n) {
|
|
let e = n instanceof Error ? n.message : String(n);
|
|
console.warn(
|
|
`Failed to apply activity patch for '${t.messageId}': ${e}`,
|
|
);
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.RAW:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onRawEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.CUSTOM:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onCustomEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.RUN_STARTED: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onRunStartedEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation && t.input?.messages)) {
|
|
for (let e of t.input.messages)
|
|
a.find((t) => t.id === e.id) || a.push(e);
|
|
u({ messages: a });
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.RUN_FINISHED:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onRunFinishedEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
result: t.result,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.RUN_ERROR:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onRunErrorEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.STEP_STARTED:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onStepStartedEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.STEP_FINISHED:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onStepFinishedEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.TEXT_MESSAGE_CHUNK:
|
|
throw Error(
|
|
"TEXT_MESSAGE_CHUNK must be tranformed before being applied",
|
|
);
|
|
case d.EventType.TOOL_CALL_CHUNK:
|
|
throw Error(
|
|
"TOOL_CALL_CHUNK must be tranformed before being applied",
|
|
);
|
|
case d.EventType.THINKING_START:
|
|
case d.EventType.THINKING_END:
|
|
case d.EventType.THINKING_TEXT_MESSAGE_START:
|
|
case d.EventType.THINKING_TEXT_MESSAGE_CONTENT:
|
|
case d.EventType.THINKING_TEXT_MESSAGE_END:
|
|
return c();
|
|
case d.EventType.REASONING_START:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onReasoningStartEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.REASONING_MESSAGE_START: {
|
|
let s = await nc(r, a, o, (r, s, i) =>
|
|
r.onReasoningMessageStartEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(s), !0 !== s.stopPropagation)) {
|
|
let { messageId: e } = t;
|
|
a.find((t) => t.id === e) ||
|
|
(a.push({ id: e, role: "reasoning", content: "" }),
|
|
u({ messages: a }));
|
|
}
|
|
return c();
|
|
}
|
|
case d.EventType.REASONING_MESSAGE_CONTENT: {
|
|
let { messageId: s, delta: i } = t,
|
|
l = a.find((e) => e.id === s);
|
|
if (!l)
|
|
return (
|
|
console.warn(
|
|
`REASONING_MESSAGE_CONTENT: No message found with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
let d = await nc(r, a, o, (r, s, i) =>
|
|
r.onReasoningMessageContentEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
reasoningMessageBuffer:
|
|
"string" == typeof l.content ? l.content : "",
|
|
}),
|
|
);
|
|
return (
|
|
u(d),
|
|
!0 !== d.stopPropagation &&
|
|
((l.content = `${"string" == typeof l.content ? l.content : ""}${i}`),
|
|
u({ messages: a })),
|
|
c()
|
|
);
|
|
}
|
|
case d.EventType.REASONING_MESSAGE_END: {
|
|
let { messageId: s } = t,
|
|
i = a.find((e) => e.id === s);
|
|
return (
|
|
i
|
|
? (u(
|
|
await nc(r, a, o, (r, s, a) =>
|
|
r.onReasoningMessageEndEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: a,
|
|
agent: n,
|
|
input: e,
|
|
reasoningMessageBuffer:
|
|
"string" == typeof i.content ? i.content : "",
|
|
}),
|
|
),
|
|
),
|
|
await Promise.all(
|
|
r.map((t) => {
|
|
t.onNewMessage?.({
|
|
message: i,
|
|
messages: a,
|
|
state: o,
|
|
agent: n,
|
|
input: e,
|
|
});
|
|
}),
|
|
))
|
|
: console.warn(
|
|
`REASONING_MESSAGE_END: No message found with ID '${s}'`,
|
|
),
|
|
c()
|
|
);
|
|
}
|
|
case d.EventType.REASONING_MESSAGE_CHUNK:
|
|
throw Error(
|
|
"REASONING_MESSAGE_CHUNK must be transformed before being applied",
|
|
);
|
|
case d.EventType.REASONING_END:
|
|
return (
|
|
u(
|
|
await nc(r, a, o, (r, s, i) =>
|
|
r.onReasoningEndEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
),
|
|
),
|
|
c()
|
|
);
|
|
case d.EventType.REASONING_ENCRYPTED_VALUE: {
|
|
let { subtype: s, entityId: i, encryptedValue: d } = t,
|
|
p = await nc(r, a, o, (r, s, i) =>
|
|
r.onReasoningEncryptedValueEvent?.({
|
|
event: t,
|
|
messages: s,
|
|
state: i,
|
|
agent: n,
|
|
input: e,
|
|
}),
|
|
);
|
|
if ((u(p), !0 !== p.stopPropagation)) {
|
|
let e = !1;
|
|
if ("tool-call" === s) {
|
|
for (let t of a)
|
|
if ("assistant" === t.role && t.toolCalls) {
|
|
let n = t.toolCalls.find((e) => e.id === i);
|
|
if (n) {
|
|
(n.encryptedValue = d), (e = !0);
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
let t = a.find((e) => e.id === i);
|
|
t?.role !== "activity" &&
|
|
t &&
|
|
((t.encryptedValue = d), (e = !0));
|
|
}
|
|
e && (l.messages = a);
|
|
}
|
|
return c();
|
|
}
|
|
}
|
|
return t.type, c();
|
|
}),
|
|
(void 0 === s && (s = 1 / 0), eV(ed, s)),
|
|
r.length > 0
|
|
? ((i = {}),
|
|
ek(function (e, t) {
|
|
var n = !1;
|
|
e.subscribe(
|
|
eM(
|
|
t,
|
|
function (e) {
|
|
(n = !0), t.next(e);
|
|
},
|
|
function () {
|
|
n || t.next(i), t.complete();
|
|
},
|
|
),
|
|
);
|
|
}))
|
|
: (e) => e,
|
|
);
|
|
},
|
|
nh = (e) => (t) => {
|
|
let n = new Map(),
|
|
r = new Map(),
|
|
s = !1,
|
|
i = !1,
|
|
a = !1,
|
|
o = new Map(),
|
|
l = !1,
|
|
u = !1,
|
|
c = !1;
|
|
return t.pipe(
|
|
eV((t) => {
|
|
let p = t.type;
|
|
if ((e && console.debug("[VERIFY]:", JSON.stringify(t)), i))
|
|
return eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send event type '${p}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`,
|
|
),
|
|
);
|
|
if (
|
|
s &&
|
|
p !== d.EventType.RUN_ERROR &&
|
|
p !== d.EventType.RUN_STARTED
|
|
)
|
|
return eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send event type '${p}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`,
|
|
),
|
|
);
|
|
if (a) {
|
|
if (p === d.EventType.RUN_STARTED) {
|
|
if (c && !s)
|
|
return eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
"Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run.",
|
|
),
|
|
);
|
|
s &&
|
|
(n.clear(),
|
|
r.clear(),
|
|
o.clear(),
|
|
(l = !1),
|
|
(u = !1),
|
|
(s = !1),
|
|
(i = !1),
|
|
(c = !0));
|
|
}
|
|
} else if (
|
|
((a = !0),
|
|
p !== d.EventType.RUN_STARTED && p !== d.EventType.RUN_ERROR)
|
|
)
|
|
return eH(
|
|
() => new d.AGUIError("First event must be 'RUN_STARTED'"),
|
|
);
|
|
switch (p) {
|
|
case d.EventType.TEXT_MESSAGE_START: {
|
|
let e = t.messageId;
|
|
return n.has(e)
|
|
? eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${e}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`,
|
|
),
|
|
)
|
|
: (n.set(e, !0), ez(t));
|
|
}
|
|
case d.EventType.TEXT_MESSAGE_CONTENT: {
|
|
let e = t.messageId;
|
|
return n.has(e)
|
|
? ez(t)
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${e}'. Start a text message with 'TEXT_MESSAGE_START' first.`,
|
|
),
|
|
);
|
|
}
|
|
case d.EventType.TEXT_MESSAGE_END: {
|
|
let e = t.messageId;
|
|
return n.has(e)
|
|
? (n.delete(e), ez(t))
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${e}'. A 'TEXT_MESSAGE_START' event must be sent first.`,
|
|
),
|
|
);
|
|
}
|
|
case d.EventType.TOOL_CALL_START: {
|
|
let e = t.toolCallId;
|
|
return r.has(e)
|
|
? eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${e}' is already in progress. Complete it with 'TOOL_CALL_END' first.`,
|
|
),
|
|
)
|
|
: (r.set(e, !0), ez(t));
|
|
}
|
|
case d.EventType.TOOL_CALL_ARGS: {
|
|
let e = t.toolCallId;
|
|
return r.has(e)
|
|
? ez(t)
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${e}'. Start a tool call with 'TOOL_CALL_START' first.`,
|
|
),
|
|
);
|
|
}
|
|
case d.EventType.TOOL_CALL_END: {
|
|
let e = t.toolCallId;
|
|
return r.has(e)
|
|
? (r.delete(e), ez(t))
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${e}'. A 'TOOL_CALL_START' event must be sent first.`,
|
|
),
|
|
);
|
|
}
|
|
case d.EventType.STEP_STARTED: {
|
|
let e = t.stepName;
|
|
return o.has(e)
|
|
? eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Step "${e}" is already active for 'STEP_STARTED'`,
|
|
),
|
|
)
|
|
: (o.set(e, !0), ez(t));
|
|
}
|
|
case d.EventType.STEP_FINISHED: {
|
|
let e = t.stepName;
|
|
return o.has(e)
|
|
? (o.delete(e), ez(t))
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'STEP_FINISHED' for step "${e}" that was not started`,
|
|
),
|
|
);
|
|
}
|
|
case d.EventType.RUN_STARTED:
|
|
return (c = !0), ez(t);
|
|
case d.EventType.RUN_FINISHED:
|
|
if (o.size > 0) {
|
|
let e = Array.from(o.keys()).join(", ");
|
|
return eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'RUN_FINISHED' while steps are still active: ${e}`,
|
|
),
|
|
);
|
|
}
|
|
if (n.size > 0) {
|
|
let e = Array.from(n.keys()).join(", ");
|
|
return eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`,
|
|
),
|
|
);
|
|
}
|
|
if (r.size > 0) {
|
|
let e = Array.from(r.keys()).join(", ");
|
|
return eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`,
|
|
),
|
|
);
|
|
}
|
|
return (s = !0), ez(t);
|
|
case d.EventType.RUN_ERROR:
|
|
return (i = !0), ez(t);
|
|
case d.EventType.CUSTOM:
|
|
return ez(t);
|
|
case d.EventType.THINKING_TEXT_MESSAGE_START:
|
|
return l
|
|
? u
|
|
? eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
"Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.",
|
|
),
|
|
)
|
|
: ((u = !0), ez(t))
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
"Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first.",
|
|
),
|
|
);
|
|
case d.EventType.THINKING_TEXT_MESSAGE_CONTENT:
|
|
return u
|
|
? ez(t)
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
"Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first.",
|
|
),
|
|
);
|
|
case d.EventType.THINKING_TEXT_MESSAGE_END:
|
|
return u
|
|
? ((u = !1), ez(t))
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
"Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first.",
|
|
),
|
|
);
|
|
case d.EventType.THINKING_START:
|
|
return l
|
|
? eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
"Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.",
|
|
),
|
|
)
|
|
: ((l = !0), ez(t));
|
|
case d.EventType.THINKING_END:
|
|
return l
|
|
? ((l = !1), ez(t))
|
|
: eH(
|
|
() =>
|
|
new d.AGUIError(
|
|
"Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first.",
|
|
),
|
|
);
|
|
default:
|
|
return ez(t);
|
|
}
|
|
}),
|
|
);
|
|
},
|
|
nf = (((a = {}).HEADERS = "headers"), (a.DATA = "data"), a),
|
|
ng = (e, t) => {
|
|
var n, r;
|
|
return ((n = () => eU(fetch(e, t))),
|
|
new eh(function (e) {
|
|
eC(n()).subscribe(e);
|
|
})).pipe(
|
|
((r = (e) => {
|
|
if (!e.ok) {
|
|
let t = e.headers.get("content-type") || "";
|
|
return eU(e.text()).pipe(
|
|
eV((n) => {
|
|
let r = n;
|
|
if (t.includes("application/json"))
|
|
try {
|
|
r = JSON.parse(n);
|
|
} catch {}
|
|
let s = Error(
|
|
`HTTP ${e.status}: ${"string" == typeof r ? r : JSON.stringify(r)}`,
|
|
);
|
|
return (s.status = e.status), (s.payload = r), eH(() => s);
|
|
}),
|
|
);
|
|
}
|
|
let t = { type: nf.HEADERS, status: e.status, headers: e.headers },
|
|
n = e.body?.getReader();
|
|
return n
|
|
? new eh(
|
|
(e) => (
|
|
e.next(t),
|
|
(async () => {
|
|
try {
|
|
for (;;) {
|
|
let { done: t, value: r } = await n.read();
|
|
if (t) break;
|
|
let s = { type: nf.DATA, data: r };
|
|
e.next(s);
|
|
}
|
|
e.complete();
|
|
} catch (t) {
|
|
e.error(t);
|
|
}
|
|
})(),
|
|
() => {
|
|
n.cancel().catch((e) => {
|
|
if (e?.name !== "AbortError") throw e;
|
|
});
|
|
}
|
|
),
|
|
)
|
|
: eH(() => Error("Failed to getReader() from response"));
|
|
}),
|
|
ek(function (e, t) {
|
|
var n = null,
|
|
s = 0,
|
|
i = !1,
|
|
a = function () {
|
|
return i && !n && t.complete();
|
|
};
|
|
e.subscribe(
|
|
eM(
|
|
t,
|
|
function (e) {
|
|
null == n || n.unsubscribe(),
|
|
eC(r(e, s++)).subscribe(
|
|
(n = eM(
|
|
t,
|
|
function (e) {
|
|
return t.next(e);
|
|
},
|
|
function () {
|
|
(n = null), a();
|
|
},
|
|
)),
|
|
);
|
|
},
|
|
function () {
|
|
(i = !0), a();
|
|
},
|
|
),
|
|
);
|
|
})),
|
|
);
|
|
},
|
|
nm = (e) => {
|
|
let t = new ev(),
|
|
n = new TextDecoder("utf-8", { fatal: !1 }),
|
|
r = "";
|
|
function s(e) {
|
|
let n = e.split(`
|
|
`),
|
|
r = [];
|
|
for (let e of n)
|
|
e.startsWith("data:") && r.push(e.slice(5).replace(/^ /, ""));
|
|
if (r.length > 0)
|
|
try {
|
|
let e = r.join(`
|
|
`),
|
|
n = JSON.parse(e);
|
|
t.next(n);
|
|
} catch (e) {
|
|
t.error(e);
|
|
}
|
|
}
|
|
return (
|
|
e.subscribe({
|
|
next: (e) => {
|
|
if (e.type !== nf.HEADERS && e.type === nf.DATA && e.data) {
|
|
let t = n.decode(e.data, { stream: !0 }),
|
|
i = (r += t).split(/\n\n/);
|
|
for (let e of ((r = i.pop() || ""), i)) s(e);
|
|
}
|
|
},
|
|
error: (e) => t.error(e),
|
|
complete: () => {
|
|
r && s((r += n.decode())), t.complete();
|
|
},
|
|
}),
|
|
t.asObservable()
|
|
);
|
|
},
|
|
nv = (e) => {
|
|
let t = new ev(),
|
|
n = new Uint8Array();
|
|
function r() {
|
|
for (; n.length >= 4; ) {
|
|
let e =
|
|
4 + new DataView(n.buffer, n.byteOffset, 4).getUint32(0, !1);
|
|
if (n.length < e) break;
|
|
try {
|
|
let r = n.slice(4, e),
|
|
s = (function (e) {
|
|
let t = Object.values(ne.decode(e)).find((e) => void 0 !== e);
|
|
if (!t) throw Error("Invalid event");
|
|
if (
|
|
((t.type = tA[t.baseEvent.type]),
|
|
(t.timestamp = t.baseEvent.timestamp),
|
|
(t.rawEvent = t.baseEvent.rawEvent),
|
|
t.type === d.EventType.MESSAGES_SNAPSHOT)
|
|
)
|
|
for (let e of t.messages)
|
|
e.toolCalls?.length === 0 && (e.toolCalls = void 0);
|
|
if (t.type === d.EventType.STATE_DELTA)
|
|
for (let e of t.delta)
|
|
(e.op = tg[e.op].toLowerCase()),
|
|
Object.keys(e).forEach((t) => {
|
|
void 0 === e[t] && delete e[t];
|
|
});
|
|
return (
|
|
Object.keys(t).forEach((e) => {
|
|
void 0 === t[e] && delete t[e];
|
|
}),
|
|
d.EventSchemas.parse(t)
|
|
);
|
|
})(r);
|
|
t.next(s), (n = n.slice(e));
|
|
} catch (n) {
|
|
let e = n instanceof Error ? n.message : String(n);
|
|
t.error(Error(`Failed to decode protocol buffer message: ${e}`));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
return (
|
|
e.subscribe({
|
|
next: (e) => {
|
|
if (e.type !== nf.HEADERS && e.type === nf.DATA && e.data) {
|
|
let t = new Uint8Array(n.length + e.data.length);
|
|
t.set(n, 0), t.set(e.data, n.length), (n = t), r();
|
|
}
|
|
},
|
|
error: (e) => t.error(e),
|
|
complete: () => {
|
|
if (n.length > 0)
|
|
try {
|
|
r();
|
|
} catch {
|
|
console.warn(
|
|
"Incomplete or invalid protocol buffer data at stream end",
|
|
);
|
|
}
|
|
t.complete();
|
|
},
|
|
}),
|
|
t.asObservable()
|
|
);
|
|
},
|
|
ny = (e) => {
|
|
let t = new ev(),
|
|
n = new eE(),
|
|
r = !1;
|
|
return (
|
|
e.subscribe({
|
|
next: (e) => {
|
|
n.next(e),
|
|
e.type !== nf.HEADERS || r
|
|
? r ||
|
|
t.error(
|
|
Error("No headers event received before data events"),
|
|
)
|
|
: ((r = !0),
|
|
"application/vnd.ag-ui.event+proto" ===
|
|
e.headers.get("content-type")
|
|
? nv(n).subscribe({
|
|
next: (e) => t.next(e),
|
|
error: (e) => t.error(e),
|
|
complete: () => t.complete(),
|
|
})
|
|
: nm(n).subscribe({
|
|
next: (e) => {
|
|
try {
|
|
let n = d.EventSchemas.parse(e);
|
|
t.next(n);
|
|
} catch (e) {
|
|
t.error(e);
|
|
}
|
|
},
|
|
error: (e) => {
|
|
if (e?.name === "AbortError") {
|
|
t.next({
|
|
type: d.EventType.RUN_ERROR,
|
|
message: e.message || "Request aborted",
|
|
code: "abort",
|
|
rawEvent: e,
|
|
}),
|
|
t.complete();
|
|
return;
|
|
}
|
|
return t.error(e);
|
|
},
|
|
complete: () => t.complete(),
|
|
}));
|
|
},
|
|
error: (e) => {
|
|
n.error(e), t.error(e);
|
|
},
|
|
complete: () => {
|
|
n.complete();
|
|
},
|
|
}),
|
|
t.asObservable()
|
|
);
|
|
},
|
|
n_ = nt.z.enum([
|
|
"TextMessageStart",
|
|
"TextMessageContent",
|
|
"TextMessageEnd",
|
|
"ActionExecutionStart",
|
|
"ActionExecutionArgs",
|
|
"ActionExecutionEnd",
|
|
"ActionExecutionResult",
|
|
"AgentStateMessage",
|
|
"MetaEvent",
|
|
"RunStarted",
|
|
"RunFinished",
|
|
"RunError",
|
|
"NodeStarted",
|
|
"NodeFinished",
|
|
]),
|
|
nE = nt.z.enum(["LangGraphInterruptEvent", "PredictState", "Exit"]),
|
|
nb = nt.z.object({
|
|
type: nt.z.literal(n_.enum.TextMessageStart),
|
|
messageId: nt.z.string(),
|
|
parentMessageId: nt.z.string().optional(),
|
|
role: nt.z.string().optional(),
|
|
}),
|
|
nT = nt.z.object({
|
|
type: nt.z.literal(n_.enum.TextMessageContent),
|
|
messageId: nt.z.string(),
|
|
content: nt.z.string(),
|
|
}),
|
|
nS = nt.z.object({
|
|
type: nt.z.literal(n_.enum.TextMessageEnd),
|
|
messageId: nt.z.string(),
|
|
}),
|
|
nA = nt.z.object({
|
|
type: nt.z.literal(n_.enum.ActionExecutionStart),
|
|
actionExecutionId: nt.z.string(),
|
|
actionName: nt.z.string(),
|
|
parentMessageId: nt.z.string().optional(),
|
|
}),
|
|
nN = nt.z.object({
|
|
type: nt.z.literal(n_.enum.ActionExecutionArgs),
|
|
actionExecutionId: nt.z.string(),
|
|
args: nt.z.string(),
|
|
}),
|
|
nI = nt.z.object({
|
|
type: nt.z.literal(n_.enum.ActionExecutionEnd),
|
|
actionExecutionId: nt.z.string(),
|
|
}),
|
|
nw = nt.z.object({
|
|
type: nt.z.literal(n_.enum.ActionExecutionResult),
|
|
actionName: nt.z.string(),
|
|
actionExecutionId: nt.z.string(),
|
|
result: nt.z.string(),
|
|
}),
|
|
nO = nt.z.object({
|
|
type: nt.z.literal(n_.enum.AgentStateMessage),
|
|
threadId: nt.z.string(),
|
|
agentName: nt.z.string(),
|
|
nodeName: nt.z.string(),
|
|
runId: nt.z.string(),
|
|
active: nt.z.boolean(),
|
|
role: nt.z.string(),
|
|
state: nt.z.string(),
|
|
running: nt.z.boolean(),
|
|
}),
|
|
nC = nt.z.object({
|
|
type: nt.z.literal(n_.enum.MetaEvent),
|
|
name: nE,
|
|
value: nt.z.any(),
|
|
}),
|
|
nR = nt.z.object({
|
|
type: nt.z.literal(n_.enum.RunError),
|
|
message: nt.z.string(),
|
|
code: nt.z.string().optional(),
|
|
});
|
|
nt.z.discriminatedUnion("type", [nb, nT, nS, nA, nN, nI, nw, nO, nC, nR]),
|
|
nt.z.object({
|
|
id: nt.z.string(),
|
|
role: nt.z.string(),
|
|
content: nt.z.string(),
|
|
parentMessageId: nt.z.string().optional(),
|
|
}),
|
|
nt.z.object({
|
|
id: nt.z.string(),
|
|
name: nt.z.string(),
|
|
arguments: nt.z.any(),
|
|
parentMessageId: nt.z.string().optional(),
|
|
}),
|
|
nt.z.object({
|
|
id: nt.z.string(),
|
|
result: nt.z.any(),
|
|
actionExecutionId: nt.z.string(),
|
|
actionName: nt.z.string(),
|
|
});
|
|
let nk = (e) => {
|
|
if ("string" == typeof e) return e;
|
|
if (!Array.isArray(e)) return;
|
|
let t = e
|
|
.filter((e) => "text" === e.type)
|
|
.map((e) => e.text)
|
|
.filter((e) => e.length > 0);
|
|
if (0 !== t.length)
|
|
return t.join(`
|
|
`);
|
|
},
|
|
nx = (e, t, n) => (r) => {
|
|
let s = {},
|
|
i = !0,
|
|
a = !0,
|
|
o = "",
|
|
l = null,
|
|
u = null,
|
|
c = [],
|
|
p = {},
|
|
h = (e) => {
|
|
"object" == typeof e &&
|
|
e &&
|
|
("messages" in e && delete e.messages, (s = e));
|
|
};
|
|
return r.pipe(
|
|
eV((r) => {
|
|
switch (r.type) {
|
|
case d.EventType.TEXT_MESSAGE_START:
|
|
return [
|
|
{
|
|
type: n_.enum.TextMessageStart,
|
|
messageId: r.messageId,
|
|
role: r.role,
|
|
},
|
|
];
|
|
case d.EventType.TEXT_MESSAGE_CONTENT:
|
|
return [
|
|
{
|
|
type: n_.enum.TextMessageContent,
|
|
messageId: r.messageId,
|
|
content: r.delta,
|
|
},
|
|
];
|
|
case d.EventType.TEXT_MESSAGE_END:
|
|
return [
|
|
{ type: n_.enum.TextMessageEnd, messageId: r.messageId },
|
|
];
|
|
case d.EventType.TOOL_CALL_START:
|
|
return (
|
|
c.push({
|
|
id: r.toolCallId,
|
|
type: "function",
|
|
function: { name: r.toolCallName, arguments: "" },
|
|
}),
|
|
(a = !0),
|
|
(p[r.toolCallId] = r.toolCallName),
|
|
[
|
|
{
|
|
type: n_.enum.ActionExecutionStart,
|
|
actionExecutionId: r.toolCallId,
|
|
actionName: r.toolCallName,
|
|
parentMessageId: r.parentMessageId,
|
|
},
|
|
]
|
|
);
|
|
case d.EventType.TOOL_CALL_ARGS: {
|
|
let l = c.find((e) => e.id === r.toolCallId);
|
|
if (!l)
|
|
return (
|
|
console.warn(
|
|
`TOOL_CALL_ARGS: No tool call found with ID '${r.toolCallId}'`,
|
|
),
|
|
[]
|
|
);
|
|
l.function.arguments += r.delta;
|
|
let d = !1;
|
|
if (u) {
|
|
let e = u.find((e) => e.tool == l.function.name);
|
|
if (e)
|
|
try {
|
|
let t = JSON.parse(eY(l.function.arguments));
|
|
e.tool_argument && e.tool_argument in t
|
|
? (h({ ...s, [e.state_key]: t[e.tool_argument] }),
|
|
(d = !0))
|
|
: e.tool_argument ||
|
|
(h({ ...s, [e.state_key]: t }), (d = !0));
|
|
} catch {}
|
|
}
|
|
return [
|
|
{
|
|
type: n_.enum.ActionExecutionArgs,
|
|
actionExecutionId: r.toolCallId,
|
|
args: r.delta,
|
|
},
|
|
...(d
|
|
? [
|
|
{
|
|
type: n_.enum.AgentStateMessage,
|
|
threadId: e,
|
|
agentName: n,
|
|
nodeName: o,
|
|
runId: t,
|
|
running: i,
|
|
role: "assistant",
|
|
state: JSON.stringify(s),
|
|
active: a,
|
|
},
|
|
]
|
|
: []),
|
|
];
|
|
}
|
|
case d.EventType.TOOL_CALL_END:
|
|
return [
|
|
{
|
|
type: n_.enum.ActionExecutionEnd,
|
|
actionExecutionId: r.toolCallId,
|
|
},
|
|
];
|
|
case d.EventType.TOOL_CALL_RESULT:
|
|
return [
|
|
{
|
|
type: n_.enum.ActionExecutionResult,
|
|
actionExecutionId: r.toolCallId,
|
|
result: r.content,
|
|
actionName: p[r.toolCallId] || "unknown",
|
|
},
|
|
];
|
|
case d.EventType.RAW:
|
|
return [];
|
|
case d.EventType.CUSTOM:
|
|
switch (r.name) {
|
|
case "Exit":
|
|
i = !1;
|
|
break;
|
|
case "PredictState":
|
|
u = r.value;
|
|
}
|
|
return [
|
|
{ type: n_.enum.MetaEvent, name: r.name, value: r.value },
|
|
];
|
|
case d.EventType.STATE_SNAPSHOT:
|
|
return (
|
|
h(r.snapshot),
|
|
[
|
|
{
|
|
type: n_.enum.AgentStateMessage,
|
|
threadId: e,
|
|
agentName: n,
|
|
nodeName: o,
|
|
runId: t,
|
|
running: i,
|
|
role: "assistant",
|
|
state: JSON.stringify(s),
|
|
active: a,
|
|
},
|
|
]
|
|
);
|
|
case d.EventType.STATE_DELTA: {
|
|
let l = N(s, r.delta, !0, !1);
|
|
return l
|
|
? (h(l.newDocument),
|
|
[
|
|
{
|
|
type: n_.enum.AgentStateMessage,
|
|
threadId: e,
|
|
agentName: n,
|
|
nodeName: o,
|
|
runId: t,
|
|
running: i,
|
|
role: "assistant",
|
|
state: JSON.stringify(s),
|
|
active: a,
|
|
},
|
|
])
|
|
: [];
|
|
}
|
|
case d.EventType.MESSAGES_SNAPSHOT:
|
|
return (
|
|
(l = r.messages),
|
|
[
|
|
{
|
|
type: n_.enum.AgentStateMessage,
|
|
threadId: e,
|
|
agentName: n,
|
|
nodeName: o,
|
|
runId: t,
|
|
running: i,
|
|
role: "assistant",
|
|
state: JSON.stringify({
|
|
...s,
|
|
...(l ? { messages: l } : {}),
|
|
}),
|
|
active: !0,
|
|
},
|
|
]
|
|
);
|
|
case d.EventType.RUN_STARTED:
|
|
return [];
|
|
case d.EventType.RUN_FINISHED:
|
|
return (
|
|
l && (s.messages = l),
|
|
0 === Object.keys(s).length
|
|
? []
|
|
: [
|
|
{
|
|
type: n_.enum.AgentStateMessage,
|
|
threadId: e,
|
|
agentName: n,
|
|
nodeName: o,
|
|
runId: t,
|
|
running: i,
|
|
role: "assistant",
|
|
state: JSON.stringify({
|
|
...s,
|
|
...(l
|
|
? {
|
|
messages: (function (e) {
|
|
let t = [];
|
|
for (let n of e)
|
|
if (
|
|
"assistant" === n.role ||
|
|
"user" === n.role ||
|
|
"system" === n.role
|
|
) {
|
|
let e = nk(n.content);
|
|
if (e) {
|
|
let r = {
|
|
id: n.id,
|
|
role: n.role,
|
|
content: e,
|
|
};
|
|
t.push(r);
|
|
}
|
|
if (
|
|
"assistant" === n.role &&
|
|
n.toolCalls &&
|
|
n.toolCalls.length > 0
|
|
)
|
|
for (let e of n.toolCalls) {
|
|
let r = {
|
|
id: e.id,
|
|
name: e.function.name,
|
|
arguments: JSON.parse(
|
|
e.function.arguments,
|
|
),
|
|
parentMessageId: n.id,
|
|
};
|
|
t.push(r);
|
|
}
|
|
} else if ("tool" === n.role) {
|
|
let r = "unknown";
|
|
for (let t of e)
|
|
if (
|
|
"assistant" === t.role &&
|
|
t.toolCalls?.length
|
|
) {
|
|
for (let e of t.toolCalls)
|
|
if (e.id === n.toolCallId) {
|
|
r = e.function.name;
|
|
break;
|
|
}
|
|
}
|
|
let s = {
|
|
id: n.id,
|
|
result: n.content,
|
|
actionExecutionId: n.toolCallId,
|
|
actionName: r,
|
|
};
|
|
t.push(s);
|
|
}
|
|
return t;
|
|
})(l),
|
|
}
|
|
: {}),
|
|
}),
|
|
active: !1,
|
|
},
|
|
]
|
|
);
|
|
case d.EventType.RUN_ERROR:
|
|
return [
|
|
{ type: n_.enum.RunError, message: r.message, code: r.code },
|
|
];
|
|
case d.EventType.STEP_STARTED:
|
|
return (
|
|
(o = r.stepName),
|
|
(c = []),
|
|
(u = null),
|
|
[
|
|
{
|
|
type: n_.enum.AgentStateMessage,
|
|
threadId: e,
|
|
agentName: n,
|
|
nodeName: o,
|
|
runId: t,
|
|
running: i,
|
|
role: "assistant",
|
|
state: JSON.stringify(s),
|
|
active: !0,
|
|
},
|
|
]
|
|
);
|
|
case d.EventType.STEP_FINISHED:
|
|
return (
|
|
(c = []),
|
|
(u = null),
|
|
[
|
|
{
|
|
type: n_.enum.AgentStateMessage,
|
|
threadId: e,
|
|
agentName: n,
|
|
nodeName: o,
|
|
runId: t,
|
|
running: i,
|
|
role: "assistant",
|
|
state: JSON.stringify(s),
|
|
active: !1,
|
|
},
|
|
]
|
|
);
|
|
default:
|
|
return [];
|
|
}
|
|
}),
|
|
);
|
|
},
|
|
nP = (e) => (t) => {
|
|
let n,
|
|
r,
|
|
s,
|
|
i,
|
|
a = () =>
|
|
"text" === i
|
|
? [
|
|
(() => {
|
|
if (!n || "text" !== i)
|
|
throw Error("No text message to close");
|
|
let t = {
|
|
type: d.EventType.TEXT_MESSAGE_END,
|
|
messageId: n.messageId,
|
|
};
|
|
return (
|
|
(i = void 0),
|
|
(n = void 0),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: TEXT_MESSAGE_END",
|
|
JSON.stringify(t),
|
|
),
|
|
t
|
|
);
|
|
})(),
|
|
]
|
|
: "tool" === i
|
|
? [
|
|
(() => {
|
|
if (!r || "tool" !== i)
|
|
throw Error("No tool call to close");
|
|
let t = {
|
|
type: d.EventType.TOOL_CALL_END,
|
|
toolCallId: r.toolCallId,
|
|
};
|
|
return (
|
|
(i = void 0),
|
|
(r = void 0),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: TOOL_CALL_END",
|
|
JSON.stringify(t),
|
|
),
|
|
t
|
|
);
|
|
})(),
|
|
]
|
|
: "reasoning" === i
|
|
? [
|
|
(() => {
|
|
if (!s || "reasoning" !== i)
|
|
throw Error("No reasoning message to close");
|
|
let t = {
|
|
type: d.EventType.REASONING_MESSAGE_END,
|
|
messageId: s.messageId,
|
|
};
|
|
return (
|
|
(i = void 0),
|
|
(s = void 0),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: REASONING_MESSAGE_END",
|
|
JSON.stringify(t),
|
|
),
|
|
t
|
|
);
|
|
})(),
|
|
]
|
|
: [];
|
|
return t.pipe(
|
|
eV((t) => {
|
|
switch (t.type) {
|
|
case d.EventType.TEXT_MESSAGE_START:
|
|
case d.EventType.TEXT_MESSAGE_CONTENT:
|
|
case d.EventType.TEXT_MESSAGE_END:
|
|
case d.EventType.TOOL_CALL_START:
|
|
case d.EventType.TOOL_CALL_ARGS:
|
|
case d.EventType.TOOL_CALL_END:
|
|
case d.EventType.TOOL_CALL_RESULT:
|
|
case d.EventType.STATE_SNAPSHOT:
|
|
case d.EventType.STATE_DELTA:
|
|
case d.EventType.MESSAGES_SNAPSHOT:
|
|
case d.EventType.CUSTOM:
|
|
case d.EventType.RUN_STARTED:
|
|
case d.EventType.RUN_FINISHED:
|
|
case d.EventType.RUN_ERROR:
|
|
case d.EventType.STEP_STARTED:
|
|
case d.EventType.STEP_FINISHED:
|
|
case d.EventType.THINKING_START:
|
|
case d.EventType.THINKING_END:
|
|
case d.EventType.THINKING_TEXT_MESSAGE_START:
|
|
case d.EventType.THINKING_TEXT_MESSAGE_CONTENT:
|
|
case d.EventType.THINKING_TEXT_MESSAGE_END:
|
|
case d.EventType.REASONING_START:
|
|
case d.EventType.REASONING_MESSAGE_START:
|
|
case d.EventType.REASONING_MESSAGE_CONTENT:
|
|
case d.EventType.REASONING_MESSAGE_END:
|
|
case d.EventType.REASONING_END:
|
|
return [...a(), t];
|
|
case d.EventType.RAW:
|
|
case d.EventType.ACTIVITY_SNAPSHOT:
|
|
case d.EventType.ACTIVITY_DELTA:
|
|
case d.EventType.REASONING_ENCRYPTED_VALUE:
|
|
return [t];
|
|
case d.EventType.TEXT_MESSAGE_CHUNK:
|
|
let o = [];
|
|
if (
|
|
(("text" !== i ||
|
|
(void 0 !== t.messageId && t.messageId !== n?.messageId)) &&
|
|
o.push(...a()),
|
|
"text" !== i)
|
|
) {
|
|
if (void 0 === t.messageId)
|
|
throw Error(
|
|
"First TEXT_MESSAGE_CHUNK must have a messageId",
|
|
);
|
|
(n = { messageId: t.messageId }), (i = "text");
|
|
let r = {
|
|
type: d.EventType.TEXT_MESSAGE_START,
|
|
messageId: t.messageId,
|
|
role: t.role || "assistant",
|
|
};
|
|
o.push(r),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: TEXT_MESSAGE_START",
|
|
JSON.stringify(r),
|
|
);
|
|
}
|
|
if (void 0 !== t.delta) {
|
|
let r = {
|
|
type: d.EventType.TEXT_MESSAGE_CONTENT,
|
|
messageId: n.messageId,
|
|
delta: t.delta,
|
|
};
|
|
o.push(r),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: TEXT_MESSAGE_CONTENT",
|
|
JSON.stringify(r),
|
|
);
|
|
}
|
|
return o;
|
|
case d.EventType.TOOL_CALL_CHUNK:
|
|
let l = [];
|
|
if (
|
|
(("tool" !== i ||
|
|
(void 0 !== t.toolCallId &&
|
|
t.toolCallId !== r?.toolCallId)) &&
|
|
l.push(...a()),
|
|
"tool" !== i)
|
|
) {
|
|
if (void 0 === t.toolCallId)
|
|
throw Error("First TOOL_CALL_CHUNK must have a toolCallId");
|
|
if (void 0 === t.toolCallName)
|
|
throw Error(
|
|
"First TOOL_CALL_CHUNK must have a toolCallName",
|
|
);
|
|
(r = {
|
|
toolCallId: t.toolCallId,
|
|
toolCallName: t.toolCallName,
|
|
parentMessageId: t.parentMessageId,
|
|
}),
|
|
(i = "tool");
|
|
let n = {
|
|
type: d.EventType.TOOL_CALL_START,
|
|
toolCallId: t.toolCallId,
|
|
toolCallName: t.toolCallName,
|
|
parentMessageId: t.parentMessageId,
|
|
};
|
|
l.push(n),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: TOOL_CALL_START",
|
|
JSON.stringify(n),
|
|
);
|
|
}
|
|
if (void 0 !== t.delta) {
|
|
let n = {
|
|
type: d.EventType.TOOL_CALL_ARGS,
|
|
toolCallId: r.toolCallId,
|
|
delta: t.delta,
|
|
};
|
|
l.push(n),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: TOOL_CALL_ARGS",
|
|
JSON.stringify(n),
|
|
);
|
|
}
|
|
return l;
|
|
case d.EventType.REASONING_MESSAGE_CHUNK:
|
|
let u = [];
|
|
if (
|
|
(("reasoning" !== i ||
|
|
(t.messageId && t.messageId !== s?.messageId)) &&
|
|
u.push(...a()),
|
|
"reasoning" !== i)
|
|
) {
|
|
if (void 0 === t.messageId)
|
|
throw Error(
|
|
"First REASONING_MESSAGE_CHUNK must have a messageId",
|
|
);
|
|
(s = { messageId: t.messageId }), (i = "reasoning");
|
|
let n = {
|
|
type: d.EventType.REASONING_MESSAGE_START,
|
|
messageId: t.messageId,
|
|
};
|
|
u.push(n),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: REASONING_MESSAGE_START",
|
|
JSON.stringify(n),
|
|
);
|
|
}
|
|
if (void 0 !== t.delta) {
|
|
let n = {
|
|
type: d.EventType.REASONING_MESSAGE_CONTENT,
|
|
messageId: s.messageId,
|
|
delta: t.delta,
|
|
};
|
|
u.push(n),
|
|
e &&
|
|
console.debug(
|
|
"[TRANSFORM]: REASONING_MESSAGE_CONTENT",
|
|
JSON.stringify(n),
|
|
);
|
|
}
|
|
return u;
|
|
}
|
|
return t.type, [];
|
|
}),
|
|
ex(() => {
|
|
a();
|
|
}),
|
|
);
|
|
};
|
|
var nM = class {
|
|
runNext(e, t) {
|
|
return t.run(e).pipe(nP(!1));
|
|
}
|
|
runNextWithState(e, t) {
|
|
let n = nu(e.messages || []),
|
|
r = nu(e.state || {}),
|
|
s = new eE();
|
|
return (
|
|
np(e, s, t, []).subscribe((e) => {
|
|
void 0 !== e.messages && (n = e.messages),
|
|
void 0 !== e.state && (r = e.state);
|
|
}),
|
|
this.runNext(e, t).pipe(
|
|
eB(
|
|
async (e) => (
|
|
s.next(e),
|
|
await new Promise((e) => setTimeout(e, 0)),
|
|
{ event: e, messages: nu(n), state: nu(r) }
|
|
),
|
|
),
|
|
)
|
|
);
|
|
}
|
|
},
|
|
nL = class extends nM {
|
|
constructor(e) {
|
|
super(), (this.fn = e);
|
|
}
|
|
run(e, t) {
|
|
return this.fn(e, t);
|
|
}
|
|
},
|
|
nD = class extends nM {
|
|
constructor(e) {
|
|
if (
|
|
(super(),
|
|
(this.blockedToolCallIds = new Set()),
|
|
e.allowedToolCalls && e.disallowedToolCalls)
|
|
)
|
|
throw Error(
|
|
"Cannot specify both allowedToolCalls and disallowedToolCalls",
|
|
);
|
|
if (!e.allowedToolCalls && !e.disallowedToolCalls)
|
|
throw Error(
|
|
"Must specify either allowedToolCalls or disallowedToolCalls",
|
|
);
|
|
e.allowedToolCalls
|
|
? (this.allowedTools = new Set(e.allowedToolCalls))
|
|
: e.disallowedToolCalls &&
|
|
(this.disallowedTools = new Set(e.disallowedToolCalls));
|
|
}
|
|
run(e, t) {
|
|
var n;
|
|
return this.runNext(e, t).pipe(
|
|
((n = (e) =>
|
|
e.type === d.EventType.TOOL_CALL_START
|
|
? !this.shouldFilterTool(e.toolCallName) ||
|
|
(this.blockedToolCallIds.add(e.toolCallId), !1)
|
|
: e.type === d.EventType.TOOL_CALL_ARGS ||
|
|
e.type === d.EventType.TOOL_CALL_END
|
|
? !this.blockedToolCallIds.has(e.toolCallId)
|
|
: e.type !== d.EventType.TOOL_CALL_RESULT ||
|
|
!this.blockedToolCallIds.has(e.toolCallId) ||
|
|
(this.blockedToolCallIds.delete(e.toolCallId), !1)),
|
|
ek(function (e, t) {
|
|
var r = 0;
|
|
e.subscribe(
|
|
eM(t, function (e) {
|
|
return n.call(void 0, e, r++) && t.next(e);
|
|
}),
|
|
);
|
|
})),
|
|
);
|
|
}
|
|
shouldFilterTool(e) {
|
|
return this.allowedTools
|
|
? !this.allowedTools.has(e)
|
|
: !!this.disallowedTools && this.disallowedTools.has(e);
|
|
}
|
|
};
|
|
function nj(e) {
|
|
let t = e.content;
|
|
if (Array.isArray(t)) {
|
|
let n = t
|
|
.filter(
|
|
(e) =>
|
|
"object" == typeof e &&
|
|
!!e &&
|
|
"type" in e &&
|
|
"text" === e.type &&
|
|
"string" == typeof e.text,
|
|
)
|
|
.map((e) => e.text)
|
|
.join("");
|
|
return { ...e, content: n };
|
|
}
|
|
return "string" == typeof t ? e : { ...e, content: "" };
|
|
}
|
|
var nZ = class extends nM {
|
|
run(e, t) {
|
|
let { parentRunId: n, ...r } = e,
|
|
s = { ...r, messages: r.messages.map(nj) };
|
|
return this.runNext(s, t);
|
|
}
|
|
};
|
|
let nU = "THINKING_START",
|
|
nG = "THINKING_END",
|
|
nF = "THINKING_TEXT_MESSAGE_START",
|
|
n$ = "THINKING_TEXT_MESSAGE_CONTENT",
|
|
nV = "THINKING_TEXT_MESSAGE_END";
|
|
var nz = class extends nM {
|
|
constructor(...e) {
|
|
super(...e),
|
|
(this.currentReasoningId = null),
|
|
(this.currentMessageId = null);
|
|
}
|
|
warnAboutTransformation(e, t) {
|
|
l.default.env.SUPPRESS_TRANSFORMATION_WARNINGS ||
|
|
console.warn(
|
|
`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`,
|
|
);
|
|
}
|
|
run(e, t) {
|
|
return (
|
|
(this.currentReasoningId = null),
|
|
(this.currentMessageId = null),
|
|
this.runNext(e, t).pipe(e$((e) => this.transformEvent(e)))
|
|
);
|
|
}
|
|
transformEvent(e) {
|
|
switch (e.type) {
|
|
case nU: {
|
|
this.currentReasoningId = nd();
|
|
let { title: t, ...n } = e;
|
|
return (
|
|
this.warnAboutTransformation(nU, d.EventType.REASONING_START),
|
|
{
|
|
...n,
|
|
type: d.EventType.REASONING_START,
|
|
messageId: this.currentReasoningId,
|
|
}
|
|
);
|
|
}
|
|
case nF:
|
|
return (
|
|
(this.currentMessageId = nd()),
|
|
this.warnAboutTransformation(
|
|
nF,
|
|
d.EventType.REASONING_MESSAGE_START,
|
|
),
|
|
{
|
|
...e,
|
|
type: d.EventType.REASONING_MESSAGE_START,
|
|
messageId: this.currentMessageId,
|
|
role: "assistant",
|
|
}
|
|
);
|
|
case n$: {
|
|
let { delta: t, ...n } = e;
|
|
return (
|
|
this.warnAboutTransformation(
|
|
n$,
|
|
d.EventType.REASONING_MESSAGE_CONTENT,
|
|
),
|
|
{
|
|
...n,
|
|
type: d.EventType.REASONING_MESSAGE_CONTENT,
|
|
messageId: this.currentMessageId ?? nd(),
|
|
delta: t,
|
|
}
|
|
);
|
|
}
|
|
case nV: {
|
|
let t = this.currentMessageId ?? nd();
|
|
return (
|
|
this.warnAboutTransformation(
|
|
nV,
|
|
d.EventType.REASONING_MESSAGE_END,
|
|
),
|
|
{ ...e, type: d.EventType.REASONING_MESSAGE_END, messageId: t }
|
|
);
|
|
}
|
|
case nG: {
|
|
let t = this.currentReasoningId ?? nd();
|
|
return (
|
|
this.warnAboutTransformation(nG, d.EventType.REASONING_END),
|
|
{ ...e, type: d.EventType.REASONING_END, messageId: t }
|
|
);
|
|
}
|
|
default:
|
|
return e;
|
|
}
|
|
}
|
|
},
|
|
nH = class {
|
|
get maxVersion() {
|
|
return "0.0.45";
|
|
}
|
|
constructor({
|
|
agentId: e,
|
|
description: t,
|
|
threadId: n,
|
|
initialMessages: r,
|
|
initialState: s,
|
|
debug: i,
|
|
} = {}) {
|
|
(this.debug = !1),
|
|
(this.subscribers = []),
|
|
(this.isRunning = !1),
|
|
(this.middlewares = []),
|
|
(this.agentId = e),
|
|
(this.description = t ?? ""),
|
|
(this.threadId = n ?? (0, u.v4)()),
|
|
(this.messages = nu(r ?? [])),
|
|
(this.state = nu(s ?? {})),
|
|
(this.debug = i ?? !1),
|
|
0 >= nl(this.maxVersion, "0.0.39") &&
|
|
this.middlewares.unshift(new nZ()),
|
|
0 >= nl(this.maxVersion, "0.0.45") &&
|
|
this.middlewares.unshift(new nz());
|
|
}
|
|
subscribe(e) {
|
|
return (
|
|
this.subscribers.push(e),
|
|
{
|
|
unsubscribe: () => {
|
|
this.subscribers = this.subscribers.filter((t) => t !== e);
|
|
},
|
|
}
|
|
);
|
|
}
|
|
use(...e) {
|
|
let t = e.map((e) => ("function" == typeof e ? new nL(e) : e));
|
|
return this.middlewares.push(...t), this;
|
|
}
|
|
async runAgent(e, t) {
|
|
try {
|
|
let n;
|
|
(this.isRunning = !0), (this.agentId = this.agentId ?? (0, u.v4)());
|
|
let r = this.prepareRunAgentInput(e),
|
|
s,
|
|
i = new Set(this.messages.map((e) => e.id)),
|
|
a = [
|
|
{
|
|
onRunFinishedEvent: (e) => {
|
|
s = e.result;
|
|
},
|
|
},
|
|
...this.subscribers,
|
|
t ?? {},
|
|
];
|
|
await this.onInitialize(r, a),
|
|
(this.activeRunDetach$ = new ev()),
|
|
(this.activeRunCompletionPromise = new Promise((e) => {
|
|
n = e;
|
|
})),
|
|
await eF(
|
|
ec(
|
|
() =>
|
|
0 === this.middlewares.length
|
|
? this.run(r)
|
|
: this.middlewares
|
|
.reduceRight(
|
|
(e, t) => ({ run: (n) => t.run(n, e) }),
|
|
this,
|
|
)
|
|
.run(r),
|
|
nP(this.debug),
|
|
nh(this.debug),
|
|
(e) => e.pipe(eJ(this.activeRunDetach$)),
|
|
(e) => this.apply(r, e, a),
|
|
(e) => this.processApplyEvents(r, e, a),
|
|
eK((e) => ((this.isRunning = !1), this.onError(r, e, a))),
|
|
ex(() => {
|
|
(this.isRunning = !1),
|
|
this.onFinalize(r, a),
|
|
n?.(),
|
|
(n = void 0),
|
|
(this.activeRunCompletionPromise = void 0),
|
|
(this.activeRunDetach$ = void 0);
|
|
}),
|
|
)(ez(null)),
|
|
);
|
|
let o = nu(this.messages).filter((e) => !i.has(e.id));
|
|
return { result: s, newMessages: o };
|
|
} finally {
|
|
this.isRunning = !1;
|
|
}
|
|
}
|
|
connect(e) {
|
|
throw new d.AGUIConnectNotImplementedError();
|
|
}
|
|
async connectAgent(e, t) {
|
|
try {
|
|
let n;
|
|
(this.isRunning = !0), (this.agentId = this.agentId ?? (0, u.v4)());
|
|
let r = this.prepareRunAgentInput(e),
|
|
s,
|
|
i = new Set(this.messages.map((e) => e.id)),
|
|
a = [
|
|
{
|
|
onRunFinishedEvent: (e) => {
|
|
s = e.result;
|
|
},
|
|
},
|
|
...this.subscribers,
|
|
t ?? {},
|
|
];
|
|
await this.onInitialize(r, a),
|
|
(this.activeRunDetach$ = new ev()),
|
|
(this.activeRunCompletionPromise = new Promise((e) => {
|
|
n = e;
|
|
})),
|
|
await eF(
|
|
ec(
|
|
() => this.connect(r),
|
|
nP(this.debug),
|
|
nh(this.debug),
|
|
(e) => e.pipe(eJ(this.activeRunDetach$)),
|
|
(e) => this.apply(r, e, a),
|
|
(e) => this.processApplyEvents(r, e, a),
|
|
eK(
|
|
(e) => (
|
|
(this.isRunning = !1),
|
|
e instanceof d.AGUIConnectNotImplementedError
|
|
? eg
|
|
: this.onError(r, e, a)
|
|
),
|
|
),
|
|
ex(() => {
|
|
(this.isRunning = !1),
|
|
this.onFinalize(r, a),
|
|
n?.(),
|
|
(n = void 0),
|
|
(this.activeRunCompletionPromise = void 0),
|
|
(this.activeRunDetach$ = void 0);
|
|
}),
|
|
)(ez(null)),
|
|
);
|
|
let o = nu(this.messages).filter((e) => !i.has(e.id));
|
|
return { result: s, newMessages: o };
|
|
} finally {
|
|
this.isRunning = !1;
|
|
}
|
|
}
|
|
abortRun() {}
|
|
async detachActiveRun() {
|
|
if (!this.activeRunDetach$) return;
|
|
let e = this.activeRunCompletionPromise ?? Promise.resolve();
|
|
this.activeRunDetach$.next(),
|
|
this.activeRunDetach$?.complete(),
|
|
await e;
|
|
}
|
|
apply(e, t, n) {
|
|
return np(e, t, this, n);
|
|
}
|
|
processApplyEvents(e, t, n) {
|
|
return t.pipe(
|
|
eX((t) => {
|
|
t.messages &&
|
|
((this.messages = t.messages),
|
|
n.forEach((t) => {
|
|
t.onMessagesChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
})),
|
|
t.state &&
|
|
((this.state = t.state),
|
|
n.forEach((t) => {
|
|
t.onStateChanged?.({
|
|
state: this.state,
|
|
messages: this.messages,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
}));
|
|
}),
|
|
);
|
|
}
|
|
prepareRunAgentInput(e) {
|
|
let t = nu(this.messages).filter((e) => "activity" !== e.role);
|
|
return {
|
|
threadId: this.threadId,
|
|
runId: e?.runId || (0, u.v4)(),
|
|
tools: nu(e?.tools ?? []),
|
|
context: nu(e?.context ?? []),
|
|
forwardedProps: nu(e?.forwardedProps ?? {}),
|
|
state: nu(this.state),
|
|
messages: t,
|
|
};
|
|
}
|
|
async onInitialize(e, t) {
|
|
let n = await nc(t, this.messages, this.state, (t, n, r) =>
|
|
t.onRunInitialized?.({
|
|
messages: n,
|
|
state: r,
|
|
agent: this,
|
|
input: e,
|
|
}),
|
|
);
|
|
(void 0 !== n.messages || void 0 !== n.state) &&
|
|
(n.messages &&
|
|
((this.messages = n.messages),
|
|
(e.messages = n.messages),
|
|
t.forEach((t) => {
|
|
t.onMessagesChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
})),
|
|
n.state &&
|
|
((this.state = n.state),
|
|
(e.state = n.state),
|
|
t.forEach((t) => {
|
|
t.onStateChanged?.({
|
|
state: this.state,
|
|
messages: this.messages,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
})));
|
|
}
|
|
onError(e, t, n) {
|
|
return eU(
|
|
nc(n, this.messages, this.state, (n, r, s) =>
|
|
n.onRunFailed?.({
|
|
error: t,
|
|
messages: r,
|
|
state: s,
|
|
agent: this,
|
|
input: e,
|
|
}),
|
|
),
|
|
).pipe(
|
|
e$((r) => {
|
|
if (
|
|
((void 0 !== r.messages || void 0 !== r.state) &&
|
|
(void 0 !== r.messages &&
|
|
((this.messages = r.messages),
|
|
n.forEach((t) => {
|
|
t.onMessagesChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
})),
|
|
void 0 !== r.state &&
|
|
((this.state = r.state),
|
|
n.forEach((t) => {
|
|
t.onStateChanged?.({
|
|
state: this.state,
|
|
messages: this.messages,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
}))),
|
|
!0 !== r.stopPropagation)
|
|
)
|
|
throw (console.error("Agent execution failed:", t), t);
|
|
return {};
|
|
}),
|
|
);
|
|
}
|
|
async onFinalize(e, t) {
|
|
let n = await nc(t, this.messages, this.state, (t, n, r) =>
|
|
t.onRunFinalized?.({
|
|
messages: n,
|
|
state: r,
|
|
agent: this,
|
|
input: e,
|
|
}),
|
|
);
|
|
(void 0 !== n.messages || void 0 !== n.state) &&
|
|
(void 0 !== n.messages &&
|
|
((this.messages = n.messages),
|
|
t.forEach((t) => {
|
|
t.onMessagesChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
})),
|
|
void 0 !== n.state &&
|
|
((this.state = n.state),
|
|
t.forEach((t) => {
|
|
t.onStateChanged?.({
|
|
state: this.state,
|
|
messages: this.messages,
|
|
agent: this,
|
|
input: e,
|
|
});
|
|
})));
|
|
}
|
|
clone() {
|
|
let e = Object.create(Object.getPrototypeOf(this));
|
|
return (
|
|
(e.agentId = this.agentId),
|
|
(e.description = this.description),
|
|
(e.threadId = this.threadId),
|
|
(e.messages = nu(this.messages)),
|
|
(e.state = nu(this.state)),
|
|
(e.debug = this.debug),
|
|
(e.isRunning = this.isRunning),
|
|
(e.subscribers = [...this.subscribers]),
|
|
(e.middlewares = [...this.middlewares]),
|
|
e
|
|
);
|
|
}
|
|
addMessage(e) {
|
|
this.messages.push(e),
|
|
(async () => {
|
|
for (let t of this.subscribers)
|
|
await t.onNewMessage?.({
|
|
message: e,
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
if ("assistant" === e.role && e.toolCalls)
|
|
for (let t of e.toolCalls)
|
|
for (let e of this.subscribers)
|
|
await e.onNewToolCall?.({
|
|
toolCall: t,
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
for (let e of this.subscribers)
|
|
await e.onMessagesChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
})();
|
|
}
|
|
addMessages(e) {
|
|
this.messages.push(...e),
|
|
(async () => {
|
|
for (let t of e) {
|
|
for (let e of this.subscribers)
|
|
await e.onNewMessage?.({
|
|
message: t,
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
if ("assistant" === t.role && t.toolCalls)
|
|
for (let e of t.toolCalls)
|
|
for (let t of this.subscribers)
|
|
await t.onNewToolCall?.({
|
|
toolCall: e,
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
}
|
|
for (let e of this.subscribers)
|
|
await e.onMessagesChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
})();
|
|
}
|
|
setMessages(e) {
|
|
(this.messages = nu(e)),
|
|
(async () => {
|
|
for (let e of this.subscribers)
|
|
await e.onMessagesChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
})();
|
|
}
|
|
setState(e) {
|
|
(this.state = nu(e)),
|
|
(async () => {
|
|
for (let e of this.subscribers)
|
|
await e.onStateChanged?.({
|
|
messages: this.messages,
|
|
state: this.state,
|
|
agent: this,
|
|
});
|
|
})();
|
|
}
|
|
legacy_to_be_removed_runAgentBridged(e) {
|
|
this.agentId = this.agentId ?? (0, u.v4)();
|
|
let t = this.prepareRunAgentInput(e);
|
|
return (
|
|
0 === this.middlewares.length
|
|
? this.run(t)
|
|
: this.middlewares
|
|
.reduceRight((e, t) => ({ run: (n) => t.run(n, e) }), this)
|
|
.run(t)
|
|
).pipe(
|
|
nP(this.debug),
|
|
nh(this.debug),
|
|
nx(this.threadId, t.runId, this.agentId),
|
|
(e) =>
|
|
e.pipe(
|
|
e$(
|
|
(e) => (
|
|
this.debug && console.debug("[LEGACY]:", JSON.stringify(e)),
|
|
e
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
},
|
|
nK = class extends nH {
|
|
requestInit(e) {
|
|
return {
|
|
method: "POST",
|
|
headers: {
|
|
...this.headers,
|
|
"Content-Type": "application/json",
|
|
Accept: "text/event-stream",
|
|
},
|
|
body: JSON.stringify(e),
|
|
signal: this.abortController.signal,
|
|
};
|
|
}
|
|
runAgent(e, t) {
|
|
return (
|
|
(this.abortController =
|
|
e?.abortController ?? new AbortController()),
|
|
super.runAgent(e, t)
|
|
);
|
|
}
|
|
abortRun() {
|
|
this.abortController.abort(), super.abortRun();
|
|
}
|
|
constructor(e) {
|
|
super(e),
|
|
(this.abortController = new AbortController()),
|
|
(this.url = e.url),
|
|
(this.headers = nu(e.headers ?? {}));
|
|
}
|
|
run(e) {
|
|
return ny(ng(this.url, this.requestInit(e)));
|
|
}
|
|
clone() {
|
|
let e = super.clone();
|
|
(e.url = this.url), (e.headers = nu(this.headers ?? {}));
|
|
let t = new AbortController(),
|
|
n = this.abortController.signal;
|
|
return n.aborted && t.abort(n.reason), (e.abortController = t), e;
|
|
}
|
|
};
|
|
function nB(e) {
|
|
let t = [],
|
|
n = new Map(),
|
|
r = new Map();
|
|
for (let s of e)
|
|
if (s.type === d.EventType.TEXT_MESSAGE_START) {
|
|
let e = s.messageId;
|
|
n.has(e) || n.set(e, { contents: [], otherEvents: [] }),
|
|
(n.get(e).start = s);
|
|
} else if (s.type === d.EventType.TEXT_MESSAGE_CONTENT) {
|
|
let e = s.messageId;
|
|
n.has(e) || n.set(e, { contents: [], otherEvents: [] }),
|
|
n.get(e).contents.push(s);
|
|
} else if (s.type === d.EventType.TEXT_MESSAGE_END) {
|
|
let e = s.messageId;
|
|
n.has(e) || n.set(e, { contents: [], otherEvents: [] });
|
|
let r = n.get(e);
|
|
(r.end = s), nJ(e, r, t), n.delete(e);
|
|
} else if (s.type === d.EventType.TOOL_CALL_START) {
|
|
let e = s.toolCallId;
|
|
r.has(e) || r.set(e, { args: [], otherEvents: [] }),
|
|
(r.get(e).start = s);
|
|
} else if (s.type === d.EventType.TOOL_CALL_ARGS) {
|
|
let e = s.toolCallId;
|
|
r.has(e) || r.set(e, { args: [], otherEvents: [] }),
|
|
r.get(e).args.push(s);
|
|
} else if (s.type === d.EventType.TOOL_CALL_END) {
|
|
let e = s.toolCallId;
|
|
r.has(e) || r.set(e, { args: [], otherEvents: [] });
|
|
let n = r.get(e);
|
|
(n.end = s), nX(e, n, t), r.delete(e);
|
|
} else {
|
|
let e = !1;
|
|
for (let [t, r] of n)
|
|
if (r.start && !r.end) {
|
|
r.otherEvents.push(s), (e = !0);
|
|
break;
|
|
}
|
|
if (!e) {
|
|
for (let [t, n] of r)
|
|
if (n.start && !n.end) {
|
|
n.otherEvents.push(s), (e = !0);
|
|
break;
|
|
}
|
|
}
|
|
e || t.push(s);
|
|
}
|
|
for (let [e, r] of n) nJ(e, r, t);
|
|
for (let [e, n] of r) nX(e, n, t);
|
|
return t;
|
|
}
|
|
function nJ(e, t, n) {
|
|
if ((t.start && n.push(t.start), t.contents.length > 0)) {
|
|
let r = t.contents.map((e) => e.delta).join(""),
|
|
s = {
|
|
type: d.EventType.TEXT_MESSAGE_CONTENT,
|
|
messageId: e,
|
|
delta: r,
|
|
};
|
|
n.push(s);
|
|
}
|
|
for (let e of (t.end && n.push(t.end), t.otherEvents)) n.push(e);
|
|
}
|
|
function nX(e, t, n) {
|
|
if ((t.start && n.push(t.start), t.args.length > 0)) {
|
|
let r = t.args.map((e) => e.delta).join(""),
|
|
s = { type: d.EventType.TOOL_CALL_ARGS, toolCallId: e, delta: r };
|
|
n.push(s);
|
|
}
|
|
for (let e of (t.end && n.push(t.end), t.otherEvents)) n.push(e);
|
|
}
|
|
e.s(
|
|
[
|
|
"AbstractAgent",
|
|
() => nH,
|
|
"BackwardCompatibility_0_0_39",
|
|
() => nZ,
|
|
"BackwardCompatibility_0_0_45",
|
|
() => nz,
|
|
"FilterToolCallsMiddleware",
|
|
() => nD,
|
|
"FunctionMiddleware",
|
|
() => nL,
|
|
"HttpAgent",
|
|
() => nK,
|
|
"Middleware",
|
|
() => nM,
|
|
"compactEvents",
|
|
() => nB,
|
|
"convertToLegacyEvents",
|
|
() => nx,
|
|
"defaultApplyEvents",
|
|
() => np,
|
|
"parseProtoStream",
|
|
() => nv,
|
|
"parseSSEStream",
|
|
() => nm,
|
|
"randomUUID",
|
|
() => nd,
|
|
"runHttpRequest",
|
|
() => ng,
|
|
"structuredClone_",
|
|
() => nu,
|
|
"transformChunks",
|
|
() => nP,
|
|
"transformHttpEventStream",
|
|
() => ny,
|
|
"verifyEvents",
|
|
() => nh,
|
|
],
|
|
64879,
|
|
);
|
|
};
|
|
|
|
export default moduleFactory;
|