@aintela/chat 0.8.0 → 0.10.0

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.
Files changed (44) hide show
  1. package/dist/Memory-BUnmYGNv.js.map +1 -1
  2. package/dist/PersonaAvatar-tKaWpDeQ.js +199 -0
  3. package/dist/PersonaAvatar-tKaWpDeQ.js.map +1 -0
  4. package/dist/agent-team.d.ts +2 -0
  5. package/dist/agent-team.js +27 -0
  6. package/dist/agent-team.js.map +1 -0
  7. package/dist/components.js +8543 -8995
  8. package/dist/components.js.map +1 -1
  9. package/dist/{detachedRunActivity-RNg1JDDW.js → detachedRunActivity-DWOR3cAC.js} +227 -224
  10. package/dist/detachedRunActivity-DWOR3cAC.js.map +1 -0
  11. package/dist/hooks.js +1 -1
  12. package/dist/{httpSessionService-DLdoBZRW.js → httpSessionService-BIkDesYB.js} +32 -31
  13. package/dist/{httpSessionService-DLdoBZRW.js.map → httpSessionService-BIkDesYB.js.map} +1 -1
  14. package/dist/index.js +289 -278
  15. package/dist/index.js.map +1 -1
  16. package/dist/serializer-DvR3nOcf.js.map +1 -1
  17. package/dist/services.js +2 -2
  18. package/dist/src/agentTeam.d.ts +3 -0
  19. package/dist/src/components/AgentTeam/PersonaAvatar.d.ts +7 -1
  20. package/dist/src/components/AgentTeam/__tests__/personaFixtures.d.ts +3 -0
  21. package/dist/src/components/AgentTeam/agentRoles.d.ts +2 -2
  22. package/dist/src/components/AgentTeam/chatAgent.d.ts +1 -1
  23. package/dist/src/components/AgentTeam/personas.d.ts +65 -4
  24. package/dist/src/components/AiChat/AiChatContext.d.ts +9 -0
  25. package/dist/src/components/AiChat/AiChatTypes.d.ts +6 -0
  26. package/dist/src/components/AiChat/ChatPane/ChatTurn.d.ts +33 -0
  27. package/dist/src/components/AiChat/ChatPane/CurrentMessage.d.ts +6 -4
  28. package/dist/src/components/AiChat/ChatPane/parts/ReadOnlyGuard.d.ts +9 -0
  29. package/dist/src/components/AiChat/ChatPane/parts/uiPartStage.d.ts +15 -10
  30. package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.d.ts +6 -0
  31. package/dist/src/components/AiChat/ChatPane/turnCommitKeepsUiTools.test.d.ts +1 -0
  32. package/dist/src/components/LlmResponseRender/EnvironmentContext.d.ts +7 -0
  33. package/dist/src/components/index.d.ts +1 -1
  34. package/dist/src/components/v2/SharedSessionTranscript.d.ts +76 -0
  35. package/dist/src/components/v2/index.d.ts +2 -0
  36. package/dist/src/models/ChatSession.d.ts +6 -0
  37. package/dist/src/models/Interaction.d.ts +1 -1
  38. package/dist/src/models/contexts.d.ts +6 -0
  39. package/dist/src/services/detachedRun/DetachedRunFramesTransport.d.ts +11 -0
  40. package/dist/src/services/detachedRun/streamDetachedRunFrames.d.ts +7 -0
  41. package/dist/{useChatSessions-DwqgYo79.js → useChatSessions-CyFKVtkk.js} +2 -2
  42. package/dist/{useChatSessions-DwqgYo79.js.map → useChatSessions-CyFKVtkk.js.map} +1 -1
  43. package/package.json +8 -1
  44. package/dist/detachedRunActivity-RNg1JDDW.js.map +0 -1
@@ -1,16 +1,16 @@
1
- var mt = Object.defineProperty;
2
- var Rt = (i, t, e) => t in i ? mt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var h = (i, t) => mt(i, "name", { value: t, configurable: !0 });
4
- var o = (i, t, e) => Rt(i, typeof t != "symbol" ? t + "" : t, e);
5
- import { i as N, E as I, S as x, z as wt, C as U, j as bt, L as Lt, P as z, n as Pt, q as Ft, T as _t, o as Nt, s as et, B as Ut } from "./serializer-DvR3nOcf.js";
6
- import { format as xt } from "date-fns";
7
- import qt from "lodash";
8
- import { C as E, P as Wt } from "./Prompt-DZb7OaPp.js";
9
- import { d as Bt } from "./environmentUtils-VZNTCzEE.js";
10
- import { r as Gt } from "./httpSessionService-DLdoBZRW.js";
1
+ var wt = Object.defineProperty;
2
+ var bt = (i, t, e) => t in i ? wt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var h = (i, t) => wt(i, "name", { value: t, configurable: !0 });
4
+ var o = (i, t, e) => bt(i, typeof t != "symbol" ? t + "" : t, e);
5
+ import { i as N, E as I, S as x, z as St, C as U, j as Lt, L as Pt, P as z, n as Ft, q as _t, T as Nt, o as Ut, s as et, B as xt } from "./serializer-DvR3nOcf.js";
6
+ import { format as qt } from "date-fns";
7
+ import Wt from "lodash";
8
+ import { C, P as Bt } from "./Prompt-DZb7OaPp.js";
9
+ import { d as Gt } from "./environmentUtils-VZNTCzEE.js";
10
+ import { r as zt } from "./httpSessionService-BIkDesYB.js";
11
11
  const Q = {
12
12
  PROMPTS: "envision-prompts"
13
- }, zt = 50, nt = class nt {
13
+ }, Ht = 50, nt = class nt {
14
14
  getPrompts() {
15
15
  try {
16
16
  const t = localStorage.getItem(Q.PROMPTS);
@@ -40,7 +40,7 @@ const Q = {
40
40
  storePrompt(t) {
41
41
  try {
42
42
  const e = this.getPrompts().filter((s) => s.promptText !== t.promptText);
43
- e.unshift(t), localStorage.setItem(Q.PROMPTS, JSON.stringify(e.slice(0, zt)));
43
+ e.unshift(t), localStorage.setItem(Q.PROMPTS, JSON.stringify(e.slice(0, Ht)));
44
44
  } catch (e) {
45
45
  console.error("Error storing prompt:", e);
46
46
  }
@@ -54,8 +54,8 @@ const Q = {
54
54
  }
55
55
  };
56
56
  h(nt, "LocalStorageService");
57
- let St = nt;
58
- const $e = /* @__PURE__ */ h((i) => {
57
+ let It = nt;
58
+ const Re = /* @__PURE__ */ h((i) => {
59
59
  const t = i.getPrompts(), e = t.length;
60
60
  if (e > 0) {
61
61
  const s = t[0].promptText, n = t[t.length - 1].promptText, r = t[0].created;
@@ -237,8 +237,8 @@ const d = new X(), rt = class rt {
237
237
  }
238
238
  };
239
239
  h(rt, "EventBusService");
240
- let It = rt;
241
- const Ht = 2e3;
240
+ let Tt = rt;
241
+ const Jt = 2e3;
242
242
  function q(i) {
243
243
  i.parts === i.prev.parts && (i.parts = i.prev.parts.slice());
244
244
  }
@@ -247,13 +247,13 @@ function J(i) {
247
247
  i.functionMap === i.prev.functionMap && (i.functionMap = new Map(i.functionMap));
248
248
  }
249
249
  h(J, "ownFunctionMap");
250
- const Jt = /* @__PURE__ */ h((i) => i == I.FunctionCall || i == I.PartialFunctionCall, "isFunctionCall"), jt = /* @__PURE__ */ h((i) => i == I.FunctionResponse, "isFunctionResponse"), At = /* @__PURE__ */ h((i) => i.parts.length + 1 + "-" + i.prev.interactionId, "nextPartId");
251
- function Kt(i, t) {
250
+ const jt = /* @__PURE__ */ h((i) => i == I.FunctionCall || i == I.PartialFunctionCall, "isFunctionCall"), Kt = /* @__PURE__ */ h((i) => i == I.FunctionResponse, "isFunctionResponse"), Ot = /* @__PURE__ */ h((i) => i.parts.length + 1 + "-" + i.prev.interactionId, "nextPartId");
251
+ function Qt(i, t) {
252
252
  var e, s, n, r, a;
253
- return !!(!t || i.mustPush || i.mustPush === !1 && (i.eventType !== t.eventType || ((e = i.functionDetails) == null ? void 0 : e.id) !== ((s = t.functionDetails) == null ? void 0 : s.id)) || i.textAppendable && (((r = (n = t.thoughtDetails) == null ? void 0 : n.text) == null ? void 0 : r.length) ?? ((a = t.text) == null ? void 0 : a.length) ?? 0) > Ht);
253
+ return !!(!t || i.mustPush || i.mustPush === !1 && (i.eventType !== t.eventType || ((e = i.functionDetails) == null ? void 0 : e.id) !== ((s = t.functionDetails) == null ? void 0 : s.id)) || i.textAppendable && (((r = (n = t.thoughtDetails) == null ? void 0 : n.text) == null ? void 0 : r.length) ?? ((a = t.text) == null ? void 0 : a.length) ?? 0) > Jt);
254
254
  }
255
- h(Kt, "opensNewPart");
256
- function Qt(i, t) {
255
+ h(Qt, "opensNewPart");
256
+ function Yt(i, t) {
257
257
  const e = t.functionDetails.id, s = t.functionDetails.clientOutput, n = i.parts.findIndex((r) => {
258
258
  var a;
259
259
  return ((a = r.functionDetails) == null ? void 0 : a.id) === e;
@@ -272,18 +272,18 @@ function Qt(i, t) {
272
272
  } else {
273
273
  const r = {
274
274
  ...t,
275
- id: At(i),
275
+ id: Ot(i),
276
276
  functionDetails: { ...t.functionDetails, silent: !0 }
277
277
  };
278
278
  q(i), i.parts.push(r), J(i), i.functionMap.set(e, r);
279
279
  }
280
280
  }
281
- h(Qt, "foldClientOutput");
282
- function Yt(i, t, e, s, n) {
281
+ h(Yt, "foldClientOutput");
282
+ function Xt(i, t, e, s, n) {
283
283
  var p;
284
- const r = i.parts.findIndex((m) => {
284
+ const r = i.parts.findIndex((w) => {
285
285
  var u;
286
- return ((u = m.functionDetails) == null ? void 0 : u.id) === s;
286
+ return ((u = w.functionDetails) == null ? void 0 : u.id) === s;
287
287
  }), a = r > -1 ? i.parts[r] : e, c = t.functionDetails, l = a.functionDetails, f = {
288
288
  ...a,
289
289
  eventType: t.eventType,
@@ -314,20 +314,20 @@ function Yt(i, t, e, s, n) {
314
314
  };
315
315
  J(i), i.functionMap.set(s, f), f.eventType === I.FunctionResponse && ((p = n == null ? void 0 : n.onFunctionResponse) == null || p.call(n, f.functionDetails)), r > -1 && (q(i), i.parts[r] = f);
316
316
  }
317
- h(Yt, "foldFunctionEvent");
318
- function Xt(i, t, e, s) {
317
+ h(Xt, "foldFunctionEvent");
318
+ function Vt(i, t, e, s) {
319
319
  s && t.functionDetails && (J(i), i.functionMap.set(s, t));
320
320
  const n = i.prev.parts[i.prev.parts.length - 1] ?? null;
321
321
  n && n.textAppendable && (q(i), i.parts[i.parts.length - 1] = { ...n, ended: /* @__PURE__ */ new Date() });
322
322
  const r = {
323
323
  ...t,
324
- id: At(i),
324
+ id: Ot(i),
325
325
  partial: e.partial
326
326
  };
327
327
  i.parts = [...i.parts, r];
328
328
  }
329
- h(Xt, "openPart");
330
- function Vt(i, t, e, s) {
329
+ h(Vt, "openPart");
330
+ function Zt(i, t, e, s) {
331
331
  const n = i.parts[i.parts.length - 1] ?? null;
332
332
  if (!n) return;
333
333
  const r = {
@@ -344,8 +344,8 @@ function Vt(i, t, e, s) {
344
344
  r.text = t.text ?? "", r.textDetails.version++, t.thoughtDetails && (r.thoughtDetails = { ...t.thoughtDetails, text: t.thoughtDetails.text.trim() });
345
345
  q(i), i.parts[i.parts.length - 1] = r;
346
346
  }
347
- h(Vt, "appendText");
348
- function Zt(i, t) {
347
+ h(Zt, "appendText");
348
+ function te(i, t) {
349
349
  if (!t || t.length === 0) return i;
350
350
  const e = i.slice();
351
351
  for (const s of t) {
@@ -354,8 +354,8 @@ function Zt(i, t) {
354
354
  }
355
355
  return e;
356
356
  }
357
- h(Zt, "mergeArtifacts");
358
- function te(i, t, e) {
357
+ h(te, "mergeArtifacts");
358
+ function ee(i, t, e) {
359
359
  var c, l;
360
360
  const s = N.FlatParts(t == null ? void 0 : t.parts), n = i.parts[i.parts.length - 1] ?? null, r = {
361
361
  prev: i,
@@ -365,20 +365,20 @@ function te(i, t, e) {
365
365
  let a = !1;
366
366
  if (s) {
367
367
  if (s.eventType === I.FunctionClientOutput && !!((c = s.functionDetails) != null && c.id))
368
- Qt(r, s);
369
- else if (Kt(s, n)) {
370
- const p = Jt(s.eventType) || jt(s.eventType), m = p ? (l = s.functionDetails) == null ? void 0 : l.id : void 0;
371
- p && !m && console.error("Got isCall or isResponse without a callId", s);
372
- const u = m ? r.functionMap.get(m) : void 0;
373
- u && m && s.functionDetails ? Yt(r, s, u, m, e) : (Xt(r, s, t, m), a = !0);
368
+ Yt(r, s);
369
+ else if (Qt(s, n)) {
370
+ const p = jt(s.eventType) || Kt(s.eventType), w = p ? (l = s.functionDetails) == null ? void 0 : l.id : void 0;
371
+ p && !w && console.error("Got isCall or isResponse without a callId", s);
372
+ const u = w ? r.functionMap.get(w) : void 0;
373
+ u && w && s.functionDetails ? Xt(r, s, u, w, e) : (Vt(r, s, t, w), a = !0);
374
374
  }
375
- s.textAppendable && Vt(r, s, t, a);
375
+ s.textAppendable && Zt(r, s, t, a);
376
376
  }
377
377
  return {
378
378
  ...i,
379
379
  version: i.version + 1,
380
380
  parts: r.parts,
381
- artifactData: Zt(i.artifactData ?? [], t.llmArtifacts),
381
+ artifactData: te(i.artifactData ?? [], t.llmArtifacts),
382
382
  functionMap: r.functionMap,
383
383
  turn_complete: t.turn_complete,
384
384
  partial: t.partial,
@@ -386,7 +386,7 @@ function te(i, t, e) {
386
386
  agent: t.agent ?? i.agent
387
387
  };
388
388
  }
389
- h(te, "reduceInteraction");
389
+ h(ee, "reduceInteraction");
390
390
  const ot = class ot {
391
391
  constructor(t, e) {
392
392
  o(this, "interaction");
@@ -399,7 +399,7 @@ const ot = class ot {
399
399
  * throttled subscribers cannot diverge from live state.
400
400
  */
401
401
  merge(t) {
402
- const e = te(this.interaction, t, {
402
+ const e = ee(this.interaction, t, {
403
403
  onFunctionResponse: /* @__PURE__ */ h((s) => this.eventBusService.gatewayEmitFunctionResponse(s), "onFunctionResponse")
404
404
  });
405
405
  return this.interaction = e, e;
@@ -407,7 +407,7 @@ const ot = class ot {
407
407
  };
408
408
  h(ot, "InteractionService");
409
409
  let j = ot;
410
- const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, re = 0.2, _ = 300 * 1e3, oe = 0.75, ae = 2e3, w = "[Connection]", at = class at {
410
+ const kt = 4001, se = 4002, Dt = 4004, ne = 4100, H = 500, ie = 2e4, re = 1e3, oe = 0.2, _ = 300 * 1e3, ae = 0.75, ce = 2e3, S = "[Connection]", at = class at {
411
411
  constructor(t) {
412
412
  o(this, "ports");
413
413
  o(this, "state");
@@ -449,7 +449,7 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
449
449
  /** Connected by the store AND by the transport. */
450
450
  get isUp() {
451
451
  var t, e;
452
- return this.state.connectionStatus === E.Connected && (((e = (t = this.ports).isConnected) == null ? void 0 : e.call(t)) ?? !0);
452
+ return this.state.connectionStatus === C.Connected && (((e = (t = this.ports).isConnected) == null ? void 0 : e.call(t)) ?? !0);
453
453
  }
454
454
  // ─── Commands ───────────────────────────────────────────────────────────
455
455
  /**
@@ -464,7 +464,7 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
464
464
  if (this.inflight) return this.inflight;
465
465
  if (this.isUp && this.target.sessionId && !this.halted)
466
466
  return Promise.resolve(this.target.sessionId);
467
- } else this.target && (console.log(`${w} switching from session ${this.target.sessionId ?? "(new)"} to ${t ?? "(new)"}.`), this.close());
467
+ } else this.target && (console.log(`${S} switching from session ${this.target.sessionId ?? "(new)"} to ${t ?? "(new)"}.`), this.close());
468
468
  return this.halted = null, this.cancelRetry(), this.target = { sessionId: t, resume: (e == null ? void 0 : e.resume) === !0, prepare: e == null ? void 0 : e.prepare }, this.startIdleTick(), this.dial();
469
469
  }
470
470
  /**
@@ -476,7 +476,7 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
476
476
  var e;
477
477
  if (this.halted)
478
478
  throw new Error(`The connection was halted (${this.halted}); session ${((e = this.target) == null ? void 0 : e.sessionId) ?? t ?? "none"} cannot be redialled.`);
479
- return this.target ? this.inflight ? this.inflight : this.isUp && this.target.sessionId ? this.target.sessionId : (console.warn(`${w} send guard: socket is DOWN at send time (session ${this.target.sessionId ?? "(new)"}, status ${this.state.connectionStatus}) — redialling now instead of in ${this.wait}ms.`), this.cancelRetry(), this.target.resume = !0, this.dial()) : (console.warn(`${w} send guard: nothing supervised yet — opening session ${t ?? "(new)"} with the replay cursor.`), this.open(t, { resume: !0 }));
479
+ return this.target ? this.inflight ? this.inflight : this.isUp && this.target.sessionId ? this.target.sessionId : (console.warn(`${S} send guard: socket is DOWN at send time (session ${this.target.sessionId ?? "(new)"}, status ${this.state.connectionStatus}) — redialling now instead of in ${this.wait}ms.`), this.cancelRetry(), this.target.resume = !0, this.dial()) : (console.warn(`${S} send guard: nothing supervised yet — opening session ${t ?? "(new)"} with the replay cursor.`), this.open(t, { resume: !0 }));
480
480
  }
481
481
  /** Stop supervising: hang up, cancel any retry, stop the idle tick. Never throws. */
482
482
  close() {
@@ -485,9 +485,9 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
485
485
  try {
486
486
  this.ports.hangUp();
487
487
  } catch (e) {
488
- console.error(`${w} hangUp threw`, e);
488
+ console.error(`${S} hangUp threw`, e);
489
489
  }
490
- t && this.state.setConnectionStatus(E.Disconnected);
490
+ t && this.state.setConnectionStatus(C.Disconnected);
491
491
  }
492
492
  // ─── Transport reports ──────────────────────────────────────────────────
493
493
  /**
@@ -501,24 +501,24 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
501
501
  * A close that lands while a dial is in flight is remembered and judged when that dial fails.
502
502
  */
503
503
  transportClosed(t, e) {
504
- if (t !== Ot && (this.lastCloseCode = t, !!this.target)) {
504
+ if (t !== kt && (this.lastCloseCode = t, !!this.target)) {
505
505
  if (this.inflight) {
506
- console.log(`${w} socket closed (code=${t}) while a dial is in flight — judged when it settles.`);
506
+ console.log(`${S} socket closed (code=${t}) while a dial is in flight — judged when it settles.`);
507
507
  return;
508
508
  }
509
- this.state.connectionStatus === E.Connected && (console.warn(`${w} socket closed: code=${t} reason="${e}" (session ${this.target.sessionId ?? "(new)"}).`), this.state.setConnectionStatus(E.Disconnected), this.judge(t));
509
+ this.state.connectionStatus === C.Connected && (console.warn(`${S} socket closed: code=${t} reason="${e}" (session ${this.target.sessionId ?? "(new)"}).`), this.state.setConnectionStatus(C.Disconnected), this.judge(t));
510
510
  }
511
511
  }
512
512
  // ─── The dial ───────────────────────────────────────────────────────────
513
513
  dial() {
514
514
  const t = this.target;
515
- this.lastCloseCode = null, this.state.setConnectionStatus(E.Connecting);
515
+ this.lastCloseCode = null, this.state.setConnectionStatus(C.Connecting);
516
516
  const e = this.now();
517
- console.log(`${w} dialling session ${t.sessionId ?? "(new)"}${t.resume ? " with the replay cursor" : ""}${this.everConnected ? " (reconnect)" : ""}.`);
517
+ console.log(`${S} dialling session ${t.sessionId ?? "(new)"}${t.resume ? " with the replay cursor" : ""}${this.everConnected ? " (reconnect)" : ""}.`);
518
518
  const n = (async () => (t.prepare && await t.prepare(), this.ports.dial(t.sessionId, { resume: t.resume })))().then((r) => {
519
519
  var c, l;
520
520
  if (this.target !== t) {
521
- console.log(`${w} a dial for ${t.sessionId ?? "(new)"} resolved after it was abandoned — hanging up.`);
521
+ console.log(`${S} a dial for ${t.sessionId ?? "(new)"} resolved after it was abandoned — hanging up.`);
522
522
  try {
523
523
  this.ports.hangUp();
524
524
  } catch {
@@ -526,19 +526,19 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
526
526
  throw new Error("Connection attempt abandoned");
527
527
  }
528
528
  if (t.sessionId && r !== t.sessionId) {
529
- console.error(`${w} asked for session ${t.sessionId}, the server answered with ${r} — refusing the swap and halting.`);
529
+ console.error(`${S} asked for session ${t.sessionId}, the server answered with ${r} — refusing the swap and halting.`);
530
530
  try {
531
531
  this.ports.hangUp();
532
532
  } catch {
533
533
  }
534
- throw this.state.setConnectionStatus(E.Disconnected), this.halt("session-gone", { sessionId: t.sessionId, actualSessionId: r }), new Error(`Session ${t.sessionId} no longer exists on the server (it answered with ${r}).`);
534
+ throw this.state.setConnectionStatus(C.Disconnected), this.halt("session-gone", { sessionId: t.sessionId, actualSessionId: r }), new Error(`Session ${t.sessionId} no longer exists on the server (it answered with ${r}).`);
535
535
  }
536
536
  const a = this.everConnected;
537
- return this.everConnected = !0, t.sessionId = r, t.resume = !0, t.prepare = void 0, this.wait = H, this.attempt = 0, this.state.setConnectionStatus(E.Connected), console.log(`${w} ${a ? "reconnected to" : "connected to"} session ${r} in ${this.now() - e}ms.`), (l = (c = this.ports).onConnected) == null || l.call(c, r, { reconnect: a }), r;
537
+ return this.everConnected = !0, t.sessionId = r, t.resume = !0, t.prepare = void 0, this.wait = H, this.attempt = 0, this.state.setConnectionStatus(C.Connected), console.log(`${S} ${a ? "reconnected to" : "connected to"} session ${r} in ${this.now() - e}ms.`), (l = (c = this.ports).onConnected) == null || l.call(c, r, { reconnect: a }), r;
538
538
  }).catch((r) => {
539
539
  if (this.target === t && !this.halted) {
540
540
  const a = this.lastCloseCode;
541
- console.error(`${w} dial of session ${t.sessionId ?? "(new)"} failed after ${this.now() - e}ms${a !== null ? ` (socket closed with ${a})` : ""}:`, r), this.state.setConnectionStatus(E.Disconnected), this.inflight === n && (this.inflight = null), this.judge(a);
541
+ console.error(`${S} dial of session ${t.sessionId ?? "(new)"} failed after ${this.now() - e}ms${a !== null ? ` (socket closed with ${a})` : ""}:`, r), this.state.setConnectionStatus(C.Disconnected), this.inflight === n && (this.inflight = null), this.judge(a);
542
542
  }
543
543
  throw r;
544
544
  }).finally(() => {
@@ -550,33 +550,33 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
550
550
  judge(t) {
551
551
  var s;
552
552
  const e = (s = this.target) == null ? void 0 : s.sessionId;
553
- if (t === ee) return this.halt("attached-elsewhere", { sessionId: e, code: t });
554
- if (t === kt) return this.halt("session-gone", { sessionId: e, code: t });
553
+ if (t === se) return this.halt("attached-elsewhere", { sessionId: e, code: t });
554
+ if (t === Dt) return this.halt("session-gone", { sessionId: e, code: t });
555
555
  if (t === 1e3 || t === 1008) return this.halt("closed-by-server", { sessionId: e, code: t });
556
556
  this.scheduleRetry();
557
557
  }
558
558
  halt(t, e) {
559
559
  var s, n;
560
- this.halted = t, this.cancelRetry(), console.warn(`${w} halted (${t}) on session ${e.sessionId ?? "(new)"}${e.code !== void 0 ? `, close code ${e.code}` : ""} — no automatic redial; an explicit open() may try again.`);
560
+ this.halted = t, this.cancelRetry(), console.warn(`${S} halted (${t}) on session ${e.sessionId ?? "(new)"}${e.code !== void 0 ? `, close code ${e.code}` : ""} — no automatic redial; an explicit open() may try again.`);
561
561
  try {
562
562
  (n = (s = this.ports).onHalt) == null || n.call(s, t, e);
563
563
  } catch (r) {
564
- console.error(`${w} onHalt threw`, r);
564
+ console.error(`${S} onHalt threw`, r);
565
565
  }
566
566
  }
567
567
  scheduleRetry() {
568
568
  var e, s;
569
569
  if (!this.target || this.retryTimer || this.inflight) return;
570
570
  if (!this.state.sessionActive) {
571
- console.log(`${w} session idle — not redialling until activity resumes.`);
571
+ console.log(`${S} session idle — not redialling until activity resumes.`);
572
572
  return;
573
573
  }
574
574
  const t = this.jittered(this.wait);
575
- this.wait = Math.min(Math.floor(this.wait + this.wait * this.wait / ie), ne), this.attempt += 1, console.warn(`${w} redialling session ${this.target.sessionId ?? "(new)"} in ${t}ms (then ${this.wait}ms, attempt ${this.attempt}).`);
575
+ this.wait = Math.min(Math.floor(this.wait + this.wait * this.wait / re), ie), this.attempt += 1, console.warn(`${S} redialling session ${this.target.sessionId ?? "(new)"} in ${t}ms (then ${this.wait}ms, attempt ${this.attempt}).`);
576
576
  try {
577
577
  (s = (e = this.ports).onRetryScheduled) == null || s.call(e, { sessionId: this.target.sessionId, delayMs: t, attempt: this.attempt });
578
578
  } catch (n) {
579
- console.error(`${w} onRetryScheduled threw`, n);
579
+ console.error(`${S} onRetryScheduled threw`, n);
580
580
  }
581
581
  this.retryTimer = setTimeout(() => {
582
582
  this.retryTimer = null, !(!this.target || this.halted) && (this.target.resume = !0, this.dial().catch(() => {
@@ -587,7 +587,7 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
587
587
  this.retryTimer && (clearTimeout(this.retryTimer), this.retryTimer = null);
588
588
  }
589
589
  jittered(t) {
590
- return Math.max(0, Math.round(t + t * re * (Math.random() * 2 - 1)));
590
+ return Math.max(0, Math.round(t + t * oe * (Math.random() * 2 - 1)));
591
591
  }
592
592
  sameTarget(t) {
593
593
  var e;
@@ -595,7 +595,7 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
595
595
  }
596
596
  // ─── Idle ───────────────────────────────────────────────────────────────
597
597
  startIdleTick() {
598
- this.idleTimer || (this.idleTimer = setInterval(() => this.tick(), ae));
598
+ this.idleTimer || (this.idleTimer = setInterval(() => this.tick(), ce));
599
599
  }
600
600
  stopIdleTick() {
601
601
  this.idleTimer && (clearInterval(this.idleTimer), this.idleTimer = null);
@@ -613,19 +613,19 @@ const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, r
613
613
  this.state.turnOpen && this.state.setLastActivity();
614
614
  const t = this.now() - this.state.lastActivity;
615
615
  if (t > _) {
616
- if (this.state.sessionActive && this.state.setIsSessionActive(!1), this.cancelRetry(), this.state.connectionStatus === E.Connected) {
617
- console.warn(`${w} idle for ${Math.round(t / 1e3)}s (limit ${_ / 1e3}s) — closing the socket (session ${this.target.sessionId ?? "(new)"}). Activity, or a send, redials it.`);
616
+ if (this.state.sessionActive && this.state.setIsSessionActive(!1), this.cancelRetry(), this.state.connectionStatus === C.Connected) {
617
+ console.warn(`${S} idle for ${Math.round(t / 1e3)}s (limit ${_ / 1e3}s) — closing the socket (session ${this.target.sessionId ?? "(new)"}). Activity, or a send, redials it.`);
618
618
  try {
619
619
  this.ports.hangUp();
620
620
  } catch (e) {
621
- console.error(`${w} hangUp threw`, e);
621
+ console.error(`${S} hangUp threw`, e);
622
622
  }
623
- this.state.setConnectionStatus(E.Disconnected);
623
+ this.state.setConnectionStatus(C.Disconnected);
624
624
  }
625
625
  return;
626
626
  }
627
- this.state.sessionActive || (console.log(`${w} activity resumed — the session is active again.`), this.state.setIsSessionActive(!0), this.wait = H, this.state.connectionStatus === E.Disconnected && !this.halted && !this.inflight && (this.target.resume = !0, this.dial().catch(() => {
628
- }))), t > _ * oe ? this.idleWarningLogged || (this.idleWarningLogged = !0, console.warn(`${w} idle ${Math.round(t / 1e3)}s of ${_ / 1e3}s — the socket closes in about ${Math.round((_ - t) / 1e3)}s unless something happens.`)) : this.idleWarningLogged = !1;
627
+ this.state.sessionActive || (console.log(`${S} activity resumed — the session is active again.`), this.state.setIsSessionActive(!0), this.wait = H, this.state.connectionStatus === C.Disconnected && !this.halted && !this.inflight && (this.target.resume = !0, this.dial().catch(() => {
628
+ }))), t > _ * ae ? this.idleWarningLogged || (this.idleWarningLogged = !0, console.warn(`${S} idle ${Math.round(t / 1e3)}s of ${_ / 1e3}s — the socket closes in about ${Math.round((_ - t) / 1e3)}s unless something happens.`)) : this.idleWarningLogged = !1;
629
629
  }
630
630
  };
631
631
  h(at, "ConnectionSupervisor");
@@ -665,7 +665,7 @@ const ct = class ct {
665
665
  h(ct, "ThrottledEmitter");
666
666
  let Z = ct;
667
667
  const y = class y {
668
- constructor(t, e, s, n, r, a, c, l, f, p, m) {
668
+ constructor(t, e, s, n, r, a, c, l, f, p, w) {
669
669
  o(this, "base_url");
670
670
  o(this, "msg_order", 0);
671
671
  o(this, "interactionsMap", /* @__PURE__ */ new Map());
@@ -722,7 +722,7 @@ const y = class y {
722
722
  o(this, "detachedRunInteractionServices", /* @__PURE__ */ new Map());
723
723
  // ─── Artifacts ──────────────────────────────────────────────────────────
724
724
  o(this, "runningRequests", /* @__PURE__ */ new Map());
725
- this.options = m ?? {}, this.user = t, this.config = r, this.rawJwt = t.access_token, this.base_url = n, this.eventBusService = e, this.sessionId = p, this.artifactService = s, this.sessionState = a.getState(), this.notificationPort = c, this.storageService = f, a.subscribe((u, g) => {
725
+ this.options = w ?? {}, this.user = t, this.config = r, this.rawJwt = t.access_token, this.base_url = n, this.eventBusService = e, this.sessionId = p, this.artifactService = s, this.sessionState = a.getState(), this.notificationPort = c, this.storageService = f, a.subscribe((u, g) => {
726
726
  this.sessionState = u, g.turnOpen && !u.turnOpen && this.flushAnnouncements();
727
727
  }), this.wsService = l, this.connection = new V({
728
728
  store: a,
@@ -737,13 +737,13 @@ const y = class y {
737
737
  this.sessionId = u, this.sessionState.setConnectionOutage(null), this.eventBusService.gatewayEmitConnected(u, g), this.flushAnnouncements();
738
738
  }, "onConnected"),
739
739
  onRetryScheduled: /* @__PURE__ */ h(({ delayMs: u, attempt: g }) => {
740
- var M;
741
- const S = Date.now(), D = ((M = this.sessionState.connectionOutage) == null ? void 0 : M.since) ?? S;
742
- this.sessionState.setConnectionOutage({ since: D, retryAt: S + u, attempt: g, halted: null }), S - D >= y.OUTAGE_CLOSES_TURN_AFTER_MS && this.closeOpenTurnWith(y.OUTAGE_TURN_MESSAGE);
740
+ var D;
741
+ const m = Date.now(), v = ((D = this.sessionState.connectionOutage) == null ? void 0 : D.since) ?? m;
742
+ this.sessionState.setConnectionOutage({ since: v, retryAt: m + u, attempt: g, halted: null }), m - v >= y.OUTAGE_CLOSES_TURN_AFTER_MS && this.closeOpenTurnWith(y.OUTAGE_TURN_MESSAGE);
743
743
  }, "onRetryScheduled"),
744
744
  onHalt: /* @__PURE__ */ h((u, g) => {
745
- const S = this.sessionState.connectionOutage;
746
- this.sessionState.setConnectionOutage({ since: (S == null ? void 0 : S.since) ?? Date.now(), retryAt: null, attempt: (S == null ? void 0 : S.attempt) ?? 0, halted: u }), this.notifyHalt(u, g), this.closeOpenTurnWith(y.HALT_TURN_MESSAGE[u]);
745
+ const m = this.sessionState.connectionOutage;
746
+ this.sessionState.setConnectionOutage({ since: (m == null ? void 0 : m.since) ?? Date.now(), retryAt: null, attempt: (m == null ? void 0 : m.attempt) ?? 0, halted: u }), this.notifyHalt(u, g), this.closeOpenTurnWith(y.HALT_TURN_MESSAGE[u]);
747
747
  }, "onHalt")
748
748
  }), this.wsService.onEvent = async (u) => {
749
749
  await this.Message(u);
@@ -907,10 +907,10 @@ const y = class y {
907
907
  const s = this.interactionsServiceMap.get(e);
908
908
  if (s) {
909
909
  const n = s.interaction;
910
- n.interactionQuestion || (n.interactionQuestion = t.content ?? ""), n.origin ?? (n.origin = wt(t.origin));
910
+ n.interactionQuestion || (n.interactionQuestion = t.content ?? ""), n.origin ?? (n.origin = St(t.origin));
911
911
  return;
912
912
  }
913
- this.openRemoteInteraction(e, t.content ?? "", wt(t.origin), !0);
913
+ this.openRemoteInteraction(e, t.content ?? "", St(t.origin), !0);
914
914
  }
915
915
  getInteractions() {
916
916
  return Array.from(this.interactionsMap.values());
@@ -927,7 +927,7 @@ const y = class y {
927
927
  return e || (e = this.openRemoteInteraction(t.interactionId, "", void 0, !1)), e.merge(t);
928
928
  }
929
929
  getNewInteractionId() {
930
- const e = xt(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
930
+ const e = qt(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
931
931
  return `${this.msg_order}_${e}`;
932
932
  }
933
933
  // ─── Inbound: server events ─────────────────────────────────────────────
@@ -1112,7 +1112,7 @@ const y = class y {
1112
1112
  try {
1113
1113
  const { promptAsString: r, json: a } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(t.data) : { promptAsString: t.data, json: void 0 };
1114
1114
  this.sessionState.onRenderPrompt && (t.data = a, t.friendlyMessage = r);
1115
- const c = await this.sendMessageInternal(t, e), l = Wt.createPrompt(r ?? "", (a == null ? void 0 : a.toString()) ?? {});
1115
+ const c = await this.sendMessageInternal(t, e), l = Bt.createPrompt(r ?? "", (a == null ? void 0 : a.toString()) ?? {});
1116
1116
  this.storageService.storePrompt(l);
1117
1117
  const f = N.fromText("Planejando próximos passos");
1118
1118
  return this.sendStatusMessage(t.data, [n, f], s.toString() + "1"), c != null && c.success ? this.eventBusService.ChatEmitMessageSent(t.data, c.interaction) : this.eventBusService.ChatEmitMessageError((c == null ? void 0 : c.error) ?? ""), c;
@@ -1134,7 +1134,7 @@ const y = class y {
1134
1134
  }
1135
1135
  // Send a message to the server over the socket
1136
1136
  async sendMessageInternal(t, e) {
1137
- var r, a, c, l, f, p, m, u;
1137
+ var r, a, c, l, f, p, w, u, g, m;
1138
1138
  const s = this.suspendState;
1139
1139
  this.suspendState = !1;
1140
1140
  const n = this.startInteraction(t.friendlyMessage ?? t.data, s);
@@ -1156,16 +1156,17 @@ const y = class y {
1156
1156
  // against any registered LlmAgent variant without seeding a Mongo record.
1157
1157
  AgentImplementation: (l = this.config.agentConfig) == null ? void 0 : l.agentImplementation,
1158
1158
  Parameters: {
1159
- CustomerName: ((f = this.config.customer) == null ? void 0 : f.name) ?? "",
1160
- DataSet: ((p = this.config.customer) == null ? void 0 : p.dataSetId) ?? ""
1159
+ ...((p = (f = this.config).parameters) == null ? void 0 : p.call(f)) ?? {},
1160
+ CustomerName: ((w = this.config.customer) == null ? void 0 : w.name) ?? "",
1161
+ DataSet: ((u = this.config.customer) == null ? void 0 : u.dataSetId) ?? ""
1161
1162
  },
1162
1163
  // Forward image attachments as a structured payload (PascalCase
1163
1164
  // keys to match the C# `Message.Images` / `MessageImage` model).
1164
- Images: (m = t.images) != null && m.length ? t.images.map((g) => ({ MimeType: g.mimeType, Data: g.data })) : void 0,
1165
+ Images: (g = t.images) != null && g.length ? t.images.map((v) => ({ MimeType: v.mimeType, Data: v.data })) : void 0,
1165
1166
  // Client-only UI representation for this turn (PascalCase to match the C# `Message.UserUi`
1166
1167
  // model). The server persists it as a UserUiContent sibling and strips it from the model
1167
1168
  // request; Content remains the only model-facing text.
1168
- UserUi: (u = t.userUi) != null && u.name ? { Name: t.userUi.name, Args: t.userUi.args } : void 0
1169
+ UserUi: (m = t.userUi) != null && m.name ? { Name: t.userUi.name, Args: t.userUi.args } : void 0
1169
1170
  }), this.localOpen(n.interactionId, "system"), {
1170
1171
  interaction: n,
1171
1172
  success: !0
@@ -1174,7 +1175,7 @@ const y = class y {
1174
1175
  sendStatusMessage(t, e, s) {
1175
1176
  var r, a;
1176
1177
  let n;
1177
- ((a = (r = this.currentIS) == null ? void 0 : r.interaction) == null ? void 0 : a.turn_complete) === !1 && !this.currentIS.interaction.remote ? (n = qt.cloneDeep(this.currentIS.interaction), n.parts.push(...e)) : n = {
1178
+ ((a = (r = this.currentIS) == null ? void 0 : r.interaction) == null ? void 0 : a.turn_complete) === !1 && !this.currentIS.interaction.remote ? (n = Wt.cloneDeep(this.currentIS.interaction), n.parts.push(...e)) : n = {
1178
1179
  interactionId: "tmp" + s,
1179
1180
  created: /* @__PURE__ */ new Date(),
1180
1181
  partial: !0,
@@ -1291,59 +1292,59 @@ o(y, "NO_CONNECTION_MESSAGE", "Não foi possível obter conexão com o servidor"
1291
1292
  "session-gone": "A sessão não existe mais no servidor. A resposta foi interrompida.",
1292
1293
  "closed-by-server": "O servidor encerrou a conexão. A resposta foi interrompida."
1293
1294
  });
1294
- let Tt = y;
1295
- function ce(i) {
1296
- const t = new Lt();
1295
+ let yt = y;
1296
+ function le(i) {
1297
+ const t = new Pt();
1297
1298
  t.author = "main", t.streamingParts = i.streamingParts, i.partialEventType ? t.eventType = i.partialEventType : t.eventType = i.functionName ? { fullName: z.StreamingFunctionCallUpdateContent, type: I.PartialFunctionCall } : i.partialReasoning ? { fullName: z.StreamingReasoningContent, type: I.Thought } : { fullName: z.StreamingTextContent, type: I.Text }, t.interactionId = i.iteractionId ?? "", t.mimeType = "text/plain", t.partial = !0, t.role = { label: "Assistant" }, t.timestamp = i.timeStamp ?? (/* @__PURE__ */ new Date()).getTime(), t.turnComplete = !1;
1298
1299
  const e = t.eventType.type;
1299
1300
  if (e == I.PartialFunctionCall) {
1300
- const s = new Pt();
1301
+ const s = new Ft();
1301
1302
  s.choiceIndex = 0, s.callId = i.functionCallId, s.arguments = i.partialText, s.name = i.functionName, t.content = { items: [s], role: { label: "Assistant" } };
1302
1303
  } else if (e == I.Text)
1303
1304
  if (t.eventType.fullName == z.StreamingTextContent) {
1304
- const s = new Ft();
1305
+ const s = new _t();
1305
1306
  s.text = i.partialText, t.content = { items: [s], role: { label: "Assistant" } };
1306
1307
  } else {
1307
- const s = new _t();
1308
+ const s = new Nt();
1308
1309
  s.text = i.partialText, t.content = { items: [s], role: { label: "Assistant" } };
1309
1310
  }
1310
1311
  else if (e == I.Thought) {
1311
- const s = new Nt();
1312
+ const s = new Ut();
1312
1313
  s.text = i.partialReasoning, t.content = { items: [s], role: { label: "Assistant" } };
1313
1314
  }
1314
1315
  return t;
1315
1316
  }
1316
- h(ce, "llmEventFromPartial");
1317
+ h(le, "llmEventFromPartial");
1317
1318
  function st(i) {
1318
- const t = i.partialEvent ? ce(i.partialEvent) : i.event;
1319
+ const t = i.partialEvent ? le(i.partialEvent) : i.event;
1319
1320
  if (t)
1320
1321
  return i.detachedRunId && (t.detachedRunId = i.detachedRunId, t.detachedRunName = i.detachedRunName), t;
1321
1322
  }
1322
1323
  h(st, "llmEventFromFrame");
1323
- function Dt(i) {
1324
+ function $t(i) {
1324
1325
  var t, e, s;
1325
1326
  return (((e = (t = i.content) == null ? void 0 : t.items) == null ? void 0 : e.length) ?? 0) > 0 || (((s = i.streamingParts) == null ? void 0 : s.length) ?? 0) > 0;
1326
1327
  }
1327
- h(Dt, "carriesContent");
1328
- function $t(i) {
1328
+ h($t, "carriesContent");
1329
+ function Rt(i) {
1329
1330
  var e;
1330
1331
  if (i.type !== "InteractionStarted" || !((e = i.interaction) != null && e.interactionId)) return;
1331
1332
  if (i.interaction.detachedRunId || !i.detachedRunId) return i.interaction;
1332
- const t = Object.assign(new bt(), i.interaction);
1333
+ const t = Object.assign(new Lt(), i.interaction);
1333
1334
  return t.detachedRunId = i.detachedRunId, t;
1334
1335
  }
1335
- h($t, "interactionStartFromFrame");
1336
- const le = 0.02;
1337
- function he(i, t) {
1336
+ h(Rt, "interactionStartFromFrame");
1337
+ const he = 0.02;
1338
+ function ue(i, t) {
1338
1339
  if (!t) return null;
1339
1340
  const e = (t.interactionsCompressed ?? 0) > 0 || (t.compressionRatio ?? 0) > 0;
1340
1341
  if (!i)
1341
- return e ? yt(t, t.size, t.size) : null;
1342
- const s = i.size - t.size, n = t.maxSize || i.maxSize || 0, r = n > 0 ? s / n >= le : i.size > 0 && s / i.size >= 0.1;
1343
- return !e && !r ? null : yt(t, i.size, t.size, i.ratio);
1342
+ return e ? vt(t, t.size, t.size) : null;
1343
+ const s = i.size - t.size, n = t.maxSize || i.maxSize || 0, r = n > 0 ? s / n >= he : i.size > 0 && s / i.size >= 0.1;
1344
+ return !e && !r ? null : vt(t, i.size, t.size, i.ratio);
1344
1345
  }
1345
- h(he, "detectCompaction");
1346
- function yt(i, t, e, s) {
1346
+ h(ue, "detectCompaction");
1347
+ function vt(i, t, e, s) {
1347
1348
  return {
1348
1349
  at: Date.now(),
1349
1350
  // Where the bar stood when it happened — the marker's position. The ratio
@@ -1355,8 +1356,8 @@ function yt(i, t, e, s) {
1355
1356
  interactionsCompressed: i.interactionsCompressed
1356
1357
  };
1357
1358
  }
1358
- h(yt, "entry");
1359
- const vt = 4, ue = 3, de = 20, P = class P {
1359
+ h(vt, "entry");
1360
+ const Et = 4, de = 3, fe = 20, P = class P {
1360
1361
  constructor() {
1361
1362
  o(this, "stats");
1362
1363
  o(this, "onFlush");
@@ -1392,14 +1393,14 @@ const vt = 4, ue = 3, de = 20, P = class P {
1392
1393
  record(t) {
1393
1394
  const e = Date.now();
1394
1395
  if (this.events.push([e, t.textLength]), this.stats.eventCount += 1, this.stats.totalTransfered += t.rawLength, t.sessionInformation && !t.fromDetachedRun) {
1395
- const r = he(this.previousSessionInformation, t.sessionInformation);
1396
- r && (this.sessionCompactions.push(r), this.sessionCompactions.length > de && this.sessionCompactions.shift()), this.previousSessionInformation = t.sessionInformation, this.stats.sessionInformation = t.sessionInformation, this.stats.sessionCompactions = this.sessionCompactions;
1396
+ const r = ue(this.previousSessionInformation, t.sessionInformation);
1397
+ r && (this.sessionCompactions.push(r), this.sessionCompactions.length > fe && this.sessionCompactions.shift()), this.previousSessionInformation = t.sessionInformation, this.stats.sessionInformation = t.sessionInformation, this.stats.sessionCompactions = this.sessionCompactions;
1397
1398
  }
1398
1399
  this.stats.elapsed = (e - this.stats.startTime.getTime()) / 1e3;
1399
- const s = e - vt * 1e3;
1400
+ const s = e - Et * 1e3;
1400
1401
  for (; this.events.length > 0 && this.events[0][0] <= s; ) this.events.shift();
1401
1402
  const n = this.events.reduce((r, a) => r + a[1], 0);
1402
- this.stats.tokensPerSecond = n / ue / vt, this.flushCoalesced();
1403
+ this.stats.tokensPerSecond = n / de / Et, this.flushCoalesced();
1403
1404
  }
1404
1405
  flushCoalesced() {
1405
1406
  if (!this.onFlush) return;
@@ -1416,7 +1417,7 @@ const vt = 4, ue = 3, de = 20, P = class P {
1416
1417
  };
1417
1418
  h(P, "StreamStatsTracker"), o(P, "STATS_FLUSH_MS", 120);
1418
1419
  let tt = P;
1419
- const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1420
+ const ge = 5e3, pe = 3e4, Y = 1e4, lt = class lt {
1420
1421
  constructor(t = "ws://localhost:8000", e) {
1421
1422
  o(this, "ws", null);
1422
1423
  /** Frame counts, byte totals, the token-rate estimate and the compaction history — see StreamStatsTracker. */
@@ -1468,7 +1469,7 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1468
1469
  * the single-attach policy makes it undeliverable from here anyway.
1469
1470
  */
1470
1471
  o(this, "pendingAnswers", []);
1471
- this.baseUrl = t, this.getToken = e, this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = et(), console.log("SOCKET INSTACE", Bt()), this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
1472
+ this.baseUrl = t, this.getToken = e, this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = et(), console.log("SOCKET INSTACE", Gt()), this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
1472
1473
  }
1473
1474
  get stats() {
1474
1475
  return this.statsTracker.stats;
@@ -1491,32 +1492,32 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1491
1492
  */
1492
1493
  connect(t, e) {
1493
1494
  return new Promise(async (s, n) => {
1494
- var M, F;
1495
+ var D, F;
1495
1496
  e != null && e.resume || (this.lastSeq = -1);
1496
- const r = (M = this.getToken) == null ? void 0 : M.call(this), a = [];
1497
+ const r = (D = this.getToken) == null ? void 0 : D.call(this), a = [];
1497
1498
  r && a.push(`access_token=${encodeURIComponent(r)}`), t && this.lastSeq >= 0 && a.push(`lastSeq=${this.lastSeq}`), t && (e != null && e.resume) && e.openInteractionId && a.push(`openInteraction=${encodeURIComponent(e.openInteractionId)}`);
1498
1499
  const c = a.length > 0 ? `?${a.join("&")}` : "", l = this.baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"), f = `${l}/ws/connect/${t ?? ""}${c}`;
1499
1500
  console.log("[WebSocket] Connecting to", `${l}/ws/connect/${t ?? ""}` + (t && this.lastSeq >= 0 ? ` (resume lastSeq=${this.lastSeq})` : "")), this.detachSocket(), this.ws = new WebSocket(f), this.ws.onopen = () => {
1500
1501
  console.log("[WebSocket] Socket open — waiting for the session id"), this.ping(), this.monitor();
1501
- }, this.ws.onmessage = (v) => {
1502
+ }, this.ws.onmessage = (E) => {
1502
1503
  try {
1503
1504
  this.lastActivity = (/* @__PURE__ */ new Date()).getTime(), this.pingSentAt = null;
1504
- const C = this.streamingResponseSerializer.parse(v.data);
1505
- if (!C)
1505
+ const M = this.streamingResponseSerializer.parse(E.data);
1506
+ if (!M)
1506
1507
  throw "Error parsing event JSON";
1507
- this.handleMessage(C, v.data);
1508
- } catch (C) {
1509
- console.error("[WebSocket] Error parsing message:", C);
1508
+ this.handleMessage(M, E.data);
1509
+ } catch (M) {
1510
+ console.error("[WebSocket] Error parsing message:", M);
1510
1511
  }
1511
- }, this.ws.onerror = (v) => {
1512
- console.error("[WebSocket] Error:", v), this.onError && this.onError("WebSocket error");
1513
- }, this.ws.onclose = (v) => {
1514
- var C;
1515
- console.log(`[WebSocket] Closed: code=${v.code} reason="${v.reason}" (session ${this.sessionLabel}, lastSeq=${this.lastSeq})`), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingSentAt = null, this.sessionId = void 0, (C = this.onClose) == null || C.call(this, v.code, v.reason);
1512
+ }, this.ws.onerror = (E) => {
1513
+ console.error("[WebSocket] Error:", E), this.onError && this.onError("WebSocket error");
1514
+ }, this.ws.onclose = (E) => {
1515
+ var M;
1516
+ console.log(`[WebSocket] Closed: code=${E.code} reason="${E.reason}" (session ${this.sessionLabel}, lastSeq=${this.lastSeq})`), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingSentAt = null, this.sessionId = void 0, (M = this.onClose) == null || M.call(this, E.code, E.reason);
1516
1517
  };
1517
- const p = 200, m = 3e4, u = 8e3, g = this.ws;
1518
+ const p = 200, w = 3e4, u = 8e3, g = this.ws;
1518
1519
  this.sessionId = void 0;
1519
- let S = 0, D = 0;
1520
+ let m = 0, v = 0;
1520
1521
  for (; ; ) {
1521
1522
  if (this.ws !== g) {
1522
1523
  n("Connection attempt superseded by a newer connect()");
@@ -1527,19 +1528,19 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1527
1528
  n("Connection closed before a session id was received");
1528
1529
  return;
1529
1530
  }
1530
- if (g.readyState === WebSocket.CONNECTING && S >= m) {
1531
+ if (g.readyState === WebSocket.CONNECTING && m >= w) {
1531
1532
  try {
1532
1533
  g.close();
1533
1534
  } catch {
1534
1535
  }
1535
- n(`Server did not accept the connection within ${m / 1e3}s`);
1536
+ n(`Server did not accept the connection within ${w / 1e3}s`);
1536
1537
  return;
1537
1538
  }
1538
- if (g.readyState === WebSocket.OPEN && D >= u) {
1539
+ if (g.readyState === WebSocket.OPEN && v >= u) {
1539
1540
  n(`Connected but no session id arrived within ${u / 1e3}s`);
1540
1541
  return;
1541
1542
  }
1542
- S % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(p), S += p, g.readyState === WebSocket.OPEN && (D += p);
1543
+ m % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(p), m += p, g.readyState === WebSocket.OPEN && (v += p);
1543
1544
  }
1544
1545
  console.log(`[WebSocket] Session ${this.sessionId} proven${this.lastSeq >= 0 ? ` (replaying from lastSeq=${this.lastSeq})` : ""}.`), this.lastKnownSessionId = this.sessionId, (F = this.onOpen) == null || F.call(this), this.flushPendingAnswers(this.sessionId), s(this.sessionId);
1545
1546
  });
@@ -1581,7 +1582,7 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1581
1582
  case "Event":
1582
1583
  break;
1583
1584
  case "InteractionStarted": {
1584
- const r = $t(t);
1585
+ const r = Rt(t);
1585
1586
  r ? (n = this.onInteractionStarted) == null || n.call(this, r) : console.warn("[WebSocket] InteractionStarted frame without an interaction id");
1586
1587
  break;
1587
1588
  }
@@ -1594,7 +1595,7 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1594
1595
  console.warn("[WebSocket] Unknown message type:", t.type);
1595
1596
  }
1596
1597
  const s = st(t);
1597
- return s ? (Dt(s) && this.emitFirstToken(s.interactionId), this.handleEvent(s, e), s) : null;
1598
+ return s ? ($t(s) && this.emitFirstToken(s.interactionId), this.handleEvent(s, e), s) : null;
1598
1599
  }
1599
1600
  emitFirstToken(t) {
1600
1601
  var e;
@@ -1715,7 +1716,7 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1715
1716
  const e = t - this.pingSentAt;
1716
1717
  if (e >= Y) {
1717
1718
  this.failSocket(
1718
- se,
1719
+ ne,
1719
1720
  `No frame received for ${Math.round(e / 1e3)}s after a Ping`
1720
1721
  );
1721
1722
  return;
@@ -1723,11 +1724,11 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1723
1724
  console.warn(`[WebSocket] Still no reply ${e}ms after the Ping (budget ${Y}ms, session ${this.sessionLabel}) — the peer may be gone.`);
1724
1725
  return;
1725
1726
  }
1726
- t - this.lastActivity >= ge && this.ping();
1727
+ t - this.lastActivity >= pe && this.ping();
1727
1728
  } catch (t) {
1728
1729
  console.error("Error on monitor", t);
1729
1730
  }
1730
- }, fe);
1731
+ }, ge);
1731
1732
  }
1732
1733
  /**
1733
1734
  * Send a heartbeat ping and start the reply clock (unless one is already running).
@@ -1773,7 +1774,7 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1773
1774
  * Disconnect the WebSocket
1774
1775
  */
1775
1776
  disconnect() {
1776
- console.log(`[WebSocket] disconnect() (session ${this.sessionLabel})`), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingSentAt = null, this.firstTokenInteractions.clear(), this.lastKnownSessionId = void 0, this.lastSeq = -1, this.ws && (this.ws.close(Ot, "Intentional disconnect"), this.ws = null);
1777
+ console.log(`[WebSocket] disconnect() (session ${this.sessionLabel})`), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingSentAt = null, this.firstTokenInteractions.clear(), this.lastKnownSessionId = void 0, this.lastSeq = -1, this.ws && (this.ws.close(kt, "Intentional disconnect"), this.ws = null);
1777
1778
  }
1778
1779
  /**
1779
1780
  * Check if connected
@@ -1783,7 +1784,7 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1783
1784
  }
1784
1785
  async handleEvent(t, e) {
1785
1786
  var n, r, a, c;
1786
- const s = (r = (n = t.content) == null ? void 0 : n.items) == null ? void 0 : r.find((l) => l instanceof Ut);
1787
+ const s = (r = (n = t.content) == null ? void 0 : n.items) == null ? void 0 : r.find((l) => l instanceof xt);
1787
1788
  if (s) {
1788
1789
  (a = this.onBillingLimit) == null || a.call(this, {
1789
1790
  plan: s.plan ?? "team",
@@ -1817,7 +1818,7 @@ const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
1817
1818
  }
1818
1819
  };
1819
1820
  h(lt, "WebSocketConnecionV2");
1820
- let Et = lt;
1821
+ let Ct = lt;
1821
1822
  const ht = class ht {
1822
1823
  constructor(t, e) {
1823
1824
  o(this, "cache", /* @__PURE__ */ new Map());
@@ -1826,7 +1827,7 @@ const ht = class ht {
1826
1827
  this.serverBaseUrl = t.replace(/\/$/, ""), this.accessToken = e;
1827
1828
  }
1828
1829
  get headers() {
1829
- return { Authorization: `Bearer ${Gt(this.accessToken)}` };
1830
+ return { Authorization: `Bearer ${zt(this.accessToken)}` };
1830
1831
  }
1831
1832
  async init() {
1832
1833
  }
@@ -1874,7 +1875,7 @@ const ht = class ht {
1874
1875
  }
1875
1876
  };
1876
1877
  h(ht, "HttpArtifactService");
1877
- let Ct = ht;
1878
+ let Mt = ht;
1878
1879
  const ut = class ut extends Error {
1879
1880
  constructor(t, e) {
1880
1881
  super(e ?? `GET detached-run frames answered ${t}`), this.status = t, this.name = "DetachedRunFramesHttpError";
@@ -1882,15 +1883,15 @@ const ut = class ut extends Error {
1882
1883
  };
1883
1884
  h(ut, "DetachedRunFramesHttpError");
1884
1885
  let L = ut;
1885
- function pe(i) {
1886
+ function me(i) {
1886
1887
  if (i instanceof L) {
1887
1888
  const { status: t } = i;
1888
1889
  return { kind: t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 404 || t === 410 ? "notFound" : "gaveUp", status: t, cause: i };
1889
1890
  }
1890
1891
  return { kind: "gaveUp", cause: i };
1891
1892
  }
1892
- h(pe, "toDetachedRunFollowError");
1893
- function me(i) {
1893
+ h(me, "toDetachedRunFollowError");
1894
+ function we(i) {
1894
1895
  let t = "", e = [], s, n;
1895
1896
  const r = /* @__PURE__ */ h(() => {
1896
1897
  (e.length > 0 || s !== void 0) && i({ event: s, data: e.join(`
@@ -1921,12 +1922,12 @@ function me(i) {
1921
1922
  }
1922
1923
  };
1923
1924
  }
1924
- h(me, "createSseParser");
1925
- function we(i) {
1925
+ h(we, "createSseParser");
1926
+ function Se(i) {
1926
1927
  return i >= 500 || i === 408 || i === 429;
1927
1928
  }
1928
- h(we, "retryable");
1929
- function Se(i, t) {
1929
+ h(Se, "retryable");
1930
+ function Ie(i, t) {
1930
1931
  return new Promise((e) => {
1931
1932
  if (t != null && t.aborted) return e();
1932
1933
  const s = setTimeout(n, i);
@@ -1936,15 +1937,16 @@ function Se(i, t) {
1936
1937
  h(n, "done"), t == null || t.addEventListener("abort", n, { once: !0 });
1937
1938
  });
1938
1939
  }
1939
- h(Se, "sleep");
1940
- function Ie(i, t, e) {
1941
- return `${i.replace(/\/+$/, "")}/detached-runs/${encodeURIComponent(t)}/frames?afterSeq=${e}`;
1940
+ h(Ie, "sleep");
1941
+ function Te(i, t, e, s) {
1942
+ const n = t === "session" ? "sessions" : "detached-runs";
1943
+ return `${i.replace(/\/+$/, "")}/${n}/${encodeURIComponent(e)}/frames?afterSeq=${s}`;
1942
1944
  }
1943
- h(Ie, "framesUrl");
1944
- async function Te(i) {
1945
- var M, F, v, C, ft;
1946
- const { baseUrl: t, runId: e, signal: s, onFrame: n, onEnd: r, onOpen: a, onRetry: c } = i, l = i.fetchImpl ?? ((A, $) => fetch(A, $)), f = ((M = i.retry) == null ? void 0 : M.initialMs) ?? 500, p = ((F = i.retry) == null ? void 0 : F.maxMs) ?? 15e3, m = ((v = i.retry) == null ? void 0 : v.maxAttempts) ?? Number.POSITIVE_INFINITY;
1947
- let u = i.afterSeq ?? 0, g = 0, S = !1;
1945
+ h(Te, "framesUrl");
1946
+ async function ye(i) {
1947
+ var F, E, M, ft, gt;
1948
+ const { baseUrl: t, runId: e, signal: s, onFrame: n, onEnd: r, onOpen: a, onRetry: c } = i, l = i.resource ?? "detachedRun", f = i.fetchImpl ?? ((A, $) => fetch(A, $)), p = ((F = i.retry) == null ? void 0 : F.initialMs) ?? 500, w = ((E = i.retry) == null ? void 0 : E.maxMs) ?? 15e3, u = ((M = i.retry) == null ? void 0 : M.maxAttempts) ?? Number.POSITIVE_INFINITY;
1949
+ let g = i.afterSeq ?? 0, m = 0, v = !1;
1948
1950
  async function D(A) {
1949
1951
  if (i.onUnauthorized)
1950
1952
  try {
@@ -1959,77 +1961,77 @@ async function Te(i) {
1959
1961
  for (h(D, "secondChance"); !(s != null && s.aborted); ) {
1960
1962
  let A;
1961
1963
  try {
1962
- const O = { Accept: "text/event-stream" }, K = await ((C = i.getToken) == null ? void 0 : C.call(i)) ?? void 0;
1964
+ const O = { Accept: "text/event-stream" }, K = await ((ft = i.getToken) == null ? void 0 : ft.call(i)) ?? void 0;
1963
1965
  K && (O.Authorization = `Bearer ${K}`);
1964
- const k = await l(Ie(t, e, u), { method: "GET", headers: O, signal: s, cache: "no-store" });
1966
+ const k = await f(Te(t, l, e, g), { method: "GET", headers: O, signal: s, cache: "no-store" });
1965
1967
  if (k.status === 401) {
1966
- if (!S && await D(K)) {
1967
- S = !0;
1968
+ if (!v && await D(K)) {
1969
+ v = !0;
1968
1970
  continue;
1969
1971
  }
1970
1972
  throw new L(401);
1971
1973
  }
1972
- if (S = !1, !k.ok)
1973
- throw we(k.status) ? new Error(`GET detached-run frames answered ${k.status}`) : new L(k.status);
1974
+ if (v = !1, !k.ok)
1975
+ throw Se(k.status) ? new Error(`GET detached-run frames answered ${k.status}`) : new L(k.status);
1974
1976
  if (!k.body) throw new L(k.status, "The frames response has no readable body");
1975
1977
  a == null || a();
1976
1978
  let W = !1;
1977
- const B = me((T) => {
1979
+ const B = we((T) => {
1978
1980
  if (T.event === "end") {
1979
1981
  const b = Number(T.data);
1980
- T.data !== "" && Number.isFinite(b) && b > u && (u = b), W = !0;
1982
+ T.data !== "" && Number.isFinite(b) && b > g && (g = b), W = !0;
1981
1983
  return;
1982
1984
  }
1983
1985
  if (T.event !== void 0 && T.event !== "message" || T.data === "") return;
1984
1986
  const R = T.id !== void 0 && T.id !== "" ? Number(T.id) : void 0;
1985
1987
  if (R !== void 0 && Number.isFinite(R)) {
1986
- if (R <= u) return;
1987
- u = R;
1988
+ if (R <= g) return;
1989
+ g = R;
1988
1990
  }
1989
1991
  W = !1;
1990
- let pt;
1992
+ let mt;
1991
1993
  try {
1992
- pt = JSON.parse(T.data);
1994
+ mt = JSON.parse(T.data);
1993
1995
  } catch (b) {
1994
1996
  console.warn(`[DetachedRunFrames] run ${e}: a frame that is not JSON was skipped (seq ${T.id ?? "?"})`, b);
1995
1997
  return;
1996
1998
  }
1997
- g = 0;
1999
+ m = 0;
1998
2000
  try {
1999
- n(pt, R);
2001
+ n(mt, R);
2000
2002
  } catch (b) {
2001
2003
  console.error(`[DetachedRunFrames] run ${e}: onFrame threw on seq ${T.id ?? "?"}`, b);
2002
2004
  }
2003
- }), G = k.body.getReader(), gt = new TextDecoder();
2005
+ }), G = k.body.getReader(), pt = new TextDecoder();
2004
2006
  try {
2005
2007
  for (; ; ) {
2006
2008
  const { done: T, value: R } = await G.read();
2007
2009
  if (T) break;
2008
- B.push(gt.decode(R, { stream: !0 }));
2010
+ B.push(pt.decode(R, { stream: !0 }));
2009
2011
  }
2010
- B.push(gt.decode()), B.idle() || (W = !1), B.flush();
2012
+ B.push(pt.decode()), B.idle() || (W = !1), B.flush();
2011
2013
  } finally {
2012
- (ft = G.releaseLock) == null || ft.call(G);
2014
+ (gt = G.releaseLock) == null || gt.call(G);
2013
2015
  }
2014
- if (W)
2015
- return r == null || r(u), { reason: "end", lastSeq: u };
2016
- A = new Error("The frames stream closed before its end event");
2016
+ if (W && l !== "session")
2017
+ return r == null || r(g), { reason: "end", lastSeq: g };
2018
+ A = new Error(l === "session" ? "The session frames stream closed" : "The frames stream closed before its end event");
2017
2019
  } catch (O) {
2018
2020
  if (s != null && s.aborted) break;
2019
2021
  if (O instanceof L) throw O;
2020
2022
  A = O;
2021
2023
  }
2022
- if (g += 1, g >= m) throw A;
2023
- const $ = Math.min(f * 2 ** (g - 1), p);
2024
+ if (m += 1, m >= u) throw A;
2025
+ const $ = Math.min(p * 2 ** (m - 1), w);
2024
2026
  try {
2025
- c == null || c(A, g, $);
2027
+ c == null || c(A, m, $);
2026
2028
  } catch {
2027
2029
  }
2028
- await Se($, s);
2030
+ await Ie($, s);
2029
2031
  }
2030
- return { reason: "aborted", lastSeq: u };
2032
+ return { reason: "aborted", lastSeq: g };
2031
2033
  }
2032
- h(Te, "streamDetachedRunFrames");
2034
+ h(ye, "streamDetachedRunFrames");
2033
2035
  const dt = class dt {
2034
2036
  constructor(t) {
2035
2037
  o(this, "onEvent");
@@ -2062,7 +2064,8 @@ const dt = class dt {
2062
2064
  return this.following;
2063
2065
  }
2064
2066
  connect(t, e) {
2065
- return t ? ((t !== this.runId || !(e != null && e.resume)) && (this.lastSeq = 0, this.firstTokens.clear()), this.runId = t, this.start(t)) : Promise.reject(new Error("DetachedRunFramesTransport: connect() needs the run id"));
2067
+ var s, n;
2068
+ return t ? ((t !== this.runId || !(e != null && e.resume)) && (this.lastSeq = ((n = (s = this.options).initialAfterSeq) == null ? void 0 : n.call(s)) ?? 0, this.firstTokens.clear()), this.runId = t, this.start(t)) : Promise.reject(new Error("DetachedRunFramesTransport: connect() needs the run id"));
2066
2069
  }
2067
2070
  /**
2068
2071
  * Follow again from the last seq — after the stream ended and the run was resumed (answered). A no-op while a
@@ -2077,7 +2080,7 @@ const dt = class dt {
2077
2080
  const e = new AbortController();
2078
2081
  return this.controller = e, this.following = !0, new Promise((n, r) => {
2079
2082
  let a = !1;
2080
- Te({
2083
+ ye({
2081
2084
  ...this.options,
2082
2085
  runId: t,
2083
2086
  afterSeq: this.lastSeq,
@@ -2099,15 +2102,15 @@ const dt = class dt {
2099
2102
  }).then(() => {
2100
2103
  a || r(new Error("The frames stream stopped before it opened"));
2101
2104
  }).catch((c) => {
2102
- var p, m, u;
2103
- const l = pe(c), f = l.kind === "notFound" ? kt : l.kind === "forbidden" || l.kind === "unauthorized" ? 1008 : 1011;
2105
+ var p, w, u;
2106
+ const l = me(c), f = l.kind === "notFound" ? Dt : l.kind === "forbidden" || l.kind === "unauthorized" ? 1008 : 1011;
2104
2107
  console.error(`[DetachedRunFrames] run ${t}: following stopped (${l.kind})`, c);
2105
2108
  try {
2106
2109
  (p = this.onFollowError) == null || p.call(this, l);
2107
2110
  } catch (g) {
2108
2111
  console.error("[DetachedRunFrames] onFollowError threw", g);
2109
2112
  }
2110
- (m = this.onError) == null || m.call(this, String((c == null ? void 0 : c.message) ?? c)), (u = this.onClose) == null || u.call(this, f, String((c == null ? void 0 : c.message) ?? "")), a || r(c);
2113
+ (w = this.onError) == null || w.call(this, String((c == null ? void 0 : c.message) ?? c)), (u = this.onClose) == null || u.call(this, f, String((c == null ? void 0 : c.message) ?? "")), a || r(c);
2111
2114
  }).finally(() => {
2112
2115
  this.controller === e && (this.following = !1);
2113
2116
  });
@@ -2124,14 +2127,14 @@ const dt = class dt {
2124
2127
  return;
2125
2128
  }
2126
2129
  if (!e) return;
2127
- const s = $t(e);
2130
+ const s = Rt(e);
2128
2131
  if (s) {
2129
2132
  (r = this.onInteractionStarted) == null || r.call(this, s);
2130
2133
  return;
2131
2134
  }
2132
2135
  const n = st(e);
2133
2136
  if (n) {
2134
- Dt(n) && n.interactionId && !this.firstTokens.has(n.interactionId) && (this.firstTokens.add(n.interactionId), (a = this.onFirstToken) == null || a.call(this, n.interactionId));
2137
+ $t(n) && n.interactionId && !this.firstTokens.has(n.interactionId) && (this.firstTokens.add(n.interactionId), (a = this.onFirstToken) == null || a.call(this, n.interactionId));
2135
2138
  try {
2136
2139
  const l = x.parseFromTypedEvent(n);
2137
2140
  (c = this.onEvent) == null || c.call(this, l).catch((f) => console.error("[DetachedRunFrames] onEvent failed", f));
@@ -2154,9 +2157,9 @@ const dt = class dt {
2154
2157
  }
2155
2158
  };
2156
2159
  h(dt, "DetachedRunFramesTransport");
2157
- let Mt = dt;
2158
- const ye = "todolistUpdated";
2159
- function Re(i, t = et()) {
2160
+ let At = dt;
2161
+ const ve = "todolistUpdated";
2162
+ function be(i, t = et()) {
2160
2163
  var n, r;
2161
2164
  let e;
2162
2165
  try {
@@ -2168,14 +2171,14 @@ function Re(i, t = et()) {
2168
2171
  if (!e) return [];
2169
2172
  const s = [];
2170
2173
  for (const a of e.parts ?? [])
2171
- if (a.eventType === I.ToolEvent && ((n = a.toolDetails) == null ? void 0 : n.eventName) === ye) {
2172
- const c = ve(a.toolDetails.eventData);
2174
+ if (a.eventType === I.ToolEvent && ((n = a.toolDetails) == null ? void 0 : n.eventName) === ve) {
2175
+ const c = Ee(a.toolDetails.eventData);
2173
2176
  c && s.push({ kind: "todo", todoList: c });
2174
2177
  } else (a.eventType === I.FunctionCall || a.eventType === I.PartialFunctionCall) && ((r = a.functionDetails) != null && r.name) ? s.push({ kind: "tool", name: a.functionDetails.name, interactionId: e.interactionId }) : a.eventType === I.Text && a.text && s.push({ kind: "text", text: a.text, partial: !!e.partial, interactionId: e.interactionId });
2175
2178
  return s;
2176
2179
  }
2177
- h(Re, "readDetachedRunActivity");
2178
- function ve(i) {
2180
+ h(be, "readDetachedRunActivity");
2181
+ function Ee(i) {
2179
2182
  if (!i) return null;
2180
2183
  try {
2181
2184
  const t = JSON.parse(i);
@@ -2184,26 +2187,26 @@ function ve(i) {
2184
2187
  return null;
2185
2188
  }
2186
2189
  }
2187
- h(ve, "parseTodoList");
2190
+ h(Ee, "parseTodoList");
2188
2191
  export {
2189
- Tt as A,
2192
+ yt as A,
2190
2193
  V as C,
2191
2194
  L as D,
2192
- It as E,
2193
- Ct as H,
2195
+ Tt as E,
2196
+ Mt as H,
2194
2197
  _ as I,
2195
- St as L,
2196
- Ht as M,
2197
- ye as T,
2198
- oe as W,
2199
- Mt as a,
2198
+ It as L,
2199
+ Jt as M,
2200
+ ve as T,
2201
+ ae as W,
2202
+ At as a,
2200
2203
  j as b,
2201
- Et as c,
2202
- me as d,
2203
- te as e,
2204
- Re as r,
2205
- Te as s,
2206
- pe as t,
2207
- $e as u
2204
+ Ct as c,
2205
+ we as d,
2206
+ ee as e,
2207
+ be as r,
2208
+ ye as s,
2209
+ me as t,
2210
+ Re as u
2208
2211
  };
2209
- //# sourceMappingURL=detachedRunActivity-RNg1JDDW.js.map
2212
+ //# sourceMappingURL=detachedRunActivity-DWOR3cAC.js.map