@asgard-js/core 0.3.11 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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 || {}), z = function(n, t) {
13
- return z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
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
- }, z(n, t);
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
- z(n, t);
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 qe(n, t, e) {
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 Ve(n) {
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() {
@@ -228,7 +228,7 @@ function F(n, t) {
228
228
  0 <= e && n.splice(e, 1);
229
229
  }
230
230
  }
231
- var U = (function() {
231
+ var N = (function() {
232
232
  function n(t) {
233
233
  this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
234
234
  }
@@ -316,16 +316,16 @@ var U = (function() {
316
316
  var t = new n();
317
317
  return t.closed = !0, t;
318
318
  })(), n;
319
- })(), be = U.EMPTY;
319
+ })(), be = N.EMPTY;
320
320
  function Se(n) {
321
- return n instanceof U || n && "closed" in n && m(n.remove) && m(n.add) && m(n.unsubscribe);
321
+ return n instanceof N || n && "closed" in n && m(n.remove) && m(n.add) && m(n.unsubscribe);
322
322
  }
323
323
  function oe(n) {
324
324
  m(n) ? n() : n.unsubscribe();
325
325
  }
326
- var Ye = {
326
+ var Ve = {
327
327
  Promise: void 0
328
- }, We = {
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
- We.setTimeout(function() {
340
+ Xe.setTimeout(function() {
341
341
  throw n;
342
342
  });
343
343
  }
344
- function J() {
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 Q(e, r, s);
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), Xe = (function() {
380
+ })(N), 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
- })(), Q = (function(n) {
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 Xe(o), i;
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: J,
431
+ next: Q,
432
432
  error: ze,
433
- complete: J
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 Q(t, e, r);
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 Q({
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 ?? Ye.Promise) !== null && t !== void 0 ? t : Promise;
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);
@@ -639,7 +639,7 @@ var nt = (function(n) {
639
639
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
640
640
  }, t.prototype._innerSubscribe = function(e) {
641
641
  var r = this, s = this, i = s.hasError, o = s.isStopped, a = s.observers;
642
- return i || o ? be : (this.currentObservers = null, a.push(e), new U(function() {
642
+ return i || o ? be : (this.currentObservers = null, a.push(e), new N(function() {
643
643
  r.currentObservers = null, F(a, e);
644
644
  }));
645
645
  }, t.prototype._checkFinalizedStatuses = function(e) {
@@ -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), N = (function(n) {
673
+ })(se), P = (function(n) {
674
674
  w(t, n);
675
675
  function t(e) {
676
676
  var r = n.call(this) || this;
@@ -705,7 +705,7 @@ var nt = (function(n) {
705
705
  return t.prototype.schedule = function(e, r) {
706
706
  return this;
707
707
  }, t;
708
- })(U), ue = {
708
+ })(N), ue = {
709
709
  setInterval: function(n, t) {
710
710
  for (var e = [], r = 2; r < arguments.length; r++)
711
711
  e[r - 2] = arguments[r];
@@ -813,21 +813,21 @@ function Ae(n) {
813
813
  function _e(n) {
814
814
  return m(n[re]);
815
815
  }
816
- function Me(n) {
816
+ function xe(n) {
817
817
  return Symbol.asyncIterator && m(n?.[Symbol.asyncIterator]);
818
818
  }
819
- function xe(n) {
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 Le = dt();
826
- function ke(n) {
827
- return m(n?.[Le]);
825
+ var Pe = dt();
826
+ function Le(n) {
827
+ return m(n?.[Pe]);
828
828
  }
829
- function Pe(n) {
830
- return qe(this, arguments, function() {
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) {
@@ -860,7 +860,7 @@ function Pe(n) {
860
860
  function Ue(n) {
861
861
  return m(n?.getReader);
862
862
  }
863
- function x(n) {
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 (Me(n))
873
+ if (xe(n))
874
874
  return Ne(n);
875
- if (ke(n))
875
+ if (Le(n))
876
876
  return gt(n);
877
877
  if (Ue(n))
878
878
  return mt(n);
879
879
  }
880
- throw xe(n);
880
+ throw Me(n);
881
881
  }
882
882
  function ht(n) {
883
883
  return new S(function(t) {
@@ -932,7 +932,7 @@ function Ne(n) {
932
932
  });
933
933
  }
934
934
  function mt(n) {
935
- return Ne(Pe(n));
935
+ return Ne(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 = Ve(n), u.label = 1;
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 x(n).pipe($e(t), Re(t));
1008
+ return M(n).pipe($e(t), Re(t));
1009
1009
  }
1010
1010
  function bt(n, t) {
1011
- return x(n).pipe($e(t), Re(t));
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[Le](), C(e, t, function() {
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(Pe(n), t);
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 (Me(n))
1065
+ if (xe(n))
1066
1066
  return je(n, t);
1067
- if (ke(n))
1067
+ if (Le(n))
1068
1068
  return It(n, t);
1069
1069
  if (Ue(n))
1070
1070
  return Et(n, t);
1071
1071
  }
1072
- throw xe(n);
1072
+ throw Me(n);
1073
1073
  }
1074
1074
  function ie(n, t) {
1075
- return t ? wt(n, t) : x(n);
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 P(n, t) {
1086
+ function U(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 P(function(t) {
1099
+ return U(function(t) {
1100
1100
  return At(n, t);
1101
1101
  });
1102
1102
  }
1103
- var Mt = Array.isArray, xt = Object.getPrototypeOf, Lt = Object.prototype, kt = Object.keys;
1104
- function Pt(n) {
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 (Mt(t))
1107
+ if (xt(t))
1108
1108
  return { args: t, keys: null };
1109
1109
  if (Ut(t)) {
1110
- var e = kt(t);
1110
+ var e = Lt(t);
1111
1111
  return {
1112
1112
  args: e.map(function(r) {
1113
1113
  return t[r];
@@ -1119,7 +1119,7 @@ function Pt(n) {
1119
1119
  return { args: n, keys: null };
1120
1120
  }
1121
1121
  function Ut(n) {
1122
- return n && typeof n == "object" && xt(n) === Lt;
1122
+ return n && typeof n == "object" && Mt(n) === Pt;
1123
1123
  }
1124
1124
  function Nt(n, t) {
1125
1125
  return n.reduce(function(e, r, s) {
@@ -1129,7 +1129,7 @@ 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 = Pt(n), i = s.args, o = s.keys;
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) {
@@ -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
- x(e(p, h++)).subscribe(O(t, function(I) {
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 M = u.shift();
1178
- o || f(M);
1177
+ var x = u.shift();
1178
+ o || f(x);
1179
1179
  }; u.length && c < r; )
1180
1180
  I();
1181
1181
  v();
1182
- } catch (M) {
1183
- t.error(M);
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 P(function(i, o) {
1194
+ return U(function(i, o) {
1195
1195
  return t(r, i, s, o);
1196
- })(x(n(r, s)));
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 P(function() {
1227
+ return U(function() {
1228
1228
  return n;
1229
1229
  });
1230
1230
  }
1231
1231
  function Ft(n, t) {
1232
1232
  return B(function(e, r) {
1233
- return x(n(e, r)).pipe(Gt(1), Kt(e));
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 Z(n, t) {
1244
- return t === void 0 && (t = q), n = n ?? qt, A(function(e, r) {
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 qt(n, t) {
1252
+ function Yt(n, t) {
1253
1253
  return n === t;
1254
1254
  }
1255
- function Vt(n) {
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 Yt(n) {
1264
+ function Vt(n) {
1265
1265
  return A(function(t, e) {
1266
- x(n).subscribe(O(e, function() {
1266
+ M(n).subscribe(O(e, function() {
1267
1267
  return e.complete();
1268
- }, J)), !e.closed && t.subscribe(e);
1268
+ }, Q)), !e.closed && t.subscribe(e);
1269
1269
  });
1270
1270
  }
1271
- async function Wt(n, t) {
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 Xt(n) {
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 M() {
1363
+ function x() {
1364
1364
  document.removeEventListener("visibilitychange", p), window.clearTimeout(I), f.abort();
1365
1365
  }
1366
1366
  e?.addEventListener("abort", () => {
1367
- M(), g();
1367
+ x(), g();
1368
1368
  });
1369
1369
  const He = c ?? window.fetch, Ge = s ?? tn;
1370
1370
  async function V() {
1371
- var Y;
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 Wt(j.body, Xt(zt((T) => {
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?.(), M(), g();
1379
+ }, i))), o?.(), x(), g();
1380
1380
  } catch (j) {
1381
1381
  if (!f.signal.aborted)
1382
1382
  try {
1383
- const T = (Y = a?.(j)) !== null && Y !== void 0 ? Y : _;
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
- M(), v(T);
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
- Yt(this.destroy$),
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
- Vt(() => this.onRunSettled())
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 X;
1721
+ let z;
1722
1722
  const sn = new Uint8Array(16);
1723
1723
  function on() {
1724
- if (!X) {
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
- X = crypto.getRandomValues.bind(crypto);
1727
+ z = crypto.getRandomValues.bind(crypto);
1728
1728
  }
1729
- return X(sn);
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) {
@@ -1817,6 +1817,7 @@ class y {
1817
1817
  }
1818
1818
  onMessageStart(t) {
1819
1819
  const e = t.fact.messageStart.message;
1820
+ if (e.parentToolUseId) return this;
1820
1821
  if (this.isTerminalBot(this.messages?.get(e.messageId))) return this;
1821
1822
  const r = new Map(this.messages);
1822
1823
  return r.set(e.messageId, {
@@ -1832,7 +1833,9 @@ class y {
1832
1833
  }), new y({ messages: r, pendingConsent: this.pendingConsent });
1833
1834
  }
1834
1835
  onMessageDelta(t) {
1835
- const e = t.fact.messageDelta.message, r = this.messages?.get(e.messageId);
1836
+ const e = t.fact.messageDelta.message;
1837
+ if (e.parentToolUseId) return this;
1838
+ const r = this.messages?.get(e.messageId);
1836
1839
  if (this.isTerminalBot(r)) return this;
1837
1840
  const s = r?.type === "bot" ? r : void 0, i = new Map(this.messages);
1838
1841
  return i.set(e.messageId, {
@@ -1848,7 +1851,9 @@ class y {
1848
1851
  }), new y({ messages: i, pendingConsent: this.pendingConsent });
1849
1852
  }
1850
1853
  onMessageComplete(t) {
1851
- const e = t.fact.messageComplete.message, r = new Map(this.messages), s = r.get(e.messageId);
1854
+ const e = t.fact.messageComplete.message;
1855
+ if (e.parentToolUseId) return this;
1856
+ const r = new Map(this.messages), s = r.get(e.messageId);
1852
1857
  return r.set(e.messageId, {
1853
1858
  type: "bot",
1854
1859
  eventType: d.MESSAGE_COMPLETE,
@@ -1863,6 +1868,7 @@ class y {
1863
1868
  }
1864
1869
  onThinkingStart(t) {
1865
1870
  const e = t.fact.messageThinkingStart.message;
1871
+ if (e.parentToolUseId) return this;
1866
1872
  if (this.isTerminalThinking(this.messages?.get(e.messageId))) return this;
1867
1873
  const r = new Map(this.messages), s = {
1868
1874
  type: "thinking",
@@ -1875,7 +1881,9 @@ class y {
1875
1881
  return r.set(e.messageId, s), new y({ messages: r, pendingConsent: this.pendingConsent });
1876
1882
  }
1877
1883
  onThinkingDelta(t) {
1878
- const e = t.fact.messageThinkingDelta.message, r = this.messages?.get(e.messageId);
1884
+ const e = t.fact.messageThinkingDelta.message;
1885
+ if (e.parentToolUseId) return this;
1886
+ const r = this.messages?.get(e.messageId);
1879
1887
  if (this.isTerminalThinking(r)) return this;
1880
1888
  const s = r?.type === "thinking" ? r : void 0, i = new Map(this.messages), o = {
1881
1889
  type: "thinking",
@@ -1888,7 +1896,9 @@ class y {
1888
1896
  return i.set(e.messageId, o), new y({ messages: i, pendingConsent: this.pendingConsent });
1889
1897
  }
1890
1898
  onThinkingComplete(t) {
1891
- const e = t.fact.messageThinkingComplete.message, r = this.messages?.get(e.messageId), s = r?.type === "thinking" ? r : void 0, i = new Map(this.messages), o = {
1899
+ const e = t.fact.messageThinkingComplete.message;
1900
+ if (e.parentToolUseId) return this;
1901
+ const r = this.messages?.get(e.messageId), s = r?.type === "thinking" ? r : void 0, i = new Map(this.messages), o = {
1892
1902
  type: "thinking",
1893
1903
  messageId: e.messageId,
1894
1904
  // Self-sufficient (F-011): the complete frame carries the full reasoning, so a complete-only
@@ -2155,9 +2165,9 @@ function In(n, t) {
2155
2165
  });
2156
2166
  }
2157
2167
  function En(n) {
2158
- const t = new N([]), e = new N([]), r = new U();
2159
- return r.add(n.pipe(P(vn), Z(bn)).subscribe(t)), r.add(
2160
- n.pipe(P(yn), Z(In)).subscribe(e)
2168
+ const t = new P([]), e = new P([]), r = new N();
2169
+ return r.add(n.pipe(U(vn), Y(bn)).subscribe(t)), r.add(
2170
+ n.pipe(U(yn), Y(In)).subscribe(e)
2161
2171
  ), {
2162
2172
  tasks$: t.asObservable(),
2163
2173
  subagents$: e.asObservable(),
@@ -2173,6 +2183,7 @@ class K {
2173
2183
  isConnecting$;
2174
2184
  conversation$;
2175
2185
  channelTitleSubject;
2186
+ sandboxPhaseSubject;
2176
2187
  derivedStores;
2177
2188
  statesObserver;
2178
2189
  statesSubscription;
@@ -2182,6 +2193,8 @@ class K {
2182
2193
  subagents$;
2183
2194
  /** Reactive channel title store (F-016): seeded from metadata, updated by `title.update`; replay-safe. */
2184
2195
  channelTitle$;
2196
+ /** Reactive sandbox cold-start phase store (F-018): per-slice, derived from the last sandbox event; replay-safe. */
2197
+ sandboxPhase$;
2185
2198
  currentUserMessageId;
2186
2199
  // The most-recently-sent user message id. Unlike currentUserMessageId (which
2187
2200
  // is cleared once a traceId is attached), this is kept across the SSE
@@ -2197,7 +2210,7 @@ class K {
2197
2210
  throw new Error("client must be required");
2198
2211
  if (!t.customChannelId)
2199
2212
  throw new Error("customChannelId must be required");
2200
- this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new N(!1), this.conversation$ = new N(t.conversation), this.channelTitleSubject = new N(t.channelTitle ?? null), this.derivedStores = En(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(Z()), this.statesObserver = t.statesObserver;
2213
+ 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
2214
  }
2202
2215
  /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2203
2216
  getTasks() {
@@ -2211,6 +2224,10 @@ class K {
2211
2224
  getChannelTitle() {
2212
2225
  return this.channelTitleSubject.value;
2213
2226
  }
2227
+ /** Current sandbox phase snapshot (F-018) — for framework-agnostic `getSnapshot()` bridging. */
2228
+ getSandboxPhase() {
2229
+ return this.sandboxPhaseSubject.value;
2230
+ }
2214
2231
  /** Seed / override the channel title (F-016) — used by the join-restore metadata seed (F-015). */
2215
2232
  setChannelTitle(t) {
2216
2233
  this.channelTitleSubject.next(t);
@@ -2248,14 +2265,16 @@ class K {
2248
2265
  this.conversation$,
2249
2266
  this.derivedStores.tasks$,
2250
2267
  this.derivedStores.subagents$,
2251
- this.channelTitle$
2268
+ this.channelTitle$,
2269
+ this.sandboxPhase$
2252
2270
  ]).pipe(
2253
- P(([t, e, r, s, i]) => ({
2271
+ U(([t, e, r, s, i, o]) => ({
2254
2272
  isConnecting: t,
2255
2273
  conversation: e,
2256
2274
  tasks: r,
2257
2275
  subagents: s,
2258
- channelTitle: i
2276
+ channelTitle: i,
2277
+ sandboxPhase: o
2259
2278
  }))
2260
2279
  ).subscribe(this.statesObserver);
2261
2280
  }
@@ -2273,6 +2292,25 @@ class K {
2273
2292
  }
2274
2293
  return t;
2275
2294
  }
2295
+ /**
2296
+ * Advance the sandbox phase store from an incoming event's type (F-018). Only sandbox / run-boundary
2297
+ * events move it; every other event is a no-op, so `distinctUntilChanged` suppresses re-emission on
2298
+ * high-frequency message deltas.
2299
+ */
2300
+ updateSandboxPhase(t) {
2301
+ switch (t) {
2302
+ case d.SANDBOX_LAUNCH:
2303
+ this.sandboxPhaseSubject.next("launching");
2304
+ break;
2305
+ case d.SANDBOX_READY:
2306
+ this.sandboxPhaseSubject.next("ready");
2307
+ break;
2308
+ case d.INIT:
2309
+ case d.ERROR:
2310
+ this.sandboxPhaseSubject.next("idle");
2311
+ break;
2312
+ }
2313
+ }
2276
2314
  /**
2277
2315
  * The SSE run handlers shared by every run kind (POST send/reset and GET rejoin): fold each frame
2278
2316
  * through the conversation reducer, keep the title store in sync, attach the traceId to the pending
@@ -2284,7 +2322,7 @@ class K {
2284
2322
  onSseMessage: (s) => {
2285
2323
  if (t?.onSseMessage?.(s), s.eventType === d.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
2286
2324
  s.fact.channelTitleUpdate.title
2287
- ), this.currentUserMessageId && s.traceId) {
2325
+ ), this.updateSandboxPhase(s.eventType), this.currentUserMessageId && s.traceId) {
2288
2326
  const i = new Map(this.conversation$.value.messages), o = i.get(this.currentUserMessageId);
2289
2327
  o && o.type === "user" && (i.set(this.currentUserMessageId, {
2290
2328
  ...o,
@@ -2380,7 +2418,7 @@ class K {
2380
2418
  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
2419
  }
2382
2420
  close() {
2383
- this.currentRun?.unsubscribe(), this.currentRun = void 0, this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
2421
+ 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
2422
  }
2385
2423
  }
2386
2424
  export {