@asgard-js/core 0.3.51 → 0.3.52

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 Pn(n) {
19
+ function _n(n) {
20
20
  return n instanceof w;
21
21
  }
22
22
  class Z extends Error {
@@ -26,20 +26,30 @@ 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 _n(n) {
29
+ function Ln(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 || {}), 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) {
32
+ class we extends Error {
33
+ /** The paused batch's process id, as carried by the pending consent prompt. */
34
+ processId;
35
+ constructor(t) {
36
+ super("Cannot send a message while this channel is awaiting a tool-call consent response."), this.name = "ChannelAwaitingConsentError", this.processId = t;
37
+ }
38
+ }
39
+ function Un(n) {
40
+ return n instanceof we;
41
+ }
42
+ 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 || {}), Xe = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Xe || {}), Ve = /* @__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))(Ve || {});
43
+ async function ze(n, t) {
34
44
  const e = n.getReader();
35
45
  let r;
36
46
  for (; !(r = await e.read()).done; )
37
47
  t(r.value);
38
48
  }
39
- function ze(n) {
49
+ function Je(n) {
40
50
  let t, e, r, s = !1;
41
51
  return function(i) {
42
- t === void 0 ? (t = i, e = 0, r = -1) : t = Qe(t, i);
52
+ t === void 0 ? (t = i, e = 0, r = -1) : t = Ze(t, i);
43
53
  const a = t.length;
44
54
  let c = 0;
45
55
  for (; e < a; ) {
@@ -63,7 +73,7 @@ function ze(n) {
63
73
  c === a ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
64
74
  };
65
75
  }
66
- function Je(n, t, e) {
76
+ function Qe(n, t, e) {
67
77
  let r = ce();
68
78
  const s = new TextDecoder();
69
79
  return function(i, a) {
@@ -90,7 +100,7 @@ function Je(n, t, e) {
90
100
  }
91
101
  };
92
102
  }
93
- function Qe(n, t) {
103
+ function Ze(n, t) {
94
104
  const e = new Uint8Array(n.length + t.length);
95
105
  return e.set(n), e.set(t, n.length), e;
96
106
  }
@@ -102,7 +112,7 @@ function ce() {
102
112
  retry: void 0
103
113
  };
104
114
  }
105
- var Ze = function(n, t) {
115
+ var et = function(n, t) {
106
116
  var e = {};
107
117
  for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
108
118
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
@@ -110,9 +120,9 @@ var Ze = function(n, t) {
110
120
  t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
111
121
  return e;
112
122
  };
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"]);
123
+ const ee = "text/event-stream", tt = 1e3, ue = "last-event-id";
124
+ function Ee(n, t) {
125
+ var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h = et(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
116
126
  return new Promise((m, b) => {
117
127
  const d = Object.assign({}, r);
118
128
  d.accept || (d.accept = ee);
@@ -121,38 +131,38 @@ function we(n, t) {
121
131
  p.abort(), document.hidden || X();
122
132
  }
123
133
  c || document.addEventListener("visibilitychange", f);
124
- let _ = et, E = 0;
134
+ let _ = tt, E = 0;
125
135
  function L() {
126
136
  document.removeEventListener("visibilitychange", f), window.clearTimeout(E), p.abort();
127
137
  }
128
138
  e?.addEventListener("abort", () => {
129
139
  L(), m();
130
140
  });
131
- const Ke = u ?? window.fetch, Ye = s ?? tt;
141
+ const Ye = u ?? window.fetch, We = s ?? nt;
132
142
  async function X() {
133
143
  var V;
134
144
  p = new AbortController();
135
145
  try {
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
- x ? d[ue] = x : delete d[ue];
139
- }, (x) => {
140
- _ = x;
146
+ const H = await Ye(n, Object.assign(Object.assign({}, h), { headers: d, signal: p.signal }));
147
+ await We(H), await ze(H.body, Je(Qe((C) => {
148
+ C ? d[ue] = C : delete d[ue];
149
+ }, (C) => {
150
+ _ = C;
141
151
  }, o))), i?.(), L(), m();
142
152
  } catch (H) {
143
153
  if (!p.signal.aborted)
144
154
  try {
145
- const x = (V = a?.(H)) !== null && V !== void 0 ? V : _;
146
- window.clearTimeout(E), E = window.setTimeout(X, x);
147
- } catch (x) {
148
- L(), b(x);
155
+ const C = (V = a?.(H)) !== null && V !== void 0 ? V : _;
156
+ window.clearTimeout(E), E = window.setTimeout(X, C);
157
+ } catch (C) {
158
+ L(), b(C);
149
159
  }
150
160
  }
151
161
  }
152
162
  X();
153
163
  });
154
164
  }
155
- function tt(n) {
165
+ function nt(n) {
156
166
  const t = n.headers.get("content-type");
157
167
  if (!t?.startsWith(ee))
158
168
  throw new Error(`Expected content-type to be ${ee}, Actual: ${t}`);
@@ -173,7 +183,7 @@ function T(n, t) {
173
183
  }
174
184
  n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
175
185
  }
176
- function nt(n, t, e, r) {
186
+ function rt(n, t, e, r) {
177
187
  function s(o) {
178
188
  return o instanceof e ? o : new e(function(i) {
179
189
  i(o);
@@ -200,7 +210,7 @@ function nt(n, t, e, r) {
200
210
  u((r = r.apply(n, t || [])).next());
201
211
  });
202
212
  }
203
- function Ee(n, t) {
213
+ function Ie(n, t) {
204
214
  var e = { label: 0, sent: function() {
205
215
  if (o[0] & 1) throw o[1];
206
216
  return o[1];
@@ -295,7 +305,7 @@ function F(n, t, e) {
295
305
  function k(n) {
296
306
  return this instanceof k ? (this.v = n, this) : new k(n);
297
307
  }
298
- function rt(n, t, e) {
308
+ function st(n, t, e) {
299
309
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
300
310
  var r = e.apply(n, t || []), s, o = [];
301
311
  return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), s[Symbol.asyncIterator] = function() {
@@ -333,7 +343,7 @@ function rt(n, t, e) {
333
343
  d(p), o.shift(), o.length && c(o[0][0], o[0][1]);
334
344
  }
335
345
  }
336
- function st(n) {
346
+ function ot(n) {
337
347
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
338
348
  var t = n[Symbol.asyncIterator], e;
339
349
  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 +365,13 @@ function st(n) {
355
365
  function g(n) {
356
366
  return typeof n == "function";
357
367
  }
358
- function Ie(n) {
368
+ function Te(n) {
359
369
  var t = function(r) {
360
370
  Error.call(r), r.stack = new Error().stack;
361
371
  }, e = n(t);
362
372
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
363
373
  }
364
- var z = Ie(function(n) {
374
+ var z = Te(function(n) {
365
375
  return function(e) {
366
376
  n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
367
377
  ` + e.map(function(r, s) {
@@ -464,16 +474,16 @@ var j = (function() {
464
474
  var t = new n();
465
475
  return t.closed = !0, t;
466
476
  })(), n;
467
- })(), Te = j.EMPTY;
477
+ })(), Ce = j.EMPTY;
468
478
  function xe(n) {
469
479
  return n instanceof j || n && "closed" in n && g(n.remove) && g(n.add) && g(n.unsubscribe);
470
480
  }
471
481
  function le(n) {
472
482
  g(n) ? n() : n.unsubscribe();
473
483
  }
474
- var ot = {
484
+ var it = {
475
485
  Promise: void 0
476
- }, it = {
486
+ }, at = {
477
487
  setTimeout: function(n, t) {
478
488
  for (var e = [], r = 2; r < arguments.length; r++)
479
489
  e[r - 2] = arguments[r];
@@ -484,8 +494,8 @@ var ot = {
484
494
  },
485
495
  delegate: void 0
486
496
  };
487
- function Ce(n) {
488
- it.setTimeout(function() {
497
+ function Oe(n) {
498
+ at.setTimeout(function() {
489
499
  throw n;
490
500
  });
491
501
  }
@@ -498,7 +508,7 @@ var se = (function(n) {
498
508
  T(t, n);
499
509
  function t(e) {
500
510
  var r = n.call(this) || this;
501
- return r.isStopped = !1, e ? (r.destination = e, xe(e) && e.add(r)) : r.destination = ut, r;
511
+ return r.isStopped = !1, e ? (r.destination = e, xe(e) && e.add(r)) : r.destination = lt, r;
502
512
  }
503
513
  return t.create = function(e, r, s) {
504
514
  return new re(e, r, s);
@@ -525,7 +535,7 @@ var se = (function(n) {
525
535
  this.unsubscribe();
526
536
  }
527
537
  }, t;
528
- })(j), at = (function() {
538
+ })(j), ct = (function() {
529
539
  function n(t) {
530
540
  this.partialObserver = t;
531
541
  }
@@ -564,20 +574,20 @@ var se = (function(n) {
564
574
  next: e ?? void 0,
565
575
  error: r ?? void 0,
566
576
  complete: s ?? void 0
567
- } : i = e, o.destination = new at(i), o;
577
+ } : i = e, o.destination = new ct(i), o;
568
578
  }
569
579
  return t;
570
580
  })(se);
571
581
  function B(n) {
572
- Ce(n);
582
+ Oe(n);
573
583
  }
574
- function ct(n) {
584
+ function ut(n) {
575
585
  throw n;
576
586
  }
577
- var ut = {
587
+ var lt = {
578
588
  closed: !0,
579
589
  next: ne,
580
- error: ct,
590
+ error: ut,
581
591
  complete: ne
582
592
  }, oe = (function() {
583
593
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
@@ -585,7 +595,7 @@ var ut = {
585
595
  function W(n) {
586
596
  return n;
587
597
  }
588
- function lt(n) {
598
+ function dt(n) {
589
599
  return n.length === 0 ? W : n.length === 1 ? n[0] : function(e) {
590
600
  return n.reduce(function(r, s) {
591
601
  return s(r);
@@ -600,7 +610,7 @@ var S = (function() {
600
610
  var e = new n();
601
611
  return e.source = this, e.operator = t, e;
602
612
  }, n.prototype.subscribe = function(t, e, r) {
603
- var s = this, o = ht(t) ? t : new re(t, e, r);
613
+ var s = this, o = ft(t) ? t : new re(t, e, r);
604
614
  return G(function() {
605
615
  var i = s, a = i.operator, c = i.source;
606
616
  o.add(a ? a.call(o, c) : c ? s._subscribe(o) : s._trySubscribe(o));
@@ -635,7 +645,7 @@ var S = (function() {
635
645
  }, n.prototype.pipe = function() {
636
646
  for (var t = [], e = 0; e < arguments.length; e++)
637
647
  t[e] = arguments[e];
638
- return lt(t)(this);
648
+ return dt(t)(this);
639
649
  }, n.prototype.toPromise = function(t) {
640
650
  var e = this;
641
651
  return t = de(t), new t(function(r, s) {
@@ -654,20 +664,20 @@ var S = (function() {
654
664
  })();
655
665
  function de(n) {
656
666
  var t;
657
- return (t = n ?? ot.Promise) !== null && t !== void 0 ? t : Promise;
658
- }
659
- function dt(n) {
660
- return n && g(n.next) && g(n.error) && g(n.complete);
667
+ return (t = n ?? it.Promise) !== null && t !== void 0 ? t : Promise;
661
668
  }
662
669
  function ht(n) {
663
- return n && n instanceof se || dt(n) && xe(n);
670
+ return n && g(n.next) && g(n.error) && g(n.complete);
664
671
  }
665
672
  function ft(n) {
673
+ return n && n instanceof se || ht(n) && xe(n);
674
+ }
675
+ function pt(n) {
666
676
  return g(n?.lift);
667
677
  }
668
678
  function P(n) {
669
679
  return function(t) {
670
- if (ft(t))
680
+ if (pt(t))
671
681
  return t.lift(function(e) {
672
682
  try {
673
683
  return n(e, this);
@@ -679,9 +689,9 @@ function P(n) {
679
689
  };
680
690
  }
681
691
  function A(n, t, e, r, s) {
682
- return new pt(n, t, e, r, s);
692
+ return new mt(n, t, e, r, s);
683
693
  }
684
- var pt = (function(n) {
694
+ var mt = (function(n) {
685
695
  T(t, n);
686
696
  function t(e, r, s, o, i, a) {
687
697
  var c = n.call(this, e) || this;
@@ -716,7 +726,7 @@ var pt = (function(n) {
716
726
  n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
717
727
  }
718
728
  }, t;
719
- })(se), mt = Ie(function(n) {
729
+ })(se), gt = Te(function(n) {
720
730
  return function() {
721
731
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
722
732
  };
@@ -731,7 +741,7 @@ var pt = (function(n) {
731
741
  return r.operator = e, r;
732
742
  }, t.prototype._throwIfClosed = function() {
733
743
  if (this.closed)
734
- throw new mt();
744
+ throw new gt();
735
745
  }, t.prototype.next = function(e) {
736
746
  var r = this;
737
747
  G(function() {
@@ -787,7 +797,7 @@ var pt = (function(n) {
787
797
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
788
798
  }, t.prototype._innerSubscribe = function(e) {
789
799
  var r = this, s = this, o = s.hasError, i = s.isStopped, a = s.observers;
790
- return o || i ? Te : (this.currentObservers = null, a.push(e), new j(function() {
800
+ return o || i ? Ce : (this.currentObservers = null, a.push(e), new j(function() {
791
801
  r.currentObservers = null, K(a, e);
792
802
  }));
793
803
  }, t.prototype._checkFinalizedStatuses = function(e) {
@@ -816,9 +826,9 @@ var pt = (function(n) {
816
826
  (r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
817
827
  }, t.prototype._subscribe = function(e) {
818
828
  var r, s;
819
- return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Te;
829
+ return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Ce;
820
830
  }, t;
821
- })(ie), C = (function(n) {
831
+ })(ie), x = (function(n) {
822
832
  T(t, n);
823
833
  function t(e) {
824
834
  var r = n.call(this) || this;
@@ -841,11 +851,11 @@ var pt = (function(n) {
841
851
  }, t.prototype.next = function(e) {
842
852
  n.prototype.next.call(this, this._value = e);
843
853
  }, t;
844
- })(ie), gt = {
854
+ })(ie), bt = {
845
855
  now: function() {
846
856
  return Date.now();
847
857
  }
848
- }, bt = (function(n) {
858
+ }, vt = (function(n) {
849
859
  T(t, n);
850
860
  function t(e, r) {
851
861
  return n.call(this) || this;
@@ -863,7 +873,7 @@ var pt = (function(n) {
863
873
  return clearInterval(n);
864
874
  },
865
875
  delegate: void 0
866
- }, vt = (function(n) {
876
+ }, yt = (function(n) {
867
877
  T(t, n);
868
878
  function t(e, r) {
869
879
  var s = n.call(this, e, r) || this;
@@ -905,14 +915,14 @@ var pt = (function(n) {
905
915
  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
916
  }
907
917
  }, t;
908
- })(bt), pe = (function() {
918
+ })(vt), pe = (function() {
909
919
  function n(t, e) {
910
920
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
911
921
  }
912
922
  return n.prototype.schedule = function(t, e, r) {
913
923
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
914
- }, n.now = gt.now, n;
915
- })(), yt = (function(n) {
924
+ }, n.now = bt.now, n;
925
+ })(), St = (function(n) {
916
926
  T(t, n);
917
927
  function t(e, r) {
918
928
  r === void 0 && (r = pe.now);
@@ -937,47 +947,47 @@ var pt = (function(n) {
937
947
  throw s;
938
948
  }
939
949
  }, t;
940
- })(pe), Oe = new yt(vt), St = Oe, wt = new S(function(n) {
950
+ })(pe), Ae = new St(yt), wt = Ae, Et = new S(function(n) {
941
951
  return n.complete();
942
952
  });
943
- function Ae(n) {
953
+ function Pe(n) {
944
954
  return n && g(n.schedule);
945
955
  }
946
- function Pe(n) {
956
+ function _e(n) {
947
957
  return n[n.length - 1];
948
958
  }
949
- function Et(n) {
950
- return g(Pe(n)) ? n.pop() : void 0;
959
+ function It(n) {
960
+ return g(_e(n)) ? n.pop() : void 0;
951
961
  }
952
- function _e(n) {
953
- return Ae(Pe(n)) ? n.pop() : void 0;
962
+ function Le(n) {
963
+ return Pe(_e(n)) ? n.pop() : void 0;
954
964
  }
955
- var Le = (function(n) {
965
+ var Ue = (function(n) {
956
966
  return n && typeof n.length == "number" && typeof n != "function";
957
967
  });
958
- function Ue(n) {
968
+ function Me(n) {
959
969
  return g(n?.then);
960
970
  }
961
- function Me(n) {
971
+ function ke(n) {
962
972
  return g(n[oe]);
963
973
  }
964
- function ke(n) {
974
+ function Ne(n) {
965
975
  return Symbol.asyncIterator && g(n?.[Symbol.asyncIterator]);
966
976
  }
967
- function Ne(n) {
977
+ function Re(n) {
968
978
  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
979
  }
970
- function It() {
980
+ function Tt() {
971
981
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
972
982
  }
973
- var Re = It();
974
- function je(n) {
975
- return g(n?.[Re]);
976
- }
983
+ var je = Tt();
977
984
  function $e(n) {
978
- return rt(this, arguments, function() {
985
+ return g(n?.[je]);
986
+ }
987
+ function De(n) {
988
+ return st(this, arguments, function() {
979
989
  var e, r, s, o;
980
- return Ee(this, function(i) {
990
+ return Ie(this, function(i) {
981
991
  switch (i.label) {
982
992
  case 0:
983
993
  e = n.getReader(), i.label = 1;
@@ -1005,29 +1015,29 @@ function $e(n) {
1005
1015
  });
1006
1016
  });
1007
1017
  }
1008
- function De(n) {
1018
+ function Fe(n) {
1009
1019
  return g(n?.getReader);
1010
1020
  }
1011
1021
  function U(n) {
1012
1022
  if (n instanceof S)
1013
1023
  return n;
1014
1024
  if (n != null) {
1015
- if (Me(n))
1016
- return Tt(n);
1017
- if (Le(n))
1018
- return xt(n);
1019
- if (Ue(n))
1020
- return Ct(n);
1021
1025
  if (ke(n))
1022
- return Fe(n);
1023
- if (je(n))
1026
+ return Ct(n);
1027
+ if (Ue(n))
1028
+ return xt(n);
1029
+ if (Me(n))
1024
1030
  return Ot(n);
1025
- if (De(n))
1031
+ if (Ne(n))
1032
+ return He(n);
1033
+ if ($e(n))
1026
1034
  return At(n);
1035
+ if (Fe(n))
1036
+ return Pt(n);
1027
1037
  }
1028
- throw Ne(n);
1038
+ throw Re(n);
1029
1039
  }
1030
- function Tt(n) {
1040
+ function Ct(n) {
1031
1041
  return new S(function(t) {
1032
1042
  var e = n[oe]();
1033
1043
  if (g(e.subscribe))
@@ -1042,16 +1052,16 @@ function xt(n) {
1042
1052
  t.complete();
1043
1053
  });
1044
1054
  }
1045
- function Ct(n) {
1055
+ function Ot(n) {
1046
1056
  return new S(function(t) {
1047
1057
  n.then(function(e) {
1048
1058
  t.closed || (t.next(e), t.complete());
1049
1059
  }, function(e) {
1050
1060
  return t.error(e);
1051
- }).then(null, Ce);
1061
+ }).then(null, Oe);
1052
1062
  });
1053
1063
  }
1054
- function Ot(n) {
1064
+ function At(n) {
1055
1065
  return new S(function(t) {
1056
1066
  var e, r;
1057
1067
  try {
@@ -1072,24 +1082,24 @@ function Ot(n) {
1072
1082
  t.complete();
1073
1083
  });
1074
1084
  }
1075
- function Fe(n) {
1085
+ function He(n) {
1076
1086
  return new S(function(t) {
1077
- Pt(n, t).catch(function(e) {
1087
+ _t(n, t).catch(function(e) {
1078
1088
  return t.error(e);
1079
1089
  });
1080
1090
  });
1081
1091
  }
1082
- function At(n) {
1083
- return Fe($e(n));
1092
+ function Pt(n) {
1093
+ return He(De(n));
1084
1094
  }
1085
- function Pt(n, t) {
1095
+ function _t(n, t) {
1086
1096
  var e, r, s, o;
1087
- return nt(this, void 0, void 0, function() {
1097
+ return rt(this, void 0, void 0, function() {
1088
1098
  var i, a;
1089
- return Ee(this, function(c) {
1099
+ return Ie(this, function(c) {
1090
1100
  switch (c.label) {
1091
1101
  case 0:
1092
- c.trys.push([0, 5, 6, 11]), e = st(n), c.label = 1;
1102
+ c.trys.push([0, 5, 6, 11]), e = ot(n), c.label = 1;
1093
1103
  case 1:
1094
1104
  return [4, e.next()];
1095
1105
  case 2:
@@ -1128,7 +1138,7 @@ function O(n, t, e, r, s) {
1128
1138
  if (n.add(o), !s)
1129
1139
  return o;
1130
1140
  }
1131
- function He(n, t) {
1141
+ function Be(n, t) {
1132
1142
  return t === void 0 && (t = 0), P(function(e, r) {
1133
1143
  e.subscribe(A(r, function(s) {
1134
1144
  return O(r, n, function() {
@@ -1145,20 +1155,20 @@ function He(n, t) {
1145
1155
  }));
1146
1156
  });
1147
1157
  }
1148
- function Be(n, t) {
1158
+ function Ge(n, t) {
1149
1159
  return t === void 0 && (t = 0), P(function(e, r) {
1150
1160
  r.add(n.schedule(function() {
1151
1161
  return e.subscribe(r);
1152
1162
  }, t));
1153
1163
  });
1154
1164
  }
1155
- function _t(n, t) {
1156
- return U(n).pipe(Be(t), He(t));
1157
- }
1158
1165
  function Lt(n, t) {
1159
- return U(n).pipe(Be(t), He(t));
1166
+ return U(n).pipe(Ge(t), Be(t));
1160
1167
  }
1161
1168
  function Ut(n, t) {
1169
+ return U(n).pipe(Ge(t), Be(t));
1170
+ }
1171
+ function Mt(n, t) {
1162
1172
  return new S(function(e) {
1163
1173
  var r = 0;
1164
1174
  return t.schedule(function() {
@@ -1166,11 +1176,11 @@ function Ut(n, t) {
1166
1176
  });
1167
1177
  });
1168
1178
  }
1169
- function Mt(n, t) {
1179
+ function kt(n, t) {
1170
1180
  return new S(function(e) {
1171
1181
  var r;
1172
1182
  return O(e, t, function() {
1173
- r = n[Re](), O(e, t, function() {
1183
+ r = n[je](), O(e, t, function() {
1174
1184
  var s, o, i;
1175
1185
  try {
1176
1186
  s = r.next(), o = s.value, i = s.done;
@@ -1185,7 +1195,7 @@ function Mt(n, t) {
1185
1195
  };
1186
1196
  });
1187
1197
  }
1188
- function Ge(n, t) {
1198
+ function qe(n, t) {
1189
1199
  if (!n)
1190
1200
  throw new Error("Iterable cannot be null");
1191
1201
  return new S(function(e) {
@@ -1199,36 +1209,36 @@ function Ge(n, t) {
1199
1209
  });
1200
1210
  });
1201
1211
  }
1202
- function kt(n, t) {
1203
- return Ge($e(n), t);
1204
- }
1205
1212
  function Nt(n, t) {
1213
+ return qe(De(n), t);
1214
+ }
1215
+ function Rt(n, t) {
1206
1216
  if (n != null) {
1207
- if (Me(n))
1208
- return _t(n, t);
1209
- if (Le(n))
1210
- return Ut(n, t);
1211
- if (Ue(n))
1212
- return Lt(n, t);
1213
1217
  if (ke(n))
1214
- return Ge(n, t);
1215
- if (je(n))
1218
+ return Lt(n, t);
1219
+ if (Ue(n))
1216
1220
  return Mt(n, t);
1217
- if (De(n))
1221
+ if (Me(n))
1222
+ return Ut(n, t);
1223
+ if (Ne(n))
1224
+ return qe(n, t);
1225
+ if ($e(n))
1218
1226
  return kt(n, t);
1227
+ if (Fe(n))
1228
+ return Nt(n, t);
1219
1229
  }
1220
- throw Ne(n);
1230
+ throw Re(n);
1221
1231
  }
1222
1232
  function ae(n, t) {
1223
- return t ? Nt(n, t) : U(n);
1233
+ return t ? Rt(n, t) : U(n);
1224
1234
  }
1225
- function Rt() {
1235
+ function jt() {
1226
1236
  for (var n = [], t = 0; t < arguments.length; t++)
1227
1237
  n[t] = arguments[t];
1228
- var e = _e(n);
1238
+ var e = Le(n);
1229
1239
  return ae(n, e);
1230
1240
  }
1231
- function jt(n) {
1241
+ function $t(n) {
1232
1242
  return n instanceof Date && !isNaN(n);
1233
1243
  }
1234
1244
  function R(n, t) {
@@ -1239,23 +1249,23 @@ function R(n, t) {
1239
1249
  }));
1240
1250
  });
1241
1251
  }
1242
- var $t = Array.isArray;
1243
- function Dt(n, t) {
1244
- return $t(t) ? n.apply(void 0, F([], D(t))) : n(t);
1252
+ var Dt = Array.isArray;
1253
+ function Ft(n, t) {
1254
+ return Dt(t) ? n.apply(void 0, F([], D(t))) : n(t);
1245
1255
  }
1246
- function Ft(n) {
1256
+ function Ht(n) {
1247
1257
  return R(function(t) {
1248
- return Dt(n, t);
1258
+ return Ft(n, t);
1249
1259
  });
1250
1260
  }
1251
- var Ht = Array.isArray, Bt = Object.getPrototypeOf, Gt = Object.prototype, qt = Object.keys;
1252
- function Kt(n) {
1261
+ var Bt = Array.isArray, Gt = Object.getPrototypeOf, qt = Object.prototype, Kt = Object.keys;
1262
+ function Yt(n) {
1253
1263
  if (n.length === 1) {
1254
1264
  var t = n[0];
1255
- if (Ht(t))
1265
+ if (Bt(t))
1256
1266
  return { args: t, keys: null };
1257
- if (Yt(t)) {
1258
- var e = qt(t);
1267
+ if (Wt(t)) {
1268
+ var e = Kt(t);
1259
1269
  return {
1260
1270
  args: e.map(function(r) {
1261
1271
  return t[r];
@@ -1266,26 +1276,26 @@ function Kt(n) {
1266
1276
  }
1267
1277
  return { args: n, keys: null };
1268
1278
  }
1269
- function Yt(n) {
1270
- return n && typeof n == "object" && Bt(n) === Gt;
1279
+ function Wt(n) {
1280
+ return n && typeof n == "object" && Gt(n) === qt;
1271
1281
  }
1272
- function Wt(n, t) {
1282
+ function Xt(n, t) {
1273
1283
  return n.reduce(function(e, r, s) {
1274
1284
  return e[r] = t[s], e;
1275
1285
  }, {});
1276
1286
  }
1277
- function Xt() {
1287
+ function Vt() {
1278
1288
  for (var n = [], t = 0; t < arguments.length; t++)
1279
1289
  n[t] = arguments[t];
1280
- var e = _e(n), r = Et(n), s = Kt(n), o = s.args, i = s.keys;
1290
+ var e = Le(n), r = It(n), s = Yt(n), o = s.args, i = s.keys;
1281
1291
  if (o.length === 0)
1282
1292
  return ae([], e);
1283
- var a = new S(Vt(o, e, i ? function(c) {
1284
- return Wt(i, c);
1293
+ var a = new S(zt(o, e, i ? function(c) {
1294
+ return Xt(i, c);
1285
1295
  } : W));
1286
- return r ? a.pipe(Ft(r)) : a;
1296
+ return r ? a.pipe(Ht(r)) : a;
1287
1297
  }
1288
- function Vt(n, t, e) {
1298
+ function zt(n, t, e) {
1289
1299
  return e === void 0 && (e = W), function(r) {
1290
1300
  me(t, function() {
1291
1301
  for (var s = n.length, o = new Array(s), i = s, a = s, c = function(h) {
@@ -1305,7 +1315,7 @@ function Vt(n, t, e) {
1305
1315
  function me(n, t, e) {
1306
1316
  n ? O(e, n, t) : t();
1307
1317
  }
1308
- function zt(n, t, e, r, s, o, i, a) {
1318
+ function Jt(n, t, e, r, s, o, i, a) {
1309
1319
  var c = [], u = 0, h = 0, m = !1, b = function() {
1310
1320
  m && !c.length && !u && t.complete();
1311
1321
  }, d = function(f) {
@@ -1343,14 +1353,14 @@ function Y(n, t, e) {
1343
1353
  return t(r, o, s, i);
1344
1354
  })(U(n(r, s)));
1345
1355
  }, e) : (typeof t == "number" && (e = t), P(function(r, s) {
1346
- return zt(r, s, n, e);
1356
+ return Jt(r, s, n, e);
1347
1357
  }));
1348
1358
  }
1349
- function Jt(n, t, e) {
1350
- n === void 0 && (n = 0), e === void 0 && (e = St);
1359
+ function Qt(n, t, e) {
1360
+ n === void 0 && (n = 0), e === void 0 && (e = wt);
1351
1361
  var r = -1;
1352
- return t != null && (Ae(t) ? e = t : r = t), new S(function(s) {
1353
- var o = jt(n) ? +n - e.now() : n;
1362
+ return t != null && (Pe(t) ? e = t : r = t), new S(function(s) {
1363
+ var o = $t(n) ? +n - e.now() : n;
1354
1364
  o < 0 && (o = 0);
1355
1365
  var i = 0;
1356
1366
  return e.schedule(function() {
@@ -1358,12 +1368,12 @@ function Jt(n, t, e) {
1358
1368
  }, o);
1359
1369
  });
1360
1370
  }
1361
- function Qt(n, t) {
1371
+ function Zt(n, t) {
1362
1372
  return g(t) ? Y(n, t, 1) : Y(n, 1);
1363
1373
  }
1364
- function Zt(n) {
1374
+ function en(n) {
1365
1375
  return n <= 0 ? function() {
1366
- return wt;
1376
+ return Et;
1367
1377
  } : P(function(t, e) {
1368
1378
  var r = 0;
1369
1379
  t.subscribe(A(e, function(s) {
@@ -1371,25 +1381,25 @@ function Zt(n) {
1371
1381
  }));
1372
1382
  });
1373
1383
  }
1374
- function en(n) {
1384
+ function tn(n) {
1375
1385
  return R(function() {
1376
1386
  return n;
1377
1387
  });
1378
1388
  }
1379
- function tn(n, t) {
1389
+ function nn(n, t) {
1380
1390
  return Y(function(e, r) {
1381
- return U(n(e, r)).pipe(Zt(1), en(e));
1391
+ return U(n(e, r)).pipe(en(1), tn(e));
1382
1392
  });
1383
1393
  }
1384
- function nn(n, t) {
1385
- t === void 0 && (t = Oe);
1386
- var e = Jt(n, t);
1387
- return tn(function() {
1394
+ function rn(n, t) {
1395
+ t === void 0 && (t = Ae);
1396
+ var e = Qt(n, t);
1397
+ return nn(function() {
1388
1398
  return e;
1389
1399
  });
1390
1400
  }
1391
1401
  function M(n, t) {
1392
- return t === void 0 && (t = W), n = n ?? rn, P(function(e, r) {
1402
+ return t === void 0 && (t = W), n = n ?? sn, P(function(e, r) {
1393
1403
  var s, o = !0;
1394
1404
  e.subscribe(A(r, function(i) {
1395
1405
  var a = t(i);
@@ -1397,10 +1407,10 @@ function M(n, t) {
1397
1407
  }));
1398
1408
  });
1399
1409
  }
1400
- function rn(n, t) {
1410
+ function sn(n, t) {
1401
1411
  return n === t;
1402
1412
  }
1403
- function sn(n) {
1413
+ function on(n) {
1404
1414
  return P(function(t, e) {
1405
1415
  try {
1406
1416
  t.subscribe(e);
@@ -1409,7 +1419,7 @@ function sn(n) {
1409
1419
  }
1410
1420
  });
1411
1421
  }
1412
- function on(n) {
1422
+ function an(n) {
1413
1423
  return P(function(t, e) {
1414
1424
  U(n).subscribe(A(e, function() {
1415
1425
  return e.complete();
@@ -1427,7 +1437,7 @@ function ge(n) {
1427
1437
  };
1428
1438
  e && (b["X-API-KEY"] = e);
1429
1439
  const d = new URL(t);
1430
- return s && d.searchParams.set("is_debug", "true"), we(d.toString(), {
1440
+ return s && d.searchParams.set("is_debug", "true"), Ee(d.toString(), {
1431
1441
  method: i,
1432
1442
  headers: b,
1433
1443
  body: i === "POST" && r ? JSON.stringify(r) : void 0,
@@ -1472,7 +1482,7 @@ function ge(n) {
1472
1482
  };
1473
1483
  });
1474
1484
  }
1475
- class an {
1485
+ class cn {
1476
1486
  listeners = {};
1477
1487
  on(t, e) {
1478
1488
  this.listeners = Object.assign({}, this.listeners, {
@@ -1491,7 +1501,7 @@ class an {
1491
1501
  this.listeners[t] && this.listeners[t].forEach((r) => r(...e));
1492
1502
  }
1493
1503
  }
1494
- class Ln {
1504
+ class Mn {
1495
1505
  apiKey;
1496
1506
  endpoint;
1497
1507
  botProviderEndpoint;
@@ -1501,7 +1511,7 @@ class Ln {
1501
1511
  detached = !1;
1502
1512
  detachTimer;
1503
1513
  inFlight = 0;
1504
- sseEmitter = new an();
1514
+ sseEmitter = new cn();
1505
1515
  transformSsePayload;
1506
1516
  customHeaders;
1507
1517
  constructor(t) {
@@ -1659,11 +1669,11 @@ class Ln {
1659
1669
  // No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
1660
1670
  // run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
1661
1671
  // create-sse-observable); a no-cursor failure surfaces via `error` below.
1662
- Qt((r) => Rt(r).pipe(nn(e?.delayTime ?? 50))),
1663
- on(this.destroy$),
1672
+ Zt((r) => jt(r).pipe(rn(e?.delayTime ?? 50))),
1673
+ an(this.destroy$),
1664
1674
  // Settle the run accounting on every termination path — complete, error, AND a user-initiated
1665
1675
  // unsubscribe (stop-generation aborts the connection without a terminal event).
1666
- sn(() => this.onRunSettled())
1676
+ on(() => this.onRunSettled())
1667
1677
  ).subscribe({
1668
1678
  next: (r) => {
1669
1679
  this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
@@ -1904,7 +1914,7 @@ class Ln {
1904
1914
  const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/watch`);
1905
1915
  return r.searchParams.set("path", e), new S((s) => {
1906
1916
  const o = new AbortController();
1907
- return we(r.toString(), {
1917
+ return Ee(r.toString(), {
1908
1918
  headers: this.apiHeaders(),
1909
1919
  signal: o.signal,
1910
1920
  openWhenHidden: !0,
@@ -1944,29 +1954,29 @@ class Ln {
1944
1954
  const y = [];
1945
1955
  for (let n = 0; n < 256; ++n)
1946
1956
  y.push((n + 256).toString(16).slice(1));
1947
- function cn(n, t = 0) {
1957
+ function un(n, t = 0) {
1948
1958
  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
1959
  }
1950
1960
  let J;
1951
- const un = new Uint8Array(16);
1952
- function ln() {
1961
+ const ln = new Uint8Array(16);
1962
+ function dn() {
1953
1963
  if (!J) {
1954
1964
  if (typeof crypto > "u" || !crypto.getRandomValues)
1955
1965
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1956
1966
  J = crypto.getRandomValues.bind(crypto);
1957
1967
  }
1958
- return J(un);
1968
+ return J(ln);
1959
1969
  }
1960
- const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), be = { randomUUID: dn };
1961
- function hn(n, t, e) {
1970
+ const hn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), be = { randomUUID: hn };
1971
+ function fn(n, t, e) {
1962
1972
  n = n || {};
1963
- const r = n.random ?? n.rng?.() ?? ln();
1973
+ const r = n.random ?? n.rng?.() ?? dn();
1964
1974
  if (r.length < 16)
1965
1975
  throw new Error("Random bytes length must be >= 16");
1966
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, cn(r);
1976
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, un(r);
1967
1977
  }
1968
- function qe(n, t, e) {
1969
- return be.randomUUID && !n ? be.randomUUID() : hn(n);
1978
+ function Ke(n, t, e) {
1979
+ return be.randomUUID && !n ? be.randomUUID() : fn(n);
1970
1980
  }
1971
1981
  class v {
1972
1982
  messages = null;
@@ -2178,7 +2188,7 @@ class v {
2178
2188
  return s.set(e.messageId, o), new v({ messages: s, pendingConsent: this.pendingConsent });
2179
2189
  }
2180
2190
  onMessageError(t) {
2181
- const e = qe(), r = t.fact.runError.error, s = new Map(this.messages);
2191
+ const e = Ke(), r = t.fact.runError.error, s = new Map(this.messages);
2182
2192
  return s.set(e, {
2183
2193
  type: "error",
2184
2194
  eventType: l.ERROR,
@@ -2280,9 +2290,9 @@ class v {
2280
2290
  return r.delete(s), r.set(s, o), new v({ messages: r, pendingConsent: this.pendingConsent });
2281
2291
  }
2282
2292
  }
2283
- const fn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2284
- function pn(n) {
2285
- return n.toolsetName === "" && fn.has(n.toolName);
2293
+ const pn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2294
+ function mn(n) {
2295
+ return n.toolsetName === "" && pn.has(n.toolName);
2286
2296
  }
2287
2297
  function ve(n) {
2288
2298
  return typeof n == "object" && n !== null ? n : void 0;
@@ -2290,7 +2300,7 @@ function ve(n) {
2290
2300
  function I(n) {
2291
2301
  return typeof n == "string" ? n : void 0;
2292
2302
  }
2293
- function mn(n) {
2303
+ function gn(n) {
2294
2304
  const t = [], e = /* @__PURE__ */ new Map();
2295
2305
  for (const r of n) {
2296
2306
  const s = r.parameter ?? {}, o = r.sidecar ?? {};
@@ -2314,16 +2324,16 @@ function mn(n) {
2314
2324
  }
2315
2325
  return t.map((r) => e.get(r));
2316
2326
  }
2317
- function gn(n) {
2327
+ function bn(n) {
2318
2328
  return n.toolsetName === "" && n.toolName === "Agent";
2319
2329
  }
2320
- function bn(n) {
2330
+ function vn(n) {
2321
2331
  return !!n;
2322
2332
  }
2323
2333
  function ye(n) {
2324
2334
  n.status !== "running" && (n.status = "running", n.summary = void 0);
2325
2335
  }
2326
- function vn(n) {
2336
+ function yn(n) {
2327
2337
  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));
2328
2338
  for (const o of n)
2329
2339
  switch (o.kind) {
@@ -2364,21 +2374,21 @@ function vn(n) {
2364
2374
  tools: Array.from(r.get(o).values())
2365
2375
  }));
2366
2376
  }
2367
- function yn(n) {
2377
+ function Sn(n) {
2368
2378
  return typeof n == "string" ? n : void 0;
2369
2379
  }
2370
- function Sn(n) {
2380
+ function wn(n) {
2371
2381
  const t = [];
2372
2382
  for (const e of n) {
2373
- if (e.type === "tool-call" && gn(e)) {
2383
+ if (e.type === "tool-call" && bn(e)) {
2374
2384
  t.push({
2375
2385
  kind: "agentStart",
2376
2386
  toolUseId: e.toolUseId ?? e.messageId,
2377
- description: yn(e.parameter.description)
2387
+ description: Sn(e.parameter.description)
2378
2388
  });
2379
2389
  continue;
2380
2390
  }
2381
- if (e.type === "tool-call" && bn(e.parentToolUseId)) {
2391
+ if (e.type === "tool-call" && vn(e.parentToolUseId)) {
2382
2392
  const r = e.toolUseId ?? e.messageId;
2383
2393
  t.push({
2384
2394
  kind: "toolStart",
@@ -2415,22 +2425,22 @@ function Sn(n) {
2415
2425
  }
2416
2426
  return t;
2417
2427
  }
2418
- function wn(n) {
2428
+ function En(n) {
2419
2429
  const t = Array.from(n.messages?.values() ?? []).filter(
2420
- (e) => e.type === "tool-call" && e.isComplete && pn(e)
2430
+ (e) => e.type === "tool-call" && e.isComplete && mn(e)
2421
2431
  );
2422
- return mn(t);
2432
+ return gn(t);
2423
2433
  }
2424
- function En(n) {
2425
- return vn(Sn(Array.from(n.messages?.values() ?? [])));
2434
+ function In(n) {
2435
+ return yn(wn(Array.from(n.messages?.values() ?? [])));
2426
2436
  }
2427
- function In(n, t) {
2437
+ function Tn(n, t) {
2428
2438
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
2429
2439
  const s = t[r];
2430
2440
  return e.id === s.id && e.status === s.status && e.subject === s.subject && e.activeForm === s.activeForm && e.description === s.description;
2431
2441
  });
2432
2442
  }
2433
- function Tn(n, t) {
2443
+ function Cn(n, t) {
2434
2444
  return n.length !== t.length ? !1 : n.every((e, r) => {
2435
2445
  const s = t[r];
2436
2446
  return e.toolName === s.toolName && e.toolsetName === s.toolsetName && e.status === s.status && e.reason === s.reason;
@@ -2439,13 +2449,13 @@ function Tn(n, t) {
2439
2449
  function xn(n, t) {
2440
2450
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
2441
2451
  const s = t[r];
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);
2452
+ return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary && Cn(e.tools, s.tools);
2443
2453
  });
2444
2454
  }
2445
- function Cn(n) {
2446
- const t = new C([]), e = new C([]), r = new j();
2447
- return r.add(n.pipe(R(wn), M(In)).subscribe(t)), r.add(
2448
- n.pipe(R(En), M(xn)).subscribe(e)
2455
+ function On(n) {
2456
+ const t = new x([]), e = new x([]), r = new j();
2457
+ return r.add(n.pipe(R(En), M(Tn)).subscribe(t)), r.add(
2458
+ n.pipe(R(In), M(xn)).subscribe(e)
2449
2459
  ), {
2450
2460
  tasks$: t.asObservable(),
2451
2461
  subagents$: e.asObservable(),
@@ -2461,8 +2471,8 @@ function Se(n) {
2461
2471
  (e, r) => (e.sandboxBlueprintName || e.sandboxName).localeCompare(r.sandboxBlueprintName || r.sandboxName)
2462
2472
  );
2463
2473
  }
2464
- const Q = { kind: null, stopPhase: "idle" }, On = 1e4;
2465
- function An(n, t) {
2474
+ const Q = { kind: null, stopPhase: "idle" }, An = 1e4;
2475
+ function Pn(n, t) {
2466
2476
  return n.kind === t.kind && n.stopPhase === t.stopPhase && n.requestId === t.requestId;
2467
2477
  }
2468
2478
  class q {
@@ -2518,9 +2528,9 @@ class q {
2518
2528
  throw new Error("client must be required");
2519
2529
  if (!t.customChannelId)
2520
2530
  throw new Error("customChannelId must be required");
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(
2531
+ this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new x(!1), this.runStatusSubject = new x(Q), this.conversation$ = new x(t.conversation), this.channelTitleSubject = new x(t.channelTitle ?? null), this.sandboxPhaseSubject = new x("idle"), this.launchedSandboxesSubject = new x(
2522
2532
  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;
2533
+ ), this.derivedStores = On(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(Pn)), this.statesObserver = t.statesObserver;
2524
2534
  }
2525
2535
  /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2526
2536
  getTasks() {
@@ -2617,7 +2627,7 @@ class q {
2617
2627
  }
2618
2628
  }
2619
2629
  subscribe() {
2620
- this.statesSubscription = Xt([
2630
+ this.statesSubscription = Vt([
2621
2631
  this.isConnecting$,
2622
2632
  this.conversation$,
2623
2633
  this.derivedStores.tasks$,
@@ -2699,7 +2709,9 @@ class q {
2699
2709
  i && i.type === "user" && (o.set(this.currentUserMessageId, {
2700
2710
  ...i,
2701
2711
  traceId: s.traceId
2702
- }), this.conversation$.next(new v({ messages: o }))), this.currentUserMessageId = void 0;
2712
+ }), this.conversation$.next(
2713
+ new v({ messages: o, pendingConsent: this.conversation$.value.pendingConsent })
2714
+ )), this.currentUserMessageId = void 0;
2703
2715
  }
2704
2716
  this.conversation$.next(this.conversation$.value.onMessage(s));
2705
2717
  },
@@ -2767,12 +2779,14 @@ class q {
2767
2779
  sendMessage(t, e) {
2768
2780
  const r = this.runStatusSubject.value.kind;
2769
2781
  if (r) return Promise.reject(new Z(r));
2770
- const s = t.text.trim(), o = t.customMessageId ?? qe();
2771
- return this.currentUserMessageId = o, this.lastSentMessageId = o, this.conversation$.next(
2782
+ const s = this.conversation$.value.pendingConsent;
2783
+ if (s) return Promise.reject(new we(s.processId));
2784
+ const o = t.text.trim(), i = t.customMessageId ?? Ke();
2785
+ return this.currentUserMessageId = i, this.lastSentMessageId = i, this.conversation$.next(
2772
2786
  this.conversation$.value.pushMessage({
2773
2787
  type: "user",
2774
- messageId: o,
2775
- text: s,
2788
+ messageId: i,
2789
+ text: o,
2776
2790
  blobIds: t.blobIds,
2777
2791
  filePreviewUrls: t.filePreviewUrls,
2778
2792
  documentNames: t.documentNames,
@@ -2783,9 +2797,9 @@ class q {
2783
2797
  {
2784
2798
  action: $.NONE,
2785
2799
  customChannelId: this.customChannelId,
2786
- customMessageId: o,
2800
+ customMessageId: i,
2787
2801
  payload: this.resolvePayload(t?.payload),
2788
- text: s,
2802
+ text: o,
2789
2803
  blobIds: t?.blobIds
2790
2804
  },
2791
2805
  e
@@ -2895,7 +2909,7 @@ class q {
2895
2909
  this.forceStopTimer = void 0;
2896
2910
  const t = this.runStatusSubject.value;
2897
2911
  t.stopPhase === "stopping" && this.runStatusSubject.next({ ...t, stopPhase: "force-stoppable" });
2898
- }, On);
2912
+ }, An);
2899
2913
  }
2900
2914
  /**
2901
2915
  * Cut the local SSE connection without telling the backend. This is *not* stop-generation (see
@@ -2912,7 +2926,7 @@ class q {
2912
2926
  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();
2913
2927
  }
2914
2928
  }
2915
- function Un(n) {
2929
+ function kn(n) {
2916
2930
  const t = /^sandbox:\/\/([^/]+)\/([^?#]+)(?:\?([^#]*))?/.exec(n.trim());
2917
2931
  if (!t) return null;
2918
2932
  const e = decodeURIComponent(t[1]), r = t[2], s = new URLSearchParams(t[3] ?? "");
@@ -2924,29 +2938,31 @@ function Un(n) {
2924
2938
  return null;
2925
2939
  }
2926
2940
  export {
2927
- Ln as AsgardServiceClient,
2941
+ Mn as AsgardServiceClient,
2928
2942
  q as Channel,
2943
+ we as ChannelAwaitingConsentError,
2929
2944
  Z as ChannelBusyError,
2930
2945
  v as Conversation,
2931
2946
  l as EventType,
2932
2947
  $ as FetchSseAction,
2933
2948
  w as HttpError,
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,
2949
+ Ve as MessageTemplateType,
2950
+ Xe as ToolCallConsentResult,
2951
+ wn as conversationToSubagentEvents,
2952
+ On as createDerivedStores,
2953
+ In as deriveSubagents,
2954
+ En as deriveTasks,
2955
+ bn as isAgentTool,
2956
+ Un as isChannelAwaitingConsentError,
2957
+ Ln as isChannelBusyError,
2958
+ _n as isHttpError,
2959
+ vn as isSubagentChildTool,
2960
+ mn as isTaskTool,
2945
2961
  Se as reconcileLaunched,
2946
- vn as reduceSubagents,
2947
- mn as reduceTaskEvents,
2948
- Un as resolveSandboxUri,
2962
+ yn as reduceSubagents,
2963
+ gn as reduceTaskEvents,
2964
+ kn as resolveSandboxUri,
2949
2965
  xn as subagentsEqual,
2950
- In as tasksEqual
2966
+ Tn as tasksEqual
2951
2967
  };
2952
2968
  //# sourceMappingURL=index.mjs.map