@asgard-js/core 0.3.28 → 0.3.30

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
@@ -19,7 +19,7 @@ class w extends Error {
19
19
  function An(n) {
20
20
  return n instanceof w;
21
21
  }
22
- class ye extends Error {
22
+ class Z extends Error {
23
23
  /** Which run is holding the channel. */
24
24
  runKind;
25
25
  constructor(t) {
@@ -27,7 +27,7 @@ class ye extends Error {
27
27
  }
28
28
  }
29
29
  function Pn(n) {
30
- return n instanceof ye;
30
+ return n instanceof Z;
31
31
  }
32
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
33
  async function Xe(n, t) {
@@ -64,11 +64,11 @@ function Ve(n) {
64
64
  };
65
65
  }
66
66
  function ze(n, t, e) {
67
- let r = ae();
67
+ let r = ce();
68
68
  const s = new TextDecoder();
69
69
  return function(i, a) {
70
70
  if (i.length === 0)
71
- e?.(r), r = ae();
71
+ e?.(r), r = ce();
72
72
  else if (a > 0) {
73
73
  const c = s.decode(i.subarray(0, a)), u = a + (i[a + 1] === 32 ? 2 : 1), h = s.decode(i.subarray(u));
74
74
  switch (c) {
@@ -94,7 +94,7 @@ function Je(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
  }
97
- function ae() {
97
+ function ce() {
98
98
  return {
99
99
  data: "",
100
100
  event: "",
@@ -110,12 +110,12 @@ 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 Z = "text/event-stream", Ze = 1e3, ce = "last-event-id";
113
+ const ee = "text/event-stream", Ze = 1e3, ue = "last-event-id";
114
114
  function Se(n, t) {
115
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"]);
116
116
  return new Promise((m, b) => {
117
117
  const d = Object.assign({}, r);
118
- d.accept || (d.accept = Z);
118
+ d.accept || (d.accept = ee);
119
119
  let p;
120
120
  function f() {
121
121
  p.abort(), document.hidden || X();
@@ -135,7 +135,7 @@ function Se(n, t) {
135
135
  try {
136
136
  const H = await Ke(n, Object.assign(Object.assign({}, h), { headers: d, signal: p.signal }));
137
137
  await qe(H), await Xe(H.body, Ve(ze((x) => {
138
- x ? d[ce] = x : delete d[ce];
138
+ x ? d[ue] = x : delete d[ue];
139
139
  }, (x) => {
140
140
  _ = x;
141
141
  }, o))), i?.(), L(), m();
@@ -154,20 +154,20 @@ function Se(n, t) {
154
154
  }
155
155
  function et(n) {
156
156
  const t = n.headers.get("content-type");
157
- if (!t?.startsWith(Z))
158
- throw new Error(`Expected content-type to be ${Z}, Actual: ${t}`);
157
+ if (!t?.startsWith(ee))
158
+ throw new Error(`Expected content-type to be ${ee}, Actual: ${t}`);
159
159
  }
160
- var ee = function(n, t) {
161
- return ee = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
160
+ var te = function(n, t) {
161
+ return te = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
162
162
  e.__proto__ = r;
163
163
  } || function(e, r) {
164
164
  for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
165
- }, ee(n, t);
165
+ }, te(n, t);
166
166
  };
167
167
  function T(n, t) {
168
168
  if (typeof t != "function" && t !== null)
169
169
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
170
- ee(n, t);
170
+ te(n, t);
171
171
  function e() {
172
172
  this.constructor = n;
173
173
  }
@@ -417,7 +417,7 @@ var j = (function() {
417
417
  for (var b = R(m), d = b.next(); !d.done; d = b.next()) {
418
418
  var p = d.value;
419
419
  try {
420
- ue(p);
420
+ le(p);
421
421
  } catch (f) {
422
422
  o = o ?? [], f instanceof z ? o = F(F([], D(o)), D(f.errors)) : o.push(f);
423
423
  }
@@ -439,7 +439,7 @@ var j = (function() {
439
439
  var e;
440
440
  if (t && t !== this)
441
441
  if (this.closed)
442
- ue(t);
442
+ le(t);
443
443
  else {
444
444
  if (t instanceof n) {
445
445
  if (t.closed || t._hasParent(this))
@@ -468,7 +468,7 @@ var j = (function() {
468
468
  function Te(n) {
469
469
  return n instanceof j || n && "closed" in n && g(n.remove) && g(n.add) && g(n.unsubscribe);
470
470
  }
471
- function ue(n) {
471
+ function le(n) {
472
472
  g(n) ? n() : n.unsubscribe();
473
473
  }
474
474
  var st = {
@@ -489,19 +489,19 @@ function xe(n) {
489
489
  throw n;
490
490
  });
491
491
  }
492
- function te() {
492
+ function ne() {
493
493
  }
494
494
  function G(n) {
495
495
  n();
496
496
  }
497
- var re = (function(n) {
497
+ var se = (function(n) {
498
498
  T(t, n);
499
499
  function t(e) {
500
500
  var r = n.call(this) || this;
501
501
  return r.isStopped = !1, e ? (r.destination = e, Te(e) && e.add(r)) : r.destination = ct, r;
502
502
  }
503
503
  return t.create = function(e, r, s) {
504
- return new ne(e, r, s);
504
+ return new re(e, r, s);
505
505
  }, t.prototype.next = function(e) {
506
506
  this.isStopped || this._next(e);
507
507
  }, t.prototype.error = function(e) {
@@ -556,7 +556,7 @@ var re = (function(n) {
556
556
  B(e);
557
557
  }
558
558
  }, n;
559
- })(), ne = (function(n) {
559
+ })(), re = (function(n) {
560
560
  T(t, n);
561
561
  function t(e, r, s) {
562
562
  var o = n.call(this) || this, i;
@@ -567,7 +567,7 @@ var re = (function(n) {
567
567
  } : i = e, o.destination = new it(i), o;
568
568
  }
569
569
  return t;
570
- })(re);
570
+ })(se);
571
571
  function B(n) {
572
572
  xe(n);
573
573
  }
@@ -576,10 +576,10 @@ function at(n) {
576
576
  }
577
577
  var ct = {
578
578
  closed: !0,
579
- next: te,
579
+ next: ne,
580
580
  error: at,
581
- complete: te
582
- }, se = (function() {
581
+ complete: ne
582
+ }, oe = (function() {
583
583
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
584
584
  })();
585
585
  function W(n) {
@@ -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 ne(t, e, r);
603
+ var s = this, o = dt(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));
@@ -613,8 +613,8 @@ var S = (function() {
613
613
  }
614
614
  }, n.prototype.forEach = function(t, e) {
615
615
  var r = this;
616
- return e = le(e), new e(function(s, o) {
617
- var i = new ne({
616
+ return e = de(e), new e(function(s, o) {
617
+ var i = new re({
618
618
  next: function(a) {
619
619
  try {
620
620
  t(a);
@@ -630,7 +630,7 @@ var S = (function() {
630
630
  }, n.prototype._subscribe = function(t) {
631
631
  var e;
632
632
  return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
633
- }, n.prototype[se] = function() {
633
+ }, n.prototype[oe] = function() {
634
634
  return this;
635
635
  }, n.prototype.pipe = function() {
636
636
  for (var t = [], e = 0; e < arguments.length; e++)
@@ -638,7 +638,7 @@ var S = (function() {
638
638
  return ut(t)(this);
639
639
  }, n.prototype.toPromise = function(t) {
640
640
  var e = this;
641
- return t = le(t), new t(function(r, s) {
641
+ return t = de(t), new t(function(r, s) {
642
642
  var o;
643
643
  e.subscribe(function(i) {
644
644
  return o = i;
@@ -652,7 +652,7 @@ var S = (function() {
652
652
  return new n(t);
653
653
  }, n;
654
654
  })();
655
- function le(n) {
655
+ function de(n) {
656
656
  var t;
657
657
  return (t = n ?? st.Promise) !== null && t !== void 0 ? t : Promise;
658
658
  }
@@ -660,7 +660,7 @@ function lt(n) {
660
660
  return n && g(n.next) && g(n.error) && g(n.complete);
661
661
  }
662
662
  function dt(n) {
663
- return n && n instanceof re || lt(n) && Te(n);
663
+ return n && n instanceof se || lt(n) && Te(n);
664
664
  }
665
665
  function ht(n) {
666
666
  return g(n?.lift);
@@ -716,18 +716,18 @@ 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
- })(re), pt = Ee(function(n) {
719
+ })(se), pt = Ee(function(n) {
720
720
  return function() {
721
721
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
722
722
  };
723
- }), oe = (function(n) {
723
+ }), ie = (function(n) {
724
724
  T(t, n);
725
725
  function t() {
726
726
  var e = n.call(this) || this;
727
727
  return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
728
728
  }
729
729
  return t.prototype.lift = function(e) {
730
- var r = new de(this, this);
730
+ var r = new he(this, this);
731
731
  return r.operator = e, r;
732
732
  }, t.prototype._throwIfClosed = function() {
733
733
  if (this.closed)
@@ -797,9 +797,9 @@ var ft = (function(n) {
797
797
  var e = new S();
798
798
  return e.source = this, e;
799
799
  }, t.create = function(e, r) {
800
- return new de(e, r);
800
+ return new he(e, r);
801
801
  }, t;
802
- })(S), de = (function(n) {
802
+ })(S), he = (function(n) {
803
803
  T(t, n);
804
804
  function t(e, r) {
805
805
  var s = n.call(this) || this;
@@ -818,7 +818,7 @@ var ft = (function(n) {
818
818
  var r, s;
819
819
  return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Ie;
820
820
  }, t;
821
- })(oe), C = (function(n) {
821
+ })(ie), C = (function(n) {
822
822
  T(t, n);
823
823
  function t(e) {
824
824
  var r = n.call(this) || this;
@@ -841,7 +841,7 @@ 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
- })(oe), mt = {
844
+ })(ie), mt = {
845
845
  now: function() {
846
846
  return Date.now();
847
847
  }
@@ -853,7 +853,7 @@ var ft = (function(n) {
853
853
  return t.prototype.schedule = function(e, r) {
854
854
  return this;
855
855
  }, t;
856
- })(j), he = {
856
+ })(j), fe = {
857
857
  setInterval: function(n, t) {
858
858
  for (var e = [], r = 2; r < arguments.length; r++)
859
859
  e[r - 2] = arguments[r];
@@ -877,11 +877,11 @@ var ft = (function(n) {
877
877
  var o = this.id, i = this.scheduler;
878
878
  return o != null && (this.id = this.recycleAsyncId(i, o, r)), this.pending = !0, this.delay = r, this.id = (s = this.id) !== null && s !== void 0 ? s : this.requestAsyncId(i, this.id, r), this;
879
879
  }, t.prototype.requestAsyncId = function(e, r, s) {
880
- return s === void 0 && (s = 0), he.setInterval(e.flush.bind(e, this), s);
880
+ return s === void 0 && (s = 0), fe.setInterval(e.flush.bind(e, this), s);
881
881
  }, t.prototype.recycleAsyncId = function(e, r, s) {
882
882
  if (s === void 0 && (s = 0), s != null && this.delay === s && this.pending === !1)
883
883
  return r;
884
- r != null && he.clearInterval(r);
884
+ r != null && fe.clearInterval(r);
885
885
  }, t.prototype.execute = function(e, r) {
886
886
  if (this.closed)
887
887
  return new Error("executing a cancelled action");
@@ -905,7 +905,7 @@ var ft = (function(n) {
905
905
  this.work = this.state = this.scheduler = null, this.pending = !1, q(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), fe = (function() {
908
+ })(gt), pe = (function() {
909
909
  function n(t, e) {
910
910
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
911
911
  }
@@ -915,7 +915,7 @@ var ft = (function(n) {
915
915
  })(), vt = (function(n) {
916
916
  T(t, n);
917
917
  function t(e, r) {
918
- r === void 0 && (r = fe.now);
918
+ r === void 0 && (r = pe.now);
919
919
  var s = n.call(this, e, r) || this;
920
920
  return s.actions = [], s._active = !1, s;
921
921
  }
@@ -937,7 +937,7 @@ var ft = (function(n) {
937
937
  throw s;
938
938
  }
939
939
  }, t;
940
- })(fe), Ce = new vt(bt), yt = Ce, St = new S(function(n) {
940
+ })(pe), Ce = new vt(bt), yt = Ce, St = new S(function(n) {
941
941
  return n.complete();
942
942
  });
943
943
  function Oe(n) {
@@ -959,7 +959,7 @@ function Le(n) {
959
959
  return g(n?.then);
960
960
  }
961
961
  function Ue(n) {
962
- return g(n[se]);
962
+ return g(n[oe]);
963
963
  }
964
964
  function Me(n) {
965
965
  return Symbol.asyncIterator && g(n?.[Symbol.asyncIterator]);
@@ -1029,7 +1029,7 @@ function U(n) {
1029
1029
  }
1030
1030
  function It(n) {
1031
1031
  return new S(function(t) {
1032
- var e = n[se]();
1032
+ var e = n[oe]();
1033
1033
  if (g(e.subscribe))
1034
1034
  return e.subscribe(t);
1035
1035
  throw new TypeError("Provided object does not correctly implement Symbol.observable");
@@ -1219,14 +1219,14 @@ function kt(n, t) {
1219
1219
  }
1220
1220
  throw ke(n);
1221
1221
  }
1222
- function ie(n, t) {
1222
+ function ae(n, t) {
1223
1223
  return t ? kt(n, t) : U(n);
1224
1224
  }
1225
1225
  function Rt() {
1226
1226
  for (var n = [], t = 0; t < arguments.length; t++)
1227
1227
  n[t] = arguments[t];
1228
1228
  var e = Pe(n);
1229
- return ie(n, e);
1229
+ return ae(n, e);
1230
1230
  }
1231
1231
  function Nt(n) {
1232
1232
  return n instanceof Date && !isNaN(n);
@@ -1279,7 +1279,7 @@ function Wt() {
1279
1279
  n[t] = arguments[t];
1280
1280
  var e = Pe(n), r = wt(n), s = Kt(n), o = s.args, i = s.keys;
1281
1281
  if (o.length === 0)
1282
- return ie([], e);
1282
+ return ae([], e);
1283
1283
  var a = new S(Xt(o, e, i ? function(c) {
1284
1284
  return Yt(i, c);
1285
1285
  } : W));
@@ -1287,10 +1287,10 @@ function Wt() {
1287
1287
  }
1288
1288
  function Xt(n, t, e) {
1289
1289
  return e === void 0 && (e = W), function(r) {
1290
- pe(t, function() {
1290
+ me(t, function() {
1291
1291
  for (var s = n.length, o = new Array(s), i = s, a = s, c = function(h) {
1292
- pe(t, function() {
1293
- var m = ie(n[h], t), b = !1;
1292
+ me(t, function() {
1293
+ var m = ae(n[h], t), b = !1;
1294
1294
  m.subscribe(A(r, function(d) {
1295
1295
  o[h] = d, b || (b = !0, a--), a || r.next(e(o.slice()));
1296
1296
  }, function() {
@@ -1302,7 +1302,7 @@ function Xt(n, t, e) {
1302
1302
  }, r);
1303
1303
  };
1304
1304
  }
1305
- function pe(n, t, e) {
1305
+ function me(n, t, e) {
1306
1306
  n ? O(e, n, t) : t();
1307
1307
  }
1308
1308
  function Vt(n, t, e, r, s, o, i, a) {
@@ -1413,10 +1413,10 @@ function sn(n) {
1413
1413
  return P(function(t, e) {
1414
1414
  U(n).subscribe(A(e, function() {
1415
1415
  return e.complete();
1416
- }, te)), !e.closed && t.subscribe(e);
1416
+ }, ne)), !e.closed && t.subscribe(e);
1417
1417
  });
1418
1418
  }
1419
- function me(n) {
1419
+ function ge(n) {
1420
1420
  const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders: o } = n, i = n.method ?? "POST";
1421
1421
  return new S((a) => {
1422
1422
  const c = new AbortController();
@@ -1496,7 +1496,7 @@ class _n {
1496
1496
  endpoint;
1497
1497
  botProviderEndpoint;
1498
1498
  debugMode;
1499
- destroy$ = new oe();
1499
+ destroy$ = new ie();
1500
1500
  closed = !1;
1501
1501
  detached = !1;
1502
1502
  detachTimer;
@@ -1554,7 +1554,7 @@ class _n {
1554
1554
  }
1555
1555
  fetchSse(t, e) {
1556
1556
  return e?.onSseStart?.(), this.inFlight += 1, this.runSse(
1557
- me({
1557
+ ge({
1558
1558
  apiKey: this.apiKey,
1559
1559
  endpoint: this.endpoint,
1560
1560
  debugMode: this.debugMode,
@@ -1573,7 +1573,7 @@ class _n {
1573
1573
  e?.onSseStart?.(), this.inFlight += 1;
1574
1574
  const r = new URL(this.endpoint);
1575
1575
  return r.searchParams.set("custom_channel_id", t), this.runSse(
1576
- me({
1576
+ ge({
1577
1577
  apiKey: this.apiKey,
1578
1578
  endpoint: r.toString(),
1579
1579
  debugMode: this.debugMode,
@@ -1957,7 +1957,7 @@ function un() {
1957
1957
  }
1958
1958
  return J(cn);
1959
1959
  }
1960
- const ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ge = { randomUUID: ln };
1960
+ const ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), be = { randomUUID: ln };
1961
1961
  function dn(n, t, e) {
1962
1962
  n = n || {};
1963
1963
  const r = n.random ?? n.rng?.() ?? un();
@@ -1966,7 +1966,7 @@ function dn(n, t, e) {
1966
1966
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, an(r);
1967
1967
  }
1968
1968
  function Ge(n, t, e) {
1969
- return ge.randomUUID && !n ? ge.randomUUID() : dn(n);
1969
+ return be.randomUUID && !n ? be.randomUUID() : dn(n);
1970
1970
  }
1971
1971
  class v {
1972
1972
  messages = null;
@@ -2252,7 +2252,7 @@ const hn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2252
2252
  function fn(n) {
2253
2253
  return n.toolsetName === "" && hn.has(n.toolName);
2254
2254
  }
2255
- function be(n) {
2255
+ function ve(n) {
2256
2256
  return typeof n == "object" && n !== null ? n : void 0;
2257
2257
  }
2258
2258
  function I(n) {
@@ -2263,7 +2263,7 @@ function pn(n) {
2263
2263
  for (const r of n) {
2264
2264
  const s = r.parameter ?? {}, o = r.sidecar ?? {};
2265
2265
  if (r.toolName === "TaskCreate") {
2266
- const i = be(o.task), a = I(i?.id);
2266
+ const i = ve(o.task), a = I(i?.id);
2267
2267
  if (!a) continue;
2268
2268
  e.has(a) || t.push(a), e.set(a, {
2269
2269
  id: a,
@@ -2274,7 +2274,7 @@ function pn(n) {
2274
2274
  // initial status = pending (keep existing on repeat)
2275
2275
  });
2276
2276
  } else if (r.toolName === "TaskUpdate") {
2277
- const i = be(o.statusChange), a = I(s.taskId) || I(o.taskId), c = I(i?.to) || I(s.status);
2277
+ const i = ve(o.statusChange), a = I(s.taskId) || I(o.taskId), c = I(i?.to) || I(s.status);
2278
2278
  if (!a || !c) continue;
2279
2279
  const u = e.get(a);
2280
2280
  u && e.set(a, { ...u, status: c });
@@ -2419,7 +2419,7 @@ function xn(n) {
2419
2419
  teardown: () => r.unsubscribe()
2420
2420
  };
2421
2421
  }
2422
- function ve(n) {
2422
+ function ye(n) {
2423
2423
  const t = /* @__PURE__ */ new Map();
2424
2424
  for (const e of n) t.set(e.sandboxName, e);
2425
2425
  return [...t.values()].sort(
@@ -2484,7 +2484,7 @@ class K {
2484
2484
  if (!t.customChannelId)
2485
2485
  throw new Error("customChannelId must be required");
2486
2486
  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(
2487
- ve(t.launchedSandboxes ?? [])
2487
+ ye(t.launchedSandboxes ?? [])
2488
2488
  ), 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;
2489
2489
  }
2490
2490
  /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
@@ -2521,7 +2521,7 @@ class K {
2521
2521
  * launch whose name now appears (promoted to live). metadata (heartbeat-backed) is the sole authority.
2522
2522
  */
2523
2523
  applyLaunchedSandboxes(t) {
2524
- const e = ve(t);
2524
+ const e = ye(t);
2525
2525
  this.pendingLaunches = this.pendingLaunches.filter((r) => !e.some((s) => s.sandboxName === r)), this.launchedSandboxesSubject.next(e);
2526
2526
  }
2527
2527
  /**
@@ -2731,7 +2731,7 @@ class K {
2731
2731
  }
2732
2732
  sendMessage(t, e) {
2733
2733
  const r = this.runStatusSubject.value.kind;
2734
- if (r) return Promise.reject(new ye(r));
2734
+ if (r) return Promise.reject(new Z(r));
2735
2735
  const s = t.text.trim(), o = t.customMessageId ?? Ge();
2736
2736
  return this.currentUserMessageId = o, this.lastSentMessageId = o, this.conversation$.next(
2737
2737
  this.conversation$.value.pushMessage({
@@ -2775,14 +2775,29 @@ class K {
2775
2775
  * text — the backend suppresses `message.*` and writes no transcript, so nothing renders in the
2776
2776
  * conversation; the FE simply waits for the resulting `sandbox.launch`/`ready` frames (and a metadata
2777
2777
  * refetch) to refill `launchedSandboxes$`. An invisible turn, unlike `sendMessage`.
2778
+ *
2779
+ * Invisible, but still a real turn — so it needs `payload` exactly like the other three outbounds
2780
+ * (BUG-004). The backend rebuilds `prevPayload` from *this* turn's incoming payload and never carries
2781
+ * the previous turn's over, and the sandbox blueprint reads its subagents / source-set mounts /
2782
+ * working directory straight out of it. Omitting payload therefore wakes an empty sandbox rather than
2783
+ * the one the channel was working in, and every one of those expressions has a falsy fallback, so it
2784
+ * fails silently.
2785
+ *
2786
+ * @param payload Turn-level payload, resolved through the same path as `sendMessage` — pass a
2787
+ * function to compute it at send time. In `@asgard-js/react` this is filled in automatically from
2788
+ * `onBeforeSendMessage`.
2789
+ *
2790
+ * Rejects with `ChannelBusyError` when a run already holds the channel, exactly like `sendMessage`.
2778
2791
  */
2779
- nudge(t) {
2780
- return this.fetchSse(
2792
+ nudge(t, e) {
2793
+ const r = this.runStatusSubject.value.kind;
2794
+ return r ? Promise.reject(new Z(r)) : this.fetchSse(
2781
2795
  "nudge",
2782
2796
  {
2783
2797
  action: $.NUDGE,
2784
2798
  customChannelId: this.customChannelId,
2785
2799
  customMessageId: this.lastSentMessageId ?? this.customMessageId,
2800
+ payload: this.resolvePayload(e),
2786
2801
  text: ""
2787
2802
  },
2788
2803
  t
@@ -2876,7 +2891,7 @@ function Ln(n) {
2876
2891
  export {
2877
2892
  _n as AsgardServiceClient,
2878
2893
  K as Channel,
2879
- ye as ChannelBusyError,
2894
+ Z as ChannelBusyError,
2880
2895
  v as Conversation,
2881
2896
  l as EventType,
2882
2897
  $ as FetchSseAction,
@@ -2892,7 +2907,7 @@ export {
2892
2907
  An as isHttpError,
2893
2908
  gn as isSubagentChildTool,
2894
2909
  fn as isTaskTool,
2895
- ve as reconcileLaunched,
2910
+ ye as reconcileLaunched,
2896
2911
  bn as reduceSubagents,
2897
2912
  pn as reduceTaskEvents,
2898
2913
  Ln as resolveSandboxUri,