@aintela/chat 0.2.40 → 0.2.42

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.
@@ -1,16 +1,16 @@
1
- var nt = Object.defineProperty;
2
- var gt = (O, t, e) => t in O ? nt(O, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : O[t] = e;
3
- var f = (O, t) => nt(O, "name", { value: t, configurable: !0 });
4
- var a = (O, t, e) => gt(O, typeof t != "symbol" ? t + "" : t, e);
5
- import { d as L, t as mt, E as I, k as pt, j as St, q as wt, C as B } from "./environmentUtils-CUVZ6Dq1.js";
6
- import { I as _, S as ut, g as yt, L as Tt, P as x, b as It, e as Ct, T as vt, c as Et } from "./serializer-uea8YsIP.js";
7
- import { unified as Mt } from "unified";
8
- import Ot from "remark-parse";
9
- import { toMarkdown as Dt } from "mdast-util-to-markdown";
10
- import { format as At } from "date-fns";
11
- import Nt from "lodash";
12
- import { P as kt, C as R } from "./Prompt-DZb7OaPp.js";
13
- import { r as Pt } from "./httpSessionService-CNzThf-T.js";
1
+ var rt = Object.defineProperty;
2
+ var St = (O, t, e) => t in O ? rt(O, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : O[t] = e;
3
+ var g = (O, t) => rt(O, "name", { value: t, configurable: !0 });
4
+ var a = (O, t, e) => St(O, typeof t != "symbol" ? t + "" : t, e);
5
+ import { d as L, t as wt, E as C, k as yt, j as Tt, q as It, C as B } from "./environmentUtils-CUVZ6Dq1.js";
6
+ import { I as _, S as gt, g as Ct, L as vt, P as x, b as Et, e as Mt, T as Ot, c as Dt } from "./serializer-uea8YsIP.js";
7
+ import { unified as At } from "unified";
8
+ import kt from "remark-parse";
9
+ import { toMarkdown as Nt } from "mdast-util-to-markdown";
10
+ import { format as Pt } from "date-fns";
11
+ import _t from "lodash";
12
+ import { P as bt, C as R } from "./Prompt-DZb7OaPp.js";
13
+ import { r as Ft } from "./httpSessionService-CNzThf-T.js";
14
14
  const w = {
15
15
  ARTIFACTS: "envision-artifacts",
16
16
  SECTIONS: "envision-sections",
@@ -39,7 +39,7 @@ const w = {
39
39
  }
40
40
  ], K = class K {
41
41
  constructor() {
42
- a(this, "onPromptCreated", /* @__PURE__ */ f(() => {
42
+ a(this, "onPromptCreated", /* @__PURE__ */ g(() => {
43
43
  }, "onPromptCreated"));
44
44
  }
45
45
  getItem(t) {
@@ -197,9 +197,9 @@ const w = {
197
197
  }
198
198
  }
199
199
  };
200
- f(K, "LocalStorageService");
201
- let it = K;
202
- const Qt = /* @__PURE__ */ f((O) => {
200
+ g(K, "LocalStorageService");
201
+ let ot = K;
202
+ const te = /* @__PURE__ */ g((O) => {
203
203
  const t = O.getPrompts(), e = t.length;
204
204
  if (e > 0) {
205
205
  const s = t[0].promptText, i = t[t.length - 1].promptText, n = t[0].created;
@@ -231,7 +231,7 @@ const Qt = /* @__PURE__ */ f((O) => {
231
231
  a(this, "gatewayFirstToken", "gatewayFirstToken");
232
232
  }
233
233
  };
234
- f(z, "EventTypes");
234
+ g(z, "EventTypes");
235
235
  let q = z;
236
236
  const c = new q(), Y = class Y {
237
237
  constructor() {
@@ -484,7 +484,7 @@ const c = new q(), Y = class Y {
484
484
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
485
485
  }
486
486
  };
487
- f(Y, "EventBusService");
487
+ g(Y, "EventBusService");
488
488
  let J = Y;
489
489
  const j = class j extends J {
490
490
  constructor() {
@@ -494,7 +494,7 @@ const j = class j extends J {
494
494
  console.log("MockEventBusService.gatewayEmitConnectionStateChange");
495
495
  }
496
496
  gatewayEmitMessage(t, e) {
497
- mt() ? process.stdout.write(`M${t.version}, `) : console.log("MockEventBusService.gatewayEmitMessage");
497
+ wt() ? process.stdout.write(`M${t.version}, `) : console.log("MockEventBusService.gatewayEmitMessage");
498
498
  }
499
499
  gatewayEmitTurnComplete(t, e) {
500
500
  console.log("MockEventBusService.gatewayEmitTurnComplete");
@@ -512,36 +512,36 @@ const j = class j extends J {
512
512
  console.log("MockEventBusService.gatewayOffFunctionResponse", t);
513
513
  }
514
514
  };
515
- f(j, "MockEventBusService");
516
- let at = j;
517
- const dt = {
515
+ g(j, "MockEventBusService");
516
+ let ct = j;
517
+ const Rt = 2e3, pt = {
518
518
  inline: "inline",
519
519
  block: "block"
520
- }, Q = class Q {
520
+ }, X = class X {
521
521
  constructor() {
522
522
  a(this, "parts", []);
523
523
  a(this, "isLastGroup", !1);
524
524
  a(this, "hasThoughts", !1);
525
525
  a(this, "lastWithThoughts", !1);
526
- a(this, "type", dt.inline);
526
+ a(this, "type", pt.inline);
527
527
  }
528
528
  };
529
- f(Q, "InteractionPartGroup");
530
- let W = Q;
531
- const X = class X {
529
+ g(X, "InteractionPartGroup");
530
+ let W = X;
531
+ const Q = class Q {
532
532
  constructor(t, e) {
533
533
  a(this, "interaction");
534
534
  a(this, "eventBusService");
535
- a(this, "parseTextIntoParts", /* @__PURE__ */ f((t) => {
535
+ a(this, "parseTextIntoParts", /* @__PURE__ */ g((t) => {
536
536
  if (!t || t.trim().length == 0) return [];
537
- const e = Mt().use(Ot).parse(t), s = [];
537
+ const e = At().use(kt).parse(t), s = [];
538
538
  let i = null;
539
539
  for (const n of e.children)
540
540
  n.type === "code" ? (i && (s.push(i), i = null), n.lang === "htmlCanvas" && s.push(`
541
541
  \`\`\`liveTsx
542
542
  ${n.value}
543
543
  \`\`\`
544
- `)) : (i || (i = ""), i += Dt(n));
544
+ `)) : (i || (i = ""), i += Nt(n));
545
545
  return i && s.push(i), s;
546
546
  }, "parseTextIntoParts"));
547
547
  this.interaction = t, this.eventBusService = e;
@@ -556,29 +556,29 @@ ${n.value}
556
556
  return i;
557
557
  }
558
558
  groupPartsByDisplayType(t, e = !0, s = !1) {
559
- var l;
559
+ var l, o, d;
560
560
  const i = [];
561
561
  let n = new W();
562
- for (let o = 0; o < t.length; o++) {
563
- const u = t[o];
564
- let h = !(((l = u.functionDetails) == null ? void 0 : l.isUi) ?? !1) && u.eventType !== I.Text && u.eventType !== I.Thought && (u.eventType === I.FunctionCall || u.eventType === I.PartialFunctionCall || u.eventType === I.FunctionResponse) && o < t.length - 1;
565
- !e && h && !s || (h ? (u.eventType == I.Thought && (n.hasThoughts = !0), n.parts.push(u), n.isLastGroup = o === t.length - 1) : (n.parts.length > 0 && (i.push(n), n = new W()), i.push({
566
- type: dt.block,
567
- parts: [u],
568
- isLastGroup: o === t.length - 1,
562
+ for (let u = 0; u < t.length; u++) {
563
+ const h = t[u];
564
+ let p = !((((l = h.functionDetails) == null ? void 0 : l.isUi) ?? !1) || ((o = h.functionDetails) == null ? void 0 : o.cancelUi) !== !0 && (((d = h.functionDetails) == null ? void 0 : d.isAskUser) ?? !1)) && h.eventType !== C.Text && h.eventType !== C.Thought && (h.eventType === C.FunctionCall || h.eventType === C.PartialFunctionCall || h.eventType === C.FunctionResponse) && u < t.length - 1;
565
+ !e && p && !s || (p ? (h.eventType == C.Thought && (n.hasThoughts = !0), n.parts.push(h), n.isLastGroup = u === t.length - 1) : (n.parts.length > 0 && (i.push(n), n = new W()), i.push({
566
+ type: pt.block,
567
+ parts: [h],
568
+ isLastGroup: u === t.length - 1,
569
569
  hasThoughts: !1,
570
570
  lastWithThoughts: !1
571
571
  })));
572
572
  }
573
573
  n.parts.length > 0 && i.push(n);
574
- const r = i.filter((o) => o.hasThoughts);
574
+ const r = i.filter((u) => u.hasThoughts);
575
575
  return r.length > 0 && (r[r.length - 1].lastWithThoughts = !0), i;
576
576
  }
577
577
  isFunctionCall(t) {
578
- return t == I.FunctionCall || t == I.PartialFunctionCall;
578
+ return t == C.FunctionCall || t == C.PartialFunctionCall;
579
579
  }
580
580
  isFunctionResponse(t) {
581
- return t == I.FunctionResponse;
581
+ return t == C.FunctionResponse;
582
582
  }
583
583
  // Computes the next interaction from a server event. Pure with respect to
584
584
  // `prev` — no part or array on the prior tree is mutated; modified entities
@@ -586,47 +586,51 @@ ${n.value}
586
586
  // new tree as the last step, so snapshots already handed out to throttled
587
587
  // subscribers can't diverge from the live state.
588
588
  merge(t) {
589
- var b, T, A, N, et;
589
+ var b, T, A, k, et, st, nt, it;
590
590
  const e = this.interaction, s = [], i = [], n = _.FlatParts(t == null ? void 0 : t.parts), r = e.parts[e.parts.length - 1] ?? null;
591
591
  let l = !1;
592
592
  n && (l = !r || n.mustPush || n.mustPush === !1 && (n.eventType !== (r == null ? void 0 : r.eventType) || ((b = n == null ? void 0 : n.functionDetails) == null ? void 0 : b.id) !== ((T = r.functionDetails) == null ? void 0 : T.id)));
593
- let o = e.parts, u = e.functionMap ?? /* @__PURE__ */ new Map(), d = !e.functionMap;
594
- const h = /* @__PURE__ */ f(() => {
595
- d || (u = new Map(u), d = !0);
596
- }, "cloneFunctionMap"), v = /* @__PURE__ */ f(() => {
593
+ let o = e.parts, d = e.functionMap ?? /* @__PURE__ */ new Map(), u = !e.functionMap;
594
+ const h = /* @__PURE__ */ g(() => {
595
+ u || (d = new Map(d), u = !0);
596
+ }, "cloneFunctionMap"), v = /* @__PURE__ */ g(() => {
597
597
  o === e.parts && (o = e.parts.slice());
598
598
  }, "clonePartsIfShared");
599
+ if (!l && (o == null ? void 0 : o.length) > 0 && (n != null && n.textAppendable)) {
600
+ const f = o[o.length - 1];
601
+ (((k = (A = f.thoughtDetails) == null ? void 0 : A.text) == null ? void 0 : k.length) ?? ((et = f.text) == null ? void 0 : et.length) ?? 0) > Rt && (l = !0);
602
+ }
599
603
  let p = !1;
600
- if ((n == null ? void 0 : n.eventType) === I.FunctionClientOutput && !!((A = n.functionDetails) != null && A.id) && n) {
601
- const g = n.functionDetails.id, C = n.functionDetails.clientOutput, E = o.findIndex((S) => {
604
+ if ((n == null ? void 0 : n.eventType) === C.FunctionClientOutput && !!((st = n.functionDetails) != null && st.id) && n) {
605
+ const f = n.functionDetails.id, I = n.functionDetails.clientOutput, E = o.findIndex((S) => {
602
606
  var m;
603
- return ((m = S.functionDetails) == null ? void 0 : m.id) === g;
607
+ return ((m = S.functionDetails) == null ? void 0 : m.id) === f;
604
608
  });
605
609
  if (E > -1) {
606
610
  const S = o[E], m = {
607
611
  ...S,
608
612
  functionDetails: {
609
613
  ...S.functionDetails,
610
- clientOutput: C ?? S.functionDetails.clientOutput
614
+ clientOutput: I ?? S.functionDetails.clientOutput
611
615
  }
612
616
  };
613
- v(), o[E] = m, h(), u.set(g, m), s.push(m);
617
+ v(), o[E] = m, h(), d.set(f, m), s.push(m);
614
618
  } else {
615
619
  const S = {
616
620
  ...n,
617
621
  id: o.length + 1 + "-" + e.interactionId,
618
622
  functionDetails: { ...n.functionDetails, silent: !0 }
619
623
  };
620
- v(), o = o === e.parts ? e.parts.slice() : o, o.push(S), h(), u.set(g, S);
624
+ v(), o = o === e.parts ? e.parts.slice() : o, o.push(S), h(), d.set(f, S);
621
625
  }
622
626
  } else if (l && n) {
623
- const g = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), C = g ? (N = n.functionDetails) == null ? void 0 : N.id : void 0;
624
- g && !C && console.error("Got isCall or isResponse without a callId", n);
625
- const E = C ? u.get(C) : void 0;
626
- if (E && C && n.functionDetails) {
627
- const S = o.findIndex((ft) => {
628
- var st;
629
- return ((st = ft.functionDetails) == null ? void 0 : st.id) === C;
627
+ const f = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), I = f ? (nt = n.functionDetails) == null ? void 0 : nt.id : void 0;
628
+ f && !I && console.error("Got isCall or isResponse without a callId", n);
629
+ const E = I ? d.get(I) : void 0;
630
+ if (E && I && n.functionDetails) {
631
+ const S = o.findIndex((mt) => {
632
+ var at;
633
+ return ((at = mt.functionDetails) == null ? void 0 : at.id) === I;
630
634
  }), m = S > -1 ? o[S] : E, F = {
631
635
  ...m,
632
636
  eventType: n.eventType,
@@ -667,9 +671,9 @@ ${n.value}
667
671
  cancelUi: n.functionDetails.cancelUi === !0 || m.functionDetails.cancelUi === !0
668
672
  }
669
673
  };
670
- h(), u.set(C, F), F.eventType === I.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(F.functionDetails), s.push(F), S > -1 && (v(), o[S] = F);
674
+ h(), d.set(I, F), F.eventType === C.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(F.functionDetails), s.push(F), S > -1 && (v(), o[S] = F);
671
675
  } else {
672
- if (C && n.functionDetails && !E && (h(), u.set(C, n)), r && r.textAppendable) {
676
+ if (I && n.functionDetails && !E && (h(), d.set(I, n)), r && r.textAppendable) {
673
677
  const m = {
674
678
  ...r,
675
679
  ended: /* @__PURE__ */ new Date(),
@@ -683,40 +687,40 @@ ${n.value}
683
687
  isStillWriting: n.textAppendable,
684
688
  partial: t.partial
685
689
  };
686
- (et = S.functionDetails) != null && et.silent || s.push(S), o = [...o, S], p = !0;
690
+ (it = S.functionDetails) != null && it.silent || s.push(S), o = [...o, S], p = !0;
687
691
  }
688
692
  }
689
693
  let y = o[o.length - 1] ?? null;
690
694
  if (y && n && n.textAppendable) {
691
- const g = {
695
+ const f = {
692
696
  ...y,
693
697
  partial: t.partial,
694
698
  textDetails: y.textDetails ? { ...y.textDetails } : { version: 0 }
695
699
  };
696
- let C = !1;
700
+ let I = !1;
697
701
  if (t.partial) {
698
702
  try {
699
- g.textDetails.version++, p || (g.text = (y.text ?? "") + (n.text ?? ""));
703
+ f.textDetails.version++, p || (f.text = (y.text ?? "") + (n.text ?? ""));
700
704
  } catch (E) {
701
705
  console.error("Error here", E.toString());
702
706
  }
703
- g.textLastChunk = n.text ?? "", g.isStillWriting = !0, C = !0, n.thoughtDetails && g.thoughtDetails && n.thoughtDetails.text !== g.thoughtDetails.text && (g.thoughtDetails = {
704
- ...g.thoughtDetails,
705
- text: g.thoughtDetails.text + n.thoughtDetails.text
706
- }, g.thoughtLastChunk = n.thoughtDetails.text);
707
+ f.textLastChunk = n.text ?? "", f.isStillWriting = !0, I = !0, n.thoughtDetails && f.thoughtDetails && (n.thoughtDetails.text.length >= 50 || n.thoughtDetails.text.length < 50 && n.thoughtDetails.text !== f.thoughtDetails.text) && (f.thoughtDetails = {
708
+ ...f.thoughtDetails,
709
+ text: f.thoughtDetails.text + n.thoughtDetails.text
710
+ }, f.thoughtLastChunk = n.thoughtDetails.text);
707
711
  } else
708
- g.isStillWriting = !1, g.text = n.text ?? "", g.textDetails.version++, n.thoughtDetails && (g.thoughtDetails = {
712
+ f.isStillWriting = !1, f.text = n.text ?? "", f.textDetails.version++, n.thoughtDetails && (f.thoughtDetails = {
709
713
  ...n.thoughtDetails,
710
714
  text: n.thoughtDetails.text.trim()
711
- }), C = !l;
712
- v(), o[o.length - 1] = g, y = g, C && s.push(g);
715
+ }), I = !l;
716
+ v(), o[o.length - 1] = f, y = f, I && s.push(f);
713
717
  }
714
718
  let M = e.artifactData ?? [];
715
719
  if (t.llmArtifacts && t.llmArtifacts.length > 0) {
716
- let g = !1;
717
- for (const C of t.llmArtifacts) {
718
- const E = C.toArtifact();
719
- g || (M = M.slice(), g = !0);
720
+ let f = !1;
721
+ for (const I of t.llmArtifacts) {
722
+ const E = I.toArtifact();
723
+ f || (M = M.slice(), f = !0);
720
724
  const S = M.findIndex((m) => m.id === E.id);
721
725
  S === -1 ? M.push(E) : M[S] = E;
722
726
  }
@@ -726,7 +730,7 @@ ${n.value}
726
730
  version: e.version + 1,
727
731
  parts: o,
728
732
  artifactData: M,
729
- functionMap: u,
733
+ functionMap: d,
730
734
  turn_complete: t.turn_complete,
731
735
  partial: t.partial,
732
736
  asyncFinalResponse: t.asyncFinalResponse
@@ -742,11 +746,11 @@ ${n.value}
742
746
  };
743
747
  }
744
748
  };
745
- f(X, "InteractionService");
746
- let $ = X;
747
- const _t = 1200 * 1e3, k = class k {
748
- constructor(t, e, s, i, n, r, l, o, u, d = St.Interactive) {
749
- a(this, "base_production_url", pt() ?? "https://agent.tripapi.com.br");
749
+ g(Q, "InteractionService");
750
+ let $ = Q;
751
+ const Ut = 1200 * 1e3, N = class N {
752
+ constructor(t, e, s, i, n, r, l, o, d, u = Tt.Interactive) {
753
+ a(this, "base_production_url", yt() ?? "https://agent.tripapi.com.br");
750
754
  a(this, "base_url_local", "http://localagent:8000");
751
755
  a(this, "base_url");
752
756
  a(this, "isLocal", !1);
@@ -770,46 +774,46 @@ const _t = 1200 * 1e3, k = class k {
770
774
  //Define all SSEServer methods here, use from SSEServer.ts
771
775
  a(this, "eventBusService");
772
776
  a(this, "artifactService");
773
- a(this, "onTurnOpen", /* @__PURE__ */ f((t) => {
777
+ a(this, "onTurnOpen", /* @__PURE__ */ g((t) => {
774
778
  this.eventBusService.gatewayOnTurnOpen(t);
775
779
  }, "onTurnOpen"));
776
- a(this, "offTurnOpen", /* @__PURE__ */ f((t) => {
780
+ a(this, "offTurnOpen", /* @__PURE__ */ g((t) => {
777
781
  this.eventBusService.gatewayOffTurnOpen(t);
778
782
  }, "offTurnOpen"));
779
- a(this, "onTurnComplete", /* @__PURE__ */ f((t) => {
783
+ a(this, "onTurnComplete", /* @__PURE__ */ g((t) => {
780
784
  this.eventBusService.gatewayOnTurnComplete(t);
781
785
  }, "onTurnComplete"));
782
- a(this, "offTurnComplete", /* @__PURE__ */ f((t) => {
786
+ a(this, "offTurnComplete", /* @__PURE__ */ g((t) => {
783
787
  this.eventBusService.gatewayOffTurnComplete(t);
784
788
  }, "offTurnComplete"));
785
- a(this, "onStreamError", /* @__PURE__ */ f((t) => {
789
+ a(this, "onStreamError", /* @__PURE__ */ g((t) => {
786
790
  this.eventBusService.gatewayOnStreamError(t);
787
791
  }, "onStreamError"));
788
- a(this, "offStreamError", /* @__PURE__ */ f((t) => {
792
+ a(this, "offStreamError", /* @__PURE__ */ g((t) => {
789
793
  this.eventBusService.gatewayOffStreamError(t);
790
794
  }, "offStreamError"));
791
- a(this, "onStreamEnded", /* @__PURE__ */ f((t) => {
795
+ a(this, "onStreamEnded", /* @__PURE__ */ g((t) => {
792
796
  this.eventBusService.gatewayOnStreamEnded(t);
793
797
  }, "onStreamEnded"));
794
- a(this, "offStreamEnded", /* @__PURE__ */ f((t) => {
798
+ a(this, "offStreamEnded", /* @__PURE__ */ g((t) => {
795
799
  this.eventBusService.gatewayOffStreamEnded(t);
796
800
  }, "offStreamEnded"));
797
- a(this, "onMessage", /* @__PURE__ */ f((t) => {
801
+ a(this, "onMessage", /* @__PURE__ */ g((t) => {
798
802
  this.eventBusService.gatewayOnMessage(t);
799
803
  }, "onMessage"));
800
- a(this, "offMessage", /* @__PURE__ */ f((t) => {
804
+ a(this, "offMessage", /* @__PURE__ */ g((t) => {
801
805
  this.eventBusService.gatewayOffMessage(t);
802
806
  }, "offMessage"));
803
- a(this, "onFirstToken", /* @__PURE__ */ f((t) => {
807
+ a(this, "onFirstToken", /* @__PURE__ */ g((t) => {
804
808
  this.eventBusService.gatewayOnFirstToken(t);
805
809
  }, "onFirstToken"));
806
- a(this, "offFirstToken", /* @__PURE__ */ f((t) => {
810
+ a(this, "offFirstToken", /* @__PURE__ */ g((t) => {
807
811
  this.eventBusService.gatewayOffFirstToken(t);
808
812
  }, "offFirstToken"));
809
- a(this, "onFunctionResponse", /* @__PURE__ */ f((t) => {
813
+ a(this, "onFunctionResponse", /* @__PURE__ */ g((t) => {
810
814
  this.eventBusService.gatewayOnFunctionResponse(t);
811
815
  }, "onFunctionResponse"));
812
- a(this, "offFunctionResponse", /* @__PURE__ */ f((t) => {
816
+ a(this, "offFunctionResponse", /* @__PURE__ */ g((t) => {
813
817
  this.eventBusService.gatewayOffFunctionResponse(t);
814
818
  }, "offFunctionResponse"));
815
819
  a(this, "toolSessionId", null);
@@ -821,7 +825,7 @@ const _t = 1200 * 1e3, k = class k {
821
825
  a(this, "subAgentInteractionServices", /* @__PURE__ */ new Map());
822
826
  a(this, "lastThorttledTimeout", null);
823
827
  a(this, "lastPingStatus", !1);
824
- this.user = t, this.config = n, this.rawJwt = t.access_token, this.base_url = i, this.eventBusService = e, this.sessionId = u, this.runMode = d, this.artifactService = s, this.sessionState = r.getState(), this.notificationPort = l, this.storageService = o, r.subscribe((h, v) => {
828
+ this.user = t, this.config = n, this.rawJwt = t.access_token, this.base_url = i, this.eventBusService = e, this.sessionId = d, this.runMode = u, this.artifactService = s, this.sessionState = r.getState(), this.notificationPort = l, this.storageService = o, r.subscribe((h, v) => {
825
829
  this.sessionState = h;
826
830
  });
827
831
  }
@@ -1043,7 +1047,7 @@ const _t = 1200 * 1e3, k = class k {
1043
1047
  }
1044
1048
  } catch (e) {
1045
1049
  if (this.getCurrentInteractionId()) {
1046
- const s = ut.createErrorEvent("OnMessage error: " + e.toString(), this.getCurrentInteractionId() ?? "Empty Current"), i = this.updateMap(s);
1050
+ const s = gt.createErrorEvent("OnMessage error: " + e.toString(), this.getCurrentInteractionId() ?? "Empty Current"), i = this.updateMap(s);
1047
1051
  if (console.error("Error event: ", JSON.stringify(s, void 0, 4)), !i) {
1048
1052
  console.error("Error event, could not update interaction: ", JSON.stringify(s, void 0, 4));
1049
1053
  return;
@@ -1073,10 +1077,10 @@ const _t = 1200 * 1e3, k = class k {
1073
1077
  }
1074
1078
  localEmitMessage(t, e) {
1075
1079
  const s = (/* @__PURE__ */ new Date()).getTime(), i = s - this.lastCurrentMessageUpdate;
1076
- t.partial === !1 || i >= k.CURRENT_MSG_THROTTLE_MS ? (this.lastThorttledTimeout && (clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = null), this.doEmitMessage(t, s, e), this.pendingCurrentMessage = null) : (this.pendingCurrentMessage = t, this.lastThorttledTimeout && clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = setTimeout(() => {
1080
+ t.partial === !1 || i >= N.CURRENT_MSG_THROTTLE_MS ? (this.lastThorttledTimeout && (clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = null), this.doEmitMessage(t, s, e), this.pendingCurrentMessage = null) : (this.pendingCurrentMessage = t, this.lastThorttledTimeout && clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = setTimeout(() => {
1077
1081
  var r, l;
1078
1082
  this.pendingCurrentMessage && (((r = this.pendingCurrentMessage) == null ? void 0 : r.version) ?? 0) > (((l = this.sessionState.currentMessage) == null ? void 0 : l.version) ?? 0) && (this.doEmitMessage(this.pendingCurrentMessage, s, e), this.lastThorttledTimeout = null);
1079
- }, k.CURRENT_MSG_THROTTLE_MS * 2));
1083
+ }, N.CURRENT_MSG_THROTTLE_MS * 2));
1080
1084
  }
1081
1085
  localOpen(t, e) {
1082
1086
  this.sessionState.setTurnOpen(!0), this.eventBusService.gatewayEmitTurnOpen(t ?? "");
@@ -1104,7 +1108,7 @@ const _t = 1200 * 1e3, k = class k {
1104
1108
  }), this.sessionState.setTurnOpen(!1);
1105
1109
  }
1106
1110
  async handlePing() {
1107
- return Date.now() - this.lastPing.getTime() > _t ? await this.ping() ? (this.lastPing = /* @__PURE__ */ new Date(), this.lastPingStatus = !0, !0) : (this.lastPingStatus = !1, !1) : (this.lastPingStatus = !0, !0);
1111
+ return Date.now() - this.lastPing.getTime() > Ut ? await this.ping() ? (this.lastPing = /* @__PURE__ */ new Date(), this.lastPingStatus = !0, !0) : (this.lastPingStatus = !1, !1) : (this.lastPingStatus = !0, !0);
1108
1112
  }
1109
1113
  async sendMessage(t, e) {
1110
1114
  let s = this.getInteractions().length, i = _.createWaiting(!0, !0, "Overall", /* @__PURE__ */ new Date());
@@ -1112,10 +1116,10 @@ const _t = 1200 * 1e3, k = class k {
1112
1116
  try {
1113
1117
  const { promptAsString: n, json: r } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(t.data) : { promptAsString: t.data, json: void 0 };
1114
1118
  this.sessionState.onRenderPrompt && (t.data = r, t.friendlyMessage = n);
1115
- const l = await this.sendMessageInternal(t, e), o = kt.createPrompt(n ?? "", (r == null ? void 0 : r.toString()) ?? {});
1119
+ const l = await this.sendMessageInternal(t, e), o = bt.createPrompt(n ?? "", (r == null ? void 0 : r.toString()) ?? {});
1116
1120
  this.storageService.storePrompt(o);
1117
- const u = _.fromText("Planejando próximos passos");
1118
- return this.sendStatusMessage(t.data, [i, u], s.toString() + "1"), l != null && l.success ? this.eventBusService.ChatEmitMessageSent(t.data, l.interaction) : this.eventBusService.ChatEmitMessageError((l == null ? void 0 : l.error) ?? ""), l;
1121
+ const d = _.fromText("Planejando próximos passos");
1122
+ return this.sendStatusMessage(t.data, [i, d], s.toString() + "1"), l != null && l.success ? this.eventBusService.ChatEmitMessageSent(t.data, l.interaction) : this.eventBusService.ChatEmitMessageError((l == null ? void 0 : l.error) ?? ""), l;
1119
1123
  } catch (n) {
1120
1124
  return this.eventBusService.ChatEmitMessageError((n == null ? void 0 : n.toString()) ?? ""), {
1121
1125
  success: !1,
@@ -1143,7 +1147,7 @@ const _t = 1200 * 1e3, k = class k {
1143
1147
  sendStatusMessage(t, e, s) {
1144
1148
  var n, r;
1145
1149
  let i;
1146
- ((r = (n = this.currentIS) == null ? void 0 : n.interaction) == null ? void 0 : r.turn_complete) === !1 ? (i = Nt.cloneDeep(this.currentIS.interaction), i.parts.push(...e)) : i = {
1150
+ ((r = (n = this.currentIS) == null ? void 0 : n.interaction) == null ? void 0 : r.turn_complete) === !1 ? (i = _t.cloneDeep(this.currentIS.interaction), i.parts.push(...e)) : i = {
1147
1151
  interactionId: "tmp" + s,
1148
1152
  created: /* @__PURE__ */ new Date(),
1149
1153
  partial: !0,
@@ -1166,13 +1170,13 @@ const _t = 1200 * 1e3, k = class k {
1166
1170
  }
1167
1171
  }
1168
1172
  getNewInteractionId() {
1169
- const e = At(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
1173
+ const e = Pt(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
1170
1174
  return `${this.msg_order}_${e}`;
1171
1175
  }
1172
1176
  };
1173
- f(k, "AgentGatewayService"), a(k, "SUSPENSION_MSG", "SUSPEND"), a(k, "CURRENT_MSG_THROTTLE_MS", 20);
1174
- let G = k;
1175
- const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2, ot = 2, Z = class Z {
1177
+ g(N, "AgentGatewayService"), a(N, "SUSPENSION_MSG", "SUSPEND"), a(N, "CURRENT_MSG_THROTTLE_MS", 20);
1178
+ let G = N;
1179
+ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2, ht = 2, Z = class Z {
1176
1180
  constructor(t = "ws://localhost:8000", e) {
1177
1181
  a(this, "ws", null);
1178
1182
  a(this, "stats");
@@ -1262,7 +1266,7 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1262
1266
  * Cleared by `disconnect()`.
1263
1267
  */
1264
1268
  a(this, "hasEverReceivedPacket", !1);
1265
- this.baseUrl = t, this.getToken = e, this.pingPongStack = [], this.events = [], this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = yt(), console.log("SOCKET INSTACE", wt()), this.stats = {
1269
+ this.baseUrl = t, this.getToken = e, this.pingPongStack = [], this.events = [], this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = Ct(), console.log("SOCKET INSTACE", It()), this.stats = {
1266
1270
  eventCount: 0,
1267
1271
  unknonwCount: 0,
1268
1272
  buffer: [],
@@ -1284,8 +1288,8 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1284
1288
  i || (this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.lastSeq = -1), this._internalReconnect = !1;
1285
1289
  const n = (b = this.getToken) == null ? void 0 : b.call(this), r = [];
1286
1290
  n && r.push(`access_token=${encodeURIComponent(n)}`), t && this.lastSeq >= 0 && r.push(`lastSeq=${this.lastSeq}`);
1287
- const l = r.length > 0 ? `?${r.join("&")}` : "", o = this.baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"), u = `${o}/ws/connect/${t ?? ""}${l}`, d = `${o}/ws/connect/${t ?? ""}` + (i && t && this.lastSeq >= 0 ? ` (resume lastSeq=${this.lastSeq})` : "");
1288
- if (console.log("Connecting to ", d), this.ws) {
1291
+ const l = r.length > 0 ? `?${r.join("&")}` : "", o = this.baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"), d = `${o}/ws/connect/${t ?? ""}${l}`, u = `${o}/ws/connect/${t ?? ""}` + (i && t && this.lastSeq >= 0 ? ` (resume lastSeq=${this.lastSeq})` : "");
1292
+ if (console.log("Connecting to ", u), this.ws) {
1289
1293
  this.ws.onopen = null, this.ws.onmessage = null, this.ws.onerror = null, this.ws.onclose = null;
1290
1294
  try {
1291
1295
  this.ws.close();
@@ -1293,7 +1297,7 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1293
1297
  }
1294
1298
  this.ws = null;
1295
1299
  }
1296
- this.ws = new WebSocket(u), console.log("[WebSocket] Connecting to:", `${o}/ws/connect/${t ?? ""}`);
1300
+ this.ws = new WebSocket(d), console.log("[WebSocket] Connecting to:", `${o}/ws/connect/${t ?? ""}`);
1297
1301
  let h = !1;
1298
1302
  this.ws.onopen = () => {
1299
1303
  console.log("[WebSocket] Connected");
@@ -1305,8 +1309,8 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1305
1309
  const A = this.streamingResponseSerializer.parse(T.data);
1306
1310
  if (!A)
1307
1311
  throw "Error parsing event JSON";
1308
- const N = this.handleMessage(A, T.data);
1309
- !h && (N != null && N.timestamp) && (h = !0, this.hasEverReceivedPacket = !0);
1312
+ const k = this.handleMessage(A, T.data);
1313
+ !h && (k != null && k.timestamp) && (h = !0, this.hasEverReceivedPacket = !0);
1310
1314
  } catch (A) {
1311
1315
  console.error("[WebSocket] Error parsing message:", A);
1312
1316
  }
@@ -1360,19 +1364,19 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1360
1364
  * - 4000-4099 reserved for app-level fatal codes from the server
1361
1365
  */
1362
1366
  shouldAttemptReconnect(t) {
1363
- return !(this.intentionalDisconnect || t === H || t === bt || t === 1e3 || t === 1008);
1367
+ return !(this.intentionalDisconnect || t === H || t === Lt || t === 1e3 || t === 1008);
1364
1368
  }
1365
1369
  cancelPendingReconnect() {
1366
1370
  this.reconnectTimer && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
1367
1371
  }
1368
1372
  computeBackoffDelay() {
1369
- const t = Rt * Math.pow(Lt, this.reconnectAttempts), e = Math.min(t, Ut), s = e * xt * (Math.random() * 2 - 1);
1373
+ const t = Bt * Math.pow($t, this.reconnectAttempts), e = Math.min(t, Wt), s = e * qt * (Math.random() * 2 - 1);
1370
1374
  return Math.max(0, Math.round(e + s));
1371
1375
  }
1372
1376
  scheduleReconnect(t, e, s) {
1373
1377
  var n, r;
1374
1378
  if (this.intentionalDisconnect) return;
1375
- if (this.reconnectAttempts >= ot) {
1379
+ if (this.reconnectAttempts >= ht) {
1376
1380
  console.warn(
1377
1381
  `[WebSocket] Reconnect exhausted after ${this.reconnectAttempts} attempts (last code=${e}, reason="${s}"). Handing off to outer state manager.`
1378
1382
  ), this.isReconnecting = !1, this.reconnectAttempts = 0, this.cancelPendingReconnect(), (n = this.onClose) == null || n.call(this, e, s);
@@ -1381,7 +1385,7 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1381
1385
  this.isReconnecting = !0, this.reconnectAttempts += 1;
1382
1386
  const i = this.computeBackoffDelay();
1383
1387
  console.warn(
1384
- `[WebSocket] Unexpected close (code=${e}, reason="${s}"). Reconnect attempt #${this.reconnectAttempts}/${ot} in ${i}ms (resume sessionId=${t ?? "none"}).`
1388
+ `[WebSocket] Unexpected close (code=${e}, reason="${s}"). Reconnect attempt #${this.reconnectAttempts}/${ht} in ${i}ms (resume sessionId=${t ?? "none"}).`
1385
1389
  ), (r = this.onReconnecting) == null || r.call(this, this.reconnectAttempts, i), this.cancelPendingReconnect(), this.reconnectTimer = setTimeout(async () => {
1386
1390
  if (this.reconnectTimer = null, !this.intentionalDisconnect)
1387
1391
  try {
@@ -1398,7 +1402,7 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1398
1402
  * Handle incoming messages from server
1399
1403
  */
1400
1404
  handleMessage(t, e) {
1401
- var l, o, u;
1405
+ var l, o, d;
1402
1406
  switch (typeof t.seq == "number" && t.seq > this.lastSeq && (this.lastSeq = t.seq), t.type) {
1403
1407
  case "Pong":
1404
1408
  if (this.sessionId = t.sessionId, this.lastKnownSessionId = t.sessionId ?? this.lastKnownSessionId, !t.sessionId) {
@@ -1421,47 +1425,47 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1421
1425
  console.warn("[WebSocket] Unknown message type:", t.type);
1422
1426
  }
1423
1427
  if (t.partialEvent) {
1424
- const d = t.partialEvent;
1425
- this.emitFirstToken(d == null ? void 0 : d.iteractionId);
1426
- const h = new Tt();
1427
- if (h.author = "main", h.streamingParts = t.partialEvent.streamingParts, t.partialEvent.partialEventType ? h.eventType = t.partialEvent.partialEventType : h.eventType = d.functionName ? {
1428
+ const u = t.partialEvent;
1429
+ this.emitFirstToken(u == null ? void 0 : u.iteractionId);
1430
+ const h = new vt();
1431
+ if (h.author = "main", h.streamingParts = t.partialEvent.streamingParts, t.partialEvent.partialEventType ? h.eventType = t.partialEvent.partialEventType : h.eventType = u.functionName ? {
1428
1432
  fullName: x.StreamingFunctionCallUpdateContent,
1429
- type: I.PartialFunctionCall
1430
- } : d.partialReasoning ? {
1433
+ type: C.PartialFunctionCall
1434
+ } : u.partialReasoning ? {
1431
1435
  fullName: x.StreamingReasoningContent,
1432
- type: I.Thought
1436
+ type: C.Thought
1433
1437
  } : {
1434
1438
  fullName: x.StreamingTextContent,
1435
- type: I.Text
1436
- }, h.interactionId = (d == null ? void 0 : d.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type == I.PartialFunctionCall) {
1437
- var s = new It();
1438
- s.choiceIndex = 0, s.callId = d.functionCallId, s.arguments = d.partialText, s.name = d.functionName, h.content = {
1439
+ type: C.Text
1440
+ }, h.interactionId = (u == null ? void 0 : u.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type == C.PartialFunctionCall) {
1441
+ var s = new Et();
1442
+ s.choiceIndex = 0, s.callId = u.functionCallId, s.arguments = u.partialText, s.name = u.functionName, h.content = {
1439
1443
  items: [s],
1440
1444
  role: {
1441
1445
  label: "Assistant"
1442
1446
  }
1443
1447
  };
1444
- } else if (h.eventType.type == I.Text)
1448
+ } else if (h.eventType.type == C.Text)
1445
1449
  if (h.eventType.fullName == x.StreamingTextContent) {
1446
- var i = new Ct();
1447
- i.text = d.partialText, h.content = {
1450
+ var i = new Mt();
1451
+ i.text = u.partialText, h.content = {
1448
1452
  items: [i],
1449
1453
  role: {
1450
1454
  label: "Assistant"
1451
1455
  }
1452
1456
  };
1453
1457
  } else {
1454
- var n = new vt();
1455
- n.text = d.partialText, h.content = {
1458
+ var n = new Ot();
1459
+ n.text = u.partialText, h.content = {
1456
1460
  items: [n],
1457
1461
  role: {
1458
1462
  label: "Assistant"
1459
1463
  }
1460
1464
  };
1461
1465
  }
1462
- else if (h.eventType.type == I.Thought) {
1463
- var r = new Et();
1464
- r.text = d.partialReasoning, h.content = {
1466
+ else if (h.eventType.type == C.Thought) {
1467
+ var r = new Dt();
1468
+ r.text = u.partialReasoning, h.content = {
1465
1469
  items: [r],
1466
1470
  role: {
1467
1471
  label: "Assistant"
@@ -1471,9 +1475,9 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1471
1475
  t.event = void 0;
1472
1476
  h.role = {
1473
1477
  label: "Assistant"
1474
- }, h.timestamp = (d == null ? void 0 : d.timeStamp) ?? (/* @__PURE__ */ new Date()).getTime(), h.turnComplete = !1, t.event = h, t.partialEvent = void 0;
1478
+ }, h.timestamp = (u == null ? void 0 : u.timeStamp) ?? (/* @__PURE__ */ new Date()).getTime(), h.turnComplete = !1, t.event = h, t.partialEvent = void 0;
1475
1479
  }
1476
- return t.event ? (t.subAgentId && (t.event.subAgentId = t.subAgentId, t.event.subAgentName = t.subAgentName), ((((o = (l = t.event.content) == null ? void 0 : l.items) == null ? void 0 : o.length) ?? 0) > 0 || (((u = t.event.streamingParts) == null ? void 0 : u.length) ?? 0) > 0) && this.emitFirstToken(t.event.interactionId), this.handleEvent(t.event, e), t.event) : null;
1480
+ return t.event ? (t.subAgentId && (t.event.subAgentId = t.subAgentId, t.event.subAgentName = t.subAgentName), ((((o = (l = t.event.content) == null ? void 0 : l.items) == null ? void 0 : o.length) ?? 0) > 0 || (((d = t.event.streamingParts) == null ? void 0 : d.length) ?? 0) > 0) && this.emitFirstToken(t.event.interactionId), this.handleEvent(t.event, e), t.event) : null;
1477
1481
  }
1478
1482
  emitFirstToken(t) {
1479
1483
  var e;
@@ -1647,12 +1651,12 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1647
1651
  async handleEvent(t, e) {
1648
1652
  var s;
1649
1653
  try {
1650
- const i = ut.parseFromTypedEvent(t);
1654
+ const i = gt.parseFromTypedEvent(t);
1651
1655
  if (!i)
1652
1656
  throw "Server event was null";
1653
1657
  this.events.push([(/* @__PURE__ */ new Date()).getTime(), ((s = t.text) == null ? void 0 : s.length) ?? 0]), this.stats.eventCount += 1, this.stats.totalTransfered += e.length, i.session_information && !i.subAgentId && (this.stats.sessionInformation = i.session_information), this.stats.elapsed = (Date.now() - this.stats.startTime.getTime()) / 1e3;
1654
- const n = Date.now() - rt * 1e3, l = this.events.filter((o) => o[0] > n).reduce((o, u) => o += u[1], 0) / Ft;
1655
- this.stats.tokensPerSecond = l / rt, this.flushStatsCoalesced(), this.onEvent && this.onEvent(i).catch((o) => {
1658
+ const n = Date.now() - lt * 1e3, l = this.events.filter((o) => o[0] > n).reduce((o, d) => o += d[1], 0) / xt;
1659
+ this.stats.tokensPerSecond = l / lt, this.flushStatsCoalesced(), this.onEvent && this.onEvent(i).catch((o) => {
1656
1660
  console.error("Lost error on on-event", o);
1657
1661
  });
1658
1662
  } catch (i) {
@@ -1660,11 +1664,11 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
1660
1664
  }
1661
1665
  }
1662
1666
  };
1663
- f(Z, "WebSocketConnecionV2");
1664
- let ct = Z;
1665
- const Bt = "envision_agent_sessionId", V = class V extends G {
1666
- constructor(e, s, i, n, r, l, o, u, d, h, v) {
1667
- super(e, s, i, n, r, l, o, d, v);
1667
+ g(Z, "WebSocketConnecionV2");
1668
+ let ut = Z;
1669
+ const Jt = "envision_agent_sessionId", V = class V extends G {
1670
+ constructor(e, s, i, n, r, l, o, d, u, h, v) {
1671
+ super(e, s, i, n, r, l, o, u, v);
1668
1672
  a(this, "suspendState", !1);
1669
1673
  a(this, "wsService");
1670
1674
  a(this, "root_url", "");
@@ -1681,7 +1685,7 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
1681
1685
  a(this, "lastConnectionPromise", null);
1682
1686
  a(this, "socketState", R.Disconnected);
1683
1687
  a(this, "streamOpened", !1);
1684
- this.hearBeatPort = h, this.root_url = this.base_url, this.wsService = u, this.wsService.onEvent = async (p) => {
1688
+ this.hearBeatPort = h, this.root_url = this.base_url, this.wsService = d, this.wsService.onEvent = async (p) => {
1685
1689
  await super.Message(p);
1686
1690
  }, this.wsService.onNewPacket = (p) => {
1687
1691
  this.sessionState.setStatistics(p), this.eventBusService.streamEmitNewChunk(p);
@@ -1717,7 +1721,7 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
1717
1721
  return this.suspendState;
1718
1722
  }
1719
1723
  getStoredSessionId() {
1720
- const e = localStorage.getItem(Bt);
1724
+ const e = localStorage.getItem(Jt);
1721
1725
  if (e)
1722
1726
  return e;
1723
1727
  }
@@ -1743,13 +1747,13 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
1743
1747
  r = !0;
1744
1748
  }, e.suspendStream();
1745
1749
  try {
1746
- let u = 0;
1747
- for (; !r && u < 5e3; )
1748
- await this.sleep(100), u += 100;
1750
+ let d = 0;
1751
+ for (; !r && d < 5e3; )
1752
+ await this.sleep(100), d += 100;
1749
1753
  if (r)
1750
1754
  if (this.currentIS) {
1751
- const d = this.currentIS.interaction;
1752
- d.isSuspended = !0, this.sessionState.setCurrentMessage(d), this.sessionState.setTurnOpen(!1), i(!0);
1755
+ const u = this.currentIS.interaction;
1756
+ u.isSuspended = !0, this.sessionState.setCurrentMessage(u), this.sessionState.setTurnOpen(!1), i(!0);
1753
1757
  } else
1754
1758
  console.error("CurrentIS is null"), n("CurrentIS is null");
1755
1759
  else
@@ -1759,9 +1763,17 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
1759
1763
  }
1760
1764
  });
1761
1765
  }
1762
- /** Forwards a parked-tool answer; 'queued' means the socket was down and it will flush on reconnect. */
1766
+ /**
1767
+ * Forwards a parked-tool answer; 'queued' means the socket was down and it will flush on reconnect.
1768
+ *
1769
+ * Feature-detected rather than cast: a host may supply any `IWebSocketConnection` (the demo's fake
1770
+ * gateway does), and a hard cast turned "this transport doesn't deliver answers" into a TypeError
1771
+ * thrown from a click handler — with the answer lost either way.
1772
+ */
1763
1773
  answerHumanTool(e, s) {
1764
- return this.wsService.answerHumanTool(e, s);
1774
+ var n;
1775
+ const i = (n = this.wsService.answerHumanTool) == null ? void 0 : n.bind(this.wsService);
1776
+ return i ? i(e, s) : (console.warn("[AgentGateway] transport cannot deliver parked-tool answers", e), "queued");
1765
1777
  }
1766
1778
  async cancelSuspend() {
1767
1779
  var s;
@@ -1804,7 +1816,7 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
1804
1816
  }
1805
1817
  // Send a message to the server via HTTP POST
1806
1818
  async sendMessageInternal(e, s, i) {
1807
- var l, o, u, d, h, v, p, D;
1819
+ var l, o, d, u, h, v, p, D;
1808
1820
  const n = this.suspendState;
1809
1821
  this.suspendState = !1;
1810
1822
  const r = this.startInteraction(e.friendlyMessage ?? e.data, n);
@@ -1820,13 +1832,13 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
1820
1832
  Action: B.SendMessage,
1821
1833
  ModelId: this.config.model,
1822
1834
  InteractionId: r.interactionId,
1823
- AgentId: (u = this.config.agentConfig) == null ? void 0 : u.id,
1835
+ AgentId: (d = this.config.agentConfig) == null ? void 0 : d.id,
1824
1836
  // Optional explicit C# class name on the server (e.g. "LlmAgentSessionReplay").
1825
1837
  // When set, AgentBootStrapService.GetAgent dispatches to that class directly
1826
1838
  // instead of looking up an Agent metadata row by AgentId. Plumbed through
1827
1839
  // `agentContext.agentConfig.agentImplementation` so a host can run a turn
1828
1840
  // against any registered LlmAgent variant without seeding a Mongo record.
1829
- AgentImplementation: (d = this.config.agentConfig) == null ? void 0 : d.agentImplementation,
1841
+ AgentImplementation: (u = this.config.agentConfig) == null ? void 0 : u.agentImplementation,
1830
1842
  Parameters: {
1831
1843
  CustomerName: ((h = this.config.customer) == null ? void 0 : h.name) ?? "",
1832
1844
  DataSet: ((v = this.config.customer) == null ? void 0 : v.dataSetId) ?? ""
@@ -1844,8 +1856,8 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
1844
1856
  });
1845
1857
  }
1846
1858
  };
1847
- f(V, "AgentGatewayWSAsync");
1848
- let lt = V;
1859
+ g(V, "AgentGatewayWSAsync");
1860
+ let dt = V;
1849
1861
  const tt = class tt {
1850
1862
  constructor(t, e) {
1851
1863
  a(this, "cache", /* @__PURE__ */ new Map());
@@ -1854,7 +1866,7 @@ const tt = class tt {
1854
1866
  this.serverBaseUrl = t.replace(/\/$/, ""), this.accessToken = e;
1855
1867
  }
1856
1868
  get headers() {
1857
- return { Authorization: `Bearer ${Pt(this.accessToken)}` };
1869
+ return { Authorization: `Bearer ${Ft(this.accessToken)}` };
1858
1870
  }
1859
1871
  async init() {
1860
1872
  }
@@ -1901,17 +1913,17 @@ const tt = class tt {
1901
1913
  }
1902
1914
  }
1903
1915
  };
1904
- f(tt, "HttpArtifactService");
1905
- let ht = tt;
1916
+ g(tt, "HttpArtifactService");
1917
+ let ft = tt;
1906
1918
  export {
1907
1919
  G as A,
1908
1920
  J as E,
1909
- ht as H,
1921
+ ft as H,
1910
1922
  $ as I,
1911
- it as L,
1912
- at as M,
1913
- ct as W,
1914
- lt as a,
1915
- Qt as u
1923
+ ot as L,
1924
+ ct as M,
1925
+ ut as W,
1926
+ dt as a,
1927
+ te as u
1916
1928
  };
1917
- //# sourceMappingURL=httpArtifactService-BqcorW_s.js.map
1929
+ //# sourceMappingURL=httpArtifactService--6WV2FDW.js.map