@asgard-js/core 0.3.41 → 0.3.42

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
@@ -16,7 +16,7 @@ class w extends Error {
16
16
  super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = r;
17
17
  }
18
18
  }
19
- function An(n) {
19
+ function Pn(n) {
20
20
  return n instanceof w;
21
21
  }
22
22
  class Z extends Error {
@@ -26,20 +26,20 @@ class Z extends Error {
26
26
  super(`Cannot send a message while a "${t}" run is in flight on this channel.`), this.name = "ChannelBusyError", this.runKind = t;
27
27
  }
28
28
  }
29
- function Pn(n) {
29
+ function _n(n) {
30
30
  return n instanceof Z;
31
31
  }
32
- var $ = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))($ || {}), l = /* @__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))(l || {}), Ye = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ye || {}), We = /* @__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))(We || {});
33
- async function Xe(n, t) {
32
+ var $ = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))($ || {}), l = /* @__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))(l || {}), We = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(We || {}), Xe = /* @__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))(Xe || {});
33
+ async function Ve(n, t) {
34
34
  const e = n.getReader();
35
35
  let r;
36
36
  for (; !(r = await e.read()).done; )
37
37
  t(r.value);
38
38
  }
39
- function Ve(n) {
39
+ function ze(n) {
40
40
  let t, e, r, s = !1;
41
41
  return function(i) {
42
- t === void 0 ? (t = i, e = 0, r = -1) : t = Je(t, i);
42
+ t === void 0 ? (t = i, e = 0, r = -1) : t = Qe(t, i);
43
43
  const a = t.length;
44
44
  let c = 0;
45
45
  for (; e < a; ) {
@@ -63,7 +63,7 @@ function Ve(n) {
63
63
  c === a ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
64
64
  };
65
65
  }
66
- function ze(n, t, e) {
66
+ function Je(n, t, e) {
67
67
  let r = ce();
68
68
  const s = new TextDecoder();
69
69
  return function(i, a) {
@@ -90,7 +90,7 @@ function ze(n, t, e) {
90
90
  }
91
91
  };
92
92
  }
93
- function Je(n, t) {
93
+ function Qe(n, t) {
94
94
  const e = new Uint8Array(n.length + t.length);
95
95
  return e.set(n), e.set(t, n.length), e;
96
96
  }
@@ -102,7 +102,7 @@ function ce() {
102
102
  retry: void 0
103
103
  };
104
104
  }
105
- var Qe = function(n, t) {
105
+ var Ze = function(n, t) {
106
106
  var e = {};
107
107
  for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
108
108
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
@@ -110,9 +110,9 @@ var Qe = function(n, t) {
110
110
  t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
111
111
  return e;
112
112
  };
113
- const ee = "text/event-stream", Ze = 1e3, ue = "last-event-id";
114
- function Se(n, t) {
115
- var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h = Qe(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
113
+ const ee = "text/event-stream", et = 1e3, ue = "last-event-id";
114
+ function we(n, t) {
115
+ var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h = Ze(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
116
116
  return new Promise((m, b) => {
117
117
  const d = Object.assign({}, r);
118
118
  d.accept || (d.accept = ee);
@@ -121,20 +121,20 @@ function Se(n, t) {
121
121
  p.abort(), document.hidden || X();
122
122
  }
123
123
  c || document.addEventListener("visibilitychange", f);
124
- let _ = Ze, E = 0;
124
+ let _ = et, E = 0;
125
125
  function L() {
126
126
  document.removeEventListener("visibilitychange", f), window.clearTimeout(E), p.abort();
127
127
  }
128
128
  e?.addEventListener("abort", () => {
129
129
  L(), m();
130
130
  });
131
- const qe = u ?? window.fetch, Ke = s ?? et;
131
+ const Ke = u ?? window.fetch, Ye = s ?? tt;
132
132
  async function X() {
133
133
  var V;
134
134
  p = new AbortController();
135
135
  try {
136
- const H = await qe(n, Object.assign(Object.assign({}, h), { headers: d, signal: p.signal }));
137
- await Ke(H), await Xe(H.body, Ve(ze((x) => {
136
+ const H = await Ke(n, Object.assign(Object.assign({}, h), { headers: d, signal: p.signal }));
137
+ await Ye(H), await Ve(H.body, ze(Je((x) => {
138
138
  x ? d[ue] = x : delete d[ue];
139
139
  }, (x) => {
140
140
  _ = x;
@@ -152,7 +152,7 @@ function Se(n, t) {
152
152
  X();
153
153
  });
154
154
  }
155
- function et(n) {
155
+ function tt(n) {
156
156
  const t = n.headers.get("content-type");
157
157
  if (!t?.startsWith(ee))
158
158
  throw new Error(`Expected content-type to be ${ee}, Actual: ${t}`);
@@ -173,7 +173,7 @@ function T(n, t) {
173
173
  }
174
174
  n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
175
175
  }
176
- function tt(n, t, e, r) {
176
+ function nt(n, t, e, r) {
177
177
  function s(o) {
178
178
  return o instanceof e ? o : new e(function(i) {
179
179
  i(o);
@@ -200,7 +200,7 @@ function tt(n, t, e, r) {
200
200
  u((r = r.apply(n, t || [])).next());
201
201
  });
202
202
  }
203
- function we(n, t) {
203
+ function Ee(n, t) {
204
204
  var e = { label: 0, sent: function() {
205
205
  if (o[0] & 1) throw o[1];
206
206
  return o[1];
@@ -295,7 +295,7 @@ function F(n, t, e) {
295
295
  function k(n) {
296
296
  return this instanceof k ? (this.v = n, this) : new k(n);
297
297
  }
298
- function nt(n, t, e) {
298
+ function rt(n, t, e) {
299
299
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
300
300
  var r = e.apply(n, t || []), s, o = [];
301
301
  return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), s[Symbol.asyncIterator] = function() {
@@ -333,7 +333,7 @@ function nt(n, t, e) {
333
333
  d(p), o.shift(), o.length && c(o[0][0], o[0][1]);
334
334
  }
335
335
  }
336
- function rt(n) {
336
+ function st(n) {
337
337
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
338
338
  var t = n[Symbol.asyncIterator], e;
339
339
  return t ? t.call(n) : (n = typeof N == "function" ? N(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
@@ -355,13 +355,13 @@ function rt(n) {
355
355
  function g(n) {
356
356
  return typeof n == "function";
357
357
  }
358
- function Ee(n) {
358
+ function Ie(n) {
359
359
  var t = function(r) {
360
360
  Error.call(r), r.stack = new Error().stack;
361
361
  }, e = n(t);
362
362
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
363
363
  }
364
- var z = Ee(function(n) {
364
+ var z = Ie(function(n) {
365
365
  return function(e) {
366
366
  n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
367
367
  ` + e.map(function(r, s) {
@@ -464,16 +464,16 @@ var j = (function() {
464
464
  var t = new n();
465
465
  return t.closed = !0, t;
466
466
  })(), n;
467
- })(), Ie = j.EMPTY;
468
- function Te(n) {
467
+ })(), Te = j.EMPTY;
468
+ function xe(n) {
469
469
  return n instanceof j || n && "closed" in n && g(n.remove) && g(n.add) && g(n.unsubscribe);
470
470
  }
471
471
  function le(n) {
472
472
  g(n) ? n() : n.unsubscribe();
473
473
  }
474
- var st = {
474
+ var ot = {
475
475
  Promise: void 0
476
- }, ot = {
476
+ }, it = {
477
477
  setTimeout: function(n, t) {
478
478
  for (var e = [], r = 2; r < arguments.length; r++)
479
479
  e[r - 2] = arguments[r];
@@ -484,8 +484,8 @@ var st = {
484
484
  },
485
485
  delegate: void 0
486
486
  };
487
- function xe(n) {
488
- ot.setTimeout(function() {
487
+ function Ce(n) {
488
+ it.setTimeout(function() {
489
489
  throw n;
490
490
  });
491
491
  }
@@ -498,7 +498,7 @@ var se = (function(n) {
498
498
  T(t, n);
499
499
  function t(e) {
500
500
  var r = n.call(this) || this;
501
- return r.isStopped = !1, e ? (r.destination = e, Te(e) && e.add(r)) : r.destination = ct, r;
501
+ return r.isStopped = !1, e ? (r.destination = e, xe(e) && e.add(r)) : r.destination = ut, r;
502
502
  }
503
503
  return t.create = function(e, r, s) {
504
504
  return new re(e, r, s);
@@ -525,7 +525,7 @@ var se = (function(n) {
525
525
  this.unsubscribe();
526
526
  }
527
527
  }, t;
528
- })(j), it = (function() {
528
+ })(j), at = (function() {
529
529
  function n(t) {
530
530
  this.partialObserver = t;
531
531
  }
@@ -564,20 +564,20 @@ var se = (function(n) {
564
564
  next: e ?? void 0,
565
565
  error: r ?? void 0,
566
566
  complete: s ?? void 0
567
- } : i = e, o.destination = new it(i), o;
567
+ } : i = e, o.destination = new at(i), o;
568
568
  }
569
569
  return t;
570
570
  })(se);
571
571
  function B(n) {
572
- xe(n);
572
+ Ce(n);
573
573
  }
574
- function at(n) {
574
+ function ct(n) {
575
575
  throw n;
576
576
  }
577
- var ct = {
577
+ var ut = {
578
578
  closed: !0,
579
579
  next: ne,
580
- error: at,
580
+ error: ct,
581
581
  complete: ne
582
582
  }, oe = (function() {
583
583
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
@@ -585,7 +585,7 @@ var ct = {
585
585
  function W(n) {
586
586
  return n;
587
587
  }
588
- function ut(n) {
588
+ function lt(n) {
589
589
  return n.length === 0 ? W : n.length === 1 ? n[0] : function(e) {
590
590
  return n.reduce(function(r, s) {
591
591
  return s(r);
@@ -600,7 +600,7 @@ var S = (function() {
600
600
  var e = new n();
601
601
  return e.source = this, e.operator = t, e;
602
602
  }, n.prototype.subscribe = function(t, e, r) {
603
- var s = this, o = dt(t) ? t : new re(t, e, r);
603
+ var s = this, o = ht(t) ? t : new re(t, e, r);
604
604
  return G(function() {
605
605
  var i = s, a = i.operator, c = i.source;
606
606
  o.add(a ? a.call(o, c) : c ? s._subscribe(o) : s._trySubscribe(o));
@@ -635,7 +635,7 @@ var S = (function() {
635
635
  }, n.prototype.pipe = function() {
636
636
  for (var t = [], e = 0; e < arguments.length; e++)
637
637
  t[e] = arguments[e];
638
- return ut(t)(this);
638
+ return lt(t)(this);
639
639
  }, n.prototype.toPromise = function(t) {
640
640
  var e = this;
641
641
  return t = de(t), new t(function(r, s) {
@@ -654,20 +654,20 @@ var S = (function() {
654
654
  })();
655
655
  function de(n) {
656
656
  var t;
657
- return (t = n ?? st.Promise) !== null && t !== void 0 ? t : Promise;
658
- }
659
- function lt(n) {
660
- return n && g(n.next) && g(n.error) && g(n.complete);
657
+ return (t = n ?? ot.Promise) !== null && t !== void 0 ? t : Promise;
661
658
  }
662
659
  function dt(n) {
663
- return n && n instanceof se || lt(n) && Te(n);
660
+ return n && g(n.next) && g(n.error) && g(n.complete);
664
661
  }
665
662
  function ht(n) {
663
+ return n && n instanceof se || dt(n) && xe(n);
664
+ }
665
+ function ft(n) {
666
666
  return g(n?.lift);
667
667
  }
668
668
  function P(n) {
669
669
  return function(t) {
670
- if (ht(t))
670
+ if (ft(t))
671
671
  return t.lift(function(e) {
672
672
  try {
673
673
  return n(e, this);
@@ -679,9 +679,9 @@ function P(n) {
679
679
  };
680
680
  }
681
681
  function A(n, t, e, r, s) {
682
- return new ft(n, t, e, r, s);
682
+ return new pt(n, t, e, r, s);
683
683
  }
684
- var ft = (function(n) {
684
+ var pt = (function(n) {
685
685
  T(t, n);
686
686
  function t(e, r, s, o, i, a) {
687
687
  var c = n.call(this, e) || this;
@@ -716,7 +716,7 @@ var ft = (function(n) {
716
716
  n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
717
717
  }
718
718
  }, t;
719
- })(se), pt = Ee(function(n) {
719
+ })(se), mt = Ie(function(n) {
720
720
  return function() {
721
721
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
722
722
  };
@@ -731,7 +731,7 @@ var ft = (function(n) {
731
731
  return r.operator = e, r;
732
732
  }, t.prototype._throwIfClosed = function() {
733
733
  if (this.closed)
734
- throw new pt();
734
+ throw new mt();
735
735
  }, t.prototype.next = function(e) {
736
736
  var r = this;
737
737
  G(function() {
@@ -787,7 +787,7 @@ var ft = (function(n) {
787
787
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
788
788
  }, t.prototype._innerSubscribe = function(e) {
789
789
  var r = this, s = this, o = s.hasError, i = s.isStopped, a = s.observers;
790
- return o || i ? Ie : (this.currentObservers = null, a.push(e), new j(function() {
790
+ return o || i ? Te : (this.currentObservers = null, a.push(e), new j(function() {
791
791
  r.currentObservers = null, K(a, e);
792
792
  }));
793
793
  }, t.prototype._checkFinalizedStatuses = function(e) {
@@ -816,7 +816,7 @@ var ft = (function(n) {
816
816
  (r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
817
817
  }, t.prototype._subscribe = function(e) {
818
818
  var r, s;
819
- return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Ie;
819
+ return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Te;
820
820
  }, t;
821
821
  })(ie), C = (function(n) {
822
822
  T(t, n);
@@ -841,11 +841,11 @@ var ft = (function(n) {
841
841
  }, t.prototype.next = function(e) {
842
842
  n.prototype.next.call(this, this._value = e);
843
843
  }, t;
844
- })(ie), mt = {
844
+ })(ie), gt = {
845
845
  now: function() {
846
846
  return Date.now();
847
847
  }
848
- }, gt = (function(n) {
848
+ }, bt = (function(n) {
849
849
  T(t, n);
850
850
  function t(e, r) {
851
851
  return n.call(this) || this;
@@ -863,7 +863,7 @@ var ft = (function(n) {
863
863
  return clearInterval(n);
864
864
  },
865
865
  delegate: void 0
866
- }, bt = (function(n) {
866
+ }, vt = (function(n) {
867
867
  T(t, n);
868
868
  function t(e, r) {
869
869
  var s = n.call(this, e, r) || this;
@@ -905,14 +905,14 @@ var ft = (function(n) {
905
905
  this.work = this.state = this.scheduler = null, this.pending = !1, K(o, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
906
906
  }
907
907
  }, t;
908
- })(gt), pe = (function() {
908
+ })(bt), pe = (function() {
909
909
  function n(t, e) {
910
910
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
911
911
  }
912
912
  return n.prototype.schedule = function(t, e, r) {
913
913
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
914
- }, n.now = mt.now, n;
915
- })(), vt = (function(n) {
914
+ }, n.now = gt.now, n;
915
+ })(), yt = (function(n) {
916
916
  T(t, n);
917
917
  function t(e, r) {
918
918
  r === void 0 && (r = pe.now);
@@ -937,47 +937,47 @@ var ft = (function(n) {
937
937
  throw s;
938
938
  }
939
939
  }, t;
940
- })(pe), Ce = new vt(bt), yt = Ce, St = new S(function(n) {
940
+ })(pe), Oe = new yt(vt), St = Oe, wt = new S(function(n) {
941
941
  return n.complete();
942
942
  });
943
- function Oe(n) {
943
+ function Ae(n) {
944
944
  return n && g(n.schedule);
945
945
  }
946
- function Ae(n) {
946
+ function Pe(n) {
947
947
  return n[n.length - 1];
948
948
  }
949
- function wt(n) {
950
- return g(Ae(n)) ? n.pop() : void 0;
949
+ function Et(n) {
950
+ return g(Pe(n)) ? n.pop() : void 0;
951
951
  }
952
- function Pe(n) {
953
- return Oe(Ae(n)) ? n.pop() : void 0;
952
+ function _e(n) {
953
+ return Ae(Pe(n)) ? n.pop() : void 0;
954
954
  }
955
- var _e = (function(n) {
955
+ var Le = (function(n) {
956
956
  return n && typeof n.length == "number" && typeof n != "function";
957
957
  });
958
- function Le(n) {
958
+ function Ue(n) {
959
959
  return g(n?.then);
960
960
  }
961
- function Ue(n) {
961
+ function Me(n) {
962
962
  return g(n[oe]);
963
963
  }
964
- function Me(n) {
964
+ function ke(n) {
965
965
  return Symbol.asyncIterator && g(n?.[Symbol.asyncIterator]);
966
966
  }
967
- function ke(n) {
967
+ function Ne(n) {
968
968
  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.");
969
969
  }
970
- function Et() {
970
+ function It() {
971
971
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
972
972
  }
973
- var Ne = Et();
974
- function Re(n) {
975
- return g(n?.[Ne]);
976
- }
973
+ var Re = It();
977
974
  function je(n) {
978
- return nt(this, arguments, function() {
975
+ return g(n?.[Re]);
976
+ }
977
+ function $e(n) {
978
+ return rt(this, arguments, function() {
979
979
  var e, r, s, o;
980
- return we(this, function(i) {
980
+ return Ee(this, function(i) {
981
981
  switch (i.label) {
982
982
  case 0:
983
983
  e = n.getReader(), i.label = 1;
@@ -1005,29 +1005,29 @@ function je(n) {
1005
1005
  });
1006
1006
  });
1007
1007
  }
1008
- function $e(n) {
1008
+ function De(n) {
1009
1009
  return g(n?.getReader);
1010
1010
  }
1011
1011
  function U(n) {
1012
1012
  if (n instanceof S)
1013
1013
  return n;
1014
1014
  if (n != null) {
1015
- if (Ue(n))
1016
- return It(n);
1017
- if (_e(n))
1015
+ if (Me(n))
1018
1016
  return Tt(n);
1019
1017
  if (Le(n))
1020
1018
  return xt(n);
1021
- if (Me(n))
1022
- return De(n);
1023
- if (Re(n))
1019
+ if (Ue(n))
1024
1020
  return Ct(n);
1025
- if ($e(n))
1021
+ if (ke(n))
1022
+ return Fe(n);
1023
+ if (je(n))
1026
1024
  return Ot(n);
1025
+ if (De(n))
1026
+ return At(n);
1027
1027
  }
1028
- throw ke(n);
1028
+ throw Ne(n);
1029
1029
  }
1030
- function It(n) {
1030
+ function Tt(n) {
1031
1031
  return new S(function(t) {
1032
1032
  var e = n[oe]();
1033
1033
  if (g(e.subscribe))
@@ -1035,23 +1035,23 @@ function It(n) {
1035
1035
  throw new TypeError("Provided object does not correctly implement Symbol.observable");
1036
1036
  });
1037
1037
  }
1038
- function Tt(n) {
1038
+ function xt(n) {
1039
1039
  return new S(function(t) {
1040
1040
  for (var e = 0; e < n.length && !t.closed; e++)
1041
1041
  t.next(n[e]);
1042
1042
  t.complete();
1043
1043
  });
1044
1044
  }
1045
- function xt(n) {
1045
+ function Ct(n) {
1046
1046
  return new S(function(t) {
1047
1047
  n.then(function(e) {
1048
1048
  t.closed || (t.next(e), t.complete());
1049
1049
  }, function(e) {
1050
1050
  return t.error(e);
1051
- }).then(null, xe);
1051
+ }).then(null, Ce);
1052
1052
  });
1053
1053
  }
1054
- function Ct(n) {
1054
+ function Ot(n) {
1055
1055
  return new S(function(t) {
1056
1056
  var e, r;
1057
1057
  try {
@@ -1072,24 +1072,24 @@ function Ct(n) {
1072
1072
  t.complete();
1073
1073
  });
1074
1074
  }
1075
- function De(n) {
1075
+ function Fe(n) {
1076
1076
  return new S(function(t) {
1077
- At(n, t).catch(function(e) {
1077
+ Pt(n, t).catch(function(e) {
1078
1078
  return t.error(e);
1079
1079
  });
1080
1080
  });
1081
1081
  }
1082
- function Ot(n) {
1083
- return De(je(n));
1082
+ function At(n) {
1083
+ return Fe($e(n));
1084
1084
  }
1085
- function At(n, t) {
1085
+ function Pt(n, t) {
1086
1086
  var e, r, s, o;
1087
- return tt(this, void 0, void 0, function() {
1087
+ return nt(this, void 0, void 0, function() {
1088
1088
  var i, a;
1089
- return we(this, function(c) {
1089
+ return Ee(this, function(c) {
1090
1090
  switch (c.label) {
1091
1091
  case 0:
1092
- c.trys.push([0, 5, 6, 11]), e = rt(n), c.label = 1;
1092
+ c.trys.push([0, 5, 6, 11]), e = st(n), c.label = 1;
1093
1093
  case 1:
1094
1094
  return [4, e.next()];
1095
1095
  case 2:
@@ -1128,7 +1128,7 @@ function O(n, t, e, r, s) {
1128
1128
  if (n.add(o), !s)
1129
1129
  return o;
1130
1130
  }
1131
- function Fe(n, t) {
1131
+ function He(n, t) {
1132
1132
  return t === void 0 && (t = 0), P(function(e, r) {
1133
1133
  e.subscribe(A(r, function(s) {
1134
1134
  return O(r, n, function() {
@@ -1145,20 +1145,20 @@ function Fe(n, t) {
1145
1145
  }));
1146
1146
  });
1147
1147
  }
1148
- function He(n, t) {
1148
+ function Be(n, t) {
1149
1149
  return t === void 0 && (t = 0), P(function(e, r) {
1150
1150
  r.add(n.schedule(function() {
1151
1151
  return e.subscribe(r);
1152
1152
  }, t));
1153
1153
  });
1154
1154
  }
1155
- function Pt(n, t) {
1156
- return U(n).pipe(He(t), Fe(t));
1157
- }
1158
1155
  function _t(n, t) {
1159
- return U(n).pipe(He(t), Fe(t));
1156
+ return U(n).pipe(Be(t), He(t));
1160
1157
  }
1161
1158
  function Lt(n, t) {
1159
+ return U(n).pipe(Be(t), He(t));
1160
+ }
1161
+ function Ut(n, t) {
1162
1162
  return new S(function(e) {
1163
1163
  var r = 0;
1164
1164
  return t.schedule(function() {
@@ -1166,11 +1166,11 @@ function Lt(n, t) {
1166
1166
  });
1167
1167
  });
1168
1168
  }
1169
- function Ut(n, t) {
1169
+ function Mt(n, t) {
1170
1170
  return new S(function(e) {
1171
1171
  var r;
1172
1172
  return O(e, t, function() {
1173
- r = n[Ne](), O(e, t, function() {
1173
+ r = n[Re](), O(e, t, function() {
1174
1174
  var s, o, i;
1175
1175
  try {
1176
1176
  s = r.next(), o = s.value, i = s.done;
@@ -1185,7 +1185,7 @@ function Ut(n, t) {
1185
1185
  };
1186
1186
  });
1187
1187
  }
1188
- function Be(n, t) {
1188
+ function Ge(n, t) {
1189
1189
  if (!n)
1190
1190
  throw new Error("Iterable cannot be null");
1191
1191
  return new S(function(e) {
@@ -1199,36 +1199,36 @@ function Be(n, t) {
1199
1199
  });
1200
1200
  });
1201
1201
  }
1202
- function Mt(n, t) {
1203
- return Be(je(n), t);
1204
- }
1205
1202
  function kt(n, t) {
1203
+ return Ge($e(n), t);
1204
+ }
1205
+ function Nt(n, t) {
1206
1206
  if (n != null) {
1207
- if (Ue(n))
1208
- return Pt(n, t);
1209
- if (_e(n))
1210
- return Lt(n, t);
1211
- if (Le(n))
1212
- return _t(n, t);
1213
1207
  if (Me(n))
1214
- return Be(n, t);
1215
- if (Re(n))
1208
+ return _t(n, t);
1209
+ if (Le(n))
1216
1210
  return Ut(n, t);
1217
- if ($e(n))
1211
+ if (Ue(n))
1212
+ return Lt(n, t);
1213
+ if (ke(n))
1214
+ return Ge(n, t);
1215
+ if (je(n))
1218
1216
  return Mt(n, t);
1217
+ if (De(n))
1218
+ return kt(n, t);
1219
1219
  }
1220
- throw ke(n);
1220
+ throw Ne(n);
1221
1221
  }
1222
1222
  function ae(n, t) {
1223
- return t ? kt(n, t) : U(n);
1223
+ return t ? Nt(n, t) : U(n);
1224
1224
  }
1225
- function Nt() {
1225
+ function Rt() {
1226
1226
  for (var n = [], t = 0; t < arguments.length; t++)
1227
1227
  n[t] = arguments[t];
1228
- var e = Pe(n);
1228
+ var e = _e(n);
1229
1229
  return ae(n, e);
1230
1230
  }
1231
- function Rt(n) {
1231
+ function jt(n) {
1232
1232
  return n instanceof Date && !isNaN(n);
1233
1233
  }
1234
1234
  function R(n, t) {
@@ -1239,23 +1239,23 @@ function R(n, t) {
1239
1239
  }));
1240
1240
  });
1241
1241
  }
1242
- var jt = Array.isArray;
1243
- function $t(n, t) {
1244
- return jt(t) ? n.apply(void 0, F([], D(t))) : n(t);
1242
+ var $t = Array.isArray;
1243
+ function Dt(n, t) {
1244
+ return $t(t) ? n.apply(void 0, F([], D(t))) : n(t);
1245
1245
  }
1246
- function Dt(n) {
1246
+ function Ft(n) {
1247
1247
  return R(function(t) {
1248
- return $t(n, t);
1248
+ return Dt(n, t);
1249
1249
  });
1250
1250
  }
1251
- var Ft = Array.isArray, Ht = Object.getPrototypeOf, Bt = Object.prototype, Gt = Object.keys;
1252
- function qt(n) {
1251
+ var Ht = Array.isArray, Bt = Object.getPrototypeOf, Gt = Object.prototype, qt = Object.keys;
1252
+ function Kt(n) {
1253
1253
  if (n.length === 1) {
1254
1254
  var t = n[0];
1255
- if (Ft(t))
1255
+ if (Ht(t))
1256
1256
  return { args: t, keys: null };
1257
- if (Kt(t)) {
1258
- var e = Gt(t);
1257
+ if (Yt(t)) {
1258
+ var e = qt(t);
1259
1259
  return {
1260
1260
  args: e.map(function(r) {
1261
1261
  return t[r];
@@ -1266,26 +1266,26 @@ function qt(n) {
1266
1266
  }
1267
1267
  return { args: n, keys: null };
1268
1268
  }
1269
- function Kt(n) {
1270
- return n && typeof n == "object" && Ht(n) === Bt;
1269
+ function Yt(n) {
1270
+ return n && typeof n == "object" && Bt(n) === Gt;
1271
1271
  }
1272
- function Yt(n, t) {
1272
+ function Wt(n, t) {
1273
1273
  return n.reduce(function(e, r, s) {
1274
1274
  return e[r] = t[s], e;
1275
1275
  }, {});
1276
1276
  }
1277
- function Wt() {
1277
+ function Xt() {
1278
1278
  for (var n = [], t = 0; t < arguments.length; t++)
1279
1279
  n[t] = arguments[t];
1280
- var e = Pe(n), r = wt(n), s = qt(n), o = s.args, i = s.keys;
1280
+ var e = _e(n), r = Et(n), s = Kt(n), o = s.args, i = s.keys;
1281
1281
  if (o.length === 0)
1282
1282
  return ae([], e);
1283
- var a = new S(Xt(o, e, i ? function(c) {
1284
- return Yt(i, c);
1283
+ var a = new S(Vt(o, e, i ? function(c) {
1284
+ return Wt(i, c);
1285
1285
  } : W));
1286
- return r ? a.pipe(Dt(r)) : a;
1286
+ return r ? a.pipe(Ft(r)) : a;
1287
1287
  }
1288
- function Xt(n, t, e) {
1288
+ function Vt(n, t, e) {
1289
1289
  return e === void 0 && (e = W), function(r) {
1290
1290
  me(t, function() {
1291
1291
  for (var s = n.length, o = new Array(s), i = s, a = s, c = function(h) {
@@ -1305,7 +1305,7 @@ function Xt(n, t, e) {
1305
1305
  function me(n, t, e) {
1306
1306
  n ? O(e, n, t) : t();
1307
1307
  }
1308
- function Vt(n, t, e, r, s, o, i, a) {
1308
+ function zt(n, t, e, r, s, o, i, a) {
1309
1309
  var c = [], u = 0, h = 0, m = !1, b = function() {
1310
1310
  m && !c.length && !u && t.complete();
1311
1311
  }, d = function(f) {
@@ -1343,14 +1343,14 @@ function Y(n, t, e) {
1343
1343
  return t(r, o, s, i);
1344
1344
  })(U(n(r, s)));
1345
1345
  }, e) : (typeof t == "number" && (e = t), P(function(r, s) {
1346
- return Vt(r, s, n, e);
1346
+ return zt(r, s, n, e);
1347
1347
  }));
1348
1348
  }
1349
- function zt(n, t, e) {
1350
- n === void 0 && (n = 0), e === void 0 && (e = yt);
1349
+ function Jt(n, t, e) {
1350
+ n === void 0 && (n = 0), e === void 0 && (e = St);
1351
1351
  var r = -1;
1352
- return t != null && (Oe(t) ? e = t : r = t), new S(function(s) {
1353
- var o = Rt(n) ? +n - e.now() : n;
1352
+ return t != null && (Ae(t) ? e = t : r = t), new S(function(s) {
1353
+ var o = jt(n) ? +n - e.now() : n;
1354
1354
  o < 0 && (o = 0);
1355
1355
  var i = 0;
1356
1356
  return e.schedule(function() {
@@ -1358,12 +1358,12 @@ function zt(n, t, e) {
1358
1358
  }, o);
1359
1359
  });
1360
1360
  }
1361
- function Jt(n, t) {
1361
+ function Qt(n, t) {
1362
1362
  return g(t) ? Y(n, t, 1) : Y(n, 1);
1363
1363
  }
1364
- function Qt(n) {
1364
+ function Zt(n) {
1365
1365
  return n <= 0 ? function() {
1366
- return St;
1366
+ return wt;
1367
1367
  } : P(function(t, e) {
1368
1368
  var r = 0;
1369
1369
  t.subscribe(A(e, function(s) {
@@ -1371,25 +1371,25 @@ function Qt(n) {
1371
1371
  }));
1372
1372
  });
1373
1373
  }
1374
- function Zt(n) {
1374
+ function en(n) {
1375
1375
  return R(function() {
1376
1376
  return n;
1377
1377
  });
1378
1378
  }
1379
- function en(n, t) {
1379
+ function tn(n, t) {
1380
1380
  return Y(function(e, r) {
1381
- return U(n(e, r)).pipe(Qt(1), Zt(e));
1381
+ return U(n(e, r)).pipe(Zt(1), en(e));
1382
1382
  });
1383
1383
  }
1384
- function tn(n, t) {
1385
- t === void 0 && (t = Ce);
1386
- var e = zt(n, t);
1387
- return en(function() {
1384
+ function nn(n, t) {
1385
+ t === void 0 && (t = Oe);
1386
+ var e = Jt(n, t);
1387
+ return tn(function() {
1388
1388
  return e;
1389
1389
  });
1390
1390
  }
1391
1391
  function M(n, t) {
1392
- return t === void 0 && (t = W), n = n ?? nn, P(function(e, r) {
1392
+ return t === void 0 && (t = W), n = n ?? rn, P(function(e, r) {
1393
1393
  var s, o = !0;
1394
1394
  e.subscribe(A(r, function(i) {
1395
1395
  var a = t(i);
@@ -1397,10 +1397,10 @@ function M(n, t) {
1397
1397
  }));
1398
1398
  });
1399
1399
  }
1400
- function nn(n, t) {
1400
+ function rn(n, t) {
1401
1401
  return n === t;
1402
1402
  }
1403
- function rn(n) {
1403
+ function sn(n) {
1404
1404
  return P(function(t, e) {
1405
1405
  try {
1406
1406
  t.subscribe(e);
@@ -1409,7 +1409,7 @@ function rn(n) {
1409
1409
  }
1410
1410
  });
1411
1411
  }
1412
- function sn(n) {
1412
+ function on(n) {
1413
1413
  return P(function(t, e) {
1414
1414
  U(n).subscribe(A(e, function() {
1415
1415
  return e.complete();
@@ -1427,7 +1427,7 @@ function ge(n) {
1427
1427
  };
1428
1428
  e && (b["X-API-KEY"] = e);
1429
1429
  const d = new URL(t);
1430
- return s && d.searchParams.set("is_debug", "true"), Se(d.toString(), {
1430
+ return s && d.searchParams.set("is_debug", "true"), we(d.toString(), {
1431
1431
  method: i,
1432
1432
  headers: b,
1433
1433
  body: i === "POST" && r ? JSON.stringify(r) : void 0,
@@ -1472,7 +1472,7 @@ function ge(n) {
1472
1472
  };
1473
1473
  });
1474
1474
  }
1475
- class on {
1475
+ class an {
1476
1476
  listeners = {};
1477
1477
  on(t, e) {
1478
1478
  this.listeners = Object.assign({}, this.listeners, {
@@ -1491,7 +1491,7 @@ class on {
1491
1491
  this.listeners[t] && this.listeners[t].forEach((r) => r(...e));
1492
1492
  }
1493
1493
  }
1494
- class _n {
1494
+ class Ln {
1495
1495
  apiKey;
1496
1496
  endpoint;
1497
1497
  botProviderEndpoint;
@@ -1501,7 +1501,7 @@ class _n {
1501
1501
  detached = !1;
1502
1502
  detachTimer;
1503
1503
  inFlight = 0;
1504
- sseEmitter = new on();
1504
+ sseEmitter = new an();
1505
1505
  transformSsePayload;
1506
1506
  customHeaders;
1507
1507
  constructor(t) {
@@ -1659,11 +1659,11 @@ class _n {
1659
1659
  // No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
1660
1660
  // run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
1661
1661
  // create-sse-observable); a no-cursor failure surfaces via `error` below.
1662
- Jt((r) => Nt(r).pipe(tn(e?.delayTime ?? 50))),
1663
- sn(this.destroy$),
1662
+ Qt((r) => Rt(r).pipe(nn(e?.delayTime ?? 50))),
1663
+ on(this.destroy$),
1664
1664
  // Settle the run accounting on every termination path — complete, error, AND a user-initiated
1665
1665
  // unsubscribe (stop-generation aborts the connection without a terminal event).
1666
- rn(() => this.onRunSettled())
1666
+ sn(() => this.onRunSettled())
1667
1667
  ).subscribe({
1668
1668
  next: (r) => {
1669
1669
  this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
@@ -1904,7 +1904,7 @@ class _n {
1904
1904
  const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/watch`);
1905
1905
  return r.searchParams.set("path", e), new S((s) => {
1906
1906
  const o = new AbortController();
1907
- return Se(r.toString(), {
1907
+ return we(r.toString(), {
1908
1908
  headers: this.apiHeaders(),
1909
1909
  signal: o.signal,
1910
1910
  openWhenHidden: !0,
@@ -1944,29 +1944,29 @@ class _n {
1944
1944
  const y = [];
1945
1945
  for (let n = 0; n < 256; ++n)
1946
1946
  y.push((n + 256).toString(16).slice(1));
1947
- function an(n, t = 0) {
1947
+ function cn(n, t = 0) {
1948
1948
  return (y[n[t + 0]] + y[n[t + 1]] + y[n[t + 2]] + y[n[t + 3]] + "-" + y[n[t + 4]] + y[n[t + 5]] + "-" + y[n[t + 6]] + y[n[t + 7]] + "-" + y[n[t + 8]] + y[n[t + 9]] + "-" + y[n[t + 10]] + y[n[t + 11]] + y[n[t + 12]] + y[n[t + 13]] + y[n[t + 14]] + y[n[t + 15]]).toLowerCase();
1949
1949
  }
1950
1950
  let J;
1951
- const cn = new Uint8Array(16);
1952
- function un() {
1951
+ const un = new Uint8Array(16);
1952
+ function ln() {
1953
1953
  if (!J) {
1954
1954
  if (typeof crypto > "u" || !crypto.getRandomValues)
1955
1955
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1956
1956
  J = crypto.getRandomValues.bind(crypto);
1957
1957
  }
1958
- return J(cn);
1958
+ return J(un);
1959
1959
  }
1960
- const ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), be = { randomUUID: ln };
1961
- function dn(n, t, e) {
1960
+ const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), be = { randomUUID: dn };
1961
+ function hn(n, t, e) {
1962
1962
  n = n || {};
1963
- const r = n.random ?? n.rng?.() ?? un();
1963
+ const r = n.random ?? n.rng?.() ?? ln();
1964
1964
  if (r.length < 16)
1965
1965
  throw new Error("Random bytes length must be >= 16");
1966
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, an(r);
1966
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, cn(r);
1967
1967
  }
1968
- function Ge(n, t, e) {
1969
- return be.randomUUID && !n ? be.randomUUID() : dn(n);
1968
+ function qe(n, t, e) {
1969
+ return be.randomUUID && !n ? be.randomUUID() : hn(n);
1970
1970
  }
1971
1971
  class v {
1972
1972
  messages = null;
@@ -2178,7 +2178,7 @@ class v {
2178
2178
  return s.set(e.messageId, o), new v({ messages: s, pendingConsent: this.pendingConsent });
2179
2179
  }
2180
2180
  onMessageError(t) {
2181
- const e = Ge(), r = t.fact.runError.error, s = new Map(this.messages);
2181
+ const e = qe(), r = t.fact.runError.error, s = new Map(this.messages);
2182
2182
  return s.set(e, {
2183
2183
  type: "error",
2184
2184
  eventType: l.ERROR,
@@ -2262,7 +2262,7 @@ class v {
2262
2262
  time: /* @__PURE__ */ new Date(),
2263
2263
  traceId: t.traceId
2264
2264
  };
2265
- return r.set(s, o), new v({ messages: r, pendingConsent: this.pendingConsent });
2265
+ return r.delete(s), r.set(s, o), new v({ messages: r, pendingConsent: this.pendingConsent });
2266
2266
  }
2267
2267
  onSubagentComplete(t) {
2268
2268
  const e = t.fact.subagentComplete, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:complete`, o = {
@@ -2277,12 +2277,12 @@ class v {
2277
2277
  time: /* @__PURE__ */ new Date(),
2278
2278
  traceId: t.traceId
2279
2279
  };
2280
- return r.set(s, o), new v({ messages: r, pendingConsent: this.pendingConsent });
2280
+ return r.delete(s), r.set(s, o), new v({ messages: r, pendingConsent: this.pendingConsent });
2281
2281
  }
2282
2282
  }
2283
- const hn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2284
- function fn(n) {
2285
- return n.toolsetName === "" && hn.has(n.toolName);
2283
+ const fn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2284
+ function pn(n) {
2285
+ return n.toolsetName === "" && fn.has(n.toolName);
2286
2286
  }
2287
2287
  function ve(n) {
2288
2288
  return typeof n == "object" && n !== null ? n : void 0;
@@ -2290,7 +2290,7 @@ function ve(n) {
2290
2290
  function I(n) {
2291
2291
  return typeof n == "string" ? n : void 0;
2292
2292
  }
2293
- function pn(n) {
2293
+ function mn(n) {
2294
2294
  const t = [], e = /* @__PURE__ */ new Map();
2295
2295
  for (const r of n) {
2296
2296
  const s = r.parameter ?? {}, o = r.sidecar ?? {};
@@ -2314,13 +2314,16 @@ function pn(n) {
2314
2314
  }
2315
2315
  return t.map((r) => e.get(r));
2316
2316
  }
2317
- function mn(n) {
2317
+ function gn(n) {
2318
2318
  return n.toolsetName === "" && n.toolName === "Agent";
2319
2319
  }
2320
- function gn(n) {
2320
+ function bn(n) {
2321
2321
  return !!n;
2322
2322
  }
2323
- function bn(n) {
2323
+ function ye(n) {
2324
+ n.status !== "running" && (n.status = "running", n.summary = void 0);
2325
+ }
2326
+ function vn(n) {
2324
2327
  const t = [], e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = (o) => (e.has(o) || (t.push(o), e.set(o, { status: "running" }), r.set(o, /* @__PURE__ */ new Map())), e.get(o));
2325
2328
  for (const o of n)
2326
2329
  switch (o.kind) {
@@ -2331,11 +2334,11 @@ function bn(n) {
2331
2334
  }
2332
2335
  case "subagentStart": {
2333
2336
  const i = s(o.parentToolUseId);
2334
- i.agentId = o.agentId ?? i.agentId, i.subagentType = o.subagentType ?? i.subagentType, i.description = o.description ?? i.description;
2337
+ i.agentId = o.agentId ?? i.agentId, i.subagentType = o.subagentType ?? i.subagentType, i.description = o.description ?? i.description, ye(i);
2335
2338
  break;
2336
2339
  }
2337
2340
  case "toolStart": {
2338
- s(o.parentToolUseId), r.get(o.parentToolUseId).set(o.toolUseId, {
2341
+ ye(s(o.parentToolUseId)), r.get(o.parentToolUseId).set(o.toolUseId, {
2339
2342
  toolsetName: o.toolsetName,
2340
2343
  toolName: o.toolName,
2341
2344
  parameter: o.parameter ?? {},
@@ -2361,21 +2364,21 @@ function bn(n) {
2361
2364
  tools: Array.from(r.get(o).values())
2362
2365
  }));
2363
2366
  }
2364
- function vn(n) {
2367
+ function yn(n) {
2365
2368
  return typeof n == "string" ? n : void 0;
2366
2369
  }
2367
- function yn(n) {
2370
+ function Sn(n) {
2368
2371
  const t = [];
2369
2372
  for (const e of n) {
2370
- if (e.type === "tool-call" && mn(e)) {
2373
+ if (e.type === "tool-call" && gn(e)) {
2371
2374
  t.push({
2372
2375
  kind: "agentStart",
2373
2376
  toolUseId: e.toolUseId ?? e.messageId,
2374
- description: vn(e.parameter.description)
2377
+ description: yn(e.parameter.description)
2375
2378
  });
2376
2379
  continue;
2377
2380
  }
2378
- if (e.type === "tool-call" && gn(e.parentToolUseId)) {
2381
+ if (e.type === "tool-call" && bn(e.parentToolUseId)) {
2379
2382
  const r = e.toolUseId ?? e.messageId;
2380
2383
  t.push({
2381
2384
  kind: "toolStart",
@@ -2412,37 +2415,37 @@ function yn(n) {
2412
2415
  }
2413
2416
  return t;
2414
2417
  }
2415
- function Sn(n) {
2418
+ function wn(n) {
2416
2419
  const t = Array.from(n.messages?.values() ?? []).filter(
2417
- (e) => e.type === "tool-call" && e.isComplete && fn(e)
2420
+ (e) => e.type === "tool-call" && e.isComplete && pn(e)
2418
2421
  );
2419
- return pn(t);
2422
+ return mn(t);
2420
2423
  }
2421
- function wn(n) {
2422
- return bn(yn(Array.from(n.messages?.values() ?? [])));
2424
+ function En(n) {
2425
+ return vn(Sn(Array.from(n.messages?.values() ?? [])));
2423
2426
  }
2424
- function En(n, t) {
2427
+ function In(n, t) {
2425
2428
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
2426
2429
  const s = t[r];
2427
2430
  return e.id === s.id && e.status === s.status && e.subject === s.subject && e.activeForm === s.activeForm && e.description === s.description;
2428
2431
  });
2429
2432
  }
2430
- function In(n, t) {
2433
+ function Tn(n, t) {
2431
2434
  return n.length !== t.length ? !1 : n.every((e, r) => {
2432
2435
  const s = t[r];
2433
2436
  return e.toolName === s.toolName && e.toolsetName === s.toolsetName && e.status === s.status && e.reason === s.reason;
2434
2437
  });
2435
2438
  }
2436
- function Tn(n, t) {
2439
+ function xn(n, t) {
2437
2440
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
2438
2441
  const s = t[r];
2439
- return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary && In(e.tools, s.tools);
2442
+ return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary && Tn(e.tools, s.tools);
2440
2443
  });
2441
2444
  }
2442
- function xn(n) {
2445
+ function Cn(n) {
2443
2446
  const t = new C([]), e = new C([]), r = new j();
2444
- return r.add(n.pipe(R(Sn), M(En)).subscribe(t)), r.add(
2445
- n.pipe(R(wn), M(Tn)).subscribe(e)
2447
+ return r.add(n.pipe(R(wn), M(In)).subscribe(t)), r.add(
2448
+ n.pipe(R(En), M(xn)).subscribe(e)
2446
2449
  ), {
2447
2450
  tasks$: t.asObservable(),
2448
2451
  subagents$: e.asObservable(),
@@ -2451,15 +2454,15 @@ function xn(n) {
2451
2454
  teardown: () => r.unsubscribe()
2452
2455
  };
2453
2456
  }
2454
- function ye(n) {
2457
+ function Se(n) {
2455
2458
  const t = /* @__PURE__ */ new Map();
2456
2459
  for (const e of n) t.set(e.sandboxName, e);
2457
2460
  return [...t.values()].sort(
2458
2461
  (e, r) => (e.sandboxBlueprintName || e.sandboxName).localeCompare(r.sandboxBlueprintName || r.sandboxName)
2459
2462
  );
2460
2463
  }
2461
- const Q = { kind: null, stopPhase: "idle" }, Cn = 1e4;
2462
- function On(n, t) {
2464
+ const Q = { kind: null, stopPhase: "idle" }, On = 1e4;
2465
+ function An(n, t) {
2463
2466
  return n.kind === t.kind && n.stopPhase === t.stopPhase && n.requestId === t.requestId;
2464
2467
  }
2465
2468
  class q {
@@ -2516,8 +2519,8 @@ class q {
2516
2519
  if (!t.customChannelId)
2517
2520
  throw new Error("customChannelId must be required");
2518
2521
  this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new C(!1), this.runStatusSubject = new C(Q), this.conversation$ = new C(t.conversation), this.channelTitleSubject = new C(t.channelTitle ?? null), this.sandboxPhaseSubject = new C("idle"), this.launchedSandboxesSubject = new C(
2519
- ye(t.launchedSandboxes ?? [])
2520
- ), this.derivedStores = xn(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(M()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(M()), this.launchedSandboxes$ = this.launchedSandboxesSubject.pipe(M()), this.runStatus$ = this.runStatusSubject.pipe(M(On)), this.statesObserver = t.statesObserver;
2522
+ Se(t.launchedSandboxes ?? [])
2523
+ ), this.derivedStores = Cn(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(M()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(M()), this.launchedSandboxes$ = this.launchedSandboxesSubject.pipe(M()), this.runStatus$ = this.runStatusSubject.pipe(M(An)), this.statesObserver = t.statesObserver;
2521
2524
  }
2522
2525
  /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2523
2526
  getTasks() {
@@ -2553,7 +2556,7 @@ class q {
2553
2556
  * launch whose name now appears (promoted to live). metadata (heartbeat-backed) is the sole authority.
2554
2557
  */
2555
2558
  applyLaunchedSandboxes(t) {
2556
- const e = ye(t);
2559
+ const e = Se(t);
2557
2560
  this.pendingLaunches = this.pendingLaunches.filter((r) => !e.some((s) => s.sandboxName === r)), this.launchedSandboxesSubject.next(e);
2558
2561
  }
2559
2562
  /**
@@ -2614,7 +2617,7 @@ class q {
2614
2617
  }
2615
2618
  }
2616
2619
  subscribe() {
2617
- this.statesSubscription = Wt([
2620
+ this.statesSubscription = Xt([
2618
2621
  this.isConnecting$,
2619
2622
  this.conversation$,
2620
2623
  this.derivedStores.tasks$,
@@ -2764,7 +2767,7 @@ class q {
2764
2767
  sendMessage(t, e) {
2765
2768
  const r = this.runStatusSubject.value.kind;
2766
2769
  if (r) return Promise.reject(new Z(r));
2767
- const s = t.text.trim(), o = t.customMessageId ?? Ge();
2770
+ const s = t.text.trim(), o = t.customMessageId ?? qe();
2768
2771
  return this.currentUserMessageId = o, this.lastSentMessageId = o, this.conversation$.next(
2769
2772
  this.conversation$.value.pushMessage({
2770
2773
  type: "user",
@@ -2892,7 +2895,7 @@ class q {
2892
2895
  this.forceStopTimer = void 0;
2893
2896
  const t = this.runStatusSubject.value;
2894
2897
  t.stopPhase === "stopping" && this.runStatusSubject.next({ ...t, stopPhase: "force-stoppable" });
2895
- }, Cn);
2898
+ }, On);
2896
2899
  }
2897
2900
  /**
2898
2901
  * Cut the local SSE connection without telling the backend. This is *not* stop-generation (see
@@ -2909,7 +2912,7 @@ class q {
2909
2912
  this.currentRun?.unsubscribe(), this.currentRun = void 0, this.clearForceStopTimer(), this.isConnecting$.complete(), this.runStatusSubject.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.sandboxPhaseSubject.complete(), this.launchedSandboxesSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
2910
2913
  }
2911
2914
  }
2912
- function Ln(n) {
2915
+ function Un(n) {
2913
2916
  const t = /^sandbox:\/\/([^/]+)\/([^?#]+)(?:\?([^#]*))?/.exec(n.trim());
2914
2917
  if (!t) return null;
2915
2918
  const e = decodeURIComponent(t[1]), r = t[2], s = new URLSearchParams(t[3] ?? "");
@@ -2921,29 +2924,29 @@ function Ln(n) {
2921
2924
  return null;
2922
2925
  }
2923
2926
  export {
2924
- _n as AsgardServiceClient,
2927
+ Ln as AsgardServiceClient,
2925
2928
  q as Channel,
2926
2929
  Z as ChannelBusyError,
2927
2930
  v as Conversation,
2928
2931
  l as EventType,
2929
2932
  $ as FetchSseAction,
2930
2933
  w as HttpError,
2931
- We as MessageTemplateType,
2932
- Ye as ToolCallConsentResult,
2933
- yn as conversationToSubagentEvents,
2934
- xn as createDerivedStores,
2935
- wn as deriveSubagents,
2936
- Sn as deriveTasks,
2937
- mn as isAgentTool,
2938
- Pn as isChannelBusyError,
2939
- An as isHttpError,
2940
- gn as isSubagentChildTool,
2941
- fn as isTaskTool,
2942
- ye as reconcileLaunched,
2943
- bn as reduceSubagents,
2944
- pn as reduceTaskEvents,
2945
- Ln as resolveSandboxUri,
2946
- Tn as subagentsEqual,
2947
- En as tasksEqual
2934
+ Xe as MessageTemplateType,
2935
+ We as ToolCallConsentResult,
2936
+ Sn as conversationToSubagentEvents,
2937
+ Cn as createDerivedStores,
2938
+ En as deriveSubagents,
2939
+ wn as deriveTasks,
2940
+ gn as isAgentTool,
2941
+ _n as isChannelBusyError,
2942
+ Pn as isHttpError,
2943
+ bn as isSubagentChildTool,
2944
+ pn as isTaskTool,
2945
+ Se as reconcileLaunched,
2946
+ vn as reduceSubagents,
2947
+ mn as reduceTaskEvents,
2948
+ Un as resolveSandboxUri,
2949
+ xn as subagentsEqual,
2950
+ In as tasksEqual
2948
2951
  };
2949
2952
  //# sourceMappingURL=index.mjs.map