@aintela/chat 0.2.28 → 0.2.30

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 (33) hide show
  1. package/dist/{promptHighlight-BHSQkdFs.js → atMentions-DqhG_vde.js} +37 -17
  2. package/dist/atMentions-DqhG_vde.js.map +1 -0
  3. package/dist/{auth-GFZAFz7L.js → auth-BN22f1HF.js} +2 -2
  4. package/dist/{auth-GFZAFz7L.js.map → auth-BN22f1HF.js.map} +1 -1
  5. package/dist/components.js +3039 -2995
  6. package/dist/components.js.map +1 -1
  7. package/dist/hooks.js +2 -2
  8. package/dist/{httpArtifactService-B668XBHO.js → httpArtifactService-COu1QCBJ.js} +137 -136
  9. package/dist/{httpArtifactService-B668XBHO.js.map → httpArtifactService-COu1QCBJ.js.map} +1 -1
  10. package/dist/{httpSessionService-BuT5FlDc.js → httpSessionService-B_G3Ej2C.js} +2 -2
  11. package/dist/{httpSessionService-BuT5FlDc.js.map → httpSessionService-B_G3Ej2C.js.map} +1 -1
  12. package/dist/index.js +55 -53
  13. package/dist/models.js +1 -1
  14. package/dist/{serializer-BPina6fX.js → serializer-BZjKrhXT.js} +118 -117
  15. package/dist/{serializer-BPina6fX.js.map → serializer-BZjKrhXT.js.map} +1 -1
  16. package/dist/services.js +2 -2
  17. package/dist/src/ErrorBondary.d.ts +1 -1
  18. package/dist/src/components/v2/PromptV2.d.ts +11 -0
  19. package/dist/src/hooks/usePromptAssist.d.ts +1 -0
  20. package/dist/src/models/semanticKernelModel/serializer.test.d.ts +1 -0
  21. package/dist/src/services/httpPromptAssistService.d.ts +5 -0
  22. package/dist/src/utils/atMentions.d.ts +28 -0
  23. package/dist/src/utils/atMentions.test.d.ts +1 -0
  24. package/dist/src/utils/index.d.ts +2 -0
  25. package/dist/{useChatSessions-DsHPo0GV.js → useChatSessions-D5y5kCID.js} +2 -2
  26. package/dist/{useChatSessions-DsHPo0GV.js.map → useChatSessions-D5y5kCID.js.map} +1 -1
  27. package/dist/useContainerWidth-D0CQQqZ2.js +262 -0
  28. package/dist/useContainerWidth-D0CQQqZ2.js.map +1 -0
  29. package/dist/utils.js +28 -26
  30. package/package.json +1 -1
  31. package/dist/promptHighlight-BHSQkdFs.js.map +0 -1
  32. package/dist/useContainerWidth-0EA-kdzl.js +0 -260
  33. package/dist/useContainerWidth-0EA-kdzl.js.map +0 -1
@@ -2,19 +2,19 @@ var nt = Object.defineProperty;
2
2
  var gt = (O, t, e) => t in O ? nt(O, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : O[t] = e;
3
3
  var f = (O, t) => nt(O, "name", { value: t, configurable: !0 });
4
4
  var a = (O, t, e) => gt(O, typeof t != "symbol" ? t + "" : t, e);
5
- import { d as _, t as mt, E as y, k as pt, j as St, q as wt, C as L } from "./environmentUtils-CUVZ6Dq1.js";
6
- import { I as A, S as ut, g as Tt, L as yt, P as F, b as It, e as Ct, T as vt, c as Et } from "./serializer-BPina6fX.js";
5
+ import { d as R, t as mt, E as y, k as pt, j as St, q as wt, C as x } from "./environmentUtils-CUVZ6Dq1.js";
6
+ import { I as P, S as ut, g as Tt, L as yt, P as b, b as It, e as Ct, T as vt, c as Et } from "./serializer-BZjKrhXT.js";
7
7
  import { unified as Mt } from "unified";
8
8
  import Ot from "remark-parse";
9
9
  import { toMarkdown as Dt } from "mdast-util-to-markdown";
10
10
  import { format as At } from "date-fns";
11
11
  import Nt from "lodash";
12
- import { P as Pt, C as P } from "./Prompt-DZb7OaPp.js";
12
+ import { P as Pt, C as _ } from "./Prompt-DZb7OaPp.js";
13
13
  const T = {
14
14
  ARTIFACTS: "envision-artifacts",
15
15
  SECTIONS: "envision-sections",
16
16
  PROMPTS: "envision-prompts"
17
- }, k = [
17
+ }, F = [
18
18
  {
19
19
  id: "dashboards",
20
20
  name: "Dashboards",
@@ -36,7 +36,7 @@ const T = {
36
36
  created: (/* @__PURE__ */ new Date()).toISOString(),
37
37
  iconType: "folder"
38
38
  }
39
- ], J = class J {
39
+ ], q = class q {
40
40
  constructor() {
41
41
  a(this, "onPromptCreated", /* @__PURE__ */ f(() => {
42
42
  }, "onPromptCreated"));
@@ -54,14 +54,14 @@ const T = {
54
54
  try {
55
55
  const t = localStorage.getItem(T.SECTIONS);
56
56
  if (!t)
57
- localStorage.setItem(T.SECTIONS, JSON.stringify(k));
57
+ localStorage.setItem(T.SECTIONS, JSON.stringify(F));
58
58
  else {
59
59
  const s = JSON.parse(t);
60
- if (k.some(
60
+ if (F.some(
61
61
  (n) => !s.find((r) => r.id === n.id)
62
62
  )) {
63
63
  const n = [...s];
64
- k.forEach((r) => {
64
+ F.forEach((r) => {
65
65
  s.find((l) => l.id === r.id) || n.push(r);
66
66
  }), localStorage.setItem(T.SECTIONS, JSON.stringify(n));
67
67
  }
@@ -74,7 +74,7 @@ const T = {
74
74
  if (!r.sectionId) {
75
75
  i = !0;
76
76
  let l = "data-analytics";
77
- return r.type === _.Dashboard ? l = "dashboards" : r.type === _.Chart && (l = "charts"), {
77
+ return r.type === R.Dashboard ? l = "dashboards" : r.type === R.Chart && (l = "charts"), {
78
78
  ...r,
79
79
  sectionId: l
80
80
  };
@@ -90,9 +90,9 @@ const T = {
90
90
  getSections() {
91
91
  try {
92
92
  const t = localStorage.getItem(T.SECTIONS);
93
- return t ? JSON.parse(t) : k;
93
+ return t ? JSON.parse(t) : F;
94
94
  } catch (t) {
95
- return console.error("Error loading sections:", t), k;
95
+ return console.error("Error loading sections:", t), F;
96
96
  }
97
97
  }
98
98
  getArtifacts() {
@@ -133,7 +133,7 @@ const T = {
133
133
  e[s] = t;
134
134
  else {
135
135
  let i = "data-analytics";
136
- t.type === _.Dashboard ? i = "dashboards" : t.type === _.Chart && (i = "charts");
136
+ t.type === R.Dashboard ? i = "dashboards" : t.type === R.Chart && (i = "charts");
137
137
  const n = {
138
138
  ...t,
139
139
  created: t.created || (/* @__PURE__ */ new Date()).toISOString(),
@@ -196,8 +196,8 @@ const T = {
196
196
  }
197
197
  }
198
198
  };
199
- f(J, "LocalStorageService");
200
- let it = J;
199
+ f(q, "LocalStorageService");
200
+ let it = q;
201
201
  const jt = /* @__PURE__ */ f((O) => {
202
202
  const t = O.getPrompts(), e = t.length;
203
203
  if (e > 0) {
@@ -205,7 +205,7 @@ const jt = /* @__PURE__ */ f((O) => {
205
205
  return { promptState: e + "_" + s + "_" + i + "_" + n };
206
206
  } else
207
207
  return { promptState: "0" };
208
- }, "usePromptState"), q = class q {
208
+ }, "usePromptState"), G = class G {
209
209
  constructor() {
210
210
  a(this, "activityLost", "activityLost");
211
211
  a(this, "artifactGenerated", "artifactGenerated");
@@ -230,9 +230,9 @@ const jt = /* @__PURE__ */ f((O) => {
230
230
  a(this, "gatewayFirstToken", "gatewayFirstToken");
231
231
  }
232
232
  };
233
- f(q, "EventTypes");
234
- let x = q;
235
- const c = new x(), G = class G {
233
+ f(G, "EventTypes");
234
+ let B = G;
235
+ const c = new B(), H = class H {
236
236
  constructor() {
237
237
  a(this, "listeners", {});
238
238
  a(this, "listenersCount", {});
@@ -483,9 +483,9 @@ const c = new x(), G = class G {
483
483
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
484
484
  }
485
485
  };
486
- f(G, "EventBusService");
487
- let B = G;
488
- const H = class H extends B {
486
+ f(H, "EventBusService");
487
+ let $ = H;
488
+ const K = class K extends $ {
489
489
  constructor() {
490
490
  super();
491
491
  }
@@ -511,12 +511,12 @@ const H = class H extends B {
511
511
  console.log("MockEventBusService.gatewayOffFunctionResponse", t);
512
512
  }
513
513
  };
514
- f(H, "MockEventBusService");
515
- let at = H;
514
+ f(K, "MockEventBusService");
515
+ let at = K;
516
516
  const dt = {
517
517
  inline: "inline",
518
518
  block: "block"
519
- }, K = class K {
519
+ }, z = class z {
520
520
  constructor() {
521
521
  a(this, "parts", []);
522
522
  a(this, "isLastGroup", !1);
@@ -525,9 +525,9 @@ const dt = {
525
525
  a(this, "type", dt.inline);
526
526
  }
527
527
  };
528
- f(K, "InteractionPartGroup");
529
- let R = K;
530
- const z = class z {
528
+ f(z, "InteractionPartGroup");
529
+ let U = z;
530
+ const j = class j {
531
531
  constructor(t, e) {
532
532
  a(this, "interaction");
533
533
  a(this, "eventBusService");
@@ -549,7 +549,7 @@ ${n.value}
549
549
  const s = this.parseTextIntoParts(t), i = [];
550
550
  let n = 0;
551
551
  for (const r of s) {
552
- const l = A.fromText(r);
552
+ const l = P.fromText(r);
553
553
  l.id = n + "_" + e, i.push(l), n++;
554
554
  }
555
555
  return i;
@@ -557,11 +557,11 @@ ${n.value}
557
557
  groupPartsByDisplayType(t, e = !0, s = !1) {
558
558
  var l;
559
559
  const i = [];
560
- let n = new R();
560
+ let n = new U();
561
561
  for (let o = 0; o < t.length; o++) {
562
562
  const u = t[o];
563
563
  let h = !(((l = u.functionDetails) == null ? void 0 : l.isUi) ?? !1) && u.eventType !== y.Text && u.eventType !== y.Thought && (u.eventType === y.FunctionCall || u.eventType === y.PartialFunctionCall || u.eventType === y.FunctionResponse) && o < t.length - 1;
564
- !e && h && !s || (h ? (u.eventType == y.Thought && (n.hasThoughts = !0), n.parts.push(u), n.isLastGroup = o === t.length - 1) : (n.parts.length > 0 && (i.push(n), n = new R()), i.push({
564
+ !e && h && !s || (h ? (u.eventType == y.Thought && (n.hasThoughts = !0), n.parts.push(u), n.isLastGroup = o === t.length - 1) : (n.parts.length > 0 && (i.push(n), n = new U()), i.push({
565
565
  type: dt.block,
566
566
  parts: [u],
567
567
  isLastGroup: o === t.length - 1,
@@ -585,48 +585,48 @@ ${n.value}
585
585
  // new tree as the last step, so snapshots already handed out to throttled
586
586
  // subscribers can't diverge from the live state.
587
587
  merge(t) {
588
- var X, Z, V, tt, et;
589
- const e = this.interaction, s = [], i = [], n = A.FlatParts(t == null ? void 0 : t.parts), r = e.parts[e.parts.length - 1] ?? null;
588
+ var A, Z, V, tt, et;
589
+ const e = this.interaction, s = [], i = [], n = P.FlatParts(t == null ? void 0 : t.parts), r = e.parts[e.parts.length - 1] ?? null;
590
590
  let l = !1;
591
- n && (l = !r || n.mustPush || n.mustPush === !1 && (n.eventType !== (r == null ? void 0 : r.eventType) || ((X = n == null ? void 0 : n.functionDetails) == null ? void 0 : X.id) !== ((Z = r.functionDetails) == null ? void 0 : Z.id)));
591
+ n && (l = !r || n.mustPush || n.mustPush === !1 && (n.eventType !== (r == null ? void 0 : r.eventType) || ((A = n == null ? void 0 : n.functionDetails) == null ? void 0 : A.id) !== ((Z = r.functionDetails) == null ? void 0 : Z.id)));
592
592
  let o = e.parts, u = e.functionMap ?? /* @__PURE__ */ new Map(), d = !e.functionMap;
593
593
  const h = /* @__PURE__ */ f(() => {
594
594
  d || (u = new Map(u), d = !0);
595
- }, "cloneFunctionMap"), v = /* @__PURE__ */ f(() => {
595
+ }, "cloneFunctionMap"), C = /* @__PURE__ */ f(() => {
596
596
  o === e.parts && (o = e.parts.slice());
597
597
  }, "clonePartsIfShared");
598
598
  let p = !1;
599
599
  if ((n == null ? void 0 : n.eventType) === y.FunctionClientOutput && !!((V = n.functionDetails) != null && V.id) && n) {
600
- const g = n.functionDetails.id, C = n.functionDetails.clientOutput, E = o.findIndex((w) => {
600
+ const g = n.functionDetails.id, I = n.functionDetails.clientOutput, v = o.findIndex((w) => {
601
601
  var m;
602
602
  return ((m = w.functionDetails) == null ? void 0 : m.id) === g;
603
603
  });
604
- if (E > -1) {
605
- const w = o[E], m = {
604
+ if (v > -1) {
605
+ const w = o[v], m = {
606
606
  ...w,
607
607
  functionDetails: {
608
608
  ...w.functionDetails,
609
- clientOutput: C ?? w.functionDetails.clientOutput
609
+ clientOutput: I ?? w.functionDetails.clientOutput
610
610
  }
611
611
  };
612
- v(), o[E] = m, h(), u.set(g, m), s.push(m);
612
+ C(), o[v] = m, h(), u.set(g, m), s.push(m);
613
613
  } else {
614
614
  const w = {
615
615
  ...n,
616
616
  id: o.length + 1 + "-" + e.interactionId,
617
617
  functionDetails: { ...n.functionDetails, silent: !0 }
618
618
  };
619
- v(), o = o === e.parts ? e.parts.slice() : o, o.push(w), h(), u.set(g, w);
619
+ C(), o = o === e.parts ? e.parts.slice() : o, o.push(w), h(), u.set(g, w);
620
620
  }
621
621
  } else if (l && n) {
622
- const g = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), C = g ? (tt = n.functionDetails) == null ? void 0 : tt.id : void 0;
623
- g && !C && console.error("Got isCall or isResponse without a callId", n);
624
- const E = C ? u.get(C) : void 0;
625
- if (E && C && n.functionDetails) {
622
+ const g = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), I = g ? (tt = n.functionDetails) == null ? void 0 : tt.id : void 0;
623
+ g && !I && console.error("Got isCall or isResponse without a callId", n);
624
+ const v = I ? u.get(I) : void 0;
625
+ if (v && I && n.functionDetails) {
626
626
  const w = o.findIndex((ft) => {
627
627
  var st;
628
- return ((st = ft.functionDetails) == null ? void 0 : st.id) === C;
629
- }), m = w > -1 ? o[w] : E, N = {
628
+ return ((st = ft.functionDetails) == null ? void 0 : st.id) === I;
629
+ }), m = w > -1 ? o[w] : v, k = {
630
630
  ...m,
631
631
  eventType: n.eventType,
632
632
  functionDetails: {
@@ -663,15 +663,15 @@ ${n.value}
663
663
  isAskUser: n.functionDetails.isAskUser || m.functionDetails.isAskUser || !!(n.functionDetails.askUserComponent ?? m.functionDetails.askUserComponent)
664
664
  }
665
665
  };
666
- h(), u.set(C, N), N.eventType === y.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(N.functionDetails), s.push(N), w > -1 && (v(), o[w] = N);
666
+ h(), u.set(I, k), k.eventType === y.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(k.functionDetails), s.push(k), w > -1 && (C(), o[w] = k);
667
667
  } else {
668
- if (C && n.functionDetails && !E && (h(), u.set(C, n)), r && r.textAppendable) {
668
+ if (I && n.functionDetails && !v && (h(), u.set(I, n)), r && r.textAppendable) {
669
669
  const m = {
670
670
  ...r,
671
671
  ended: /* @__PURE__ */ new Date(),
672
672
  isStillWriting: !1
673
673
  };
674
- v(), o[o.length - 1] = m, s.push(m);
674
+ C(), o[o.length - 1] = m, s.push(m);
675
675
  }
676
676
  const w = {
677
677
  ...n,
@@ -682,21 +682,21 @@ ${n.value}
682
682
  (et = w.functionDetails) != null && et.silent || s.push(w), o = [...o, w], p = !0;
683
683
  }
684
684
  }
685
- let I = o[o.length - 1] ?? null;
686
- if (I && n && n.textAppendable) {
685
+ let E = o[o.length - 1] ?? null;
686
+ if (E && n && n.textAppendable) {
687
687
  const g = {
688
- ...I,
688
+ ...E,
689
689
  partial: t.partial,
690
- textDetails: I.textDetails ? { ...I.textDetails } : { version: 0 }
690
+ textDetails: E.textDetails ? { ...E.textDetails } : { version: 0 }
691
691
  };
692
- let C = !1;
692
+ let I = !1;
693
693
  if (t.partial) {
694
694
  try {
695
- g.textDetails.version++, p || (g.text = (I.text ?? "") + (n.text ?? ""));
696
- } catch (E) {
697
- console.error("Error here", E.toString());
695
+ g.textDetails.version++, p || (g.text = (E.text ?? "") + (n.text ?? ""));
696
+ } catch (v) {
697
+ console.error("Error here", v.toString());
698
698
  }
699
- g.textLastChunk = n.text ?? "", g.isStillWriting = !0, C = !0, n.thoughtDetails && g.thoughtDetails && n.thoughtDetails.text !== g.thoughtDetails.text && (g.thoughtDetails = {
699
+ g.textLastChunk = n.text ?? "", g.isStillWriting = !0, I = !0, n.thoughtDetails && g.thoughtDetails && n.thoughtDetails.text !== g.thoughtDetails.text && (g.thoughtDetails = {
700
700
  ...g.thoughtDetails,
701
701
  text: g.thoughtDetails.text + n.thoughtDetails.text
702
702
  }, g.thoughtLastChunk = n.thoughtDetails.text);
@@ -704,43 +704,43 @@ ${n.value}
704
704
  g.isStillWriting = !1, g.text = n.text ?? "", g.textDetails.version++, n.thoughtDetails && (g.thoughtDetails = {
705
705
  ...n.thoughtDetails,
706
706
  text: n.thoughtDetails.text.trim()
707
- }), C = !l;
708
- v(), o[o.length - 1] = g, I = g, C && s.push(g);
707
+ }), I = !l;
708
+ C(), o[o.length - 1] = g, E = g, I && s.push(g);
709
709
  }
710
- let M = e.artifactData ?? [];
710
+ let S = e.artifactData ?? [];
711
711
  if (t.llmArtifacts && t.llmArtifacts.length > 0) {
712
712
  let g = !1;
713
- for (const C of t.llmArtifacts) {
714
- const E = C.toArtifact();
715
- g || (M = M.slice(), g = !0);
716
- const w = M.findIndex((m) => m.id === E.id);
717
- w === -1 ? M.push(E) : M[w] = E;
713
+ for (const I of t.llmArtifacts) {
714
+ const v = I.toArtifact();
715
+ g || (S = S.slice(), g = !0);
716
+ const w = S.findIndex((m) => m.id === v.id);
717
+ w === -1 ? S.push(v) : S[w] = v;
718
718
  }
719
719
  }
720
- const U = {
720
+ const M = {
721
721
  ...e,
722
722
  version: e.version + 1,
723
723
  parts: o,
724
- artifactData: M,
724
+ artifactData: S,
725
725
  functionMap: u,
726
726
  turn_complete: t.turn_complete,
727
727
  partial: t.partial,
728
728
  asyncFinalResponse: t.asyncFinalResponse
729
729
  };
730
- return this.interaction = U, {
731
- updatedInteraction: U,
730
+ return this.interaction = M, {
731
+ updatedInteraction: M,
732
732
  updatedParts: s,
733
733
  newArtifacts: i,
734
- mainBranch: U,
734
+ mainBranch: M,
735
735
  analyticsBranch: null,
736
736
  analyticsBranchPartsChanged: null,
737
737
  mainBranchPartsChanged: s
738
738
  };
739
739
  }
740
740
  };
741
- f(z, "InteractionService");
742
- let b = z;
743
- const kt = 1200 * 1e3, D = class D {
741
+ f(j, "InteractionService");
742
+ let L = j;
743
+ const kt = 1200 * 1e3, N = class N {
744
744
  constructor(t, e, s, i, n, r, l, o, u, d = St.Interactive) {
745
745
  a(this, "base_production_url", pt() ?? "https://agent.tripapi.com.br");
746
746
  a(this, "base_url_local", "http://localagent:8000");
@@ -817,7 +817,7 @@ const kt = 1200 * 1e3, D = class D {
817
817
  a(this, "subAgentInteractionServices", /* @__PURE__ */ new Map());
818
818
  a(this, "lastThorttledTimeout", null);
819
819
  a(this, "lastPingStatus", !1);
820
- 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) => {
820
+ 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, C) => {
821
821
  this.sessionState = h;
822
822
  });
823
823
  }
@@ -902,7 +902,7 @@ const kt = 1200 * 1e3, D = class D {
902
902
  functionMap: /* @__PURE__ */ new Map(),
903
903
  interactionQuestion: t
904
904
  };
905
- return this.interactionsMap.set(n.interactionId, n), this.currentIS = new b(n, this.eventBusService), this.interactionsServiceMap.set(n.interactionId, this.currentIS), n;
905
+ return this.interactionsMap.set(n.interactionId, n), this.currentIS = new L(n, this.eventBusService), this.interactionsServiceMap.set(n.interactionId, this.currentIS), n;
906
906
  }
907
907
  getInteractions() {
908
908
  return Array.from(this.interactionsMap.values());
@@ -978,7 +978,7 @@ const kt = 1200 * 1e3, D = class D {
978
978
  version: 0,
979
979
  functionMap: /* @__PURE__ */ new Map(),
980
980
  interactionQuestion: s ?? t
981
- }, n = new b(i, this.eventBusService), this.subAgentInteractions.set(t, i), this.subAgentInteractionServices.set(t, n)), { interaction: i, service: n };
981
+ }, n = new L(i, this.eventBusService), this.subAgentInteractions.set(t, i), this.subAgentInteractionServices.set(t, n)), { interaction: i, service: n };
982
982
  }
983
983
  handleSubAgentEvent(t) {
984
984
  const e = t.subAgentId, { service: s } = this.getOrCreateSubAgentInteraction(e, t.interactionId, t.subAgentName);
@@ -1068,10 +1068,10 @@ const kt = 1200 * 1e3, D = class D {
1068
1068
  }
1069
1069
  localEmitMessage(t, e) {
1070
1070
  const s = (/* @__PURE__ */ new Date()).getTime(), i = s - this.lastCurrentMessageUpdate;
1071
- t.partial === !1 || i >= D.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(() => {
1071
+ 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(() => {
1072
1072
  var r, l;
1073
1073
  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);
1074
- }, D.CURRENT_MSG_THROTTLE_MS * 2));
1074
+ }, N.CURRENT_MSG_THROTTLE_MS * 2));
1075
1075
  }
1076
1076
  localOpen(t, e) {
1077
1077
  this.sessionState.setTurnOpen(!0), this.eventBusService.gatewayEmitTurnOpen(t ?? "");
@@ -1102,14 +1102,14 @@ const kt = 1200 * 1e3, D = class D {
1102
1102
  return Date.now() - this.lastPing.getTime() > kt ? await this.ping() ? (this.lastPing = /* @__PURE__ */ new Date(), this.lastPingStatus = !0, !0) : (this.lastPingStatus = !1, !1) : (this.lastPingStatus = !0, !0);
1103
1103
  }
1104
1104
  async sendMessage(t, e) {
1105
- let s = this.getInteractions().length, i = A.createWaiting(!0, !0, "Overall", /* @__PURE__ */ new Date());
1105
+ let s = this.getInteractions().length, i = P.createWaiting(!0, !0, "Overall", /* @__PURE__ */ new Date());
1106
1106
  this.sendStatusMessage(t.data, [i], s.toString() + "1");
1107
1107
  try {
1108
1108
  const { promptAsString: n, json: r } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(t.data) : { promptAsString: t.data, json: void 0 };
1109
1109
  this.sessionState.onRenderPrompt && (t.data = r, t.friendlyMessage = n);
1110
1110
  const l = await this.sendMessageInternal(t, e), o = Pt.createPrompt(n ?? "", (r == null ? void 0 : r.toString()) ?? {});
1111
1111
  this.storageService.storePrompt(o);
1112
- const u = A.fromText("Planejando próximos passos");
1112
+ const u = P.fromText("Planejando próximos passos");
1113
1113
  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;
1114
1114
  } catch (n) {
1115
1115
  return this.eventBusService.ChatEmitMessageError((n == null ? void 0 : n.toString()) ?? ""), {
@@ -1119,7 +1119,7 @@ const kt = 1200 * 1e3, D = class D {
1119
1119
  created: /* @__PURE__ */ new Date(),
1120
1120
  interactionId: "",
1121
1121
  partial: !1,
1122
- parts: [A.fromError((n == null ? void 0 : n.toString()) ?? "")],
1122
+ parts: [P.fromError((n == null ? void 0 : n.toString()) ?? "")],
1123
1123
  version: 0
1124
1124
  }
1125
1125
  };
@@ -1165,9 +1165,9 @@ const kt = 1200 * 1e3, D = class D {
1165
1165
  return `${this.msg_order}_${e}`;
1166
1166
  }
1167
1167
  };
1168
- f(D, "AgentGatewayService"), a(D, "SUSPENSION_MSG", "SUSPEND"), a(D, "CURRENT_MSG_THROTTLE_MS", 20);
1169
- let $ = D;
1170
- const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2, ot = 2, j = class j {
1168
+ f(N, "AgentGatewayService"), a(N, "SUSPENSION_MSG", "SUSPEND"), a(N, "CURRENT_MSG_THROTTLE_MS", 20);
1169
+ let W = N;
1170
+ const J = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2, ot = 2, Y = class Y {
1171
1171
  constructor(t = "ws://localhost:8000", e) {
1172
1172
  a(this, "ws", null);
1173
1173
  a(this, "stats");
@@ -1264,11 +1264,11 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1264
1264
  */
1265
1265
  connect(t) {
1266
1266
  return new Promise(async (e, s) => {
1267
- var p;
1267
+ var E;
1268
1268
  this.intentionalDisconnect = !1;
1269
1269
  const i = this._internalReconnect;
1270
1270
  i || (this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.lastSeq = -1), this._internalReconnect = !1;
1271
- const n = (p = this.getToken) == null ? void 0 : p.call(this), r = [];
1271
+ const n = (E = this.getToken) == null ? void 0 : E.call(this), r = [];
1272
1272
  n && r.push(`access_token=${encodeURIComponent(n)}`), t && this.lastSeq >= 0 && r.push(`lastSeq=${this.lastSeq}`);
1273
1273
  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})` : "");
1274
1274
  if (console.log("Connecting to ", d), this.ws) {
@@ -1288,28 +1288,29 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1288
1288
  }, this.ws.onmessage = (S) => {
1289
1289
  try {
1290
1290
  this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
1291
- const I = this.streamingResponseSerializer.parse(S.data);
1292
- if (!I)
1291
+ const M = this.streamingResponseSerializer.parse(S.data);
1292
+ if (!M)
1293
1293
  throw "Error parsing event JSON";
1294
- const M = this.handleMessage(I, S.data);
1295
- !h && (M != null && M.timestamp) && (h = !0, this.hasEverReceivedPacket = !0);
1296
- } catch (I) {
1297
- console.error("[WebSocket] Error parsing message:", I);
1294
+ const A = this.handleMessage(M, S.data);
1295
+ !h && (A != null && A.timestamp) && (h = !0, this.hasEverReceivedPacket = !0);
1296
+ } catch (M) {
1297
+ console.error("[WebSocket] Error parsing message:", M);
1298
1298
  }
1299
1299
  }, this.ws.onerror = (S) => {
1300
1300
  console.error("[WebSocket] Error:", S), this.onError && this.onError("WebSocket error");
1301
1301
  }, this.ws.onclose = (S) => {
1302
1302
  console.log("[WebSocket] Closed:", S.code, S.reason), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [];
1303
- const I = this.sessionId ?? this.lastKnownSessionId;
1303
+ const M = this.sessionId ?? this.lastKnownSessionId;
1304
1304
  if (this.sessionId = void 0, (h || this.hasEverReceivedPacket) && this.shouldAttemptReconnect(S.code)) {
1305
- this.scheduleReconnect(I, S.code, S.reason);
1305
+ this.scheduleReconnect(M, S.code, S.reason);
1306
1306
  return;
1307
1307
  }
1308
1308
  this.isReconnecting = !1, this.reconnectAttempts = 0, this.onClose && this.onClose(S.code, S.reason);
1309
1309
  };
1310
- let v = 0;
1311
- for (this.sessionId = void 0; !this.sessionId && v < 30; )
1312
- console.log("Aguardando session Id"), await this.sleep(400), v++;
1310
+ let C = 0;
1311
+ const p = 4 * 1e3, D = 400;
1312
+ for (this.sessionId = void 0; !this.sessionId && C * D < p; )
1313
+ console.log("Aguardando session Id"), await this.sleep(D), C++;
1313
1314
  this.sessionId ? (console.log("SUCCESS - GOT SESSION ID", this.sessionId), this.lastKnownSessionId = this.sessionId, e(this.sessionId)) : s("After 12 seconds no session id was generated");
1314
1315
  });
1315
1316
  }
@@ -1323,7 +1324,7 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1323
1324
  * - 4000-4099 reserved for app-level fatal codes from the server
1324
1325
  */
1325
1326
  shouldAttemptReconnect(t) {
1326
- return !(this.intentionalDisconnect || t === W || t === _t || t === 1e3 || t === 1008);
1327
+ return !(this.intentionalDisconnect || t === J || t === _t || t === 1e3 || t === 1008);
1327
1328
  }
1328
1329
  cancelPendingReconnect() {
1329
1330
  this.reconnectTimer && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
@@ -1388,13 +1389,13 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1388
1389
  this.emitFirstToken(d == null ? void 0 : d.iteractionId);
1389
1390
  const h = new yt();
1390
1391
  if (h.author = "main", h.streamingParts = t.partialEvent.streamingParts, t.partialEvent.partialEventType ? h.eventType = t.partialEvent.partialEventType : h.eventType = d.functionName ? {
1391
- fullName: F.StreamingFunctionCallUpdateContent,
1392
+ fullName: b.StreamingFunctionCallUpdateContent,
1392
1393
  type: y.PartialFunctionCall
1393
1394
  } : d.partialReasoning ? {
1394
- fullName: F.StreamingReasoningContent,
1395
+ fullName: b.StreamingReasoningContent,
1395
1396
  type: y.Thought
1396
1397
  } : {
1397
- fullName: F.StreamingTextContent,
1398
+ fullName: b.StreamingTextContent,
1398
1399
  type: y.Text
1399
1400
  }, h.interactionId = (d == null ? void 0 : d.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type == y.PartialFunctionCall) {
1400
1401
  var s = new It();
@@ -1405,7 +1406,7 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1405
1406
  }
1406
1407
  };
1407
1408
  } else if (h.eventType.type == y.Text)
1408
- if (h.eventType.fullName == F.StreamingTextContent) {
1409
+ if (h.eventType.fullName == b.StreamingTextContent) {
1409
1410
  var i = new Ct();
1410
1411
  i.text = d.partialText, h.content = {
1411
1412
  items: [i],
@@ -1484,7 +1485,7 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1484
1485
  }
1485
1486
  suspendStream() {
1486
1487
  this.sendBaseMessage({
1487
- Action: L.Suspend,
1488
+ Action: x.Suspend,
1488
1489
  AgentId: "",
1489
1490
  InteractionId: "",
1490
1491
  ModelId: ""
@@ -1493,7 +1494,7 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1493
1494
  /** Send the user's answer to a parked ask_user tool call (ChatAction.AnswerHumanTool). */
1494
1495
  answerHumanTool(t, e) {
1495
1496
  this.sendBaseMessage({
1496
- Action: L.AnswerHumanTool,
1497
+ Action: x.AnswerHumanTool,
1497
1498
  AgentId: "",
1498
1499
  InteractionId: "",
1499
1500
  ToolCallId: t,
@@ -1540,7 +1541,7 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1540
1541
  * Disconnect the WebSocket
1541
1542
  */
1542
1543
  disconnect() {
1543
- console.warn("Chamou DISCONNECT!!!"), this.intentionalDisconnect = !0, this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [], this.firstTokenInteractions.clear(), this.lastKnownSessionId = void 0, this.lastSeq = -1, this.hasEverReceivedPacket = !1, this.ws && (this.ws.close(W, "Intentional disconnect"), this.ws = null);
1544
+ console.warn("Chamou DISCONNECT!!!"), this.intentionalDisconnect = !0, this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [], this.firstTokenInteractions.clear(), this.lastKnownSessionId = void 0, this.lastSeq = -1, this.hasEverReceivedPacket = !1, this.ws && (this.ws.close(J, "Intentional disconnect"), this.ws = null);
1544
1545
  }
1545
1546
  /**
1546
1547
  * Check if connected
@@ -1582,11 +1583,11 @@ const W = 4001, _t = 4002, rt = 4, Ft = 3, Rt = 500, bt = 3e4, Ut = 2, Lt = 0.2,
1582
1583
  }
1583
1584
  }
1584
1585
  };
1585
- f(j, "WebSocketConnecionV2");
1586
- let ct = j;
1587
- const xt = "envision_agent_sessionId", Y = class Y extends $ {
1588
- constructor(e, s, i, n, r, l, o, u, d, h, v) {
1589
- super(e, s, i, n, r, l, o, d, v);
1586
+ f(Y, "WebSocketConnecionV2");
1587
+ let ct = Y;
1588
+ const xt = "envision_agent_sessionId", Q = class Q extends W {
1589
+ constructor(e, s, i, n, r, l, o, u, d, h, C) {
1590
+ super(e, s, i, n, r, l, o, d, C);
1590
1591
  a(this, "suspendState", !1);
1591
1592
  a(this, "wsService");
1592
1593
  a(this, "root_url", "");
@@ -1594,7 +1595,7 @@ const xt = "envision_agent_sessionId", Y = class Y extends $ {
1594
1595
  a(this, "connectionAttempts", 0);
1595
1596
  a(this, "statuses", ["CONNECTING", "OPEN", "CLOSED", "UNKNOWN"]);
1596
1597
  a(this, "lastConnectionPromise", null);
1597
- a(this, "socketState", P.Disconnected);
1598
+ a(this, "socketState", _.Disconnected);
1598
1599
  a(this, "streamOpened", !1);
1599
1600
  this.hearBeatPort = h, this.root_url = this.base_url, this.wsService = u, this.wsService.onEvent = async (p) => {
1600
1601
  await super.Message(p);
@@ -1603,23 +1604,23 @@ const xt = "envision_agent_sessionId", Y = class Y extends $ {
1603
1604
  }, this.wsService.onPong = (p) => {
1604
1605
  }, this.wsService.onError = (p) => {
1605
1606
  this.streamOpened = !1;
1606
- const S = {
1607
+ const D = {
1607
1608
  data: this.getErrorEvent(p),
1608
1609
  lastEventId: (/* @__PURE__ */ new Date()).getTime().toString(),
1609
1610
  origin: "gatewayService"
1610
1611
  };
1611
1612
  console.error("Stream error:", p), this.notificationPort.pushNotification({
1612
- message: "Stream error" + p,
1613
- type: "warning"
1614
- }), super.Message(S);
1613
+ message: "Reiniciando a conexão com o servidor",
1614
+ type: "info"
1615
+ }), super.Message(D);
1615
1616
  }, this.wsService.onOpen = () => {
1616
- this.sessionState.setConnectionStatus(P.Connected);
1617
+ this.sessionState.setConnectionStatus(_.Connected);
1617
1618
  }, this.wsService.onReconnected = (p) => {
1618
- this.sessionState.setConnectionStatus(P.Connected);
1619
+ this.sessionState.setConnectionStatus(_.Connected);
1619
1620
  }, this.wsService.onFirstToken = (p) => {
1620
1621
  this.localEmitFirstToken(p);
1621
- }, this.wsService.onClose = (p, S) => {
1622
- p != W && this.sessionState.setConnectionStatus(P.Disconnected);
1622
+ }, this.wsService.onClose = (p, D) => {
1623
+ p != J && this.sessionState.setConnectionStatus(_.Disconnected);
1623
1624
  };
1624
1625
  }
1625
1626
  reset(e, s) {
@@ -1686,7 +1687,7 @@ const xt = "envision_agent_sessionId", Y = class Y extends $ {
1686
1687
  return !0;
1687
1688
  }
1688
1689
  async openConnection(e) {
1689
- return this.lastConnectionPromise ? this.lastConnectionPromise : this.socketState == P.Disconnected ? (this.lastConnectionPromise = new Promise((s, i) => {
1690
+ return this.lastConnectionPromise ? this.lastConnectionPromise : this.socketState == _.Disconnected ? (this.lastConnectionPromise = new Promise((s, i) => {
1690
1691
  this.wsService.connect(e).then((n) => {
1691
1692
  this.sessionId = n, s(n);
1692
1693
  }).catch((n) => {
@@ -1718,11 +1719,11 @@ const xt = "envision_agent_sessionId", Y = class Y extends $ {
1718
1719
  }
1719
1720
  // Send a message to the server via HTTP POST
1720
1721
  async sendMessageInternal(e, s, i) {
1721
- var l, o, u, d, h, v, p, S;
1722
+ var l, o, u, d, h, C, p, D;
1722
1723
  const n = this.suspendState;
1723
1724
  this.suspendState = !1;
1724
1725
  const r = this.startInteraction(e.friendlyMessage ?? e.data, n);
1725
- if (this.registerInteractionCallId(r.interactionId, s), (l = e.userUi) != null && l.name && r.parts.push(A.fromUserUi(e.userUi.name, e.userUi.args)), !this.wsService)
1726
+ if (this.registerInteractionCallId(r.interactionId, s), (l = e.userUi) != null && l.name && r.parts.push(P.fromUserUi(e.userUi.name, e.userUi.args)), !this.wsService)
1726
1727
  throw "no wsService created";
1727
1728
  if (!this.sessionId)
1728
1729
  throw "no session id set";
@@ -1731,7 +1732,7 @@ const xt = "envision_agent_sessionId", Y = class Y extends $ {
1731
1732
  return this.wsService.sendMessage({
1732
1733
  Content: e.data,
1733
1734
  SessionId: this.sessionId,
1734
- Action: L.SendMessage,
1735
+ Action: x.SendMessage,
1735
1736
  ModelId: this.config.model,
1736
1737
  InteractionId: r.interactionId,
1737
1738
  AgentId: (u = this.config.agentConfig) == null ? void 0 : u.id,
@@ -1743,24 +1744,24 @@ const xt = "envision_agent_sessionId", Y = class Y extends $ {
1743
1744
  AgentImplementation: (d = this.config.agentConfig) == null ? void 0 : d.agentImplementation,
1744
1745
  Parameters: {
1745
1746
  CustomerName: ((h = this.config.customer) == null ? void 0 : h.name) ?? "",
1746
- DataSet: ((v = this.config.customer) == null ? void 0 : v.dataSetId) ?? ""
1747
+ DataSet: ((C = this.config.customer) == null ? void 0 : C.dataSetId) ?? ""
1747
1748
  },
1748
1749
  // Forward image attachments as a structured payload (PascalCase
1749
1750
  // keys to match the C# `Message.Images` / `MessageImage` model).
1750
- Images: (p = e.images) != null && p.length ? e.images.map((I) => ({ MimeType: I.mimeType, Data: I.data })) : void 0,
1751
+ Images: (p = e.images) != null && p.length ? e.images.map((E) => ({ MimeType: E.mimeType, Data: E.data })) : void 0,
1751
1752
  // Client-only UI representation for this turn (PascalCase to match the C# `Message.UserUi`
1752
1753
  // model). The server persists it as a UserUiContent sibling and strips it from the model
1753
1754
  // request; Content remains the only model-facing text.
1754
- UserUi: (S = e.userUi) != null && S.name ? { Name: e.userUi.name, Args: e.userUi.args } : void 0
1755
+ UserUi: (D = e.userUi) != null && D.name ? { Name: e.userUi.name, Args: e.userUi.args } : void 0
1755
1756
  }), this.localOpen(r.interactionId, "system"), Promise.resolve({
1756
1757
  interaction: r,
1757
1758
  success: !0
1758
1759
  });
1759
1760
  }
1760
1761
  };
1761
- f(Y, "AgentGatewayWSAsync");
1762
- let lt = Y;
1763
- const Q = class Q {
1762
+ f(Q, "AgentGatewayWSAsync");
1763
+ let lt = Q;
1764
+ const X = class X {
1764
1765
  constructor(t, e) {
1765
1766
  a(this, "cache", /* @__PURE__ */ new Map());
1766
1767
  a(this, "serverBaseUrl");
@@ -1815,17 +1816,17 @@ const Q = class Q {
1815
1816
  }
1816
1817
  }
1817
1818
  };
1818
- f(Q, "HttpArtifactService");
1819
- let ht = Q;
1819
+ f(X, "HttpArtifactService");
1820
+ let ht = X;
1820
1821
  export {
1821
- $ as A,
1822
- B as E,
1822
+ W as A,
1823
+ $ as E,
1823
1824
  ht as H,
1824
- b as I,
1825
+ L as I,
1825
1826
  it as L,
1826
1827
  at as M,
1827
1828
  ct as W,
1828
1829
  lt as a,
1829
1830
  jt as u
1830
1831
  };
1831
- //# sourceMappingURL=httpArtifactService-B668XBHO.js.map
1832
+ //# sourceMappingURL=httpArtifactService-COu1QCBJ.js.map