@asgard-js/core 0.3.84 → 0.3.86

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
@@ -1,4 +1,4 @@
1
- class y extends Error {
1
+ class A extends Error {
2
2
  status;
3
3
  statusText;
4
4
  /**
@@ -16,20 +16,20 @@ class y extends Error {
16
16
  super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = s;
17
17
  }
18
18
  }
19
- function _n(n) {
20
- return n instanceof y;
19
+ function Kn(n) {
20
+ return n instanceof A;
21
21
  }
22
- class te extends Error {
22
+ class se extends Error {
23
23
  /** Which run is holding the channel. */
24
24
  runKind;
25
25
  constructor(t) {
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 Mn(n) {
30
- return n instanceof te;
29
+ function Wn(n) {
30
+ return n instanceof se;
31
31
  }
32
- class ne extends Error {
32
+ class re extends Error {
33
33
  /**
34
34
  * The paused batch's process id, as carried by the pending consent prompt.
35
35
  *
@@ -43,26 +43,26 @@ class ne extends Error {
43
43
  super("Cannot send this turn while the channel is awaiting a tool-call consent response."), this.name = "ChannelAwaitingConsentError", this.processId = t;
44
44
  }
45
45
  }
46
- function Un(n) {
47
- return n instanceof ne;
46
+ function Vn(n) {
47
+ return n instanceof re;
48
48
  }
49
- var H = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))(H || {}), 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.MESSAGE_CANVAS_START = "asgard.message.canvas.start", n.MESSAGE_CANVAS_DELTA = "asgard.message.canvas.delta", n.MESSAGE_CANVAS_COMPLETE = "asgard.message.canvas.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.PROMPT_SUGGESTION = "asgard.prompt_suggestion", n.SANDBOX_LAUNCH = "asgard.sandbox.launch", n.SANDBOX_READY = "asgard.sandbox.ready", n.MESSAGE_FEEDBACK = "asgard.message.feedback", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(l || {}), ze = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(ze || {}), Ce = /* @__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.QUESTION = "QUESTION", n.CANVAS = "CANVAS", n))(Ce || {});
50
- async function Je(n, t) {
49
+ var G = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))(G || {}), h = /* @__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.MESSAGE_CANVAS_START = "asgard.message.canvas.start", n.MESSAGE_CANVAS_DELTA = "asgard.message.canvas.delta", n.MESSAGE_CANVAS_COMPLETE = "asgard.message.canvas.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.PROMPT_SUGGESTION = "asgard.prompt_suggestion", n.SANDBOX_LAUNCH = "asgard.sandbox.launch", n.SANDBOX_READY = "asgard.sandbox.ready", n.MESSAGE_FEEDBACK = "asgard.message.feedback", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(h || {}), tt = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(tt || {}), Oe = /* @__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.QUESTION = "QUESTION", n.CANVAS = "CANVAS", n))(Oe || {});
50
+ async function nt(n, t) {
51
51
  const e = n.getReader();
52
52
  let s;
53
53
  for (; !(s = await e.read()).done; )
54
54
  t(s.value);
55
55
  }
56
- function Qe(n) {
56
+ function st(n) {
57
57
  let t, e, s, r = !1;
58
- return function(a) {
59
- t === void 0 ? (t = a, e = 0, s = -1) : t = et(t, a);
60
- const o = t.length;
58
+ return function(i) {
59
+ t === void 0 ? (t = i, e = 0, s = -1) : t = ot(t, i);
60
+ const a = t.length;
61
61
  let c = 0;
62
- for (; e < o; ) {
62
+ for (; e < a; ) {
63
63
  r && (t[e] === 10 && (c = ++e), r = !1);
64
64
  let u = -1;
65
- for (; e < o && u === -1; ++e)
65
+ for (; e < a && u === -1; ++e)
66
66
  switch (t[e]) {
67
67
  case 58:
68
68
  s === -1 && (s = e - c);
@@ -77,41 +77,41 @@ function Qe(n) {
77
77
  break;
78
78
  n(t.subarray(c, u), s), c = e, s = -1;
79
79
  }
80
- c === o ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
80
+ c === a ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
81
81
  };
82
82
  }
83
- function Ze(n, t, e) {
84
- let s = le();
83
+ function rt(n, t, e) {
84
+ let s = he();
85
85
  const r = new TextDecoder();
86
- return function(a, o) {
87
- if (a.length === 0)
88
- e?.(s), s = le();
89
- else if (o > 0) {
90
- const c = r.decode(a.subarray(0, o)), u = o + (a[o + 1] === 32 ? 2 : 1), d = r.decode(a.subarray(u));
86
+ return function(i, a) {
87
+ if (i.length === 0)
88
+ e?.(s), s = he();
89
+ else if (a > 0) {
90
+ const c = r.decode(i.subarray(0, a)), u = a + (i[a + 1] === 32 ? 2 : 1), l = r.decode(i.subarray(u));
91
91
  switch (c) {
92
92
  case "data":
93
93
  s.data = s.data ? s.data + `
94
- ` + d : d;
94
+ ` + l : l;
95
95
  break;
96
96
  case "event":
97
- s.event = d;
97
+ s.event = l;
98
98
  break;
99
99
  case "id":
100
- n(s.id = d);
100
+ n(s.id = l);
101
101
  break;
102
102
  case "retry":
103
- const m = parseInt(d, 10);
104
- isNaN(m) || t(s.retry = m);
103
+ const v = parseInt(l, 10);
104
+ isNaN(v) || t(s.retry = v);
105
105
  break;
106
106
  }
107
107
  }
108
108
  };
109
109
  }
110
- function et(n, t) {
110
+ function ot(n, t) {
111
111
  const e = new Uint8Array(n.length + t.length);
112
112
  return e.set(n), e.set(t, n.length), e;
113
113
  }
114
- function le() {
114
+ function he() {
115
115
  return {
116
116
  data: "",
117
117
  event: "",
@@ -119,7 +119,7 @@ function le() {
119
119
  retry: void 0
120
120
  };
121
121
  }
122
- var tt = function(n, t) {
122
+ var it = function(n, t) {
123
123
  var e = {};
124
124
  for (var s in n) Object.prototype.hasOwnProperty.call(n, s) && t.indexOf(s) < 0 && (e[s] = n[s]);
125
125
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
@@ -127,117 +127,117 @@ var tt = function(n, t) {
127
127
  t.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, s[r]) && (e[s[r]] = n[s[r]]);
128
128
  return e;
129
129
  };
130
- const se = "text/event-stream", nt = 1e3, de = "last-event-id";
131
- function xe(n, t) {
132
- var { signal: e, headers: s, onopen: r, onmessage: i, onclose: a, onerror: o, openWhenHidden: c, fetch: u } = t, d = tt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
133
- return new Promise((m, v) => {
134
- const h = Object.assign({}, s);
135
- h.accept || (h.accept = se);
136
- let p;
137
- function f() {
138
- p.abort(), document.hidden || F();
130
+ const oe = "text/event-stream", at = 1e3, fe = "last-event-id";
131
+ function ke(n, t) {
132
+ var { signal: e, headers: s, onopen: r, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, l = it(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
133
+ return new Promise((v, w) => {
134
+ const p = Object.assign({}, s);
135
+ p.accept || (p.accept = oe);
136
+ let g;
137
+ function d() {
138
+ g.abort(), document.hidden || b();
139
139
  }
140
- c || document.addEventListener("visibilitychange", f);
141
- let I = nt, E = 0;
142
- function B() {
143
- document.removeEventListener("visibilitychange", f), window.clearTimeout(E), p.abort();
140
+ c || document.addEventListener("visibilitychange", d);
141
+ let C = at, x = 0;
142
+ function f() {
143
+ document.removeEventListener("visibilitychange", d), window.clearTimeout(x), g.abort();
144
144
  }
145
145
  e?.addEventListener("abort", () => {
146
- B(), m();
146
+ f(), v();
147
147
  });
148
- const R = u ?? window.fetch, _ = r ?? st;
149
- async function F() {
150
- var j;
151
- p = new AbortController();
148
+ const m = u ?? window.fetch, S = r ?? ct;
149
+ async function b() {
150
+ var I;
151
+ g = new AbortController();
152
152
  try {
153
- const $ = await R(n, Object.assign(Object.assign({}, d), { headers: h, signal: p.signal }));
154
- await _($), await Je($.body, Qe(Ze((k) => {
155
- k ? h[de] = k : delete h[de];
156
- }, (k) => {
157
- I = k;
158
- }, i))), a?.(), B(), m();
159
- } catch ($) {
160
- if (!p.signal.aborted)
153
+ const M = await m(n, Object.assign(Object.assign({}, l), { headers: p, signal: g.signal }));
154
+ await S(M), await nt(M.body, st(rt((_) => {
155
+ _ ? p[fe] = _ : delete p[fe];
156
+ }, (_) => {
157
+ C = _;
158
+ }, o))), i?.(), f(), v();
159
+ } catch (M) {
160
+ if (!g.signal.aborted)
161
161
  try {
162
- const k = (j = o?.($)) !== null && j !== void 0 ? j : I;
163
- window.clearTimeout(E), E = window.setTimeout(F, k);
164
- } catch (k) {
165
- B(), v(k);
162
+ const _ = (I = a?.(M)) !== null && I !== void 0 ? I : C;
163
+ window.clearTimeout(x), x = window.setTimeout(b, _);
164
+ } catch (_) {
165
+ f(), w(_);
166
166
  }
167
167
  }
168
168
  }
169
- F();
169
+ b();
170
170
  });
171
171
  }
172
- function st(n) {
172
+ function ct(n) {
173
173
  const t = n.headers.get("content-type");
174
- if (!t?.startsWith(se))
175
- throw new Error(`Expected content-type to be ${se}, Actual: ${t}`);
174
+ if (!t?.startsWith(oe))
175
+ throw new Error(`Expected content-type to be ${oe}, Actual: ${t}`);
176
176
  }
177
- var re = function(n, t) {
178
- return re = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, s) {
177
+ var ie = function(n, t) {
178
+ return ie = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, s) {
179
179
  e.__proto__ = s;
180
180
  } || function(e, s) {
181
181
  for (var r in s) Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
182
- }, re(n, t);
182
+ }, ie(n, t);
183
183
  };
184
- function O(n, t) {
184
+ function N(n, t) {
185
185
  if (typeof t != "function" && t !== null)
186
186
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
187
- re(n, t);
187
+ ie(n, t);
188
188
  function e() {
189
189
  this.constructor = n;
190
190
  }
191
191
  n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
192
192
  }
193
- function rt(n, t, e, s) {
194
- function r(i) {
195
- return i instanceof e ? i : new e(function(a) {
196
- a(i);
193
+ function ut(n, t, e, s) {
194
+ function r(o) {
195
+ return o instanceof e ? o : new e(function(i) {
196
+ i(o);
197
197
  });
198
198
  }
199
- return new (e || (e = Promise))(function(i, a) {
200
- function o(d) {
199
+ return new (e || (e = Promise))(function(o, i) {
200
+ function a(l) {
201
201
  try {
202
- u(s.next(d));
203
- } catch (m) {
204
- a(m);
202
+ u(s.next(l));
203
+ } catch (v) {
204
+ i(v);
205
205
  }
206
206
  }
207
- function c(d) {
207
+ function c(l) {
208
208
  try {
209
- u(s.throw(d));
210
- } catch (m) {
211
- a(m);
209
+ u(s.throw(l));
210
+ } catch (v) {
211
+ i(v);
212
212
  }
213
213
  }
214
- function u(d) {
215
- d.done ? i(d.value) : r(d.value).then(o, c);
214
+ function u(l) {
215
+ l.done ? o(l.value) : r(l.value).then(a, c);
216
216
  }
217
217
  u((s = s.apply(n, t || [])).next());
218
218
  });
219
219
  }
220
- function Ae(n, t) {
220
+ function _e(n, t) {
221
221
  var e = { label: 0, sent: function() {
222
- if (i[0] & 1) throw i[1];
223
- return i[1];
224
- }, trys: [], ops: [] }, s, r, i, a = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
225
- return a.next = o(0), a.throw = o(1), a.return = o(2), typeof Symbol == "function" && (a[Symbol.iterator] = function() {
222
+ if (o[0] & 1) throw o[1];
223
+ return o[1];
224
+ }, trys: [], ops: [] }, s, r, o, i = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
225
+ return i.next = a(0), i.throw = a(1), i.return = a(2), typeof Symbol == "function" && (i[Symbol.iterator] = function() {
226
226
  return this;
227
- }), a;
228
- function o(u) {
229
- return function(d) {
230
- return c([u, d]);
227
+ }), i;
228
+ function a(u) {
229
+ return function(l) {
230
+ return c([u, l]);
231
231
  };
232
232
  }
233
233
  function c(u) {
234
234
  if (s) throw new TypeError("Generator is already executing.");
235
- for (; a && (a = 0, u[0] && (e = 0)), e; ) try {
236
- if (s = 1, r && (i = u[0] & 2 ? r.return : u[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, u[1])).done) return i;
237
- switch (r = 0, i && (u = [u[0] & 2, i.value]), u[0]) {
235
+ for (; i && (i = 0, u[0] && (e = 0)), e; ) try {
236
+ if (s = 1, r && (o = u[0] & 2 ? r.return : u[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, u[1])).done) return o;
237
+ switch (r = 0, o && (u = [u[0] & 2, o.value]), u[0]) {
238
238
  case 0:
239
239
  case 1:
240
- i = u;
240
+ o = u;
241
241
  break;
242
242
  case 4:
243
243
  return e.label++, { value: u[1], done: !1 };
@@ -248,36 +248,36 @@ function Ae(n, t) {
248
248
  u = e.ops.pop(), e.trys.pop();
249
249
  continue;
250
250
  default:
251
- if (i = e.trys, !(i = i.length > 0 && i[i.length - 1]) && (u[0] === 6 || u[0] === 2)) {
251
+ if (o = e.trys, !(o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
252
252
  e = 0;
253
253
  continue;
254
254
  }
255
- if (u[0] === 3 && (!i || u[1] > i[0] && u[1] < i[3])) {
255
+ if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
256
256
  e.label = u[1];
257
257
  break;
258
258
  }
259
- if (u[0] === 6 && e.label < i[1]) {
260
- e.label = i[1], i = u;
259
+ if (u[0] === 6 && e.label < o[1]) {
260
+ e.label = o[1], o = u;
261
261
  break;
262
262
  }
263
- if (i && e.label < i[2]) {
264
- e.label = i[2], e.ops.push(u);
263
+ if (o && e.label < o[2]) {
264
+ e.label = o[2], e.ops.push(u);
265
265
  break;
266
266
  }
267
- i[2] && e.ops.pop(), e.trys.pop();
267
+ o[2] && e.ops.pop(), e.trys.pop();
268
268
  continue;
269
269
  }
270
270
  u = t.call(n, e);
271
- } catch (d) {
272
- u = [6, d], r = 0;
271
+ } catch (l) {
272
+ u = [6, l], r = 0;
273
273
  } finally {
274
- s = i = 0;
274
+ s = o = 0;
275
275
  }
276
276
  if (u[0] & 5) throw u[1];
277
277
  return { value: u[0] ? u[1] : void 0, done: !0 };
278
278
  }
279
279
  }
280
- function U(n) {
280
+ function $(n) {
281
281
  var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], s = 0;
282
282
  if (e) return e.call(n);
283
283
  if (n && typeof n.length == "number") return {
@@ -287,98 +287,98 @@ function U(n) {
287
287
  };
288
288
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
289
289
  }
290
- function q(n, t) {
290
+ function K(n, t) {
291
291
  var e = typeof Symbol == "function" && n[Symbol.iterator];
292
292
  if (!e) return n;
293
- var s = e.call(n), r, i = [], a;
293
+ var s = e.call(n), r, o = [], i;
294
294
  try {
295
- for (; (t === void 0 || t-- > 0) && !(r = s.next()).done; ) i.push(r.value);
296
- } catch (o) {
297
- a = { error: o };
295
+ for (; (t === void 0 || t-- > 0) && !(r = s.next()).done; ) o.push(r.value);
296
+ } catch (a) {
297
+ i = { error: a };
298
298
  } finally {
299
299
  try {
300
300
  r && !r.done && (e = s.return) && e.call(s);
301
301
  } finally {
302
- if (a) throw a.error;
302
+ if (i) throw i.error;
303
303
  }
304
304
  }
305
- return i;
305
+ return o;
306
306
  }
307
- function K(n, t, e) {
308
- if (e || arguments.length === 2) for (var s = 0, r = t.length, i; s < r; s++)
309
- (i || !(s in t)) && (i || (i = Array.prototype.slice.call(t, 0, s)), i[s] = t[s]);
310
- return n.concat(i || Array.prototype.slice.call(t));
307
+ function W(n, t, e) {
308
+ if (e || arguments.length === 2) for (var s = 0, r = t.length, o; s < r; s++)
309
+ (o || !(s in t)) && (o || (o = Array.prototype.slice.call(t, 0, s)), o[s] = t[s]);
310
+ return n.concat(o || Array.prototype.slice.call(t));
311
311
  }
312
- function D(n) {
313
- return this instanceof D ? (this.v = n, this) : new D(n);
312
+ function B(n) {
313
+ return this instanceof B ? (this.v = n, this) : new B(n);
314
314
  }
315
- function it(n, t, e) {
315
+ function lt(n, t, e) {
316
316
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
317
- var s = e.apply(n, t || []), r, i = [];
318
- return r = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), o("next"), o("throw"), o("return", a), r[Symbol.asyncIterator] = function() {
317
+ var s = e.apply(n, t || []), r, o = [];
318
+ return r = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), r[Symbol.asyncIterator] = function() {
319
319
  return this;
320
320
  }, r;
321
- function a(h) {
322
- return function(p) {
323
- return Promise.resolve(p).then(h, m);
321
+ function i(p) {
322
+ return function(g) {
323
+ return Promise.resolve(g).then(p, v);
324
324
  };
325
325
  }
326
- function o(h, p) {
327
- s[h] && (r[h] = function(f) {
328
- return new Promise(function(I, E) {
329
- i.push([h, f, I, E]) > 1 || c(h, f);
326
+ function a(p, g) {
327
+ s[p] && (r[p] = function(d) {
328
+ return new Promise(function(C, x) {
329
+ o.push([p, d, C, x]) > 1 || c(p, d);
330
330
  });
331
- }, p && (r[h] = p(r[h])));
331
+ }, g && (r[p] = g(r[p])));
332
332
  }
333
- function c(h, p) {
333
+ function c(p, g) {
334
334
  try {
335
- u(s[h](p));
336
- } catch (f) {
337
- v(i[0][3], f);
335
+ u(s[p](g));
336
+ } catch (d) {
337
+ w(o[0][3], d);
338
338
  }
339
339
  }
340
- function u(h) {
341
- h.value instanceof D ? Promise.resolve(h.value.v).then(d, m) : v(i[0][2], h);
340
+ function u(p) {
341
+ p.value instanceof B ? Promise.resolve(p.value.v).then(l, v) : w(o[0][2], p);
342
342
  }
343
- function d(h) {
344
- c("next", h);
343
+ function l(p) {
344
+ c("next", p);
345
345
  }
346
- function m(h) {
347
- c("throw", h);
346
+ function v(p) {
347
+ c("throw", p);
348
348
  }
349
- function v(h, p) {
350
- h(p), i.shift(), i.length && c(i[0][0], i[0][1]);
349
+ function w(p, g) {
350
+ p(g), o.shift(), o.length && c(o[0][0], o[0][1]);
351
351
  }
352
352
  }
353
- function at(n) {
353
+ function dt(n) {
354
354
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
355
355
  var t = n[Symbol.asyncIterator], e;
356
- return t ? t.call(n) : (n = typeof U == "function" ? U(n) : n[Symbol.iterator](), e = {}, s("next"), s("throw"), s("return"), e[Symbol.asyncIterator] = function() {
356
+ return t ? t.call(n) : (n = typeof $ == "function" ? $(n) : n[Symbol.iterator](), e = {}, s("next"), s("throw"), s("return"), e[Symbol.asyncIterator] = function() {
357
357
  return this;
358
358
  }, e);
359
- function s(i) {
360
- e[i] = n[i] && function(a) {
361
- return new Promise(function(o, c) {
362
- a = n[i](a), r(o, c, a.done, a.value);
359
+ function s(o) {
360
+ e[o] = n[o] && function(i) {
361
+ return new Promise(function(a, c) {
362
+ i = n[o](i), r(a, c, i.done, i.value);
363
363
  });
364
364
  };
365
365
  }
366
- function r(i, a, o, c) {
366
+ function r(o, i, a, c) {
367
367
  Promise.resolve(c).then(function(u) {
368
- i({ value: u, done: o });
369
- }, a);
368
+ o({ value: u, done: a });
369
+ }, i);
370
370
  }
371
371
  }
372
- function b(n) {
372
+ function E(n) {
373
373
  return typeof n == "function";
374
374
  }
375
- function Oe(n) {
375
+ function Pe(n) {
376
376
  var t = function(s) {
377
377
  Error.call(s), s.stack = new Error().stack;
378
378
  }, e = n(t);
379
379
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
380
380
  }
381
- var Q = Oe(function(n) {
381
+ var Z = Pe(function(n) {
382
382
  return function(e) {
383
383
  n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
384
384
  ` + e.map(function(s, r) {
@@ -393,70 +393,70 @@ function V(n, t) {
393
393
  0 <= e && n.splice(e, 1);
394
394
  }
395
395
  }
396
- var L = (function() {
396
+ var D = (function() {
397
397
  function n(t) {
398
398
  this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
399
399
  }
400
400
  return n.prototype.unsubscribe = function() {
401
- var t, e, s, r, i;
401
+ var t, e, s, r, o;
402
402
  if (!this.closed) {
403
403
  this.closed = !0;
404
- var a = this._parentage;
405
- if (a)
406
- if (this._parentage = null, Array.isArray(a))
404
+ var i = this._parentage;
405
+ if (i)
406
+ if (this._parentage = null, Array.isArray(i))
407
407
  try {
408
- for (var o = U(a), c = o.next(); !c.done; c = o.next()) {
408
+ for (var a = $(i), c = a.next(); !c.done; c = a.next()) {
409
409
  var u = c.value;
410
410
  u.remove(this);
411
411
  }
412
- } catch (f) {
413
- t = { error: f };
412
+ } catch (d) {
413
+ t = { error: d };
414
414
  } finally {
415
415
  try {
416
- c && !c.done && (e = o.return) && e.call(o);
416
+ c && !c.done && (e = a.return) && e.call(a);
417
417
  } finally {
418
418
  if (t) throw t.error;
419
419
  }
420
420
  }
421
421
  else
422
- a.remove(this);
423
- var d = this.initialTeardown;
424
- if (b(d))
422
+ i.remove(this);
423
+ var l = this.initialTeardown;
424
+ if (E(l))
425
425
  try {
426
- d();
427
- } catch (f) {
428
- i = f instanceof Q ? f.errors : [f];
426
+ l();
427
+ } catch (d) {
428
+ o = d instanceof Z ? d.errors : [d];
429
429
  }
430
- var m = this._finalizers;
431
- if (m) {
430
+ var v = this._finalizers;
431
+ if (v) {
432
432
  this._finalizers = null;
433
433
  try {
434
- for (var v = U(m), h = v.next(); !h.done; h = v.next()) {
435
- var p = h.value;
434
+ for (var w = $(v), p = w.next(); !p.done; p = w.next()) {
435
+ var g = p.value;
436
436
  try {
437
- he(p);
438
- } catch (f) {
439
- i = i ?? [], f instanceof Q ? i = K(K([], q(i)), q(f.errors)) : i.push(f);
437
+ pe(g);
438
+ } catch (d) {
439
+ o = o ?? [], d instanceof Z ? o = W(W([], K(o)), K(d.errors)) : o.push(d);
440
440
  }
441
441
  }
442
- } catch (f) {
443
- s = { error: f };
442
+ } catch (d) {
443
+ s = { error: d };
444
444
  } finally {
445
445
  try {
446
- h && !h.done && (r = v.return) && r.call(v);
446
+ p && !p.done && (r = w.return) && r.call(w);
447
447
  } finally {
448
448
  if (s) throw s.error;
449
449
  }
450
450
  }
451
451
  }
452
- if (i)
453
- throw new Q(i);
452
+ if (o)
453
+ throw new Z(o);
454
454
  }
455
455
  }, n.prototype.add = function(t) {
456
456
  var e;
457
457
  if (t && t !== this)
458
458
  if (this.closed)
459
- he(t);
459
+ pe(t);
460
460
  else {
461
461
  if (t instanceof n) {
462
462
  if (t.closed || t._hasParent(this))
@@ -481,44 +481,44 @@ var L = (function() {
481
481
  var t = new n();
482
482
  return t.closed = !0, t;
483
483
  })(), n;
484
- })(), ke = L.EMPTY;
485
- function Pe(n) {
486
- return n instanceof L || n && "closed" in n && b(n.remove) && b(n.add) && b(n.unsubscribe);
484
+ })(), Me = D.EMPTY;
485
+ function Le(n) {
486
+ return n instanceof D || n && "closed" in n && E(n.remove) && E(n.add) && E(n.unsubscribe);
487
487
  }
488
- function he(n) {
489
- b(n) ? n() : n.unsubscribe();
488
+ function pe(n) {
489
+ E(n) ? n() : n.unsubscribe();
490
490
  }
491
- var ot = {
491
+ var ht = {
492
492
  Promise: void 0
493
- }, ct = {
493
+ }, ft = {
494
494
  setTimeout: function(n, t) {
495
495
  for (var e = [], s = 2; s < arguments.length; s++)
496
496
  e[s - 2] = arguments[s];
497
- return setTimeout.apply(void 0, K([n, t], q(e)));
497
+ return setTimeout.apply(void 0, W([n, t], K(e)));
498
498
  },
499
499
  clearTimeout: function(n) {
500
500
  return clearTimeout(n);
501
501
  },
502
502
  delegate: void 0
503
503
  };
504
- function _e(n) {
505
- ct.setTimeout(function() {
504
+ function Ue(n) {
505
+ ft.setTimeout(function() {
506
506
  throw n;
507
507
  });
508
508
  }
509
- function ie() {
509
+ function ae() {
510
510
  }
511
- function X(n) {
511
+ function Y(n) {
512
512
  n();
513
513
  }
514
- var oe = (function(n) {
515
- O(t, n);
514
+ var ue = (function(n) {
515
+ N(t, n);
516
516
  function t(e) {
517
517
  var s = n.call(this) || this;
518
- return s.isStopped = !1, e ? (s.destination = e, Pe(e) && e.add(s)) : s.destination = dt, s;
518
+ return s.isStopped = !1, e ? (s.destination = e, Le(e) && e.add(s)) : s.destination = mt, s;
519
519
  }
520
520
  return t.create = function(e, s, r) {
521
- return new ae(e, s, r);
521
+ return new ce(e, s, r);
522
522
  }, t.prototype.next = function(e) {
523
523
  this.isStopped || this._next(e);
524
524
  }, t.prototype.error = function(e) {
@@ -542,7 +542,7 @@ var oe = (function(n) {
542
542
  this.unsubscribe();
543
543
  }
544
544
  }, t;
545
- })(L), ut = (function() {
545
+ })(D), pt = (function() {
546
546
  function n(t) {
547
547
  this.partialObserver = t;
548
548
  }
@@ -552,7 +552,7 @@ var oe = (function(n) {
552
552
  try {
553
553
  e.next(t);
554
554
  } catch (s) {
555
- W(s);
555
+ X(s);
556
556
  }
557
557
  }, n.prototype.error = function(t) {
558
558
  var e = this.partialObserver;
@@ -560,56 +560,56 @@ var oe = (function(n) {
560
560
  try {
561
561
  e.error(t);
562
562
  } catch (s) {
563
- W(s);
563
+ X(s);
564
564
  }
565
565
  else
566
- W(t);
566
+ X(t);
567
567
  }, n.prototype.complete = function() {
568
568
  var t = this.partialObserver;
569
569
  if (t.complete)
570
570
  try {
571
571
  t.complete();
572
572
  } catch (e) {
573
- W(e);
573
+ X(e);
574
574
  }
575
575
  }, n;
576
- })(), ae = (function(n) {
577
- O(t, n);
576
+ })(), ce = (function(n) {
577
+ N(t, n);
578
578
  function t(e, s, r) {
579
- var i = n.call(this) || this, a;
580
- return b(e) || !e ? a = {
579
+ var o = n.call(this) || this, i;
580
+ return E(e) || !e ? i = {
581
581
  next: e ?? void 0,
582
582
  error: s ?? void 0,
583
583
  complete: r ?? void 0
584
- } : a = e, i.destination = new ut(a), i;
584
+ } : i = e, o.destination = new pt(i), o;
585
585
  }
586
586
  return t;
587
- })(oe);
588
- function W(n) {
589
- _e(n);
587
+ })(ue);
588
+ function X(n) {
589
+ Ue(n);
590
590
  }
591
- function lt(n) {
591
+ function gt(n) {
592
592
  throw n;
593
593
  }
594
- var dt = {
594
+ var mt = {
595
595
  closed: !0,
596
- next: ie,
597
- error: lt,
598
- complete: ie
599
- }, ce = (function() {
596
+ next: ae,
597
+ error: gt,
598
+ complete: ae
599
+ }, le = (function() {
600
600
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
601
601
  })();
602
- function z(n) {
602
+ function J(n) {
603
603
  return n;
604
604
  }
605
- function ht(n) {
606
- return n.length === 0 ? z : n.length === 1 ? n[0] : function(e) {
605
+ function bt(n) {
606
+ return n.length === 0 ? J : n.length === 1 ? n[0] : function(e) {
607
607
  return n.reduce(function(s, r) {
608
608
  return r(s);
609
609
  }, e);
610
610
  };
611
611
  }
612
- var w = (function() {
612
+ var O = (function() {
613
613
  function n(t) {
614
614
  t && (this._subscribe = t);
615
615
  }
@@ -617,11 +617,11 @@ var w = (function() {
617
617
  var e = new n();
618
618
  return e.source = this, e.operator = t, e;
619
619
  }, n.prototype.subscribe = function(t, e, s) {
620
- var r = this, i = pt(t) ? t : new ae(t, e, s);
621
- return X(function() {
622
- var a = r, o = a.operator, c = a.source;
623
- i.add(o ? o.call(i, c) : c ? r._subscribe(i) : r._trySubscribe(i));
624
- }), i;
620
+ var r = this, o = vt(t) ? t : new ce(t, e, s);
621
+ return Y(function() {
622
+ var i = r, a = i.operator, c = i.source;
623
+ o.add(a ? a.call(o, c) : c ? r._subscribe(o) : r._trySubscribe(o));
624
+ }), o;
625
625
  }, n.prototype._trySubscribe = function(t) {
626
626
  try {
627
627
  return this._subscribe(t);
@@ -630,61 +630,61 @@ var w = (function() {
630
630
  }
631
631
  }, n.prototype.forEach = function(t, e) {
632
632
  var s = this;
633
- return e = fe(e), new e(function(r, i) {
634
- var a = new ae({
635
- next: function(o) {
633
+ return e = ge(e), new e(function(r, o) {
634
+ var i = new ce({
635
+ next: function(a) {
636
636
  try {
637
- t(o);
637
+ t(a);
638
638
  } catch (c) {
639
- i(c), a.unsubscribe();
639
+ o(c), i.unsubscribe();
640
640
  }
641
641
  },
642
- error: i,
642
+ error: o,
643
643
  complete: r
644
644
  });
645
- s.subscribe(a);
645
+ s.subscribe(i);
646
646
  });
647
647
  }, n.prototype._subscribe = function(t) {
648
648
  var e;
649
649
  return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
650
- }, n.prototype[ce] = function() {
650
+ }, n.prototype[le] = function() {
651
651
  return this;
652
652
  }, n.prototype.pipe = function() {
653
653
  for (var t = [], e = 0; e < arguments.length; e++)
654
654
  t[e] = arguments[e];
655
- return ht(t)(this);
655
+ return bt(t)(this);
656
656
  }, n.prototype.toPromise = function(t) {
657
657
  var e = this;
658
- return t = fe(t), new t(function(s, r) {
659
- var i;
660
- e.subscribe(function(a) {
661
- return i = a;
662
- }, function(a) {
663
- return r(a);
658
+ return t = ge(t), new t(function(s, r) {
659
+ var o;
660
+ e.subscribe(function(i) {
661
+ return o = i;
662
+ }, function(i) {
663
+ return r(i);
664
664
  }, function() {
665
- return s(i);
665
+ return s(o);
666
666
  });
667
667
  });
668
668
  }, n.create = function(t) {
669
669
  return new n(t);
670
670
  }, n;
671
671
  })();
672
- function fe(n) {
672
+ function ge(n) {
673
673
  var t;
674
- return (t = n ?? ot.Promise) !== null && t !== void 0 ? t : Promise;
674
+ return (t = n ?? ht.Promise) !== null && t !== void 0 ? t : Promise;
675
675
  }
676
- function ft(n) {
677
- return n && b(n.next) && b(n.error) && b(n.complete);
676
+ function St(n) {
677
+ return n && E(n.next) && E(n.error) && E(n.complete);
678
678
  }
679
- function pt(n) {
680
- return n && n instanceof oe || ft(n) && Pe(n);
679
+ function vt(n) {
680
+ return n && n instanceof ue || St(n) && Le(n);
681
681
  }
682
- function gt(n) {
683
- return b(n?.lift);
682
+ function yt(n) {
683
+ return E(n?.lift);
684
684
  }
685
- function P(n) {
685
+ function F(n) {
686
686
  return function(t) {
687
- if (gt(t))
687
+ if (yt(t))
688
688
  return t.lift(function(e) {
689
689
  try {
690
690
  return n(e, this);
@@ -695,24 +695,24 @@ function P(n) {
695
695
  throw new TypeError("Unable to lift unknown Observable type");
696
696
  };
697
697
  }
698
- function N(n, t, e, s, r) {
699
- return new mt(n, t, e, s, r);
698
+ function H(n, t, e, s, r) {
699
+ return new wt(n, t, e, s, r);
700
700
  }
701
- var mt = (function(n) {
702
- O(t, n);
703
- function t(e, s, r, i, a, o) {
701
+ var wt = (function(n) {
702
+ N(t, n);
703
+ function t(e, s, r, o, i, a) {
704
704
  var c = n.call(this, e) || this;
705
- return c.onFinalize = a, c.shouldUnsubscribe = o, c._next = s ? function(u) {
705
+ return c.onFinalize = i, c.shouldUnsubscribe = a, c._next = s ? function(u) {
706
706
  try {
707
707
  s(u);
708
- } catch (d) {
709
- e.error(d);
708
+ } catch (l) {
709
+ e.error(l);
710
710
  }
711
- } : n.prototype._next, c._error = i ? function(u) {
711
+ } : n.prototype._next, c._error = o ? function(u) {
712
712
  try {
713
- i(u);
714
- } catch (d) {
715
- e.error(d);
713
+ o(u);
714
+ } catch (l) {
715
+ e.error(l);
716
716
  } finally {
717
717
  this.unsubscribe();
718
718
  }
@@ -733,38 +733,38 @@ var mt = (function(n) {
733
733
  n.prototype.unsubscribe.call(this), !s && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
734
734
  }
735
735
  }, t;
736
- })(oe), bt = Oe(function(n) {
736
+ })(ue), Et = Pe(function(n) {
737
737
  return function() {
738
738
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
739
739
  };
740
- }), ue = (function(n) {
741
- O(t, n);
740
+ }), de = (function(n) {
741
+ N(t, n);
742
742
  function t() {
743
743
  var e = n.call(this) || this;
744
744
  return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
745
745
  }
746
746
  return t.prototype.lift = function(e) {
747
- var s = new pe(this, this);
747
+ var s = new me(this, this);
748
748
  return s.operator = e, s;
749
749
  }, t.prototype._throwIfClosed = function() {
750
750
  if (this.closed)
751
- throw new bt();
751
+ throw new Et();
752
752
  }, t.prototype.next = function(e) {
753
753
  var s = this;
754
- X(function() {
755
- var r, i;
754
+ Y(function() {
755
+ var r, o;
756
756
  if (s._throwIfClosed(), !s.isStopped) {
757
757
  s.currentObservers || (s.currentObservers = Array.from(s.observers));
758
758
  try {
759
- for (var a = U(s.currentObservers), o = a.next(); !o.done; o = a.next()) {
760
- var c = o.value;
759
+ for (var i = $(s.currentObservers), a = i.next(); !a.done; a = i.next()) {
760
+ var c = a.value;
761
761
  c.next(e);
762
762
  }
763
763
  } catch (u) {
764
764
  r = { error: u };
765
765
  } finally {
766
766
  try {
767
- o && !o.done && (i = a.return) && i.call(a);
767
+ a && !a.done && (o = i.return) && o.call(i);
768
768
  } finally {
769
769
  if (r) throw r.error;
770
770
  }
@@ -773,7 +773,7 @@ var mt = (function(n) {
773
773
  });
774
774
  }, t.prototype.error = function(e) {
775
775
  var s = this;
776
- X(function() {
776
+ Y(function() {
777
777
  if (s._throwIfClosed(), !s.isStopped) {
778
778
  s.hasError = s.isStopped = !0, s.thrownError = e;
779
779
  for (var r = s.observers; r.length; )
@@ -782,7 +782,7 @@ var mt = (function(n) {
782
782
  });
783
783
  }, t.prototype.complete = function() {
784
784
  var e = this;
785
- X(function() {
785
+ Y(function() {
786
786
  if (e._throwIfClosed(), !e.isStopped) {
787
787
  e.isStopped = !0;
788
788
  for (var s = e.observers; s.length; )
@@ -803,21 +803,21 @@ var mt = (function(n) {
803
803
  }, t.prototype._subscribe = function(e) {
804
804
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
805
805
  }, t.prototype._innerSubscribe = function(e) {
806
- var s = this, r = this, i = r.hasError, a = r.isStopped, o = r.observers;
807
- return i || a ? ke : (this.currentObservers = null, o.push(e), new L(function() {
808
- s.currentObservers = null, V(o, e);
806
+ var s = this, r = this, o = r.hasError, i = r.isStopped, a = r.observers;
807
+ return o || i ? Me : (this.currentObservers = null, a.push(e), new D(function() {
808
+ s.currentObservers = null, V(a, e);
809
809
  }));
810
810
  }, t.prototype._checkFinalizedStatuses = function(e) {
811
- var s = this, r = s.hasError, i = s.thrownError, a = s.isStopped;
812
- r ? e.error(i) : a && e.complete();
811
+ var s = this, r = s.hasError, o = s.thrownError, i = s.isStopped;
812
+ r ? e.error(o) : i && e.complete();
813
813
  }, t.prototype.asObservable = function() {
814
- var e = new w();
814
+ var e = new O();
815
815
  return e.source = this, e;
816
816
  }, t.create = function(e, s) {
817
- return new pe(e, s);
817
+ return new me(e, s);
818
818
  }, t;
819
- })(w), pe = (function(n) {
820
- O(t, n);
819
+ })(O), me = (function(n) {
820
+ N(t, n);
821
821
  function t(e, s) {
822
822
  var r = n.call(this) || this;
823
823
  return r.destination = e, r.source = s, r;
@@ -833,10 +833,10 @@ var mt = (function(n) {
833
833
  (s = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || s === void 0 || s.call(e);
834
834
  }, t.prototype._subscribe = function(e) {
835
835
  var s, r;
836
- return (r = (s = this.source) === null || s === void 0 ? void 0 : s.subscribe(e)) !== null && r !== void 0 ? r : ke;
836
+ return (r = (s = this.source) === null || s === void 0 ? void 0 : s.subscribe(e)) !== null && r !== void 0 ? r : Me;
837
837
  }, t;
838
- })(ue), A = (function(n) {
839
- O(t, n);
838
+ })(de), R = (function(n) {
839
+ N(t, n);
840
840
  function t(e) {
841
841
  var s = n.call(this) || this;
842
842
  return s._value = e, s;
@@ -851,37 +851,37 @@ var mt = (function(n) {
851
851
  var s = n.prototype._subscribe.call(this, e);
852
852
  return !s.closed && e.next(this._value), s;
853
853
  }, t.prototype.getValue = function() {
854
- var e = this, s = e.hasError, r = e.thrownError, i = e._value;
854
+ var e = this, s = e.hasError, r = e.thrownError, o = e._value;
855
855
  if (s)
856
856
  throw r;
857
- return this._throwIfClosed(), i;
857
+ return this._throwIfClosed(), o;
858
858
  }, t.prototype.next = function(e) {
859
859
  n.prototype.next.call(this, this._value = e);
860
860
  }, t;
861
- })(ue), vt = {
861
+ })(de), It = {
862
862
  now: function() {
863
863
  return Date.now();
864
864
  }
865
- }, St = (function(n) {
866
- O(t, n);
865
+ }, Tt = (function(n) {
866
+ N(t, n);
867
867
  function t(e, s) {
868
868
  return n.call(this) || this;
869
869
  }
870
870
  return t.prototype.schedule = function(e, s) {
871
871
  return this;
872
872
  }, t;
873
- })(L), ge = {
873
+ })(D), be = {
874
874
  setInterval: function(n, t) {
875
875
  for (var e = [], s = 2; s < arguments.length; s++)
876
876
  e[s - 2] = arguments[s];
877
- return setInterval.apply(void 0, K([n, t], q(e)));
877
+ return setInterval.apply(void 0, W([n, t], K(e)));
878
878
  },
879
879
  clearInterval: function(n) {
880
880
  return clearInterval(n);
881
881
  },
882
882
  delegate: void 0
883
- }, yt = (function(n) {
884
- O(t, n);
883
+ }, Ct = (function(n) {
884
+ N(t, n);
885
885
  function t(e, s) {
886
886
  var r = n.call(this, e, s) || this;
887
887
  return r.scheduler = e, r.work = s, r.pending = !1, r;
@@ -891,14 +891,14 @@ var mt = (function(n) {
891
891
  if (s === void 0 && (s = 0), this.closed)
892
892
  return this;
893
893
  this.state = e;
894
- var i = this.id, a = this.scheduler;
895
- return i != null && (this.id = this.recycleAsyncId(a, i, s)), this.pending = !0, this.delay = s, this.id = (r = this.id) !== null && r !== void 0 ? r : this.requestAsyncId(a, this.id, s), this;
894
+ var o = this.id, i = this.scheduler;
895
+ return o != null && (this.id = this.recycleAsyncId(i, o, s)), this.pending = !0, this.delay = s, this.id = (r = this.id) !== null && r !== void 0 ? r : this.requestAsyncId(i, this.id, s), this;
896
896
  }, t.prototype.requestAsyncId = function(e, s, r) {
897
- return r === void 0 && (r = 0), ge.setInterval(e.flush.bind(e, this), r);
897
+ return r === void 0 && (r = 0), be.setInterval(e.flush.bind(e, this), r);
898
898
  }, t.prototype.recycleAsyncId = function(e, s, r) {
899
899
  if (r === void 0 && (r = 0), r != null && this.delay === r && this.pending === !1)
900
900
  return s;
901
- s != null && ge.clearInterval(s);
901
+ s != null && be.clearInterval(s);
902
902
  }, t.prototype.execute = function(e, s) {
903
903
  if (this.closed)
904
904
  return new Error("executing a cancelled action");
@@ -908,31 +908,31 @@ var mt = (function(n) {
908
908
  return r;
909
909
  this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
910
910
  }, t.prototype._execute = function(e, s) {
911
- var r = !1, i;
911
+ var r = !1, o;
912
912
  try {
913
913
  this.work(e);
914
- } catch (a) {
915
- r = !0, i = a || new Error("Scheduled action threw falsy error");
914
+ } catch (i) {
915
+ r = !0, o = i || new Error("Scheduled action threw falsy error");
916
916
  }
917
917
  if (r)
918
- return this.unsubscribe(), i;
918
+ return this.unsubscribe(), o;
919
919
  }, t.prototype.unsubscribe = function() {
920
920
  if (!this.closed) {
921
- var e = this, s = e.id, r = e.scheduler, i = r.actions;
922
- this.work = this.state = this.scheduler = null, this.pending = !1, V(i, this), s != null && (this.id = this.recycleAsyncId(r, s, null)), this.delay = null, n.prototype.unsubscribe.call(this);
921
+ var e = this, s = e.id, r = e.scheduler, o = r.actions;
922
+ this.work = this.state = this.scheduler = null, this.pending = !1, V(o, this), s != null && (this.id = this.recycleAsyncId(r, s, null)), this.delay = null, n.prototype.unsubscribe.call(this);
923
923
  }
924
924
  }, t;
925
- })(St), me = (function() {
925
+ })(Tt), Se = (function() {
926
926
  function n(t, e) {
927
927
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
928
928
  }
929
929
  return n.prototype.schedule = function(t, e, s) {
930
930
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(s, e);
931
- }, n.now = vt.now, n;
932
- })(), wt = (function(n) {
933
- O(t, n);
931
+ }, n.now = It.now, n;
932
+ })(), xt = (function(n) {
933
+ N(t, n);
934
934
  function t(e, s) {
935
- s === void 0 && (s = me.now);
935
+ s === void 0 && (s = Se.now);
936
936
  var r = n.call(this, e, s) || this;
937
937
  return r.actions = [], r._active = !1, r;
938
938
  }
@@ -954,62 +954,62 @@ var mt = (function(n) {
954
954
  throw r;
955
955
  }
956
956
  }, t;
957
- })(me), Et = new wt(yt);
958
- function It(n) {
959
- return n && b(n.schedule);
957
+ })(Se), At = new xt(Ct);
958
+ function Ot(n) {
959
+ return n && E(n.schedule);
960
960
  }
961
- function Me(n) {
961
+ function Re(n) {
962
962
  return n[n.length - 1];
963
963
  }
964
- function Tt(n) {
965
- return b(Me(n)) ? n.pop() : void 0;
964
+ function kt(n) {
965
+ return E(Re(n)) ? n.pop() : void 0;
966
966
  }
967
- function Ue(n) {
968
- return It(Me(n)) ? n.pop() : void 0;
967
+ function Ne(n) {
968
+ return Ot(Re(n)) ? n.pop() : void 0;
969
969
  }
970
- var Le = (function(n) {
970
+ var Fe = (function(n) {
971
971
  return n && typeof n.length == "number" && typeof n != "function";
972
972
  });
973
- function Ne(n) {
974
- return b(n?.then);
973
+ function je(n) {
974
+ return E(n?.then);
975
975
  }
976
- function Re(n) {
977
- return b(n[ce]);
976
+ function $e(n) {
977
+ return E(n[le]);
978
978
  }
979
- function Fe(n) {
980
- return Symbol.asyncIterator && b(n?.[Symbol.asyncIterator]);
979
+ function De(n) {
980
+ return Symbol.asyncIterator && E(n?.[Symbol.asyncIterator]);
981
981
  }
982
- function je(n) {
982
+ function He(n) {
983
983
  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.");
984
984
  }
985
- function Ct() {
985
+ function _t() {
986
986
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
987
987
  }
988
- var $e = Ct();
989
- function De(n) {
990
- return b(n?.[$e]);
988
+ var Be = _t();
989
+ function Ge(n) {
990
+ return E(n?.[Be]);
991
991
  }
992
- function Be(n) {
993
- return it(this, arguments, function() {
994
- var e, s, r, i;
995
- return Ae(this, function(a) {
996
- switch (a.label) {
992
+ function qe(n) {
993
+ return lt(this, arguments, function() {
994
+ var e, s, r, o;
995
+ return _e(this, function(i) {
996
+ switch (i.label) {
997
997
  case 0:
998
- e = n.getReader(), a.label = 1;
998
+ e = n.getReader(), i.label = 1;
999
999
  case 1:
1000
- a.trys.push([1, , 9, 10]), a.label = 2;
1000
+ i.trys.push([1, , 9, 10]), i.label = 2;
1001
1001
  case 2:
1002
- return [4, D(e.read())];
1002
+ return [4, B(e.read())];
1003
1003
  case 3:
1004
- return s = a.sent(), r = s.value, i = s.done, i ? [4, D(void 0)] : [3, 5];
1004
+ return s = i.sent(), r = s.value, o = s.done, o ? [4, B(void 0)] : [3, 5];
1005
1005
  case 4:
1006
- return [2, a.sent()];
1006
+ return [2, i.sent()];
1007
1007
  case 5:
1008
- return [4, D(r)];
1008
+ return [4, B(r)];
1009
1009
  case 6:
1010
- return [4, a.sent()];
1010
+ return [4, i.sent()];
1011
1011
  case 7:
1012
- return a.sent(), [3, 2];
1012
+ return i.sent(), [3, 2];
1013
1013
  case 8:
1014
1014
  return [3, 10];
1015
1015
  case 9:
@@ -1020,66 +1020,66 @@ function Be(n) {
1020
1020
  });
1021
1021
  });
1022
1022
  }
1023
- function He(n) {
1024
- return b(n?.getReader);
1023
+ function Ke(n) {
1024
+ return E(n?.getReader);
1025
1025
  }
1026
- function J(n) {
1027
- if (n instanceof w)
1026
+ function Q(n) {
1027
+ if (n instanceof O)
1028
1028
  return n;
1029
1029
  if (n != null) {
1030
- if (Re(n))
1031
- return xt(n);
1032
- if (Le(n))
1033
- return At(n);
1034
- if (Ne(n))
1035
- return Ot(n);
1030
+ if ($e(n))
1031
+ return Pt(n);
1036
1032
  if (Fe(n))
1037
- return Ge(n);
1033
+ return Mt(n);
1034
+ if (je(n))
1035
+ return Lt(n);
1038
1036
  if (De(n))
1039
- return kt(n);
1040
- if (He(n))
1041
- return Pt(n);
1037
+ return We(n);
1038
+ if (Ge(n))
1039
+ return Ut(n);
1040
+ if (Ke(n))
1041
+ return Rt(n);
1042
1042
  }
1043
- throw je(n);
1043
+ throw He(n);
1044
1044
  }
1045
- function xt(n) {
1046
- return new w(function(t) {
1047
- var e = n[ce]();
1048
- if (b(e.subscribe))
1045
+ function Pt(n) {
1046
+ return new O(function(t) {
1047
+ var e = n[le]();
1048
+ if (E(e.subscribe))
1049
1049
  return e.subscribe(t);
1050
1050
  throw new TypeError("Provided object does not correctly implement Symbol.observable");
1051
1051
  });
1052
1052
  }
1053
- function At(n) {
1054
- return new w(function(t) {
1053
+ function Mt(n) {
1054
+ return new O(function(t) {
1055
1055
  for (var e = 0; e < n.length && !t.closed; e++)
1056
1056
  t.next(n[e]);
1057
1057
  t.complete();
1058
1058
  });
1059
1059
  }
1060
- function Ot(n) {
1061
- return new w(function(t) {
1060
+ function Lt(n) {
1061
+ return new O(function(t) {
1062
1062
  n.then(function(e) {
1063
1063
  t.closed || (t.next(e), t.complete());
1064
1064
  }, function(e) {
1065
1065
  return t.error(e);
1066
- }).then(null, _e);
1066
+ }).then(null, Ue);
1067
1067
  });
1068
1068
  }
1069
- function kt(n) {
1070
- return new w(function(t) {
1069
+ function Ut(n) {
1070
+ return new O(function(t) {
1071
1071
  var e, s;
1072
1072
  try {
1073
- for (var r = U(n), i = r.next(); !i.done; i = r.next()) {
1074
- var a = i.value;
1075
- if (t.next(a), t.closed)
1073
+ for (var r = $(n), o = r.next(); !o.done; o = r.next()) {
1074
+ var i = o.value;
1075
+ if (t.next(i), t.closed)
1076
1076
  return;
1077
1077
  }
1078
- } catch (o) {
1079
- e = { error: o };
1078
+ } catch (a) {
1079
+ e = { error: a };
1080
1080
  } finally {
1081
1081
  try {
1082
- i && !i.done && (s = r.return) && s.call(r);
1082
+ o && !o.done && (s = r.return) && s.call(r);
1083
1083
  } finally {
1084
1084
  if (e) throw e.error;
1085
1085
  }
@@ -1087,29 +1087,29 @@ function kt(n) {
1087
1087
  t.complete();
1088
1088
  });
1089
1089
  }
1090
- function Ge(n) {
1091
- return new w(function(t) {
1092
- _t(n, t).catch(function(e) {
1090
+ function We(n) {
1091
+ return new O(function(t) {
1092
+ Nt(n, t).catch(function(e) {
1093
1093
  return t.error(e);
1094
1094
  });
1095
1095
  });
1096
1096
  }
1097
- function Pt(n) {
1098
- return Ge(Be(n));
1097
+ function Rt(n) {
1098
+ return We(qe(n));
1099
1099
  }
1100
- function _t(n, t) {
1101
- var e, s, r, i;
1102
- return rt(this, void 0, void 0, function() {
1103
- var a, o;
1104
- return Ae(this, function(c) {
1100
+ function Nt(n, t) {
1101
+ var e, s, r, o;
1102
+ return ut(this, void 0, void 0, function() {
1103
+ var i, a;
1104
+ return _e(this, function(c) {
1105
1105
  switch (c.label) {
1106
1106
  case 0:
1107
- c.trys.push([0, 5, 6, 11]), e = at(n), c.label = 1;
1107
+ c.trys.push([0, 5, 6, 11]), e = dt(n), c.label = 1;
1108
1108
  case 1:
1109
1109
  return [4, e.next()];
1110
1110
  case 2:
1111
1111
  if (s = c.sent(), !!s.done) return [3, 4];
1112
- if (a = s.value, t.next(a), t.closed)
1112
+ if (i = s.value, t.next(i), t.closed)
1113
1113
  return [2];
1114
1114
  c.label = 3;
1115
1115
  case 3:
@@ -1117,9 +1117,9 @@ function _t(n, t) {
1117
1117
  case 4:
1118
1118
  return [3, 11];
1119
1119
  case 5:
1120
- return o = c.sent(), r = { error: o }, [3, 11];
1120
+ return a = c.sent(), r = { error: a }, [3, 11];
1121
1121
  case 6:
1122
- return c.trys.push([6, , 9, 10]), s && !s.done && (i = e.return) ? [4, i.call(e)] : [3, 8];
1122
+ return c.trys.push([6, , 9, 10]), s && !s.done && (o = e.return) ? [4, o.call(e)] : [3, 8];
1123
1123
  case 7:
1124
1124
  c.sent(), c.label = 8;
1125
1125
  case 8:
@@ -1135,78 +1135,78 @@ function _t(n, t) {
1135
1135
  });
1136
1136
  });
1137
1137
  }
1138
- function T(n, t, e, s, r) {
1138
+ function P(n, t, e, s, r) {
1139
1139
  s === void 0 && (s = 0), r === void 0 && (r = !1);
1140
- var i = t.schedule(function() {
1140
+ var o = t.schedule(function() {
1141
1141
  e(), r ? n.add(this.schedule(null, s)) : this.unsubscribe();
1142
1142
  }, s);
1143
- if (n.add(i), !r)
1144
- return i;
1143
+ if (n.add(o), !r)
1144
+ return o;
1145
1145
  }
1146
- function qe(n, t) {
1147
- return t === void 0 && (t = 0), P(function(e, s) {
1148
- e.subscribe(N(s, function(r) {
1149
- return T(s, n, function() {
1146
+ function Ve(n, t) {
1147
+ return t === void 0 && (t = 0), F(function(e, s) {
1148
+ e.subscribe(H(s, function(r) {
1149
+ return P(s, n, function() {
1150
1150
  return s.next(r);
1151
1151
  }, t);
1152
1152
  }, function() {
1153
- return T(s, n, function() {
1153
+ return P(s, n, function() {
1154
1154
  return s.complete();
1155
1155
  }, t);
1156
1156
  }, function(r) {
1157
- return T(s, n, function() {
1157
+ return P(s, n, function() {
1158
1158
  return s.error(r);
1159
1159
  }, t);
1160
1160
  }));
1161
1161
  });
1162
1162
  }
1163
- function Ke(n, t) {
1164
- return t === void 0 && (t = 0), P(function(e, s) {
1163
+ function Xe(n, t) {
1164
+ return t === void 0 && (t = 0), F(function(e, s) {
1165
1165
  s.add(n.schedule(function() {
1166
1166
  return e.subscribe(s);
1167
1167
  }, t));
1168
1168
  });
1169
1169
  }
1170
- function Mt(n, t) {
1171
- return J(n).pipe(Ke(t), qe(t));
1170
+ function Ft(n, t) {
1171
+ return Q(n).pipe(Xe(t), Ve(t));
1172
1172
  }
1173
- function Ut(n, t) {
1174
- return J(n).pipe(Ke(t), qe(t));
1173
+ function jt(n, t) {
1174
+ return Q(n).pipe(Xe(t), Ve(t));
1175
1175
  }
1176
- function Lt(n, t) {
1177
- return new w(function(e) {
1176
+ function $t(n, t) {
1177
+ return new O(function(e) {
1178
1178
  var s = 0;
1179
1179
  return t.schedule(function() {
1180
1180
  s === n.length ? e.complete() : (e.next(n[s++]), e.closed || this.schedule());
1181
1181
  });
1182
1182
  });
1183
1183
  }
1184
- function Nt(n, t) {
1185
- return new w(function(e) {
1184
+ function Dt(n, t) {
1185
+ return new O(function(e) {
1186
1186
  var s;
1187
- return T(e, t, function() {
1188
- s = n[$e](), T(e, t, function() {
1189
- var r, i, a;
1187
+ return P(e, t, function() {
1188
+ s = n[Be](), P(e, t, function() {
1189
+ var r, o, i;
1190
1190
  try {
1191
- r = s.next(), i = r.value, a = r.done;
1192
- } catch (o) {
1193
- e.error(o);
1191
+ r = s.next(), o = r.value, i = r.done;
1192
+ } catch (a) {
1193
+ e.error(a);
1194
1194
  return;
1195
1195
  }
1196
- a ? e.complete() : e.next(i);
1196
+ i ? e.complete() : e.next(o);
1197
1197
  }, 0, !0);
1198
1198
  }), function() {
1199
- return b(s?.return) && s.return();
1199
+ return E(s?.return) && s.return();
1200
1200
  };
1201
1201
  });
1202
1202
  }
1203
- function Ve(n, t) {
1203
+ function Ye(n, t) {
1204
1204
  if (!n)
1205
1205
  throw new Error("Iterable cannot be null");
1206
- return new w(function(e) {
1207
- T(e, t, function() {
1206
+ return new O(function(e) {
1207
+ P(e, t, function() {
1208
1208
  var s = n[Symbol.asyncIterator]();
1209
- T(e, t, function() {
1209
+ P(e, t, function() {
1210
1210
  s.next().then(function(r) {
1211
1211
  r.done ? e.complete() : e.next(r.value);
1212
1212
  });
@@ -1214,54 +1214,54 @@ function Ve(n, t) {
1214
1214
  });
1215
1215
  });
1216
1216
  }
1217
- function Rt(n, t) {
1218
- return Ve(Be(n), t);
1217
+ function Ht(n, t) {
1218
+ return Ye(qe(n), t);
1219
1219
  }
1220
- function Ft(n, t) {
1220
+ function Bt(n, t) {
1221
1221
  if (n != null) {
1222
- if (Re(n))
1223
- return Mt(n, t);
1224
- if (Le(n))
1225
- return Lt(n, t);
1226
- if (Ne(n))
1227
- return Ut(n, t);
1222
+ if ($e(n))
1223
+ return Ft(n, t);
1228
1224
  if (Fe(n))
1229
- return Ve(n, t);
1225
+ return $t(n, t);
1226
+ if (je(n))
1227
+ return jt(n, t);
1230
1228
  if (De(n))
1231
- return Nt(n, t);
1232
- if (He(n))
1233
- return Rt(n, t);
1229
+ return Ye(n, t);
1230
+ if (Ge(n))
1231
+ return Dt(n, t);
1232
+ if (Ke(n))
1233
+ return Ht(n, t);
1234
1234
  }
1235
- throw je(n);
1235
+ throw He(n);
1236
1236
  }
1237
- function We(n, t) {
1238
- return t ? Ft(n, t) : J(n);
1237
+ function ze(n, t) {
1238
+ return t ? Bt(n, t) : Q(n);
1239
1239
  }
1240
- function Y(n, t) {
1241
- return P(function(e, s) {
1240
+ function z(n, t) {
1241
+ return F(function(e, s) {
1242
1242
  var r = 0;
1243
- e.subscribe(N(s, function(i) {
1244
- s.next(n.call(t, i, r++));
1243
+ e.subscribe(H(s, function(o) {
1244
+ s.next(n.call(t, o, r++));
1245
1245
  }));
1246
1246
  });
1247
1247
  }
1248
- var jt = Array.isArray;
1249
- function $t(n, t) {
1250
- return jt(t) ? n.apply(void 0, K([], q(t))) : n(t);
1248
+ var Gt = Array.isArray;
1249
+ function qt(n, t) {
1250
+ return Gt(t) ? n.apply(void 0, W([], K(t))) : n(t);
1251
1251
  }
1252
- function Dt(n) {
1253
- return Y(function(t) {
1254
- return $t(n, t);
1252
+ function Kt(n) {
1253
+ return z(function(t) {
1254
+ return qt(n, t);
1255
1255
  });
1256
1256
  }
1257
- var Bt = Array.isArray, Ht = Object.getPrototypeOf, Gt = Object.prototype, qt = Object.keys;
1258
- function Kt(n) {
1257
+ var Wt = Array.isArray, Vt = Object.getPrototypeOf, Xt = Object.prototype, Yt = Object.keys;
1258
+ function zt(n) {
1259
1259
  if (n.length === 1) {
1260
1260
  var t = n[0];
1261
- if (Bt(t))
1261
+ if (Wt(t))
1262
1262
  return { args: t, keys: null };
1263
- if (Vt(t)) {
1264
- var e = qt(t);
1263
+ if (Jt(t)) {
1264
+ var e = Yt(t);
1265
1265
  return {
1266
1266
  args: e.map(function(s) {
1267
1267
  return t[s];
@@ -1272,35 +1272,35 @@ function Kt(n) {
1272
1272
  }
1273
1273
  return { args: n, keys: null };
1274
1274
  }
1275
- function Vt(n) {
1276
- return n && typeof n == "object" && Ht(n) === Gt;
1275
+ function Jt(n) {
1276
+ return n && typeof n == "object" && Vt(n) === Xt;
1277
1277
  }
1278
- function Wt(n, t) {
1278
+ function Qt(n, t) {
1279
1279
  return n.reduce(function(e, s, r) {
1280
1280
  return e[s] = t[r], e;
1281
1281
  }, {});
1282
1282
  }
1283
- function Xt() {
1283
+ function Zt() {
1284
1284
  for (var n = [], t = 0; t < arguments.length; t++)
1285
1285
  n[t] = arguments[t];
1286
- var e = Ue(n), s = Tt(n), r = Kt(n), i = r.args, a = r.keys;
1287
- if (i.length === 0)
1288
- return We([], e);
1289
- var o = new w(Yt(i, e, a ? function(c) {
1290
- return Wt(a, c);
1291
- } : z));
1292
- return s ? o.pipe(Dt(s)) : o;
1293
- }
1294
- function Yt(n, t, e) {
1295
- return e === void 0 && (e = z), function(s) {
1296
- be(t, function() {
1297
- for (var r = n.length, i = new Array(r), a = r, o = r, c = function(d) {
1298
- be(t, function() {
1299
- var m = We(n[d], t), v = !1;
1300
- m.subscribe(N(s, function(h) {
1301
- i[d] = h, v || (v = !0, o--), o || s.next(e(i.slice()));
1286
+ var e = Ne(n), s = kt(n), r = zt(n), o = r.args, i = r.keys;
1287
+ if (o.length === 0)
1288
+ return ze([], e);
1289
+ var a = new O(en(o, e, i ? function(c) {
1290
+ return Qt(i, c);
1291
+ } : J));
1292
+ return s ? a.pipe(Kt(s)) : a;
1293
+ }
1294
+ function en(n, t, e) {
1295
+ return e === void 0 && (e = J), function(s) {
1296
+ ve(t, function() {
1297
+ for (var r = n.length, o = new Array(r), i = r, a = r, c = function(l) {
1298
+ ve(t, function() {
1299
+ var v = ze(n[l], t), w = !1;
1300
+ v.subscribe(H(s, function(p) {
1301
+ o[l] = p, w || (w = !0, a--), a || s.next(e(o.slice()));
1302
1302
  }, function() {
1303
- --a || s.complete();
1303
+ --i || s.complete();
1304
1304
  }));
1305
1305
  }, s);
1306
1306
  }, u = 0; u < r; u++)
@@ -1308,79 +1308,79 @@ function Yt(n, t, e) {
1308
1308
  }, s);
1309
1309
  };
1310
1310
  }
1311
- function be(n, t, e) {
1312
- n ? T(e, n, t) : t();
1311
+ function ve(n, t, e) {
1312
+ n ? P(e, n, t) : t();
1313
1313
  }
1314
- function zt(n, t) {
1315
- return P(function(e, s) {
1314
+ function tn(n, t) {
1315
+ return F(function(e, s) {
1316
1316
  var r = 0;
1317
- e.subscribe(N(s, function(i) {
1318
- return n.call(t, i, r++) && s.next(i);
1317
+ e.subscribe(H(s, function(o) {
1318
+ return n.call(t, o, r++) && s.next(o);
1319
1319
  }));
1320
1320
  });
1321
1321
  }
1322
- function Jt(n) {
1322
+ function nn(n) {
1323
1323
  for (var t, e, s = [], r = 1; r < arguments.length; r++)
1324
1324
  s[r - 1] = arguments[r];
1325
- var i = (t = Ue(s)) !== null && t !== void 0 ? t : Et, a = (e = s[0]) !== null && e !== void 0 ? e : null, o = s[1] || 1 / 0;
1326
- return P(function(c, u) {
1327
- var d = [], m = !1, v = function(f) {
1328
- var I = f.buffer, E = f.subs;
1329
- E.unsubscribe(), V(d, f), u.next(I), m && h();
1330
- }, h = function() {
1331
- if (d) {
1332
- var f = new L();
1333
- u.add(f);
1334
- var I = [], E = {
1335
- buffer: I,
1336
- subs: f
1325
+ var o = (t = Ne(s)) !== null && t !== void 0 ? t : At, i = (e = s[0]) !== null && e !== void 0 ? e : null, a = s[1] || 1 / 0;
1326
+ return F(function(c, u) {
1327
+ var l = [], v = !1, w = function(d) {
1328
+ var C = d.buffer, x = d.subs;
1329
+ x.unsubscribe(), V(l, d), u.next(C), v && p();
1330
+ }, p = function() {
1331
+ if (l) {
1332
+ var d = new D();
1333
+ u.add(d);
1334
+ var C = [], x = {
1335
+ buffer: C,
1336
+ subs: d
1337
1337
  };
1338
- d.push(E), T(f, i, function() {
1339
- return v(E);
1338
+ l.push(x), P(d, o, function() {
1339
+ return w(x);
1340
1340
  }, n);
1341
1341
  }
1342
1342
  };
1343
- a !== null && a >= 0 ? T(u, i, h, a, !0) : m = !0, h();
1344
- var p = N(u, function(f) {
1345
- var I, E, B = d.slice();
1343
+ i !== null && i >= 0 ? P(u, o, p, i, !0) : v = !0, p();
1344
+ var g = H(u, function(d) {
1345
+ var C, x, f = l.slice();
1346
1346
  try {
1347
- for (var R = U(B), _ = R.next(); !_.done; _ = R.next()) {
1348
- var F = _.value, j = F.buffer;
1349
- j.push(f), o <= j.length && v(F);
1347
+ for (var m = $(f), S = m.next(); !S.done; S = m.next()) {
1348
+ var b = S.value, I = b.buffer;
1349
+ I.push(d), a <= I.length && w(b);
1350
1350
  }
1351
- } catch ($) {
1352
- I = { error: $ };
1351
+ } catch (M) {
1352
+ C = { error: M };
1353
1353
  } finally {
1354
1354
  try {
1355
- _ && !_.done && (E = R.return) && E.call(R);
1355
+ S && !S.done && (x = m.return) && x.call(m);
1356
1356
  } finally {
1357
- if (I) throw I.error;
1357
+ if (C) throw C.error;
1358
1358
  }
1359
1359
  }
1360
1360
  }, function() {
1361
- for (; d?.length; )
1362
- u.next(d.shift().buffer);
1363
- p?.unsubscribe(), u.complete(), u.unsubscribe();
1361
+ for (; l?.length; )
1362
+ u.next(l.shift().buffer);
1363
+ g?.unsubscribe(), u.complete(), u.unsubscribe();
1364
1364
  }, void 0, function() {
1365
- return d = null;
1365
+ return l = null;
1366
1366
  });
1367
- c.subscribe(p);
1367
+ c.subscribe(g);
1368
1368
  });
1369
1369
  }
1370
- function M(n, t) {
1371
- return t === void 0 && (t = z), n = n ?? Qt, P(function(e, s) {
1372
- var r, i = !0;
1373
- e.subscribe(N(s, function(a) {
1374
- var o = t(a);
1375
- (i || !n(r, o)) && (i = !1, r = o, s.next(a));
1370
+ function j(n, t) {
1371
+ return t === void 0 && (t = J), n = n ?? sn, F(function(e, s) {
1372
+ var r, o = !0;
1373
+ e.subscribe(H(s, function(i) {
1374
+ var a = t(i);
1375
+ (o || !n(r, a)) && (o = !1, r = a, s.next(i));
1376
1376
  }));
1377
1377
  });
1378
1378
  }
1379
- function Qt(n, t) {
1379
+ function sn(n, t) {
1380
1380
  return n === t;
1381
1381
  }
1382
- function Zt(n) {
1383
- return P(function(t, e) {
1382
+ function rn(n) {
1383
+ return F(function(t, e) {
1384
1384
  try {
1385
1385
  t.subscribe(e);
1386
1386
  } finally {
@@ -1388,70 +1388,70 @@ function Zt(n) {
1388
1388
  }
1389
1389
  });
1390
1390
  }
1391
- function en(n) {
1392
- return P(function(t, e) {
1393
- J(n).subscribe(N(e, function() {
1391
+ function on(n) {
1392
+ return F(function(t, e) {
1393
+ Q(n).subscribe(H(e, function() {
1394
1394
  return e.complete();
1395
- }, ie)), !e.closed && t.subscribe(e);
1395
+ }, ae)), !e.closed && t.subscribe(e);
1396
1396
  });
1397
1397
  }
1398
- function ve(n) {
1399
- const { endpoint: t, apiKey: e, payload: s, debugMode: r, customHeaders: i } = n, a = n.method ?? "POST";
1400
- return new w((o) => {
1398
+ function ye(n) {
1399
+ const { endpoint: t, apiKey: e, payload: s, debugMode: r, customHeaders: o } = n, i = n.method ?? "POST";
1400
+ return new O((a) => {
1401
1401
  const c = new AbortController();
1402
- let u, d = !1, m = !1;
1403
- const v = {
1402
+ let u, l = !1, v = !1;
1403
+ const w = {
1404
1404
  "Content-Type": "application/json",
1405
- ...i
1405
+ ...o
1406
1406
  };
1407
- e && (v["X-API-KEY"] = e);
1408
- const h = new URL(t);
1409
- return r && h.searchParams.set("is_debug", "true"), xe(h.toString(), {
1410
- method: a,
1411
- headers: v,
1412
- body: a === "POST" && s ? JSON.stringify(s) : void 0,
1407
+ e && (w["X-API-KEY"] = e);
1408
+ const p = new URL(t);
1409
+ return r && p.searchParams.set("is_debug", "true"), ke(p.toString(), {
1410
+ method: i,
1411
+ headers: w,
1412
+ body: i === "POST" && s ? JSON.stringify(s) : void 0,
1413
1413
  signal: c.signal,
1414
1414
  /**
1415
1415
  * Allow SSE to work when the page is hidden.
1416
1416
  * https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
1417
1417
  */
1418
1418
  openWhenHidden: !0,
1419
- onopen: async (p) => {
1420
- if (p.ok)
1421
- u = p.headers.get("X-Trace-Id") ?? void 0;
1419
+ onopen: async (g) => {
1420
+ if (g.ok)
1421
+ u = g.headers.get("X-Trace-Id") ?? void 0;
1422
1422
  else {
1423
- let f;
1423
+ let d;
1424
1424
  try {
1425
- f = await p.json();
1425
+ d = await g.json();
1426
1426
  } catch {
1427
1427
  try {
1428
- f = await p.text();
1428
+ d = await g.text();
1429
1429
  } catch {
1430
- f = null;
1430
+ d = null;
1431
1431
  }
1432
1432
  }
1433
- o.error(new y(p.status, p.statusText, f)), c.abort();
1433
+ a.error(new A(g.status, g.statusText, d)), c.abort();
1434
1434
  }
1435
1435
  },
1436
- onmessage: (p) => {
1437
- p.id && (d = !0);
1438
- const f = JSON.parse(p.data);
1439
- u ? f.traceId = u : f.requestId && (f.traceId = f.requestId, u || (u = f.requestId)), o.next(f);
1436
+ onmessage: (g) => {
1437
+ g.id && (l = !0);
1438
+ const d = JSON.parse(g.data);
1439
+ u ? d.traceId = u : d.requestId && (d.traceId = d.requestId, u || (u = d.requestId)), a.next(d);
1440
1440
  },
1441
1441
  onclose: () => {
1442
- o.complete();
1442
+ a.complete();
1443
1443
  },
1444
- onerror: (p) => {
1445
- if (m) throw p;
1446
- if (!d)
1447
- throw o.error(p), c.abort(), p;
1444
+ onerror: (g) => {
1445
+ if (v) throw g;
1446
+ if (!l)
1447
+ throw a.error(g), c.abort(), g;
1448
1448
  }
1449
1449
  }), () => {
1450
- m = !0, c.abort();
1450
+ v = !0, c.abort();
1451
1451
  };
1452
1452
  });
1453
1453
  }
1454
- class tn {
1454
+ class an {
1455
1455
  listeners = {};
1456
1456
  on(t, e) {
1457
1457
  this.listeners = Object.assign({}, this.listeners, {
@@ -1470,21 +1470,21 @@ class tn {
1470
1470
  this.listeners[t] && this.listeners[t].forEach((s) => s(...e));
1471
1471
  }
1472
1472
  }
1473
- const nn = 50;
1474
- function Se(n, t) {
1473
+ const cn = 50;
1474
+ function ee(n, t) {
1475
1475
  return t?.customChannelId && n.searchParams.set("custom_channel_id", t.customChannelId), n;
1476
1476
  }
1477
- class Ln {
1477
+ class Xn {
1478
1478
  apiKey;
1479
1479
  endpoint;
1480
1480
  botProviderEndpoint;
1481
1481
  debugMode;
1482
- destroy$ = new ue();
1482
+ destroy$ = new de();
1483
1483
  closed = !1;
1484
1484
  detached = !1;
1485
1485
  detachTimer;
1486
1486
  inFlight = 0;
1487
- sseEmitter = new tn();
1487
+ sseEmitter = new an();
1488
1488
  transformSsePayload;
1489
1489
  customHeaders;
1490
1490
  constructor(t) {
@@ -1505,39 +1505,39 @@ class Ln {
1505
1505
  }
1506
1506
  handleEvent(t) {
1507
1507
  switch (t.eventType) {
1508
- case l.INIT:
1509
- this.sseEmitter.emit(l.INIT, t);
1508
+ case h.INIT:
1509
+ this.sseEmitter.emit(h.INIT, t);
1510
1510
  break;
1511
- case l.PROCESS_START:
1512
- case l.PROCESS_COMPLETE:
1513
- this.sseEmitter.emit(l.PROCESS, t);
1511
+ case h.PROCESS_START:
1512
+ case h.PROCESS_COMPLETE:
1513
+ this.sseEmitter.emit(h.PROCESS, t);
1514
1514
  break;
1515
- case l.MESSAGE_START:
1516
- case l.MESSAGE_DELTA:
1517
- case l.MESSAGE_COMPLETE:
1518
- this.sseEmitter.emit(l.MESSAGE, t);
1515
+ case h.MESSAGE_START:
1516
+ case h.MESSAGE_DELTA:
1517
+ case h.MESSAGE_COMPLETE:
1518
+ this.sseEmitter.emit(h.MESSAGE, t);
1519
1519
  break;
1520
- case l.TOOL_CALL_START:
1521
- case l.TOOL_CALL_COMPLETE:
1522
- this.sseEmitter.emit(l.TOOL_CALL, t);
1520
+ case h.TOOL_CALL_START:
1521
+ case h.TOOL_CALL_COMPLETE:
1522
+ this.sseEmitter.emit(h.TOOL_CALL, t);
1523
1523
  break;
1524
- case l.TOOL_CALL_CONSENT:
1524
+ case h.TOOL_CALL_CONSENT:
1525
1525
  this.sseEmitter.emit(
1526
- l.TOOL_CALL_CONSENT,
1526
+ h.TOOL_CALL_CONSENT,
1527
1527
  t
1528
1528
  );
1529
1529
  break;
1530
- case l.DONE:
1531
- this.sseEmitter.emit(l.DONE, t);
1530
+ case h.DONE:
1531
+ this.sseEmitter.emit(h.DONE, t);
1532
1532
  break;
1533
- case l.ERROR:
1534
- this.sseEmitter.emit(l.ERROR, t);
1533
+ case h.ERROR:
1534
+ this.sseEmitter.emit(h.ERROR, t);
1535
1535
  break;
1536
1536
  }
1537
1537
  }
1538
1538
  fetchSse(t, e) {
1539
1539
  return e?.onSseStart?.(), this.inFlight += 1, this.runSse(
1540
- ve({
1540
+ ye({
1541
1541
  apiKey: this.apiKey,
1542
1542
  endpoint: this.endpoint,
1543
1543
  debugMode: this.debugMode,
@@ -1556,7 +1556,7 @@ class Ln {
1556
1556
  e?.onSseStart?.(), this.inFlight += 1;
1557
1557
  const s = new URL(this.endpoint);
1558
1558
  return s.searchParams.set("custom_channel_id", t), this.runSse(
1559
- ve({
1559
+ ye({
1560
1560
  apiKey: this.apiKey,
1561
1561
  endpoint: s.toString(),
1562
1562
  debugMode: this.debugMode,
@@ -1584,20 +1584,20 @@ class Ln {
1584
1584
  s.searchParams.set("custom_channel_id", t);
1585
1585
  const r = { ...this.customHeaders };
1586
1586
  this.apiKey && (r["X-API-KEY"] = this.apiKey);
1587
- const i = await fetch(s.toString(), { method: "GET", headers: r });
1588
- if (i.status === 404)
1587
+ const o = await fetch(s.toString(), { method: "GET", headers: r });
1588
+ if (o.status === 404)
1589
1589
  return null;
1590
- if (!i.ok)
1591
- throw new y(i.status, i.statusText, await i.text().catch(() => {
1590
+ if (!o.ok)
1591
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1592
1592
  }));
1593
- const a = await i.json(), o = a.data ?? a;
1593
+ const i = await o.json(), a = i.data ?? i;
1594
1594
  return {
1595
- title: o.title ?? null,
1596
- runState: o.runState ?? "IDLE",
1597
- lastActivityAt: o.lastActivityAt,
1595
+ title: a.title ?? null,
1596
+ runState: a.runState ?? "IDLE",
1597
+ lastActivityAt: a.lastActivityAt,
1598
1598
  // F-019 — whitelist-pass the live-sandbox list (map the five backend fields); `[]` for an old
1599
1599
  // backend / a channel with none live. metadata is the sole authority on "who is live".
1600
- launchedSandboxes: (o.launchedSandboxes ?? []).map((c) => ({
1600
+ launchedSandboxes: (a.launchedSandboxes ?? []).map((c) => ({
1601
1601
  sandboxName: c.sandboxName,
1602
1602
  sandboxBlueprintName: c.sandboxBlueprintName,
1603
1603
  workingDirectory: c.workingDirectory,
@@ -1632,9 +1632,9 @@ class Ln {
1632
1632
  throw new Error("Unable to derive channel suspend endpoint. Please provide botProviderEndpoint in config.");
1633
1633
  const r = new URL(s);
1634
1634
  r.searchParams.set("custom_channel_id", t), e?.requestId && r.searchParams.set("request_id", e.requestId), e?.force && r.searchParams.set("force", "true");
1635
- const i = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1636
- if (!(i.ok || i.status === 404))
1637
- throw new y(i.status, i.statusText, await i.text().catch(() => {
1635
+ const o = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1636
+ if (!(o.ok || o.status === 404))
1637
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1638
1638
  }));
1639
1639
  }
1640
1640
  deriveChannelEndpoint() {
@@ -1665,7 +1665,7 @@ class Ln {
1665
1665
  s.searchParams.set("custom_channel_id", t);
1666
1666
  const r = await fetch(s.toString(), { method: "DELETE", headers: this.apiHeaders() });
1667
1667
  if (!r.ok)
1668
- throw new y(r.status, r.statusText, await r.text().catch(() => {
1668
+ throw new A(r.status, r.statusText, await r.text().catch(() => {
1669
1669
  }));
1670
1670
  }
1671
1671
  deriveFeedbackEndpoint() {
@@ -1692,16 +1692,16 @@ class Ln {
1692
1692
  messageId: t.messageId,
1693
1693
  verdict: t.verdict,
1694
1694
  ...s ? { comment: s } : {}
1695
- }, i = await fetch(e, {
1695
+ }, o = await fetch(e, {
1696
1696
  method: "POST",
1697
1697
  headers: { ...this.apiHeaders(), "Content-Type": "application/json" },
1698
1698
  body: JSON.stringify(r)
1699
1699
  });
1700
- if (!i.ok)
1701
- throw new y(i.status, i.statusText, await i.text().catch(() => {
1700
+ if (!o.ok)
1701
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1702
1702
  }));
1703
- const a = await i.json(), o = a.data ?? a;
1704
- return { messageId: o.messageId, seq: o.seq };
1703
+ const i = await o.json(), a = i.data ?? i;
1704
+ return { messageId: a.messageId, seq: a.seq };
1705
1705
  }
1706
1706
  runSse(t, e) {
1707
1707
  return t.pipe(
@@ -1721,13 +1721,13 @@ class Ln {
1721
1721
  // at a consumer, one microtask apart — but the latency it adds is one window total, no matter
1722
1722
  // how many frames land in it. Frames are still delivered individually and in order below, so
1723
1723
  // nothing downstream can tell the difference apart from the timing.
1724
- Jt(e?.delayTime ?? nn),
1724
+ nn(e?.delayTime ?? cn),
1725
1725
  // An idle stream still ticks an empty buffer every window; do not wake the consumer for nothing.
1726
- zt((s) => s.length > 0),
1727
- en(this.destroy$),
1726
+ tn((s) => s.length > 0),
1727
+ on(this.destroy$),
1728
1728
  // Settle the run accounting on every termination path — complete, error, AND a user-initiated
1729
1729
  // unsubscribe (stop-generation aborts the connection without a terminal event).
1730
- Zt(() => this.onRunSettled())
1730
+ rn(() => this.onRunSettled())
1731
1731
  ).subscribe({
1732
1732
  next: (s) => {
1733
1733
  if (!this.detached)
@@ -1781,22 +1781,22 @@ class Ln {
1781
1781
  throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");
1782
1782
  const r = new FormData();
1783
1783
  r.append("file", t), r.append("customChannelId", e);
1784
- const i = {
1784
+ const o = {
1785
1785
  ...this.customHeaders
1786
1786
  };
1787
- this.apiKey && (i["X-API-KEY"] = this.apiKey);
1787
+ this.apiKey && (o["X-API-KEY"] = this.apiKey);
1788
1788
  try {
1789
- const a = await fetch(s, {
1789
+ const i = await fetch(s, {
1790
1790
  method: "POST",
1791
- headers: i,
1791
+ headers: o,
1792
1792
  body: r
1793
1793
  });
1794
- if (!a.ok)
1795
- throw new Error(`Upload failed: ${a.status} ${a.statusText}`);
1796
- const o = await a.json();
1797
- return this.debugMode && console.log("[AsgardServiceClient] File upload response:", o), o;
1798
- } catch (a) {
1799
- throw console.error("[AsgardServiceClient] File upload error:", a), a;
1794
+ if (!i.ok)
1795
+ throw new Error(`Upload failed: ${i.status} ${i.statusText}`);
1796
+ const a = await i.json();
1797
+ return this.debugMode && console.log("[AsgardServiceClient] File upload response:", a), a;
1798
+ } catch (i) {
1799
+ throw console.error("[AsgardServiceClient] File upload error:", i), i;
1800
1800
  }
1801
1801
  }
1802
1802
  /**
@@ -1807,21 +1807,21 @@ class Ln {
1807
1807
  const s = this.getBaseEndpoint();
1808
1808
  if (!s)
1809
1809
  throw new Error("Unable to derive channel-home download endpoint. Please provide botProviderEndpoint in config.");
1810
- const r = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`, i = `${s}/channel-home/download?${r}`, a = {
1810
+ const r = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`, o = `${s}/channel-home/download?${r}`, i = {
1811
1811
  ...this.customHeaders
1812
1812
  };
1813
- this.apiKey && (a["X-API-KEY"] = this.apiKey);
1813
+ this.apiKey && (i["X-API-KEY"] = this.apiKey);
1814
1814
  try {
1815
- const o = await fetch(i, {
1815
+ const a = await fetch(o, {
1816
1816
  method: "GET",
1817
- headers: a
1817
+ headers: i
1818
1818
  });
1819
- if (!o.ok)
1820
- throw new Error(`Channel Home download failed: ${o.status} ${o.statusText}`);
1821
- const c = await o.blob(), u = t.split("/").pop() || "download";
1819
+ if (!a.ok)
1820
+ throw new Error(`Channel Home download failed: ${a.status} ${a.statusText}`);
1821
+ const c = await a.blob(), u = t.split("/").pop() || "download";
1822
1822
  return this.debugMode && console.log("[AsgardServiceClient] Channel Home download response:", { filename: u, size: c.size }), { blob: c, filename: u };
1823
- } catch (o) {
1824
- throw console.error("[AsgardServiceClient] Channel Home download error:", o), o;
1823
+ } catch (a) {
1824
+ throw console.error("[AsgardServiceClient] Channel Home download error:", a), a;
1825
1825
  }
1826
1826
  }
1827
1827
  /**
@@ -1839,17 +1839,50 @@ class Ln {
1839
1839
  throw new Error(
1840
1840
  "Unable to derive sandbox browser open-url endpoint. Please provide botProviderEndpoint in config."
1841
1841
  );
1842
- const r = Se(
1842
+ const r = ee(
1843
1843
  new URL(`${s}/sandbox/${encodeURIComponent(t)}/browser/open-url`),
1844
1844
  e
1845
- ), i = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1846
- if (!i.ok)
1847
- throw new y(i.status, i.statusText, await i.text().catch(() => {
1845
+ ), o = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1846
+ if (!o.ok)
1847
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1848
1848
  }));
1849
- const a = await i.json(), o = a.data?.openURL ?? a.openURL;
1850
- if (!o)
1849
+ const i = await o.json(), a = i.data?.openURL ?? i.openURL;
1850
+ if (!a)
1851
1851
  throw new Error("Sandbox browser open-url response did not contain an openURL.");
1852
- return o;
1852
+ return a;
1853
+ }
1854
+ /**
1855
+ * F-035 — 取得 sandbox 瀏覽器的串流連線憑證:`POST {base}/sandbox/{sandboxName}/browser/session`
1856
+ * → `{ wsUrl, token }`(envelope 容錯,比照 `generateSandboxBrowserOpenUrl`)。
1857
+ *
1858
+ * 與 `generateSandboxBrowserOpenUrl` 的差別在**誰畫畫面**:那一支拿的是一次性網址、交給新分頁載入
1859
+ * Neko 自己的前端(UC-034,保留不動當 fallback);這一支拿的是 WebSocket endpoint 與 token,由 SDK
1860
+ * 自己接 WebRTC、自己畫、自己轉送鍵鼠。
1861
+ *
1862
+ * 三件呼叫端必須知道的性質:
1863
+ * - **token 是 Neko 的 session token,不是 Asgard 的。** 權限等同使用者透過舊的 open-url 流程本來就
1864
+ * 能做的事,並隨 sandbox pod 一起消失。
1865
+ * - **token 不在 `wsUrl` 裡**,連線時自己 append `?token=`(瀏覽器的 WebSocket API 不能設 header)。
1866
+ * - **可以重複呼叫**,每次 mint 一個新 session。連線斷掉或 sandbox 重啟後就該重呼,不要留著舊 token
1867
+ * 重試 —— token 沒有 TTL 但存在 Neko 的記憶體裡,pod 一重啟就失效。
1868
+ */
1869
+ async createSandboxBrowserSession(t, e) {
1870
+ const s = this.getBaseEndpoint();
1871
+ if (!s)
1872
+ throw new Error(
1873
+ "Unable to derive sandbox browser session endpoint. Please provide botProviderEndpoint in config."
1874
+ );
1875
+ const r = ee(
1876
+ new URL(`${s}/sandbox/${encodeURIComponent(t)}/browser/session`),
1877
+ e
1878
+ ), o = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1879
+ if (!o.ok)
1880
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1881
+ }));
1882
+ const i = await o.json(), a = i.data?.wsUrl ?? i.wsUrl, c = i.data?.token ?? i.token;
1883
+ if (!a || !c)
1884
+ throw new Error("Sandbox browser session response did not contain both wsUrl and token.");
1885
+ return { wsUrl: a, token: c };
1853
1886
  }
1854
1887
  /**
1855
1888
  * F-021 — 衍生 sandbox fs 端點 base:`{base}/sandbox/{sandboxName}/fs`(namespace / bot-provider 已在 base)。
@@ -1865,7 +1898,7 @@ class Ln {
1865
1898
  * so the ownership parameter cannot be forgotten in one of eleven places (see `withChannelScope`).
1866
1899
  */
1867
1900
  sandboxFsUrl(t, e, s) {
1868
- return Se(new URL(`${this.deriveSandboxFsEndpoint(t)}/${e}`), s);
1901
+ return ee(new URL(`${this.deriveSandboxFsEndpoint(t)}/${e}`), s);
1869
1902
  }
1870
1903
  /** The shared auth / custom headers for the client's plain-JSON REST calls (no SSE). */
1871
1904
  apiHeaders() {
@@ -1879,12 +1912,12 @@ class Ln {
1879
1912
  async sandboxFsList(t, e, s) {
1880
1913
  const r = this.sandboxFsUrl(t, "list", s);
1881
1914
  r.searchParams.set("path", e);
1882
- const i = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1883
- if (!i.ok)
1884
- throw new y(i.status, i.statusText, await i.text().catch(() => {
1915
+ const o = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1916
+ if (!o.ok)
1917
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1885
1918
  }));
1886
- const a = await i.json(), o = a.data ?? a;
1887
- return { entries: o.entries ?? [], truncated: o.truncated ?? !1 };
1919
+ const i = await o.json(), a = i.data ?? i;
1920
+ return { entries: a.entries ?? [], truncated: a.truncated ?? !1 };
1888
1921
  }
1889
1922
  /**
1890
1923
  * F-021 — 讀取 sandbox 檔案(`GET fs/file?path=[&offset_bytes&limit_bytes]`)。回應是 raw octet-stream,
@@ -1893,15 +1926,15 @@ class Ln {
1893
1926
  async sandboxFsRead(t, e, s) {
1894
1927
  const r = this.sandboxFsUrl(t, "file", s);
1895
1928
  r.searchParams.set("path", e), s?.offsetBytes != null && r.searchParams.set("offset_bytes", String(s.offsetBytes)), s?.limitBytes != null && r.searchParams.set("limit_bytes", String(s.limitBytes));
1896
- const i = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1897
- if (!i.ok)
1898
- throw new y(i.status, i.statusText, await i.text().catch(() => {
1929
+ const o = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1930
+ if (!o.ok)
1931
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1899
1932
  }));
1900
- const a = await i.blob(), o = i.headers.get("X-Total-Bytes");
1933
+ const i = await o.blob(), a = o.headers.get("X-Total-Bytes");
1901
1934
  return {
1902
- content: a,
1903
- totalBytes: o != null ? Number(o) : a.size,
1904
- truncated: i.headers.get("X-Truncated") === "true"
1935
+ content: i,
1936
+ totalBytes: a != null ? Number(a) : i.size,
1937
+ truncated: o.headers.get("X-Truncated") === "true"
1905
1938
  };
1906
1939
  }
1907
1940
  /**
@@ -1909,48 +1942,48 @@ class Ln {
1909
1942
  * 回應 `{ data: { bytesWritten } }`。
1910
1943
  */
1911
1944
  async sandboxFsWrite(t, e, s, r) {
1912
- const i = this.sandboxFsUrl(t, "file", r);
1913
- i.searchParams.set("path", e), r?.mode != null && i.searchParams.set("mode", String(r.mode)), r?.createOnly && i.searchParams.set("create_only", "true");
1914
- const a = new FormData();
1915
- a.append("file", s instanceof Blob ? s : new Blob([s]));
1916
- const o = await fetch(i.toString(), {
1945
+ const o = this.sandboxFsUrl(t, "file", r);
1946
+ o.searchParams.set("path", e), r?.mode != null && o.searchParams.set("mode", String(r.mode)), r?.createOnly && o.searchParams.set("create_only", "true");
1947
+ const i = new FormData();
1948
+ i.append("file", s instanceof Blob ? s : new Blob([s]));
1949
+ const a = await fetch(o.toString(), {
1917
1950
  method: "PUT",
1918
1951
  headers: this.apiHeaders(),
1919
- body: a,
1952
+ body: i,
1920
1953
  signal: r?.signal
1921
1954
  });
1922
- if (!o.ok)
1923
- throw new y(o.status, o.statusText, await o.text().catch(() => {
1955
+ if (!a.ok)
1956
+ throw new A(a.status, a.statusText, await a.text().catch(() => {
1924
1957
  }));
1925
- const c = await o.json();
1958
+ const c = await a.json();
1926
1959
  return { bytesWritten: (c.data ?? c).bytesWritten ?? 0 };
1927
1960
  }
1928
1961
  /** F-021 Cycle 2 — `sandbox://` fs mutation shared request helper (throws `HttpError` on non-OK). */
1929
- async sandboxFsRequest(t, e, s, r, i) {
1930
- const a = this.sandboxFsUrl(t, e, i);
1931
- Object.entries(r).forEach(([c, u]) => a.searchParams.set(c, u));
1932
- const o = await fetch(a.toString(), { method: s, headers: this.apiHeaders() });
1933
- if (!o.ok)
1934
- throw new y(o.status, o.statusText, await o.text().catch(() => {
1962
+ async sandboxFsRequest(t, e, s, r, o) {
1963
+ const i = this.sandboxFsUrl(t, e, o);
1964
+ Object.entries(r).forEach(([c, u]) => i.searchParams.set(c, u));
1965
+ const a = await fetch(i.toString(), { method: s, headers: this.apiHeaders() });
1966
+ if (!a.ok)
1967
+ throw new A(a.status, a.statusText, await a.text().catch(() => {
1935
1968
  }));
1936
- return o.json().catch(() => null);
1969
+ return a.json().catch(() => null);
1937
1970
  }
1938
1971
  /** F-021 — stat a sandbox path (`GET fs/stat?path=`). */
1939
1972
  async sandboxFsStat(t, e, s) {
1940
1973
  const r = this.sandboxFsUrl(t, "stat", s);
1941
1974
  r.searchParams.set("path", e);
1942
- const i = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1943
- if (!i.ok)
1944
- throw new y(i.status, i.statusText, await i.text().catch(() => {
1975
+ const o = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1976
+ if (!o.ok)
1977
+ throw new A(o.status, o.statusText, await o.text().catch(() => {
1945
1978
  }));
1946
- const a = await i.json(), o = a.data ?? a;
1979
+ const i = await o.json(), a = i.data ?? i;
1947
1980
  return {
1948
- exists: o.exists ?? !1,
1949
- isDir: o.isDir ?? !1,
1950
- sizeBytes: o.sizeBytes ?? 0,
1951
- mtimeUnix: o.mtimeUnix ?? 0,
1952
- mode: o.mode ?? 0,
1953
- etag: o.etag
1981
+ exists: a.exists ?? !1,
1982
+ isDir: a.isDir ?? !1,
1983
+ sizeBytes: a.sizeBytes ?? 0,
1984
+ mtimeUnix: a.mtimeUnix ?? 0,
1985
+ mode: a.mode ?? 0,
1986
+ etag: a.etag
1954
1987
  };
1955
1988
  }
1956
1989
  /** F-021 — create a directory (`POST fs/mkdir?path=`). */
@@ -1967,15 +2000,15 @@ class Ln {
1967
2000
  }
1968
2001
  /** F-021 — copy a path (`POST fs/copy?src=&dst=[&overwrite]`) → bytes copied. */
1969
2002
  async sandboxFsCopy(t, e, s, r) {
1970
- const i = { src: e, dst: s };
1971
- r?.overwrite && (i.overwrite = "true");
1972
- const a = await this.sandboxFsRequest(t, "copy", "POST", i, r);
1973
- return { bytesCopied: (a?.data ?? a)?.bytesCopied ?? 0 };
2003
+ const o = { src: e, dst: s };
2004
+ r?.overwrite && (o.overwrite = "true");
2005
+ const i = await this.sandboxFsRequest(t, "copy", "POST", o, r);
2006
+ return { bytesCopied: (i?.data ?? i)?.bytesCopied ?? 0 };
1974
2007
  }
1975
2008
  /** F-021 — move / rename a path (`POST fs/move?src=&dst=[&overwrite]`). */
1976
2009
  async sandboxFsMove(t, e, s, r) {
1977
- const i = { src: e, dst: s };
1978
- r?.overwrite && (i.overwrite = "true"), await this.sandboxFsRequest(t, "move", "POST", i, r);
2010
+ const o = { src: e, dst: s };
2011
+ r?.overwrite && (o.overwrite = "true"), await this.sandboxFsRequest(t, "move", "POST", o, r);
1979
2012
  }
1980
2013
  /**
1981
2014
  * F-021 — watch a sandbox path for changes (`GET fs/watch?path=`, SSE). Each `event: change` frame is one
@@ -1984,27 +2017,27 @@ class Ln {
1984
2017
  */
1985
2018
  sandboxFsWatch(t, e, s) {
1986
2019
  const r = this.sandboxFsUrl(t, "watch", s);
1987
- return r.searchParams.set("path", e), new w((i) => {
1988
- const a = new AbortController();
1989
- return xe(r.toString(), {
2020
+ return r.searchParams.set("path", e), new O((o) => {
2021
+ const i = new AbortController();
2022
+ return ke(r.toString(), {
1990
2023
  headers: this.apiHeaders(),
1991
- signal: a.signal,
2024
+ signal: i.signal,
1992
2025
  openWhenHidden: !0,
1993
- onopen: async (o) => {
1994
- if (!o.ok) {
1995
- const c = await o.text().catch(() => {
2026
+ onopen: async (a) => {
2027
+ if (!a.ok) {
2028
+ const c = await a.text().catch(() => {
1996
2029
  });
1997
- i.error(new y(o.status, o.statusText, c)), a.abort();
2030
+ o.error(new A(a.status, a.statusText, c)), i.abort();
1998
2031
  }
1999
2032
  },
2000
- onmessage: (o) => {
2001
- o.event === "change" && i.next(JSON.parse(o.data));
2033
+ onmessage: (a) => {
2034
+ a.event === "change" && o.next(JSON.parse(a.data));
2002
2035
  },
2003
- onclose: () => i.complete(),
2004
- onerror: (o) => {
2005
- throw i.error(o), a.abort(), o;
2036
+ onclose: () => o.complete(),
2037
+ onerror: (a) => {
2038
+ throw o.error(a), i.abort(), a;
2006
2039
  }
2007
- }), () => a.abort();
2040
+ }), () => i.abort();
2008
2041
  });
2009
2042
  }
2010
2043
  /**
@@ -2023,9 +2056,9 @@ class Ln {
2023
2056
  return !t && this.endpoint && (t = this.endpoint.replace("/message/sse", "")), t ? t.replace(/\/+$/, "") : null;
2024
2057
  }
2025
2058
  }
2026
- const sn = "", rn = /* @__PURE__ */ new Set(["", ".", ".."]);
2027
- function C(n, t) {
2028
- if (n === sn) {
2059
+ const un = "", ln = /* @__PURE__ */ new Set(["", ".", ".."]);
2060
+ function L(n, t) {
2061
+ if (n === un) {
2029
2062
  if (t?.allowRoot)
2030
2063
  return n;
2031
2064
  throw new Error(
@@ -2036,15 +2069,15 @@ function C(n, t) {
2036
2069
  throw new Error(`SourceSet volume path must be relative, with no leading slash (the root is ""): "${n}".`);
2037
2070
  if (n.endsWith("/"))
2038
2071
  throw new Error(`SourceSet volume path must not end with a slash: "${n}".`);
2039
- if (n.split("/").some((e) => rn.has(e)))
2072
+ if (n.split("/").some((e) => ln.has(e)))
2040
2073
  throw new Error(`SourceSet volume path must not contain empty, "." or ".." segments: "${n}".`);
2041
2074
  return n;
2042
2075
  }
2043
- const Xe = 1e3, an = 1e4;
2044
- function ye(n) {
2045
- return Math.min(Math.max(1, Math.floor(n)), Xe);
2076
+ const Je = 1e3, dn = 1e4;
2077
+ function we(n) {
2078
+ return Math.min(Math.max(1, Math.floor(n)), Je);
2046
2079
  }
2047
- class Nn {
2080
+ class Yn {
2048
2081
  endpoint;
2049
2082
  apiKey;
2050
2083
  customHeaders;
@@ -2057,26 +2090,26 @@ class Nn {
2057
2090
  return this.apiKey && (t["X-API-KEY"] = this.apiKey), t;
2058
2091
  }
2059
2092
  /** Issue one volume request, turning any non-2xx into {@link HttpError} (409 included, see R8). */
2060
- async request(t, e, s, r, i) {
2061
- const a = new URL(`${this.endpoint}/${t}`);
2062
- Object.entries(s).forEach(([c, u]) => a.searchParams.set(c, u));
2063
- const o = await fetch(a.toString(), { method: e, headers: this.headers(), body: r, signal: i });
2064
- if (!o.ok)
2065
- throw new y(o.status, o.statusText, await o.text().catch(() => {
2093
+ async request(t, e, s, r, o) {
2094
+ const i = new URL(`${this.endpoint}/${t}`);
2095
+ Object.entries(s).forEach(([c, u]) => i.searchParams.set(c, u));
2096
+ const a = await fetch(i.toString(), { method: e, headers: this.headers(), body: r, signal: o });
2097
+ if (!a.ok)
2098
+ throw new A(a.status, a.statusText, await a.text().catch(() => {
2066
2099
  }));
2067
- return o;
2100
+ return a;
2068
2101
  }
2069
2102
  /** One page of a directory (`GET volume/list?path=[&page&page_size]`). `path` may be the root `''`. */
2070
2103
  async list(t, e) {
2071
- const s = { path: C(t, { allowRoot: !0 }) };
2072
- e?.page != null && (s.page = String(e.page)), e?.pageSize != null && (s.page_size = String(ye(e.pageSize)));
2073
- const i = await (await this.request("list", "GET", s)).json(), a = i.data ?? i;
2104
+ const s = { path: L(t, { allowRoot: !0 }) };
2105
+ e?.page != null && (s.page = String(e.page)), e?.pageSize != null && (s.page_size = String(we(e.pageSize)));
2106
+ const o = await (await this.request("list", "GET", s)).json(), i = o.data ?? o;
2074
2107
  return {
2075
- entries: a.entries ?? [],
2108
+ entries: i.entries ?? [],
2076
2109
  // Reported as `null` rather than invented. An earlier version synthesized
2077
2110
  // `{ total: entries.length }` here to keep `listAll` terminating, which worked — and made a
2078
2111
  // relay that omits `paging` report the first 1000 of 3000 files as the whole directory.
2079
- paging: a.paging ?? i.paging ?? null
2112
+ paging: i.paging ?? o.paging ?? null
2080
2113
  };
2081
2114
  }
2082
2115
  /**
@@ -2086,31 +2119,31 @@ class Nn {
2086
2119
  * directory that looks whole is the failure this exists to prevent.
2087
2120
  */
2088
2121
  async listAll(t, e) {
2089
- const s = ye(e?.pageSize ?? Xe), r = e?.maxEntries ?? an, i = [];
2090
- let a = 0, o = !0, c = 0;
2122
+ const s = we(e?.pageSize ?? Je), r = e?.maxEntries ?? dn, o = [];
2123
+ let i = 0, a = !0, c = 0;
2091
2124
  for (; ; ) {
2092
- const u = await this.list(t, { page: c, pageSize: s }), d = u.paging;
2093
- if (d && d.index !== c) {
2094
- a = d.total, o = !1;
2125
+ const u = await this.list(t, { page: c, pageSize: s }), l = u.paging;
2126
+ if (l && l.index !== c) {
2127
+ i = l.total, a = !1;
2095
2128
  break;
2096
2129
  }
2097
- if (i.push(...u.entries), !d) {
2098
- o = u.entries.length < s;
2130
+ if (o.push(...u.entries), !l) {
2131
+ a = u.entries.length < s;
2099
2132
  break;
2100
2133
  }
2101
- if (a = d.total, i.length >= a)
2134
+ if (i = l.total, o.length >= i)
2102
2135
  break;
2103
- if (i.length >= r || u.entries.length === 0) {
2104
- o = !1;
2136
+ if (o.length >= r || u.entries.length === 0) {
2137
+ a = !1;
2105
2138
  break;
2106
2139
  }
2107
2140
  c += 1;
2108
2141
  }
2109
- return { entries: i, total: a, complete: o };
2142
+ return { entries: o, total: i, complete: a };
2110
2143
  }
2111
2144
  /** Stat a path (`GET volume/stat?path=`). A missing path is 200 with `exists: false`, not a 404. */
2112
2145
  async stat(t) {
2113
- const s = await (await this.request("stat", "GET", { path: C(t) })).json(), r = s.data ?? s;
2146
+ const s = await (await this.request("stat", "GET", { path: L(t) })).json(), r = s.data ?? s;
2114
2147
  return {
2115
2148
  exists: r.exists ?? !1,
2116
2149
  isDir: r.isDir ?? !1,
@@ -2122,12 +2155,12 @@ class Nn {
2122
2155
  }
2123
2156
  /** Read a file (`GET volume/file?path=[&offset_bytes&limit_bytes]`) as raw bytes. */
2124
2157
  async read(t, e) {
2125
- const s = { path: C(t) };
2158
+ const s = { path: L(t) };
2126
2159
  e?.offsetBytes != null && (s.offset_bytes = String(e.offsetBytes)), e?.limitBytes != null && (s.limit_bytes = String(e.limitBytes));
2127
- const r = await this.request("file", "GET", s), i = await r.blob(), a = r.headers.get("X-Total-Bytes");
2160
+ const r = await this.request("file", "GET", s), o = await r.blob(), i = r.headers.get("X-Total-Bytes");
2128
2161
  return {
2129
- content: i,
2130
- totalBytes: a != null ? Number(a) : i.size,
2162
+ content: o,
2163
+ totalBytes: i != null ? Number(i) : o.size,
2131
2164
  truncated: r.headers.get("X-Truncated") === "true"
2132
2165
  };
2133
2166
  }
@@ -2136,67 +2169,67 @@ class Nn {
2136
2169
  * With `createOnly`, an existing path is a 409 rather than an overwrite.
2137
2170
  */
2138
2171
  async write(t, e, s) {
2139
- const r = { path: C(t) };
2172
+ const r = { path: L(t) };
2140
2173
  s?.mode != null && (r.mode = String(s.mode)), s?.createOnly && (r.create_only = "true");
2141
- const i = new FormData();
2142
- i.append("file", e instanceof Blob ? e : new Blob([e]));
2143
- const o = await (await this.request("file", "PUT", r, i, s?.signal)).json();
2144
- return { bytesWritten: (o.data ?? o).bytesWritten ?? 0 };
2174
+ const o = new FormData();
2175
+ o.append("file", e instanceof Blob ? e : new Blob([e]));
2176
+ const a = await (await this.request("file", "PUT", r, o, s?.signal)).json();
2177
+ return { bytesWritten: (a.data ?? a).bytesWritten ?? 0 };
2145
2178
  }
2146
2179
  /** Create a directory and any missing parents (`POST volume/mkdir?path=`). */
2147
2180
  async mkdir(t, e) {
2148
- await this.request("mkdir", "POST", { path: C(t) }, void 0, e?.signal);
2181
+ await this.request("mkdir", "POST", { path: L(t) }, void 0, e?.signal);
2149
2182
  }
2150
2183
  /** Delete a file or empty directory (`DELETE volume/item?path=`). */
2151
2184
  async remove(t) {
2152
- await this.request("item", "DELETE", { path: C(t) });
2185
+ await this.request("item", "DELETE", { path: L(t) });
2153
2186
  }
2154
2187
  /** Recursively delete a directory (`DELETE volume/all?path=`). The volume root is not a valid target. */
2155
2188
  async removeAll(t) {
2156
- await this.request("all", "DELETE", { path: C(t) });
2189
+ await this.request("all", "DELETE", { path: L(t) });
2157
2190
  }
2158
2191
  /** Copy a file or directory tree (`POST volume/copy?src=&dst=[&overwrite]`). */
2159
2192
  async copy(t, e, s) {
2160
- const r = this.copyMoveQuery(t, e, s), a = await (await this.request("copy", "POST", r)).json();
2161
- return { bytesCopied: (a.data ?? a).bytesCopied ?? 0 };
2193
+ const r = this.copyMoveQuery(t, e, s), i = await (await this.request("copy", "POST", r)).json();
2194
+ return { bytesCopied: (i.data ?? i).bytesCopied ?? 0 };
2162
2195
  }
2163
2196
  /** Move or rename (`POST volume/move?src=&dst=[&overwrite]`) — also how the UI renames. */
2164
2197
  async move(t, e, s) {
2165
2198
  await this.request("move", "POST", this.copyMoveQuery(t, e, s));
2166
2199
  }
2167
2200
  copyMoveQuery(t, e, s) {
2168
- const r = { src: C(t), dst: C(e) };
2201
+ const r = { src: L(t), dst: L(e) };
2169
2202
  return s?.overwrite && (r.overwrite = "true"), r;
2170
2203
  }
2171
2204
  }
2172
- const S = [];
2205
+ const T = [];
2173
2206
  for (let n = 0; n < 256; ++n)
2174
- S.push((n + 256).toString(16).slice(1));
2175
- function on(n, t = 0) {
2176
- return (S[n[t + 0]] + S[n[t + 1]] + S[n[t + 2]] + S[n[t + 3]] + "-" + S[n[t + 4]] + S[n[t + 5]] + "-" + S[n[t + 6]] + S[n[t + 7]] + "-" + S[n[t + 8]] + S[n[t + 9]] + "-" + S[n[t + 10]] + S[n[t + 11]] + S[n[t + 12]] + S[n[t + 13]] + S[n[t + 14]] + S[n[t + 15]]).toLowerCase();
2177
- }
2178
- let Z;
2179
- const cn = new Uint8Array(16);
2180
- function un() {
2181
- if (!Z) {
2207
+ T.push((n + 256).toString(16).slice(1));
2208
+ function hn(n, t = 0) {
2209
+ return (T[n[t + 0]] + T[n[t + 1]] + T[n[t + 2]] + T[n[t + 3]] + "-" + T[n[t + 4]] + T[n[t + 5]] + "-" + T[n[t + 6]] + T[n[t + 7]] + "-" + T[n[t + 8]] + T[n[t + 9]] + "-" + T[n[t + 10]] + T[n[t + 11]] + T[n[t + 12]] + T[n[t + 13]] + T[n[t + 14]] + T[n[t + 15]]).toLowerCase();
2210
+ }
2211
+ let te;
2212
+ const fn = new Uint8Array(16);
2213
+ function pn() {
2214
+ if (!te) {
2182
2215
  if (typeof crypto > "u" || !crypto.getRandomValues)
2183
2216
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2184
- Z = crypto.getRandomValues.bind(crypto);
2217
+ te = crypto.getRandomValues.bind(crypto);
2185
2218
  }
2186
- return Z(cn);
2219
+ return te(fn);
2187
2220
  }
2188
- const ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), we = { randomUUID: ln };
2189
- function dn(n, t, e) {
2221
+ const gn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ee = { randomUUID: gn };
2222
+ function mn(n, t, e) {
2190
2223
  n = n || {};
2191
- const s = n.random ?? n.rng?.() ?? un();
2224
+ const s = n.random ?? n.rng?.() ?? pn();
2192
2225
  if (s.length < 16)
2193
2226
  throw new Error("Random bytes length must be >= 16");
2194
- return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, on(s);
2227
+ return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, hn(s);
2195
2228
  }
2196
- function Ye(n, t, e) {
2197
- return we.randomUUID && !n ? we.randomUUID() : dn(n);
2229
+ function Qe(n, t, e) {
2230
+ return Ee.randomUUID && !n ? Ee.randomUUID() : mn(n);
2198
2231
  }
2199
- class g {
2232
+ class y {
2200
2233
  messages = null;
2201
2234
  pendingConsent = null;
2202
2235
  pendingFeedback = null;
@@ -2205,10 +2238,10 @@ class g {
2205
2238
  }
2206
2239
  pushMessage(t) {
2207
2240
  const e = new Map(this.messages);
2208
- return e.set(t.messageId, t), new g({ messages: e, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2241
+ return e.set(t.messageId, t), new y({ messages: e, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2209
2242
  }
2210
2243
  clearPendingConsent() {
2211
- return this.pendingConsent ? new g({ messages: this.messages, pendingConsent: null, pendingFeedback: this.pendingFeedback }) : this;
2244
+ return this.pendingConsent ? new y({ messages: this.messages, pendingConsent: null, pendingFeedback: this.pendingFeedback }) : this;
2212
2245
  }
2213
2246
  /**
2214
2247
  * Put a consent prompt back (#410) — the mirror of {@link clearPendingConsent}, used to undo the
@@ -2216,7 +2249,7 @@ class g {
2216
2249
  * meantime: that one is newer than the batch being restored.
2217
2250
  */
2218
2251
  restorePendingConsent(t) {
2219
- return this.pendingConsent ? this : new g({ messages: this.messages, pendingConsent: t, pendingFeedback: this.pendingFeedback });
2252
+ return this.pendingConsent ? this : new y({ messages: this.messages, pendingConsent: t, pendingFeedback: this.pendingFeedback });
2220
2253
  }
2221
2254
  /**
2222
2255
  * Converge everything the aborted run left mid-flight (F-020 AC10, F-023). A stopped run sends no
@@ -2237,7 +2270,7 @@ class g {
2237
2270
  const e = new Map(this.messages);
2238
2271
  for (const [s, r] of e)
2239
2272
  r.type === "tool-call" && !r.isComplete && (e.set(s, { ...r, isComplete: !0, isCancelled: !0 }), t = !0), r.type === "thinking" && r.isThinking && (e.set(s, { ...r, isThinking: !1 }), t = !0);
2240
- return t ? new g({ messages: e, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback }) : this;
2273
+ return t ? new y({ messages: e, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback }) : this;
2241
2274
  }
2242
2275
  /**
2243
2276
  * @deprecated Renamed to {@link settleInFlightMessages} in 0.3.27 — it settles in-flight thinking
@@ -2249,39 +2282,39 @@ class g {
2249
2282
  }
2250
2283
  onMessage(t) {
2251
2284
  switch (t.eventType) {
2252
- case l.MESSAGE_START:
2285
+ case h.MESSAGE_START:
2253
2286
  return this.onMessageStart(t);
2254
- case l.MESSAGE_DELTA:
2287
+ case h.MESSAGE_DELTA:
2255
2288
  return this.onMessageDelta(t);
2256
- case l.MESSAGE_COMPLETE:
2289
+ case h.MESSAGE_COMPLETE:
2257
2290
  return this.onMessageComplete(t);
2258
- case l.MESSAGE_USER:
2291
+ case h.MESSAGE_USER:
2259
2292
  return this.onMessageUser(t);
2260
- case l.MESSAGE_FEEDBACK:
2293
+ case h.MESSAGE_FEEDBACK:
2261
2294
  return this.onMessageFeedback(t);
2262
- case l.MESSAGE_THINKING_START:
2295
+ case h.MESSAGE_THINKING_START:
2263
2296
  return this.onThinkingStart(t);
2264
- case l.MESSAGE_THINKING_DELTA:
2297
+ case h.MESSAGE_THINKING_DELTA:
2265
2298
  return this.onThinkingDelta(t);
2266
- case l.MESSAGE_THINKING_COMPLETE:
2299
+ case h.MESSAGE_THINKING_COMPLETE:
2267
2300
  return this.onThinkingComplete(t);
2268
- case l.MESSAGE_CANVAS_START:
2301
+ case h.MESSAGE_CANVAS_START:
2269
2302
  return this.onCanvasStart(t);
2270
- case l.MESSAGE_CANVAS_DELTA:
2303
+ case h.MESSAGE_CANVAS_DELTA:
2271
2304
  return this.onCanvasDelta(t);
2272
- case l.MESSAGE_CANVAS_COMPLETE:
2305
+ case h.MESSAGE_CANVAS_COMPLETE:
2273
2306
  return this.onCanvasComplete(t);
2274
- case l.TOOL_CALL_START:
2307
+ case h.TOOL_CALL_START:
2275
2308
  return this.onToolCallStart(t);
2276
- case l.TOOL_CALL_COMPLETE:
2309
+ case h.TOOL_CALL_COMPLETE:
2277
2310
  return this.onToolCallComplete(t);
2278
- case l.TOOL_CALL_CONSENT:
2311
+ case h.TOOL_CALL_CONSENT:
2279
2312
  return this.onToolCallConsent(t);
2280
- case l.SUBAGENT_START:
2313
+ case h.SUBAGENT_START:
2281
2314
  return this.onSubagentStart(t);
2282
- case l.SUBAGENT_COMPLETE:
2315
+ case h.SUBAGENT_COMPLETE:
2283
2316
  return this.onSubagentComplete(t);
2284
- case l.ERROR:
2317
+ case h.ERROR:
2285
2318
  return this.onMessageError(t);
2286
2319
  default:
2287
2320
  return this;
@@ -2327,7 +2360,7 @@ class g {
2327
2360
  const s = new Map(this.messages);
2328
2361
  return s.set(e.messageId, {
2329
2362
  type: "bot",
2330
- eventType: l.MESSAGE_START,
2363
+ eventType: h.MESSAGE_START,
2331
2364
  isTyping: !0,
2332
2365
  typingText: "",
2333
2366
  messageId: e.messageId,
@@ -2335,17 +2368,17 @@ class g {
2335
2368
  time: /* @__PURE__ */ new Date(),
2336
2369
  traceId: t.traceId,
2337
2370
  raw: ""
2338
- }), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2371
+ }), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2339
2372
  }
2340
2373
  onMessageDelta(t) {
2341
2374
  const e = t.fact.messageDelta.message;
2342
2375
  if (e.parentToolUseId) return this;
2343
2376
  const s = this.messages?.get(e.messageId);
2344
2377
  if (this.isTerminalBot(s)) return this;
2345
- const r = s?.type === "bot" ? s : void 0, i = new Map(this.messages);
2346
- return i.set(e.messageId, {
2378
+ const r = s?.type === "bot" ? s : void 0, o = new Map(this.messages);
2379
+ return o.set(e.messageId, {
2347
2380
  type: "bot",
2348
- eventType: l.MESSAGE_DELTA,
2381
+ eventType: h.MESSAGE_DELTA,
2349
2382
  isTyping: !0,
2350
2383
  typingText: `${r?.typingText ?? ""}${e.text}`,
2351
2384
  messageId: e.messageId,
@@ -2353,26 +2386,26 @@ class g {
2353
2386
  time: /* @__PURE__ */ new Date(),
2354
2387
  traceId: t.traceId ?? r?.traceId,
2355
2388
  raw: r?.raw ?? ""
2356
- }), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2389
+ }), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2357
2390
  }
2358
2391
  onMessageComplete(t) {
2359
2392
  const e = t.fact.messageComplete.message;
2360
2393
  if (e.parentToolUseId) return this;
2361
- const s = new Map(this.messages), r = s.get(e.messageId), i = r?.type === "bot" ? r : void 0, a = this.pendingFeedback?.get(e.messageId), o = a ?? i?.feedback;
2394
+ const s = new Map(this.messages), r = s.get(e.messageId), o = r?.type === "bot" ? r : void 0, i = this.pendingFeedback?.get(e.messageId), a = i ?? o?.feedback;
2362
2395
  s.set(e.messageId, {
2363
2396
  type: "bot",
2364
- eventType: l.MESSAGE_COMPLETE,
2397
+ eventType: h.MESSAGE_COMPLETE,
2365
2398
  isTyping: !1,
2366
2399
  typingText: null,
2367
2400
  messageId: e.messageId,
2368
2401
  message: e,
2369
- ...o ? { feedback: o } : {},
2402
+ ...a ? { feedback: a } : {},
2370
2403
  time: /* @__PURE__ */ new Date(),
2371
- traceId: t.traceId ?? i?.traceId,
2404
+ traceId: t.traceId ?? o?.traceId,
2372
2405
  raw: JSON.stringify(t)
2373
2406
  });
2374
2407
  let c = this.pendingFeedback;
2375
- return a && (c = new Map(this.pendingFeedback), c.delete(e.messageId)), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: c });
2408
+ return i && (c = new Map(this.pendingFeedback), c.delete(e.messageId)), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: c });
2376
2409
  }
2377
2410
  /**
2378
2411
  * `asgard.message.feedback` (F-033): fold a rating into the reply it targets. The server is
@@ -2397,11 +2430,11 @@ class g {
2397
2430
  applyFeedback(t, e) {
2398
2431
  const s = this.messages?.get(t);
2399
2432
  if (s?.type === "bot") {
2400
- const i = new Map(this.messages), a = { ...s, feedback: e };
2401
- return i.set(t, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2433
+ const o = new Map(this.messages), i = { ...s, feedback: e };
2434
+ return o.set(t, i), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2402
2435
  }
2403
2436
  const r = new Map(this.pendingFeedback);
2404
- return r.set(t, e), new g({ messages: this.messages, pendingConsent: this.pendingConsent, pendingFeedback: r });
2437
+ return r.set(t, e), new y({ messages: this.messages, pendingConsent: this.pendingConsent, pendingFeedback: r });
2405
2438
  }
2406
2439
  onThinkingStart(t) {
2407
2440
  const e = t.fact.messageThinkingStart.message;
@@ -2415,14 +2448,14 @@ class g {
2415
2448
  time: /* @__PURE__ */ new Date(),
2416
2449
  traceId: t.traceId
2417
2450
  };
2418
- return s.set(e.messageId, r), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2451
+ return s.set(e.messageId, r), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2419
2452
  }
2420
2453
  onThinkingDelta(t) {
2421
2454
  const e = t.fact.messageThinkingDelta.message;
2422
2455
  if (e.parentToolUseId) return this;
2423
2456
  const s = this.messages?.get(e.messageId);
2424
2457
  if (this.isTerminalThinking(s)) return this;
2425
- const r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), a = {
2458
+ const r = s?.type === "thinking" ? s : void 0, o = new Map(this.messages), i = {
2426
2459
  type: "thinking",
2427
2460
  messageId: e.messageId,
2428
2461
  text: `${r?.text ?? ""}${e.text}`,
@@ -2430,12 +2463,12 @@ class g {
2430
2463
  time: r?.time ?? /* @__PURE__ */ new Date(),
2431
2464
  traceId: t.traceId ?? r?.traceId
2432
2465
  };
2433
- return i.set(e.messageId, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2466
+ return o.set(e.messageId, i), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2434
2467
  }
2435
2468
  onThinkingComplete(t) {
2436
2469
  const e = t.fact.messageThinkingComplete.message;
2437
2470
  if (e.parentToolUseId) return this;
2438
- const s = this.messages?.get(e.messageId), r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), a = {
2471
+ const s = this.messages?.get(e.messageId), r = s?.type === "thinking" ? s : void 0, o = new Map(this.messages), i = {
2439
2472
  type: "thinking",
2440
2473
  messageId: e.messageId,
2441
2474
  // Self-sufficient (F-011): the complete frame carries the full reasoning, so a complete-only
@@ -2445,7 +2478,7 @@ class g {
2445
2478
  time: r?.time ?? /* @__PURE__ */ new Date(),
2446
2479
  traceId: t.traceId ?? r?.traceId
2447
2480
  };
2448
- return i.set(e.messageId, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2481
+ return o.set(e.messageId, i), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2449
2482
  }
2450
2483
  onCanvasStart(t) {
2451
2484
  const e = t.fact.messageCanvasStart.message;
@@ -2459,14 +2492,14 @@ class g {
2459
2492
  time: /* @__PURE__ */ new Date(),
2460
2493
  traceId: t.traceId
2461
2494
  };
2462
- return s.set(e.messageId, r), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2495
+ return s.set(e.messageId, r), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2463
2496
  }
2464
2497
  onCanvasDelta(t) {
2465
2498
  const e = t.fact.messageCanvasDelta.message;
2466
2499
  if (e.parentToolUseId) return this;
2467
2500
  const s = this.messages?.get(e.messageId);
2468
2501
  if (this.isTerminalCanvas(s)) return this;
2469
- const r = s?.type === "canvas" ? s : void 0, i = new Map(this.messages), a = {
2502
+ const r = s?.type === "canvas" ? s : void 0, o = new Map(this.messages), i = {
2470
2503
  type: "canvas",
2471
2504
  messageId: e.messageId,
2472
2505
  // Deltas are incremental, exactly like a text delta.
@@ -2476,18 +2509,18 @@ class g {
2476
2509
  time: r?.time ?? /* @__PURE__ */ new Date(),
2477
2510
  traceId: t.traceId ?? r?.traceId
2478
2511
  };
2479
- return i.set(e.messageId, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2512
+ return o.set(e.messageId, i), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2480
2513
  }
2481
2514
  onCanvasComplete(t) {
2482
2515
  const e = t.fact.messageCanvasComplete.message;
2483
2516
  if (e.parentToolUseId) return this;
2484
- const s = e.template?.type === Ce.CANVAS ? e.template : void 0, r = s?.canvas?.html;
2517
+ const s = e.template?.type === Oe.CANVAS ? e.template : void 0, r = s?.canvas?.html;
2485
2518
  if (!r) {
2486
2519
  if (!this.messages?.has(e.messageId)) return this;
2487
2520
  const u = new Map(this.messages);
2488
- return u.delete(e.messageId), new g({ messages: u, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2521
+ return u.delete(e.messageId), new y({ messages: u, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2489
2522
  }
2490
- const i = this.messages?.get(e.messageId), a = i?.type === "canvas" ? i : void 0, o = new Map(this.messages), c = {
2523
+ const o = this.messages?.get(e.messageId), i = o?.type === "canvas" ? o : void 0, a = new Map(this.messages), c = {
2491
2524
  type: "canvas",
2492
2525
  messageId: e.messageId,
2493
2526
  // **Replace, never append.** This fragment is authoritative, and a rejoin replays only the
@@ -2495,15 +2528,15 @@ class g {
2495
2528
  html: r,
2496
2529
  title: s?.title,
2497
2530
  isDrawing: !1,
2498
- time: a?.time ?? /* @__PURE__ */ new Date(),
2499
- traceId: t.traceId ?? a?.traceId
2531
+ time: i?.time ?? /* @__PURE__ */ new Date(),
2532
+ traceId: t.traceId ?? i?.traceId
2500
2533
  };
2501
- return o.set(e.messageId, c), new g({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2534
+ return a.set(e.messageId, c), new y({ messages: a, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2502
2535
  }
2503
2536
  onMessageUser(t) {
2504
2537
  const e = t.fact.messageUser;
2505
2538
  if ((this.messages?.get(e.messageId) ?? (e.customMessageId ? this.messages?.get(e.customMessageId) : void 0))?.type === "user") return this;
2506
- const r = new Map(this.messages), i = {
2539
+ const r = new Map(this.messages), o = {
2507
2540
  type: "user",
2508
2541
  messageId: e.messageId,
2509
2542
  text: e.text,
@@ -2514,25 +2547,25 @@ class g {
2514
2547
  time: /* @__PURE__ */ new Date(),
2515
2548
  traceId: t.traceId
2516
2549
  };
2517
- return r.set(e.messageId, i), new g({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2550
+ return r.set(e.messageId, o), new y({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2518
2551
  }
2519
2552
  onMessageError(t) {
2520
- const e = Ye(), s = t.fact.runError.error, r = new Map(this.messages);
2553
+ const e = Qe(), s = t.fact.runError.error, r = new Map(this.messages);
2521
2554
  return r.set(e, {
2522
2555
  type: "error",
2523
- eventType: l.ERROR,
2556
+ eventType: h.ERROR,
2524
2557
  messageId: e,
2525
2558
  error: s,
2526
2559
  time: /* @__PURE__ */ new Date(),
2527
2560
  traceId: t.traceId
2528
- }), new g({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2561
+ }), new y({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2529
2562
  }
2530
2563
  onToolCallStart(t) {
2531
2564
  const e = t.fact.toolCallStart, s = new Map(this.messages), r = `${e.processId}-${e.callSeq}`;
2532
2565
  if (this.isTerminalToolCall(this.messages?.get(r))) return this;
2533
- const i = {
2566
+ const o = {
2534
2567
  type: "tool-call",
2535
- eventType: l.TOOL_CALL_START,
2568
+ eventType: h.TOOL_CALL_START,
2536
2569
  messageId: r,
2537
2570
  processId: e.processId,
2538
2571
  callSeq: e.callSeq,
@@ -2546,25 +2579,25 @@ class g {
2546
2579
  time: /* @__PURE__ */ new Date(),
2547
2580
  traceId: t.traceId
2548
2581
  };
2549
- return s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2582
+ return s.set(r, o), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2550
2583
  }
2551
2584
  onToolCallComplete(t) {
2552
- const e = t.fact.toolCallComplete, s = new Map(this.messages), r = `${e.processId}-${e.callSeq}`, i = s.get(r);
2553
- if (i?.type === "tool-call") {
2554
- const a = {
2555
- ...i,
2556
- eventType: l.TOOL_CALL_COMPLETE,
2585
+ const e = t.fact.toolCallComplete, s = new Map(this.messages), r = `${e.processId}-${e.callSeq}`, o = s.get(r);
2586
+ if (o?.type === "tool-call") {
2587
+ const i = {
2588
+ ...o,
2589
+ eventType: h.TOOL_CALL_COMPLETE,
2557
2590
  result: e.toolCallResult,
2558
2591
  isError: e.isError,
2559
2592
  sidecar: e.toolUseResultSidecar,
2560
2593
  isComplete: !0,
2561
- traceId: t.traceId ?? i.traceId
2594
+ traceId: t.traceId ?? o.traceId
2562
2595
  };
2563
- s.set(r, a);
2596
+ s.set(r, i);
2564
2597
  } else {
2565
- const a = {
2598
+ const i = {
2566
2599
  type: "tool-call",
2567
- eventType: l.TOOL_CALL_COMPLETE,
2600
+ eventType: h.TOOL_CALL_COMPLETE,
2568
2601
  messageId: r,
2569
2602
  processId: e.processId,
2570
2603
  callSeq: e.callSeq,
@@ -2581,20 +2614,20 @@ class g {
2581
2614
  time: /* @__PURE__ */ new Date(),
2582
2615
  traceId: t.traceId
2583
2616
  };
2584
- s.set(r, a);
2617
+ s.set(r, i);
2585
2618
  }
2586
- return new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2619
+ return new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2587
2620
  }
2588
2621
  onToolCallConsent(t) {
2589
2622
  const e = t.fact.toolCallConsent;
2590
- return new g({
2623
+ return new y({
2591
2624
  messages: this.messages,
2592
2625
  pendingConsent: e,
2593
2626
  pendingFeedback: this.pendingFeedback
2594
2627
  });
2595
2628
  }
2596
2629
  onSubagentStart(t) {
2597
- const e = t.fact.subagentStart, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:start`, i = {
2630
+ const e = t.fact.subagentStart, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:start`, o = {
2598
2631
  type: "subagent",
2599
2632
  messageId: r,
2600
2633
  kind: "start",
@@ -2605,10 +2638,10 @@ class g {
2605
2638
  time: /* @__PURE__ */ new Date(),
2606
2639
  traceId: t.traceId
2607
2640
  };
2608
- return s.delete(r), s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2641
+ return s.delete(r), s.set(r, o), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2609
2642
  }
2610
2643
  onSubagentComplete(t) {
2611
- const e = t.fact.subagentComplete, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:complete`, i = {
2644
+ const e = t.fact.subagentComplete, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:complete`, o = {
2612
2645
  type: "subagent",
2613
2646
  messageId: r,
2614
2647
  kind: "complete",
@@ -2620,108 +2653,108 @@ class g {
2620
2653
  time: /* @__PURE__ */ new Date(),
2621
2654
  traceId: t.traceId
2622
2655
  };
2623
- return s.delete(r), s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2656
+ return s.delete(r), s.set(r, o), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2624
2657
  }
2625
2658
  }
2626
- const hn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2627
- function fn(n) {
2628
- return n.toolsetName === "" && hn.has(n.toolName);
2659
+ const bn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2660
+ function Sn(n) {
2661
+ return n.toolsetName === "" && bn.has(n.toolName);
2629
2662
  }
2630
- function Ee(n) {
2663
+ function Ie(n) {
2631
2664
  return typeof n == "object" && n !== null ? n : void 0;
2632
2665
  }
2633
- function x(n) {
2666
+ function U(n) {
2634
2667
  return typeof n == "string" ? n : void 0;
2635
2668
  }
2636
- function pn(n) {
2669
+ function vn(n) {
2637
2670
  const t = [], e = /* @__PURE__ */ new Map();
2638
2671
  for (const s of n) {
2639
- const r = s.parameter ?? {}, i = s.sidecar ?? {};
2672
+ const r = s.parameter ?? {}, o = s.sidecar ?? {};
2640
2673
  if (s.toolName === "TaskCreate") {
2641
- const a = Ee(i.task), o = x(a?.id);
2642
- if (!o) continue;
2643
- e.has(o) || t.push(o), e.set(o, {
2644
- id: o,
2645
- subject: x(r.subject) || x(a?.subject) || "",
2646
- activeForm: x(r.activeForm),
2647
- description: x(r.description),
2648
- status: e.get(o)?.status ?? "pending"
2674
+ const i = Ie(o.task), a = U(i?.id);
2675
+ if (!a) continue;
2676
+ e.has(a) || t.push(a), e.set(a, {
2677
+ id: a,
2678
+ subject: U(r.subject) || U(i?.subject) || "",
2679
+ activeForm: U(r.activeForm),
2680
+ description: U(r.description),
2681
+ status: e.get(a)?.status ?? "pending"
2649
2682
  // initial status = pending (keep existing on repeat)
2650
2683
  });
2651
2684
  } else if (s.toolName === "TaskUpdate") {
2652
- const a = Ee(i.statusChange), o = x(r.taskId) || x(i.taskId), c = x(a?.to) || x(r.status);
2653
- if (!o || !c) continue;
2654
- const u = e.get(o);
2655
- u && e.set(o, { ...u, status: c });
2685
+ const i = Ie(o.statusChange), a = U(r.taskId) || U(o.taskId), c = U(i?.to) || U(r.status);
2686
+ if (!a || !c) continue;
2687
+ const u = e.get(a);
2688
+ u && e.set(a, { ...u, status: c });
2656
2689
  }
2657
2690
  }
2658
2691
  return t.map((s) => e.get(s));
2659
2692
  }
2660
- function gn(n) {
2693
+ function yn(n) {
2661
2694
  return n.toolsetName === "" && n.toolName === "Agent";
2662
2695
  }
2663
- function mn(n) {
2696
+ function wn(n) {
2664
2697
  return !!n;
2665
2698
  }
2666
- function Ie(n) {
2699
+ function Te(n) {
2667
2700
  n.status !== "running" && (n.status = "running", n.summary = void 0);
2668
2701
  }
2669
- function bn(n) {
2670
- const t = [], e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = (i) => (e.has(i) || (t.push(i), e.set(i, { status: "running" }), s.set(i, /* @__PURE__ */ new Map())), e.get(i));
2671
- for (const i of n)
2672
- switch (i.kind) {
2702
+ function En(n) {
2703
+ const t = [], e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = (o) => (e.has(o) || (t.push(o), e.set(o, { status: "running" }), s.set(o, /* @__PURE__ */ new Map())), e.get(o));
2704
+ for (const o of n)
2705
+ switch (o.kind) {
2673
2706
  case "agentStart": {
2674
- const a = r(i.toolUseId);
2675
- i.description && !a.description && (a.description = i.description);
2707
+ const i = r(o.toolUseId);
2708
+ o.description && !i.description && (i.description = o.description);
2676
2709
  break;
2677
2710
  }
2678
2711
  case "subagentStart": {
2679
- const a = r(i.parentToolUseId);
2680
- a.agentId = i.agentId ?? a.agentId, a.subagentType = i.subagentType ?? a.subagentType, a.description = i.description ?? a.description, Ie(a);
2712
+ const i = r(o.parentToolUseId);
2713
+ i.agentId = o.agentId ?? i.agentId, i.subagentType = o.subagentType ?? i.subagentType, i.description = o.description ?? i.description, Te(i);
2681
2714
  break;
2682
2715
  }
2683
2716
  case "toolStart": {
2684
- Ie(r(i.parentToolUseId)), s.get(i.parentToolUseId).set(i.toolUseId, {
2685
- toolsetName: i.toolsetName,
2686
- toolName: i.toolName,
2687
- parameter: i.parameter ?? {},
2688
- reason: i.reason,
2717
+ Te(r(o.parentToolUseId)), s.get(o.parentToolUseId).set(o.toolUseId, {
2718
+ toolsetName: o.toolsetName,
2719
+ toolName: o.toolName,
2720
+ parameter: o.parameter ?? {},
2721
+ reason: o.reason,
2689
2722
  status: "running"
2690
2723
  });
2691
2724
  break;
2692
2725
  }
2693
2726
  case "toolComplete": {
2694
- const a = s.get(i.parentToolUseId)?.get(i.toolUseId);
2695
- a && (a.status = i.isError ? "error" : "completed");
2727
+ const i = s.get(o.parentToolUseId)?.get(o.toolUseId);
2728
+ i && (i.status = o.isError ? "error" : "completed");
2696
2729
  break;
2697
2730
  }
2698
2731
  case "subagentComplete": {
2699
- const a = r(i.parentToolUseId);
2700
- a.status = i.status, a.summary = i.summary;
2732
+ const i = r(o.parentToolUseId);
2733
+ i.status = o.status, i.summary = o.summary;
2701
2734
  break;
2702
2735
  }
2703
2736
  }
2704
- return t.map((i) => ({
2705
- parentToolUseId: i,
2706
- ...e.get(i),
2707
- tools: Array.from(s.get(i).values())
2737
+ return t.map((o) => ({
2738
+ parentToolUseId: o,
2739
+ ...e.get(o),
2740
+ tools: Array.from(s.get(o).values())
2708
2741
  }));
2709
2742
  }
2710
- function vn(n) {
2743
+ function In(n) {
2711
2744
  return typeof n == "string" ? n : void 0;
2712
2745
  }
2713
- function Sn(n) {
2746
+ function Tn(n) {
2714
2747
  const t = [];
2715
2748
  for (const e of n) {
2716
- if (e.type === "tool-call" && gn(e)) {
2749
+ if (e.type === "tool-call" && yn(e)) {
2717
2750
  t.push({
2718
2751
  kind: "agentStart",
2719
2752
  toolUseId: e.toolUseId ?? e.messageId,
2720
- description: vn(e.parameter.description)
2753
+ description: In(e.parameter.description)
2721
2754
  });
2722
2755
  continue;
2723
2756
  }
2724
- if (e.type === "tool-call" && mn(e.parentToolUseId)) {
2757
+ if (e.type === "tool-call" && wn(e.parentToolUseId)) {
2725
2758
  const s = e.toolUseId ?? e.messageId;
2726
2759
  t.push({
2727
2760
  kind: "toolStart",
@@ -2758,37 +2791,37 @@ function Sn(n) {
2758
2791
  }
2759
2792
  return t;
2760
2793
  }
2761
- function yn(n) {
2794
+ function Cn(n) {
2762
2795
  const t = Array.from(n.messages?.values() ?? []).filter(
2763
- (e) => e.type === "tool-call" && e.isComplete && fn(e)
2796
+ (e) => e.type === "tool-call" && e.isComplete && Sn(e)
2764
2797
  );
2765
- return pn(t);
2798
+ return vn(t);
2766
2799
  }
2767
- function wn(n) {
2768
- return bn(Sn(Array.from(n.messages?.values() ?? [])));
2800
+ function xn(n) {
2801
+ return En(Tn(Array.from(n.messages?.values() ?? [])));
2769
2802
  }
2770
- function En(n, t) {
2803
+ function An(n, t) {
2771
2804
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, s) => {
2772
2805
  const r = t[s];
2773
2806
  return e.id === r.id && e.status === r.status && e.subject === r.subject && e.activeForm === r.activeForm && e.description === r.description;
2774
2807
  });
2775
2808
  }
2776
- function In(n, t) {
2809
+ function On(n, t) {
2777
2810
  return n.length !== t.length ? !1 : n.every((e, s) => {
2778
2811
  const r = t[s];
2779
2812
  return e.toolName === r.toolName && e.toolsetName === r.toolsetName && e.status === r.status && e.reason === r.reason;
2780
2813
  });
2781
2814
  }
2782
- function Tn(n, t) {
2815
+ function kn(n, t) {
2783
2816
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, s) => {
2784
2817
  const r = t[s];
2785
- return e.parentToolUseId === r.parentToolUseId && e.status === r.status && e.subagentType === r.subagentType && e.description === r.description && e.summary === r.summary && In(e.tools, r.tools);
2818
+ return e.parentToolUseId === r.parentToolUseId && e.status === r.status && e.subagentType === r.subagentType && e.description === r.description && e.summary === r.summary && On(e.tools, r.tools);
2786
2819
  });
2787
2820
  }
2788
- function Cn(n) {
2789
- const t = new A([]), e = new A([]), s = new L();
2790
- return s.add(n.pipe(Y(yn), M(En)).subscribe(t)), s.add(
2791
- n.pipe(Y(wn), M(Tn)).subscribe(e)
2821
+ function _n(n) {
2822
+ const t = new R([]), e = new R([]), s = new D();
2823
+ return s.add(n.pipe(z(Cn), j(An)).subscribe(t)), s.add(
2824
+ n.pipe(z(xn), j(kn)).subscribe(e)
2792
2825
  ), {
2793
2826
  tasks$: t.asObservable(),
2794
2827
  subagents$: e.asObservable(),
@@ -2797,18 +2830,18 @@ function Cn(n) {
2797
2830
  teardown: () => s.unsubscribe()
2798
2831
  };
2799
2832
  }
2800
- function Te(n) {
2833
+ function Ce(n) {
2801
2834
  const t = /* @__PURE__ */ new Map();
2802
2835
  for (const e of n) t.set(e.sandboxName, e);
2803
2836
  return [...t.values()].sort(
2804
2837
  (e, s) => (e.sandboxBlueprintName || e.sandboxName).localeCompare(s.sandboxBlueprintName || s.sandboxName)
2805
2838
  );
2806
2839
  }
2807
- const ee = { kind: null, stopPhase: "idle" }, xn = 1e4;
2808
- function An(n, t) {
2840
+ const ne = { kind: null, stopPhase: "idle" }, Pn = 1e4;
2841
+ function Mn(n, t) {
2809
2842
  return n.kind === t.kind && n.stopPhase === t.stopPhase && n.requestId === t.requestId;
2810
2843
  }
2811
- class G {
2844
+ class q {
2812
2845
  client;
2813
2846
  customChannelId;
2814
2847
  customMessageId;
@@ -2868,9 +2901,9 @@ class G {
2868
2901
  throw new Error("client must be required");
2869
2902
  if (!t.customChannelId)
2870
2903
  throw new Error("customChannelId must be required");
2871
- this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new A(!1), this.runStatusSubject = new A(ee), this.conversation$ = new A(t.conversation), this.channelTitleSubject = new A(t.channelTitle ?? null), this.promptSuggestionSubject = new A(null), this.sandboxPhaseSubject = new A("idle"), this.launchedSandboxesSubject = new A(
2872
- Te(t.launchedSandboxes ?? [])
2873
- ), this.derivedStores = Cn(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(M()), this.promptSuggestion$ = this.promptSuggestionSubject.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;
2904
+ this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new R(!1), this.runStatusSubject = new R(ne), this.conversation$ = new R(t.conversation), this.channelTitleSubject = new R(t.channelTitle ?? null), this.promptSuggestionSubject = new R(null), this.sandboxPhaseSubject = new R("idle"), this.launchedSandboxesSubject = new R(
2905
+ Ce(t.launchedSandboxes ?? [])
2906
+ ), this.derivedStores = _n(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(j()), this.promptSuggestion$ = this.promptSuggestionSubject.pipe(j()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(j()), this.launchedSandboxes$ = this.launchedSandboxesSubject.pipe(j()), this.runStatus$ = this.runStatusSubject.pipe(j(Mn)), this.statesObserver = t.statesObserver;
2874
2907
  }
2875
2908
  /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2876
2909
  getTasks() {
@@ -2918,7 +2951,7 @@ class G {
2918
2951
  * launch whose name now appears (promoted to live). metadata (heartbeat-backed) is the sole authority.
2919
2952
  */
2920
2953
  applyLaunchedSandboxes(t) {
2921
- const e = Te(t);
2954
+ const e = Ce(t);
2922
2955
  this.pendingLaunches = this.pendingLaunches.filter((s) => !e.some((r) => r.sandboxName === s)), this.launchedSandboxesSubject.next(e);
2923
2956
  }
2924
2957
  /**
@@ -2952,7 +2985,7 @@ class G {
2952
2985
  this.channelTitleSubject.next(t);
2953
2986
  }
2954
2987
  static create(t) {
2955
- const e = new G(t);
2988
+ const e = new q(t);
2956
2989
  return e.subscribe(), e;
2957
2990
  }
2958
2991
  /**
@@ -2964,11 +2997,11 @@ class G {
2964
2997
  * stop-generation must not fire on it (F-023 AC8).
2965
2998
  */
2966
2999
  static async open(t, e, s, r) {
2967
- const i = new G(t);
3000
+ const o = new q(t);
2968
3001
  try {
2969
- return i.subscribe(), r?.(i), await i.openChannel(e, s), i;
2970
- } catch (a) {
2971
- throw i.close(), a;
3002
+ return o.subscribe(), r?.(o), await o.openChannel(e, s), o;
3003
+ } catch (i) {
3004
+ throw o.close(), i;
2972
3005
  }
2973
3006
  }
2974
3007
  /**
@@ -2994,7 +3027,7 @@ class G {
2994
3027
  throw new Error(
2995
3028
  "This client cannot reset a channel: IAsgardServiceClient.deleteChannel is not implemented. Implement it (DELETE {base}/channel?custom_channel_id=…) or use AsgardServiceClient."
2996
3029
  );
2997
- return await t.client.deleteChannel(t.customChannelId), G.open(t, e, s, r);
3030
+ return await t.client.deleteChannel(t.customChannelId), q.open(t, e, s, r);
2998
3031
  }
2999
3032
  /**
3000
3033
  * Join an **existing** channel without resetting it (F-015). Seeds the title from `config.channelTitle`
@@ -3004,15 +3037,15 @@ class G {
3004
3037
  * "join an existing channel and wipe its history" data-loss bug.
3005
3038
  */
3006
3039
  static async restore(t, e, s) {
3007
- const r = new G(t);
3040
+ const r = new q(t);
3008
3041
  try {
3009
3042
  return r.subscribe(), s?.(r), await r.rejoinChannel(e), r;
3010
- } catch (i) {
3011
- throw r.close(), i;
3043
+ } catch (o) {
3044
+ throw r.close(), o;
3012
3045
  }
3013
3046
  }
3014
3047
  subscribe() {
3015
- this.statesSubscription = Xt([
3048
+ this.statesSubscription = Zt([
3016
3049
  this.isConnecting$,
3017
3050
  this.conversation$,
3018
3051
  this.derivedStores.tasks$,
@@ -3023,15 +3056,15 @@ class G {
3023
3056
  this.launchedSandboxes$,
3024
3057
  this.runStatus$
3025
3058
  ]).pipe(
3026
- Y(
3059
+ z(
3027
3060
  ([
3028
3061
  t,
3029
3062
  e,
3030
3063
  s,
3031
3064
  r,
3065
+ o,
3032
3066
  i,
3033
3067
  a,
3034
- o,
3035
3068
  c,
3036
3069
  u
3037
3070
  ]) => ({
@@ -3039,9 +3072,9 @@ class G {
3039
3072
  conversation: e,
3040
3073
  tasks: s,
3041
3074
  subagents: r,
3042
- channelTitle: i,
3043
- promptSuggestion: a,
3044
- sandboxPhase: o,
3075
+ channelTitle: o,
3076
+ promptSuggestion: i,
3077
+ sandboxPhase: a,
3045
3078
  launchedSandboxes: c,
3046
3079
  runStatus: u
3047
3080
  })
@@ -3069,14 +3102,14 @@ class G {
3069
3102
  */
3070
3103
  updateSandboxPhase(t) {
3071
3104
  switch (t) {
3072
- case l.SANDBOX_LAUNCH:
3105
+ case h.SANDBOX_LAUNCH:
3073
3106
  this.sandboxPhaseSubject.next("launching");
3074
3107
  break;
3075
- case l.SANDBOX_READY:
3108
+ case h.SANDBOX_READY:
3076
3109
  this.sandboxPhaseSubject.next("ready");
3077
3110
  break;
3078
- case l.INIT:
3079
- case l.ERROR:
3111
+ case h.INIT:
3112
+ case h.ERROR:
3080
3113
  this.sandboxPhaseSubject.next("idle");
3081
3114
  break;
3082
3115
  }
@@ -3090,18 +3123,18 @@ class G {
3090
3123
  return {
3091
3124
  onSseStart: t?.onSseStart,
3092
3125
  onSseMessage: (r) => {
3093
- if (t?.onSseMessage?.(r), this.captureRequestId(r.requestId), r.eventType === l.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
3126
+ if (t?.onSseMessage?.(r), this.captureRequestId(r.requestId), r.eventType === h.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
3094
3127
  r.fact.channelTitleUpdate.title
3095
- ), r.eventType === l.PROMPT_SUGGESTION ? this.promptSuggestionSubject.next(
3128
+ ), r.eventType === h.PROMPT_SUGGESTION ? this.promptSuggestionSubject.next(
3096
3129
  r.fact.promptSuggestion.suggestion
3097
- ) : r.eventType === l.INIT && this.clearPromptSuggestion(), this.updateSandboxPhase(r.eventType), r.eventType === l.SANDBOX_LAUNCH && this.noteSandboxLaunch(r.fact.sandboxLaunch.sandboxName), this.currentUserMessageId && r.traceId) {
3098
- const i = new Map(this.conversation$.value.messages), a = i.get(this.currentUserMessageId);
3099
- a && a.type === "user" && (i.set(this.currentUserMessageId, {
3100
- ...a,
3130
+ ) : r.eventType === h.INIT && this.clearPromptSuggestion(), this.updateSandboxPhase(r.eventType), r.eventType === h.SANDBOX_LAUNCH && this.noteSandboxLaunch(r.fact.sandboxLaunch.sandboxName), this.currentUserMessageId && r.traceId) {
3131
+ const o = new Map(this.conversation$.value.messages), i = o.get(this.currentUserMessageId);
3132
+ i && i.type === "user" && (o.set(this.currentUserMessageId, {
3133
+ ...i,
3101
3134
  traceId: r.traceId
3102
3135
  }), this.conversation$.next(
3103
- new g({
3104
- messages: i,
3136
+ new y({
3137
+ messages: o,
3105
3138
  pendingConsent: this.conversation$.value.pendingConsent,
3106
3139
  pendingFeedback: this.conversation$.value.pendingFeedback
3107
3140
  })
@@ -3124,7 +3157,7 @@ class G {
3124
3157
  */
3125
3158
  settleRun() {
3126
3159
  const t = this.runStatusSubject.value.stopPhase !== "idle";
3127
- this.clearForceStopTimer(), this.isConnecting$.next(!1), this.runStatusSubject.next(ee), this.currentUserMessageId = void 0, this.currentRun = void 0, t && this.conversation$.next(this.conversation$.value.settleInFlightMessages());
3160
+ this.clearForceStopTimer(), this.isConnecting$.next(!1), this.runStatusSubject.next(ne), this.currentUserMessageId = void 0, this.currentRun = void 0, t && this.conversation$.next(this.conversation$.value.settleInFlightMessages());
3128
3161
  }
3129
3162
  /** Record the backend run id from the first frame that carries one; later frames must not overwrite it. */
3130
3163
  captureRequestId(t) {
@@ -3135,8 +3168,8 @@ class G {
3135
3168
  this.forceStopTimer && (clearTimeout(this.forceStopTimer), this.forceStopTimer = void 0);
3136
3169
  }
3137
3170
  fetchSse(t, e, s) {
3138
- return new Promise((r, i) => {
3139
- this.isConnecting$.next(!0), this.runStatusSubject.next({ kind: t, stopPhase: "idle" }), this.currentRun = this.client.fetchSse(e, this.buildRunHandlers(s, r, i));
3171
+ return new Promise((r, o) => {
3172
+ this.isConnecting$.next(!0), this.runStatusSubject.next({ kind: t, stopPhase: "idle" }), this.currentRun = this.client.fetchSse(e, this.buildRunHandlers(s, r, o));
3140
3173
  });
3141
3174
  }
3142
3175
  /**
@@ -3166,7 +3199,7 @@ class G {
3166
3199
  return this.fetchSse(
3167
3200
  "reset",
3168
3201
  {
3169
- action: H.NONE,
3202
+ action: G.NONE,
3170
3203
  customChannelId: this.customChannelId,
3171
3204
  customMessageId: this.customMessageId,
3172
3205
  text: t?.text || "",
@@ -3177,16 +3210,16 @@ class G {
3177
3210
  }
3178
3211
  sendMessage(t, e) {
3179
3212
  const s = this.runStatusSubject.value.kind;
3180
- if (s) return Promise.reject(new te(s));
3213
+ if (s) return Promise.reject(new se(s));
3181
3214
  const r = this.conversation$.value.pendingConsent;
3182
- if (r) return Promise.reject(new ne(r.processId));
3215
+ if (r) return Promise.reject(new re(r.processId));
3183
3216
  this.clearPromptSuggestion();
3184
- const i = t.text.trim(), a = t.customMessageId ?? Ye();
3185
- return this.currentUserMessageId = a, this.lastSentMessageId = a, this.conversation$.next(
3217
+ const o = t.text.trim(), i = t.customMessageId ?? Qe();
3218
+ return this.currentUserMessageId = i, this.lastSentMessageId = i, this.conversation$.next(
3186
3219
  this.conversation$.value.pushMessage({
3187
3220
  type: "user",
3188
- messageId: a,
3189
- text: i,
3221
+ messageId: i,
3222
+ text: o,
3190
3223
  blobIds: t.blobIds,
3191
3224
  filePreviewUrls: t.filePreviewUrls,
3192
3225
  documentNames: t.documentNames,
@@ -3195,11 +3228,11 @@ class G {
3195
3228
  ), this.fetchSse(
3196
3229
  "user",
3197
3230
  {
3198
- action: H.NONE,
3231
+ action: G.NONE,
3199
3232
  customChannelId: this.customChannelId,
3200
- customMessageId: a,
3233
+ customMessageId: i,
3201
3234
  payload: this.resolvePayload(t?.payload),
3202
- text: i,
3235
+ text: o,
3203
3236
  blobIds: t?.blobIds
3204
3237
  },
3205
3238
  e
@@ -3239,7 +3272,7 @@ class G {
3239
3272
  return this.conversation$.next(this.conversation$.value.clearPendingConsent()), this.fetchSse(
3240
3273
  "user",
3241
3274
  {
3242
- action: H.RESPONSE_TOOL_CALL_CONSENT,
3275
+ action: G.RESPONSE_TOOL_CALL_CONSENT,
3243
3276
  customChannelId: this.customChannelId,
3244
3277
  customMessageId: this.lastSentMessageId ?? this.customMessageId,
3245
3278
  payload: this.resolvePayload(s),
@@ -3247,8 +3280,8 @@ class G {
3247
3280
  toolCallConsents: t
3248
3281
  },
3249
3282
  e
3250
- ).catch((i) => {
3251
- throw r && this.conversation$.next(this.conversation$.value.restorePendingConsent(r)), i;
3283
+ ).catch((o) => {
3284
+ throw r && this.conversation$.next(this.conversation$.value.restorePendingConsent(r)), o;
3252
3285
  });
3253
3286
  }
3254
3287
  /**
@@ -3273,12 +3306,12 @@ class G {
3273
3306
  */
3274
3307
  nudge(t, e) {
3275
3308
  const s = this.runStatusSubject.value.kind;
3276
- if (s) return Promise.reject(new te(s));
3309
+ if (s) return Promise.reject(new se(s));
3277
3310
  const r = this.conversation$.value.pendingConsent;
3278
- return r ? Promise.reject(new ne(r.processId)) : this.fetchSse(
3311
+ return r ? Promise.reject(new re(r.processId)) : this.fetchSse(
3279
3312
  "nudge",
3280
3313
  {
3281
- action: H.NUDGE,
3314
+ action: G.NUDGE,
3282
3315
  customChannelId: this.customChannelId,
3283
3316
  customMessageId: this.lastSentMessageId ?? this.customMessageId,
3284
3317
  payload: this.resolvePayload(e),
@@ -3344,7 +3377,7 @@ class G {
3344
3377
  this.forceStopTimer = void 0;
3345
3378
  const t = this.runStatusSubject.value;
3346
3379
  t.stopPhase === "stopping" && this.runStatusSubject.next({ ...t, stopPhase: "force-stoppable" });
3347
- }, xn);
3380
+ }, Pn);
3348
3381
  }
3349
3382
  /**
3350
3383
  * Cut the local SSE connection without telling the backend. This is *not* stop-generation (see
@@ -3355,75 +3388,326 @@ class G {
3355
3388
  * stream disposed so no reconnect is attempted (F-023 AC10).
3356
3389
  */
3357
3390
  abortConnection() {
3358
- this.currentRun && (this.currentRun.unsubscribe(), this.clearForceStopTimer(), this.currentRun = void 0, this.isConnecting$.next(!1), this.runStatusSubject.next(ee), this.currentUserMessageId = void 0, this.conversation$.next(this.conversation$.value.settleInFlightMessages()));
3391
+ this.currentRun && (this.currentRun.unsubscribe(), this.clearForceStopTimer(), this.currentRun = void 0, this.isConnecting$.next(!1), this.runStatusSubject.next(ne), this.currentUserMessageId = void 0, this.conversation$.next(this.conversation$.value.settleInFlightMessages()));
3359
3392
  }
3360
3393
  close() {
3361
3394
  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();
3362
3395
  }
3363
3396
  }
3364
- const On = {
3397
+ const Ln = {
3365
3398
  GOOD: "[Response Feedback: Good]",
3366
3399
  BAD: "[Response Feedback: Bad]"
3367
- }, Rn = 8 * 1024;
3368
- function Fn(n) {
3400
+ }, zn = 8 * 1024;
3401
+ function Jn(n) {
3369
3402
  return new TextEncoder().encode(n).length;
3370
3403
  }
3371
- function jn(n, t) {
3372
- const e = On[n], s = t?.trim() ?? "";
3404
+ function Qn(n, t) {
3405
+ const e = Ln[n], s = t?.trim() ?? "";
3373
3406
  return s ? `${e}
3374
3407
 
3375
3408
  ${s}` : e;
3376
3409
  }
3377
- const kn = ["open-file", "open-folder"];
3378
- function Pn(n) {
3379
- return kn.includes(n);
3410
+ const Un = ["open-file", "open-folder"];
3411
+ function Rn(n) {
3412
+ return Un.includes(n);
3380
3413
  }
3381
- function $n(n) {
3414
+ function Zn(n) {
3382
3415
  const t = /^sandbox:\/\/([^/]+)\/([^?#]+)(?:\?([^#]*))?/.exec(n.trim());
3383
3416
  if (!t) return null;
3384
3417
  const e = decodeURIComponent(t[1]), s = t[2], r = new URLSearchParams(t[3] ?? "");
3385
3418
  if (s === "open-browser") return { kind: "open-browser", sandboxName: e };
3386
- if (Pn(s)) {
3387
- const i = r.get("absolute_path");
3388
- return i ? { kind: s, sandboxName: e, absolutePath: i } : null;
3419
+ if (Rn(s)) {
3420
+ const o = r.get("absolute_path");
3421
+ return o ? { kind: s, sandboxName: e, absolutePath: o } : null;
3389
3422
  }
3390
3423
  return null;
3391
3424
  }
3425
+ const xe = {
3426
+ Backspace: 65288,
3427
+ Tab: 65289,
3428
+ Enter: 65293,
3429
+ Escape: 65307,
3430
+ Delete: 65535,
3431
+ Home: 65360,
3432
+ ArrowLeft: 65361,
3433
+ ArrowUp: 65362,
3434
+ ArrowRight: 65363,
3435
+ ArrowDown: 65364,
3436
+ PageUp: 65365,
3437
+ PageDown: 65366,
3438
+ End: 65367,
3439
+ Insert: 65379,
3440
+ F1: 65470,
3441
+ F2: 65471,
3442
+ F3: 65472,
3443
+ F4: 65473,
3444
+ F5: 65474,
3445
+ F6: 65475,
3446
+ F7: 65476,
3447
+ F8: 65477,
3448
+ F9: 65478,
3449
+ F10: 65479,
3450
+ F11: 65480,
3451
+ F12: 65481,
3452
+ Shift: 65505,
3453
+ Control: 65507,
3454
+ CapsLock: 65509,
3455
+ Alt: 65513,
3456
+ Meta: 65515,
3457
+ ContextMenu: 65383,
3458
+ " ": 32
3459
+ }, k = {
3460
+ ISO_Level3_Shift: 65027,
3461
+ Shift_L: 65505,
3462
+ Mode_switch: 65406,
3463
+ Control_L: 65507,
3464
+ Meta_L: 65511,
3465
+ Alt_L: 65513,
3466
+ Alt_R: 65514,
3467
+ Super_L: 65515,
3468
+ Super_R: 65516
3469
+ }, Ze = 16777216;
3470
+ function et(n) {
3471
+ const t = n.codePointAt(0) ?? 0;
3472
+ return t > 255 ? t | Ze : t;
3473
+ }
3474
+ function es(n) {
3475
+ return n in xe ? xe[n] : n.length === 1 ? et(n) : null;
3476
+ }
3477
+ function ts(n) {
3478
+ return n >= 32 && n <= 126 || n >= Ze;
3479
+ }
3480
+ function Nn() {
3481
+ if (typeof navigator > "u") return !1;
3482
+ const n = navigator.platform || "";
3483
+ return /(Mac|iPhone|iPod|iPad)/i.test(n);
3484
+ }
3485
+ function ns(n, t = Nn()) {
3486
+ if (!t) return n;
3487
+ switch (n) {
3488
+ case k.Meta_L:
3489
+ return k.Control_L;
3490
+ case k.Super_L:
3491
+ return k.Alt_L;
3492
+ case k.Super_R:
3493
+ return k.Super_L;
3494
+ case k.Alt_L:
3495
+ return k.Mode_switch;
3496
+ case k.Alt_R:
3497
+ return k.ISO_Level3_Shift;
3498
+ default:
3499
+ return n;
3500
+ }
3501
+ }
3502
+ const Fn = 19, Ae = 10, ss = 100;
3503
+ function rs(n) {
3504
+ const t = n.deltaMode === 0 ? 1 : Fn, e = (s) => Math.max(-Ae, Math.min(Ae, -s * t)) || 0;
3505
+ return { x: e(n.deltaX), y: e(n.deltaY) };
3506
+ }
3507
+ function jn(n) {
3508
+ return n >= 65 && n <= 90;
3509
+ }
3510
+ const $n = 1e4, Dn = 8e3, Hn = 1, Bn = 7, Gn = /* @__PURE__ */ new Set(["control/move"]);
3511
+ function qn(n) {
3512
+ if (n.byteLength < Bn) return null;
3513
+ const t = new DataView(n);
3514
+ return t.getUint8(0) !== Hn ? null : { x: t.getUint16(3), y: t.getUint16(5) };
3515
+ }
3516
+ function os(n) {
3517
+ return {
3518
+ async connect(t, e) {
3519
+ e.onStatus("connecting");
3520
+ const { wsUrl: s, token: r } = await n.createSession(t), o = s.includes("?") ? "&" : "?", i = new WebSocket(`${s}${o}token=${encodeURIComponent(r)}`);
3521
+ let a = null, c = null, u = "none", l, v = !1, w = null;
3522
+ const p = [], g = (f, m) => {
3523
+ i.readyState === WebSocket.OPEN && (i.send(JSON.stringify({ event: f, payload: m })), Gn.has(f) || e.onWire?.("send", f, m));
3524
+ }, d = (f, m) => {
3525
+ u === "me" && g(f, m);
3526
+ }, C = (f) => {
3527
+ u !== f && (u = f, e.onHostChange(f));
3528
+ };
3529
+ try {
3530
+ await new Promise((f, m) => {
3531
+ const S = setTimeout(
3532
+ () => m(new Error("Sandbox browser WebSocket connection timed out.")),
3533
+ Dn
3534
+ );
3535
+ i.onopen = () => {
3536
+ clearTimeout(S), f();
3537
+ }, i.onerror = () => {
3538
+ clearTimeout(S), m(new Error("Sandbox browser WebSocket failed to connect."));
3539
+ };
3540
+ });
3541
+ } catch (f) {
3542
+ throw v = !0, i.close(), f;
3543
+ }
3544
+ i.onclose = (f) => {
3545
+ v || (e.onStatus("error", `Sandbox browser connection closed (code ${f.code}).`), e.onWire?.("recv", "ws/close", { code: f.code }));
3546
+ };
3547
+ const x = async (f) => {
3548
+ const m = new RTCPeerConnection({
3549
+ // Use the server's ICE configuration verbatim. The platform injects the pod's TURN URLs and
3550
+ // time-limited credentials, and they arrive here untouched — the client never needs to know how
3551
+ // the media gateway is deployed, and must not carry its own.
3552
+ iceServers: f.iceservers ?? []
3553
+ });
3554
+ a = m, m.onicecandidate = (b) => {
3555
+ b.candidate && g("signal/candidate", b.candidate.toJSON());
3556
+ }, m.oniceconnectionstatechange = () => {
3557
+ e.onWire?.("recv", "ice/state", m.iceConnectionState), m.iceConnectionState === "failed" && e.onStatus("error", "ICE connection failed.");
3558
+ }, m.ontrack = (b) => {
3559
+ const [I] = b.streams;
3560
+ I && w !== I.id && (w = I.id, e.onStream(I), e.onStatus("live"));
3561
+ }, m.ondatachannel = (b) => {
3562
+ const I = b.channel;
3563
+ I.binaryType = "arraybuffer", I.onmessage = (M) => {
3564
+ if (!(M.data instanceof ArrayBuffer)) return;
3565
+ const _ = qn(M.data);
3566
+ _ && e.onRemoteCursor?.(_);
3567
+ };
3568
+ }, await m.setRemoteDescription({ type: "offer", sdp: f.sdp });
3569
+ for (const b of p.splice(0))
3570
+ await m.addIceCandidate(b).catch(() => {
3571
+ });
3572
+ const S = await m.createAnswer();
3573
+ await m.setLocalDescription(S), g("signal/answer", { sdp: S.sdp, displayname: n.displayName ?? "asgard-js-sdk" });
3574
+ };
3575
+ return i.onmessage = (f) => {
3576
+ let m;
3577
+ try {
3578
+ m = JSON.parse(String(f.data));
3579
+ } catch {
3580
+ return;
3581
+ }
3582
+ const S = m.payload ?? {};
3583
+ switch (m.event !== "signal/candidate" && e.onWire?.("recv", m.event, S), m.event) {
3584
+ case "system/init": {
3585
+ c = S.session_id ?? null;
3586
+ const I = (S.control_host ?? void 0)?.id ?? void 0;
3587
+ I !== void 0 && C(I ? I === c ? "me" : "agent" : "none");
3588
+ return;
3589
+ }
3590
+ case "control/host": {
3591
+ const b = S.host_id ?? null;
3592
+ C(b ? b === c ? "me" : "agent" : "none");
3593
+ return;
3594
+ }
3595
+ case "clipboard/updated": {
3596
+ e.onClipboardChange?.(S.text ?? "");
3597
+ return;
3598
+ }
3599
+ case "signal/provide":
3600
+ case "signal/offer": {
3601
+ x(S).catch((b) => {
3602
+ e.onStatus("error", b instanceof Error ? b.message : String(b));
3603
+ });
3604
+ return;
3605
+ }
3606
+ case "signal/candidate": {
3607
+ const b = S;
3608
+ a?.remoteDescription ? a.addIceCandidate(b).catch(() => {
3609
+ }) : p.push(b);
3610
+ return;
3611
+ }
3612
+ default:
3613
+ return;
3614
+ }
3615
+ }, g("signal/request", { video: {}, audio: {} }), l = setInterval(() => g("client/heartbeat", {}), $n), {
3616
+ requestControl() {
3617
+ g("control/request", {});
3618
+ },
3619
+ releaseControl() {
3620
+ d("control/release", {});
3621
+ },
3622
+ sendPointer(f) {
3623
+ const m = Math.round(f.x), S = Math.round(f.y);
3624
+ if (f.type === "move") {
3625
+ d("control/move", { x: m, y: S });
3626
+ return;
3627
+ }
3628
+ if (f.type === "scroll") {
3629
+ d("control/scroll", {
3630
+ delta_x: Math.round(f.deltaX ?? 0),
3631
+ delta_y: Math.round(f.deltaY ?? 0),
3632
+ control_key: !1
3633
+ });
3634
+ return;
3635
+ }
3636
+ d(f.type === "down" ? "control/buttondown" : "control/buttonup", {
3637
+ x: m,
3638
+ y: S,
3639
+ code: f.button ?? 1
3640
+ });
3641
+ },
3642
+ sendKey(f) {
3643
+ if (f.type === "text") {
3644
+ for (const m of f.text ?? "") {
3645
+ const S = et(m), b = jn(S);
3646
+ b && d("control/keydown", { keysym: k.Shift_L }), d("control/keydown", { keysym: S }), d("control/keyup", { keysym: S }), b && d("control/keyup", { keysym: k.Shift_L });
3647
+ }
3648
+ return;
3649
+ }
3650
+ typeof f.keysym == "number" && d(f.type === "down" ? "control/keydown" : "control/keyup", { keysym: f.keysym });
3651
+ },
3652
+ setClipboard(f) {
3653
+ d("clipboard/set", { text: f });
3654
+ },
3655
+ paste(f) {
3656
+ d("control/paste", { text: f });
3657
+ },
3658
+ close() {
3659
+ v = !0, l && clearInterval(l), l = void 0, a?.close(), a = null, i.close();
3660
+ }
3661
+ };
3662
+ }
3663
+ };
3664
+ }
3392
3665
  export {
3393
- Ln as AsgardServiceClient,
3394
- Nn as AsgardSourceSetClient,
3395
- G as Channel,
3396
- ne as ChannelAwaitingConsentError,
3397
- te as ChannelBusyError,
3398
- g as Conversation,
3399
- l as EventType,
3400
- Rn as FEEDBACK_COMMENT_MAX_BYTES,
3401
- H as FetchSseAction,
3402
- y as HttpError,
3403
- Ce as MessageTemplateType,
3404
- On as RESPONSE_FEEDBACK_PREFIX,
3405
- an as SOURCE_SET_DEFAULT_MAX_ENTRIES,
3406
- Xe as SOURCE_SET_MAX_PAGE_SIZE,
3407
- sn as SOURCE_SET_VOLUME_ROOT,
3408
- ze as ToolCallConsentResult,
3409
- C as assertVolumePath,
3410
- jn as composeFeedbackMessage,
3411
- Sn as conversationToSubagentEvents,
3412
- Cn as createDerivedStores,
3413
- wn as deriveSubagents,
3414
- yn as deriveTasks,
3415
- Fn as feedbackCommentByteLength,
3416
- gn as isAgentTool,
3417
- Un as isChannelAwaitingConsentError,
3418
- Mn as isChannelBusyError,
3419
- _n as isHttpError,
3420
- mn as isSubagentChildTool,
3421
- fn as isTaskTool,
3422
- Te as reconcileLaunched,
3423
- bn as reduceSubagents,
3424
- pn as reduceTaskEvents,
3425
- $n as resolveSandboxUri,
3426
- Tn as subagentsEqual,
3427
- En as tasksEqual
3666
+ Xn as AsgardServiceClient,
3667
+ Yn as AsgardSourceSetClient,
3668
+ q as Channel,
3669
+ re as ChannelAwaitingConsentError,
3670
+ se as ChannelBusyError,
3671
+ y as Conversation,
3672
+ h as EventType,
3673
+ zn as FEEDBACK_COMMENT_MAX_BYTES,
3674
+ G as FetchSseAction,
3675
+ A as HttpError,
3676
+ xe as KEYSYM,
3677
+ Oe as MessageTemplateType,
3678
+ Ln as RESPONSE_FEEDBACK_PREFIX,
3679
+ dn as SOURCE_SET_DEFAULT_MAX_ENTRIES,
3680
+ Je as SOURCE_SET_MAX_PAGE_SIZE,
3681
+ un as SOURCE_SET_VOLUME_ROOT,
3682
+ tt as ToolCallConsentResult,
3683
+ Ae as WHEEL_MAX,
3684
+ ss as WHEEL_THROTTLE_MS,
3685
+ k as XK,
3686
+ L as assertVolumePath,
3687
+ et as charToKeysym,
3688
+ Qn as composeFeedbackMessage,
3689
+ Tn as conversationToSubagentEvents,
3690
+ _n as createDerivedStores,
3691
+ os as createSandboxBrowserTransport,
3692
+ qn as decodeCursorFrame,
3693
+ xn as deriveSubagents,
3694
+ Cn as deriveTasks,
3695
+ Jn as feedbackCommentByteLength,
3696
+ yn as isAgentTool,
3697
+ Vn as isChannelAwaitingConsentError,
3698
+ Wn as isChannelBusyError,
3699
+ Kn as isHttpError,
3700
+ ts as isPrintableKeysym,
3701
+ wn as isSubagentChildTool,
3702
+ Sn as isTaskTool,
3703
+ es as keyToKeysym,
3704
+ ns as mapModifierKeysym,
3705
+ rs as normalizeWheel,
3706
+ Ce as reconcileLaunched,
3707
+ En as reduceSubagents,
3708
+ vn as reduceTaskEvents,
3709
+ Zn as resolveSandboxUri,
3710
+ kn as subagentsEqual,
3711
+ An as tasksEqual
3428
3712
  };
3429
3713
  //# sourceMappingURL=index.mjs.map