@asgard-js/core 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/enum.d.ts +2 -0
- package/dist/constants/enum.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -98
- package/dist/index.mjs.map +1 -1
- package/dist/lib/channel.d.ts +12 -1
- package/dist/lib/channel.d.ts.map +1 -1
- package/dist/types/channel.d.ts +8 -0
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/sse-response.d.ts +12 -0
- package/dist/types/sse-response.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9,17 +9,17 @@ class te extends Error {
|
|
|
9
9
|
function wn(n) {
|
|
10
10
|
return n instanceof te;
|
|
11
11
|
}
|
|
12
|
-
var H = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n))(H || {}), d = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.MESSAGE_USER = "asgard.message.user", n.MESSAGE_THINKING_START = "asgard.message.thinking.start", n.MESSAGE_THINKING_DELTA = "asgard.message.thinking.delta", n.MESSAGE_THINKING_COMPLETE = "asgard.message.thinking.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.SUBAGENT_START = "asgard.subagent.start", n.SUBAGENT_COMPLETE = "asgard.subagent.complete", n.CHANNEL_TITLE_UPDATE = "asgard.channel.title.update", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), Ke = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ke || {}), Fe = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n.CHART = "CHART", n.TABLE = "TABLE", n.ATTACHMENT = "ATTACHMENT", n))(Fe || {}),
|
|
13
|
-
return
|
|
12
|
+
var H = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n))(H || {}), d = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.MESSAGE_USER = "asgard.message.user", n.MESSAGE_THINKING_START = "asgard.message.thinking.start", n.MESSAGE_THINKING_DELTA = "asgard.message.thinking.delta", n.MESSAGE_THINKING_COMPLETE = "asgard.message.thinking.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.SUBAGENT_START = "asgard.subagent.start", n.SUBAGENT_COMPLETE = "asgard.subagent.complete", n.CHANNEL_TITLE_UPDATE = "asgard.channel.title.update", n.SANDBOX_LAUNCH = "asgard.sandbox.launch", n.SANDBOX_READY = "asgard.sandbox.ready", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), Ke = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ke || {}), Fe = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n.CHART = "CHART", n.TABLE = "TABLE", n.ATTACHMENT = "ATTACHMENT", n))(Fe || {}), J = function(n, t) {
|
|
13
|
+
return J = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
|
|
14
14
|
e.__proto__ = r;
|
|
15
15
|
} || function(e, r) {
|
|
16
16
|
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
|
|
17
|
-
},
|
|
17
|
+
}, J(n, t);
|
|
18
18
|
};
|
|
19
19
|
function w(n, t) {
|
|
20
20
|
if (typeof t != "function" && t !== null)
|
|
21
21
|
throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
|
22
|
-
|
|
22
|
+
J(n, t);
|
|
23
23
|
function e() {
|
|
24
24
|
this.constructor = n;
|
|
25
25
|
}
|
|
@@ -147,7 +147,7 @@ function $(n, t, e) {
|
|
|
147
147
|
function L(n) {
|
|
148
148
|
return this instanceof L ? (this.v = n, this) : new L(n);
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function Ye(n, t, e) {
|
|
151
151
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
152
152
|
var r = e.apply(n, t || []), s, i = [];
|
|
153
153
|
return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", o), s[Symbol.asyncIterator] = function() {
|
|
@@ -185,7 +185,7 @@ function qe(n, t, e) {
|
|
|
185
185
|
l(f), i.shift(), i.length && u(i[0][0], i[0][1]);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function qe(n) {
|
|
189
189
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
190
190
|
var t = n[Symbol.asyncIterator], e;
|
|
191
191
|
return t ? t.call(n) : (n = typeof k == "function" ? k(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
|
|
@@ -323,9 +323,9 @@ function Se(n) {
|
|
|
323
323
|
function oe(n) {
|
|
324
324
|
m(n) ? n() : n.unsubscribe();
|
|
325
325
|
}
|
|
326
|
-
var
|
|
326
|
+
var Ve = {
|
|
327
327
|
Promise: void 0
|
|
328
|
-
},
|
|
328
|
+
}, Xe = {
|
|
329
329
|
setTimeout: function(n, t) {
|
|
330
330
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
331
331
|
e[r - 2] = arguments[r];
|
|
@@ -337,11 +337,11 @@ var Ye = {
|
|
|
337
337
|
delegate: void 0
|
|
338
338
|
};
|
|
339
339
|
function Ie(n) {
|
|
340
|
-
|
|
340
|
+
Xe.setTimeout(function() {
|
|
341
341
|
throw n;
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function Q() {
|
|
345
345
|
}
|
|
346
346
|
function G(n) {
|
|
347
347
|
n();
|
|
@@ -353,7 +353,7 @@ var ne = (function(n) {
|
|
|
353
353
|
return r.isStopped = !1, e ? (r.destination = e, Se(e) && e.add(r)) : r.destination = Je, r;
|
|
354
354
|
}
|
|
355
355
|
return t.create = function(e, r, s) {
|
|
356
|
-
return new
|
|
356
|
+
return new Z(e, r, s);
|
|
357
357
|
}, t.prototype.next = function(e) {
|
|
358
358
|
this.isStopped || this._next(e);
|
|
359
359
|
}, t.prototype.error = function(e) {
|
|
@@ -377,7 +377,7 @@ var ne = (function(n) {
|
|
|
377
377
|
this.unsubscribe();
|
|
378
378
|
}
|
|
379
379
|
}, t;
|
|
380
|
-
})(U),
|
|
380
|
+
})(U), We = (function() {
|
|
381
381
|
function n(t) {
|
|
382
382
|
this.partialObserver = t;
|
|
383
383
|
}
|
|
@@ -408,7 +408,7 @@ var ne = (function(n) {
|
|
|
408
408
|
D(e);
|
|
409
409
|
}
|
|
410
410
|
}, n;
|
|
411
|
-
})(),
|
|
411
|
+
})(), Z = (function(n) {
|
|
412
412
|
w(t, n);
|
|
413
413
|
function t(e, r, s) {
|
|
414
414
|
var i = n.call(this) || this, o;
|
|
@@ -416,7 +416,7 @@ var ne = (function(n) {
|
|
|
416
416
|
next: e ?? void 0,
|
|
417
417
|
error: r ?? void 0,
|
|
418
418
|
complete: s ?? void 0
|
|
419
|
-
} : o = e, i.destination = new
|
|
419
|
+
} : o = e, i.destination = new We(o), i;
|
|
420
420
|
}
|
|
421
421
|
return t;
|
|
422
422
|
})(ne);
|
|
@@ -428,9 +428,9 @@ function ze(n) {
|
|
|
428
428
|
}
|
|
429
429
|
var Je = {
|
|
430
430
|
closed: !0,
|
|
431
|
-
next:
|
|
431
|
+
next: Q,
|
|
432
432
|
error: ze,
|
|
433
|
-
complete:
|
|
433
|
+
complete: Q
|
|
434
434
|
}, re = (function() {
|
|
435
435
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
436
436
|
})();
|
|
@@ -452,7 +452,7 @@ var S = (function() {
|
|
|
452
452
|
var e = new n();
|
|
453
453
|
return e.source = this, e.operator = t, e;
|
|
454
454
|
}, n.prototype.subscribe = function(t, e, r) {
|
|
455
|
-
var s = this, i = et(t) ? t : new
|
|
455
|
+
var s = this, i = et(t) ? t : new Z(t, e, r);
|
|
456
456
|
return G(function() {
|
|
457
457
|
var o = s, a = o.operator, u = o.source;
|
|
458
458
|
i.add(a ? a.call(i, u) : u ? s._subscribe(i) : s._trySubscribe(i));
|
|
@@ -466,7 +466,7 @@ var S = (function() {
|
|
|
466
466
|
}, n.prototype.forEach = function(t, e) {
|
|
467
467
|
var r = this;
|
|
468
468
|
return e = ae(e), new e(function(s, i) {
|
|
469
|
-
var o = new
|
|
469
|
+
var o = new Z({
|
|
470
470
|
next: function(a) {
|
|
471
471
|
try {
|
|
472
472
|
t(a);
|
|
@@ -506,7 +506,7 @@ var S = (function() {
|
|
|
506
506
|
})();
|
|
507
507
|
function ae(n) {
|
|
508
508
|
var t;
|
|
509
|
-
return (t = n ??
|
|
509
|
+
return (t = n ?? Ve.Promise) !== null && t !== void 0 ? t : Promise;
|
|
510
510
|
}
|
|
511
511
|
function Ze(n) {
|
|
512
512
|
return n && m(n.next) && m(n.error) && m(n.complete);
|
|
@@ -670,7 +670,7 @@ var nt = (function(n) {
|
|
|
670
670
|
var r, s;
|
|
671
671
|
return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : be;
|
|
672
672
|
}, t;
|
|
673
|
-
})(se),
|
|
673
|
+
})(se), P = (function(n) {
|
|
674
674
|
w(t, n);
|
|
675
675
|
function t(e) {
|
|
676
676
|
var r = n.call(this) || this;
|
|
@@ -813,21 +813,21 @@ function Ae(n) {
|
|
|
813
813
|
function _e(n) {
|
|
814
814
|
return m(n[re]);
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function xe(n) {
|
|
817
817
|
return Symbol.asyncIterator && m(n?.[Symbol.asyncIterator]);
|
|
818
818
|
}
|
|
819
|
-
function
|
|
819
|
+
function Me(n) {
|
|
820
820
|
return new TypeError("You provided " + (n !== null && typeof n == "object" ? "an invalid object" : "'" + n + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
821
821
|
}
|
|
822
822
|
function dt() {
|
|
823
823
|
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
|
824
824
|
}
|
|
825
|
-
var
|
|
826
|
-
function
|
|
827
|
-
return m(n?.[
|
|
825
|
+
var Pe = dt();
|
|
826
|
+
function Le(n) {
|
|
827
|
+
return m(n?.[Pe]);
|
|
828
828
|
}
|
|
829
|
-
function
|
|
830
|
-
return
|
|
829
|
+
function ke(n) {
|
|
830
|
+
return Ye(this, arguments, function() {
|
|
831
831
|
var e, r, s, i;
|
|
832
832
|
return ve(this, function(o) {
|
|
833
833
|
switch (o.label) {
|
|
@@ -857,10 +857,10 @@ function Pe(n) {
|
|
|
857
857
|
});
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function Ne(n) {
|
|
861
861
|
return m(n?.getReader);
|
|
862
862
|
}
|
|
863
|
-
function
|
|
863
|
+
function M(n) {
|
|
864
864
|
if (n instanceof S)
|
|
865
865
|
return n;
|
|
866
866
|
if (n != null) {
|
|
@@ -870,14 +870,14 @@ function x(n) {
|
|
|
870
870
|
return ft(n);
|
|
871
871
|
if (Ae(n))
|
|
872
872
|
return pt(n);
|
|
873
|
-
if (
|
|
874
|
-
return
|
|
875
|
-
if (
|
|
873
|
+
if (xe(n))
|
|
874
|
+
return Ue(n);
|
|
875
|
+
if (Le(n))
|
|
876
876
|
return gt(n);
|
|
877
|
-
if (
|
|
877
|
+
if (Ne(n))
|
|
878
878
|
return mt(n);
|
|
879
879
|
}
|
|
880
|
-
throw
|
|
880
|
+
throw Me(n);
|
|
881
881
|
}
|
|
882
882
|
function ht(n) {
|
|
883
883
|
return new S(function(t) {
|
|
@@ -924,7 +924,7 @@ function gt(n) {
|
|
|
924
924
|
t.complete();
|
|
925
925
|
});
|
|
926
926
|
}
|
|
927
|
-
function
|
|
927
|
+
function Ue(n) {
|
|
928
928
|
return new S(function(t) {
|
|
929
929
|
vt(n, t).catch(function(e) {
|
|
930
930
|
return t.error(e);
|
|
@@ -932,7 +932,7 @@ function Ne(n) {
|
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
934
|
function mt(n) {
|
|
935
|
-
return
|
|
935
|
+
return Ue(ke(n));
|
|
936
936
|
}
|
|
937
937
|
function vt(n, t) {
|
|
938
938
|
var e, r, s, i;
|
|
@@ -941,7 +941,7 @@ function vt(n, t) {
|
|
|
941
941
|
return ve(this, function(u) {
|
|
942
942
|
switch (u.label) {
|
|
943
943
|
case 0:
|
|
944
|
-
u.trys.push([0, 5, 6, 11]), e =
|
|
944
|
+
u.trys.push([0, 5, 6, 11]), e = qe(n), u.label = 1;
|
|
945
945
|
case 1:
|
|
946
946
|
return [4, e.next()];
|
|
947
947
|
case 2:
|
|
@@ -1005,10 +1005,10 @@ function $e(n, t) {
|
|
|
1005
1005
|
});
|
|
1006
1006
|
}
|
|
1007
1007
|
function yt(n, t) {
|
|
1008
|
-
return
|
|
1008
|
+
return M(n).pipe($e(t), Re(t));
|
|
1009
1009
|
}
|
|
1010
1010
|
function bt(n, t) {
|
|
1011
|
-
return
|
|
1011
|
+
return M(n).pipe($e(t), Re(t));
|
|
1012
1012
|
}
|
|
1013
1013
|
function St(n, t) {
|
|
1014
1014
|
return new S(function(e) {
|
|
@@ -1022,7 +1022,7 @@ function It(n, t) {
|
|
|
1022
1022
|
return new S(function(e) {
|
|
1023
1023
|
var r;
|
|
1024
1024
|
return C(e, t, function() {
|
|
1025
|
-
r = n[
|
|
1025
|
+
r = n[Pe](), C(e, t, function() {
|
|
1026
1026
|
var s, i, o;
|
|
1027
1027
|
try {
|
|
1028
1028
|
s = r.next(), i = s.value, o = s.done;
|
|
@@ -1052,7 +1052,7 @@ function je(n, t) {
|
|
|
1052
1052
|
});
|
|
1053
1053
|
}
|
|
1054
1054
|
function Et(n, t) {
|
|
1055
|
-
return je(
|
|
1055
|
+
return je(ke(n), t);
|
|
1056
1056
|
}
|
|
1057
1057
|
function wt(n, t) {
|
|
1058
1058
|
if (n != null) {
|
|
@@ -1062,17 +1062,17 @@ function wt(n, t) {
|
|
|
1062
1062
|
return St(n, t);
|
|
1063
1063
|
if (Ae(n))
|
|
1064
1064
|
return bt(n, t);
|
|
1065
|
-
if (
|
|
1065
|
+
if (xe(n))
|
|
1066
1066
|
return je(n, t);
|
|
1067
|
-
if (
|
|
1067
|
+
if (Le(n))
|
|
1068
1068
|
return It(n, t);
|
|
1069
|
-
if (
|
|
1069
|
+
if (Ne(n))
|
|
1070
1070
|
return Et(n, t);
|
|
1071
1071
|
}
|
|
1072
|
-
throw
|
|
1072
|
+
throw Me(n);
|
|
1073
1073
|
}
|
|
1074
1074
|
function ie(n, t) {
|
|
1075
|
-
return t ? wt(n, t) :
|
|
1075
|
+
return t ? wt(n, t) : M(n);
|
|
1076
1076
|
}
|
|
1077
1077
|
function Tt() {
|
|
1078
1078
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
@@ -1083,7 +1083,7 @@ function Tt() {
|
|
|
1083
1083
|
function Ct(n) {
|
|
1084
1084
|
return n instanceof Date && !isNaN(n);
|
|
1085
1085
|
}
|
|
1086
|
-
function
|
|
1086
|
+
function N(n, t) {
|
|
1087
1087
|
return A(function(e, r) {
|
|
1088
1088
|
var s = 0;
|
|
1089
1089
|
e.subscribe(O(r, function(i) {
|
|
@@ -1096,18 +1096,18 @@ function At(n, t) {
|
|
|
1096
1096
|
return Ot(t) ? n.apply(void 0, $([], R(t))) : n(t);
|
|
1097
1097
|
}
|
|
1098
1098
|
function _t(n) {
|
|
1099
|
-
return
|
|
1099
|
+
return N(function(t) {
|
|
1100
1100
|
return At(n, t);
|
|
1101
1101
|
});
|
|
1102
1102
|
}
|
|
1103
|
-
var
|
|
1104
|
-
function
|
|
1103
|
+
var xt = Array.isArray, Mt = Object.getPrototypeOf, Pt = Object.prototype, Lt = Object.keys;
|
|
1104
|
+
function kt(n) {
|
|
1105
1105
|
if (n.length === 1) {
|
|
1106
1106
|
var t = n[0];
|
|
1107
|
-
if (
|
|
1107
|
+
if (xt(t))
|
|
1108
1108
|
return { args: t, keys: null };
|
|
1109
|
-
if (
|
|
1110
|
-
var e =
|
|
1109
|
+
if (Nt(t)) {
|
|
1110
|
+
var e = Lt(t);
|
|
1111
1111
|
return {
|
|
1112
1112
|
args: e.map(function(r) {
|
|
1113
1113
|
return t[r];
|
|
@@ -1118,10 +1118,10 @@ function Pt(n) {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
return { args: n, keys: null };
|
|
1120
1120
|
}
|
|
1121
|
-
function
|
|
1122
|
-
return n && typeof n == "object" &&
|
|
1121
|
+
function Nt(n) {
|
|
1122
|
+
return n && typeof n == "object" && Mt(n) === Pt;
|
|
1123
1123
|
}
|
|
1124
|
-
function
|
|
1124
|
+
function Ut(n, t) {
|
|
1125
1125
|
return n.reduce(function(e, r, s) {
|
|
1126
1126
|
return e[r] = t[s], e;
|
|
1127
1127
|
}, {});
|
|
@@ -1129,11 +1129,11 @@ function Nt(n, t) {
|
|
|
1129
1129
|
function Rt() {
|
|
1130
1130
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1131
1131
|
n[t] = arguments[t];
|
|
1132
|
-
var e = Ce(n), r = lt(n), s =
|
|
1132
|
+
var e = Ce(n), r = lt(n), s = kt(n), i = s.args, o = s.keys;
|
|
1133
1133
|
if (i.length === 0)
|
|
1134
1134
|
return ie([], e);
|
|
1135
1135
|
var a = new S($t(i, e, o ? function(u) {
|
|
1136
|
-
return
|
|
1136
|
+
return Ut(o, u);
|
|
1137
1137
|
} : q));
|
|
1138
1138
|
return r ? a.pipe(_t(r)) : a;
|
|
1139
1139
|
}
|
|
@@ -1165,7 +1165,7 @@ function jt(n, t, e, r, s, i, o, a) {
|
|
|
1165
1165
|
}, f = function(p) {
|
|
1166
1166
|
c++;
|
|
1167
1167
|
var _ = !1;
|
|
1168
|
-
|
|
1168
|
+
M(e(p, h++)).subscribe(O(t, function(I) {
|
|
1169
1169
|
t.next(I);
|
|
1170
1170
|
}, function() {
|
|
1171
1171
|
_ = !0;
|
|
@@ -1174,13 +1174,13 @@ function jt(n, t, e, r, s, i, o, a) {
|
|
|
1174
1174
|
try {
|
|
1175
1175
|
c--;
|
|
1176
1176
|
for (var I = function() {
|
|
1177
|
-
var
|
|
1178
|
-
o || f(
|
|
1177
|
+
var x = u.shift();
|
|
1178
|
+
o || f(x);
|
|
1179
1179
|
}; u.length && c < r; )
|
|
1180
1180
|
I();
|
|
1181
1181
|
v();
|
|
1182
|
-
} catch (
|
|
1183
|
-
t.error(
|
|
1182
|
+
} catch (x) {
|
|
1183
|
+
t.error(x);
|
|
1184
1184
|
}
|
|
1185
1185
|
}));
|
|
1186
1186
|
};
|
|
@@ -1191,9 +1191,9 @@ function jt(n, t, e, r, s, i, o, a) {
|
|
|
1191
1191
|
}
|
|
1192
1192
|
function B(n, t, e) {
|
|
1193
1193
|
return e === void 0 && (e = 1 / 0), m(t) ? B(function(r, s) {
|
|
1194
|
-
return
|
|
1194
|
+
return N(function(i, o) {
|
|
1195
1195
|
return t(r, i, s, o);
|
|
1196
|
-
})(
|
|
1196
|
+
})(M(n(r, s)));
|
|
1197
1197
|
}, e) : (typeof t == "number" && (e = t), A(function(r, s) {
|
|
1198
1198
|
return jt(r, s, n, e);
|
|
1199
1199
|
}));
|
|
@@ -1224,13 +1224,13 @@ function Gt(n) {
|
|
|
1224
1224
|
});
|
|
1225
1225
|
}
|
|
1226
1226
|
function Kt(n) {
|
|
1227
|
-
return
|
|
1227
|
+
return N(function() {
|
|
1228
1228
|
return n;
|
|
1229
1229
|
});
|
|
1230
1230
|
}
|
|
1231
1231
|
function Ft(n, t) {
|
|
1232
1232
|
return B(function(e, r) {
|
|
1233
|
-
return
|
|
1233
|
+
return M(n(e, r)).pipe(Gt(1), Kt(e));
|
|
1234
1234
|
});
|
|
1235
1235
|
}
|
|
1236
1236
|
function Bt(n, t) {
|
|
@@ -1240,8 +1240,8 @@ function Bt(n, t) {
|
|
|
1240
1240
|
return e;
|
|
1241
1241
|
});
|
|
1242
1242
|
}
|
|
1243
|
-
function
|
|
1244
|
-
return t === void 0 && (t = q), n = n ??
|
|
1243
|
+
function Y(n, t) {
|
|
1244
|
+
return t === void 0 && (t = q), n = n ?? Yt, A(function(e, r) {
|
|
1245
1245
|
var s, i = !0;
|
|
1246
1246
|
e.subscribe(O(r, function(o) {
|
|
1247
1247
|
var a = t(o);
|
|
@@ -1249,10 +1249,10 @@ function Z(n, t) {
|
|
|
1249
1249
|
}));
|
|
1250
1250
|
});
|
|
1251
1251
|
}
|
|
1252
|
-
function
|
|
1252
|
+
function Yt(n, t) {
|
|
1253
1253
|
return n === t;
|
|
1254
1254
|
}
|
|
1255
|
-
function
|
|
1255
|
+
function qt(n) {
|
|
1256
1256
|
return A(function(t, e) {
|
|
1257
1257
|
try {
|
|
1258
1258
|
t.subscribe(e);
|
|
@@ -1261,20 +1261,20 @@ function Vt(n) {
|
|
|
1261
1261
|
}
|
|
1262
1262
|
});
|
|
1263
1263
|
}
|
|
1264
|
-
function
|
|
1264
|
+
function Vt(n) {
|
|
1265
1265
|
return A(function(t, e) {
|
|
1266
|
-
|
|
1266
|
+
M(n).subscribe(O(e, function() {
|
|
1267
1267
|
return e.complete();
|
|
1268
|
-
},
|
|
1268
|
+
}, Q)), !e.closed && t.subscribe(e);
|
|
1269
1269
|
});
|
|
1270
1270
|
}
|
|
1271
|
-
async function
|
|
1271
|
+
async function Xt(n, t) {
|
|
1272
1272
|
const e = n.getReader();
|
|
1273
1273
|
let r;
|
|
1274
1274
|
for (; !(r = await e.read()).done; )
|
|
1275
1275
|
t(r.value);
|
|
1276
1276
|
}
|
|
1277
|
-
function
|
|
1277
|
+
function Wt(n) {
|
|
1278
1278
|
let t, e, r, s = !1;
|
|
1279
1279
|
return function(o) {
|
|
1280
1280
|
t === void 0 ? (t = o, e = 0, r = -1) : t = Jt(t, o);
|
|
@@ -1360,30 +1360,30 @@ function en(n, t) {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
u || document.addEventListener("visibilitychange", p);
|
|
1362
1362
|
let _ = Zt, I = 0;
|
|
1363
|
-
function
|
|
1363
|
+
function x() {
|
|
1364
1364
|
document.removeEventListener("visibilitychange", p), window.clearTimeout(I), f.abort();
|
|
1365
1365
|
}
|
|
1366
1366
|
e?.addEventListener("abort", () => {
|
|
1367
|
-
|
|
1367
|
+
x(), g();
|
|
1368
1368
|
});
|
|
1369
1369
|
const He = c ?? window.fetch, Ge = s ?? tn;
|
|
1370
1370
|
async function V() {
|
|
1371
|
-
var
|
|
1371
|
+
var X;
|
|
1372
1372
|
f = new AbortController();
|
|
1373
1373
|
try {
|
|
1374
1374
|
const j = await He(n, Object.assign(Object.assign({}, h), { headers: l, signal: f.signal }));
|
|
1375
|
-
await Ge(j), await
|
|
1375
|
+
await Ge(j), await Xt(j.body, Wt(zt((T) => {
|
|
1376
1376
|
T ? l[fe] = T : delete l[fe];
|
|
1377
1377
|
}, (T) => {
|
|
1378
1378
|
_ = T;
|
|
1379
|
-
}, i))), o?.(),
|
|
1379
|
+
}, i))), o?.(), x(), g();
|
|
1380
1380
|
} catch (j) {
|
|
1381
1381
|
if (!f.signal.aborted)
|
|
1382
1382
|
try {
|
|
1383
|
-
const T = (
|
|
1383
|
+
const T = (X = a?.(j)) !== null && X !== void 0 ? X : _;
|
|
1384
1384
|
window.clearTimeout(I), I = window.setTimeout(V, T);
|
|
1385
1385
|
} catch (T) {
|
|
1386
|
-
|
|
1386
|
+
x(), v(T);
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
@@ -1598,10 +1598,10 @@ class Tn {
|
|
|
1598
1598
|
// run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
|
|
1599
1599
|
// create-sse-observable); a no-cursor failure surfaces via `error` below.
|
|
1600
1600
|
Ht((r) => Tt(r).pipe(Bt(e?.delayTime ?? 50))),
|
|
1601
|
-
|
|
1601
|
+
Vt(this.destroy$),
|
|
1602
1602
|
// Settle the run accounting on every termination path — complete, error, AND a user-initiated
|
|
1603
1603
|
// unsubscribe (stop-generation aborts the connection without a terminal event).
|
|
1604
|
-
|
|
1604
|
+
qt(() => this.onRunSettled())
|
|
1605
1605
|
).subscribe({
|
|
1606
1606
|
next: (r) => {
|
|
1607
1607
|
this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
|
|
@@ -1718,15 +1718,15 @@ for (let n = 0; n < 256; ++n)
|
|
|
1718
1718
|
function rn(n, t = 0) {
|
|
1719
1719
|
return (b[n[t + 0]] + b[n[t + 1]] + b[n[t + 2]] + b[n[t + 3]] + "-" + b[n[t + 4]] + b[n[t + 5]] + "-" + b[n[t + 6]] + b[n[t + 7]] + "-" + b[n[t + 8]] + b[n[t + 9]] + "-" + b[n[t + 10]] + b[n[t + 11]] + b[n[t + 12]] + b[n[t + 13]] + b[n[t + 14]] + b[n[t + 15]]).toLowerCase();
|
|
1720
1720
|
}
|
|
1721
|
-
let
|
|
1721
|
+
let z;
|
|
1722
1722
|
const sn = new Uint8Array(16);
|
|
1723
1723
|
function on() {
|
|
1724
|
-
if (!
|
|
1724
|
+
if (!z) {
|
|
1725
1725
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1726
1726
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1727
|
-
|
|
1727
|
+
z = crypto.getRandomValues.bind(crypto);
|
|
1728
1728
|
}
|
|
1729
|
-
return
|
|
1729
|
+
return z(sn);
|
|
1730
1730
|
}
|
|
1731
1731
|
const an = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ge = { randomUUID: an };
|
|
1732
1732
|
function cn(n, t, e) {
|
|
@@ -2155,9 +2155,9 @@ function In(n, t) {
|
|
|
2155
2155
|
});
|
|
2156
2156
|
}
|
|
2157
2157
|
function En(n) {
|
|
2158
|
-
const t = new
|
|
2159
|
-
return r.add(n.pipe(
|
|
2160
|
-
n.pipe(
|
|
2158
|
+
const t = new P([]), e = new P([]), r = new U();
|
|
2159
|
+
return r.add(n.pipe(N(vn), Y(bn)).subscribe(t)), r.add(
|
|
2160
|
+
n.pipe(N(yn), Y(In)).subscribe(e)
|
|
2161
2161
|
), {
|
|
2162
2162
|
tasks$: t.asObservable(),
|
|
2163
2163
|
subagents$: e.asObservable(),
|
|
@@ -2173,6 +2173,7 @@ class K {
|
|
|
2173
2173
|
isConnecting$;
|
|
2174
2174
|
conversation$;
|
|
2175
2175
|
channelTitleSubject;
|
|
2176
|
+
sandboxPhaseSubject;
|
|
2176
2177
|
derivedStores;
|
|
2177
2178
|
statesObserver;
|
|
2178
2179
|
statesSubscription;
|
|
@@ -2182,6 +2183,8 @@ class K {
|
|
|
2182
2183
|
subagents$;
|
|
2183
2184
|
/** Reactive channel title store (F-016): seeded from metadata, updated by `title.update`; replay-safe. */
|
|
2184
2185
|
channelTitle$;
|
|
2186
|
+
/** Reactive sandbox cold-start phase store (F-018): per-slice, derived from the last sandbox event; replay-safe. */
|
|
2187
|
+
sandboxPhase$;
|
|
2185
2188
|
currentUserMessageId;
|
|
2186
2189
|
// The most-recently-sent user message id. Unlike currentUserMessageId (which
|
|
2187
2190
|
// is cleared once a traceId is attached), this is kept across the SSE
|
|
@@ -2197,7 +2200,7 @@ class K {
|
|
|
2197
2200
|
throw new Error("client must be required");
|
|
2198
2201
|
if (!t.customChannelId)
|
|
2199
2202
|
throw new Error("customChannelId must be required");
|
|
2200
|
-
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new
|
|
2203
|
+
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new P(!1), this.conversation$ = new P(t.conversation), this.channelTitleSubject = new P(t.channelTitle ?? null), this.sandboxPhaseSubject = new P("idle"), this.derivedStores = En(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(Y()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(Y()), this.statesObserver = t.statesObserver;
|
|
2201
2204
|
}
|
|
2202
2205
|
/** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2203
2206
|
getTasks() {
|
|
@@ -2211,6 +2214,10 @@ class K {
|
|
|
2211
2214
|
getChannelTitle() {
|
|
2212
2215
|
return this.channelTitleSubject.value;
|
|
2213
2216
|
}
|
|
2217
|
+
/** Current sandbox phase snapshot (F-018) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2218
|
+
getSandboxPhase() {
|
|
2219
|
+
return this.sandboxPhaseSubject.value;
|
|
2220
|
+
}
|
|
2214
2221
|
/** Seed / override the channel title (F-016) — used by the join-restore metadata seed (F-015). */
|
|
2215
2222
|
setChannelTitle(t) {
|
|
2216
2223
|
this.channelTitleSubject.next(t);
|
|
@@ -2248,14 +2255,16 @@ class K {
|
|
|
2248
2255
|
this.conversation$,
|
|
2249
2256
|
this.derivedStores.tasks$,
|
|
2250
2257
|
this.derivedStores.subagents$,
|
|
2251
|
-
this.channelTitle
|
|
2258
|
+
this.channelTitle$,
|
|
2259
|
+
this.sandboxPhase$
|
|
2252
2260
|
]).pipe(
|
|
2253
|
-
|
|
2261
|
+
N(([t, e, r, s, i, o]) => ({
|
|
2254
2262
|
isConnecting: t,
|
|
2255
2263
|
conversation: e,
|
|
2256
2264
|
tasks: r,
|
|
2257
2265
|
subagents: s,
|
|
2258
|
-
channelTitle: i
|
|
2266
|
+
channelTitle: i,
|
|
2267
|
+
sandboxPhase: o
|
|
2259
2268
|
}))
|
|
2260
2269
|
).subscribe(this.statesObserver);
|
|
2261
2270
|
}
|
|
@@ -2273,6 +2282,25 @@ class K {
|
|
|
2273
2282
|
}
|
|
2274
2283
|
return t;
|
|
2275
2284
|
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Advance the sandbox phase store from an incoming event's type (F-018). Only sandbox / run-boundary
|
|
2287
|
+
* events move it; every other event is a no-op, so `distinctUntilChanged` suppresses re-emission on
|
|
2288
|
+
* high-frequency message deltas.
|
|
2289
|
+
*/
|
|
2290
|
+
updateSandboxPhase(t) {
|
|
2291
|
+
switch (t) {
|
|
2292
|
+
case d.SANDBOX_LAUNCH:
|
|
2293
|
+
this.sandboxPhaseSubject.next("launching");
|
|
2294
|
+
break;
|
|
2295
|
+
case d.SANDBOX_READY:
|
|
2296
|
+
this.sandboxPhaseSubject.next("ready");
|
|
2297
|
+
break;
|
|
2298
|
+
case d.INIT:
|
|
2299
|
+
case d.ERROR:
|
|
2300
|
+
this.sandboxPhaseSubject.next("idle");
|
|
2301
|
+
break;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2276
2304
|
/**
|
|
2277
2305
|
* The SSE run handlers shared by every run kind (POST send/reset and GET rejoin): fold each frame
|
|
2278
2306
|
* through the conversation reducer, keep the title store in sync, attach the traceId to the pending
|
|
@@ -2284,7 +2312,7 @@ class K {
|
|
|
2284
2312
|
onSseMessage: (s) => {
|
|
2285
2313
|
if (t?.onSseMessage?.(s), s.eventType === d.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
|
|
2286
2314
|
s.fact.channelTitleUpdate.title
|
|
2287
|
-
), this.currentUserMessageId && s.traceId) {
|
|
2315
|
+
), this.updateSandboxPhase(s.eventType), this.currentUserMessageId && s.traceId) {
|
|
2288
2316
|
const i = new Map(this.conversation$.value.messages), o = i.get(this.currentUserMessageId);
|
|
2289
2317
|
o && o.type === "user" && (i.set(this.currentUserMessageId, {
|
|
2290
2318
|
...o,
|
|
@@ -2380,7 +2408,7 @@ class K {
|
|
|
2380
2408
|
this.currentRun && (this.currentRun.unsubscribe(), this.currentRun = void 0, this.isConnecting$.next(!1), this.currentUserMessageId = void 0, this.conversation$.next(this.conversation$.value.cancelInFlightToolCalls()));
|
|
2381
2409
|
}
|
|
2382
2410
|
close() {
|
|
2383
|
-
this.currentRun?.unsubscribe(), this.currentRun = void 0, this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2411
|
+
this.currentRun?.unsubscribe(), this.currentRun = void 0, this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.sandboxPhaseSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2384
2412
|
}
|
|
2385
2413
|
}
|
|
2386
2414
|
export {
|