@asgard-js/core 0.3.79 → 0.3.81

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 E extends Error {
1
+ class y extends Error {
2
2
  status;
3
3
  statusText;
4
4
  /**
@@ -16,8 +16,8 @@ class E extends Error {
16
16
  super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = s;
17
17
  }
18
18
  }
19
- function An(n) {
20
- return n instanceof E;
19
+ function On(n) {
20
+ return n instanceof y;
21
21
  }
22
22
  class te extends Error {
23
23
  /** Which run is holding the channel. */
@@ -26,7 +26,7 @@ class te 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 On(n) {
29
+ function kn(n) {
30
30
  return n instanceof te;
31
31
  }
32
32
  class ne extends Error {
@@ -46,7 +46,7 @@ class ne extends Error {
46
46
  function Pn(n) {
47
47
  return n instanceof ne;
48
48
  }
49
- var B = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))(B || {}), d = /* @__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.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), Ye = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ye || {}), Te = /* @__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))(Te || {});
49
+ var H = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))(H || {}), l = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.MESSAGE_USER = "asgard.message.user", n.MESSAGE_THINKING_START = "asgard.message.thinking.start", n.MESSAGE_THINKING_DELTA = "asgard.message.thinking.delta", n.MESSAGE_THINKING_COMPLETE = "asgard.message.thinking.complete", n.MESSAGE_CANVAS_START = "asgard.message.canvas.start", n.MESSAGE_CANVAS_DELTA = "asgard.message.canvas.delta", n.MESSAGE_CANVAS_COMPLETE = "asgard.message.canvas.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.SUBAGENT_START = "asgard.subagent.start", n.SUBAGENT_COMPLETE = "asgard.subagent.complete", n.CHANNEL_TITLE_UPDATE = "asgard.channel.title.update", n.PROMPT_SUGGESTION = "asgard.prompt_suggestion", n.SANDBOX_LAUNCH = "asgard.sandbox.launch", n.SANDBOX_READY = "asgard.sandbox.ready", n.MESSAGE_FEEDBACK = "asgard.message.feedback", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(l || {}), Ye = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ye || {}), Te = /* @__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))(Te || {});
50
50
  async function ze(n, t) {
51
51
  const e = n.getReader();
52
52
  let s;
@@ -55,52 +55,52 @@ async function ze(n, t) {
55
55
  }
56
56
  function Je(n) {
57
57
  let t, e, s, r = !1;
58
- return function(o) {
59
- t === void 0 ? (t = o, e = 0, s = -1) : t = Ze(t, o);
60
- const a = t.length;
61
- let u = 0;
62
- for (; e < a; ) {
63
- r && (t[e] === 10 && (u = ++e), r = !1);
64
- let c = -1;
65
- for (; e < a && c === -1; ++e)
58
+ return function(a) {
59
+ t === void 0 ? (t = a, e = 0, s = -1) : t = Ze(t, a);
60
+ const o = t.length;
61
+ let c = 0;
62
+ for (; e < o; ) {
63
+ r && (t[e] === 10 && (c = ++e), r = !1);
64
+ let u = -1;
65
+ for (; e < o && u === -1; ++e)
66
66
  switch (t[e]) {
67
67
  case 58:
68
- s === -1 && (s = e - u);
68
+ s === -1 && (s = e - c);
69
69
  break;
70
70
  case 13:
71
71
  r = !0;
72
72
  case 10:
73
- c = e;
73
+ u = e;
74
74
  break;
75
75
  }
76
- if (c === -1)
76
+ if (u === -1)
77
77
  break;
78
- n(t.subarray(u, c), s), u = e, s = -1;
78
+ n(t.subarray(c, u), s), c = e, s = -1;
79
79
  }
80
- u === a ? t = void 0 : u !== 0 && (t = t.subarray(u), e -= u);
80
+ c === o ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
81
81
  };
82
82
  }
83
83
  function Qe(n, t, e) {
84
84
  let s = le();
85
85
  const r = new TextDecoder();
86
- return function(o, a) {
87
- if (o.length === 0)
86
+ return function(a, o) {
87
+ if (a.length === 0)
88
88
  e?.(s), s = le();
89
- else if (a > 0) {
90
- const u = r.decode(o.subarray(0, a)), c = a + (o[a + 1] === 32 ? 2 : 1), l = r.decode(o.subarray(c));
91
- switch (u) {
89
+ else if (o > 0) {
90
+ const c = r.decode(a.subarray(0, o)), u = o + (a[o + 1] === 32 ? 2 : 1), d = r.decode(a.subarray(u));
91
+ switch (c) {
92
92
  case "data":
93
93
  s.data = s.data ? s.data + `
94
- ` + l : l;
94
+ ` + d : d;
95
95
  break;
96
96
  case "event":
97
- s.event = l;
97
+ s.event = d;
98
98
  break;
99
99
  case "id":
100
- n(s.id = l);
100
+ n(s.id = d);
101
101
  break;
102
102
  case "retry":
103
- const m = parseInt(l, 10);
103
+ const m = parseInt(d, 10);
104
104
  isNaN(m) || t(s.retry = m);
105
105
  break;
106
106
  }
@@ -129,44 +129,44 @@ var et = function(n, t) {
129
129
  };
130
130
  const se = "text/event-stream", tt = 1e3, de = "last-event-id";
131
131
  function Ce(n, t) {
132
- var { signal: e, headers: s, onopen: r, onmessage: i, onclose: o, onerror: a, openWhenHidden: u, fetch: c } = t, l = et(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
132
+ var { signal: e, headers: s, onopen: r, onmessage: i, onclose: a, onerror: o, openWhenHidden: c, fetch: u } = t, d = et(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
133
133
  return new Promise((m, v) => {
134
134
  const h = Object.assign({}, s);
135
135
  h.accept || (h.accept = se);
136
136
  let p;
137
137
  function f() {
138
- p.abort(), document.hidden || j();
138
+ p.abort(), document.hidden || F();
139
139
  }
140
- u || document.addEventListener("visibilitychange", f);
141
- let I = tt, w = 0;
142
- function F() {
143
- document.removeEventListener("visibilitychange", f), window.clearTimeout(w), p.abort();
140
+ c || document.addEventListener("visibilitychange", f);
141
+ let I = tt, E = 0;
142
+ function B() {
143
+ document.removeEventListener("visibilitychange", f), window.clearTimeout(E), p.abort();
144
144
  }
145
145
  e?.addEventListener("abort", () => {
146
- F(), m();
146
+ B(), m();
147
147
  });
148
- const k = c ?? window.fetch, L = r ?? nt;
149
- async function j() {
150
- var $;
148
+ const R = u ?? window.fetch, _ = r ?? nt;
149
+ async function F() {
150
+ var j;
151
151
  p = new AbortController();
152
152
  try {
153
- const D = await k(n, Object.assign(Object.assign({}, l), { headers: h, signal: p.signal }));
154
- await L(D), await ze(D.body, Je(Qe((P) => {
155
- P ? h[de] = P : delete h[de];
156
- }, (P) => {
157
- I = P;
158
- }, i))), o?.(), F(), m();
159
- } catch (D) {
153
+ const $ = await R(n, Object.assign(Object.assign({}, d), { headers: h, signal: p.signal }));
154
+ await _($), await ze($.body, Je(Qe((k) => {
155
+ k ? h[de] = k : delete h[de];
156
+ }, (k) => {
157
+ I = k;
158
+ }, i))), a?.(), B(), m();
159
+ } catch ($) {
160
160
  if (!p.signal.aborted)
161
161
  try {
162
- const P = ($ = a?.(D)) !== null && $ !== void 0 ? $ : I;
163
- window.clearTimeout(w), w = window.setTimeout(j, P);
164
- } catch (P) {
165
- F(), v(P);
162
+ const k = (j = o?.($)) !== null && j !== void 0 ? j : I;
163
+ window.clearTimeout(E), E = window.setTimeout(F, k);
164
+ } catch (k) {
165
+ B(), v(k);
166
166
  }
167
167
  }
168
168
  }
169
- j();
169
+ F();
170
170
  });
171
171
  }
172
172
  function nt(n) {
@@ -192,92 +192,92 @@ function O(n, t) {
192
192
  }
193
193
  function st(n, t, e, s) {
194
194
  function r(i) {
195
- return i instanceof e ? i : new e(function(o) {
196
- o(i);
195
+ return i instanceof e ? i : new e(function(a) {
196
+ a(i);
197
197
  });
198
198
  }
199
- return new (e || (e = Promise))(function(i, o) {
200
- function a(l) {
199
+ return new (e || (e = Promise))(function(i, a) {
200
+ function o(d) {
201
201
  try {
202
- c(s.next(l));
202
+ u(s.next(d));
203
203
  } catch (m) {
204
- o(m);
204
+ a(m);
205
205
  }
206
206
  }
207
- function u(l) {
207
+ function c(d) {
208
208
  try {
209
- c(s.throw(l));
209
+ u(s.throw(d));
210
210
  } catch (m) {
211
- o(m);
211
+ a(m);
212
212
  }
213
213
  }
214
- function c(l) {
215
- l.done ? i(l.value) : r(l.value).then(a, u);
214
+ function u(d) {
215
+ d.done ? i(d.value) : r(d.value).then(o, c);
216
216
  }
217
- c((s = s.apply(n, t || [])).next());
217
+ u((s = s.apply(n, t || [])).next());
218
218
  });
219
219
  }
220
220
  function xe(n, t) {
221
221
  var e = { label: 0, sent: function() {
222
222
  if (i[0] & 1) throw i[1];
223
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() {
224
+ }, trys: [], ops: [] }, s, r, i, a = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
225
+ return a.next = o(0), a.throw = o(1), a.return = o(2), typeof Symbol == "function" && (a[Symbol.iterator] = function() {
226
226
  return this;
227
- }), o;
228
- function a(c) {
229
- return function(l) {
230
- return u([c, l]);
227
+ }), a;
228
+ function o(u) {
229
+ return function(d) {
230
+ return c([u, d]);
231
231
  };
232
232
  }
233
- function u(c) {
233
+ function c(u) {
234
234
  if (s) throw new TypeError("Generator is already executing.");
235
- for (; o && (o = 0, c[0] && (e = 0)), e; ) try {
236
- if (s = 1, r && (i = c[0] & 2 ? r.return : c[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, c[1])).done) return i;
237
- switch (r = 0, i && (c = [c[0] & 2, i.value]), c[0]) {
235
+ for (; a && (a = 0, u[0] && (e = 0)), e; ) try {
236
+ if (s = 1, r && (i = u[0] & 2 ? r.return : u[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, u[1])).done) return i;
237
+ switch (r = 0, i && (u = [u[0] & 2, i.value]), u[0]) {
238
238
  case 0:
239
239
  case 1:
240
- i = c;
240
+ i = u;
241
241
  break;
242
242
  case 4:
243
- return e.label++, { value: c[1], done: !1 };
243
+ return e.label++, { value: u[1], done: !1 };
244
244
  case 5:
245
- e.label++, r = c[1], c = [0];
245
+ e.label++, r = u[1], u = [0];
246
246
  continue;
247
247
  case 7:
248
- c = e.ops.pop(), e.trys.pop();
248
+ u = e.ops.pop(), e.trys.pop();
249
249
  continue;
250
250
  default:
251
- if (i = e.trys, !(i = i.length > 0 && i[i.length - 1]) && (c[0] === 6 || c[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 (c[0] === 3 && (!i || c[1] > i[0] && c[1] < i[3])) {
256
- e.label = c[1];
255
+ if (u[0] === 3 && (!i || u[1] > i[0] && u[1] < i[3])) {
256
+ e.label = u[1];
257
257
  break;
258
258
  }
259
- if (c[0] === 6 && e.label < i[1]) {
260
- e.label = i[1], i = c;
259
+ if (u[0] === 6 && e.label < i[1]) {
260
+ e.label = i[1], i = u;
261
261
  break;
262
262
  }
263
263
  if (i && e.label < i[2]) {
264
- e.label = i[2], e.ops.push(c);
264
+ e.label = i[2], e.ops.push(u);
265
265
  break;
266
266
  }
267
267
  i[2] && e.ops.pop(), e.trys.pop();
268
268
  continue;
269
269
  }
270
- c = t.call(n, e);
271
- } catch (l) {
272
- c = [6, l], r = 0;
270
+ u = t.call(n, e);
271
+ } catch (d) {
272
+ u = [6, d], r = 0;
273
273
  } finally {
274
274
  s = i = 0;
275
275
  }
276
- if (c[0] & 5) throw c[1];
277
- return { value: c[0] ? c[1] : void 0, done: !0 };
276
+ if (u[0] & 5) throw u[1];
277
+ return { value: u[0] ? u[1] : void 0, done: !0 };
278
278
  }
279
279
  }
280
- function M(n) {
280
+ function L(n) {
281
281
  var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], s = 0;
282
282
  if (e) return e.call(n);
283
283
  if (n && typeof n.length == "number") return {
@@ -290,16 +290,16 @@ function M(n) {
290
290
  function q(n, t) {
291
291
  var e = typeof Symbol == "function" && n[Symbol.iterator];
292
292
  if (!e) return n;
293
- var s = e.call(n), r, i = [], o;
293
+ var s = e.call(n), r, i = [], a;
294
294
  try {
295
295
  for (; (t === void 0 || t-- > 0) && !(r = s.next()).done; ) i.push(r.value);
296
- } catch (a) {
297
- o = { error: a };
296
+ } catch (o) {
297
+ a = { error: o };
298
298
  } finally {
299
299
  try {
300
300
  r && !r.done && (e = s.return) && e.call(s);
301
301
  } finally {
302
- if (o) throw o.error;
302
+ if (a) throw a.error;
303
303
  }
304
304
  }
305
305
  return i;
@@ -309,64 +309,64 @@ function K(n, t, e) {
309
309
  (i || !(s in t)) && (i || (i = Array.prototype.slice.call(t, 0, s)), i[s] = t[s]);
310
310
  return n.concat(i || Array.prototype.slice.call(t));
311
311
  }
312
- function H(n) {
313
- return this instanceof H ? (this.v = n, this) : new H(n);
312
+ function D(n) {
313
+ return this instanceof D ? (this.v = n, this) : new D(n);
314
314
  }
315
315
  function rt(n, t, e) {
316
316
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
317
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() {
318
+ return r = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), o("next"), o("throw"), o("return", a), r[Symbol.asyncIterator] = function() {
319
319
  return this;
320
320
  }, r;
321
- function o(h) {
321
+ function a(h) {
322
322
  return function(p) {
323
323
  return Promise.resolve(p).then(h, m);
324
324
  };
325
325
  }
326
- function a(h, p) {
326
+ function o(h, p) {
327
327
  s[h] && (r[h] = function(f) {
328
- return new Promise(function(I, w) {
329
- i.push([h, f, I, w]) > 1 || u(h, f);
328
+ return new Promise(function(I, E) {
329
+ i.push([h, f, I, E]) > 1 || c(h, f);
330
330
  });
331
331
  }, p && (r[h] = p(r[h])));
332
332
  }
333
- function u(h, p) {
333
+ function c(h, p) {
334
334
  try {
335
- c(s[h](p));
335
+ u(s[h](p));
336
336
  } catch (f) {
337
337
  v(i[0][3], f);
338
338
  }
339
339
  }
340
- function c(h) {
341
- h.value instanceof H ? Promise.resolve(h.value.v).then(l, m) : v(i[0][2], h);
340
+ function u(h) {
341
+ h.value instanceof D ? Promise.resolve(h.value.v).then(d, m) : v(i[0][2], h);
342
342
  }
343
- function l(h) {
344
- u("next", h);
343
+ function d(h) {
344
+ c("next", h);
345
345
  }
346
346
  function m(h) {
347
- u("throw", h);
347
+ c("throw", h);
348
348
  }
349
349
  function v(h, p) {
350
- h(p), i.shift(), i.length && u(i[0][0], i[0][1]);
350
+ h(p), i.shift(), i.length && c(i[0][0], i[0][1]);
351
351
  }
352
352
  }
353
353
  function it(n) {
354
354
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
355
355
  var t = n[Symbol.asyncIterator], e;
356
- return t ? t.call(n) : (n = typeof M == "function" ? M(n) : n[Symbol.iterator](), e = {}, s("next"), s("throw"), s("return"), e[Symbol.asyncIterator] = function() {
356
+ return t ? t.call(n) : (n = typeof L == "function" ? L(n) : n[Symbol.iterator](), e = {}, s("next"), s("throw"), s("return"), e[Symbol.asyncIterator] = function() {
357
357
  return this;
358
358
  }, e);
359
359
  function s(i) {
360
- e[i] = n[i] && function(o) {
361
- return new Promise(function(a, u) {
362
- o = n[i](o), r(a, u, o.done, o.value);
360
+ e[i] = n[i] && function(a) {
361
+ return new Promise(function(o, c) {
362
+ a = n[i](a), r(o, c, a.done, a.value);
363
363
  });
364
364
  };
365
365
  }
366
- function r(i, o, a, u) {
367
- Promise.resolve(u).then(function(c) {
368
- i({ value: c, done: a });
369
- }, o);
366
+ function r(i, a, o, c) {
367
+ Promise.resolve(c).then(function(u) {
368
+ i({ value: u, done: o });
369
+ }, a);
370
370
  }
371
371
  }
372
372
  function b(n) {
@@ -393,7 +393,7 @@ function V(n, t) {
393
393
  0 <= e && n.splice(e, 1);
394
394
  }
395
395
  }
396
- var N = (function() {
396
+ var U = (function() {
397
397
  function n(t) {
398
398
  this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
399
399
  }
@@ -401,29 +401,29 @@ var N = (function() {
401
401
  var t, e, s, r, i;
402
402
  if (!this.closed) {
403
403
  this.closed = !0;
404
- var o = this._parentage;
405
- if (o)
406
- if (this._parentage = null, Array.isArray(o))
404
+ var a = this._parentage;
405
+ if (a)
406
+ if (this._parentage = null, Array.isArray(a))
407
407
  try {
408
- for (var a = M(o), u = a.next(); !u.done; u = a.next()) {
409
- var c = u.value;
410
- c.remove(this);
408
+ for (var o = L(a), c = o.next(); !c.done; c = o.next()) {
409
+ var u = c.value;
410
+ u.remove(this);
411
411
  }
412
412
  } catch (f) {
413
413
  t = { error: f };
414
414
  } finally {
415
415
  try {
416
- u && !u.done && (e = a.return) && e.call(a);
416
+ c && !c.done && (e = o.return) && e.call(o);
417
417
  } finally {
418
418
  if (t) throw t.error;
419
419
  }
420
420
  }
421
421
  else
422
- o.remove(this);
423
- var l = this.initialTeardown;
424
- if (b(l))
422
+ a.remove(this);
423
+ var d = this.initialTeardown;
424
+ if (b(d))
425
425
  try {
426
- l();
426
+ d();
427
427
  } catch (f) {
428
428
  i = f instanceof Q ? f.errors : [f];
429
429
  }
@@ -431,7 +431,7 @@ var N = (function() {
431
431
  if (m) {
432
432
  this._finalizers = null;
433
433
  try {
434
- for (var v = M(m), h = v.next(); !h.done; h = v.next()) {
434
+ for (var v = L(m), h = v.next(); !h.done; h = v.next()) {
435
435
  var p = h.value;
436
436
  try {
437
437
  he(p);
@@ -481,16 +481,16 @@ var N = (function() {
481
481
  var t = new n();
482
482
  return t.closed = !0, t;
483
483
  })(), n;
484
- })(), Oe = N.EMPTY;
485
- function Pe(n) {
486
- return n instanceof N || n && "closed" in n && b(n.remove) && b(n.add) && b(n.unsubscribe);
484
+ })(), Oe = U.EMPTY;
485
+ function ke(n) {
486
+ return n instanceof U || n && "closed" in n && b(n.remove) && b(n.add) && b(n.unsubscribe);
487
487
  }
488
488
  function he(n) {
489
489
  b(n) ? n() : n.unsubscribe();
490
490
  }
491
- var ot = {
491
+ var at = {
492
492
  Promise: void 0
493
- }, at = {
493
+ }, ot = {
494
494
  setTimeout: function(n, t) {
495
495
  for (var e = [], s = 2; s < arguments.length; s++)
496
496
  e[s - 2] = arguments[s];
@@ -501,24 +501,24 @@ var ot = {
501
501
  },
502
502
  delegate: void 0
503
503
  };
504
- function _e(n) {
505
- at.setTimeout(function() {
504
+ function Pe(n) {
505
+ ot.setTimeout(function() {
506
506
  throw n;
507
507
  });
508
508
  }
509
509
  function ie() {
510
510
  }
511
- function X(n) {
511
+ function W(n) {
512
512
  n();
513
513
  }
514
- var ae = (function(n) {
514
+ var oe = (function(n) {
515
515
  O(t, n);
516
516
  function t(e) {
517
517
  var s = n.call(this) || this;
518
- return s.isStopped = !1, e ? (s.destination = e, Pe(e) && e.add(s)) : s.destination = lt, s;
518
+ return s.isStopped = !1, e ? (s.destination = e, ke(e) && e.add(s)) : s.destination = lt, s;
519
519
  }
520
520
  return t.create = function(e, s, r) {
521
- return new oe(e, s, r);
521
+ return new ae(e, s, r);
522
522
  }, t.prototype.next = function(e) {
523
523
  this.isStopped || this._next(e);
524
524
  }, t.prototype.error = function(e) {
@@ -542,7 +542,7 @@ var ae = (function(n) {
542
542
  this.unsubscribe();
543
543
  }
544
544
  }, t;
545
- })(N), ct = (function() {
545
+ })(U), ct = (function() {
546
546
  function n(t) {
547
547
  this.partialObserver = t;
548
548
  }
@@ -552,7 +552,7 @@ var ae = (function(n) {
552
552
  try {
553
553
  e.next(t);
554
554
  } catch (s) {
555
- W(s);
555
+ X(s);
556
556
  }
557
557
  }, n.prototype.error = function(t) {
558
558
  var e = this.partialObserver;
@@ -560,33 +560,33 @@ var ae = (function(n) {
560
560
  try {
561
561
  e.error(t);
562
562
  } catch (s) {
563
- W(s);
563
+ X(s);
564
564
  }
565
565
  else
566
- W(t);
566
+ X(t);
567
567
  }, n.prototype.complete = function() {
568
568
  var t = this.partialObserver;
569
569
  if (t.complete)
570
570
  try {
571
571
  t.complete();
572
572
  } catch (e) {
573
- W(e);
573
+ X(e);
574
574
  }
575
575
  }, n;
576
- })(), oe = (function(n) {
576
+ })(), ae = (function(n) {
577
577
  O(t, n);
578
578
  function t(e, s, r) {
579
- var i = n.call(this) || this, o;
580
- return b(e) || !e ? o = {
579
+ var i = n.call(this) || this, a;
580
+ return b(e) || !e ? a = {
581
581
  next: e ?? void 0,
582
582
  error: s ?? void 0,
583
583
  complete: r ?? void 0
584
- } : o = e, i.destination = new ct(o), i;
584
+ } : a = e, i.destination = new ct(a), i;
585
585
  }
586
586
  return t;
587
- })(ae);
588
- function W(n) {
589
- _e(n);
587
+ })(oe);
588
+ function X(n) {
589
+ Pe(n);
590
590
  }
591
591
  function ut(n) {
592
592
  throw n;
@@ -609,7 +609,7 @@ function dt(n) {
609
609
  }, e);
610
610
  };
611
611
  }
612
- var y = (function() {
612
+ var w = (function() {
613
613
  function n(t) {
614
614
  t && (this._subscribe = t);
615
615
  }
@@ -617,10 +617,10 @@ var y = (function() {
617
617
  var e = new n();
618
618
  return e.source = this, e.operator = t, e;
619
619
  }, n.prototype.subscribe = function(t, e, s) {
620
- var r = this, i = ft(t) ? t : new oe(t, e, s);
621
- return X(function() {
622
- var o = r, a = o.operator, u = o.source;
623
- i.add(a ? a.call(i, u) : u ? r._subscribe(i) : r._trySubscribe(i));
620
+ var r = this, i = ft(t) ? t : new ae(t, e, s);
621
+ return W(function() {
622
+ var a = r, o = a.operator, c = a.source;
623
+ i.add(o ? o.call(i, c) : c ? r._subscribe(i) : r._trySubscribe(i));
624
624
  }), i;
625
625
  }, n.prototype._trySubscribe = function(t) {
626
626
  try {
@@ -631,18 +631,18 @@ var y = (function() {
631
631
  }, n.prototype.forEach = function(t, e) {
632
632
  var s = this;
633
633
  return e = fe(e), new e(function(r, i) {
634
- var o = new oe({
635
- next: function(a) {
634
+ var a = new ae({
635
+ next: function(o) {
636
636
  try {
637
- t(a);
638
- } catch (u) {
639
- i(u), o.unsubscribe();
637
+ t(o);
638
+ } catch (c) {
639
+ i(c), a.unsubscribe();
640
640
  }
641
641
  },
642
642
  error: i,
643
643
  complete: r
644
644
  });
645
- s.subscribe(o);
645
+ s.subscribe(a);
646
646
  });
647
647
  }, n.prototype._subscribe = function(t) {
648
648
  var e;
@@ -657,10 +657,10 @@ var y = (function() {
657
657
  var e = this;
658
658
  return t = fe(t), new t(function(s, r) {
659
659
  var i;
660
- e.subscribe(function(o) {
661
- return i = o;
662
- }, function(o) {
663
- return r(o);
660
+ e.subscribe(function(a) {
661
+ return i = a;
662
+ }, function(a) {
663
+ return r(a);
664
664
  }, function() {
665
665
  return s(i);
666
666
  });
@@ -671,18 +671,18 @@ var y = (function() {
671
671
  })();
672
672
  function fe(n) {
673
673
  var t;
674
- return (t = n ?? ot.Promise) !== null && t !== void 0 ? t : Promise;
674
+ return (t = n ?? at.Promise) !== null && t !== void 0 ? t : Promise;
675
675
  }
676
676
  function ht(n) {
677
677
  return n && b(n.next) && b(n.error) && b(n.complete);
678
678
  }
679
679
  function ft(n) {
680
- return n && n instanceof ae || ht(n) && Pe(n);
680
+ return n && n instanceof oe || ht(n) && ke(n);
681
681
  }
682
682
  function pt(n) {
683
683
  return b(n?.lift);
684
684
  }
685
- function _(n) {
685
+ function P(n) {
686
686
  return function(t) {
687
687
  if (pt(t))
688
688
  return t.lift(function(e) {
@@ -695,36 +695,36 @@ function _(n) {
695
695
  throw new TypeError("Unable to lift unknown Observable type");
696
696
  };
697
697
  }
698
- function R(n, t, e, s, r) {
699
- return new mt(n, t, e, s, r);
698
+ function N(n, t, e, s, r) {
699
+ return new gt(n, t, e, s, r);
700
700
  }
701
- var mt = (function(n) {
701
+ var gt = (function(n) {
702
702
  O(t, n);
703
- function t(e, s, r, i, o, a) {
704
- var u = n.call(this, e) || this;
705
- return u.onFinalize = o, u.shouldUnsubscribe = a, u._next = s ? function(c) {
703
+ function t(e, s, r, i, a, o) {
704
+ var c = n.call(this, e) || this;
705
+ return c.onFinalize = a, c.shouldUnsubscribe = o, c._next = s ? function(u) {
706
706
  try {
707
- s(c);
708
- } catch (l) {
709
- e.error(l);
707
+ s(u);
708
+ } catch (d) {
709
+ e.error(d);
710
710
  }
711
- } : n.prototype._next, u._error = i ? function(c) {
711
+ } : n.prototype._next, c._error = i ? function(u) {
712
712
  try {
713
- i(c);
714
- } catch (l) {
715
- e.error(l);
713
+ i(u);
714
+ } catch (d) {
715
+ e.error(d);
716
716
  } finally {
717
717
  this.unsubscribe();
718
718
  }
719
- } : n.prototype._error, u._complete = r ? function() {
719
+ } : n.prototype._error, c._complete = r ? function() {
720
720
  try {
721
721
  r();
722
- } catch (c) {
723
- e.error(c);
722
+ } catch (u) {
723
+ e.error(u);
724
724
  } finally {
725
725
  this.unsubscribe();
726
726
  }
727
- } : n.prototype._complete, u;
727
+ } : n.prototype._complete, c;
728
728
  }
729
729
  return t.prototype.unsubscribe = function() {
730
730
  var e;
@@ -733,7 +733,7 @@ var mt = (function(n) {
733
733
  n.prototype.unsubscribe.call(this), !s && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
734
734
  }
735
735
  }, t;
736
- })(ae), gt = Ae(function(n) {
736
+ })(oe), mt = Ae(function(n) {
737
737
  return function() {
738
738
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
739
739
  };
@@ -748,23 +748,23 @@ var mt = (function(n) {
748
748
  return s.operator = e, s;
749
749
  }, t.prototype._throwIfClosed = function() {
750
750
  if (this.closed)
751
- throw new gt();
751
+ throw new mt();
752
752
  }, t.prototype.next = function(e) {
753
753
  var s = this;
754
- X(function() {
754
+ W(function() {
755
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 o = M(s.currentObservers), a = o.next(); !a.done; a = o.next()) {
760
- var u = a.value;
761
- u.next(e);
759
+ for (var a = L(s.currentObservers), o = a.next(); !o.done; o = a.next()) {
760
+ var c = o.value;
761
+ c.next(e);
762
762
  }
763
- } catch (c) {
764
- r = { error: c };
763
+ } catch (u) {
764
+ r = { error: u };
765
765
  } finally {
766
766
  try {
767
- a && !a.done && (i = o.return) && i.call(o);
767
+ o && !o.done && (i = a.return) && i.call(a);
768
768
  } finally {
769
769
  if (r) throw r.error;
770
770
  }
@@ -773,7 +773,7 @@ var mt = (function(n) {
773
773
  });
774
774
  }, t.prototype.error = function(e) {
775
775
  var s = this;
776
- X(function() {
776
+ W(function() {
777
777
  if (s._throwIfClosed(), !s.isStopped) {
778
778
  s.hasError = s.isStopped = !0, s.thrownError = e;
779
779
  for (var r = s.observers; r.length; )
@@ -782,7 +782,7 @@ var mt = (function(n) {
782
782
  });
783
783
  }, t.prototype.complete = function() {
784
784
  var e = this;
785
- X(function() {
785
+ W(function() {
786
786
  if (e._throwIfClosed(), !e.isStopped) {
787
787
  e.isStopped = !0;
788
788
  for (var s = e.observers; s.length; )
@@ -803,20 +803,20 @@ var mt = (function(n) {
803
803
  }, t.prototype._subscribe = function(e) {
804
804
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
805
805
  }, t.prototype._innerSubscribe = function(e) {
806
- var s = this, r = this, i = r.hasError, o = r.isStopped, a = r.observers;
807
- return i || o ? Oe : (this.currentObservers = null, a.push(e), new N(function() {
808
- s.currentObservers = null, V(a, e);
806
+ var s = this, r = this, i = r.hasError, a = r.isStopped, o = r.observers;
807
+ return i || a ? Oe : (this.currentObservers = null, o.push(e), new U(function() {
808
+ s.currentObservers = null, V(o, e);
809
809
  }));
810
810
  }, t.prototype._checkFinalizedStatuses = function(e) {
811
- var s = this, r = s.hasError, i = s.thrownError, o = s.isStopped;
812
- r ? e.error(i) : o && e.complete();
811
+ var s = this, r = s.hasError, i = s.thrownError, a = s.isStopped;
812
+ r ? e.error(i) : a && e.complete();
813
813
  }, t.prototype.asObservable = function() {
814
- var e = new y();
814
+ var e = new w();
815
815
  return e.source = this, e;
816
816
  }, t.create = function(e, s) {
817
817
  return new pe(e, s);
818
818
  }, t;
819
- })(y), pe = (function(n) {
819
+ })(w), pe = (function(n) {
820
820
  O(t, n);
821
821
  function t(e, s) {
822
822
  var r = n.call(this) || this;
@@ -870,7 +870,7 @@ var mt = (function(n) {
870
870
  return t.prototype.schedule = function(e, s) {
871
871
  return this;
872
872
  }, t;
873
- })(N), me = {
873
+ })(U), ge = {
874
874
  setInterval: function(n, t) {
875
875
  for (var e = [], s = 2; s < arguments.length; s++)
876
876
  e[s - 2] = arguments[s];
@@ -891,14 +891,14 @@ var mt = (function(n) {
891
891
  if (s === void 0 && (s = 0), this.closed)
892
892
  return this;
893
893
  this.state = e;
894
- var i = this.id, 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;
894
+ var i = this.id, a = this.scheduler;
895
+ return i != null && (this.id = this.recycleAsyncId(a, i, s)), this.pending = !0, this.delay = s, this.id = (r = this.id) !== null && r !== void 0 ? r : this.requestAsyncId(a, this.id, s), this;
896
896
  }, t.prototype.requestAsyncId = function(e, s, r) {
897
- return r === void 0 && (r = 0), me.setInterval(e.flush.bind(e, this), r);
897
+ return r === void 0 && (r = 0), ge.setInterval(e.flush.bind(e, this), r);
898
898
  }, t.prototype.recycleAsyncId = function(e, s, r) {
899
899
  if (r === void 0 && (r = 0), r != null && this.delay === r && this.pending === !1)
900
900
  return s;
901
- s != null && me.clearInterval(s);
901
+ s != null && ge.clearInterval(s);
902
902
  }, t.prototype.execute = function(e, s) {
903
903
  if (this.closed)
904
904
  return new Error("executing a cancelled action");
@@ -911,8 +911,8 @@ var mt = (function(n) {
911
911
  var r = !1, i;
912
912
  try {
913
913
  this.work(e);
914
- } catch (o) {
915
- r = !0, i = o || new Error("Scheduled action threw falsy error");
914
+ } catch (a) {
915
+ r = !0, i = a || new Error("Scheduled action threw falsy error");
916
916
  }
917
917
  if (r)
918
918
  return this.unsubscribe(), i;
@@ -922,7 +922,7 @@ var mt = (function(n) {
922
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
- })(vt), ge = (function() {
925
+ })(vt), me = (function() {
926
926
  function n(t, e) {
927
927
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
928
928
  }
@@ -932,7 +932,7 @@ var mt = (function(n) {
932
932
  })(), yt = (function(n) {
933
933
  O(t, n);
934
934
  function t(e, s) {
935
- s === void 0 && (s = ge.now);
935
+ s === void 0 && (s = me.now);
936
936
  var r = n.call(this, e, s) || this;
937
937
  return r.actions = [], r._active = !1, r;
938
938
  }
@@ -954,62 +954,62 @@ var mt = (function(n) {
954
954
  throw r;
955
955
  }
956
956
  }, t;
957
- })(ge), wt = new yt(St);
957
+ })(me), wt = new yt(St);
958
958
  function Et(n) {
959
959
  return n && b(n.schedule);
960
960
  }
961
- function Le(n) {
961
+ function _e(n) {
962
962
  return n[n.length - 1];
963
963
  }
964
964
  function It(n) {
965
- return b(Le(n)) ? n.pop() : void 0;
965
+ return b(_e(n)) ? n.pop() : void 0;
966
966
  }
967
- function Ue(n) {
968
- return Et(Le(n)) ? n.pop() : void 0;
967
+ function Me(n) {
968
+ return Et(_e(n)) ? n.pop() : void 0;
969
969
  }
970
- var Me = (function(n) {
970
+ var Le = (function(n) {
971
971
  return n && typeof n.length == "number" && typeof n != "function";
972
972
  });
973
- function Ne(n) {
973
+ function Ue(n) {
974
974
  return b(n?.then);
975
975
  }
976
- function Re(n) {
976
+ function Ne(n) {
977
977
  return b(n[ce]);
978
978
  }
979
- function ke(n) {
979
+ function Re(n) {
980
980
  return Symbol.asyncIterator && b(n?.[Symbol.asyncIterator]);
981
981
  }
982
- function je(n) {
982
+ function Fe(n) {
983
983
  return new TypeError("You provided " + (n !== null && typeof n == "object" ? "an invalid object" : "'" + n + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
984
984
  }
985
985
  function Tt() {
986
986
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
987
987
  }
988
- var $e = Tt();
989
- function De(n) {
990
- return b(n?.[$e]);
988
+ var je = Tt();
989
+ function $e(n) {
990
+ return b(n?.[je]);
991
991
  }
992
- function He(n) {
992
+ function De(n) {
993
993
  return rt(this, arguments, function() {
994
994
  var e, s, r, i;
995
- return xe(this, function(o) {
996
- switch (o.label) {
995
+ return xe(this, function(a) {
996
+ switch (a.label) {
997
997
  case 0:
998
- e = n.getReader(), o.label = 1;
998
+ e = n.getReader(), a.label = 1;
999
999
  case 1:
1000
- o.trys.push([1, , 9, 10]), o.label = 2;
1000
+ a.trys.push([1, , 9, 10]), a.label = 2;
1001
1001
  case 2:
1002
- return [4, H(e.read())];
1002
+ return [4, D(e.read())];
1003
1003
  case 3:
1004
- return s = o.sent(), r = s.value, i = s.done, i ? [4, H(void 0)] : [3, 5];
1004
+ return s = a.sent(), r = s.value, i = s.done, i ? [4, D(void 0)] : [3, 5];
1005
1005
  case 4:
1006
- return [2, o.sent()];
1006
+ return [2, a.sent()];
1007
1007
  case 5:
1008
- return [4, H(r)];
1008
+ return [4, D(r)];
1009
1009
  case 6:
1010
- return [4, o.sent()];
1010
+ return [4, a.sent()];
1011
1011
  case 7:
1012
- return o.sent(), [3, 2];
1012
+ return a.sent(), [3, 2];
1013
1013
  case 8:
1014
1014
  return [3, 10];
1015
1015
  case 9:
@@ -1020,30 +1020,30 @@ function He(n) {
1020
1020
  });
1021
1021
  });
1022
1022
  }
1023
- function Fe(n) {
1023
+ function Be(n) {
1024
1024
  return b(n?.getReader);
1025
1025
  }
1026
1026
  function J(n) {
1027
- if (n instanceof y)
1027
+ if (n instanceof w)
1028
1028
  return n;
1029
1029
  if (n != null) {
1030
- if (Re(n))
1030
+ if (Ne(n))
1031
1031
  return Ct(n);
1032
- if (Me(n))
1032
+ if (Le(n))
1033
1033
  return xt(n);
1034
- if (Ne(n))
1034
+ if (Ue(n))
1035
1035
  return At(n);
1036
- if (ke(n))
1037
- return Be(n);
1038
- if (De(n))
1036
+ if (Re(n))
1037
+ return He(n);
1038
+ if ($e(n))
1039
1039
  return Ot(n);
1040
- if (Fe(n))
1041
- return Pt(n);
1040
+ if (Be(n))
1041
+ return kt(n);
1042
1042
  }
1043
- throw je(n);
1043
+ throw Fe(n);
1044
1044
  }
1045
1045
  function Ct(n) {
1046
- return new y(function(t) {
1046
+ return new w(function(t) {
1047
1047
  var e = n[ce]();
1048
1048
  if (b(e.subscribe))
1049
1049
  return e.subscribe(t);
@@ -1051,32 +1051,32 @@ function Ct(n) {
1051
1051
  });
1052
1052
  }
1053
1053
  function xt(n) {
1054
- return new y(function(t) {
1054
+ return new w(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 At(n) {
1061
- return new y(function(t) {
1061
+ return new w(function(t) {
1062
1062
  n.then(function(e) {
1063
1063
  t.closed || (t.next(e), t.complete());
1064
1064
  }, function(e) {
1065
1065
  return t.error(e);
1066
- }).then(null, _e);
1066
+ }).then(null, Pe);
1067
1067
  });
1068
1068
  }
1069
1069
  function Ot(n) {
1070
- return new y(function(t) {
1070
+ return new w(function(t) {
1071
1071
  var e, s;
1072
1072
  try {
1073
- for (var r = M(n), i = r.next(); !i.done; i = r.next()) {
1074
- var o = i.value;
1075
- if (t.next(o), t.closed)
1073
+ for (var r = L(n), i = r.next(); !i.done; i = r.next()) {
1074
+ var a = i.value;
1075
+ if (t.next(a), t.closed)
1076
1076
  return;
1077
1077
  }
1078
- } catch (a) {
1079
- e = { error: a };
1078
+ } catch (o) {
1079
+ e = { error: o };
1080
1080
  } finally {
1081
1081
  try {
1082
1082
  i && !i.done && (s = r.return) && s.call(r);
@@ -1087,41 +1087,41 @@ function Ot(n) {
1087
1087
  t.complete();
1088
1088
  });
1089
1089
  }
1090
- function Be(n) {
1091
- return new y(function(t) {
1092
- _t(n, t).catch(function(e) {
1090
+ function He(n) {
1091
+ return new w(function(t) {
1092
+ Pt(n, t).catch(function(e) {
1093
1093
  return t.error(e);
1094
1094
  });
1095
1095
  });
1096
1096
  }
1097
- function Pt(n) {
1098
- return Be(He(n));
1097
+ function kt(n) {
1098
+ return He(De(n));
1099
1099
  }
1100
- function _t(n, t) {
1100
+ function Pt(n, t) {
1101
1101
  var e, s, r, i;
1102
1102
  return st(this, void 0, void 0, function() {
1103
- var o, a;
1104
- return xe(this, function(u) {
1105
- switch (u.label) {
1103
+ var a, o;
1104
+ return xe(this, function(c) {
1105
+ switch (c.label) {
1106
1106
  case 0:
1107
- u.trys.push([0, 5, 6, 11]), e = it(n), u.label = 1;
1107
+ c.trys.push([0, 5, 6, 11]), e = it(n), c.label = 1;
1108
1108
  case 1:
1109
1109
  return [4, e.next()];
1110
1110
  case 2:
1111
- if (s = u.sent(), !!s.done) return [3, 4];
1112
- if (o = s.value, t.next(o), t.closed)
1111
+ if (s = c.sent(), !!s.done) return [3, 4];
1112
+ if (a = s.value, t.next(a), t.closed)
1113
1113
  return [2];
1114
- u.label = 3;
1114
+ c.label = 3;
1115
1115
  case 3:
1116
1116
  return [3, 1];
1117
1117
  case 4:
1118
1118
  return [3, 11];
1119
1119
  case 5:
1120
- return a = u.sent(), r = { error: a }, [3, 11];
1120
+ return o = c.sent(), r = { error: o }, [3, 11];
1121
1121
  case 6:
1122
- return u.trys.push([6, , 9, 10]), s && !s.done && (i = e.return) ? [4, i.call(e)] : [3, 8];
1122
+ return c.trys.push([6, , 9, 10]), s && !s.done && (i = e.return) ? [4, i.call(e)] : [3, 8];
1123
1123
  case 7:
1124
- u.sent(), u.label = 8;
1124
+ c.sent(), c.label = 8;
1125
1125
  case 8:
1126
1126
  return [3, 10];
1127
1127
  case 9:
@@ -1144,8 +1144,8 @@ function T(n, t, e, s, r) {
1144
1144
  return i;
1145
1145
  }
1146
1146
  function Ge(n, t) {
1147
- return t === void 0 && (t = 0), _(function(e, s) {
1148
- e.subscribe(R(s, function(r) {
1147
+ return t === void 0 && (t = 0), P(function(e, s) {
1148
+ e.subscribe(N(s, function(r) {
1149
1149
  return T(s, n, function() {
1150
1150
  return s.next(r);
1151
1151
  }, t);
@@ -1161,39 +1161,39 @@ function Ge(n, t) {
1161
1161
  });
1162
1162
  }
1163
1163
  function qe(n, t) {
1164
- return t === void 0 && (t = 0), _(function(e, s) {
1164
+ return t === void 0 && (t = 0), P(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 Lt(n, t) {
1170
+ function _t(n, t) {
1171
1171
  return J(n).pipe(qe(t), Ge(t));
1172
1172
  }
1173
- function Ut(n, t) {
1173
+ function Mt(n, t) {
1174
1174
  return J(n).pipe(qe(t), Ge(t));
1175
1175
  }
1176
- function Mt(n, t) {
1177
- return new y(function(e) {
1176
+ function Lt(n, t) {
1177
+ return new w(function(e) {
1178
1178
  var s = 0;
1179
1179
  return t.schedule(function() {
1180
1180
  s === n.length ? e.complete() : (e.next(n[s++]), e.closed || this.schedule());
1181
1181
  });
1182
1182
  });
1183
1183
  }
1184
- function Nt(n, t) {
1185
- return new y(function(e) {
1184
+ function Ut(n, t) {
1185
+ return new w(function(e) {
1186
1186
  var s;
1187
1187
  return T(e, t, function() {
1188
- s = n[$e](), T(e, t, function() {
1189
- var r, i, o;
1188
+ s = n[je](), T(e, t, function() {
1189
+ var r, i, a;
1190
1190
  try {
1191
- r = s.next(), i = r.value, o = r.done;
1192
- } catch (a) {
1193
- e.error(a);
1191
+ r = s.next(), i = r.value, a = r.done;
1192
+ } catch (o) {
1193
+ e.error(o);
1194
1194
  return;
1195
1195
  }
1196
- o ? e.complete() : e.next(i);
1196
+ a ? e.complete() : e.next(i);
1197
1197
  }, 0, !0);
1198
1198
  }), function() {
1199
1199
  return b(s?.return) && s.return();
@@ -1203,7 +1203,7 @@ function Nt(n, t) {
1203
1203
  function Ke(n, t) {
1204
1204
  if (!n)
1205
1205
  throw new Error("Iterable cannot be null");
1206
- return new y(function(e) {
1206
+ return new w(function(e) {
1207
1207
  T(e, t, function() {
1208
1208
  var s = n[Symbol.asyncIterator]();
1209
1209
  T(e, t, function() {
@@ -1214,51 +1214,51 @@ function Ke(n, t) {
1214
1214
  });
1215
1215
  });
1216
1216
  }
1217
- function Rt(n, t) {
1218
- return Ke(He(n), t);
1217
+ function Nt(n, t) {
1218
+ return Ke(De(n), t);
1219
1219
  }
1220
- function kt(n, t) {
1220
+ function Rt(n, t) {
1221
1221
  if (n != null) {
1222
- if (Re(n))
1222
+ if (Ne(n))
1223
+ return _t(n, t);
1224
+ if (Le(n))
1223
1225
  return Lt(n, t);
1224
- if (Me(n))
1226
+ if (Ue(n))
1225
1227
  return Mt(n, t);
1226
- if (Ne(n))
1227
- return Ut(n, t);
1228
- if (ke(n))
1228
+ if (Re(n))
1229
1229
  return Ke(n, t);
1230
- if (De(n))
1230
+ if ($e(n))
1231
+ return Ut(n, t);
1232
+ if (Be(n))
1231
1233
  return Nt(n, t);
1232
- if (Fe(n))
1233
- return Rt(n, t);
1234
1234
  }
1235
- throw je(n);
1235
+ throw Fe(n);
1236
1236
  }
1237
1237
  function Ve(n, t) {
1238
- return t ? kt(n, t) : J(n);
1238
+ return t ? Rt(n, t) : J(n);
1239
1239
  }
1240
1240
  function Y(n, t) {
1241
- return _(function(e, s) {
1241
+ return P(function(e, s) {
1242
1242
  var r = 0;
1243
- e.subscribe(R(s, function(i) {
1243
+ e.subscribe(N(s, function(i) {
1244
1244
  s.next(n.call(t, i, r++));
1245
1245
  }));
1246
1246
  });
1247
1247
  }
1248
- var jt = Array.isArray;
1249
- function $t(n, t) {
1250
- return jt(t) ? n.apply(void 0, K([], q(t))) : n(t);
1248
+ var Ft = Array.isArray;
1249
+ function jt(n, t) {
1250
+ return Ft(t) ? n.apply(void 0, K([], q(t))) : n(t);
1251
1251
  }
1252
- function Dt(n) {
1252
+ function $t(n) {
1253
1253
  return Y(function(t) {
1254
- return $t(n, t);
1254
+ return jt(n, t);
1255
1255
  });
1256
1256
  }
1257
- var Ht = Array.isArray, Ft = Object.getPrototypeOf, Bt = Object.prototype, Gt = Object.keys;
1257
+ var Dt = Array.isArray, Bt = Object.getPrototypeOf, Ht = Object.prototype, Gt = Object.keys;
1258
1258
  function qt(n) {
1259
1259
  if (n.length === 1) {
1260
1260
  var t = n[0];
1261
- if (Ht(t))
1261
+ if (Dt(t))
1262
1262
  return { args: t, keys: null };
1263
1263
  if (Kt(t)) {
1264
1264
  var e = Gt(t);
@@ -1273,38 +1273,38 @@ function qt(n) {
1273
1273
  return { args: n, keys: null };
1274
1274
  }
1275
1275
  function Kt(n) {
1276
- return n && typeof n == "object" && Ft(n) === Bt;
1276
+ return n && typeof n == "object" && Bt(n) === Ht;
1277
1277
  }
1278
1278
  function Vt(n, t) {
1279
1279
  return n.reduce(function(e, s, r) {
1280
1280
  return e[s] = t[r], e;
1281
1281
  }, {});
1282
1282
  }
1283
- function Wt() {
1283
+ function Xt() {
1284
1284
  for (var n = [], t = 0; t < arguments.length; t++)
1285
1285
  n[t] = arguments[t];
1286
- var e = Ue(n), s = It(n), r = qt(n), i = r.args, o = r.keys;
1286
+ var e = Me(n), s = It(n), r = qt(n), i = r.args, a = r.keys;
1287
1287
  if (i.length === 0)
1288
1288
  return Ve([], e);
1289
- var a = new y(Xt(i, e, o ? function(u) {
1290
- return Vt(o, u);
1289
+ var o = new w(Wt(i, e, a ? function(c) {
1290
+ return Vt(a, c);
1291
1291
  } : z));
1292
- return s ? a.pipe(Dt(s)) : a;
1292
+ return s ? o.pipe($t(s)) : o;
1293
1293
  }
1294
- function Xt(n, t, e) {
1294
+ function Wt(n, t, e) {
1295
1295
  return e === void 0 && (e = z), function(s) {
1296
1296
  be(t, function() {
1297
- for (var r = n.length, i = new Array(r), o = r, a = r, u = function(l) {
1297
+ for (var r = n.length, i = new Array(r), a = r, o = r, c = function(d) {
1298
1298
  be(t, function() {
1299
- var m = Ve(n[l], t), v = !1;
1300
- m.subscribe(R(s, function(h) {
1301
- i[l] = h, v || (v = !0, a--), a || s.next(e(i.slice()));
1299
+ var m = Ve(n[d], t), v = !1;
1300
+ m.subscribe(N(s, function(h) {
1301
+ i[d] = h, v || (v = !0, o--), o || s.next(e(i.slice()));
1302
1302
  }, function() {
1303
- --o || s.complete();
1303
+ --a || s.complete();
1304
1304
  }));
1305
1305
  }, s);
1306
- }, c = 0; c < r; c++)
1307
- u(c);
1306
+ }, u = 0; u < r; u++)
1307
+ c(u);
1308
1308
  }, s);
1309
1309
  };
1310
1310
  }
@@ -1312,9 +1312,9 @@ function be(n, t, e) {
1312
1312
  n ? T(e, n, t) : t();
1313
1313
  }
1314
1314
  function Yt(n, t) {
1315
- return _(function(e, s) {
1315
+ return P(function(e, s) {
1316
1316
  var r = 0;
1317
- e.subscribe(R(s, function(i) {
1317
+ e.subscribe(N(s, function(i) {
1318
1318
  return n.call(t, i, r++) && s.next(i);
1319
1319
  }));
1320
1320
  });
@@ -1322,57 +1322,57 @@ function Yt(n, t) {
1322
1322
  function zt(n) {
1323
1323
  for (var t, e, s = [], r = 1; r < arguments.length; r++)
1324
1324
  s[r - 1] = arguments[r];
1325
- var i = (t = Ue(s)) !== null && t !== void 0 ? t : wt, o = (e = s[0]) !== null && e !== void 0 ? e : null, a = s[1] || 1 / 0;
1326
- return _(function(u, c) {
1327
- var l = [], m = !1, v = function(f) {
1328
- var I = f.buffer, w = f.subs;
1329
- w.unsubscribe(), V(l, f), c.next(I), m && h();
1325
+ var i = (t = Me(s)) !== null && t !== void 0 ? t : wt, a = (e = s[0]) !== null && e !== void 0 ? e : null, o = s[1] || 1 / 0;
1326
+ return P(function(c, u) {
1327
+ var d = [], m = !1, v = function(f) {
1328
+ var I = f.buffer, E = f.subs;
1329
+ E.unsubscribe(), V(d, f), u.next(I), m && h();
1330
1330
  }, h = function() {
1331
- if (l) {
1332
- var f = new N();
1333
- c.add(f);
1334
- var I = [], w = {
1331
+ if (d) {
1332
+ var f = new U();
1333
+ u.add(f);
1334
+ var I = [], E = {
1335
1335
  buffer: I,
1336
1336
  subs: f
1337
1337
  };
1338
- l.push(w), T(f, i, function() {
1339
- return v(w);
1338
+ d.push(E), T(f, i, function() {
1339
+ return v(E);
1340
1340
  }, n);
1341
1341
  }
1342
1342
  };
1343
- o !== null && o >= 0 ? T(c, i, h, o, !0) : m = !0, h();
1344
- var p = R(c, function(f) {
1345
- var I, w, F = l.slice();
1343
+ a !== null && a >= 0 ? T(u, i, h, a, !0) : m = !0, h();
1344
+ var p = N(u, function(f) {
1345
+ var I, E, B = d.slice();
1346
1346
  try {
1347
- for (var k = M(F), L = k.next(); !L.done; L = k.next()) {
1348
- var j = L.value, $ = j.buffer;
1349
- $.push(f), a <= $.length && v(j);
1347
+ for (var R = L(B), _ = R.next(); !_.done; _ = R.next()) {
1348
+ var F = _.value, j = F.buffer;
1349
+ j.push(f), o <= j.length && v(F);
1350
1350
  }
1351
- } catch (D) {
1352
- I = { error: D };
1351
+ } catch ($) {
1352
+ I = { error: $ };
1353
1353
  } finally {
1354
1354
  try {
1355
- L && !L.done && (w = k.return) && w.call(k);
1355
+ _ && !_.done && (E = R.return) && E.call(R);
1356
1356
  } finally {
1357
1357
  if (I) throw I.error;
1358
1358
  }
1359
1359
  }
1360
1360
  }, function() {
1361
- for (; l?.length; )
1362
- c.next(l.shift().buffer);
1363
- p?.unsubscribe(), c.complete(), c.unsubscribe();
1361
+ for (; d?.length; )
1362
+ u.next(d.shift().buffer);
1363
+ p?.unsubscribe(), u.complete(), u.unsubscribe();
1364
1364
  }, void 0, function() {
1365
- return l = null;
1365
+ return d = null;
1366
1366
  });
1367
- u.subscribe(p);
1367
+ c.subscribe(p);
1368
1368
  });
1369
1369
  }
1370
- function U(n, t) {
1371
- return t === void 0 && (t = z), n = n ?? Jt, _(function(e, s) {
1370
+ function M(n, t) {
1371
+ return t === void 0 && (t = z), n = n ?? Jt, P(function(e, s) {
1372
1372
  var r, i = !0;
1373
- e.subscribe(R(s, function(o) {
1374
- var a = t(o);
1375
- (i || !n(r, a)) && (i = !1, r = a, s.next(o));
1373
+ e.subscribe(N(s, function(a) {
1374
+ var o = t(a);
1375
+ (i || !n(r, o)) && (i = !1, r = o, s.next(a));
1376
1376
  }));
1377
1377
  });
1378
1378
  }
@@ -1380,7 +1380,7 @@ function Jt(n, t) {
1380
1380
  return n === t;
1381
1381
  }
1382
1382
  function Qt(n) {
1383
- return _(function(t, e) {
1383
+ return P(function(t, e) {
1384
1384
  try {
1385
1385
  t.subscribe(e);
1386
1386
  } finally {
@@ -1389,17 +1389,17 @@ function Qt(n) {
1389
1389
  });
1390
1390
  }
1391
1391
  function Zt(n) {
1392
- return _(function(t, e) {
1393
- J(n).subscribe(R(e, function() {
1392
+ return P(function(t, e) {
1393
+ J(n).subscribe(N(e, function() {
1394
1394
  return e.complete();
1395
1395
  }, ie)), !e.closed && t.subscribe(e);
1396
1396
  });
1397
1397
  }
1398
1398
  function ve(n) {
1399
- const { endpoint: t, apiKey: e, payload: s, debugMode: r, customHeaders: i } = n, o = n.method ?? "POST";
1400
- return new y((a) => {
1401
- const u = new AbortController();
1402
- let c, l = !1, m = !1;
1399
+ const { endpoint: t, apiKey: e, payload: s, debugMode: r, customHeaders: i } = n, a = n.method ?? "POST";
1400
+ return new w((o) => {
1401
+ const c = new AbortController();
1402
+ let u, d = !1, m = !1;
1403
1403
  const v = {
1404
1404
  "Content-Type": "application/json",
1405
1405
  ...i
@@ -1407,10 +1407,10 @@ function ve(n) {
1407
1407
  e && (v["X-API-KEY"] = e);
1408
1408
  const h = new URL(t);
1409
1409
  return r && h.searchParams.set("is_debug", "true"), Ce(h.toString(), {
1410
- method: o,
1410
+ method: a,
1411
1411
  headers: v,
1412
- body: o === "POST" && s ? JSON.stringify(s) : void 0,
1413
- signal: u.signal,
1412
+ body: a === "POST" && s ? JSON.stringify(s) : void 0,
1413
+ signal: c.signal,
1414
1414
  /**
1415
1415
  * Allow SSE to work when the page is hidden.
1416
1416
  * https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
@@ -1418,7 +1418,7 @@ function ve(n) {
1418
1418
  openWhenHidden: !0,
1419
1419
  onopen: async (p) => {
1420
1420
  if (p.ok)
1421
- c = p.headers.get("X-Trace-Id") ?? void 0;
1421
+ u = p.headers.get("X-Trace-Id") ?? void 0;
1422
1422
  else {
1423
1423
  let f;
1424
1424
  try {
@@ -1430,24 +1430,24 @@ function ve(n) {
1430
1430
  f = null;
1431
1431
  }
1432
1432
  }
1433
- a.error(new E(p.status, p.statusText, f)), u.abort();
1433
+ o.error(new y(p.status, p.statusText, f)), c.abort();
1434
1434
  }
1435
1435
  },
1436
1436
  onmessage: (p) => {
1437
- p.id && (l = !0);
1437
+ p.id && (d = !0);
1438
1438
  const f = JSON.parse(p.data);
1439
- c ? f.traceId = c : f.requestId && (f.traceId = f.requestId, c || (c = f.requestId)), a.next(f);
1439
+ u ? f.traceId = u : f.requestId && (f.traceId = f.requestId, u || (u = f.requestId)), o.next(f);
1440
1440
  },
1441
1441
  onclose: () => {
1442
- a.complete();
1442
+ o.complete();
1443
1443
  },
1444
1444
  onerror: (p) => {
1445
1445
  if (m) throw p;
1446
- if (!l)
1447
- throw a.error(p), u.abort(), p;
1446
+ if (!d)
1447
+ throw o.error(p), c.abort(), p;
1448
1448
  }
1449
1449
  }), () => {
1450
- m = !0, u.abort();
1450
+ m = !0, c.abort();
1451
1451
  };
1452
1452
  });
1453
1453
  }
@@ -1502,33 +1502,33 @@ class _n {
1502
1502
  }
1503
1503
  handleEvent(t) {
1504
1504
  switch (t.eventType) {
1505
- case d.INIT:
1506
- this.sseEmitter.emit(d.INIT, t);
1505
+ case l.INIT:
1506
+ this.sseEmitter.emit(l.INIT, t);
1507
1507
  break;
1508
- case d.PROCESS_START:
1509
- case d.PROCESS_COMPLETE:
1510
- this.sseEmitter.emit(d.PROCESS, t);
1508
+ case l.PROCESS_START:
1509
+ case l.PROCESS_COMPLETE:
1510
+ this.sseEmitter.emit(l.PROCESS, t);
1511
1511
  break;
1512
- case d.MESSAGE_START:
1513
- case d.MESSAGE_DELTA:
1514
- case d.MESSAGE_COMPLETE:
1515
- this.sseEmitter.emit(d.MESSAGE, t);
1512
+ case l.MESSAGE_START:
1513
+ case l.MESSAGE_DELTA:
1514
+ case l.MESSAGE_COMPLETE:
1515
+ this.sseEmitter.emit(l.MESSAGE, t);
1516
1516
  break;
1517
- case d.TOOL_CALL_START:
1518
- case d.TOOL_CALL_COMPLETE:
1519
- this.sseEmitter.emit(d.TOOL_CALL, t);
1517
+ case l.TOOL_CALL_START:
1518
+ case l.TOOL_CALL_COMPLETE:
1519
+ this.sseEmitter.emit(l.TOOL_CALL, t);
1520
1520
  break;
1521
- case d.TOOL_CALL_CONSENT:
1521
+ case l.TOOL_CALL_CONSENT:
1522
1522
  this.sseEmitter.emit(
1523
- d.TOOL_CALL_CONSENT,
1523
+ l.TOOL_CALL_CONSENT,
1524
1524
  t
1525
1525
  );
1526
1526
  break;
1527
- case d.DONE:
1528
- this.sseEmitter.emit(d.DONE, t);
1527
+ case l.DONE:
1528
+ this.sseEmitter.emit(l.DONE, t);
1529
1529
  break;
1530
- case d.ERROR:
1531
- this.sseEmitter.emit(d.ERROR, t);
1530
+ case l.ERROR:
1531
+ this.sseEmitter.emit(l.ERROR, t);
1532
1532
  break;
1533
1533
  }
1534
1534
  }
@@ -1585,21 +1585,21 @@ class _n {
1585
1585
  if (i.status === 404)
1586
1586
  return null;
1587
1587
  if (!i.ok)
1588
- throw new E(i.status, i.statusText, await i.text().catch(() => {
1588
+ throw new y(i.status, i.statusText, await i.text().catch(() => {
1589
1589
  }));
1590
- const o = await i.json(), a = o.data ?? o;
1590
+ const a = await i.json(), o = a.data ?? a;
1591
1591
  return {
1592
- title: a.title ?? null,
1593
- runState: a.runState ?? "IDLE",
1594
- lastActivityAt: a.lastActivityAt,
1592
+ title: o.title ?? null,
1593
+ runState: o.runState ?? "IDLE",
1594
+ lastActivityAt: o.lastActivityAt,
1595
1595
  // F-019 — whitelist-pass the live-sandbox list (map the five backend fields); `[]` for an old
1596
1596
  // backend / a channel with none live. metadata is the sole authority on "who is live".
1597
- launchedSandboxes: (a.launchedSandboxes ?? []).map((u) => ({
1598
- sandboxName: u.sandboxName,
1599
- sandboxBlueprintName: u.sandboxBlueprintName,
1600
- workingDirectory: u.workingDirectory,
1601
- editorServerEnabled: u.editorServerEnabled,
1602
- browserEnabled: u.browserEnabled
1597
+ launchedSandboxes: (o.launchedSandboxes ?? []).map((c) => ({
1598
+ sandboxName: c.sandboxName,
1599
+ sandboxBlueprintName: c.sandboxBlueprintName,
1600
+ workingDirectory: c.workingDirectory,
1601
+ editorServerEnabled: c.editorServerEnabled,
1602
+ browserEnabled: c.browserEnabled
1603
1603
  }))
1604
1604
  };
1605
1605
  }
@@ -1631,7 +1631,7 @@ class _n {
1631
1631
  r.searchParams.set("custom_channel_id", t), e?.requestId && r.searchParams.set("request_id", e.requestId), e?.force && r.searchParams.set("force", "true");
1632
1632
  const i = await fetch(r.toString(), { method: "POST", headers: this.apiHeaders() });
1633
1633
  if (!(i.ok || i.status === 404))
1634
- throw new E(i.status, i.statusText, await i.text().catch(() => {
1634
+ throw new y(i.status, i.statusText, await i.text().catch(() => {
1635
1635
  }));
1636
1636
  }
1637
1637
  deriveChannelEndpoint() {
@@ -1662,9 +1662,44 @@ class _n {
1662
1662
  s.searchParams.set("custom_channel_id", t);
1663
1663
  const r = await fetch(s.toString(), { method: "DELETE", headers: this.apiHeaders() });
1664
1664
  if (!r.ok)
1665
- throw new E(r.status, r.statusText, await r.text().catch(() => {
1665
+ throw new y(r.status, r.statusText, await r.text().catch(() => {
1666
1666
  }));
1667
1667
  }
1668
+ deriveFeedbackEndpoint() {
1669
+ const t = this.getBaseEndpoint();
1670
+ return t ? `${t}/message/feedback` : null;
1671
+ }
1672
+ /**
1673
+ * Rate one assistant reply Good or Bad (F-033): `POST {base}/message/feedback` with
1674
+ * `{ customChannelId, messageId, verdict, comment? }`. Derived from `botProviderEndpoint` exactly like
1675
+ * `/message/sse`, because every product relay exposes it at that same shape.
1676
+ *
1677
+ * Resolves to `{ messageId, seq }` — the persisted entry's own id and transcript cursor — on any 2xx
1678
+ * (the relays wrap it in a `{ data }` envelope; a bare body is accepted too). `404` means the target is
1679
+ * not a ratable reply (a thinking block, the user's own message, an unknown id), `400` a bad verdict
1680
+ * or a comment over 8 KiB; both, like any other failure, reject with {@link HttpError}. Nothing is
1681
+ * retried: the caller decides whether to offer another attempt, with the user's comment intact.
1682
+ */
1683
+ async sendMessageFeedback(t) {
1684
+ const e = this.deriveFeedbackEndpoint();
1685
+ if (!e)
1686
+ throw new Error("Unable to derive message feedback endpoint. Please provide botProviderEndpoint in config.");
1687
+ const s = t.comment?.trim(), r = {
1688
+ customChannelId: t.customChannelId,
1689
+ messageId: t.messageId,
1690
+ verdict: t.verdict,
1691
+ ...s ? { comment: s } : {}
1692
+ }, i = await fetch(e, {
1693
+ method: "POST",
1694
+ headers: { ...this.apiHeaders(), "Content-Type": "application/json" },
1695
+ body: JSON.stringify(r)
1696
+ });
1697
+ if (!i.ok)
1698
+ throw new y(i.status, i.statusText, await i.text().catch(() => {
1699
+ }));
1700
+ const a = await i.json(), o = a.data ?? a;
1701
+ return { messageId: o.messageId, seq: o.seq };
1702
+ }
1668
1703
  runSse(t, e) {
1669
1704
  return t.pipe(
1670
1705
  // No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
@@ -1748,17 +1783,17 @@ class _n {
1748
1783
  };
1749
1784
  this.apiKey && (i["X-API-KEY"] = this.apiKey);
1750
1785
  try {
1751
- const o = await fetch(s, {
1786
+ const a = await fetch(s, {
1752
1787
  method: "POST",
1753
1788
  headers: i,
1754
1789
  body: r
1755
1790
  });
1756
- if (!o.ok)
1757
- throw new Error(`Upload failed: ${o.status} ${o.statusText}`);
1758
- const a = await o.json();
1759
- return this.debugMode && console.log("[AsgardServiceClient] File upload response:", a), a;
1760
- } catch (o) {
1761
- throw console.error("[AsgardServiceClient] File upload error:", o), o;
1791
+ if (!a.ok)
1792
+ throw new Error(`Upload failed: ${a.status} ${a.statusText}`);
1793
+ const o = await a.json();
1794
+ return this.debugMode && console.log("[AsgardServiceClient] File upload response:", o), o;
1795
+ } catch (a) {
1796
+ throw console.error("[AsgardServiceClient] File upload error:", a), a;
1762
1797
  }
1763
1798
  }
1764
1799
  /**
@@ -1769,21 +1804,21 @@ class _n {
1769
1804
  const s = this.getBaseEndpoint();
1770
1805
  if (!s)
1771
1806
  throw new Error("Unable to derive channel-home download endpoint. Please provide botProviderEndpoint in config.");
1772
- const r = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`, i = `${s}/channel-home/download?${r}`, o = {
1807
+ const r = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`, i = `${s}/channel-home/download?${r}`, a = {
1773
1808
  ...this.customHeaders
1774
1809
  };
1775
- this.apiKey && (o["X-API-KEY"] = this.apiKey);
1810
+ this.apiKey && (a["X-API-KEY"] = this.apiKey);
1776
1811
  try {
1777
- const a = await fetch(i, {
1812
+ const o = await fetch(i, {
1778
1813
  method: "GET",
1779
- headers: o
1814
+ headers: a
1780
1815
  });
1781
- if (!a.ok)
1782
- throw new Error(`Channel Home download failed: ${a.status} ${a.statusText}`);
1783
- const u = await a.blob(), c = t.split("/").pop() || "download";
1784
- return this.debugMode && console.log("[AsgardServiceClient] Channel Home download response:", { filename: c, size: u.size }), { blob: u, filename: c };
1785
- } catch (a) {
1786
- throw console.error("[AsgardServiceClient] Channel Home download error:", a), a;
1816
+ if (!o.ok)
1817
+ throw new Error(`Channel Home download failed: ${o.status} ${o.statusText}`);
1818
+ const c = await o.blob(), u = t.split("/").pop() || "download";
1819
+ return this.debugMode && console.log("[AsgardServiceClient] Channel Home download response:", { filename: u, size: c.size }), { blob: c, filename: u };
1820
+ } catch (o) {
1821
+ throw console.error("[AsgardServiceClient] Channel Home download error:", o), o;
1787
1822
  }
1788
1823
  }
1789
1824
  /**
@@ -1802,12 +1837,12 @@ class _n {
1802
1837
  this.apiKey && (r["X-API-KEY"] = this.apiKey);
1803
1838
  const i = await fetch(s, { method: "POST", headers: r });
1804
1839
  if (!i.ok)
1805
- throw new E(i.status, i.statusText, await i.text().catch(() => {
1840
+ throw new y(i.status, i.statusText, await i.text().catch(() => {
1806
1841
  }));
1807
- const o = await i.json(), a = o.data?.openURL ?? o.openURL;
1808
- if (!a)
1842
+ const a = await i.json(), o = a.data?.openURL ?? a.openURL;
1843
+ if (!o)
1809
1844
  throw new Error("Sandbox browser open-url response did not contain an openURL.");
1810
- return a;
1845
+ return o;
1811
1846
  }
1812
1847
  /**
1813
1848
  * F-021 — 衍生 sandbox fs 端點 base:`{base}/sandbox/{sandboxName}/fs`(namespace / bot-provider 已在 base)。
@@ -1832,10 +1867,10 @@ class _n {
1832
1867
  s.searchParams.set("path", e);
1833
1868
  const r = await fetch(s.toString(), { method: "GET", headers: this.apiHeaders() });
1834
1869
  if (!r.ok)
1835
- throw new E(r.status, r.statusText, await r.text().catch(() => {
1870
+ throw new y(r.status, r.statusText, await r.text().catch(() => {
1836
1871
  }));
1837
- const i = await r.json(), o = i.data ?? i;
1838
- return { entries: o.entries ?? [], truncated: o.truncated ?? !1 };
1872
+ const i = await r.json(), a = i.data ?? i;
1873
+ return { entries: a.entries ?? [], truncated: a.truncated ?? !1 };
1839
1874
  }
1840
1875
  /**
1841
1876
  * F-021 — 讀取 sandbox 檔案(`GET fs/file?path=[&offset_bytes&limit_bytes]`)。回應是 raw octet-stream,
@@ -1846,12 +1881,12 @@ class _n {
1846
1881
  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));
1847
1882
  const i = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
1848
1883
  if (!i.ok)
1849
- throw new E(i.status, i.statusText, await i.text().catch(() => {
1884
+ throw new y(i.status, i.statusText, await i.text().catch(() => {
1850
1885
  }));
1851
- const o = await i.blob(), a = i.headers.get("X-Total-Bytes");
1886
+ const a = await i.blob(), o = i.headers.get("X-Total-Bytes");
1852
1887
  return {
1853
- content: o,
1854
- totalBytes: a != null ? Number(a) : o.size,
1888
+ content: a,
1889
+ totalBytes: o != null ? Number(o) : a.size,
1855
1890
  truncated: i.headers.get("X-Truncated") === "true"
1856
1891
  };
1857
1892
  }
@@ -1862,29 +1897,29 @@ class _n {
1862
1897
  async sandboxFsWrite(t, e, s, r) {
1863
1898
  const i = new URL(`${this.deriveSandboxFsEndpoint(t)}/file`);
1864
1899
  i.searchParams.set("path", e), r?.mode != null && i.searchParams.set("mode", String(r.mode)), r?.createOnly && i.searchParams.set("create_only", "true");
1865
- const o = new FormData();
1866
- o.append("file", s instanceof Blob ? s : new Blob([s]));
1867
- const a = await fetch(i.toString(), {
1900
+ const a = new FormData();
1901
+ a.append("file", s instanceof Blob ? s : new Blob([s]));
1902
+ const o = await fetch(i.toString(), {
1868
1903
  method: "PUT",
1869
1904
  headers: this.apiHeaders(),
1870
- body: o,
1905
+ body: a,
1871
1906
  signal: r?.signal
1872
1907
  });
1873
- if (!a.ok)
1874
- throw new E(a.status, a.statusText, await a.text().catch(() => {
1908
+ if (!o.ok)
1909
+ throw new y(o.status, o.statusText, await o.text().catch(() => {
1875
1910
  }));
1876
- const u = await a.json();
1877
- return { bytesWritten: (u.data ?? u).bytesWritten ?? 0 };
1911
+ const c = await o.json();
1912
+ return { bytesWritten: (c.data ?? c).bytesWritten ?? 0 };
1878
1913
  }
1879
1914
  /** F-021 Cycle 2 — `sandbox://` fs mutation shared request helper (throws `HttpError` on non-OK). */
1880
1915
  async sandboxFsRequest(t, e, s, r) {
1881
1916
  const i = new URL(`${this.deriveSandboxFsEndpoint(t)}/${e}`);
1882
- Object.entries(r).forEach(([a, u]) => i.searchParams.set(a, u));
1883
- const o = await fetch(i.toString(), { method: s, headers: this.apiHeaders() });
1884
- if (!o.ok)
1885
- throw new E(o.status, o.statusText, await o.text().catch(() => {
1917
+ Object.entries(r).forEach(([o, c]) => i.searchParams.set(o, c));
1918
+ const a = await fetch(i.toString(), { method: s, headers: this.apiHeaders() });
1919
+ if (!a.ok)
1920
+ throw new y(a.status, a.statusText, await a.text().catch(() => {
1886
1921
  }));
1887
- return o.json().catch(() => null);
1922
+ return a.json().catch(() => null);
1888
1923
  }
1889
1924
  /** F-021 — stat a sandbox path (`GET fs/stat?path=`). */
1890
1925
  async sandboxFsStat(t, e) {
@@ -1892,16 +1927,16 @@ class _n {
1892
1927
  s.searchParams.set("path", e);
1893
1928
  const r = await fetch(s.toString(), { method: "GET", headers: this.apiHeaders() });
1894
1929
  if (!r.ok)
1895
- throw new E(r.status, r.statusText, await r.text().catch(() => {
1930
+ throw new y(r.status, r.statusText, await r.text().catch(() => {
1896
1931
  }));
1897
- const i = await r.json(), o = i.data ?? i;
1932
+ const i = await r.json(), a = i.data ?? i;
1898
1933
  return {
1899
- exists: o.exists ?? !1,
1900
- isDir: o.isDir ?? !1,
1901
- sizeBytes: o.sizeBytes ?? 0,
1902
- mtimeUnix: o.mtimeUnix ?? 0,
1903
- mode: o.mode ?? 0,
1904
- etag: o.etag
1934
+ exists: a.exists ?? !1,
1935
+ isDir: a.isDir ?? !1,
1936
+ sizeBytes: a.sizeBytes ?? 0,
1937
+ mtimeUnix: a.mtimeUnix ?? 0,
1938
+ mode: a.mode ?? 0,
1939
+ etag: a.etag
1905
1940
  };
1906
1941
  }
1907
1942
  /** F-021 — create a directory (`POST fs/mkdir?path=`). */
@@ -1920,8 +1955,8 @@ class _n {
1920
1955
  async sandboxFsCopy(t, e, s, r) {
1921
1956
  const i = { src: e, dst: s };
1922
1957
  r?.overwrite && (i.overwrite = "true");
1923
- const o = await this.sandboxFsRequest(t, "copy", "POST", i);
1924
- return { bytesCopied: (o?.data ?? o)?.bytesCopied ?? 0 };
1958
+ const a = await this.sandboxFsRequest(t, "copy", "POST", i);
1959
+ return { bytesCopied: (a?.data ?? a)?.bytesCopied ?? 0 };
1925
1960
  }
1926
1961
  /** F-021 — move / rename a path (`POST fs/move?src=&dst=[&overwrite]`). */
1927
1962
  async sandboxFsMove(t, e, s, r) {
@@ -1935,25 +1970,25 @@ class _n {
1935
1970
  */
1936
1971
  sandboxFsWatch(t, e) {
1937
1972
  const s = new URL(`${this.deriveSandboxFsEndpoint(t)}/watch`);
1938
- return s.searchParams.set("path", e), new y((r) => {
1973
+ return s.searchParams.set("path", e), new w((r) => {
1939
1974
  const i = new AbortController();
1940
1975
  return Ce(s.toString(), {
1941
1976
  headers: this.apiHeaders(),
1942
1977
  signal: i.signal,
1943
1978
  openWhenHidden: !0,
1944
- onopen: async (o) => {
1945
- if (!o.ok) {
1946
- const a = await o.text().catch(() => {
1979
+ onopen: async (a) => {
1980
+ if (!a.ok) {
1981
+ const o = await a.text().catch(() => {
1947
1982
  });
1948
- r.error(new E(o.status, o.statusText, a)), i.abort();
1983
+ r.error(new y(a.status, a.statusText, o)), i.abort();
1949
1984
  }
1950
1985
  },
1951
- onmessage: (o) => {
1952
- o.event === "change" && r.next(JSON.parse(o.data));
1986
+ onmessage: (a) => {
1987
+ a.event === "change" && r.next(JSON.parse(a.data));
1953
1988
  },
1954
1989
  onclose: () => r.complete(),
1955
- onerror: (o) => {
1956
- throw r.error(o), i.abort(), o;
1990
+ onerror: (a) => {
1991
+ throw r.error(a), i.abort(), a;
1957
1992
  }
1958
1993
  }), () => i.abort();
1959
1994
  });
@@ -1991,11 +2026,11 @@ function C(n, t) {
1991
2026
  throw new Error(`SourceSet volume path must not contain empty, "." or ".." segments: "${n}".`);
1992
2027
  return n;
1993
2028
  }
1994
- const We = 1e3, rn = 1e4;
2029
+ const Xe = 1e3, rn = 1e4;
1995
2030
  function Se(n) {
1996
- return Math.min(Math.max(1, Math.floor(n)), We);
2031
+ return Math.min(Math.max(1, Math.floor(n)), Xe);
1997
2032
  }
1998
- class Ln {
2033
+ class Mn {
1999
2034
  endpoint;
2000
2035
  apiKey;
2001
2036
  customHeaders;
@@ -2009,25 +2044,25 @@ class Ln {
2009
2044
  }
2010
2045
  /** Issue one volume request, turning any non-2xx into {@link HttpError} (409 included, see R8). */
2011
2046
  async request(t, e, s, r, i) {
2012
- const o = new URL(`${this.endpoint}/${t}`);
2013
- Object.entries(s).forEach(([u, c]) => o.searchParams.set(u, c));
2014
- const a = await fetch(o.toString(), { method: e, headers: this.headers(), body: r, signal: i });
2015
- if (!a.ok)
2016
- throw new E(a.status, a.statusText, await a.text().catch(() => {
2047
+ const a = new URL(`${this.endpoint}/${t}`);
2048
+ Object.entries(s).forEach(([c, u]) => a.searchParams.set(c, u));
2049
+ const o = await fetch(a.toString(), { method: e, headers: this.headers(), body: r, signal: i });
2050
+ if (!o.ok)
2051
+ throw new y(o.status, o.statusText, await o.text().catch(() => {
2017
2052
  }));
2018
- return a;
2053
+ return o;
2019
2054
  }
2020
2055
  /** One page of a directory (`GET volume/list?path=[&page&page_size]`). `path` may be the root `''`. */
2021
2056
  async list(t, e) {
2022
2057
  const s = { path: C(t, { allowRoot: !0 }) };
2023
2058
  e?.page != null && (s.page = String(e.page)), e?.pageSize != null && (s.page_size = String(Se(e.pageSize)));
2024
- const i = await (await this.request("list", "GET", s)).json(), o = i.data ?? i;
2059
+ const i = await (await this.request("list", "GET", s)).json(), a = i.data ?? i;
2025
2060
  return {
2026
- entries: o.entries ?? [],
2061
+ entries: a.entries ?? [],
2027
2062
  // Reported as `null` rather than invented. An earlier version synthesized
2028
2063
  // `{ total: entries.length }` here to keep `listAll` terminating, which worked — and made a
2029
2064
  // relay that omits `paging` report the first 1000 of 3000 files as the whole directory.
2030
- paging: o.paging ?? i.paging ?? null
2065
+ paging: a.paging ?? i.paging ?? null
2031
2066
  };
2032
2067
  }
2033
2068
  /**
@@ -2037,27 +2072,27 @@ class Ln {
2037
2072
  * directory that looks whole is the failure this exists to prevent.
2038
2073
  */
2039
2074
  async listAll(t, e) {
2040
- const s = Se(e?.pageSize ?? We), r = e?.maxEntries ?? rn, i = [];
2041
- let o = 0, a = !0, u = 0;
2075
+ const s = Se(e?.pageSize ?? Xe), r = e?.maxEntries ?? rn, i = [];
2076
+ let a = 0, o = !0, c = 0;
2042
2077
  for (; ; ) {
2043
- const c = await this.list(t, { page: u, pageSize: s }), l = c.paging;
2044
- if (l && l.index !== u) {
2045
- o = l.total, a = !1;
2078
+ const u = await this.list(t, { page: c, pageSize: s }), d = u.paging;
2079
+ if (d && d.index !== c) {
2080
+ a = d.total, o = !1;
2046
2081
  break;
2047
2082
  }
2048
- if (i.push(...c.entries), !l) {
2049
- a = c.entries.length < s;
2083
+ if (i.push(...u.entries), !d) {
2084
+ o = u.entries.length < s;
2050
2085
  break;
2051
2086
  }
2052
- if (o = l.total, i.length >= o)
2087
+ if (a = d.total, i.length >= a)
2053
2088
  break;
2054
- if (i.length >= r || c.entries.length === 0) {
2055
- a = !1;
2089
+ if (i.length >= r || u.entries.length === 0) {
2090
+ o = !1;
2056
2091
  break;
2057
2092
  }
2058
- u += 1;
2093
+ c += 1;
2059
2094
  }
2060
- return { entries: i, total: o, complete: a };
2095
+ return { entries: i, total: a, complete: o };
2061
2096
  }
2062
2097
  /** Stat a path (`GET volume/stat?path=`). A missing path is 200 with `exists: false`, not a 404. */
2063
2098
  async stat(t) {
@@ -2075,10 +2110,10 @@ class Ln {
2075
2110
  async read(t, e) {
2076
2111
  const s = { path: C(t) };
2077
2112
  e?.offsetBytes != null && (s.offset_bytes = String(e.offsetBytes)), e?.limitBytes != null && (s.limit_bytes = String(e.limitBytes));
2078
- const r = await this.request("file", "GET", s), i = await r.blob(), o = r.headers.get("X-Total-Bytes");
2113
+ const r = await this.request("file", "GET", s), i = await r.blob(), a = r.headers.get("X-Total-Bytes");
2079
2114
  return {
2080
2115
  content: i,
2081
- totalBytes: o != null ? Number(o) : i.size,
2116
+ totalBytes: a != null ? Number(a) : i.size,
2082
2117
  truncated: r.headers.get("X-Truncated") === "true"
2083
2118
  };
2084
2119
  }
@@ -2091,8 +2126,8 @@ class Ln {
2091
2126
  s?.mode != null && (r.mode = String(s.mode)), s?.createOnly && (r.create_only = "true");
2092
2127
  const i = new FormData();
2093
2128
  i.append("file", e instanceof Blob ? e : new Blob([e]));
2094
- const a = await (await this.request("file", "PUT", r, i, s?.signal)).json();
2095
- return { bytesWritten: (a.data ?? a).bytesWritten ?? 0 };
2129
+ const o = await (await this.request("file", "PUT", r, i, s?.signal)).json();
2130
+ return { bytesWritten: (o.data ?? o).bytesWritten ?? 0 };
2096
2131
  }
2097
2132
  /** Create a directory and any missing parents (`POST volume/mkdir?path=`). */
2098
2133
  async mkdir(t, e) {
@@ -2108,8 +2143,8 @@ class Ln {
2108
2143
  }
2109
2144
  /** Copy a file or directory tree (`POST volume/copy?src=&dst=[&overwrite]`). */
2110
2145
  async copy(t, e, s) {
2111
- const r = this.copyMoveQuery(t, e, s), o = await (await this.request("copy", "POST", r)).json();
2112
- return { bytesCopied: (o.data ?? o).bytesCopied ?? 0 };
2146
+ const r = this.copyMoveQuery(t, e, s), a = await (await this.request("copy", "POST", r)).json();
2147
+ return { bytesCopied: (a.data ?? a).bytesCopied ?? 0 };
2113
2148
  }
2114
2149
  /** Move or rename (`POST volume/move?src=&dst=[&overwrite]`) — also how the UI renames. */
2115
2150
  async move(t, e, s) {
@@ -2123,18 +2158,18 @@ class Ln {
2123
2158
  const S = [];
2124
2159
  for (let n = 0; n < 256; ++n)
2125
2160
  S.push((n + 256).toString(16).slice(1));
2126
- function on(n, t = 0) {
2161
+ function an(n, t = 0) {
2127
2162
  return (S[n[t + 0]] + S[n[t + 1]] + S[n[t + 2]] + S[n[t + 3]] + "-" + S[n[t + 4]] + S[n[t + 5]] + "-" + S[n[t + 6]] + S[n[t + 7]] + "-" + S[n[t + 8]] + S[n[t + 9]] + "-" + S[n[t + 10]] + S[n[t + 11]] + S[n[t + 12]] + S[n[t + 13]] + S[n[t + 14]] + S[n[t + 15]]).toLowerCase();
2128
2163
  }
2129
2164
  let Z;
2130
- const an = new Uint8Array(16);
2165
+ const on = new Uint8Array(16);
2131
2166
  function cn() {
2132
2167
  if (!Z) {
2133
2168
  if (typeof crypto > "u" || !crypto.getRandomValues)
2134
2169
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2135
2170
  Z = crypto.getRandomValues.bind(crypto);
2136
2171
  }
2137
- return Z(an);
2172
+ return Z(on);
2138
2173
  }
2139
2174
  const un = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ye = { randomUUID: un };
2140
2175
  function ln(n, t, e) {
@@ -2142,23 +2177,24 @@ function ln(n, t, e) {
2142
2177
  const s = n.random ?? n.rng?.() ?? cn();
2143
2178
  if (s.length < 16)
2144
2179
  throw new Error("Random bytes length must be >= 16");
2145
- return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, on(s);
2180
+ return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, an(s);
2146
2181
  }
2147
- function Xe(n, t, e) {
2182
+ function We(n, t, e) {
2148
2183
  return ye.randomUUID && !n ? ye.randomUUID() : ln(n);
2149
2184
  }
2150
2185
  class g {
2151
2186
  messages = null;
2152
2187
  pendingConsent = null;
2153
- constructor({ messages: t, pendingConsent: e = null }) {
2154
- this.messages = t, this.pendingConsent = e ?? null;
2188
+ pendingFeedback = null;
2189
+ constructor({ messages: t, pendingConsent: e = null, pendingFeedback: s = null }) {
2190
+ this.messages = t, this.pendingConsent = e ?? null, this.pendingFeedback = s ?? null;
2155
2191
  }
2156
2192
  pushMessage(t) {
2157
2193
  const e = new Map(this.messages);
2158
- return e.set(t.messageId, t), new g({ messages: e, pendingConsent: this.pendingConsent });
2194
+ return e.set(t.messageId, t), new g({ messages: e, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2159
2195
  }
2160
2196
  clearPendingConsent() {
2161
- return this.pendingConsent ? new g({ messages: this.messages, pendingConsent: null }) : this;
2197
+ return this.pendingConsent ? new g({ messages: this.messages, pendingConsent: null, pendingFeedback: this.pendingFeedback }) : this;
2162
2198
  }
2163
2199
  /**
2164
2200
  * Put a consent prompt back (#410) — the mirror of {@link clearPendingConsent}, used to undo the
@@ -2166,7 +2202,7 @@ class g {
2166
2202
  * meantime: that one is newer than the batch being restored.
2167
2203
  */
2168
2204
  restorePendingConsent(t) {
2169
- return this.pendingConsent ? this : new g({ messages: this.messages, pendingConsent: t });
2205
+ return this.pendingConsent ? this : new g({ messages: this.messages, pendingConsent: t, pendingFeedback: this.pendingFeedback });
2170
2206
  }
2171
2207
  /**
2172
2208
  * Converge everything the aborted run left mid-flight (F-020 AC10, F-023). A stopped run sends no
@@ -2187,7 +2223,7 @@ class g {
2187
2223
  const e = new Map(this.messages);
2188
2224
  for (const [s, r] of e)
2189
2225
  r.type === "tool-call" && !r.isComplete && (e.set(s, { ...r, isComplete: !0, isCancelled: !0 }), t = !0), r.type === "thinking" && r.isThinking && (e.set(s, { ...r, isThinking: !1 }), t = !0);
2190
- return t ? new g({ messages: e, pendingConsent: this.pendingConsent }) : this;
2226
+ return t ? new g({ messages: e, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback }) : this;
2191
2227
  }
2192
2228
  /**
2193
2229
  * @deprecated Renamed to {@link settleInFlightMessages} in 0.3.27 — it settles in-flight thinking
@@ -2199,37 +2235,39 @@ class g {
2199
2235
  }
2200
2236
  onMessage(t) {
2201
2237
  switch (t.eventType) {
2202
- case d.MESSAGE_START:
2238
+ case l.MESSAGE_START:
2203
2239
  return this.onMessageStart(t);
2204
- case d.MESSAGE_DELTA:
2240
+ case l.MESSAGE_DELTA:
2205
2241
  return this.onMessageDelta(t);
2206
- case d.MESSAGE_COMPLETE:
2242
+ case l.MESSAGE_COMPLETE:
2207
2243
  return this.onMessageComplete(t);
2208
- case d.MESSAGE_USER:
2244
+ case l.MESSAGE_USER:
2209
2245
  return this.onMessageUser(t);
2210
- case d.MESSAGE_THINKING_START:
2246
+ case l.MESSAGE_FEEDBACK:
2247
+ return this.onMessageFeedback(t);
2248
+ case l.MESSAGE_THINKING_START:
2211
2249
  return this.onThinkingStart(t);
2212
- case d.MESSAGE_THINKING_DELTA:
2250
+ case l.MESSAGE_THINKING_DELTA:
2213
2251
  return this.onThinkingDelta(t);
2214
- case d.MESSAGE_THINKING_COMPLETE:
2252
+ case l.MESSAGE_THINKING_COMPLETE:
2215
2253
  return this.onThinkingComplete(t);
2216
- case d.MESSAGE_CANVAS_START:
2254
+ case l.MESSAGE_CANVAS_START:
2217
2255
  return this.onCanvasStart(t);
2218
- case d.MESSAGE_CANVAS_DELTA:
2256
+ case l.MESSAGE_CANVAS_DELTA:
2219
2257
  return this.onCanvasDelta(t);
2220
- case d.MESSAGE_CANVAS_COMPLETE:
2258
+ case l.MESSAGE_CANVAS_COMPLETE:
2221
2259
  return this.onCanvasComplete(t);
2222
- case d.TOOL_CALL_START:
2260
+ case l.TOOL_CALL_START:
2223
2261
  return this.onToolCallStart(t);
2224
- case d.TOOL_CALL_COMPLETE:
2262
+ case l.TOOL_CALL_COMPLETE:
2225
2263
  return this.onToolCallComplete(t);
2226
- case d.TOOL_CALL_CONSENT:
2264
+ case l.TOOL_CALL_CONSENT:
2227
2265
  return this.onToolCallConsent(t);
2228
- case d.SUBAGENT_START:
2266
+ case l.SUBAGENT_START:
2229
2267
  return this.onSubagentStart(t);
2230
- case d.SUBAGENT_COMPLETE:
2268
+ case l.SUBAGENT_COMPLETE:
2231
2269
  return this.onSubagentComplete(t);
2232
- case d.ERROR:
2270
+ case l.ERROR:
2233
2271
  return this.onMessageError(t);
2234
2272
  default:
2235
2273
  return this;
@@ -2275,7 +2313,7 @@ class g {
2275
2313
  const s = new Map(this.messages);
2276
2314
  return s.set(e.messageId, {
2277
2315
  type: "bot",
2278
- eventType: d.MESSAGE_START,
2316
+ eventType: l.MESSAGE_START,
2279
2317
  isTyping: !0,
2280
2318
  typingText: "",
2281
2319
  messageId: e.messageId,
@@ -2283,7 +2321,7 @@ class g {
2283
2321
  time: /* @__PURE__ */ new Date(),
2284
2322
  traceId: t.traceId,
2285
2323
  raw: ""
2286
- }), new g({ messages: s, pendingConsent: this.pendingConsent });
2324
+ }), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2287
2325
  }
2288
2326
  onMessageDelta(t) {
2289
2327
  const e = t.fact.messageDelta.message;
@@ -2293,7 +2331,7 @@ class g {
2293
2331
  const r = s?.type === "bot" ? s : void 0, i = new Map(this.messages);
2294
2332
  return i.set(e.messageId, {
2295
2333
  type: "bot",
2296
- eventType: d.MESSAGE_DELTA,
2334
+ eventType: l.MESSAGE_DELTA,
2297
2335
  isTyping: !0,
2298
2336
  typingText: `${r?.typingText ?? ""}${e.text}`,
2299
2337
  messageId: e.messageId,
@@ -2301,23 +2339,55 @@ class g {
2301
2339
  time: /* @__PURE__ */ new Date(),
2302
2340
  traceId: t.traceId ?? r?.traceId,
2303
2341
  raw: r?.raw ?? ""
2304
- }), new g({ messages: i, pendingConsent: this.pendingConsent });
2342
+ }), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2305
2343
  }
2306
2344
  onMessageComplete(t) {
2307
2345
  const e = t.fact.messageComplete.message;
2308
2346
  if (e.parentToolUseId) return this;
2309
- const s = new Map(this.messages), r = s.get(e.messageId);
2310
- return s.set(e.messageId, {
2347
+ const s = new Map(this.messages), r = s.get(e.messageId), i = r?.type === "bot" ? r : void 0, a = this.pendingFeedback?.get(e.messageId), o = a ?? i?.feedback;
2348
+ s.set(e.messageId, {
2311
2349
  type: "bot",
2312
- eventType: d.MESSAGE_COMPLETE,
2350
+ eventType: l.MESSAGE_COMPLETE,
2313
2351
  isTyping: !1,
2314
2352
  typingText: null,
2315
2353
  messageId: e.messageId,
2316
2354
  message: e,
2355
+ ...o ? { feedback: o } : {},
2317
2356
  time: /* @__PURE__ */ new Date(),
2318
- traceId: t.traceId ?? (r?.type === "bot" ? r.traceId : void 0),
2357
+ traceId: t.traceId ?? i?.traceId,
2319
2358
  raw: JSON.stringify(t)
2320
- }), new g({ messages: s, pendingConsent: this.pendingConsent });
2359
+ });
2360
+ let c = this.pendingFeedback;
2361
+ return a && (c = new Map(this.pendingFeedback), c.delete(e.messageId)), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: c });
2362
+ }
2363
+ /**
2364
+ * `asgard.message.feedback` (F-033): fold a rating into the reply it targets. The server is
2365
+ * append-only and latest-wins, so a later frame for the same target simply replaces the earlier
2366
+ * state — on a replay the frames arrive in seq order and the last one standing is the current one.
2367
+ * Only a bot reply can carry a rating; a frame naming anything else (or a reply that has not arrived
2368
+ * yet) is parked in `pendingFeedback` and applied if that reply's `complete` shows up later.
2369
+ */
2370
+ onMessageFeedback(t) {
2371
+ const e = t.fact.messageFeedback, s = {
2372
+ verdict: e.verdict,
2373
+ ...e.text ? { comment: e.text } : {}
2374
+ };
2375
+ return this.applyFeedback(e.targetMessageId, s);
2376
+ }
2377
+ /**
2378
+ * Set the current rating of one bot reply (F-033). Used by the reducer for server frames and by
2379
+ * `Channel.sendMessageFeedback` once this client's own POST has been accepted — the SDK has no open
2380
+ * stream between runs, so the live echo of its own feedback would never reach it. A target that is not
2381
+ * (yet) a bot reply is parked in `pendingFeedback`; see {@link onMessageComplete}.
2382
+ */
2383
+ applyFeedback(t, e) {
2384
+ const s = this.messages?.get(t);
2385
+ if (s?.type === "bot") {
2386
+ const i = new Map(this.messages), a = { ...s, feedback: e };
2387
+ return i.set(t, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2388
+ }
2389
+ const r = new Map(this.pendingFeedback);
2390
+ return r.set(t, e), new g({ messages: this.messages, pendingConsent: this.pendingConsent, pendingFeedback: r });
2321
2391
  }
2322
2392
  onThinkingStart(t) {
2323
2393
  const e = t.fact.messageThinkingStart.message;
@@ -2331,14 +2401,14 @@ class g {
2331
2401
  time: /* @__PURE__ */ new Date(),
2332
2402
  traceId: t.traceId
2333
2403
  };
2334
- return s.set(e.messageId, r), new g({ messages: s, pendingConsent: this.pendingConsent });
2404
+ return s.set(e.messageId, r), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2335
2405
  }
2336
2406
  onThinkingDelta(t) {
2337
2407
  const e = t.fact.messageThinkingDelta.message;
2338
2408
  if (e.parentToolUseId) return this;
2339
2409
  const s = this.messages?.get(e.messageId);
2340
2410
  if (this.isTerminalThinking(s)) return this;
2341
- const r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), o = {
2411
+ const r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), a = {
2342
2412
  type: "thinking",
2343
2413
  messageId: e.messageId,
2344
2414
  text: `${r?.text ?? ""}${e.text}`,
@@ -2346,12 +2416,12 @@ class g {
2346
2416
  time: r?.time ?? /* @__PURE__ */ new Date(),
2347
2417
  traceId: t.traceId ?? r?.traceId
2348
2418
  };
2349
- return i.set(e.messageId, o), new g({ messages: i, pendingConsent: this.pendingConsent });
2419
+ return i.set(e.messageId, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2350
2420
  }
2351
2421
  onThinkingComplete(t) {
2352
2422
  const e = t.fact.messageThinkingComplete.message;
2353
2423
  if (e.parentToolUseId) return this;
2354
- const s = this.messages?.get(e.messageId), r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), o = {
2424
+ const s = this.messages?.get(e.messageId), r = s?.type === "thinking" ? s : void 0, i = new Map(this.messages), a = {
2355
2425
  type: "thinking",
2356
2426
  messageId: e.messageId,
2357
2427
  // Self-sufficient (F-011): the complete frame carries the full reasoning, so a complete-only
@@ -2361,7 +2431,7 @@ class g {
2361
2431
  time: r?.time ?? /* @__PURE__ */ new Date(),
2362
2432
  traceId: t.traceId ?? r?.traceId
2363
2433
  };
2364
- return i.set(e.messageId, o), new g({ messages: i, pendingConsent: this.pendingConsent });
2434
+ return i.set(e.messageId, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2365
2435
  }
2366
2436
  onCanvasStart(t) {
2367
2437
  const e = t.fact.messageCanvasStart.message;
@@ -2375,14 +2445,14 @@ class g {
2375
2445
  time: /* @__PURE__ */ new Date(),
2376
2446
  traceId: t.traceId
2377
2447
  };
2378
- return s.set(e.messageId, r), new g({ messages: s, pendingConsent: this.pendingConsent });
2448
+ return s.set(e.messageId, r), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2379
2449
  }
2380
2450
  onCanvasDelta(t) {
2381
2451
  const e = t.fact.messageCanvasDelta.message;
2382
2452
  if (e.parentToolUseId) return this;
2383
2453
  const s = this.messages?.get(e.messageId);
2384
2454
  if (this.isTerminalCanvas(s)) return this;
2385
- const r = s?.type === "canvas" ? s : void 0, i = new Map(this.messages), o = {
2455
+ const r = s?.type === "canvas" ? s : void 0, i = new Map(this.messages), a = {
2386
2456
  type: "canvas",
2387
2457
  messageId: e.messageId,
2388
2458
  // Deltas are incremental, exactly like a text delta.
@@ -2392,7 +2462,7 @@ class g {
2392
2462
  time: r?.time ?? /* @__PURE__ */ new Date(),
2393
2463
  traceId: t.traceId ?? r?.traceId
2394
2464
  };
2395
- return i.set(e.messageId, o), new g({ messages: i, pendingConsent: this.pendingConsent });
2465
+ return i.set(e.messageId, a), new g({ messages: i, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2396
2466
  }
2397
2467
  onCanvasComplete(t) {
2398
2468
  const e = t.fact.messageCanvasComplete.message;
@@ -2400,10 +2470,10 @@ class g {
2400
2470
  const s = e.template?.type === Te.CANVAS ? e.template : void 0, r = s?.canvas?.html;
2401
2471
  if (!r) {
2402
2472
  if (!this.messages?.has(e.messageId)) return this;
2403
- const c = new Map(this.messages);
2404
- return c.delete(e.messageId), new g({ messages: c, pendingConsent: this.pendingConsent });
2473
+ const u = new Map(this.messages);
2474
+ return u.delete(e.messageId), new g({ messages: u, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2405
2475
  }
2406
- const i = this.messages?.get(e.messageId), o = i?.type === "canvas" ? i : void 0, a = new Map(this.messages), u = {
2476
+ const i = this.messages?.get(e.messageId), a = i?.type === "canvas" ? i : void 0, o = new Map(this.messages), c = {
2407
2477
  type: "canvas",
2408
2478
  messageId: e.messageId,
2409
2479
  // **Replace, never append.** This fragment is authoritative, and a rejoin replays only the
@@ -2411,10 +2481,10 @@ class g {
2411
2481
  html: r,
2412
2482
  title: s?.title,
2413
2483
  isDrawing: !1,
2414
- time: o?.time ?? /* @__PURE__ */ new Date(),
2415
- traceId: t.traceId ?? o?.traceId
2484
+ time: a?.time ?? /* @__PURE__ */ new Date(),
2485
+ traceId: t.traceId ?? a?.traceId
2416
2486
  };
2417
- return a.set(e.messageId, u), new g({ messages: a, pendingConsent: this.pendingConsent });
2487
+ return o.set(e.messageId, c), new g({ messages: o, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2418
2488
  }
2419
2489
  onMessageUser(t) {
2420
2490
  const e = t.fact.messageUser;
@@ -2430,25 +2500,25 @@ class g {
2430
2500
  time: /* @__PURE__ */ new Date(),
2431
2501
  traceId: t.traceId
2432
2502
  };
2433
- return r.set(e.messageId, i), new g({ messages: r, pendingConsent: this.pendingConsent });
2503
+ return r.set(e.messageId, i), new g({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2434
2504
  }
2435
2505
  onMessageError(t) {
2436
- const e = Xe(), s = t.fact.runError.error, r = new Map(this.messages);
2506
+ const e = We(), s = t.fact.runError.error, r = new Map(this.messages);
2437
2507
  return r.set(e, {
2438
2508
  type: "error",
2439
- eventType: d.ERROR,
2509
+ eventType: l.ERROR,
2440
2510
  messageId: e,
2441
2511
  error: s,
2442
2512
  time: /* @__PURE__ */ new Date(),
2443
2513
  traceId: t.traceId
2444
- }), new g({ messages: r, pendingConsent: this.pendingConsent });
2514
+ }), new g({ messages: r, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2445
2515
  }
2446
2516
  onToolCallStart(t) {
2447
2517
  const e = t.fact.toolCallStart, s = new Map(this.messages), r = `${e.processId}-${e.callSeq}`;
2448
2518
  if (this.isTerminalToolCall(this.messages?.get(r))) return this;
2449
2519
  const i = {
2450
2520
  type: "tool-call",
2451
- eventType: d.TOOL_CALL_START,
2521
+ eventType: l.TOOL_CALL_START,
2452
2522
  messageId: r,
2453
2523
  processId: e.processId,
2454
2524
  callSeq: e.callSeq,
@@ -2462,25 +2532,25 @@ class g {
2462
2532
  time: /* @__PURE__ */ new Date(),
2463
2533
  traceId: t.traceId
2464
2534
  };
2465
- return s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent });
2535
+ return s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2466
2536
  }
2467
2537
  onToolCallComplete(t) {
2468
2538
  const e = t.fact.toolCallComplete, s = new Map(this.messages), r = `${e.processId}-${e.callSeq}`, i = s.get(r);
2469
2539
  if (i?.type === "tool-call") {
2470
- const o = {
2540
+ const a = {
2471
2541
  ...i,
2472
- eventType: d.TOOL_CALL_COMPLETE,
2542
+ eventType: l.TOOL_CALL_COMPLETE,
2473
2543
  result: e.toolCallResult,
2474
2544
  isError: e.isError,
2475
2545
  sidecar: e.toolUseResultSidecar,
2476
2546
  isComplete: !0,
2477
2547
  traceId: t.traceId ?? i.traceId
2478
2548
  };
2479
- s.set(r, o);
2549
+ s.set(r, a);
2480
2550
  } else {
2481
- const o = {
2551
+ const a = {
2482
2552
  type: "tool-call",
2483
- eventType: d.TOOL_CALL_COMPLETE,
2553
+ eventType: l.TOOL_CALL_COMPLETE,
2484
2554
  messageId: r,
2485
2555
  processId: e.processId,
2486
2556
  callSeq: e.callSeq,
@@ -2497,13 +2567,17 @@ class g {
2497
2567
  time: /* @__PURE__ */ new Date(),
2498
2568
  traceId: t.traceId
2499
2569
  };
2500
- s.set(r, o);
2570
+ s.set(r, a);
2501
2571
  }
2502
- return new g({ messages: s, pendingConsent: this.pendingConsent });
2572
+ return new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2503
2573
  }
2504
2574
  onToolCallConsent(t) {
2505
2575
  const e = t.fact.toolCallConsent;
2506
- return new g({ messages: this.messages, pendingConsent: e });
2576
+ return new g({
2577
+ messages: this.messages,
2578
+ pendingConsent: e,
2579
+ pendingFeedback: this.pendingFeedback
2580
+ });
2507
2581
  }
2508
2582
  onSubagentStart(t) {
2509
2583
  const e = t.fact.subagentStart, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:start`, i = {
@@ -2517,7 +2591,7 @@ class g {
2517
2591
  time: /* @__PURE__ */ new Date(),
2518
2592
  traceId: t.traceId
2519
2593
  };
2520
- return s.delete(r), s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent });
2594
+ return s.delete(r), s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2521
2595
  }
2522
2596
  onSubagentComplete(t) {
2523
2597
  const e = t.fact.subagentComplete, s = new Map(this.messages), r = `subagent:${e.parentToolUseId}:complete`, i = {
@@ -2532,7 +2606,7 @@ class g {
2532
2606
  time: /* @__PURE__ */ new Date(),
2533
2607
  traceId: t.traceId
2534
2608
  };
2535
- return s.delete(r), s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent });
2609
+ return s.delete(r), s.set(r, i), new g({ messages: s, pendingConsent: this.pendingConsent, pendingFeedback: this.pendingFeedback });
2536
2610
  }
2537
2611
  }
2538
2612
  const dn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
@@ -2550,21 +2624,21 @@ function fn(n) {
2550
2624
  for (const s of n) {
2551
2625
  const r = s.parameter ?? {}, i = s.sidecar ?? {};
2552
2626
  if (s.toolName === "TaskCreate") {
2553
- const o = we(i.task), a = x(o?.id);
2554
- if (!a) continue;
2555
- e.has(a) || t.push(a), e.set(a, {
2556
- id: a,
2557
- subject: x(r.subject) || x(o?.subject) || "",
2627
+ const a = we(i.task), o = x(a?.id);
2628
+ if (!o) continue;
2629
+ e.has(o) || t.push(o), e.set(o, {
2630
+ id: o,
2631
+ subject: x(r.subject) || x(a?.subject) || "",
2558
2632
  activeForm: x(r.activeForm),
2559
2633
  description: x(r.description),
2560
- status: e.get(a)?.status ?? "pending"
2634
+ status: e.get(o)?.status ?? "pending"
2561
2635
  // initial status = pending (keep existing on repeat)
2562
2636
  });
2563
2637
  } else if (s.toolName === "TaskUpdate") {
2564
- const o = we(i.statusChange), a = x(r.taskId) || x(i.taskId), u = x(o?.to) || x(r.status);
2565
- if (!a || !u) continue;
2566
- const c = e.get(a);
2567
- c && e.set(a, { ...c, status: u });
2638
+ const a = we(i.statusChange), o = x(r.taskId) || x(i.taskId), c = x(a?.to) || x(r.status);
2639
+ if (!o || !c) continue;
2640
+ const u = e.get(o);
2641
+ u && e.set(o, { ...u, status: c });
2568
2642
  }
2569
2643
  }
2570
2644
  return t.map((s) => e.get(s));
@@ -2572,24 +2646,24 @@ function fn(n) {
2572
2646
  function pn(n) {
2573
2647
  return n.toolsetName === "" && n.toolName === "Agent";
2574
2648
  }
2575
- function mn(n) {
2649
+ function gn(n) {
2576
2650
  return !!n;
2577
2651
  }
2578
2652
  function Ee(n) {
2579
2653
  n.status !== "running" && (n.status = "running", n.summary = void 0);
2580
2654
  }
2581
- function gn(n) {
2655
+ function mn(n) {
2582
2656
  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));
2583
2657
  for (const i of n)
2584
2658
  switch (i.kind) {
2585
2659
  case "agentStart": {
2586
- const o = r(i.toolUseId);
2587
- i.description && !o.description && (o.description = i.description);
2660
+ const a = r(i.toolUseId);
2661
+ i.description && !a.description && (a.description = i.description);
2588
2662
  break;
2589
2663
  }
2590
2664
  case "subagentStart": {
2591
- const o = r(i.parentToolUseId);
2592
- o.agentId = i.agentId ?? o.agentId, o.subagentType = i.subagentType ?? o.subagentType, o.description = i.description ?? o.description, Ee(o);
2665
+ const a = r(i.parentToolUseId);
2666
+ a.agentId = i.agentId ?? a.agentId, a.subagentType = i.subagentType ?? a.subagentType, a.description = i.description ?? a.description, Ee(a);
2593
2667
  break;
2594
2668
  }
2595
2669
  case "toolStart": {
@@ -2603,13 +2677,13 @@ function gn(n) {
2603
2677
  break;
2604
2678
  }
2605
2679
  case "toolComplete": {
2606
- const o = s.get(i.parentToolUseId)?.get(i.toolUseId);
2607
- o && (o.status = i.isError ? "error" : "completed");
2680
+ const a = s.get(i.parentToolUseId)?.get(i.toolUseId);
2681
+ a && (a.status = i.isError ? "error" : "completed");
2608
2682
  break;
2609
2683
  }
2610
2684
  case "subagentComplete": {
2611
- const o = r(i.parentToolUseId);
2612
- o.status = i.status, o.summary = i.summary;
2685
+ const a = r(i.parentToolUseId);
2686
+ a.status = i.status, a.summary = i.summary;
2613
2687
  break;
2614
2688
  }
2615
2689
  }
@@ -2633,7 +2707,7 @@ function vn(n) {
2633
2707
  });
2634
2708
  continue;
2635
2709
  }
2636
- if (e.type === "tool-call" && mn(e.parentToolUseId)) {
2710
+ if (e.type === "tool-call" && gn(e.parentToolUseId)) {
2637
2711
  const s = e.toolUseId ?? e.messageId;
2638
2712
  t.push({
2639
2713
  kind: "toolStart",
@@ -2677,7 +2751,7 @@ function Sn(n) {
2677
2751
  return fn(t);
2678
2752
  }
2679
2753
  function yn(n) {
2680
- return gn(vn(Array.from(n.messages?.values() ?? [])));
2754
+ return mn(vn(Array.from(n.messages?.values() ?? [])));
2681
2755
  }
2682
2756
  function wn(n, t) {
2683
2757
  return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, s) => {
@@ -2698,9 +2772,9 @@ function In(n, t) {
2698
2772
  });
2699
2773
  }
2700
2774
  function Tn(n) {
2701
- const t = new A([]), e = new A([]), s = new N();
2702
- return s.add(n.pipe(Y(Sn), U(wn)).subscribe(t)), s.add(
2703
- n.pipe(Y(yn), U(In)).subscribe(e)
2775
+ const t = new A([]), e = new A([]), s = new U();
2776
+ return s.add(n.pipe(Y(Sn), M(wn)).subscribe(t)), s.add(
2777
+ n.pipe(Y(yn), M(In)).subscribe(e)
2704
2778
  ), {
2705
2779
  tasks$: t.asObservable(),
2706
2780
  subagents$: e.asObservable(),
@@ -2782,7 +2856,7 @@ class G {
2782
2856
  throw new Error("customChannelId must be required");
2783
2857
  this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new A(!1), this.runStatusSubject = new A(ee), this.conversation$ = new A(t.conversation), this.channelTitleSubject = new A(t.channelTitle ?? null), this.promptSuggestionSubject = new A(null), this.sandboxPhaseSubject = new A("idle"), this.launchedSandboxesSubject = new A(
2784
2858
  Ie(t.launchedSandboxes ?? [])
2785
- ), this.derivedStores = Tn(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(U()), this.promptSuggestion$ = this.promptSuggestionSubject.pipe(U()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(U()), this.launchedSandboxes$ = this.launchedSandboxesSubject.pipe(U()), this.runStatus$ = this.runStatusSubject.pipe(U(xn)), this.statesObserver = t.statesObserver;
2859
+ ), this.derivedStores = Tn(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(M()), this.promptSuggestion$ = this.promptSuggestionSubject.pipe(M()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(M()), this.launchedSandboxes$ = this.launchedSandboxesSubject.pipe(M()), this.runStatus$ = this.runStatusSubject.pipe(M(xn)), this.statesObserver = t.statesObserver;
2786
2860
  }
2787
2861
  /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2788
2862
  getTasks() {
@@ -2879,8 +2953,8 @@ class G {
2879
2953
  const i = new G(t);
2880
2954
  try {
2881
2955
  return i.subscribe(), r?.(i), await i.openChannel(e, s), i;
2882
- } catch (o) {
2883
- throw i.close(), o;
2956
+ } catch (a) {
2957
+ throw i.close(), a;
2884
2958
  }
2885
2959
  }
2886
2960
  /**
@@ -2924,7 +2998,7 @@ class G {
2924
2998
  }
2925
2999
  }
2926
3000
  subscribe() {
2927
- this.statesSubscription = Wt([
3001
+ this.statesSubscription = Xt([
2928
3002
  this.isConnecting$,
2929
3003
  this.conversation$,
2930
3004
  this.derivedStores.tasks$,
@@ -2942,20 +3016,20 @@ class G {
2942
3016
  s,
2943
3017
  r,
2944
3018
  i,
2945
- o,
2946
3019
  a,
2947
- u,
2948
- c
3020
+ o,
3021
+ c,
3022
+ u
2949
3023
  ]) => ({
2950
3024
  isConnecting: t,
2951
3025
  conversation: e,
2952
3026
  tasks: s,
2953
3027
  subagents: r,
2954
3028
  channelTitle: i,
2955
- promptSuggestion: o,
2956
- sandboxPhase: a,
2957
- launchedSandboxes: u,
2958
- runStatus: c
3029
+ promptSuggestion: a,
3030
+ sandboxPhase: o,
3031
+ launchedSandboxes: c,
3032
+ runStatus: u
2959
3033
  })
2960
3034
  )
2961
3035
  ).subscribe(this.statesObserver);
@@ -2981,14 +3055,14 @@ class G {
2981
3055
  */
2982
3056
  updateSandboxPhase(t) {
2983
3057
  switch (t) {
2984
- case d.SANDBOX_LAUNCH:
3058
+ case l.SANDBOX_LAUNCH:
2985
3059
  this.sandboxPhaseSubject.next("launching");
2986
3060
  break;
2987
- case d.SANDBOX_READY:
3061
+ case l.SANDBOX_READY:
2988
3062
  this.sandboxPhaseSubject.next("ready");
2989
3063
  break;
2990
- case d.INIT:
2991
- case d.ERROR:
3064
+ case l.INIT:
3065
+ case l.ERROR:
2992
3066
  this.sandboxPhaseSubject.next("idle");
2993
3067
  break;
2994
3068
  }
@@ -3002,17 +3076,21 @@ class G {
3002
3076
  return {
3003
3077
  onSseStart: t?.onSseStart,
3004
3078
  onSseMessage: (r) => {
3005
- if (t?.onSseMessage?.(r), this.captureRequestId(r.requestId), r.eventType === d.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
3079
+ if (t?.onSseMessage?.(r), this.captureRequestId(r.requestId), r.eventType === l.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
3006
3080
  r.fact.channelTitleUpdate.title
3007
- ), r.eventType === d.PROMPT_SUGGESTION ? this.promptSuggestionSubject.next(
3081
+ ), r.eventType === l.PROMPT_SUGGESTION ? this.promptSuggestionSubject.next(
3008
3082
  r.fact.promptSuggestion.suggestion
3009
- ) : r.eventType === d.INIT && this.clearPromptSuggestion(), this.updateSandboxPhase(r.eventType), r.eventType === d.SANDBOX_LAUNCH && this.noteSandboxLaunch(r.fact.sandboxLaunch.sandboxName), this.currentUserMessageId && r.traceId) {
3010
- const i = new Map(this.conversation$.value.messages), o = i.get(this.currentUserMessageId);
3011
- o && o.type === "user" && (i.set(this.currentUserMessageId, {
3012
- ...o,
3083
+ ) : r.eventType === l.INIT && this.clearPromptSuggestion(), this.updateSandboxPhase(r.eventType), r.eventType === l.SANDBOX_LAUNCH && this.noteSandboxLaunch(r.fact.sandboxLaunch.sandboxName), this.currentUserMessageId && r.traceId) {
3084
+ const i = new Map(this.conversation$.value.messages), a = i.get(this.currentUserMessageId);
3085
+ a && a.type === "user" && (i.set(this.currentUserMessageId, {
3086
+ ...a,
3013
3087
  traceId: r.traceId
3014
3088
  }), this.conversation$.next(
3015
- new g({ messages: i, pendingConsent: this.conversation$.value.pendingConsent })
3089
+ new g({
3090
+ messages: i,
3091
+ pendingConsent: this.conversation$.value.pendingConsent,
3092
+ pendingFeedback: this.conversation$.value.pendingFeedback
3093
+ })
3016
3094
  )), this.currentUserMessageId = void 0;
3017
3095
  }
3018
3096
  this.conversation$.next(this.conversation$.value.onMessage(r));
@@ -3074,7 +3152,7 @@ class G {
3074
3152
  return this.fetchSse(
3075
3153
  "reset",
3076
3154
  {
3077
- action: B.NONE,
3155
+ action: H.NONE,
3078
3156
  customChannelId: this.customChannelId,
3079
3157
  customMessageId: this.customMessageId,
3080
3158
  text: t?.text || "",
@@ -3089,11 +3167,11 @@ class G {
3089
3167
  const r = this.conversation$.value.pendingConsent;
3090
3168
  if (r) return Promise.reject(new ne(r.processId));
3091
3169
  this.clearPromptSuggestion();
3092
- const i = t.text.trim(), o = t.customMessageId ?? Xe();
3093
- return this.currentUserMessageId = o, this.lastSentMessageId = o, this.conversation$.next(
3170
+ const i = t.text.trim(), a = t.customMessageId ?? We();
3171
+ return this.currentUserMessageId = a, this.lastSentMessageId = a, this.conversation$.next(
3094
3172
  this.conversation$.value.pushMessage({
3095
3173
  type: "user",
3096
- messageId: o,
3174
+ messageId: a,
3097
3175
  text: i,
3098
3176
  blobIds: t.blobIds,
3099
3177
  filePreviewUrls: t.filePreviewUrls,
@@ -3103,9 +3181,9 @@ class G {
3103
3181
  ), this.fetchSse(
3104
3182
  "user",
3105
3183
  {
3106
- action: B.NONE,
3184
+ action: H.NONE,
3107
3185
  customChannelId: this.customChannelId,
3108
- customMessageId: o,
3186
+ customMessageId: a,
3109
3187
  payload: this.resolvePayload(t?.payload),
3110
3188
  text: i,
3111
3189
  blobIds: t?.blobIds
@@ -3113,12 +3191,41 @@ class G {
3113
3191
  e
3114
3192
  );
3115
3193
  }
3194
+ /**
3195
+ * Rate one assistant reply Good or Bad (F-033 / UC-055, UC-056, UC-059). Posts the verdict, and only
3196
+ * once the server has accepted it writes the rating into that reply's `feedback` — the SDK holds no
3197
+ * open stream between runs, so the live `asgard.message.feedback` echo of its own post would never
3198
+ * arrive; the next rejoin replays it from the transcript instead. A rejection leaves the conversation
3199
+ * untouched (no optimistic update, UC-059 Alt B), so the caller can show the error and let the user try
3200
+ * again with the same comment.
3201
+ *
3202
+ * Rating is **not** telling the agent: when the user also wants that, the caller sends an ordinary
3203
+ * message composed by `composeFeedbackMessage()` through `sendMessage` after this resolves (UC-057).
3204
+ */
3205
+ async sendMessageFeedback(t, e) {
3206
+ if (!this.client.sendMessageFeedback)
3207
+ throw new Error(
3208
+ "This client cannot rate a reply: IAsgardServiceClient.sendMessageFeedback is not implemented. Implement it (POST {base}/message/feedback) or use AsgardServiceClient."
3209
+ );
3210
+ const s = await this.client.sendMessageFeedback({
3211
+ customChannelId: this.customChannelId,
3212
+ messageId: t,
3213
+ verdict: e.verdict,
3214
+ comment: e.comment
3215
+ }), r = e.comment?.trim();
3216
+ return this.conversation$.next(
3217
+ this.conversation$.value.applyFeedback(t, {
3218
+ verdict: e.verdict,
3219
+ ...r ? { comment: r } : {}
3220
+ })
3221
+ ), s;
3222
+ }
3116
3223
  replyToolCallConsents(t, e, s) {
3117
3224
  const r = this.conversation$.value.pendingConsent;
3118
3225
  return this.conversation$.next(this.conversation$.value.clearPendingConsent()), this.fetchSse(
3119
3226
  "user",
3120
3227
  {
3121
- action: B.RESPONSE_TOOL_CALL_CONSENT,
3228
+ action: H.RESPONSE_TOOL_CALL_CONSENT,
3122
3229
  customChannelId: this.customChannelId,
3123
3230
  customMessageId: this.lastSentMessageId ?? this.customMessageId,
3124
3231
  payload: this.resolvePayload(s),
@@ -3157,7 +3264,7 @@ class G {
3157
3264
  return r ? Promise.reject(new ne(r.processId)) : this.fetchSse(
3158
3265
  "nudge",
3159
3266
  {
3160
- action: B.NUDGE,
3267
+ action: H.NUDGE,
3161
3268
  customChannelId: this.customChannelId,
3162
3269
  customMessageId: this.lastSentMessageId ?? this.customMessageId,
3163
3270
  payload: this.resolvePayload(e),
@@ -3240,7 +3347,20 @@ class G {
3240
3347
  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();
3241
3348
  }
3242
3349
  }
3350
+ const An = {
3351
+ GOOD: "[Response Feedback: Good]",
3352
+ BAD: "[Response Feedback: Bad]"
3353
+ }, Ln = 8 * 1024;
3243
3354
  function Un(n) {
3355
+ return new TextEncoder().encode(n).length;
3356
+ }
3357
+ function Nn(n, t) {
3358
+ const e = An[n], s = t?.trim() ?? "";
3359
+ return s ? `${e}
3360
+
3361
+ ${s}` : e;
3362
+ }
3363
+ function Rn(n) {
3244
3364
  const t = /^sandbox:\/\/([^/]+)\/([^?#]+)(?:\?([^#]*))?/.exec(n.trim());
3245
3365
  if (!t) return null;
3246
3366
  const e = decodeURIComponent(t[1]), s = t[2], r = new URLSearchParams(t[3] ?? "");
@@ -3253,34 +3373,38 @@ function Un(n) {
3253
3373
  }
3254
3374
  export {
3255
3375
  _n as AsgardServiceClient,
3256
- Ln as AsgardSourceSetClient,
3376
+ Mn as AsgardSourceSetClient,
3257
3377
  G as Channel,
3258
3378
  ne as ChannelAwaitingConsentError,
3259
3379
  te as ChannelBusyError,
3260
3380
  g as Conversation,
3261
- d as EventType,
3262
- B as FetchSseAction,
3263
- E as HttpError,
3381
+ l as EventType,
3382
+ Ln as FEEDBACK_COMMENT_MAX_BYTES,
3383
+ H as FetchSseAction,
3384
+ y as HttpError,
3264
3385
  Te as MessageTemplateType,
3386
+ An as RESPONSE_FEEDBACK_PREFIX,
3265
3387
  rn as SOURCE_SET_DEFAULT_MAX_ENTRIES,
3266
- We as SOURCE_SET_MAX_PAGE_SIZE,
3388
+ Xe as SOURCE_SET_MAX_PAGE_SIZE,
3267
3389
  nn as SOURCE_SET_VOLUME_ROOT,
3268
3390
  Ye as ToolCallConsentResult,
3269
3391
  C as assertVolumePath,
3392
+ Nn as composeFeedbackMessage,
3270
3393
  vn as conversationToSubagentEvents,
3271
3394
  Tn as createDerivedStores,
3272
3395
  yn as deriveSubagents,
3273
3396
  Sn as deriveTasks,
3397
+ Un as feedbackCommentByteLength,
3274
3398
  pn as isAgentTool,
3275
3399
  Pn as isChannelAwaitingConsentError,
3276
- On as isChannelBusyError,
3277
- An as isHttpError,
3278
- mn as isSubagentChildTool,
3400
+ kn as isChannelBusyError,
3401
+ On as isHttpError,
3402
+ gn as isSubagentChildTool,
3279
3403
  hn as isTaskTool,
3280
3404
  Ie as reconcileLaunched,
3281
- gn as reduceSubagents,
3405
+ mn as reduceSubagents,
3282
3406
  fn as reduceTaskEvents,
3283
- Un as resolveSandboxUri,
3407
+ Rn as resolveSandboxUri,
3284
3408
  In as subagentsEqual,
3285
3409
  wn as tasksEqual
3286
3410
  };