@aintela/chat 0.2.40 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.js +4404 -4353
- package/dist/components.js.map +1 -1
- package/dist/{httpArtifactService-BqcorW_s.js → httpArtifactService-DBKIvfSD.js} +193 -189
- package/dist/httpArtifactService-DBKIvfSD.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/services.js +1 -1
- package/dist/src/components/v2/RunProgressStripV2.d.ts +3 -1
- package/package.json +1 -1
- package/dist/httpArtifactService-BqcorW_s.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var a = (O, t, e) =>
|
|
5
|
-
import { d as L, t as
|
|
6
|
-
import { I as _, S as
|
|
7
|
-
import { unified as
|
|
8
|
-
import
|
|
9
|
-
import { toMarkdown as
|
|
10
|
-
import { format as
|
|
11
|
-
import
|
|
12
|
-
import { P as
|
|
13
|
-
import { r as
|
|
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 Tt, j as yt, 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 Nt from "remark-parse";
|
|
9
|
+
import { toMarkdown as kt } 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__ */
|
|
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
|
-
|
|
201
|
-
let
|
|
202
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
516
|
-
let
|
|
517
|
-
const
|
|
515
|
+
g(j, "MockEventBusService");
|
|
516
|
+
let ct = j;
|
|
517
|
+
const Rt = 2e3, pt = {
|
|
518
518
|
inline: "inline",
|
|
519
519
|
block: "block"
|
|
520
|
-
},
|
|
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",
|
|
526
|
+
a(this, "type", pt.inline);
|
|
527
527
|
}
|
|
528
528
|
};
|
|
529
|
-
|
|
530
|
-
let W =
|
|
531
|
-
const
|
|
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__ */
|
|
535
|
+
a(this, "parseTextIntoParts", /* @__PURE__ */ g((t) => {
|
|
536
536
|
if (!t || t.trim().length == 0) return [];
|
|
537
|
-
const e =
|
|
537
|
+
const e = At().use(Nt).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 +=
|
|
544
|
+
`)) : (i || (i = ""), i += kt(n));
|
|
545
545
|
return i && s.push(i), s;
|
|
546
546
|
}, "parseTextIntoParts"));
|
|
547
547
|
this.interaction = t, this.eventBusService = e;
|
|
@@ -561,9 +561,9 @@ ${n.value}
|
|
|
561
561
|
let n = new W();
|
|
562
562
|
for (let o = 0; o < t.length; o++) {
|
|
563
563
|
const u = t[o];
|
|
564
|
-
let h = !(((l = u.functionDetails) == null ? void 0 : l.isUi) ?? !1) && u.eventType !==
|
|
565
|
-
!e && h && !s || (h ? (u.eventType ==
|
|
566
|
-
type:
|
|
564
|
+
let h = !(((l = u.functionDetails) == null ? void 0 : l.isUi) ?? !1) && u.eventType !== C.Text && u.eventType !== C.Thought && (u.eventType === C.FunctionCall || u.eventType === C.PartialFunctionCall || u.eventType === C.FunctionResponse) && o < t.length - 1;
|
|
565
|
+
!e && h && !s || (h ? (u.eventType == C.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: pt.block,
|
|
567
567
|
parts: [u],
|
|
568
568
|
isLastGroup: o === t.length - 1,
|
|
569
569
|
hasThoughts: !1,
|
|
@@ -575,10 +575,10 @@ ${n.value}
|
|
|
575
575
|
return r.length > 0 && (r[r.length - 1].lastWithThoughts = !0), i;
|
|
576
576
|
}
|
|
577
577
|
isFunctionCall(t) {
|
|
578
|
-
return t ==
|
|
578
|
+
return t == C.FunctionCall || t == C.PartialFunctionCall;
|
|
579
579
|
}
|
|
580
580
|
isFunctionResponse(t) {
|
|
581
|
-
return t ==
|
|
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,53 +586,57 @@ ${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,
|
|
589
|
+
var b, y, A, N, 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
|
-
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) !== ((
|
|
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) !== ((y = r.functionDetails) == null ? void 0 : y.id)));
|
|
593
593
|
let o = e.parts, u = e.functionMap ?? /* @__PURE__ */ new Map(), d = !e.functionMap;
|
|
594
|
-
const h = /* @__PURE__ */
|
|
594
|
+
const h = /* @__PURE__ */ g(() => {
|
|
595
595
|
d || (u = new Map(u), d = !0);
|
|
596
|
-
}, "cloneFunctionMap"), v = /* @__PURE__ */
|
|
596
|
+
}, "cloneFunctionMap"), v = /* @__PURE__ */ g(() => {
|
|
597
597
|
o === e.parts && (o = e.parts.slice());
|
|
598
598
|
}, "clonePartsIfShared");
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
599
|
+
if (!l && (o == null ? void 0 : o.length) > 0 && (n != null && n.textAppendable)) {
|
|
600
|
+
const f = o[o.length - 1];
|
|
601
|
+
(((N = (A = f.thoughtDetails) == null ? void 0 : A.text) == null ? void 0 : N.length) ?? ((et = f.text) == null ? void 0 : et.length) ?? 0) > Rt && (l = !0);
|
|
602
|
+
}
|
|
603
|
+
let m = !1;
|
|
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) => {
|
|
606
|
+
var p;
|
|
607
|
+
return ((p = S.functionDetails) == null ? void 0 : p.id) === f;
|
|
604
608
|
});
|
|
605
609
|
if (E > -1) {
|
|
606
|
-
const S = o[E],
|
|
610
|
+
const S = o[E], p = {
|
|
607
611
|
...S,
|
|
608
612
|
functionDetails: {
|
|
609
613
|
...S.functionDetails,
|
|
610
|
-
clientOutput:
|
|
614
|
+
clientOutput: I ?? S.functionDetails.clientOutput
|
|
611
615
|
}
|
|
612
616
|
};
|
|
613
|
-
v(), o[E] =
|
|
617
|
+
v(), o[E] = p, h(), u.set(f, p), s.push(p);
|
|
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(
|
|
624
|
+
v(), o = o === e.parts ? e.parts.slice() : o, o.push(S), h(), u.set(f, S);
|
|
621
625
|
}
|
|
622
626
|
} else if (l && n) {
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
const E =
|
|
626
|
-
if (E &&
|
|
627
|
-
const S = o.findIndex((
|
|
628
|
-
var
|
|
629
|
-
return ((
|
|
630
|
-
}),
|
|
631
|
-
...
|
|
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 ? u.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;
|
|
634
|
+
}), p = S > -1 ? o[S] : E, F = {
|
|
635
|
+
...p,
|
|
632
636
|
eventType: n.eventType,
|
|
633
637
|
functionDetails: {
|
|
634
|
-
id:
|
|
635
|
-
name: n.functionDetails.name ??
|
|
638
|
+
id: p.functionDetails.id,
|
|
639
|
+
name: n.functionDetails.name ?? p.functionDetails.name,
|
|
636
640
|
// Take the parsed args from the incoming event when
|
|
637
641
|
// present (the full FunctionCall carries them), fall
|
|
638
642
|
// back to what was already on the part. Previously
|
|
@@ -641,41 +645,41 @@ ${n.value}
|
|
|
641
645
|
// args off every full FunctionCall fold because the
|
|
642
646
|
// PartialFunctionCall stream only accumulates raw
|
|
643
647
|
// JSON in `.text` — `.args` stayed undefined.
|
|
644
|
-
args: n.functionDetails.args ??
|
|
648
|
+
args: n.functionDetails.args ?? p.functionDetails.args,
|
|
645
649
|
response: n.functionDetails.response,
|
|
646
650
|
status: n.functionDetails.status ?? "Composing",
|
|
647
|
-
start: n.functionDetails.start ??
|
|
648
|
-
end: n.functionDetails.end ??
|
|
651
|
+
start: n.functionDetails.start ?? p.functionDetails.start,
|
|
652
|
+
end: n.functionDetails.end ?? p.functionDetails.end,
|
|
649
653
|
// true-wins: a UI call has multiple reps (streaming part with isUi, the
|
|
650
654
|
// persisted FunctionCall, the result) and they interleave. `??` let a later
|
|
651
655
|
// `false`/`undefined` rep clobber an earlier `true`; OR-ing keeps it sticky.
|
|
652
|
-
isUi: n.functionDetails.isUi === !0 ||
|
|
656
|
+
isUi: n.functionDetails.isUi === !0 || p.functionDetails.isUi === !0,
|
|
653
657
|
// Keep the call's friendly args summary when the result event (which has none) folds in.
|
|
654
|
-
argsDescription: n.functionDetails.argsDescription ??
|
|
658
|
+
argsDescription: n.functionDetails.argsDescription ?? p.functionDetails.argsDescription,
|
|
655
659
|
// The tool's client-only payload rides the RESULT event; keep it sticky so a
|
|
656
660
|
// later rep without one can't clobber it. This is what a uiTool renderer reads.
|
|
657
|
-
clientOutput: n.functionDetails.clientOutput ??
|
|
661
|
+
clientOutput: n.functionDetails.clientOutput ?? p.functionDetails.clientOutput,
|
|
658
662
|
// Ask-user component ([KernelUIComponent]) — sticky like isUi/clientOutput. The
|
|
659
663
|
// streaming final CALL carries it, but the PartialFunctionCall it folds onto (and a
|
|
660
664
|
// later result rep) may not; dropping it strips the part's askUser classification so
|
|
661
665
|
// the docked drawer never surfaces (issue #60 — esp. a no-arg tool like update_profile,
|
|
662
666
|
// which has no name match to fall back on the way ask_user/askauth do).
|
|
663
|
-
askUserComponent: n.functionDetails.askUserComponent ??
|
|
664
|
-
isAskUser: n.functionDetails.isAskUser ||
|
|
667
|
+
askUserComponent: n.functionDetails.askUserComponent ?? p.functionDetails.askUserComponent,
|
|
668
|
+
isAskUser: n.functionDetails.isAskUser || p.functionDetails.isAskUser || !!(n.functionDetails.askUserComponent ?? p.functionDetails.askUserComponent),
|
|
665
669
|
// Runtime "don't render" override rides the RESULT; true-wins sticky like isUi so it
|
|
666
670
|
// survives folding onto the earlier call rep and suppresses drawer/uiTool classification.
|
|
667
|
-
cancelUi: n.functionDetails.cancelUi === !0 ||
|
|
671
|
+
cancelUi: n.functionDetails.cancelUi === !0 || p.functionDetails.cancelUi === !0
|
|
668
672
|
}
|
|
669
673
|
};
|
|
670
|
-
h(), u.set(
|
|
674
|
+
h(), u.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 (
|
|
673
|
-
const
|
|
676
|
+
if (I && n.functionDetails && !E && (h(), u.set(I, n)), r && r.textAppendable) {
|
|
677
|
+
const p = {
|
|
674
678
|
...r,
|
|
675
679
|
ended: /* @__PURE__ */ new Date(),
|
|
676
680
|
isStillWriting: !1
|
|
677
681
|
};
|
|
678
|
-
v(), o[o.length - 1] =
|
|
682
|
+
v(), o[o.length - 1] = p, s.push(p);
|
|
679
683
|
}
|
|
680
684
|
const S = {
|
|
681
685
|
...n,
|
|
@@ -683,41 +687,41 @@ ${n.value}
|
|
|
683
687
|
isStillWriting: n.textAppendable,
|
|
684
688
|
partial: t.partial
|
|
685
689
|
};
|
|
686
|
-
(
|
|
690
|
+
(it = S.functionDetails) != null && it.silent || s.push(S), o = [...o, S], m = !0;
|
|
687
691
|
}
|
|
688
692
|
}
|
|
689
|
-
let
|
|
690
|
-
if (
|
|
691
|
-
const
|
|
692
|
-
...
|
|
693
|
+
let T = o[o.length - 1] ?? null;
|
|
694
|
+
if (T && n && n.textAppendable) {
|
|
695
|
+
const f = {
|
|
696
|
+
...T,
|
|
693
697
|
partial: t.partial,
|
|
694
|
-
textDetails:
|
|
698
|
+
textDetails: T.textDetails ? { ...T.textDetails } : { version: 0 }
|
|
695
699
|
};
|
|
696
|
-
let
|
|
700
|
+
let I = !1;
|
|
697
701
|
if (t.partial) {
|
|
698
702
|
try {
|
|
699
|
-
|
|
703
|
+
f.textDetails.version++, m || (f.text = (T.text ?? "") + (n.text ?? ""));
|
|
700
704
|
} catch (E) {
|
|
701
705
|
console.error("Error here", E.toString());
|
|
702
706
|
}
|
|
703
|
-
|
|
704
|
-
...
|
|
705
|
-
text:
|
|
706
|
-
},
|
|
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
|
-
|
|
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
|
-
}),
|
|
712
|
-
v(), o[o.length - 1] =
|
|
715
|
+
}), I = !l;
|
|
716
|
+
v(), o[o.length - 1] = f, T = f, I && s.push(f);
|
|
713
717
|
}
|
|
714
718
|
let M = e.artifactData ?? [];
|
|
715
719
|
if (t.llmArtifacts && t.llmArtifacts.length > 0) {
|
|
716
|
-
let
|
|
717
|
-
for (const
|
|
718
|
-
const E =
|
|
719
|
-
|
|
720
|
-
const S = M.findIndex((
|
|
720
|
+
let f = !1;
|
|
721
|
+
for (const I of t.llmArtifacts) {
|
|
722
|
+
const E = I.toArtifact();
|
|
723
|
+
f || (M = M.slice(), f = !0);
|
|
724
|
+
const S = M.findIndex((p) => p.id === E.id);
|
|
721
725
|
S === -1 ? M.push(E) : M[S] = E;
|
|
722
726
|
}
|
|
723
727
|
}
|
|
@@ -742,11 +746,11 @@ ${n.value}
|
|
|
742
746
|
};
|
|
743
747
|
}
|
|
744
748
|
};
|
|
745
|
-
|
|
746
|
-
let $ =
|
|
747
|
-
const
|
|
748
|
-
constructor(t, e, s, i, n, r, l, o, u, d =
|
|
749
|
-
a(this, "base_production_url",
|
|
749
|
+
g(Q, "InteractionService");
|
|
750
|
+
let $ = Q;
|
|
751
|
+
const Ut = 1200 * 1e3, k = class k {
|
|
752
|
+
constructor(t, e, s, i, n, r, l, o, u, d = yt.Interactive) {
|
|
753
|
+
a(this, "base_production_url", Tt() ?? "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__ */
|
|
777
|
+
a(this, "onTurnOpen", /* @__PURE__ */ g((t) => {
|
|
774
778
|
this.eventBusService.gatewayOnTurnOpen(t);
|
|
775
779
|
}, "onTurnOpen"));
|
|
776
|
-
a(this, "offTurnOpen", /* @__PURE__ */
|
|
780
|
+
a(this, "offTurnOpen", /* @__PURE__ */ g((t) => {
|
|
777
781
|
this.eventBusService.gatewayOffTurnOpen(t);
|
|
778
782
|
}, "offTurnOpen"));
|
|
779
|
-
a(this, "onTurnComplete", /* @__PURE__ */
|
|
783
|
+
a(this, "onTurnComplete", /* @__PURE__ */ g((t) => {
|
|
780
784
|
this.eventBusService.gatewayOnTurnComplete(t);
|
|
781
785
|
}, "onTurnComplete"));
|
|
782
|
-
a(this, "offTurnComplete", /* @__PURE__ */
|
|
786
|
+
a(this, "offTurnComplete", /* @__PURE__ */ g((t) => {
|
|
783
787
|
this.eventBusService.gatewayOffTurnComplete(t);
|
|
784
788
|
}, "offTurnComplete"));
|
|
785
|
-
a(this, "onStreamError", /* @__PURE__ */
|
|
789
|
+
a(this, "onStreamError", /* @__PURE__ */ g((t) => {
|
|
786
790
|
this.eventBusService.gatewayOnStreamError(t);
|
|
787
791
|
}, "onStreamError"));
|
|
788
|
-
a(this, "offStreamError", /* @__PURE__ */
|
|
792
|
+
a(this, "offStreamError", /* @__PURE__ */ g((t) => {
|
|
789
793
|
this.eventBusService.gatewayOffStreamError(t);
|
|
790
794
|
}, "offStreamError"));
|
|
791
|
-
a(this, "onStreamEnded", /* @__PURE__ */
|
|
795
|
+
a(this, "onStreamEnded", /* @__PURE__ */ g((t) => {
|
|
792
796
|
this.eventBusService.gatewayOnStreamEnded(t);
|
|
793
797
|
}, "onStreamEnded"));
|
|
794
|
-
a(this, "offStreamEnded", /* @__PURE__ */
|
|
798
|
+
a(this, "offStreamEnded", /* @__PURE__ */ g((t) => {
|
|
795
799
|
this.eventBusService.gatewayOffStreamEnded(t);
|
|
796
800
|
}, "offStreamEnded"));
|
|
797
|
-
a(this, "onMessage", /* @__PURE__ */
|
|
801
|
+
a(this, "onMessage", /* @__PURE__ */ g((t) => {
|
|
798
802
|
this.eventBusService.gatewayOnMessage(t);
|
|
799
803
|
}, "onMessage"));
|
|
800
|
-
a(this, "offMessage", /* @__PURE__ */
|
|
804
|
+
a(this, "offMessage", /* @__PURE__ */ g((t) => {
|
|
801
805
|
this.eventBusService.gatewayOffMessage(t);
|
|
802
806
|
}, "offMessage"));
|
|
803
|
-
a(this, "onFirstToken", /* @__PURE__ */
|
|
807
|
+
a(this, "onFirstToken", /* @__PURE__ */ g((t) => {
|
|
804
808
|
this.eventBusService.gatewayOnFirstToken(t);
|
|
805
809
|
}, "onFirstToken"));
|
|
806
|
-
a(this, "offFirstToken", /* @__PURE__ */
|
|
810
|
+
a(this, "offFirstToken", /* @__PURE__ */ g((t) => {
|
|
807
811
|
this.eventBusService.gatewayOffFirstToken(t);
|
|
808
812
|
}, "offFirstToken"));
|
|
809
|
-
a(this, "onFunctionResponse", /* @__PURE__ */
|
|
813
|
+
a(this, "onFunctionResponse", /* @__PURE__ */ g((t) => {
|
|
810
814
|
this.eventBusService.gatewayOnFunctionResponse(t);
|
|
811
815
|
}, "onFunctionResponse"));
|
|
812
|
-
a(this, "offFunctionResponse", /* @__PURE__ */
|
|
816
|
+
a(this, "offFunctionResponse", /* @__PURE__ */ g((t) => {
|
|
813
817
|
this.eventBusService.gatewayOffFunctionResponse(t);
|
|
814
818
|
}, "offFunctionResponse"));
|
|
815
819
|
a(this, "toolSessionId", null);
|
|
@@ -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 =
|
|
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;
|
|
@@ -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() >
|
|
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,7 +1116,7 @@ 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 =
|
|
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
1121
|
const u = _.fromText("Planejando próximos passos");
|
|
1118
1122
|
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;
|
|
@@ -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 =
|
|
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 =
|
|
1173
|
+
const e = Pt(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
|
|
1170
1174
|
return `${this.msg_order}_${e}`;
|
|
1171
1175
|
}
|
|
1172
1176
|
};
|
|
1173
|
-
|
|
1177
|
+
g(k, "AgentGatewayService"), a(k, "SUSPENSION_MSG", "SUSPEND"), a(k, "CURRENT_MSG_THROTTLE_MS", 20);
|
|
1174
1178
|
let G = k;
|
|
1175
|
-
const H = 4001,
|
|
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 =
|
|
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: [],
|
|
@@ -1297,55 +1301,55 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
|
|
|
1297
1301
|
let h = !1;
|
|
1298
1302
|
this.ws.onopen = () => {
|
|
1299
1303
|
console.log("[WebSocket] Connected");
|
|
1300
|
-
const
|
|
1301
|
-
this.isReconnecting = !1, this.reconnectAttempts = 0, this.pingPongStack.push((/* @__PURE__ */ new Date()).getTime()), this.ping(), this.monitor(), this.onOpen && this.onOpen(),
|
|
1302
|
-
}, this.ws.onmessage = (
|
|
1304
|
+
const y = this.isReconnecting;
|
|
1305
|
+
this.isReconnecting = !1, this.reconnectAttempts = 0, this.pingPongStack.push((/* @__PURE__ */ new Date()).getTime()), this.ping(), this.monitor(), this.onOpen && this.onOpen(), y && this.onReconnected && this.onReconnected(t ?? this.lastKnownSessionId ?? ""), this.flushPendingAnswers(t ?? this.lastKnownSessionId);
|
|
1306
|
+
}, this.ws.onmessage = (y) => {
|
|
1303
1307
|
try {
|
|
1304
1308
|
this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
|
|
1305
|
-
const A = this.streamingResponseSerializer.parse(
|
|
1309
|
+
const A = this.streamingResponseSerializer.parse(y.data);
|
|
1306
1310
|
if (!A)
|
|
1307
1311
|
throw "Error parsing event JSON";
|
|
1308
|
-
const N = this.handleMessage(A,
|
|
1312
|
+
const N = this.handleMessage(A, y.data);
|
|
1309
1313
|
!h && (N != null && N.timestamp) && (h = !0, this.hasEverReceivedPacket = !0);
|
|
1310
1314
|
} catch (A) {
|
|
1311
1315
|
console.error("[WebSocket] Error parsing message:", A);
|
|
1312
1316
|
}
|
|
1313
|
-
}, this.ws.onerror = (
|
|
1314
|
-
console.error("[WebSocket] Error:",
|
|
1315
|
-
}, this.ws.onclose = (
|
|
1316
|
-
console.log("[WebSocket] Closed:",
|
|
1317
|
+
}, this.ws.onerror = (y) => {
|
|
1318
|
+
console.error("[WebSocket] Error:", y), this.onError && this.onError("WebSocket error");
|
|
1319
|
+
}, this.ws.onclose = (y) => {
|
|
1320
|
+
console.log("[WebSocket] Closed:", y.code, y.reason), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [];
|
|
1317
1321
|
const A = this.sessionId ?? this.lastKnownSessionId;
|
|
1318
|
-
if (this.sessionId = void 0, (h || this.hasEverReceivedPacket) && this.shouldAttemptReconnect(
|
|
1319
|
-
this.scheduleReconnect(A,
|
|
1322
|
+
if (this.sessionId = void 0, (h || this.hasEverReceivedPacket) && this.shouldAttemptReconnect(y.code)) {
|
|
1323
|
+
this.scheduleReconnect(A, y.code, y.reason);
|
|
1320
1324
|
return;
|
|
1321
1325
|
}
|
|
1322
|
-
this.isReconnecting = !1, this.reconnectAttempts = 0, this.onClose && this.onClose(
|
|
1326
|
+
this.isReconnecting = !1, this.reconnectAttempts = 0, this.onClose && this.onClose(y.code, y.reason);
|
|
1323
1327
|
};
|
|
1324
|
-
const v = 200,
|
|
1328
|
+
const v = 200, m = 3e4, D = 8e3, T = this.ws;
|
|
1325
1329
|
this.sessionId = void 0;
|
|
1326
1330
|
let M = 0, P = 0;
|
|
1327
1331
|
for (; !this.sessionId; ) {
|
|
1328
|
-
if (this.ws !==
|
|
1332
|
+
if (this.ws !== T) {
|
|
1329
1333
|
s("Connection attempt superseded by a newer connect()");
|
|
1330
1334
|
return;
|
|
1331
1335
|
}
|
|
1332
|
-
if (
|
|
1336
|
+
if (T.readyState === WebSocket.CLOSING || T.readyState === WebSocket.CLOSED) {
|
|
1333
1337
|
s("Connection closed before a session id was received");
|
|
1334
1338
|
return;
|
|
1335
1339
|
}
|
|
1336
|
-
if (
|
|
1340
|
+
if (T.readyState === WebSocket.CONNECTING && M >= m) {
|
|
1337
1341
|
try {
|
|
1338
|
-
|
|
1342
|
+
T.close();
|
|
1339
1343
|
} catch {
|
|
1340
1344
|
}
|
|
1341
|
-
s(`Server did not accept the connection within ${
|
|
1345
|
+
s(`Server did not accept the connection within ${m / 1e3}s`);
|
|
1342
1346
|
return;
|
|
1343
1347
|
}
|
|
1344
|
-
if (
|
|
1348
|
+
if (T.readyState === WebSocket.OPEN && P >= D) {
|
|
1345
1349
|
s(`Connected but no session id arrived within ${D / 1e3}s`);
|
|
1346
1350
|
return;
|
|
1347
1351
|
}
|
|
1348
|
-
M % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(v), M += v,
|
|
1352
|
+
M % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(v), M += v, T.readyState === WebSocket.OPEN && (P += v);
|
|
1349
1353
|
}
|
|
1350
1354
|
console.log("SUCCESS - GOT SESSION ID", this.sessionId), this.lastKnownSessionId = this.sessionId, e(this.sessionId);
|
|
1351
1355
|
});
|
|
@@ -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 ===
|
|
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 =
|
|
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 >=
|
|
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}/${
|
|
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 {
|
|
@@ -1423,27 +1427,27 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
|
|
|
1423
1427
|
if (t.partialEvent) {
|
|
1424
1428
|
const d = t.partialEvent;
|
|
1425
1429
|
this.emitFirstToken(d == null ? void 0 : d.iteractionId);
|
|
1426
|
-
const h = new
|
|
1430
|
+
const h = new vt();
|
|
1427
1431
|
if (h.author = "main", h.streamingParts = t.partialEvent.streamingParts, t.partialEvent.partialEventType ? h.eventType = t.partialEvent.partialEventType : h.eventType = d.functionName ? {
|
|
1428
1432
|
fullName: x.StreamingFunctionCallUpdateContent,
|
|
1429
|
-
type:
|
|
1433
|
+
type: C.PartialFunctionCall
|
|
1430
1434
|
} : d.partialReasoning ? {
|
|
1431
1435
|
fullName: x.StreamingReasoningContent,
|
|
1432
|
-
type:
|
|
1436
|
+
type: C.Thought
|
|
1433
1437
|
} : {
|
|
1434
1438
|
fullName: x.StreamingTextContent,
|
|
1435
|
-
type:
|
|
1436
|
-
}, h.interactionId = (d == null ? void 0 : d.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type ==
|
|
1437
|
-
var s = new
|
|
1439
|
+
type: C.Text
|
|
1440
|
+
}, h.interactionId = (d == null ? void 0 : d.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type == C.PartialFunctionCall) {
|
|
1441
|
+
var s = new Et();
|
|
1438
1442
|
s.choiceIndex = 0, s.callId = d.functionCallId, s.arguments = d.partialText, s.name = d.functionName, h.content = {
|
|
1439
1443
|
items: [s],
|
|
1440
1444
|
role: {
|
|
1441
1445
|
label: "Assistant"
|
|
1442
1446
|
}
|
|
1443
1447
|
};
|
|
1444
|
-
} else if (h.eventType.type ==
|
|
1448
|
+
} else if (h.eventType.type == C.Text)
|
|
1445
1449
|
if (h.eventType.fullName == x.StreamingTextContent) {
|
|
1446
|
-
var i = new
|
|
1450
|
+
var i = new Mt();
|
|
1447
1451
|
i.text = d.partialText, h.content = {
|
|
1448
1452
|
items: [i],
|
|
1449
1453
|
role: {
|
|
@@ -1451,7 +1455,7 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
|
|
|
1451
1455
|
}
|
|
1452
1456
|
};
|
|
1453
1457
|
} else {
|
|
1454
|
-
var n = new
|
|
1458
|
+
var n = new Ot();
|
|
1455
1459
|
n.text = d.partialText, h.content = {
|
|
1456
1460
|
items: [n],
|
|
1457
1461
|
role: {
|
|
@@ -1459,8 +1463,8 @@ const H = 4001, bt = 4002, rt = 4, Ft = 3, Rt = 500, Ut = 3e4, Lt = 2, xt = 0.2,
|
|
|
1459
1463
|
}
|
|
1460
1464
|
};
|
|
1461
1465
|
}
|
|
1462
|
-
else if (h.eventType.type ==
|
|
1463
|
-
var r = new
|
|
1466
|
+
else if (h.eventType.type == C.Thought) {
|
|
1467
|
+
var r = new Dt();
|
|
1464
1468
|
r.text = d.partialReasoning, h.content = {
|
|
1465
1469
|
items: [r],
|
|
1466
1470
|
role: {
|
|
@@ -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 =
|
|
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() -
|
|
1655
|
-
this.stats.tokensPerSecond = l /
|
|
1658
|
+
const n = Date.now() - lt * 1e3, l = this.events.filter((o) => o[0] > n).reduce((o, u) => o += u[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,9 +1664,9 @@ 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
|
-
|
|
1664
|
-
let
|
|
1665
|
-
const
|
|
1667
|
+
g(Z, "WebSocketConnecionV2");
|
|
1668
|
+
let ut = Z;
|
|
1669
|
+
const Jt = "envision_agent_sessionId", V = class V extends G {
|
|
1666
1670
|
constructor(e, s, i, n, r, l, o, u, d, h, v) {
|
|
1667
1671
|
super(e, s, i, n, r, l, o, d, v);
|
|
1668
1672
|
a(this, "suspendState", !1);
|
|
@@ -1681,30 +1685,30 @@ 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 (
|
|
1685
|
-
await super.Message(
|
|
1686
|
-
}, this.wsService.onNewPacket = (
|
|
1687
|
-
this.sessionState.setStatistics(
|
|
1688
|
-
}, this.wsService.onPong = (
|
|
1689
|
-
}, this.wsService.onError = (
|
|
1688
|
+
this.hearBeatPort = h, this.root_url = this.base_url, this.wsService = u, this.wsService.onEvent = async (m) => {
|
|
1689
|
+
await super.Message(m);
|
|
1690
|
+
}, this.wsService.onNewPacket = (m) => {
|
|
1691
|
+
this.sessionState.setStatistics(m), this.eventBusService.streamEmitNewChunk(m);
|
|
1692
|
+
}, this.wsService.onPong = (m) => {
|
|
1693
|
+
}, this.wsService.onError = (m) => {
|
|
1690
1694
|
this.streamOpened = !1;
|
|
1691
1695
|
const D = {
|
|
1692
|
-
data: this.getErrorEvent(
|
|
1696
|
+
data: this.getErrorEvent(m),
|
|
1693
1697
|
lastEventId: (/* @__PURE__ */ new Date()).getTime().toString(),
|
|
1694
1698
|
origin: "gatewayService"
|
|
1695
1699
|
};
|
|
1696
|
-
console.error("Stream error:",
|
|
1700
|
+
console.error("Stream error:", m), this.everConnected && this.notificationPort.pushNotification({
|
|
1697
1701
|
message: "Reiniciando a conexão com o servidor",
|
|
1698
1702
|
type: "info"
|
|
1699
1703
|
}), super.Message(D);
|
|
1700
1704
|
}, this.wsService.onOpen = () => {
|
|
1701
1705
|
this.everConnected = !0, this.sessionState.setConnectionStatus(R.Connected);
|
|
1702
|
-
}, this.wsService.onReconnected = (
|
|
1706
|
+
}, this.wsService.onReconnected = (m) => {
|
|
1703
1707
|
this.sessionState.setConnectionStatus(R.Connected);
|
|
1704
|
-
}, this.wsService.onFirstToken = (
|
|
1705
|
-
this.localEmitFirstToken(
|
|
1706
|
-
}, this.wsService.onClose = (
|
|
1707
|
-
|
|
1708
|
+
}, this.wsService.onFirstToken = (m) => {
|
|
1709
|
+
this.localEmitFirstToken(m);
|
|
1710
|
+
}, this.wsService.onClose = (m, D) => {
|
|
1711
|
+
m != H && this.sessionState.setConnectionStatus(R.Disconnected);
|
|
1708
1712
|
};
|
|
1709
1713
|
}
|
|
1710
1714
|
reset(e, s) {
|
|
@@ -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(
|
|
1724
|
+
const e = localStorage.getItem(Jt);
|
|
1721
1725
|
if (e)
|
|
1722
1726
|
return e;
|
|
1723
1727
|
}
|
|
@@ -1804,7 +1808,7 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1804
1808
|
}
|
|
1805
1809
|
// Send a message to the server via HTTP POST
|
|
1806
1810
|
async sendMessageInternal(e, s, i) {
|
|
1807
|
-
var l, o, u, d, h, v,
|
|
1811
|
+
var l, o, u, d, h, v, m, D;
|
|
1808
1812
|
const n = this.suspendState;
|
|
1809
1813
|
this.suspendState = !1;
|
|
1810
1814
|
const r = this.startInteraction(e.friendlyMessage ?? e.data, n);
|
|
@@ -1833,7 +1837,7 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1833
1837
|
},
|
|
1834
1838
|
// Forward image attachments as a structured payload (PascalCase
|
|
1835
1839
|
// keys to match the C# `Message.Images` / `MessageImage` model).
|
|
1836
|
-
Images: (
|
|
1840
|
+
Images: (m = e.images) != null && m.length ? e.images.map((T) => ({ MimeType: T.mimeType, Data: T.data })) : void 0,
|
|
1837
1841
|
// Client-only UI representation for this turn (PascalCase to match the C# `Message.UserUi`
|
|
1838
1842
|
// model). The server persists it as a UserUiContent sibling and strips it from the model
|
|
1839
1843
|
// request; Content remains the only model-facing text.
|
|
@@ -1844,8 +1848,8 @@ const Bt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1844
1848
|
});
|
|
1845
1849
|
}
|
|
1846
1850
|
};
|
|
1847
|
-
|
|
1848
|
-
let
|
|
1851
|
+
g(V, "AgentGatewayWSAsync");
|
|
1852
|
+
let dt = V;
|
|
1849
1853
|
const tt = class tt {
|
|
1850
1854
|
constructor(t, e) {
|
|
1851
1855
|
a(this, "cache", /* @__PURE__ */ new Map());
|
|
@@ -1854,7 +1858,7 @@ const tt = class tt {
|
|
|
1854
1858
|
this.serverBaseUrl = t.replace(/\/$/, ""), this.accessToken = e;
|
|
1855
1859
|
}
|
|
1856
1860
|
get headers() {
|
|
1857
|
-
return { Authorization: `Bearer ${
|
|
1861
|
+
return { Authorization: `Bearer ${Ft(this.accessToken)}` };
|
|
1858
1862
|
}
|
|
1859
1863
|
async init() {
|
|
1860
1864
|
}
|
|
@@ -1901,17 +1905,17 @@ const tt = class tt {
|
|
|
1901
1905
|
}
|
|
1902
1906
|
}
|
|
1903
1907
|
};
|
|
1904
|
-
|
|
1905
|
-
let
|
|
1908
|
+
g(tt, "HttpArtifactService");
|
|
1909
|
+
let ft = tt;
|
|
1906
1910
|
export {
|
|
1907
1911
|
G as A,
|
|
1908
1912
|
J as E,
|
|
1909
|
-
|
|
1913
|
+
ft as H,
|
|
1910
1914
|
$ as I,
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1915
|
+
ot as L,
|
|
1916
|
+
ct as M,
|
|
1917
|
+
ut as W,
|
|
1918
|
+
dt as a,
|
|
1919
|
+
te as u
|
|
1916
1920
|
};
|
|
1917
|
-
//# sourceMappingURL=httpArtifactService-
|
|
1921
|
+
//# sourceMappingURL=httpArtifactService-DBKIvfSD.js.map
|