@asgard-js/core 0.3.91 → 0.3.92

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 A extends Error {
1
+ class k extends Error {
2
2
  status;
3
3
  statusText;
4
4
  /**
@@ -17,7 +17,7 @@ class A extends Error {
17
17
  }
18
18
  }
19
19
  function Kn(n) {
20
- return n instanceof A;
20
+ return n instanceof k;
21
21
  }
22
22
  class se extends Error {
23
23
  /** Which run is holding the channel. */
@@ -26,7 +26,7 @@ class se extends Error {
26
26
  super(`Cannot send a message while a "${t}" run is in flight on this channel.`), this.name = "ChannelBusyError", this.runKind = t;
27
27
  }
28
28
  }
29
- function Wn(n) {
29
+ function Vn(n) {
30
30
  return n instanceof se;
31
31
  }
32
32
  class re extends Error {
@@ -43,10 +43,10 @@ class re 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 Vn(n) {
46
+ function Xn(n) {
47
47
  return n instanceof re;
48
48
  }
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 || {});
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 || {}), Ae = /* @__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))(Ae || {});
50
50
  async function nt(n, t) {
51
51
  const e = n.getReader();
52
52
  let s;
@@ -55,8 +55,8 @@ async function nt(n, t) {
55
55
  }
56
56
  function st(n) {
57
57
  let t, e, s, r = !1;
58
- return function(i) {
59
- t === void 0 ? (t = i, e = 0, s = -1) : t = ot(t, i);
58
+ return function(o) {
59
+ t === void 0 ? (t = o, e = 0, s = -1) : t = it(t, o);
60
60
  const a = t.length;
61
61
  let c = 0;
62
62
  for (; e < a; ) {
@@ -83,11 +83,11 @@ function st(n) {
83
83
  function rt(n, t, e) {
84
84
  let s = he();
85
85
  const r = new TextDecoder();
86
- return function(i, a) {
87
- if (i.length === 0)
86
+ return function(o, a) {
87
+ if (o.length === 0)
88
88
  e?.(s), s = he();
89
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));
90
+ const c = r.decode(o.subarray(0, a)), u = a + (o[a + 1] === 32 ? 2 : 1), l = r.decode(o.subarray(u));
91
91
  switch (c) {
92
92
  case "data":
93
93
  s.data = s.data ? s.data + `
@@ -107,7 +107,7 @@ function rt(n, t, e) {
107
107
  }
108
108
  };
109
109
  }
110
- function ot(n, t) {
110
+ function it(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
  }
@@ -119,7 +119,7 @@ function he() {
119
119
  retry: void 0
120
120
  };
121
121
  }
122
- var it = function(n, t) {
122
+ var ot = 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,12 +127,12 @@ var it = 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 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"]);
130
+ const ie = "text/event-stream", at = 1e3, fe = "last-event-id";
131
+ function Oe(n, t) {
132
+ var { signal: e, headers: s, onopen: r, onmessage: i, onclose: o, onerror: a, openWhenHidden: c, fetch: u } = t, l = ot(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
133
133
  return new Promise((v, w) => {
134
134
  const p = Object.assign({}, s);
135
- p.accept || (p.accept = oe);
135
+ p.accept || (p.accept = ie);
136
136
  let g;
137
137
  function d() {
138
138
  g.abort(), document.hidden || b();
@@ -150,16 +150,16 @@ function ke(n, t) {
150
150
  var I;
151
151
  g = new AbortController();
152
152
  try {
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((_) => {
153
+ const L = await m(n, Object.assign(Object.assign({}, l), { headers: p, signal: g.signal }));
154
+ await S(L), await nt(L.body, st(rt((_) => {
155
155
  _ ? p[fe] = _ : delete p[fe];
156
156
  }, (_) => {
157
157
  C = _;
158
- }, o))), i?.(), f(), v();
159
- } catch (M) {
158
+ }, i))), o?.(), f(), v();
159
+ } catch (L) {
160
160
  if (!g.signal.aborted)
161
161
  try {
162
- const _ = (I = a?.(M)) !== null && I !== void 0 ? I : C;
162
+ const _ = (I = a?.(L)) !== null && I !== void 0 ? I : C;
163
163
  window.clearTimeout(x), x = window.setTimeout(b, _);
164
164
  } catch (_) {
165
165
  f(), w(_);
@@ -171,60 +171,60 @@ function ke(n, t) {
171
171
  }
172
172
  function ct(n) {
173
173
  const t = n.headers.get("content-type");
174
- if (!t?.startsWith(oe))
175
- throw new Error(`Expected content-type to be ${oe}, Actual: ${t}`);
174
+ if (!t?.startsWith(ie))
175
+ throw new Error(`Expected content-type to be ${ie}, Actual: ${t}`);
176
176
  }
177
- var ie = function(n, t) {
178
- return ie = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, s) {
177
+ var oe = function(n, t) {
178
+ return oe = 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
- }, ie(n, t);
182
+ }, oe(n, t);
183
183
  };
184
- function N(n, t) {
184
+ function R(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
- ie(n, t);
187
+ oe(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
193
  function ut(n, t, e, s) {
194
- function r(o) {
195
- return o instanceof e ? o : new e(function(i) {
196
- i(o);
194
+ function r(i) {
195
+ return i instanceof e ? i : new e(function(o) {
196
+ o(i);
197
197
  });
198
198
  }
199
- return new (e || (e = Promise))(function(o, i) {
199
+ return new (e || (e = Promise))(function(i, o) {
200
200
  function a(l) {
201
201
  try {
202
202
  u(s.next(l));
203
203
  } catch (v) {
204
- i(v);
204
+ o(v);
205
205
  }
206
206
  }
207
207
  function c(l) {
208
208
  try {
209
209
  u(s.throw(l));
210
210
  } catch (v) {
211
- i(v);
211
+ o(v);
212
212
  }
213
213
  }
214
214
  function u(l) {
215
- l.done ? o(l.value) : r(l.value).then(a, c);
215
+ l.done ? i(l.value) : r(l.value).then(a, c);
216
216
  }
217
217
  u((s = s.apply(n, t || [])).next());
218
218
  });
219
219
  }
220
220
  function _e(n, t) {
221
221
  var e = { label: 0, sent: 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() {
222
+ if (i[0] & 1) throw i[1];
223
+ return i[1];
224
+ }, trys: [], ops: [] }, s, r, i, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
225
+ return o.next = a(0), o.throw = a(1), o.return = a(2), typeof Symbol == "function" && (o[Symbol.iterator] = function() {
226
226
  return this;
227
- }), i;
227
+ }), o;
228
228
  function a(u) {
229
229
  return function(l) {
230
230
  return c([u, l]);
@@ -232,12 +232,12 @@ function _e(n, t) {
232
232
  }
233
233
  function c(u) {
234
234
  if (s) throw new TypeError("Generator is already executing.");
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]) {
235
+ for (; o && (o = 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]) {
238
238
  case 0:
239
239
  case 1:
240
- o = u;
240
+ i = u;
241
241
  break;
242
242
  case 4:
243
243
  return e.label++, { value: u[1], done: !1 };
@@ -248,30 +248,30 @@ function _e(n, t) {
248
248
  u = e.ops.pop(), e.trys.pop();
249
249
  continue;
250
250
  default:
251
- if (o = e.trys, !(o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
251
+ if (i = e.trys, !(i = i.length > 0 && i[i.length - 1]) && (u[0] === 6 || u[0] === 2)) {
252
252
  e = 0;
253
253
  continue;
254
254
  }
255
- if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
255
+ if (u[0] === 3 && (!i || u[1] > i[0] && u[1] < i[3])) {
256
256
  e.label = u[1];
257
257
  break;
258
258
  }
259
- if (u[0] === 6 && e.label < o[1]) {
260
- e.label = o[1], o = u;
259
+ if (u[0] === 6 && e.label < i[1]) {
260
+ e.label = i[1], i = u;
261
261
  break;
262
262
  }
263
- if (o && e.label < o[2]) {
264
- e.label = o[2], e.ops.push(u);
263
+ if (i && e.label < i[2]) {
264
+ e.label = i[2], e.ops.push(u);
265
265
  break;
266
266
  }
267
- o[2] && e.ops.pop(), e.trys.pop();
267
+ i[2] && e.ops.pop(), e.trys.pop();
268
268
  continue;
269
269
  }
270
270
  u = t.call(n, e);
271
271
  } catch (l) {
272
272
  u = [6, l], r = 0;
273
273
  } finally {
274
- s = o = 0;
274
+ s = i = 0;
275
275
  }
276
276
  if (u[0] & 5) throw u[1];
277
277
  return { value: u[0] ? u[1] : void 0, done: !0 };
@@ -287,38 +287,38 @@ function $(n) {
287
287
  };
288
288
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
289
289
  }
290
- function K(n, t) {
290
+ function W(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, o = [], i;
293
+ var s = e.call(n), r, i = [], o;
294
294
  try {
295
- for (; (t === void 0 || t-- > 0) && !(r = s.next()).done; ) o.push(r.value);
295
+ for (; (t === void 0 || t-- > 0) && !(r = s.next()).done; ) i.push(r.value);
296
296
  } catch (a) {
297
- i = { error: a };
297
+ o = { error: a };
298
298
  } finally {
299
299
  try {
300
300
  r && !r.done && (e = s.return) && e.call(s);
301
301
  } finally {
302
- if (i) throw i.error;
302
+ if (o) throw o.error;
303
303
  }
304
304
  }
305
- return o;
305
+ return i;
306
306
  }
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));
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));
311
311
  }
312
312
  function B(n) {
313
313
  return this instanceof B ? (this.v = n, this) : new B(n);
314
314
  }
315
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, o = [];
318
- return r = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), r[Symbol.asyncIterator] = function() {
317
+ var s = e.apply(n, t || []), r, i = [];
318
+ return r = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", o), r[Symbol.asyncIterator] = function() {
319
319
  return this;
320
320
  }, r;
321
- function i(p) {
321
+ function o(p) {
322
322
  return function(g) {
323
323
  return Promise.resolve(g).then(p, v);
324
324
  };
@@ -326,7 +326,7 @@ function lt(n, t, e) {
326
326
  function a(p, g) {
327
327
  s[p] && (r[p] = function(d) {
328
328
  return new Promise(function(C, x) {
329
- o.push([p, d, C, x]) > 1 || c(p, d);
329
+ i.push([p, d, C, x]) > 1 || c(p, d);
330
330
  });
331
331
  }, g && (r[p] = g(r[p])));
332
332
  }
@@ -334,11 +334,11 @@ function lt(n, t, e) {
334
334
  try {
335
335
  u(s[p](g));
336
336
  } catch (d) {
337
- w(o[0][3], d);
337
+ w(i[0][3], d);
338
338
  }
339
339
  }
340
340
  function u(p) {
341
- p.value instanceof B ? Promise.resolve(p.value.v).then(l, v) : w(o[0][2], p);
341
+ p.value instanceof B ? Promise.resolve(p.value.v).then(l, v) : w(i[0][2], p);
342
342
  }
343
343
  function l(p) {
344
344
  c("next", p);
@@ -347,7 +347,7 @@ function lt(n, t, e) {
347
347
  c("throw", p);
348
348
  }
349
349
  function w(p, g) {
350
- p(g), o.shift(), o.length && c(o[0][0], o[0][1]);
350
+ p(g), i.shift(), i.length && c(i[0][0], i[0][1]);
351
351
  }
352
352
  }
353
353
  function dt(n) {
@@ -356,17 +356,17 @@ function dt(n) {
356
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(o) {
360
- e[o] = n[o] && function(i) {
359
+ function s(i) {
360
+ e[i] = n[i] && function(o) {
361
361
  return new Promise(function(a, c) {
362
- i = n[o](i), r(a, c, i.done, i.value);
362
+ o = n[i](o), r(a, c, o.done, o.value);
363
363
  });
364
364
  };
365
365
  }
366
- function r(o, i, a, c) {
366
+ function r(i, o, a, c) {
367
367
  Promise.resolve(c).then(function(u) {
368
- o({ value: u, done: a });
369
- }, i);
368
+ i({ value: u, done: a });
369
+ }, o);
370
370
  }
371
371
  }
372
372
  function E(n) {
@@ -398,14 +398,14 @@ var D = (function() {
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, o;
401
+ var t, e, s, r, i;
402
402
  if (!this.closed) {
403
403
  this.closed = !0;
404
- var i = this._parentage;
405
- if (i)
406
- if (this._parentage = null, Array.isArray(i))
404
+ var o = this._parentage;
405
+ if (o)
406
+ if (this._parentage = null, Array.isArray(o))
407
407
  try {
408
- for (var a = $(i), c = a.next(); !c.done; c = a.next()) {
408
+ for (var a = $(o), c = a.next(); !c.done; c = a.next()) {
409
409
  var u = c.value;
410
410
  u.remove(this);
411
411
  }
@@ -419,13 +419,13 @@ var D = (function() {
419
419
  }
420
420
  }
421
421
  else
422
- i.remove(this);
422
+ o.remove(this);
423
423
  var l = this.initialTeardown;
424
424
  if (E(l))
425
425
  try {
426
426
  l();
427
427
  } catch (d) {
428
- o = d instanceof Z ? d.errors : [d];
428
+ i = d instanceof Z ? d.errors : [d];
429
429
  }
430
430
  var v = this._finalizers;
431
431
  if (v) {
@@ -436,7 +436,7 @@ var D = (function() {
436
436
  try {
437
437
  pe(g);
438
438
  } catch (d) {
439
- o = o ?? [], d instanceof Z ? o = W(W([], K(o)), K(d.errors)) : o.push(d);
439
+ i = i ?? [], d instanceof Z ? i = K(K([], W(i)), W(d.errors)) : i.push(d);
440
440
  }
441
441
  }
442
442
  } catch (d) {
@@ -449,8 +449,8 @@ var D = (function() {
449
449
  }
450
450
  }
451
451
  }
452
- if (o)
453
- throw new Z(o);
452
+ if (i)
453
+ throw new Z(i);
454
454
  }
455
455
  }, n.prototype.add = function(t) {
456
456
  var e;
@@ -494,7 +494,7 @@ var ht = {
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, W([n, t], K(e)));
497
+ return setTimeout.apply(void 0, K([n, t], W(e)));
498
498
  },
499
499
  clearTimeout: function(n) {
500
500
  return clearTimeout(n);
@@ -512,7 +512,7 @@ function Y(n) {
512
512
  n();
513
513
  }
514
514
  var ue = (function(n) {
515
- N(t, n);
515
+ R(t, n);
516
516
  function t(e) {
517
517
  var s = n.call(this) || this;
518
518
  return s.isStopped = !1, e ? (s.destination = e, Le(e) && e.add(s)) : s.destination = mt, s;
@@ -574,14 +574,14 @@ var ue = (function(n) {
574
574
  }
575
575
  }, n;
576
576
  })(), ce = (function(n) {
577
- N(t, n);
577
+ R(t, n);
578
578
  function t(e, s, r) {
579
- var o = n.call(this) || this, i;
580
- return E(e) || !e ? i = {
579
+ var i = n.call(this) || this, o;
580
+ return E(e) || !e ? o = {
581
581
  next: e ?? void 0,
582
582
  error: s ?? void 0,
583
583
  complete: r ?? void 0
584
- } : i = e, o.destination = new pt(i), o;
584
+ } : o = e, i.destination = new pt(o), i;
585
585
  }
586
586
  return t;
587
587
  })(ue);
@@ -609,7 +609,7 @@ function bt(n) {
609
609
  }, e);
610
610
  };
611
611
  }
612
- var O = (function() {
612
+ var A = (function() {
613
613
  function n(t) {
614
614
  t && (this._subscribe = t);
615
615
  }
@@ -617,11 +617,11 @@ var O = (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, o = vt(t) ? t : new ce(t, e, s);
620
+ var r = this, i = vt(t) ? t : new ce(t, e, s);
621
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;
622
+ var o = r, a = o.operator, c = o.source;
623
+ i.add(a ? a.call(i, c) : c ? r._subscribe(i) : r._trySubscribe(i));
624
+ }), i;
625
625
  }, n.prototype._trySubscribe = function(t) {
626
626
  try {
627
627
  return this._subscribe(t);
@@ -630,19 +630,19 @@ var O = (function() {
630
630
  }
631
631
  }, n.prototype.forEach = function(t, e) {
632
632
  var s = this;
633
- return e = ge(e), new e(function(r, o) {
634
- var i = new ce({
633
+ return e = ge(e), new e(function(r, i) {
634
+ var o = new ce({
635
635
  next: function(a) {
636
636
  try {
637
637
  t(a);
638
638
  } catch (c) {
639
- o(c), i.unsubscribe();
639
+ i(c), o.unsubscribe();
640
640
  }
641
641
  },
642
- error: o,
642
+ error: i,
643
643
  complete: r
644
644
  });
645
- s.subscribe(i);
645
+ s.subscribe(o);
646
646
  });
647
647
  }, n.prototype._subscribe = function(t) {
648
648
  var e;
@@ -656,13 +656,13 @@ var O = (function() {
656
656
  }, n.prototype.toPromise = function(t) {
657
657
  var e = this;
658
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);
659
+ var i;
660
+ e.subscribe(function(o) {
661
+ return i = o;
662
+ }, function(o) {
663
+ return r(o);
664
664
  }, function() {
665
- return s(o);
665
+ return s(i);
666
666
  });
667
667
  });
668
668
  }, n.create = function(t) {
@@ -682,7 +682,7 @@ function vt(n) {
682
682
  function yt(n) {
683
683
  return E(n?.lift);
684
684
  }
685
- function F(n) {
685
+ function j(n) {
686
686
  return function(t) {
687
687
  if (yt(t))
688
688
  return t.lift(function(e) {
@@ -699,18 +699,18 @@ function H(n, t, e, s, r) {
699
699
  return new wt(n, t, e, s, r);
700
700
  }
701
701
  var wt = (function(n) {
702
- N(t, n);
703
- function t(e, s, r, o, i, a) {
702
+ R(t, n);
703
+ function t(e, s, r, i, o, a) {
704
704
  var c = n.call(this, e) || this;
705
- return c.onFinalize = i, c.shouldUnsubscribe = a, c._next = s ? function(u) {
705
+ return c.onFinalize = o, c.shouldUnsubscribe = a, c._next = s ? function(u) {
706
706
  try {
707
707
  s(u);
708
708
  } catch (l) {
709
709
  e.error(l);
710
710
  }
711
- } : n.prototype._next, c._error = o ? function(u) {
711
+ } : n.prototype._next, c._error = i ? function(u) {
712
712
  try {
713
- o(u);
713
+ i(u);
714
714
  } catch (l) {
715
715
  e.error(l);
716
716
  } finally {
@@ -738,7 +738,7 @@ var wt = (function(n) {
738
738
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
739
739
  };
740
740
  }), de = (function(n) {
741
- N(t, n);
741
+ R(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;
@@ -752,11 +752,11 @@ var wt = (function(n) {
752
752
  }, t.prototype.next = function(e) {
753
753
  var s = this;
754
754
  Y(function() {
755
- var r, o;
755
+ var r, i;
756
756
  if (s._throwIfClosed(), !s.isStopped) {
757
757
  s.currentObservers || (s.currentObservers = Array.from(s.observers));
758
758
  try {
759
- for (var i = $(s.currentObservers), a = i.next(); !a.done; a = i.next()) {
759
+ for (var o = $(s.currentObservers), a = o.next(); !a.done; a = o.next()) {
760
760
  var c = a.value;
761
761
  c.next(e);
762
762
  }
@@ -764,7 +764,7 @@ var wt = (function(n) {
764
764
  r = { error: u };
765
765
  } finally {
766
766
  try {
767
- a && !a.done && (o = i.return) && o.call(i);
767
+ a && !a.done && (i = o.return) && i.call(o);
768
768
  } finally {
769
769
  if (r) throw r.error;
770
770
  }
@@ -803,21 +803,21 @@ var wt = (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, o = r.hasError, i = r.isStopped, a = r.observers;
807
- return o || i ? Me : (this.currentObservers = null, a.push(e), new D(function() {
806
+ var s = this, r = this, i = r.hasError, o = r.isStopped, a = r.observers;
807
+ return i || o ? Me : (this.currentObservers = null, a.push(e), new D(function() {
808
808
  s.currentObservers = null, V(a, e);
809
809
  }));
810
810
  }, t.prototype._checkFinalizedStatuses = function(e) {
811
- var s = this, r = s.hasError, o = s.thrownError, i = s.isStopped;
812
- r ? e.error(o) : i && e.complete();
811
+ var s = this, r = s.hasError, i = s.thrownError, o = s.isStopped;
812
+ r ? e.error(i) : o && e.complete();
813
813
  }, t.prototype.asObservable = function() {
814
- var e = new O();
814
+ var e = new A();
815
815
  return e.source = this, e;
816
816
  }, t.create = function(e, s) {
817
817
  return new me(e, s);
818
818
  }, t;
819
- })(O), me = (function(n) {
820
- N(t, n);
819
+ })(A), me = (function(n) {
820
+ R(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;
@@ -835,8 +835,8 @@ var wt = (function(n) {
835
835
  var s, r;
836
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
- })(de), R = (function(n) {
839
- N(t, n);
838
+ })(de), P = (function(n) {
839
+ R(t, n);
840
840
  function t(e) {
841
841
  var s = n.call(this) || this;
842
842
  return s._value = e, s;
@@ -851,10 +851,10 @@ var wt = (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, o = e._value;
854
+ var e = this, s = e.hasError, r = e.thrownError, i = e._value;
855
855
  if (s)
856
856
  throw r;
857
- return this._throwIfClosed(), o;
857
+ return this._throwIfClosed(), i;
858
858
  }, t.prototype.next = function(e) {
859
859
  n.prototype.next.call(this, this._value = e);
860
860
  }, t;
@@ -863,7 +863,7 @@ var wt = (function(n) {
863
863
  return Date.now();
864
864
  }
865
865
  }, Tt = (function(n) {
866
- N(t, n);
866
+ R(t, n);
867
867
  function t(e, s) {
868
868
  return n.call(this) || this;
869
869
  }
@@ -874,14 +874,14 @@ var wt = (function(n) {
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, W([n, t], K(e)));
877
+ return setInterval.apply(void 0, K([n, t], W(e)));
878
878
  },
879
879
  clearInterval: function(n) {
880
880
  return clearInterval(n);
881
881
  },
882
882
  delegate: void 0
883
883
  }, Ct = (function(n) {
884
- N(t, n);
884
+ R(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,8 +891,8 @@ var wt = (function(n) {
891
891
  if (s === void 0 && (s = 0), this.closed)
892
892
  return this;
893
893
  this.state = e;
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;
894
+ var i = this.id, o = this.scheduler;
895
+ return i != null && (this.id = this.recycleAsyncId(o, i, s)), this.pending = !0, this.delay = s, this.id = (r = this.id) !== null && r !== void 0 ? r : this.requestAsyncId(o, this.id, s), this;
896
896
  }, t.prototype.requestAsyncId = function(e, s, r) {
897
897
  return r === void 0 && (r = 0), be.setInterval(e.flush.bind(e, this), r);
898
898
  }, t.prototype.recycleAsyncId = function(e, s, r) {
@@ -908,18 +908,18 @@ var wt = (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, o;
911
+ var r = !1, i;
912
912
  try {
913
913
  this.work(e);
914
- } catch (i) {
915
- r = !0, o = i || new Error("Scheduled action threw falsy error");
914
+ } catch (o) {
915
+ r = !0, i = o || new Error("Scheduled action threw falsy error");
916
916
  }
917
917
  if (r)
918
- return this.unsubscribe(), o;
918
+ return this.unsubscribe(), i;
919
919
  }, t.prototype.unsubscribe = function() {
920
920
  if (!this.closed) {
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);
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);
923
923
  }
924
924
  }, t;
925
925
  })(Tt), Se = (function() {
@@ -930,7 +930,7 @@ var wt = (function(n) {
930
930
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(s, e);
931
931
  }, n.now = It.now, n;
932
932
  })(), xt = (function(n) {
933
- N(t, n);
933
+ R(t, n);
934
934
  function t(e, s) {
935
935
  s === void 0 && (s = Se.now);
936
936
  var r = n.call(this, e, s) || this;
@@ -954,20 +954,20 @@ var wt = (function(n) {
954
954
  throw r;
955
955
  }
956
956
  }, t;
957
- })(Se), At = new xt(Ct);
958
- function Ot(n) {
957
+ })(Se), kt = new xt(Ct);
958
+ function At(n) {
959
959
  return n && E(n.schedule);
960
960
  }
961
- function Re(n) {
961
+ function Fe(n) {
962
962
  return n[n.length - 1];
963
963
  }
964
- function kt(n) {
965
- return E(Re(n)) ? n.pop() : void 0;
964
+ function Ot(n) {
965
+ return E(Fe(n)) ? n.pop() : void 0;
966
966
  }
967
- function Ne(n) {
968
- return Ot(Re(n)) ? n.pop() : void 0;
967
+ function Re(n) {
968
+ return At(Fe(n)) ? n.pop() : void 0;
969
969
  }
970
- var Fe = (function(n) {
970
+ var Ne = (function(n) {
971
971
  return n && typeof n.length == "number" && typeof n != "function";
972
972
  });
973
973
  function je(n) {
@@ -991,25 +991,25 @@ function Ge(n) {
991
991
  }
992
992
  function qe(n) {
993
993
  return lt(this, arguments, function() {
994
- var e, s, r, o;
995
- return _e(this, function(i) {
996
- switch (i.label) {
994
+ var e, s, r, i;
995
+ return _e(this, function(o) {
996
+ switch (o.label) {
997
997
  case 0:
998
- e = n.getReader(), i.label = 1;
998
+ e = n.getReader(), o.label = 1;
999
999
  case 1:
1000
- i.trys.push([1, , 9, 10]), i.label = 2;
1000
+ o.trys.push([1, , 9, 10]), o.label = 2;
1001
1001
  case 2:
1002
1002
  return [4, B(e.read())];
1003
1003
  case 3:
1004
- return s = i.sent(), r = s.value, o = s.done, o ? [4, B(void 0)] : [3, 5];
1004
+ return s = o.sent(), r = s.value, i = s.done, i ? [4, B(void 0)] : [3, 5];
1005
1005
  case 4:
1006
- return [2, i.sent()];
1006
+ return [2, o.sent()];
1007
1007
  case 5:
1008
1008
  return [4, B(r)];
1009
1009
  case 6:
1010
- return [4, i.sent()];
1010
+ return [4, o.sent()];
1011
1011
  case 7:
1012
- return i.sent(), [3, 2];
1012
+ return o.sent(), [3, 2];
1013
1013
  case 8:
1014
1014
  return [3, 10];
1015
1015
  case 9:
@@ -1020,30 +1020,30 @@ function qe(n) {
1020
1020
  });
1021
1021
  });
1022
1022
  }
1023
- function Ke(n) {
1023
+ function We(n) {
1024
1024
  return E(n?.getReader);
1025
1025
  }
1026
1026
  function Q(n) {
1027
- if (n instanceof O)
1027
+ if (n instanceof A)
1028
1028
  return n;
1029
1029
  if (n != null) {
1030
1030
  if ($e(n))
1031
1031
  return Pt(n);
1032
- if (Fe(n))
1032
+ if (Ne(n))
1033
1033
  return Mt(n);
1034
1034
  if (je(n))
1035
1035
  return Lt(n);
1036
1036
  if (De(n))
1037
- return We(n);
1037
+ return Ke(n);
1038
1038
  if (Ge(n))
1039
1039
  return Ut(n);
1040
- if (Ke(n))
1041
- return Rt(n);
1040
+ if (We(n))
1041
+ return Ft(n);
1042
1042
  }
1043
1043
  throw He(n);
1044
1044
  }
1045
1045
  function Pt(n) {
1046
- return new O(function(t) {
1046
+ return new A(function(t) {
1047
1047
  var e = n[le]();
1048
1048
  if (E(e.subscribe))
1049
1049
  return e.subscribe(t);
@@ -1051,14 +1051,14 @@ function Pt(n) {
1051
1051
  });
1052
1052
  }
1053
1053
  function Mt(n) {
1054
- return new O(function(t) {
1054
+ return new A(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
1060
  function Lt(n) {
1061
- return new O(function(t) {
1061
+ return new A(function(t) {
1062
1062
  n.then(function(e) {
1063
1063
  t.closed || (t.next(e), t.complete());
1064
1064
  }, function(e) {
@@ -1067,19 +1067,19 @@ function Lt(n) {
1067
1067
  });
1068
1068
  }
1069
1069
  function Ut(n) {
1070
- return new O(function(t) {
1070
+ return new A(function(t) {
1071
1071
  var e, s;
1072
1072
  try {
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)
1073
+ for (var r = $(n), i = r.next(); !i.done; i = r.next()) {
1074
+ var o = i.value;
1075
+ if (t.next(o), t.closed)
1076
1076
  return;
1077
1077
  }
1078
1078
  } catch (a) {
1079
1079
  e = { error: a };
1080
1080
  } finally {
1081
1081
  try {
1082
- o && !o.done && (s = r.return) && s.call(r);
1082
+ i && !i.done && (s = r.return) && s.call(r);
1083
1083
  } finally {
1084
1084
  if (e) throw e.error;
1085
1085
  }
@@ -1087,20 +1087,20 @@ function Ut(n) {
1087
1087
  t.complete();
1088
1088
  });
1089
1089
  }
1090
- function We(n) {
1091
- return new O(function(t) {
1092
- Nt(n, t).catch(function(e) {
1090
+ function Ke(n) {
1091
+ return new A(function(t) {
1092
+ Rt(n, t).catch(function(e) {
1093
1093
  return t.error(e);
1094
1094
  });
1095
1095
  });
1096
1096
  }
1097
- function Rt(n) {
1098
- return We(qe(n));
1097
+ function Ft(n) {
1098
+ return Ke(qe(n));
1099
1099
  }
1100
- function Nt(n, t) {
1101
- var e, s, r, o;
1100
+ function Rt(n, t) {
1101
+ var e, s, r, i;
1102
1102
  return ut(this, void 0, void 0, function() {
1103
- var i, a;
1103
+ var o, a;
1104
1104
  return _e(this, function(c) {
1105
1105
  switch (c.label) {
1106
1106
  case 0:
@@ -1109,7 +1109,7 @@ function Nt(n, t) {
1109
1109
  return [4, e.next()];
1110
1110
  case 2:
1111
1111
  if (s = c.sent(), !!s.done) return [3, 4];
1112
- if (i = s.value, t.next(i), t.closed)
1112
+ if (o = s.value, t.next(o), t.closed)
1113
1113
  return [2];
1114
1114
  c.label = 3;
1115
1115
  case 3:
@@ -1119,7 +1119,7 @@ function Nt(n, t) {
1119
1119
  case 5:
1120
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 && (o = e.return) ? [4, o.call(e)] : [3, 8];
1122
+ return c.trys.push([6, , 9, 10]), s && !s.done && (i = e.return) ? [4, i.call(e)] : [3, 8];
1123
1123
  case 7:
1124
1124
  c.sent(), c.label = 8;
1125
1125
  case 8:
@@ -1135,46 +1135,46 @@ function Nt(n, t) {
1135
1135
  });
1136
1136
  });
1137
1137
  }
1138
- function P(n, t, e, s, r) {
1138
+ function M(n, t, e, s, r) {
1139
1139
  s === void 0 && (s = 0), r === void 0 && (r = !1);
1140
- var o = t.schedule(function() {
1140
+ var i = t.schedule(function() {
1141
1141
  e(), r ? n.add(this.schedule(null, s)) : this.unsubscribe();
1142
1142
  }, s);
1143
- if (n.add(o), !r)
1144
- return o;
1143
+ if (n.add(i), !r)
1144
+ return i;
1145
1145
  }
1146
1146
  function Ve(n, t) {
1147
- return t === void 0 && (t = 0), F(function(e, s) {
1147
+ return t === void 0 && (t = 0), j(function(e, s) {
1148
1148
  e.subscribe(H(s, function(r) {
1149
- return P(s, n, function() {
1149
+ return M(s, n, function() {
1150
1150
  return s.next(r);
1151
1151
  }, t);
1152
1152
  }, function() {
1153
- return P(s, n, function() {
1153
+ return M(s, n, function() {
1154
1154
  return s.complete();
1155
1155
  }, t);
1156
1156
  }, function(r) {
1157
- return P(s, n, function() {
1157
+ return M(s, n, function() {
1158
1158
  return s.error(r);
1159
1159
  }, t);
1160
1160
  }));
1161
1161
  });
1162
1162
  }
1163
1163
  function Xe(n, t) {
1164
- return t === void 0 && (t = 0), F(function(e, s) {
1164
+ return t === void 0 && (t = 0), j(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 Ft(n, t) {
1170
+ function Nt(n, t) {
1171
1171
  return Q(n).pipe(Xe(t), Ve(t));
1172
1172
  }
1173
1173
  function jt(n, t) {
1174
1174
  return Q(n).pipe(Xe(t), Ve(t));
1175
1175
  }
1176
1176
  function $t(n, t) {
1177
- return new O(function(e) {
1177
+ return new A(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());
@@ -1182,18 +1182,18 @@ function $t(n, t) {
1182
1182
  });
1183
1183
  }
1184
1184
  function Dt(n, t) {
1185
- return new O(function(e) {
1185
+ return new A(function(e) {
1186
1186
  var s;
1187
- return P(e, t, function() {
1188
- s = n[Be](), P(e, t, function() {
1189
- var r, o, i;
1187
+ return M(e, t, function() {
1188
+ s = n[Be](), M(e, t, function() {
1189
+ var r, i, o;
1190
1190
  try {
1191
- r = s.next(), o = r.value, i = r.done;
1191
+ r = s.next(), i = r.value, o = r.done;
1192
1192
  } catch (a) {
1193
1193
  e.error(a);
1194
1194
  return;
1195
1195
  }
1196
- i ? e.complete() : e.next(o);
1196
+ o ? e.complete() : e.next(i);
1197
1197
  }, 0, !0);
1198
1198
  }), function() {
1199
1199
  return E(s?.return) && s.return();
@@ -1203,10 +1203,10 @@ function Dt(n, t) {
1203
1203
  function Ye(n, t) {
1204
1204
  if (!n)
1205
1205
  throw new Error("Iterable cannot be null");
1206
- return new O(function(e) {
1207
- P(e, t, function() {
1206
+ return new A(function(e) {
1207
+ M(e, t, function() {
1208
1208
  var s = n[Symbol.asyncIterator]();
1209
- P(e, t, function() {
1209
+ M(e, t, function() {
1210
1210
  s.next().then(function(r) {
1211
1211
  r.done ? e.complete() : e.next(r.value);
1212
1212
  });
@@ -1220,8 +1220,8 @@ function Ht(n, t) {
1220
1220
  function Bt(n, t) {
1221
1221
  if (n != null) {
1222
1222
  if ($e(n))
1223
- return Ft(n, t);
1224
- if (Fe(n))
1223
+ return Nt(n, t);
1224
+ if (Ne(n))
1225
1225
  return $t(n, t);
1226
1226
  if (je(n))
1227
1227
  return jt(n, t);
@@ -1229,7 +1229,7 @@ function Bt(n, t) {
1229
1229
  return Ye(n, t);
1230
1230
  if (Ge(n))
1231
1231
  return Dt(n, t);
1232
- if (Ke(n))
1232
+ if (We(n))
1233
1233
  return Ht(n, t);
1234
1234
  }
1235
1235
  throw He(n);
@@ -1238,27 +1238,27 @@ function ze(n, t) {
1238
1238
  return t ? Bt(n, t) : Q(n);
1239
1239
  }
1240
1240
  function z(n, t) {
1241
- return F(function(e, s) {
1241
+ return j(function(e, s) {
1242
1242
  var r = 0;
1243
- e.subscribe(H(s, function(o) {
1244
- s.next(n.call(t, o, r++));
1243
+ e.subscribe(H(s, function(i) {
1244
+ s.next(n.call(t, i, r++));
1245
1245
  }));
1246
1246
  });
1247
1247
  }
1248
1248
  var Gt = Array.isArray;
1249
1249
  function qt(n, t) {
1250
- return Gt(t) ? n.apply(void 0, W([], K(t))) : n(t);
1250
+ return Gt(t) ? n.apply(void 0, K([], W(t))) : n(t);
1251
1251
  }
1252
- function Kt(n) {
1252
+ function Wt(n) {
1253
1253
  return z(function(t) {
1254
1254
  return qt(n, t);
1255
1255
  });
1256
1256
  }
1257
- var Wt = Array.isArray, Vt = Object.getPrototypeOf, Xt = Object.prototype, Yt = Object.keys;
1257
+ var Kt = Array.isArray, Vt = Object.getPrototypeOf, Xt = Object.prototype, Yt = Object.keys;
1258
1258
  function zt(n) {
1259
1259
  if (n.length === 1) {
1260
1260
  var t = n[0];
1261
- if (Wt(t))
1261
+ if (Kt(t))
1262
1262
  return { args: t, keys: null };
1263
1263
  if (Jt(t)) {
1264
1264
  var e = Yt(t);
@@ -1283,24 +1283,24 @@ function Qt(n, t) {
1283
1283
  function Zt() {
1284
1284
  for (var n = [], t = 0; t < arguments.length; t++)
1285
1285
  n[t] = arguments[t];
1286
- var e = Ne(n), s = kt(n), r = zt(n), o = r.args, i = r.keys;
1287
- if (o.length === 0)
1286
+ var e = Re(n), s = Ot(n), r = zt(n), i = r.args, o = r.keys;
1287
+ if (i.length === 0)
1288
1288
  return ze([], e);
1289
- var a = new O(en(o, e, i ? function(c) {
1290
- return Qt(i, c);
1289
+ var a = new A(en(i, e, o ? function(c) {
1290
+ return Qt(o, c);
1291
1291
  } : J));
1292
- return s ? a.pipe(Kt(s)) : a;
1292
+ return s ? a.pipe(Wt(s)) : a;
1293
1293
  }
1294
1294
  function en(n, t, e) {
1295
1295
  return e === void 0 && (e = J), function(s) {
1296
1296
  ve(t, function() {
1297
- for (var r = n.length, o = new Array(r), i = r, a = r, c = function(l) {
1297
+ for (var r = n.length, i = new Array(r), o = r, a = r, c = function(l) {
1298
1298
  ve(t, function() {
1299
1299
  var v = ze(n[l], t), w = !1;
1300
1300
  v.subscribe(H(s, function(p) {
1301
- o[l] = p, w || (w = !0, a--), a || s.next(e(o.slice()));
1301
+ i[l] = p, w || (w = !0, a--), a || s.next(e(i.slice()));
1302
1302
  }, function() {
1303
- --i || s.complete();
1303
+ --o || s.complete();
1304
1304
  }));
1305
1305
  }, s);
1306
1306
  }, u = 0; u < r; u++)
@@ -1309,21 +1309,21 @@ function en(n, t, e) {
1309
1309
  };
1310
1310
  }
1311
1311
  function ve(n, t, e) {
1312
- n ? P(e, n, t) : t();
1312
+ n ? M(e, n, t) : t();
1313
1313
  }
1314
1314
  function tn(n, t) {
1315
- return F(function(e, s) {
1315
+ return j(function(e, s) {
1316
1316
  var r = 0;
1317
- e.subscribe(H(s, function(o) {
1318
- return n.call(t, o, r++) && s.next(o);
1317
+ e.subscribe(H(s, function(i) {
1318
+ return n.call(t, i, r++) && s.next(i);
1319
1319
  }));
1320
1320
  });
1321
1321
  }
1322
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 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) {
1325
+ var i = (t = Re(s)) !== null && t !== void 0 ? t : kt, o = (e = s[0]) !== null && e !== void 0 ? e : null, a = s[1] || 1 / 0;
1326
+ return j(function(c, u) {
1327
1327
  var l = [], v = !1, w = function(d) {
1328
1328
  var C = d.buffer, x = d.subs;
1329
1329
  x.unsubscribe(), V(l, d), u.next(C), v && p();
@@ -1335,12 +1335,12 @@ function nn(n) {
1335
1335
  buffer: C,
1336
1336
  subs: d
1337
1337
  };
1338
- l.push(x), P(d, o, function() {
1338
+ l.push(x), M(d, i, function() {
1339
1339
  return w(x);
1340
1340
  }, n);
1341
1341
  }
1342
1342
  };
1343
- i !== null && i >= 0 ? P(u, o, p, i, !0) : v = !0, p();
1343
+ o !== null && o >= 0 ? M(u, i, p, o, !0) : v = !0, p();
1344
1344
  var g = H(u, function(d) {
1345
1345
  var C, x, f = l.slice();
1346
1346
  try {
@@ -1348,8 +1348,8 @@ function nn(n) {
1348
1348
  var b = S.value, I = b.buffer;
1349
1349
  I.push(d), a <= I.length && w(b);
1350
1350
  }
1351
- } catch (M) {
1352
- C = { error: M };
1351
+ } catch (L) {
1352
+ C = { error: L };
1353
1353
  } finally {
1354
1354
  try {
1355
1355
  S && !S.done && (x = m.return) && x.call(m);
@@ -1367,12 +1367,12 @@ function nn(n) {
1367
1367
  c.subscribe(g);
1368
1368
  });
1369
1369
  }
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));
1370
+ function N(n, t) {
1371
+ return t === void 0 && (t = J), n = n ?? sn, j(function(e, s) {
1372
+ var r, i = !0;
1373
+ e.subscribe(H(s, function(o) {
1374
+ var a = t(o);
1375
+ (i || !n(r, a)) && (i = !1, r = a, s.next(o));
1376
1376
  }));
1377
1377
  });
1378
1378
  }
@@ -1380,7 +1380,7 @@ function sn(n, t) {
1380
1380
  return n === t;
1381
1381
  }
1382
1382
  function rn(n) {
1383
- return F(function(t, e) {
1383
+ return j(function(t, e) {
1384
1384
  try {
1385
1385
  t.subscribe(e);
1386
1386
  } finally {
@@ -1389,27 +1389,27 @@ function rn(n) {
1389
1389
  });
1390
1390
  }
1391
1391
  function on(n) {
1392
- return F(function(t, e) {
1392
+ return j(function(t, e) {
1393
1393
  Q(n).subscribe(H(e, function() {
1394
1394
  return e.complete();
1395
1395
  }, ae)), !e.closed && t.subscribe(e);
1396
1396
  });
1397
1397
  }
1398
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) => {
1399
+ const { endpoint: t, apiKey: e, payload: s, debugMode: r, customHeaders: i } = n, o = n.method ?? "POST";
1400
+ return new A((a) => {
1401
1401
  const c = new AbortController();
1402
1402
  let u, l = !1, v = !1;
1403
1403
  const w = {
1404
1404
  "Content-Type": "application/json",
1405
- ...o
1405
+ ...i
1406
1406
  };
1407
1407
  e && (w["X-API-KEY"] = e);
1408
1408
  const p = new URL(t);
1409
- return r && p.searchParams.set("is_debug", "true"), ke(p.toString(), {
1410
- method: i,
1409
+ return r && p.searchParams.set("is_debug", "true"), Oe(p.toString(), {
1410
+ method: o,
1411
1411
  headers: w,
1412
- body: i === "POST" && s ? JSON.stringify(s) : void 0,
1412
+ body: o === "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.
@@ -1430,7 +1430,7 @@ function ye(n) {
1430
1430
  d = null;
1431
1431
  }
1432
1432
  }
1433
- a.error(new A(g.status, g.statusText, d)), c.abort();
1433
+ a.error(new k(g.status, g.statusText, d)), c.abort();
1434
1434
  }
1435
1435
  },
1436
1436
  onmessage: (g) => {
@@ -1474,7 +1474,18 @@ const cn = 50;
1474
1474
  function ee(n, t) {
1475
1475
  return t?.customChannelId && n.searchParams.set("custom_channel_id", t.customChannelId), n;
1476
1476
  }
1477
- class Xn {
1477
+ async function un(n, t, e) {
1478
+ if (!n.body) return n.blob();
1479
+ const s = n.body.getReader(), r = [];
1480
+ let i = 0;
1481
+ for (e(0, t); ; ) {
1482
+ const { done: o, value: a } = await s.read();
1483
+ if (o) break;
1484
+ r.push(a.slice()), i += a.byteLength, e(i, t);
1485
+ }
1486
+ return new Blob(r, { type: n.headers.get("Content-Type") ?? "" });
1487
+ }
1488
+ class Yn {
1478
1489
  apiKey;
1479
1490
  endpoint;
1480
1491
  botProviderEndpoint;
@@ -1584,13 +1595,13 @@ class Xn {
1584
1595
  s.searchParams.set("custom_channel_id", t);
1585
1596
  const r = { ...this.customHeaders };
1586
1597
  this.apiKey && (r["X-API-KEY"] = this.apiKey);
1587
- const o = await fetch(s.toString(), { method: "GET", headers: r });
1588
- if (o.status === 404)
1598
+ const i = await fetch(s.toString(), { method: "GET", headers: r });
1599
+ if (i.status === 404)
1589
1600
  return null;
1590
- if (!o.ok)
1591
- throw new A(o.status, o.statusText, await o.text().catch(() => {
1601
+ if (!i.ok)
1602
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1592
1603
  }));
1593
- const i = await o.json(), a = i.data ?? i;
1604
+ const o = await i.json(), a = o.data ?? o;
1594
1605
  return {
1595
1606
  title: a.title ?? null,
1596
1607
  runState: a.runState ?? "IDLE",
@@ -1632,9 +1643,9 @@ class Xn {
1632
1643
  throw new Error("Unable to derive channel suspend endpoint. Please provide botProviderEndpoint in config.");
1633
1644
  const r = new URL(s);
1634
1645
  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 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(() => {
1646
+ const i = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1647
+ if (!(i.ok || i.status === 404))
1648
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1638
1649
  }));
1639
1650
  }
1640
1651
  deriveChannelEndpoint() {
@@ -1665,7 +1676,7 @@ class Xn {
1665
1676
  s.searchParams.set("custom_channel_id", t);
1666
1677
  const r = await fetch(s.toString(), { method: "DELETE", headers: this.apiHeaders() });
1667
1678
  if (!r.ok)
1668
- throw new A(r.status, r.statusText, await r.text().catch(() => {
1679
+ throw new k(r.status, r.statusText, await r.text().catch(() => {
1669
1680
  }));
1670
1681
  }
1671
1682
  deriveFeedbackEndpoint() {
@@ -1692,15 +1703,15 @@ class Xn {
1692
1703
  messageId: t.messageId,
1693
1704
  verdict: t.verdict,
1694
1705
  ...s ? { comment: s } : {}
1695
- }, o = await fetch(e, {
1706
+ }, i = await fetch(e, {
1696
1707
  method: "POST",
1697
1708
  headers: { ...this.apiHeaders(), "Content-Type": "application/json" },
1698
1709
  body: JSON.stringify(r)
1699
1710
  });
1700
- if (!o.ok)
1701
- throw new A(o.status, o.statusText, await o.text().catch(() => {
1711
+ if (!i.ok)
1712
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1702
1713
  }));
1703
- const i = await o.json(), a = i.data ?? i;
1714
+ const o = await i.json(), a = o.data ?? o;
1704
1715
  return { messageId: a.messageId, seq: a.seq };
1705
1716
  }
1706
1717
  runSse(t, e) {
@@ -1781,22 +1792,22 @@ class Xn {
1781
1792
  throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");
1782
1793
  const r = new FormData();
1783
1794
  r.append("file", t), r.append("customChannelId", e);
1784
- const o = {
1795
+ const i = {
1785
1796
  ...this.customHeaders
1786
1797
  };
1787
- this.apiKey && (o["X-API-KEY"] = this.apiKey);
1798
+ this.apiKey && (i["X-API-KEY"] = this.apiKey);
1788
1799
  try {
1789
- const i = await fetch(s, {
1800
+ const o = await fetch(s, {
1790
1801
  method: "POST",
1791
- headers: o,
1802
+ headers: i,
1792
1803
  body: r
1793
1804
  });
1794
- if (!i.ok)
1795
- throw new Error(`Upload failed: ${i.status} ${i.statusText}`);
1796
- const a = await i.json();
1805
+ if (!o.ok)
1806
+ throw new Error(`Upload failed: ${o.status} ${o.statusText}`);
1807
+ const a = await o.json();
1797
1808
  return this.debugMode && console.log("[AsgardServiceClient] File upload response:", a), a;
1798
- } catch (i) {
1799
- throw console.error("[AsgardServiceClient] File upload error:", i), i;
1809
+ } catch (o) {
1810
+ throw console.error("[AsgardServiceClient] File upload error:", o), o;
1800
1811
  }
1801
1812
  }
1802
1813
  /**
@@ -1807,14 +1818,14 @@ class Xn {
1807
1818
  const s = this.getBaseEndpoint();
1808
1819
  if (!s)
1809
1820
  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)}`, o = `${s}/channel-home/download?${r}`, i = {
1821
+ const r = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`, i = `${s}/channel-home/download?${r}`, o = {
1811
1822
  ...this.customHeaders
1812
1823
  };
1813
- this.apiKey && (i["X-API-KEY"] = this.apiKey);
1824
+ this.apiKey && (o["X-API-KEY"] = this.apiKey);
1814
1825
  try {
1815
- const a = await fetch(o, {
1826
+ const a = await fetch(i, {
1816
1827
  method: "GET",
1817
- headers: i
1828
+ headers: o
1818
1829
  });
1819
1830
  if (!a.ok)
1820
1831
  throw new Error(`Channel Home download failed: ${a.status} ${a.statusText}`);
@@ -1842,11 +1853,11 @@ class Xn {
1842
1853
  const r = ee(
1843
1854
  new URL(`${s}/sandbox/${encodeURIComponent(t)}/browser/open-url`),
1844
1855
  e
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(() => {
1856
+ ), i = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1857
+ if (!i.ok)
1858
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1848
1859
  }));
1849
- const i = await o.json(), a = i.data?.openURL ?? i.openURL;
1860
+ const o = await i.json(), a = o.data?.openURL ?? o.openURL;
1850
1861
  if (!a)
1851
1862
  throw new Error("Sandbox browser open-url response did not contain an openURL.");
1852
1863
  return a;
@@ -1875,11 +1886,11 @@ class Xn {
1875
1886
  const r = ee(
1876
1887
  new URL(`${s}/sandbox/${encodeURIComponent(t)}/browser/session`),
1877
1888
  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(() => {
1889
+ ), i = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1890
+ if (!i.ok)
1891
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1881
1892
  }));
1882
- const i = await o.json(), a = i.data?.wsUrl ?? i.wsUrl, c = i.data?.token ?? i.token;
1893
+ const o = await i.json(), a = o.data?.wsUrl ?? o.wsUrl, c = o.data?.token ?? o.token;
1883
1894
  if (!a || !c)
1884
1895
  throw new Error("Sandbox browser session response did not contain both wsUrl and token.");
1885
1896
  return { wsUrl: a, token: c };
@@ -1912,11 +1923,11 @@ class Xn {
1912
1923
  async sandboxFsList(t, e, s) {
1913
1924
  const r = this.sandboxFsUrl(t, "list", s);
1914
1925
  r.searchParams.set("path", e);
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(() => {
1926
+ const i = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1927
+ if (!i.ok)
1928
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1918
1929
  }));
1919
- const i = await o.json(), a = i.data ?? i;
1930
+ const o = await i.json(), a = o.data ?? o;
1920
1931
  return { entries: a.entries ?? [], truncated: a.truncated ?? !1 };
1921
1932
  }
1922
1933
  /**
@@ -1926,15 +1937,19 @@ class Xn {
1926
1937
  async sandboxFsRead(t, e, s) {
1927
1938
  const r = this.sandboxFsUrl(t, "file", s);
1928
1939
  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));
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(() => {
1940
+ const i = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1941
+ if (!i.ok)
1942
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1932
1943
  }));
1933
- const i = await o.blob(), a = o.headers.get("X-Total-Bytes");
1944
+ const o = i.headers.get("X-Total-Bytes"), a = s?.onProgress ? await un(
1945
+ i,
1946
+ o != null ? Number(o) : null,
1947
+ s.onProgress
1948
+ ) : await i.blob();
1934
1949
  return {
1935
- content: i,
1936
- totalBytes: a != null ? Number(a) : i.size,
1937
- truncated: o.headers.get("X-Truncated") === "true"
1950
+ content: a,
1951
+ totalBytes: o != null ? Number(o) : a.size,
1952
+ truncated: i.headers.get("X-Truncated") === "true"
1938
1953
  };
1939
1954
  }
1940
1955
  /**
@@ -1942,29 +1957,29 @@ class Xn {
1942
1957
  * 回應 `{ data: { bytesWritten } }`。
1943
1958
  */
1944
1959
  async sandboxFsWrite(t, e, s, r) {
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(), {
1960
+ const i = this.sandboxFsUrl(t, "file", r);
1961
+ i.searchParams.set("path", e), r?.mode != null && i.searchParams.set("mode", String(r.mode)), r?.createOnly && i.searchParams.set("create_only", "true");
1962
+ const o = new FormData();
1963
+ o.append("file", s instanceof Blob ? s : new Blob([s]));
1964
+ const a = await fetch(i.toString(), {
1950
1965
  method: "PUT",
1951
1966
  headers: this.apiHeaders(),
1952
- body: i,
1967
+ body: o,
1953
1968
  signal: r?.signal
1954
1969
  });
1955
1970
  if (!a.ok)
1956
- throw new A(a.status, a.statusText, await a.text().catch(() => {
1971
+ throw new k(a.status, a.statusText, await a.text().catch(() => {
1957
1972
  }));
1958
1973
  const c = await a.json();
1959
1974
  return { bytesWritten: (c.data ?? c).bytesWritten ?? 0 };
1960
1975
  }
1961
1976
  /** F-021 Cycle 2 — `sandbox://` fs mutation shared request helper (throws `HttpError` on non-OK). */
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() });
1977
+ async sandboxFsRequest(t, e, s, r, i) {
1978
+ const o = this.sandboxFsUrl(t, e, i);
1979
+ Object.entries(r).forEach(([c, u]) => o.searchParams.set(c, u));
1980
+ const a = await fetch(o.toString(), { method: s, headers: this.apiHeaders() });
1966
1981
  if (!a.ok)
1967
- throw new A(a.status, a.statusText, await a.text().catch(() => {
1982
+ throw new k(a.status, a.statusText, await a.text().catch(() => {
1968
1983
  }));
1969
1984
  return a.json().catch(() => null);
1970
1985
  }
@@ -1972,11 +1987,11 @@ class Xn {
1972
1987
  async sandboxFsStat(t, e, s) {
1973
1988
  const r = this.sandboxFsUrl(t, "stat", s);
1974
1989
  r.searchParams.set("path", e);
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(() => {
1990
+ const i = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1991
+ if (!i.ok)
1992
+ throw new k(i.status, i.statusText, await i.text().catch(() => {
1978
1993
  }));
1979
- const i = await o.json(), a = i.data ?? i;
1994
+ const o = await i.json(), a = o.data ?? o;
1980
1995
  return {
1981
1996
  exists: a.exists ?? !1,
1982
1997
  isDir: a.isDir ?? !1,
@@ -2000,15 +2015,15 @@ class Xn {
2000
2015
  }
2001
2016
  /** F-021 — copy a path (`POST fs/copy?src=&dst=[&overwrite]`) → bytes copied. */
2002
2017
  async sandboxFsCopy(t, e, s, r) {
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 };
2018
+ const i = { src: e, dst: s };
2019
+ r?.overwrite && (i.overwrite = "true");
2020
+ const o = await this.sandboxFsRequest(t, "copy", "POST", i, r);
2021
+ return { bytesCopied: (o?.data ?? o)?.bytesCopied ?? 0 };
2007
2022
  }
2008
2023
  /** F-021 — move / rename a path (`POST fs/move?src=&dst=[&overwrite]`). */
2009
2024
  async sandboxFsMove(t, e, s, r) {
2010
- const o = { src: e, dst: s };
2011
- r?.overwrite && (o.overwrite = "true"), await this.sandboxFsRequest(t, "move", "POST", o, r);
2025
+ const i = { src: e, dst: s };
2026
+ r?.overwrite && (i.overwrite = "true"), await this.sandboxFsRequest(t, "move", "POST", i, r);
2012
2027
  }
2013
2028
  /**
2014
2029
  * F-021 — watch a sandbox path for changes (`GET fs/watch?path=`, SSE). Each `event: change` frame is one
@@ -2017,27 +2032,27 @@ class Xn {
2017
2032
  */
2018
2033
  sandboxFsWatch(t, e, s) {
2019
2034
  const r = this.sandboxFsUrl(t, "watch", s);
2020
- return r.searchParams.set("path", e), new O((o) => {
2021
- const i = new AbortController();
2022
- return ke(r.toString(), {
2035
+ return r.searchParams.set("path", e), new A((i) => {
2036
+ const o = new AbortController();
2037
+ return Oe(r.toString(), {
2023
2038
  headers: this.apiHeaders(),
2024
- signal: i.signal,
2039
+ signal: o.signal,
2025
2040
  openWhenHidden: !0,
2026
2041
  onopen: async (a) => {
2027
2042
  if (!a.ok) {
2028
2043
  const c = await a.text().catch(() => {
2029
2044
  });
2030
- o.error(new A(a.status, a.statusText, c)), i.abort();
2045
+ i.error(new k(a.status, a.statusText, c)), o.abort();
2031
2046
  }
2032
2047
  },
2033
2048
  onmessage: (a) => {
2034
- a.event === "change" && o.next(JSON.parse(a.data));
2049
+ a.event === "change" && i.next(JSON.parse(a.data));
2035
2050
  },
2036
- onclose: () => o.complete(),
2051
+ onclose: () => i.complete(),
2037
2052
  onerror: (a) => {
2038
- throw o.error(a), i.abort(), a;
2053
+ throw i.error(a), o.abort(), a;
2039
2054
  }
2040
- }), () => i.abort();
2055
+ }), () => o.abort();
2041
2056
  });
2042
2057
  }
2043
2058
  /**
@@ -2056,9 +2071,9 @@ class Xn {
2056
2071
  return !t && this.endpoint && (t = this.endpoint.replace("/message/sse", "")), t ? t.replace(/\/+$/, "") : null;
2057
2072
  }
2058
2073
  }
2059
- const un = "", ln = /* @__PURE__ */ new Set(["", ".", ".."]);
2060
- function L(n, t) {
2061
- if (n === un) {
2074
+ const ln = "", dn = /* @__PURE__ */ new Set(["", ".", ".."]);
2075
+ function U(n, t) {
2076
+ if (n === ln) {
2062
2077
  if (t?.allowRoot)
2063
2078
  return n;
2064
2079
  throw new Error(
@@ -2069,15 +2084,15 @@ function L(n, t) {
2069
2084
  throw new Error(`SourceSet volume path must be relative, with no leading slash (the root is ""): "${n}".`);
2070
2085
  if (n.endsWith("/"))
2071
2086
  throw new Error(`SourceSet volume path must not end with a slash: "${n}".`);
2072
- if (n.split("/").some((e) => ln.has(e)))
2087
+ if (n.split("/").some((e) => dn.has(e)))
2073
2088
  throw new Error(`SourceSet volume path must not contain empty, "." or ".." segments: "${n}".`);
2074
2089
  return n;
2075
2090
  }
2076
- const Je = 1e3, dn = 1e4;
2091
+ const Je = 1e3, hn = 1e4;
2077
2092
  function we(n) {
2078
2093
  return Math.min(Math.max(1, Math.floor(n)), Je);
2079
2094
  }
2080
- class Yn {
2095
+ class zn {
2081
2096
  endpoint;
2082
2097
  apiKey;
2083
2098
  customHeaders;
@@ -2090,26 +2105,26 @@ class Yn {
2090
2105
  return this.apiKey && (t["X-API-KEY"] = this.apiKey), t;
2091
2106
  }
2092
2107
  /** Issue one volume request, turning any non-2xx into {@link HttpError} (409 included, see R8). */
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 });
2108
+ async request(t, e, s, r, i) {
2109
+ const o = new URL(`${this.endpoint}/${t}`);
2110
+ Object.entries(s).forEach(([c, u]) => o.searchParams.set(c, u));
2111
+ const a = await fetch(o.toString(), { method: e, headers: this.headers(), body: r, signal: i });
2097
2112
  if (!a.ok)
2098
- throw new A(a.status, a.statusText, await a.text().catch(() => {
2113
+ throw new k(a.status, a.statusText, await a.text().catch(() => {
2099
2114
  }));
2100
2115
  return a;
2101
2116
  }
2102
2117
  /** One page of a directory (`GET volume/list?path=[&page&page_size]`). `path` may be the root `''`. */
2103
2118
  async list(t, e) {
2104
- const s = { path: L(t, { allowRoot: !0 }) };
2119
+ const s = { path: U(t, { allowRoot: !0 }) };
2105
2120
  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;
2121
+ const i = await (await this.request("list", "GET", s)).json(), o = i.data ?? i;
2107
2122
  return {
2108
- entries: i.entries ?? [],
2123
+ entries: o.entries ?? [],
2109
2124
  // Reported as `null` rather than invented. An earlier version synthesized
2110
2125
  // `{ total: entries.length }` here to keep `listAll` terminating, which worked — and made a
2111
2126
  // relay that omits `paging` report the first 1000 of 3000 files as the whole directory.
2112
- paging: i.paging ?? o.paging ?? null
2127
+ paging: o.paging ?? i.paging ?? null
2113
2128
  };
2114
2129
  }
2115
2130
  /**
@@ -2119,31 +2134,31 @@ class Yn {
2119
2134
  * directory that looks whole is the failure this exists to prevent.
2120
2135
  */
2121
2136
  async listAll(t, e) {
2122
- const s = we(e?.pageSize ?? Je), r = e?.maxEntries ?? dn, o = [];
2123
- let i = 0, a = !0, c = 0;
2137
+ const s = we(e?.pageSize ?? Je), r = e?.maxEntries ?? hn, i = [];
2138
+ let o = 0, a = !0, c = 0;
2124
2139
  for (; ; ) {
2125
2140
  const u = await this.list(t, { page: c, pageSize: s }), l = u.paging;
2126
2141
  if (l && l.index !== c) {
2127
- i = l.total, a = !1;
2142
+ o = l.total, a = !1;
2128
2143
  break;
2129
2144
  }
2130
- if (o.push(...u.entries), !l) {
2145
+ if (i.push(...u.entries), !l) {
2131
2146
  a = u.entries.length < s;
2132
2147
  break;
2133
2148
  }
2134
- if (i = l.total, o.length >= i)
2149
+ if (o = l.total, i.length >= o)
2135
2150
  break;
2136
- if (o.length >= r || u.entries.length === 0) {
2151
+ if (i.length >= r || u.entries.length === 0) {
2137
2152
  a = !1;
2138
2153
  break;
2139
2154
  }
2140
2155
  c += 1;
2141
2156
  }
2142
- return { entries: o, total: i, complete: a };
2157
+ return { entries: i, total: o, complete: a };
2143
2158
  }
2144
2159
  /** Stat a path (`GET volume/stat?path=`). A missing path is 200 with `exists: false`, not a 404. */
2145
2160
  async stat(t) {
2146
- const s = await (await this.request("stat", "GET", { path: L(t) })).json(), r = s.data ?? s;
2161
+ const s = await (await this.request("stat", "GET", { path: U(t) })).json(), r = s.data ?? s;
2147
2162
  return {
2148
2163
  exists: r.exists ?? !1,
2149
2164
  isDir: r.isDir ?? !1,
@@ -2155,12 +2170,12 @@ class Yn {
2155
2170
  }
2156
2171
  /** Read a file (`GET volume/file?path=[&offset_bytes&limit_bytes]`) as raw bytes. */
2157
2172
  async read(t, e) {
2158
- const s = { path: L(t) };
2173
+ const s = { path: U(t) };
2159
2174
  e?.offsetBytes != null && (s.offset_bytes = String(e.offsetBytes)), e?.limitBytes != null && (s.limit_bytes = String(e.limitBytes));
2160
- const r = await this.request("file", "GET", s), o = await r.blob(), i = r.headers.get("X-Total-Bytes");
2175
+ const r = await this.request("file", "GET", s), i = await r.blob(), o = r.headers.get("X-Total-Bytes");
2161
2176
  return {
2162
- content: o,
2163
- totalBytes: i != null ? Number(i) : o.size,
2177
+ content: i,
2178
+ totalBytes: o != null ? Number(o) : i.size,
2164
2179
  truncated: r.headers.get("X-Truncated") === "true"
2165
2180
  };
2166
2181
  }
@@ -2169,65 +2184,65 @@ class Yn {
2169
2184
  * With `createOnly`, an existing path is a 409 rather than an overwrite.
2170
2185
  */
2171
2186
  async write(t, e, s) {
2172
- const r = { path: L(t) };
2187
+ const r = { path: U(t) };
2173
2188
  s?.mode != null && (r.mode = String(s.mode)), s?.createOnly && (r.create_only = "true");
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();
2189
+ const i = new FormData();
2190
+ i.append("file", e instanceof Blob ? e : new Blob([e]));
2191
+ const a = await (await this.request("file", "PUT", r, i, s?.signal)).json();
2177
2192
  return { bytesWritten: (a.data ?? a).bytesWritten ?? 0 };
2178
2193
  }
2179
2194
  /** Create a directory and any missing parents (`POST volume/mkdir?path=`). */
2180
2195
  async mkdir(t, e) {
2181
- await this.request("mkdir", "POST", { path: L(t) }, void 0, e?.signal);
2196
+ await this.request("mkdir", "POST", { path: U(t) }, void 0, e?.signal);
2182
2197
  }
2183
2198
  /** Delete a file or empty directory (`DELETE volume/item?path=`). */
2184
2199
  async remove(t) {
2185
- await this.request("item", "DELETE", { path: L(t) });
2200
+ await this.request("item", "DELETE", { path: U(t) });
2186
2201
  }
2187
2202
  /** Recursively delete a directory (`DELETE volume/all?path=`). The volume root is not a valid target. */
2188
2203
  async removeAll(t) {
2189
- await this.request("all", "DELETE", { path: L(t) });
2204
+ await this.request("all", "DELETE", { path: U(t) });
2190
2205
  }
2191
2206
  /** Copy a file or directory tree (`POST volume/copy?src=&dst=[&overwrite]`). */
2192
2207
  async copy(t, e, s) {
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 };
2208
+ const r = this.copyMoveQuery(t, e, s), o = await (await this.request("copy", "POST", r)).json();
2209
+ return { bytesCopied: (o.data ?? o).bytesCopied ?? 0 };
2195
2210
  }
2196
2211
  /** Move or rename (`POST volume/move?src=&dst=[&overwrite]`) — also how the UI renames. */
2197
2212
  async move(t, e, s) {
2198
2213
  await this.request("move", "POST", this.copyMoveQuery(t, e, s));
2199
2214
  }
2200
2215
  copyMoveQuery(t, e, s) {
2201
- const r = { src: L(t), dst: L(e) };
2216
+ const r = { src: U(t), dst: U(e) };
2202
2217
  return s?.overwrite && (r.overwrite = "true"), r;
2203
2218
  }
2204
2219
  }
2205
2220
  const T = [];
2206
2221
  for (let n = 0; n < 256; ++n)
2207
2222
  T.push((n + 256).toString(16).slice(1));
2208
- function hn(n, t = 0) {
2223
+ function fn(n, t = 0) {
2209
2224
  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
2225
  }
2211
2226
  let te;
2212
- const fn = new Uint8Array(16);
2213
- function pn() {
2227
+ const pn = new Uint8Array(16);
2228
+ function gn() {
2214
2229
  if (!te) {
2215
2230
  if (typeof crypto > "u" || !crypto.getRandomValues)
2216
2231
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2217
2232
  te = crypto.getRandomValues.bind(crypto);
2218
2233
  }
2219
- return te(fn);
2234
+ return te(pn);
2220
2235
  }
2221
- const gn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ee = { randomUUID: gn };
2222
- function mn(n, t, e) {
2236
+ const mn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ee = { randomUUID: mn };
2237
+ function bn(n, t, e) {
2223
2238
  n = n || {};
2224
- const s = n.random ?? n.rng?.() ?? pn();
2239
+ const s = n.random ?? n.rng?.() ?? gn();
2225
2240
  if (s.length < 16)
2226
2241
  throw new Error("Random bytes length must be >= 16");
2227
- return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, hn(s);
2242
+ return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, fn(s);
2228
2243
  }
2229
2244
  function Qe(n, t, e) {
2230
- return Ee.randomUUID && !n ? Ee.randomUUID() : mn(n);
2245
+ return Ee.randomUUID && !n ? Ee.randomUUID() : bn(n);
2231
2246
  }
2232
2247
  class y {
2233
2248
  messages = null;
@@ -2375,8 +2390,8 @@ class y {
2375
2390
  if (e.parentToolUseId) return this;
2376
2391
  const s = this.messages?.get(e.messageId);
2377
2392
  if (this.isTerminalBot(s)) return this;
2378
- const r = s?.type === "bot" ? s : void 0, o = new Map(this.messages);
2379
- return o.set(e.messageId, {
2393
+ const r = s?.type === "bot" ? s : void 0, i = new Map(this.messages);
2394
+ return i.set(e.messageId, {
2380
2395
  type: "bot",
2381
2396
  eventType: h.MESSAGE_DELTA,
2382
2397
  isTyping: !0,
@@ -2386,12 +2401,12 @@ class y {
2386
2401
  time: /* @__PURE__ */ new Date(),
2387
2402
  traceId: t.traceId ?? r?.traceId,
2388
2403
  raw: r?.raw ?? ""
2389
- }), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2404
+ }), new y({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2390
2405
  }
2391
2406
  onMessageComplete(t) {
2392
2407
  const e = t.fact.messageComplete.message;
2393
2408
  if (e.parentToolUseId) return this;
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;
2409
+ const s = new Map(this.messages), r = s.get(e.messageId), i = r?.type === "bot" ? r : void 0, o = this.pendingFeedback?.get(e.messageId), a = o ?? i?.feedback;
2395
2410
  s.set(e.messageId, {
2396
2411
  type: "bot",
2397
2412
  eventType: h.MESSAGE_COMPLETE,
@@ -2401,11 +2416,11 @@ class y {
2401
2416
  message: e,
2402
2417
  ...a ? { feedback: a } : {},
2403
2418
  time: /* @__PURE__ */ new Date(),
2404
- traceId: t.traceId ?? o?.traceId,
2419
+ traceId: t.traceId ?? i?.traceId,
2405
2420
  raw: JSON.stringify(t)
2406
2421
  });
2407
2422
  let c = this.pendingFeedback;
2408
- return i && (c = new Map(this.pendingFeedback), c.delete(e.messageId)), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: c });
2423
+ return o && (c = new Map(this.pendingFeedback), c.delete(e.messageId)), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: c });
2409
2424
  }
2410
2425
  /**
2411
2426
  * `asgard.message.feedback` (F-033): fold a rating into the reply it targets. The server is
@@ -2430,8 +2445,8 @@ class y {
2430
2445
  applyFeedback(t, e) {
2431
2446
  const s = this.messages?.get(t);
2432
2447
  if (s?.type === "bot") {
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 });
2448
+ const i = new Map(this.messages), o = { ...s, feedback: e };
2449
+ return i.set(t, o), new y({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2435
2450
  }
2436
2451
  const r = new Map(this.pendingFeedback);
2437
2452
  return r.set(t, e), new y({ messages: this.messages, pendingConsent: this.pendingConsent, pendingFeedback: r });
@@ -2455,7 +2470,7 @@ class y {
2455
2470
  if (e.parentToolUseId) return this;
2456
2471
  const s = this.messages?.get(e.messageId);
2457
2472
  if (this.isTerminalThinking(s)) return this;
2458
- const r = s?.type === "thinking" ? s : void 0, o = new Map(this.messages), i = {
2473
+ const r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), o = {
2459
2474
  type: "thinking",
2460
2475
  messageId: e.messageId,
2461
2476
  text: `${r?.text ?? ""}${e.text}`,
@@ -2463,12 +2478,12 @@ class y {
2463
2478
  time: r?.time ?? /* @__PURE__ */ new Date(),
2464
2479
  traceId: t.traceId ?? r?.traceId
2465
2480
  };
2466
- return o.set(e.messageId, i), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2481
+ return i.set(e.messageId, o), new y({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2467
2482
  }
2468
2483
  onThinkingComplete(t) {
2469
2484
  const e = t.fact.messageThinkingComplete.message;
2470
2485
  if (e.parentToolUseId) return this;
2471
- const s = this.messages?.get(e.messageId), r = s?.type === "thinking" ? s : void 0, o = new Map(this.messages), i = {
2486
+ const s = this.messages?.get(e.messageId), r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), o = {
2472
2487
  type: "thinking",
2473
2488
  messageId: e.messageId,
2474
2489
  // Self-sufficient (F-011): the complete frame carries the full reasoning, so a complete-only
@@ -2478,7 +2493,7 @@ class y {
2478
2493
  time: r?.time ?? /* @__PURE__ */ new Date(),
2479
2494
  traceId: t.traceId ?? r?.traceId
2480
2495
  };
2481
- return o.set(e.messageId, i), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2496
+ return i.set(e.messageId, o), new y({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2482
2497
  }
2483
2498
  onCanvasStart(t) {
2484
2499
  const e = t.fact.messageCanvasStart.message;
@@ -2499,7 +2514,7 @@ class y {
2499
2514
  if (e.parentToolUseId) return this;
2500
2515
  const s = this.messages?.get(e.messageId);
2501
2516
  if (this.isTerminalCanvas(s)) return this;
2502
- const r = s?.type === "canvas" ? s : void 0, o = new Map(this.messages), i = {
2517
+ const r = s?.type === "canvas" ? s : void 0, i = new Map(this.messages), o = {
2503
2518
  type: "canvas",
2504
2519
  messageId: e.messageId,
2505
2520
  // Deltas are incremental, exactly like a text delta.
@@ -2509,18 +2524,18 @@ class y {
2509
2524
  time: r?.time ?? /* @__PURE__ */ new Date(),
2510
2525
  traceId: t.traceId ?? r?.traceId
2511
2526
  };
2512
- return o.set(e.messageId, i), new y({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2527
+ return i.set(e.messageId, o), new y({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2513
2528
  }
2514
2529
  onCanvasComplete(t) {
2515
2530
  const e = t.fact.messageCanvasComplete.message;
2516
2531
  if (e.parentToolUseId) return this;
2517
- const s = e.template?.type === Oe.CANVAS ? e.template : void 0, r = s?.canvas?.html;
2532
+ const s = e.template?.type === Ae.CANVAS ? e.template : void 0, r = s?.canvas?.html;
2518
2533
  if (!r) {
2519
2534
  if (!this.messages?.has(e.messageId)) return this;
2520
2535
  const u = new Map(this.messages);
2521
2536
  return u.delete(e.messageId), new y({ messages: u, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2522
2537
  }
2523
- const o = this.messages?.get(e.messageId), i = o?.type === "canvas" ? o : void 0, a = new Map(this.messages), c = {
2538
+ const i = this.messages?.get(e.messageId), o = i?.type === "canvas" ? i : void 0, a = new Map(this.messages), c = {
2524
2539
  type: "canvas",
2525
2540
  messageId: e.messageId,
2526
2541
  // **Replace, never append.** This fragment is authoritative, and a rejoin replays only the
@@ -2528,15 +2543,15 @@ class y {
2528
2543
  html: r,
2529
2544
  title: s?.title,
2530
2545
  isDrawing: !1,
2531
- time: i?.time ?? /* @__PURE__ */ new Date(),
2532
- traceId: t.traceId ?? i?.traceId
2546
+ time: o?.time ?? /* @__PURE__ */ new Date(),
2547
+ traceId: t.traceId ?? o?.traceId
2533
2548
  };
2534
2549
  return a.set(e.messageId, c), new y({ messages: a, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2535
2550
  }
2536
2551
  onMessageUser(t) {
2537
2552
  const e = t.fact.messageUser;
2538
2553
  if ((this.messages?.get(e.messageId) ?? (e.customMessageId ? this.messages?.get(e.customMessageId) : void 0))?.type === "user") return this;
2539
- const r = new Map(this.messages), o = {
2554
+ const r = new Map(this.messages), i = {
2540
2555
  type: "user",
2541
2556
  messageId: e.messageId,
2542
2557
  text: e.text,
@@ -2547,7 +2562,7 @@ class y {
2547
2562
  time: /* @__PURE__ */ new Date(),
2548
2563
  traceId: t.traceId
2549
2564
  };
2550
- return r.set(e.messageId, o), new y({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2565
+ return r.set(e.messageId, i), new y({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2551
2566
  }
2552
2567
  onMessageError(t) {
2553
2568
  const e = Qe(), s = t.fact.runError.error, r = new Map(this.messages);
@@ -2563,7 +2578,7 @@ class y {
2563
2578
  onToolCallStart(t) {
2564
2579
  const e = t.fact.toolCallStart, s = new Map(this.messages), r = `${e.processId}-${e.callSeq}`;
2565
2580
  if (this.isTerminalToolCall(this.messages?.get(r))) return this;
2566
- const o = {
2581
+ const i = {
2567
2582
  type: "tool-call",
2568
2583
  eventType: h.TOOL_CALL_START,
2569
2584
  messageId: r,
@@ -2579,23 +2594,23 @@ class y {
2579
2594
  time: /* @__PURE__ */ new Date(),
2580
2595
  traceId: t.traceId
2581
2596
  };
2582
- return s.set(r, o), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2597
+ return s.set(r, i), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2583
2598
  }
2584
2599
  onToolCallComplete(t) {
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,
2600
+ const e = t.fact.toolCallComplete, s = new Map(this.messages), r = `${e.processId}-${e.callSeq}`, i = s.get(r);
2601
+ if (i?.type === "tool-call") {
2602
+ const o = {
2603
+ ...i,
2589
2604
  eventType: h.TOOL_CALL_COMPLETE,
2590
2605
  result: e.toolCallResult,
2591
2606
  isError: e.isError,
2592
2607
  sidecar: e.toolUseResultSidecar,
2593
2608
  isComplete: !0,
2594
- traceId: t.traceId ?? o.traceId
2609
+ traceId: t.traceId ?? i.traceId
2595
2610
  };
2596
- s.set(r, i);
2611
+ s.set(r, o);
2597
2612
  } else {
2598
- const i = {
2613
+ const o = {
2599
2614
  type: "tool-call",
2600
2615
  eventType: h.TOOL_CALL_COMPLETE,
2601
2616
  messageId: r,
@@ -2614,7 +2629,7 @@ class y {
2614
2629
  time: /* @__PURE__ */ new Date(),
2615
2630
  traceId: t.traceId
2616
2631
  };
2617
- s.set(r, i);
2632
+ s.set(r, o);
2618
2633
  }
2619
2634
  return new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2620
2635
  }
@@ -2627,7 +2642,7 @@ class y {
2627
2642
  });
2628
2643
  }
2629
2644
  onSubagentStart(t) {
2630
- const e = t.fact.subagentStart, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:start`, o = {
2645
+ const e = t.fact.subagentStart, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:start`, i = {
2631
2646
  type: "subagent",
2632
2647
  messageId: r,
2633
2648
  kind: "start",
@@ -2638,10 +2653,10 @@ class y {
2638
2653
  time: /* @__PURE__ */ new Date(),
2639
2654
  traceId: t.traceId
2640
2655
  };
2641
- return s.delete(r), s.set(r, o), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2656
+ return s.delete(r), s.set(r, i), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2642
2657
  }
2643
2658
  onSubagentComplete(t) {
2644
- const e = t.fact.subagentComplete, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:complete`, o = {
2659
+ const e = t.fact.subagentComplete, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:complete`, i = {
2645
2660
  type: "subagent",
2646
2661
  messageId: r,
2647
2662
  kind: "complete",
@@ -2653,36 +2668,36 @@ class y {
2653
2668
  time: /* @__PURE__ */ new Date(),
2654
2669
  traceId: t.traceId
2655
2670
  };
2656
- return s.delete(r), s.set(r, o), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2671
+ return s.delete(r), s.set(r, i), new y({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2657
2672
  }
2658
2673
  }
2659
- const bn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2660
- function Sn(n) {
2661
- return n.toolsetName === "" && bn.has(n.toolName);
2674
+ const Sn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
2675
+ function vn(n) {
2676
+ return n.toolsetName === "" && Sn.has(n.toolName);
2662
2677
  }
2663
2678
  function Ie(n) {
2664
2679
  return typeof n == "object" && n !== null ? n : void 0;
2665
2680
  }
2666
- function U(n) {
2681
+ function F(n) {
2667
2682
  return typeof n == "string" ? n : void 0;
2668
2683
  }
2669
- function vn(n) {
2684
+ function yn(n) {
2670
2685
  const t = [], e = /* @__PURE__ */ new Map();
2671
2686
  for (const s of n) {
2672
- const r = s.parameter ?? {}, o = s.sidecar ?? {};
2687
+ const r = s.parameter ?? {}, i = s.sidecar ?? {};
2673
2688
  if (s.toolName === "TaskCreate") {
2674
- const i = Ie(o.task), a = U(i?.id);
2689
+ const o = Ie(i.task), a = F(o?.id);
2675
2690
  if (!a) continue;
2676
2691
  e.has(a) || t.push(a), e.set(a, {
2677
2692
  id: a,
2678
- subject: U(r.subject) || U(i?.subject) || "",
2679
- activeForm: U(r.activeForm),
2680
- description: U(r.description),
2693
+ subject: F(r.subject) || F(o?.subject) || "",
2694
+ activeForm: F(r.activeForm),
2695
+ description: F(r.description),
2681
2696
  status: e.get(a)?.status ?? "pending"
2682
2697
  // initial status = pending (keep existing on repeat)
2683
2698
  });
2684
2699
  } else if (s.toolName === "TaskUpdate") {
2685
- const i = Ie(o.statusChange), a = U(r.taskId) || U(o.taskId), c = U(i?.to) || U(r.status);
2700
+ const o = Ie(i.statusChange), a = F(r.taskId) || F(i.taskId), c = F(o?.to) || F(r.status);
2686
2701
  if (!a || !c) continue;
2687
2702
  const u = e.get(a);
2688
2703
  u && e.set(a, { ...u, status: c });
@@ -2690,72 +2705,72 @@ function vn(n) {
2690
2705
  }
2691
2706
  return t.map((s) => e.get(s));
2692
2707
  }
2693
- function yn(n) {
2708
+ function wn(n) {
2694
2709
  return n.toolsetName === "" && n.toolName === "Agent";
2695
2710
  }
2696
- function wn(n) {
2711
+ function En(n) {
2697
2712
  return !!n;
2698
2713
  }
2699
2714
  function Te(n) {
2700
2715
  n.status !== "running" && (n.status = "running", n.summary = void 0);
2701
2716
  }
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) {
2717
+ function In(n) {
2718
+ 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));
2719
+ for (const i of n)
2720
+ switch (i.kind) {
2706
2721
  case "agentStart": {
2707
- const i = r(o.toolUseId);
2708
- o.description && !i.description && (i.description = o.description);
2722
+ const o = r(i.toolUseId);
2723
+ i.description && !o.description && (o.description = i.description);
2709
2724
  break;
2710
2725
  }
2711
2726
  case "subagentStart": {
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);
2727
+ const o = r(i.parentToolUseId);
2728
+ o.agentId = i.agentId ?? o.agentId, o.subagentType = i.subagentType ?? o.subagentType, o.description = i.description ?? o.description, Te(o);
2714
2729
  break;
2715
2730
  }
2716
2731
  case "toolStart": {
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,
2732
+ Te(r(i.parentToolUseId)), s.get(i.parentToolUseId).set(i.toolUseId, {
2733
+ toolsetName: i.toolsetName,
2734
+ toolName: i.toolName,
2735
+ parameter: i.parameter ?? {},
2736
+ reason: i.reason,
2722
2737
  status: "running"
2723
2738
  });
2724
2739
  break;
2725
2740
  }
2726
2741
  case "toolComplete": {
2727
- const i = s.get(o.parentToolUseId)?.get(o.toolUseId);
2728
- if (!i) break;
2729
- i.status = o.isError ? "error" : "completed", o.result !== void 0 && (i.result = o.result), o.sidecar !== void 0 && (i.sidecar = o.sidecar);
2742
+ const o = s.get(i.parentToolUseId)?.get(i.toolUseId);
2743
+ if (!o) break;
2744
+ o.status = i.isError ? "error" : "completed", i.result !== void 0 && (o.result = i.result), i.sidecar !== void 0 && (o.sidecar = i.sidecar);
2730
2745
  break;
2731
2746
  }
2732
2747
  case "subagentComplete": {
2733
- const i = r(o.parentToolUseId);
2734
- i.status = o.status, i.summary = o.summary;
2748
+ const o = r(i.parentToolUseId);
2749
+ o.status = i.status, o.summary = i.summary;
2735
2750
  break;
2736
2751
  }
2737
2752
  }
2738
- return t.map((o) => ({
2739
- parentToolUseId: o,
2740
- ...e.get(o),
2741
- tools: Array.from(s.get(o).values())
2753
+ return t.map((i) => ({
2754
+ parentToolUseId: i,
2755
+ ...e.get(i),
2756
+ tools: Array.from(s.get(i).values())
2742
2757
  }));
2743
2758
  }
2744
- function In(n) {
2759
+ function Tn(n) {
2745
2760
  return typeof n == "string" ? n : void 0;
2746
2761
  }
2747
- function Tn(n) {
2762
+ function Cn(n) {
2748
2763
  const t = [];
2749
2764
  for (const e of n) {
2750
- if (e.type === "tool-call" && yn(e)) {
2765
+ if (e.type === "tool-call" && wn(e)) {
2751
2766
  t.push({
2752
2767
  kind: "agentStart",
2753
2768
  toolUseId: e.toolUseId ?? e.messageId,
2754
- description: In(e.parameter.description)
2769
+ description: Tn(e.parameter.description)
2755
2770
  });
2756
2771
  continue;
2757
2772
  }
2758
- if (e.type === "tool-call" && wn(e.parentToolUseId)) {
2773
+ if (e.type === "tool-call" && En(e.parentToolUseId)) {
2759
2774
  const s = e.toolUseId ?? e.messageId;
2760
2775
  t.push({
2761
2776
  kind: "toolStart",
@@ -2794,14 +2809,14 @@ function Tn(n) {
2794
2809
  }
2795
2810
  return t;
2796
2811
  }
2797
- function Cn(n) {
2812
+ function xn(n) {
2798
2813
  const t = Array.from(n.messages?.values() ?? []).filter(
2799
- (e) => e.type === "tool-call" && e.isComplete && Sn(e)
2814
+ (e) => e.type === "tool-call" && e.isComplete && vn(e)
2800
2815
  );
2801
- return vn(t);
2816
+ return yn(t);
2802
2817
  }
2803
- function xn(n) {
2804
- return En(Tn(Array.from(n.messages?.values() ?? [])));
2818
+ function kn(n) {
2819
+ return In(Cn(Array.from(n.messages?.values() ?? [])));
2805
2820
  }
2806
2821
  function An(n, t) {
2807
2822
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, s) => {
@@ -2817,16 +2832,16 @@ function On(n, t) {
2817
2832
  e.result === r.result && e.sidecar === r.sidecar;
2818
2833
  });
2819
2834
  }
2820
- function kn(n, t) {
2835
+ function _n(n, t) {
2821
2836
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, s) => {
2822
2837
  const r = t[s];
2823
2838
  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);
2824
2839
  });
2825
2840
  }
2826
- function _n(n) {
2827
- const t = new R([]), e = new R([]), s = new D();
2828
- return s.add(n.pipe(z(Cn), j(An)).subscribe(t)), s.add(
2829
- n.pipe(z(xn), j(kn)).subscribe(e)
2841
+ function Pn(n) {
2842
+ const t = new P([]), e = new P([]), s = new D();
2843
+ return s.add(n.pipe(z(xn), N(An)).subscribe(t)), s.add(
2844
+ n.pipe(z(kn), N(_n)).subscribe(e)
2830
2845
  ), {
2831
2846
  tasks$: t.asObservable(),
2832
2847
  subagents$: e.asObservable(),
@@ -2842,8 +2857,8 @@ function Ce(n) {
2842
2857
  (e, s) => (e.sandboxBlueprintName || e.sandboxName).localeCompare(s.sandboxBlueprintName || s.sandboxName)
2843
2858
  );
2844
2859
  }
2845
- const ne = { kind: null, stopPhase: "idle" }, Pn = 1e4;
2846
- function Mn(n, t) {
2860
+ const ne = { kind: null, stopPhase: "idle" }, Mn = 1e4;
2861
+ function Ln(n, t) {
2847
2862
  return n.kind === t.kind && n.stopPhase === t.stopPhase && n.requestId === t.requestId;
2848
2863
  }
2849
2864
  class q {
@@ -2860,6 +2875,11 @@ class q {
2860
2875
  promptSuggestionSubject;
2861
2876
  sandboxPhaseSubject;
2862
2877
  launchedSandboxesSubject;
2878
+ sandboxWakeSubject;
2879
+ // The one wake in flight (F-038): set when a nudge is accepted, cleared once the metadata re-fetch after it
2880
+ // has settled. Resolves `true` when the nudge turn ended normally (and metadata was re-fetched), `false`
2881
+ // when it was refused or failed. Every entry point joins this instead of sending a nudge of its own.
2882
+ wakeInFlight;
2863
2883
  // Sandboxes hinted live by an `asgard.sandbox.launch` frame but not yet confirmed by metadata (F-019).
2864
2884
  // Never merged into the live list directly — cleared once metadata confirms (or held until it does).
2865
2885
  pendingLaunches = [];
@@ -2884,6 +2904,12 @@ class q {
2884
2904
  launchedSandboxes$;
2885
2905
  /** Reactive run identity + stop lifecycle store (F-023): who holds the connection, and is a stop pending. */
2886
2906
  runStatus$;
2907
+ /**
2908
+ * Reactive sandbox-wake store (F-038): the channel's **only** record of "waking / last wake failed". The
2909
+ * File Explorer's wake button, the download card and any later entry point all read this one, so a wake
2910
+ * started from one of them shows on the others at once. Per-slice; replay-safe.
2911
+ */
2912
+ sandboxWake$;
2887
2913
  currentUserMessageId;
2888
2914
  // The most-recently-sent user message id. Unlike currentUserMessageId (which
2889
2915
  // is cleared once a traceId is attached), this is kept across the SSE
@@ -2906,9 +2932,9 @@ class q {
2906
2932
  throw new Error("client must be required");
2907
2933
  if (!t.customChannelId)
2908
2934
  throw new Error("customChannelId must be required");
2909
- 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(
2935
+ this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new P(!1), this.runStatusSubject = new P(ne), this.conversation$ = new P(t.conversation), this.channelTitleSubject = new P(t.channelTitle ?? null), this.promptSuggestionSubject = new P(null), this.sandboxPhaseSubject = new P("idle"), this.launchedSandboxesSubject = new P(
2910
2936
  Ce(t.launchedSandboxes ?? [])
2911
- ), 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;
2937
+ ), this.sandboxWakeSubject = new P({ phase: "idle" }), this.derivedStores = Pn(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(N()), this.promptSuggestion$ = this.promptSuggestionSubject.pipe(N()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(N()), this.launchedSandboxes$ = this.launchedSandboxesSubject.pipe(N()), this.runStatus$ = this.runStatusSubject.pipe(N(Ln)), this.sandboxWake$ = this.sandboxWakeSubject.pipe(N((e, s) => e.phase === s.phase)), this.statesObserver = t.statesObserver;
2912
2938
  }
2913
2939
  /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2914
2940
  getTasks() {
@@ -2946,6 +2972,10 @@ class q {
2946
2972
  getRunStatus() {
2947
2973
  return this.runStatusSubject.value;
2948
2974
  }
2975
+ /** Current sandbox-wake snapshot (F-038) — for framework-agnostic `getSnapshot()` bridging. */
2976
+ getSandboxWake() {
2977
+ return this.sandboxWakeSubject.value;
2978
+ }
2949
2979
  /** Names hinted by `sandbox.launch` but not yet confirmed live by metadata (F-019) — "starting" placeholders. */
2950
2980
  getPendingLaunches() {
2951
2981
  return this.pendingLaunches;
@@ -3002,11 +3032,11 @@ class q {
3002
3032
  * stop-generation must not fire on it (F-023 AC8).
3003
3033
  */
3004
3034
  static async open(t, e, s, r) {
3005
- const o = new q(t);
3035
+ const i = new q(t);
3006
3036
  try {
3007
- return o.subscribe(), r?.(o), await o.openChannel(e, s), o;
3008
- } catch (i) {
3009
- throw o.close(), i;
3037
+ return i.subscribe(), r?.(i), await i.openChannel(e, s), i;
3038
+ } catch (o) {
3039
+ throw i.close(), o;
3010
3040
  }
3011
3041
  }
3012
3042
  /**
@@ -3045,8 +3075,8 @@ class q {
3045
3075
  const r = new q(t);
3046
3076
  try {
3047
3077
  return r.subscribe(), s?.(r), await r.rejoinChannel(e), r;
3048
- } catch (o) {
3049
- throw r.close(), o;
3078
+ } catch (i) {
3079
+ throw r.close(), i;
3050
3080
  }
3051
3081
  }
3052
3082
  subscribe() {
@@ -3067,8 +3097,8 @@ class q {
3067
3097
  e,
3068
3098
  s,
3069
3099
  r,
3070
- o,
3071
3100
  i,
3101
+ o,
3072
3102
  a,
3073
3103
  c,
3074
3104
  u
@@ -3077,8 +3107,8 @@ class q {
3077
3107
  conversation: e,
3078
3108
  tasks: s,
3079
3109
  subagents: r,
3080
- channelTitle: o,
3081
- promptSuggestion: i,
3110
+ channelTitle: i,
3111
+ promptSuggestion: o,
3082
3112
  sandboxPhase: a,
3083
3113
  launchedSandboxes: c,
3084
3114
  runStatus: u
@@ -3133,13 +3163,13 @@ class q {
3133
3163
  ), r.eventType === h.PROMPT_SUGGESTION ? this.promptSuggestionSubject.next(
3134
3164
  r.fact.promptSuggestion.suggestion
3135
3165
  ) : 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) {
3136
- const o = new Map(this.conversation$.value.messages), i = o.get(this.currentUserMessageId);
3137
- i && i.type === "user" && (o.set(this.currentUserMessageId, {
3138
- ...i,
3166
+ const i = new Map(this.conversation$.value.messages), o = i.get(this.currentUserMessageId);
3167
+ o && o.type === "user" && (i.set(this.currentUserMessageId, {
3168
+ ...o,
3139
3169
  traceId: r.traceId
3140
3170
  }), this.conversation$.next(
3141
3171
  new y({
3142
- messages: o,
3172
+ messages: i,
3143
3173
  pendingConsent: this.conversation$.value.pendingConsent,
3144
3174
  pendingFeedback: this.conversation$.value.pendingFeedback
3145
3175
  })
@@ -3173,8 +3203,8 @@ class q {
3173
3203
  this.forceStopTimer && (clearTimeout(this.forceStopTimer), this.forceStopTimer = void 0);
3174
3204
  }
3175
3205
  fetchSse(t, e, s) {
3176
- return new Promise((r, o) => {
3177
- this.isConnecting$.next(!0), this.runStatusSubject.next({ kind: t, stopPhase: "idle" }), this.currentRun = this.client.fetchSse(e, this.buildRunHandlers(s, r, o));
3206
+ return new Promise((r, i) => {
3207
+ this.isConnecting$.next(!0), this.runStatusSubject.next({ kind: t, stopPhase: "idle" }), this.currentRun = this.client.fetchSse(e, this.buildRunHandlers(s, r, i));
3178
3208
  });
3179
3209
  }
3180
3210
  /**
@@ -3219,12 +3249,12 @@ class q {
3219
3249
  const r = this.conversation$.value.pendingConsent;
3220
3250
  if (r) return Promise.reject(new re(r.processId));
3221
3251
  this.clearPromptSuggestion();
3222
- const o = t.text.trim(), i = t.customMessageId ?? Qe();
3223
- return this.currentUserMessageId = i, this.lastSentMessageId = i, this.conversation$.next(
3252
+ const i = t.text.trim(), o = t.customMessageId ?? Qe();
3253
+ return this.currentUserMessageId = o, this.lastSentMessageId = o, this.conversation$.next(
3224
3254
  this.conversation$.value.pushMessage({
3225
3255
  type: "user",
3226
- messageId: i,
3227
- text: o,
3256
+ messageId: o,
3257
+ text: i,
3228
3258
  blobIds: t.blobIds,
3229
3259
  filePreviewUrls: t.filePreviewUrls,
3230
3260
  documentNames: t.documentNames,
@@ -3235,9 +3265,9 @@ class q {
3235
3265
  {
3236
3266
  action: G.NONE,
3237
3267
  customChannelId: this.customChannelId,
3238
- customMessageId: i,
3268
+ customMessageId: o,
3239
3269
  payload: this.resolvePayload(t?.payload),
3240
- text: o,
3270
+ text: i,
3241
3271
  blobIds: t?.blobIds
3242
3272
  },
3243
3273
  e
@@ -3285,8 +3315,8 @@ class q {
3285
3315
  toolCallConsents: t
3286
3316
  },
3287
3317
  e
3288
- ).catch((o) => {
3289
- throw r && this.conversation$.next(this.conversation$.value.restorePendingConsent(r)), o;
3318
+ ).catch((i) => {
3319
+ throw r && this.conversation$.next(this.conversation$.value.restorePendingConsent(r)), i;
3290
3320
  });
3291
3321
  }
3292
3322
  /**
@@ -3308,12 +3338,66 @@ class q {
3308
3338
  *
3309
3339
  * Rejects with `ChannelBusyError` when a run already holds the channel, and with
3310
3340
  * `ChannelAwaitingConsentError` while a consent prompt is pending — exactly like `sendMessage`.
3341
+ *
3342
+ * Every accepted nudge is the channel's shared sandbox wake (F-038): it drives {@link sandboxWake$}
3343
+ * whether it came from here or from {@link wakeSandbox}, so a host that calls this directly still shows
3344
+ * up as "waking" on every other entry point. Called while the metadata re-fetch after a nudge is still
3345
+ * running, it joins that wake instead of sending a second nudge.
3311
3346
  */
3312
3347
  nudge(t, e) {
3313
- const s = this.runStatusSubject.value.kind;
3314
- if (s) return Promise.reject(new se(s));
3315
- const r = this.conversation$.value.pendingConsent;
3316
- return r ? Promise.reject(new re(r.processId)) : this.fetchSse(
3348
+ return this.wakeInFlight && !this.runStatusSubject.value.kind ? this.wakeInFlight.then(() => {
3349
+ }) : this.sendNudge(t, e);
3350
+ }
3351
+ /**
3352
+ * Wake the channel's sandbox through the **one** shared wake (F-038, UC-063) and report how it ended.
3353
+ *
3354
+ * - **single-flight** — while a wake is in flight (started by any entry point, including a direct
3355
+ * {@link nudge}), this joins it and never sends a second nudge.
3356
+ * - **no timeout** — how long a wake may take is the nudge turn's own business. It failed when the nudge
3357
+ * was refused / failed, or when it ended normally but `/channel/metadata` still does not list the
3358
+ * target. {@link sandboxWake$} stays `waking` through both the turn and that re-fetch.
3359
+ * - **`blocked`** — while another run holds the channel (that run brings the sandbox up by itself; wait
3360
+ * for it) or a consent prompt is pending, nothing is sent and the store is left alone.
3361
+ *
3362
+ * @param sandboxName The sandbox to wait for. Omit it when any sandbox will do — the File Explorer's empty
3363
+ * state does not know which one is coming. Each joining caller is judged by its own target; the store
3364
+ * follows the caller that started the wake.
3365
+ * @param payload Turn-level payload, exactly as for {@link nudge} (BUG-004).
3366
+ */
3367
+ async wakeSandbox(t, e, s) {
3368
+ return this.wakeInFlight ? this.judgeWake(await this.wakeInFlight, t) : this.isSandboxLive(t) ? "live" : this.runStatusSubject.value.kind || this.conversation$.value.pendingConsent ? "blocked" : (this.sendNudge(s, e, t).catch(() => {
3369
+ }), this.judgeWake(await (this.wakeInFlight ?? Promise.resolve(!1)), t));
3370
+ }
3371
+ isSandboxLive(t) {
3372
+ const e = this.launchedSandboxesSubject.value;
3373
+ return t ? e.some((s) => s.sandboxName === t) : e.length > 0;
3374
+ }
3375
+ judgeWake(t, e) {
3376
+ return t && this.isSandboxLive(e) ? "live" : "failed";
3377
+ }
3378
+ /**
3379
+ * Record an accepted nudge as the shared wake (F-038): `waking` until the turn has ended **and** metadata
3380
+ * has been re-fetched, then `idle` if the target is listed, else `failed`. No timer anywhere.
3381
+ */
3382
+ trackWake(t, e) {
3383
+ this.sandboxWakeSubject.next({ phase: "waking" });
3384
+ const s = (async () => {
3385
+ try {
3386
+ return await t, await this.refetchMetadata(), !0;
3387
+ } catch {
3388
+ return !1;
3389
+ }
3390
+ })();
3391
+ this.wakeInFlight = s, s.then((r) => {
3392
+ this.wakeInFlight = void 0, !this.sandboxWakeSubject.closed && this.sandboxWakeSubject.next({ phase: this.judgeWake(r, e) === "live" ? "idle" : "failed" });
3393
+ });
3394
+ }
3395
+ sendNudge(t, e, s) {
3396
+ const r = this.runStatusSubject.value.kind;
3397
+ if (r) return Promise.reject(new se(r));
3398
+ const i = this.conversation$.value.pendingConsent;
3399
+ if (i) return Promise.reject(new re(i.processId));
3400
+ const o = this.fetchSse(
3317
3401
  "nudge",
3318
3402
  {
3319
3403
  action: G.NUDGE,
@@ -3324,6 +3408,7 @@ class q {
3324
3408
  },
3325
3409
  t
3326
3410
  );
3411
+ return this.trackWake(o, s), o;
3327
3412
  }
3328
3413
  /**
3329
3414
  * User-initiated stop-generation (F-023).
@@ -3382,7 +3467,7 @@ class q {
3382
3467
  this.forceStopTimer = void 0;
3383
3468
  const t = this.runStatusSubject.value;
3384
3469
  t.stopPhase === "stopping" && this.runStatusSubject.next({ ...t, stopPhase: "force-stoppable" });
3385
- }, Pn);
3470
+ }, Mn);
3386
3471
  }
3387
3472
  /**
3388
3473
  * Cut the local SSE connection without telling the backend. This is *not* stop-generation (see
@@ -3396,34 +3481,34 @@ class q {
3396
3481
  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()));
3397
3482
  }
3398
3483
  close() {
3399
- 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();
3484
+ 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.sandboxWakeSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
3400
3485
  }
3401
3486
  }
3402
- const Ln = {
3487
+ const Un = {
3403
3488
  GOOD: "[Response Feedback: Good]",
3404
3489
  BAD: "[Response Feedback: Bad]"
3405
- }, zn = 8 * 1024;
3406
- function Jn(n) {
3490
+ }, Jn = 8 * 1024;
3491
+ function Qn(n) {
3407
3492
  return new TextEncoder().encode(n).length;
3408
3493
  }
3409
- function Qn(n, t) {
3410
- const e = Ln[n], s = t?.trim() ?? "";
3494
+ function Zn(n, t) {
3495
+ const e = Un[n], s = t?.trim() ?? "";
3411
3496
  return s ? `${e}
3412
3497
 
3413
3498
  ${s}` : e;
3414
3499
  }
3415
- const Un = ["open-file", "open-folder"];
3500
+ const Fn = ["open-file", "open-folder", "download-file"];
3416
3501
  function Rn(n) {
3417
- return Un.includes(n);
3502
+ return Fn.includes(n);
3418
3503
  }
3419
- function Zn(n) {
3504
+ function es(n) {
3420
3505
  const t = /^sandbox:\/\/([^/]+)\/([^?#]+)(?:\?([^#]*))?/.exec(n.trim());
3421
3506
  if (!t) return null;
3422
3507
  const e = decodeURIComponent(t[1]), s = t[2], r = new URLSearchParams(t[3] ?? "");
3423
3508
  if (s === "open-browser") return { kind: "open-browser", sandboxName: e };
3424
3509
  if (Rn(s)) {
3425
- const o = r.get("absolute_path");
3426
- return o ? { kind: s, sandboxName: e, absolutePath: o } : null;
3510
+ const i = r.get("absolute_path");
3511
+ return i ? { kind: s, sandboxName: e, absolutePath: i } : null;
3427
3512
  }
3428
3513
  return null;
3429
3514
  }
@@ -3461,7 +3546,7 @@ const xe = {
3461
3546
  Meta: 65515,
3462
3547
  ContextMenu: 65383,
3463
3548
  " ": 32
3464
- }, k = {
3549
+ }, O = {
3465
3550
  ISO_Level3_Shift: 65027,
3466
3551
  Shift_L: 65505,
3467
3552
  Mode_switch: 65406,
@@ -3476,10 +3561,10 @@ function et(n) {
3476
3561
  const t = n.codePointAt(0) ?? 0;
3477
3562
  return t > 255 ? t | Ze : t;
3478
3563
  }
3479
- function es(n) {
3564
+ function ts(n) {
3480
3565
  return n in xe ? xe[n] : n.length === 1 ? et(n) : null;
3481
3566
  }
3482
- function ts(n) {
3567
+ function ns(n) {
3483
3568
  return n >= 32 && n <= 126 || n >= Ze;
3484
3569
  }
3485
3570
  function Nn() {
@@ -3487,45 +3572,45 @@ function Nn() {
3487
3572
  const n = navigator.platform || "";
3488
3573
  return /(Mac|iPhone|iPod|iPad)/i.test(n);
3489
3574
  }
3490
- function ns(n, t = Nn()) {
3575
+ function ss(n, t = Nn()) {
3491
3576
  if (!t) return n;
3492
3577
  switch (n) {
3493
- case k.Meta_L:
3494
- return k.Control_L;
3495
- case k.Super_L:
3496
- return k.Alt_L;
3497
- case k.Super_R:
3498
- return k.Super_L;
3499
- case k.Alt_L:
3500
- return k.Mode_switch;
3501
- case k.Alt_R:
3502
- return k.ISO_Level3_Shift;
3578
+ case O.Meta_L:
3579
+ return O.Control_L;
3580
+ case O.Super_L:
3581
+ return O.Alt_L;
3582
+ case O.Super_R:
3583
+ return O.Super_L;
3584
+ case O.Alt_L:
3585
+ return O.Mode_switch;
3586
+ case O.Alt_R:
3587
+ return O.ISO_Level3_Shift;
3503
3588
  default:
3504
3589
  return n;
3505
3590
  }
3506
3591
  }
3507
- const Fn = 19, Ae = 10, ss = 100;
3508
- function rs(n) {
3509
- const t = n.deltaMode === 0 ? 1 : Fn, e = (s) => Math.max(-Ae, Math.min(Ae, -s * t)) || 0;
3592
+ const jn = 19, ke = 10, rs = 100;
3593
+ function is(n) {
3594
+ const t = n.deltaMode === 0 ? 1 : jn, e = (s) => Math.max(-ke, Math.min(ke, -s * t)) || 0;
3510
3595
  return { x: e(n.deltaX), y: e(n.deltaY) };
3511
3596
  }
3512
- function jn(n) {
3597
+ function $n(n) {
3513
3598
  return n >= 65 && n <= 90;
3514
3599
  }
3515
- const $n = 1e4, Dn = 8e3, Hn = 1, Bn = 7, Gn = /* @__PURE__ */ new Set(["control/move"]);
3516
- function qn(n) {
3517
- if (n.byteLength < Bn) return null;
3600
+ const Dn = 1e4, Hn = 8e3, Bn = 1, Gn = 7, qn = /* @__PURE__ */ new Set(["control/move"]);
3601
+ function Wn(n) {
3602
+ if (n.byteLength < Gn) return null;
3518
3603
  const t = new DataView(n);
3519
- return t.getUint8(0) !== Hn ? null : { x: t.getUint16(3), y: t.getUint16(5) };
3604
+ return t.getUint8(0) !== Bn ? null : { x: t.getUint16(3), y: t.getUint16(5) };
3520
3605
  }
3521
3606
  function os(n) {
3522
3607
  return {
3523
3608
  async connect(t, e) {
3524
3609
  e.onStatus("connecting");
3525
- const { wsUrl: s, token: r } = await n.createSession(t), o = s.includes("?") ? "&" : "?", i = new WebSocket(`${s}${o}token=${encodeURIComponent(r)}`);
3610
+ const { wsUrl: s, token: r } = await n.createSession(t), i = s.includes("?") ? "&" : "?", o = new WebSocket(`${s}${i}token=${encodeURIComponent(r)}`);
3526
3611
  let a = null, c = null, u = "none", l, v = !1, w = null;
3527
3612
  const p = [], g = (f, m) => {
3528
- i.readyState === WebSocket.OPEN && (i.send(JSON.stringify({ event: f, payload: m })), Gn.has(f) || e.onWire?.("send", f, m));
3613
+ o.readyState === WebSocket.OPEN && (o.send(JSON.stringify({ event: f, payload: m })), qn.has(f) || e.onWire?.("send", f, m));
3529
3614
  }, d = (f, m) => {
3530
3615
  u === "me" && g(f, m);
3531
3616
  }, C = (f) => {
@@ -3535,18 +3620,18 @@ function os(n) {
3535
3620
  await new Promise((f, m) => {
3536
3621
  const S = setTimeout(
3537
3622
  () => m(new Error("Sandbox browser WebSocket connection timed out.")),
3538
- Dn
3623
+ Hn
3539
3624
  );
3540
- i.onopen = () => {
3625
+ o.onopen = () => {
3541
3626
  clearTimeout(S), f();
3542
- }, i.onerror = () => {
3627
+ }, o.onerror = () => {
3543
3628
  clearTimeout(S), m(new Error("Sandbox browser WebSocket failed to connect."));
3544
3629
  };
3545
3630
  });
3546
3631
  } catch (f) {
3547
- throw v = !0, i.close(), f;
3632
+ throw v = !0, o.close(), f;
3548
3633
  }
3549
- i.onclose = (f) => {
3634
+ o.onclose = (f) => {
3550
3635
  v || (e.onStatus("error", `Sandbox browser connection closed (code ${f.code}).`), e.onWire?.("recv", "ws/close", { code: f.code }));
3551
3636
  };
3552
3637
  const x = async (f) => {
@@ -3565,9 +3650,9 @@ function os(n) {
3565
3650
  I && w !== I.id && (w = I.id, e.onStream(I), e.onStatus("live"));
3566
3651
  }, m.ondatachannel = (b) => {
3567
3652
  const I = b.channel;
3568
- I.binaryType = "arraybuffer", I.onmessage = (M) => {
3569
- if (!(M.data instanceof ArrayBuffer)) return;
3570
- const _ = qn(M.data);
3653
+ I.binaryType = "arraybuffer", I.onmessage = (L) => {
3654
+ if (!(L.data instanceof ArrayBuffer)) return;
3655
+ const _ = Wn(L.data);
3571
3656
  _ && e.onRemoteCursor?.(_);
3572
3657
  };
3573
3658
  }, await m.setRemoteDescription({ type: "offer", sdp: f.sdp });
@@ -3577,7 +3662,7 @@ function os(n) {
3577
3662
  const S = await m.createAnswer();
3578
3663
  await m.setLocalDescription(S), g("signal/answer", { sdp: S.sdp, displayname: n.displayName ?? "asgard-js-sdk" });
3579
3664
  };
3580
- return i.onmessage = (f) => {
3665
+ return o.onmessage = (f) => {
3581
3666
  let m;
3582
3667
  try {
3583
3668
  m = JSON.parse(String(f.data));
@@ -3617,7 +3702,7 @@ function os(n) {
3617
3702
  default:
3618
3703
  return;
3619
3704
  }
3620
- }, g("signal/request", { video: {}, audio: {} }), l = setInterval(() => g("client/heartbeat", {}), $n), {
3705
+ }, g("signal/request", { video: {}, audio: {} }), l = setInterval(() => g("client/heartbeat", {}), Dn), {
3621
3706
  requestControl() {
3622
3707
  g("control/request", {});
3623
3708
  },
@@ -3647,8 +3732,8 @@ function os(n) {
3647
3732
  sendKey(f) {
3648
3733
  if (f.type === "text") {
3649
3734
  for (const m of f.text ?? "") {
3650
- const S = et(m), b = jn(S);
3651
- 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 });
3735
+ const S = et(m), b = $n(S);
3736
+ b && d("control/keydown", { keysym: O.Shift_L }), d("control/keydown", { keysym: S }), d("control/keyup", { keysym: S }), b && d("control/keyup", { keysym: O.Shift_L });
3652
3737
  }
3653
3738
  return;
3654
3739
  }
@@ -3661,58 +3746,58 @@ function os(n) {
3661
3746
  d("control/paste", { text: f });
3662
3747
  },
3663
3748
  close() {
3664
- v = !0, l && clearInterval(l), l = void 0, a?.close(), a = null, i.close();
3749
+ v = !0, l && clearInterval(l), l = void 0, a?.close(), a = null, o.close();
3665
3750
  }
3666
3751
  };
3667
3752
  }
3668
3753
  };
3669
3754
  }
3670
3755
  export {
3671
- Xn as AsgardServiceClient,
3672
- Yn as AsgardSourceSetClient,
3756
+ Yn as AsgardServiceClient,
3757
+ zn as AsgardSourceSetClient,
3673
3758
  q as Channel,
3674
3759
  re as ChannelAwaitingConsentError,
3675
3760
  se as ChannelBusyError,
3676
3761
  y as Conversation,
3677
3762
  h as EventType,
3678
- zn as FEEDBACK_COMMENT_MAX_BYTES,
3763
+ Jn as FEEDBACK_COMMENT_MAX_BYTES,
3679
3764
  G as FetchSseAction,
3680
- A as HttpError,
3765
+ k as HttpError,
3681
3766
  xe as KEYSYM,
3682
- Oe as MessageTemplateType,
3683
- Ln as RESPONSE_FEEDBACK_PREFIX,
3684
- dn as SOURCE_SET_DEFAULT_MAX_ENTRIES,
3767
+ Ae as MessageTemplateType,
3768
+ Un as RESPONSE_FEEDBACK_PREFIX,
3769
+ hn as SOURCE_SET_DEFAULT_MAX_ENTRIES,
3685
3770
  Je as SOURCE_SET_MAX_PAGE_SIZE,
3686
- un as SOURCE_SET_VOLUME_ROOT,
3771
+ ln as SOURCE_SET_VOLUME_ROOT,
3687
3772
  tt as ToolCallConsentResult,
3688
- Ae as WHEEL_MAX,
3689
- ss as WHEEL_THROTTLE_MS,
3690
- k as XK,
3691
- L as assertVolumePath,
3773
+ ke as WHEEL_MAX,
3774
+ rs as WHEEL_THROTTLE_MS,
3775
+ O as XK,
3776
+ U as assertVolumePath,
3692
3777
  et as charToKeysym,
3693
- Qn as composeFeedbackMessage,
3694
- Tn as conversationToSubagentEvents,
3695
- _n as createDerivedStores,
3778
+ Zn as composeFeedbackMessage,
3779
+ Cn as conversationToSubagentEvents,
3780
+ Pn as createDerivedStores,
3696
3781
  os as createSandboxBrowserTransport,
3697
- qn as decodeCursorFrame,
3698
- xn as deriveSubagents,
3699
- Cn as deriveTasks,
3700
- Jn as feedbackCommentByteLength,
3701
- yn as isAgentTool,
3702
- Vn as isChannelAwaitingConsentError,
3703
- Wn as isChannelBusyError,
3782
+ Wn as decodeCursorFrame,
3783
+ kn as deriveSubagents,
3784
+ xn as deriveTasks,
3785
+ Qn as feedbackCommentByteLength,
3786
+ wn as isAgentTool,
3787
+ Xn as isChannelAwaitingConsentError,
3788
+ Vn as isChannelBusyError,
3704
3789
  Kn as isHttpError,
3705
- ts as isPrintableKeysym,
3706
- wn as isSubagentChildTool,
3707
- Sn as isTaskTool,
3708
- es as keyToKeysym,
3709
- ns as mapModifierKeysym,
3710
- rs as normalizeWheel,
3790
+ ns as isPrintableKeysym,
3791
+ En as isSubagentChildTool,
3792
+ vn as isTaskTool,
3793
+ ts as keyToKeysym,
3794
+ ss as mapModifierKeysym,
3795
+ is as normalizeWheel,
3711
3796
  Ce as reconcileLaunched,
3712
- En as reduceSubagents,
3713
- vn as reduceTaskEvents,
3714
- Zn as resolveSandboxUri,
3715
- kn as subagentsEqual,
3797
+ In as reduceSubagents,
3798
+ yn as reduceTaskEvents,
3799
+ es as resolveSandboxUri,
3800
+ _n as subagentsEqual,
3716
3801
  An as tasksEqual
3717
3802
  };
3718
3803
  //# sourceMappingURL=index.mjs.map