@aintela/chat 0.2.49 → 0.2.51
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/{atMentions-CJUmkOh9.js → atMentions-BQ-FxbtK.js} +334 -290
- package/dist/atMentions-BQ-FxbtK.js.map +1 -0
- package/dist/{auth-xpQrzSI2.js → auth-DnA-Qvpi.js} +2 -2
- package/dist/{auth-xpQrzSI2.js.map → auth-DnA-Qvpi.js.map} +1 -1
- package/dist/components.js +5666 -5491
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/{httpArtifactService-CcYAfh2q.js → httpArtifactService-JtkC1T7n.js} +206 -194
- package/dist/{httpArtifactService-CcYAfh2q.js.map → httpArtifactService-JtkC1T7n.js.map} +1 -1
- package/dist/index.js +149 -143
- package/dist/services.js +1 -1
- package/dist/src/components/AiChat/sessionStateManagerService.d.ts +8 -1
- package/dist/src/components/v2/MentionPickerPanel.d.ts +34 -0
- package/dist/src/components/v2/PromptGhostHint.d.ts +11 -0
- package/dist/src/components/v2/PromptV2.d.ts +10 -14
- package/dist/src/components/v2/TriggerDropdown.d.ts +31 -0
- package/dist/src/components/v2/index.d.ts +7 -0
- package/dist/src/components/v2/useCoarsePointer.d.ts +10 -0
- package/dist/src/services/WebSocketConnection/WebSocketConnectionV2.d.ts +12 -3
- package/dist/src/services/WebSocketConnection/webSocketConnection.d.ts +8 -1
- package/dist/src/services/servers/AgentGatewayService.d.ts +8 -1
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +3 -1
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/promptTriggers.d.ts +60 -0
- package/dist/src/utils/promptTriggers.test.d.ts +1 -0
- package/dist/useContainerWidth-B3t1ZTlo.js +309 -0
- package/dist/useContainerWidth-B3t1ZTlo.js.map +1 -0
- package/dist/utils.js +29 -27
- package/package.json +1 -1
- package/dist/atMentions-CJUmkOh9.js.map +0 -1
- package/dist/useContainerWidth-CDv8UQyZ.js +0 -309
- package/dist/useContainerWidth-CDv8UQyZ.js.map +0 -1
|
@@ -2,20 +2,20 @@ var rt = Object.defineProperty;
|
|
|
2
2
|
var St = (D, t, e) => t in D ? rt(D, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : D[t] = e;
|
|
3
3
|
var g = (D, t) => rt(D, "name", { value: t, configurable: !0 });
|
|
4
4
|
var a = (D, t, e) => St(D, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
-
import { d as
|
|
6
|
-
import { I as _, S as gt, g as Ct, L as vt, P as
|
|
5
|
+
import { d as x, t as wt, E as I, k as yt, j as Tt, q as It, C as W } from "./environmentUtils-CUVZ6Dq1.js";
|
|
6
|
+
import { I as _, S as gt, g as Ct, L as vt, P as B, b as Et, e as Mt, T as Dt, c as Ot } from "./serializer-DNt8QqNO.js";
|
|
7
7
|
import { unified as At } from "unified";
|
|
8
8
|
import kt from "remark-parse";
|
|
9
9
|
import { toMarkdown as Nt } from "mdast-util-to-markdown";
|
|
10
10
|
import { format as Pt } from "date-fns";
|
|
11
11
|
import _t from "lodash";
|
|
12
|
-
import { P as bt, C as
|
|
12
|
+
import { P as bt, C as U } from "./Prompt-DZb7OaPp.js";
|
|
13
13
|
import { r as Ft } from "./httpSessionService-BDlqebW2.js";
|
|
14
14
|
const w = {
|
|
15
15
|
ARTIFACTS: "envision-artifacts",
|
|
16
16
|
SECTIONS: "envision-sections",
|
|
17
17
|
PROMPTS: "envision-prompts"
|
|
18
|
-
},
|
|
18
|
+
}, L = [
|
|
19
19
|
{
|
|
20
20
|
id: "dashboards",
|
|
21
21
|
name: "Dashboards",
|
|
@@ -37,7 +37,7 @@ const w = {
|
|
|
37
37
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
38
38
|
iconType: "folder"
|
|
39
39
|
}
|
|
40
|
-
],
|
|
40
|
+
], z = class z {
|
|
41
41
|
constructor() {
|
|
42
42
|
a(this, "onPromptCreated", /* @__PURE__ */ g(() => {
|
|
43
43
|
}, "onPromptCreated"));
|
|
@@ -55,14 +55,14 @@ const w = {
|
|
|
55
55
|
try {
|
|
56
56
|
const t = localStorage.getItem(w.SECTIONS);
|
|
57
57
|
if (!t)
|
|
58
|
-
localStorage.setItem(w.SECTIONS, JSON.stringify(
|
|
58
|
+
localStorage.setItem(w.SECTIONS, JSON.stringify(L));
|
|
59
59
|
else {
|
|
60
60
|
const s = JSON.parse(t);
|
|
61
|
-
if (
|
|
61
|
+
if (L.some(
|
|
62
62
|
(n) => !s.find((r) => r.id === n.id)
|
|
63
63
|
)) {
|
|
64
64
|
const n = [...s];
|
|
65
|
-
|
|
65
|
+
L.forEach((r) => {
|
|
66
66
|
s.find((l) => l.id === r.id) || n.push(r);
|
|
67
67
|
}), localStorage.setItem(w.SECTIONS, JSON.stringify(n));
|
|
68
68
|
}
|
|
@@ -75,7 +75,7 @@ const w = {
|
|
|
75
75
|
if (!r.sectionId) {
|
|
76
76
|
i = !0;
|
|
77
77
|
let l = "data-analytics";
|
|
78
|
-
return r.type ===
|
|
78
|
+
return r.type === x.Dashboard ? l = "dashboards" : r.type === x.Chart && (l = "charts"), {
|
|
79
79
|
...r,
|
|
80
80
|
sectionId: l
|
|
81
81
|
};
|
|
@@ -91,9 +91,9 @@ const w = {
|
|
|
91
91
|
getSections() {
|
|
92
92
|
try {
|
|
93
93
|
const t = localStorage.getItem(w.SECTIONS);
|
|
94
|
-
return t ? JSON.parse(t) :
|
|
94
|
+
return t ? JSON.parse(t) : L;
|
|
95
95
|
} catch (t) {
|
|
96
|
-
return console.error("Error loading sections:", t),
|
|
96
|
+
return console.error("Error loading sections:", t), L;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
getArtifacts() {
|
|
@@ -134,7 +134,7 @@ const w = {
|
|
|
134
134
|
e[s] = t;
|
|
135
135
|
else {
|
|
136
136
|
let i = "data-analytics";
|
|
137
|
-
t.type ===
|
|
137
|
+
t.type === x.Dashboard ? i = "dashboards" : t.type === x.Chart && (i = "charts");
|
|
138
138
|
const n = {
|
|
139
139
|
...t,
|
|
140
140
|
created: t.created || (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -197,8 +197,8 @@ const w = {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
g(
|
|
201
|
-
let ot =
|
|
200
|
+
g(z, "LocalStorageService");
|
|
201
|
+
let ot = z;
|
|
202
202
|
const te = /* @__PURE__ */ g((D) => {
|
|
203
203
|
const t = D.getPrompts(), e = t.length;
|
|
204
204
|
if (e > 0) {
|
|
@@ -206,7 +206,7 @@ const te = /* @__PURE__ */ g((D) => {
|
|
|
206
206
|
return { promptState: e + "_" + s + "_" + i + "_" + n };
|
|
207
207
|
} else
|
|
208
208
|
return { promptState: "0" };
|
|
209
|
-
}, "usePromptState"),
|
|
209
|
+
}, "usePromptState"), Y = class Y {
|
|
210
210
|
constructor() {
|
|
211
211
|
a(this, "activityLost", "activityLost");
|
|
212
212
|
a(this, "artifactGenerated", "artifactGenerated");
|
|
@@ -231,9 +231,9 @@ const te = /* @__PURE__ */ g((D) => {
|
|
|
231
231
|
a(this, "gatewayFirstToken", "gatewayFirstToken");
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
g(
|
|
235
|
-
let
|
|
236
|
-
const c = new
|
|
234
|
+
g(Y, "EventTypes");
|
|
235
|
+
let J = Y;
|
|
236
|
+
const c = new J(), j = class j {
|
|
237
237
|
constructor() {
|
|
238
238
|
a(this, "listeners", {});
|
|
239
239
|
a(this, "listenersCount", {});
|
|
@@ -484,9 +484,9 @@ 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
|
-
g(
|
|
488
|
-
let
|
|
489
|
-
const
|
|
487
|
+
g(j, "EventBusService");
|
|
488
|
+
let G = j;
|
|
489
|
+
const X = class X extends G {
|
|
490
490
|
constructor() {
|
|
491
491
|
super();
|
|
492
492
|
}
|
|
@@ -512,12 +512,12 @@ const j = class j extends J {
|
|
|
512
512
|
console.log("MockEventBusService.gatewayOffFunctionResponse", t);
|
|
513
513
|
}
|
|
514
514
|
};
|
|
515
|
-
g(
|
|
516
|
-
let ct =
|
|
515
|
+
g(X, "MockEventBusService");
|
|
516
|
+
let ct = X;
|
|
517
517
|
const Rt = 2e3, pt = {
|
|
518
518
|
inline: "inline",
|
|
519
519
|
block: "block"
|
|
520
|
-
},
|
|
520
|
+
}, Q = class Q {
|
|
521
521
|
constructor() {
|
|
522
522
|
a(this, "parts", []);
|
|
523
523
|
a(this, "isLastGroup", !1);
|
|
@@ -526,9 +526,9 @@ const Rt = 2e3, pt = {
|
|
|
526
526
|
a(this, "type", pt.inline);
|
|
527
527
|
}
|
|
528
528
|
};
|
|
529
|
-
g(
|
|
530
|
-
let
|
|
531
|
-
const
|
|
529
|
+
g(Q, "InteractionPartGroup");
|
|
530
|
+
let $ = Q;
|
|
531
|
+
const Z = class Z {
|
|
532
532
|
constructor(t, e) {
|
|
533
533
|
a(this, "interaction");
|
|
534
534
|
a(this, "eventBusService");
|
|
@@ -558,11 +558,11 @@ ${n.value}
|
|
|
558
558
|
groupPartsByDisplayType(t, e = !0, s = !1) {
|
|
559
559
|
var l, o, d;
|
|
560
560
|
const i = [];
|
|
561
|
-
let n = new
|
|
561
|
+
let n = new $();
|
|
562
562
|
for (let u = 0; u < t.length; u++) {
|
|
563
563
|
const h = t[u];
|
|
564
|
-
let
|
|
565
|
-
!e &&
|
|
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 !== I.Text && h.eventType !== I.Thought && (h.eventType === I.FunctionCall || h.eventType === I.PartialFunctionCall || h.eventType === I.FunctionResponse) && u < t.length - 1;
|
|
565
|
+
!e && p && !s || (p ? (h.eventType == I.Thought && (n.hasThoughts = !0), n.parts.push(h), n.isLastGroup = u === t.length - 1) : (n.parts.length > 0 && (i.push(n), n = new $()), i.push({
|
|
566
566
|
type: pt.block,
|
|
567
567
|
parts: [h],
|
|
568
568
|
isLastGroup: u === t.length - 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 == I.FunctionCall || t == I.PartialFunctionCall;
|
|
579
579
|
}
|
|
580
580
|
isFunctionResponse(t) {
|
|
581
|
-
return t ==
|
|
581
|
+
return t == I.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,59 +586,59 @@ ${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, F, y, A, N, 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) !== ((F = r.functionDetails) == null ? void 0 : F.id)));
|
|
593
593
|
let o = e.parts, d = e.functionMap ?? /* @__PURE__ */ new Map(), u = !e.functionMap;
|
|
594
594
|
const h = /* @__PURE__ */ g(() => {
|
|
595
595
|
u || (d = new Map(d), u = !0);
|
|
596
|
-
}, "cloneFunctionMap"),
|
|
596
|
+
}, "cloneFunctionMap"), C = /* @__PURE__ */ g(() => {
|
|
597
597
|
o === e.parts && (o = e.parts.slice());
|
|
598
598
|
}, "clonePartsIfShared");
|
|
599
599
|
if (!l && (o == null ? void 0 : o.length) > 0 && (n != null && n.textAppendable)) {
|
|
600
600
|
const f = o[o.length - 1];
|
|
601
|
-
(((
|
|
601
|
+
(((A = (y = f.thoughtDetails) == null ? void 0 : y.text) == null ? void 0 : A.length) ?? ((N = f.text) == null ? void 0 : N.length) ?? 0) > Rt && (l = !0);
|
|
602
602
|
}
|
|
603
|
-
let
|
|
604
|
-
if ((n == null ? void 0 : n.eventType) ===
|
|
605
|
-
const f = n.functionDetails.id,
|
|
606
|
-
var
|
|
607
|
-
return ((
|
|
603
|
+
let p = !1;
|
|
604
|
+
if ((n == null ? void 0 : n.eventType) === I.FunctionClientOutput && !!((st = n.functionDetails) != null && st.id) && n) {
|
|
605
|
+
const f = n.functionDetails.id, T = n.functionDetails.clientOutput, E = o.findIndex((S) => {
|
|
606
|
+
var m;
|
|
607
|
+
return ((m = S.functionDetails) == null ? void 0 : m.id) === f;
|
|
608
608
|
});
|
|
609
609
|
if (E > -1) {
|
|
610
|
-
const S = o[E],
|
|
610
|
+
const S = o[E], m = {
|
|
611
611
|
...S,
|
|
612
612
|
functionDetails: {
|
|
613
613
|
...S.functionDetails,
|
|
614
|
-
clientOutput:
|
|
614
|
+
clientOutput: T ?? S.functionDetails.clientOutput,
|
|
615
615
|
// Sticky true-wins: this event IS the park, and a later merge must not clear it.
|
|
616
616
|
parked: n.functionDetails.parked === !0 || S.functionDetails.parked === !0
|
|
617
617
|
}
|
|
618
618
|
};
|
|
619
|
-
|
|
619
|
+
C(), o[E] = m, h(), d.set(f, m), s.push(m);
|
|
620
620
|
} else {
|
|
621
621
|
const S = {
|
|
622
622
|
...n,
|
|
623
623
|
id: o.length + 1 + "-" + e.interactionId,
|
|
624
624
|
functionDetails: { ...n.functionDetails, silent: !0 }
|
|
625
625
|
};
|
|
626
|
-
|
|
626
|
+
C(), o = o === e.parts ? e.parts.slice() : o, o.push(S), h(), d.set(f, S);
|
|
627
627
|
}
|
|
628
628
|
} else if (l && n) {
|
|
629
|
-
const f = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType),
|
|
630
|
-
f && !
|
|
631
|
-
const E =
|
|
632
|
-
if (E &&
|
|
629
|
+
const f = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), T = f ? (nt = n.functionDetails) == null ? void 0 : nt.id : void 0;
|
|
630
|
+
f && !T && console.error("Got isCall or isResponse without a callId", n);
|
|
631
|
+
const E = T ? d.get(T) : void 0;
|
|
632
|
+
if (E && T && n.functionDetails) {
|
|
633
633
|
const S = o.findIndex((mt) => {
|
|
634
634
|
var at;
|
|
635
|
-
return ((at = mt.functionDetails) == null ? void 0 : at.id) ===
|
|
636
|
-
}),
|
|
637
|
-
...
|
|
635
|
+
return ((at = mt.functionDetails) == null ? void 0 : at.id) === T;
|
|
636
|
+
}), m = S > -1 ? o[S] : E, R = {
|
|
637
|
+
...m,
|
|
638
638
|
eventType: n.eventType,
|
|
639
639
|
functionDetails: {
|
|
640
|
-
id:
|
|
641
|
-
name: n.functionDetails.name ??
|
|
640
|
+
id: m.functionDetails.id,
|
|
641
|
+
name: n.functionDetails.name ?? m.functionDetails.name,
|
|
642
642
|
// Take the parsed args from the incoming event when
|
|
643
643
|
// present (the full FunctionCall carries them), fall
|
|
644
644
|
// back to what was already on the part. Previously
|
|
@@ -647,42 +647,42 @@ ${n.value}
|
|
|
647
647
|
// args off every full FunctionCall fold because the
|
|
648
648
|
// PartialFunctionCall stream only accumulates raw
|
|
649
649
|
// JSON in `.text` — `.args` stayed undefined.
|
|
650
|
-
args: n.functionDetails.args ??
|
|
650
|
+
args: n.functionDetails.args ?? m.functionDetails.args,
|
|
651
651
|
response: n.functionDetails.response,
|
|
652
652
|
status: n.functionDetails.status ?? "Composing",
|
|
653
|
-
start: n.functionDetails.start ??
|
|
654
|
-
end: n.functionDetails.end ??
|
|
653
|
+
start: n.functionDetails.start ?? m.functionDetails.start,
|
|
654
|
+
end: n.functionDetails.end ?? m.functionDetails.end,
|
|
655
655
|
// true-wins: a UI call has multiple reps (streaming part with isUi, the
|
|
656
656
|
// persisted FunctionCall, the result) and they interleave. `??` let a later
|
|
657
657
|
// `false`/`undefined` rep clobber an earlier `true`; OR-ing keeps it sticky.
|
|
658
|
-
isUi: n.functionDetails.isUi === !0 ||
|
|
658
|
+
isUi: n.functionDetails.isUi === !0 || m.functionDetails.isUi === !0,
|
|
659
659
|
// Keep the call's friendly args summary when the result event (which has none) folds in.
|
|
660
|
-
argsDescription: n.functionDetails.argsDescription ??
|
|
660
|
+
argsDescription: n.functionDetails.argsDescription ?? m.functionDetails.argsDescription,
|
|
661
661
|
// The tool's client-only payload rides the RESULT event; keep it sticky so a
|
|
662
662
|
// later rep without one can't clobber it. This is what a uiTool renderer reads.
|
|
663
|
-
clientOutput: n.functionDetails.clientOutput ??
|
|
663
|
+
clientOutput: n.functionDetails.clientOutput ?? m.functionDetails.clientOutput,
|
|
664
664
|
// Ask-user component ([KernelUIComponent]) — sticky like isUi/clientOutput. The
|
|
665
665
|
// streaming final CALL carries it, but the PartialFunctionCall it folds onto (and a
|
|
666
666
|
// later result rep) may not; dropping it strips the part's askUser classification so
|
|
667
667
|
// the docked drawer never surfaces (issue #60 — esp. a no-arg tool like update_profile,
|
|
668
668
|
// which has no name match to fall back on the way ask_user/askauth do).
|
|
669
|
-
askUserComponent: n.functionDetails.askUserComponent ??
|
|
670
|
-
isAskUser: n.functionDetails.isAskUser ||
|
|
669
|
+
askUserComponent: n.functionDetails.askUserComponent ?? m.functionDetails.askUserComponent,
|
|
670
|
+
isAskUser: n.functionDetails.isAskUser || m.functionDetails.isAskUser || !!(n.functionDetails.askUserComponent ?? m.functionDetails.askUserComponent),
|
|
671
671
|
// Runtime "don't render" override rides the RESULT; true-wins sticky like isUi so it
|
|
672
672
|
// survives folding onto the earlier call rep and suppresses drawer/uiTool classification.
|
|
673
|
-
cancelUi: n.functionDetails.cancelUi === !0 ||
|
|
674
|
-
parked: n.functionDetails.parked === !0 ||
|
|
673
|
+
cancelUi: n.functionDetails.cancelUi === !0 || m.functionDetails.cancelUi === !0,
|
|
674
|
+
parked: n.functionDetails.parked === !0 || m.functionDetails.parked === !0
|
|
675
675
|
}
|
|
676
676
|
};
|
|
677
|
-
h(), d.set(
|
|
677
|
+
h(), d.set(T, R), R.eventType === I.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(R.functionDetails), s.push(R), S > -1 && (C(), o[S] = R);
|
|
678
678
|
} else {
|
|
679
|
-
if (
|
|
680
|
-
const
|
|
679
|
+
if (T && n.functionDetails && !E && (h(), d.set(T, n)), r && r.textAppendable) {
|
|
680
|
+
const m = {
|
|
681
681
|
...r,
|
|
682
682
|
ended: /* @__PURE__ */ new Date(),
|
|
683
683
|
isStillWriting: !1
|
|
684
684
|
};
|
|
685
|
-
|
|
685
|
+
C(), o[o.length - 1] = m, s.push(m);
|
|
686
686
|
}
|
|
687
687
|
const S = {
|
|
688
688
|
...n,
|
|
@@ -690,24 +690,24 @@ ${n.value}
|
|
|
690
690
|
isStillWriting: n.textAppendable,
|
|
691
691
|
partial: t.partial
|
|
692
692
|
};
|
|
693
|
-
(it = S.functionDetails) != null && it.silent || s.push(S), o = [...o, S],
|
|
693
|
+
(it = S.functionDetails) != null && it.silent || s.push(S), o = [...o, S], p = !0;
|
|
694
694
|
}
|
|
695
695
|
}
|
|
696
|
-
let
|
|
697
|
-
if (
|
|
696
|
+
let M = o[o.length - 1] ?? null;
|
|
697
|
+
if (M && n && n.textAppendable) {
|
|
698
698
|
const f = {
|
|
699
|
-
...
|
|
699
|
+
...M,
|
|
700
700
|
partial: t.partial,
|
|
701
|
-
textDetails:
|
|
701
|
+
textDetails: M.textDetails ? { ...M.textDetails } : { version: 0 }
|
|
702
702
|
};
|
|
703
|
-
let
|
|
703
|
+
let T = !1;
|
|
704
704
|
if (t.partial) {
|
|
705
705
|
try {
|
|
706
|
-
f.textDetails.version++,
|
|
706
|
+
f.textDetails.version++, p || (f.text = (M.text ?? "") + (n.text ?? ""));
|
|
707
707
|
} catch (E) {
|
|
708
708
|
console.error("Error here", E.toString());
|
|
709
709
|
}
|
|
710
|
-
f.textLastChunk = n.text ?? "", f.isStillWriting = !0,
|
|
710
|
+
f.textLastChunk = n.text ?? "", f.isStillWriting = !0, T = !0, n.thoughtDetails && f.thoughtDetails && (n.thoughtDetails.text.length >= 50 || n.thoughtDetails.text.length < 50 && n.thoughtDetails.text !== f.thoughtDetails.text) && (f.thoughtDetails = {
|
|
711
711
|
...f.thoughtDetails,
|
|
712
712
|
text: f.thoughtDetails.text + n.thoughtDetails.text
|
|
713
713
|
}, f.thoughtLastChunk = n.thoughtDetails.text);
|
|
@@ -715,43 +715,43 @@ ${n.value}
|
|
|
715
715
|
f.isStillWriting = !1, f.text = n.text ?? "", f.textDetails.version++, n.thoughtDetails && (f.thoughtDetails = {
|
|
716
716
|
...n.thoughtDetails,
|
|
717
717
|
text: n.thoughtDetails.text.trim()
|
|
718
|
-
}),
|
|
719
|
-
|
|
718
|
+
}), T = !l;
|
|
719
|
+
C(), o[o.length - 1] = f, M = f, T && s.push(f);
|
|
720
720
|
}
|
|
721
|
-
let
|
|
721
|
+
let v = e.artifactData ?? [];
|
|
722
722
|
if (t.llmArtifacts && t.llmArtifacts.length > 0) {
|
|
723
723
|
let f = !1;
|
|
724
|
-
for (const
|
|
725
|
-
const E =
|
|
726
|
-
f || (
|
|
727
|
-
const S =
|
|
728
|
-
S === -1 ?
|
|
724
|
+
for (const T of t.llmArtifacts) {
|
|
725
|
+
const E = T.toArtifact();
|
|
726
|
+
f || (v = v.slice(), f = !0);
|
|
727
|
+
const S = v.findIndex((m) => m.id === E.id);
|
|
728
|
+
S === -1 ? v.push(E) : v[S] = E;
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
|
-
const
|
|
731
|
+
const k = {
|
|
732
732
|
...e,
|
|
733
733
|
version: e.version + 1,
|
|
734
734
|
parts: o,
|
|
735
|
-
artifactData:
|
|
735
|
+
artifactData: v,
|
|
736
736
|
functionMap: d,
|
|
737
737
|
turn_complete: t.turn_complete,
|
|
738
738
|
partial: t.partial,
|
|
739
739
|
asyncFinalResponse: t.asyncFinalResponse
|
|
740
740
|
};
|
|
741
|
-
return this.interaction =
|
|
742
|
-
updatedInteraction:
|
|
741
|
+
return this.interaction = k, {
|
|
742
|
+
updatedInteraction: k,
|
|
743
743
|
updatedParts: s,
|
|
744
744
|
newArtifacts: i,
|
|
745
|
-
mainBranch:
|
|
745
|
+
mainBranch: k,
|
|
746
746
|
analyticsBranch: null,
|
|
747
747
|
analyticsBranchPartsChanged: null,
|
|
748
748
|
mainBranchPartsChanged: s
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
751
|
};
|
|
752
|
-
g(
|
|
753
|
-
let
|
|
754
|
-
const Ut = 1200 * 1e3,
|
|
752
|
+
g(Z, "InteractionService");
|
|
753
|
+
let q = Z;
|
|
754
|
+
const Ut = 1200 * 1e3, P = class P {
|
|
755
755
|
constructor(t, e, s, i, n, r, l, o, d, u = Tt.Interactive) {
|
|
756
756
|
a(this, "base_production_url", yt() ?? "https://agent.tripapi.com.br");
|
|
757
757
|
a(this, "base_url_local", "http://localagent:8000");
|
|
@@ -828,7 +828,7 @@ const Ut = 1200 * 1e3, N = class N {
|
|
|
828
828
|
a(this, "subAgentInteractionServices", /* @__PURE__ */ new Map());
|
|
829
829
|
a(this, "lastThorttledTimeout", null);
|
|
830
830
|
a(this, "lastPingStatus", !1);
|
|
831
|
-
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,
|
|
831
|
+
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, C) => {
|
|
832
832
|
this.sessionState = h;
|
|
833
833
|
});
|
|
834
834
|
}
|
|
@@ -914,7 +914,7 @@ const Ut = 1200 * 1e3, N = class N {
|
|
|
914
914
|
functionMap: /* @__PURE__ */ new Map(),
|
|
915
915
|
interactionQuestion: t
|
|
916
916
|
};
|
|
917
|
-
return this.interactionsMap.set(n.interactionId, n), this.currentIS = new
|
|
917
|
+
return this.interactionsMap.set(n.interactionId, n), this.currentIS = new q(n, this.eventBusService), this.interactionsServiceMap.set(n.interactionId, this.currentIS), n;
|
|
918
918
|
}
|
|
919
919
|
getInteractions() {
|
|
920
920
|
return Array.from(this.interactionsMap.values());
|
|
@@ -947,7 +947,12 @@ const Ut = 1200 * 1e3, N = class N {
|
|
|
947
947
|
let t = `agent=${encodeURIComponent(this.config.agentConfig.name ?? "unset")}`;
|
|
948
948
|
return this.config.customer && (t += `&customer_id=${encodeURIComponent(this.config.customer.dataSetId)}`, t += `&customer_name=${encodeURIComponent(this.config.customer.name)}`), t;
|
|
949
949
|
}
|
|
950
|
-
|
|
950
|
+
/**
|
|
951
|
+
* Open the live connection. `options.resume` asks the transport to keep its replay cursor,
|
|
952
|
+
* so the server sends back whatever was emitted while we were disconnected — see
|
|
953
|
+
* WebSocketConnectionV2.connect.
|
|
954
|
+
*/
|
|
955
|
+
openConnection(t, e) {
|
|
951
956
|
throw "Not implemented";
|
|
952
957
|
}
|
|
953
958
|
async Error(t = void 0) {
|
|
@@ -990,7 +995,7 @@ const Ut = 1200 * 1e3, N = class N {
|
|
|
990
995
|
version: 0,
|
|
991
996
|
functionMap: /* @__PURE__ */ new Map(),
|
|
992
997
|
interactionQuestion: s ?? t
|
|
993
|
-
}, n = new
|
|
998
|
+
}, n = new q(i, this.eventBusService), this.subAgentInteractions.set(t, i), this.subAgentInteractionServices.set(t, n)), { interaction: i, service: n };
|
|
994
999
|
}
|
|
995
1000
|
handleSubAgentEvent(t) {
|
|
996
1001
|
const e = t.subAgentId, { service: s } = this.getOrCreateSubAgentInteraction(e, t.interactionId, t.subAgentName);
|
|
@@ -1080,10 +1085,10 @@ const Ut = 1200 * 1e3, N = class N {
|
|
|
1080
1085
|
}
|
|
1081
1086
|
localEmitMessage(t, e) {
|
|
1082
1087
|
const s = (/* @__PURE__ */ new Date()).getTime(), i = s - this.lastCurrentMessageUpdate;
|
|
1083
|
-
t.partial === !1 || i >=
|
|
1088
|
+
t.partial === !1 || i >= P.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(() => {
|
|
1084
1089
|
var r, l;
|
|
1085
1090
|
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);
|
|
1086
|
-
},
|
|
1091
|
+
}, P.CURRENT_MSG_THROTTLE_MS * 2));
|
|
1087
1092
|
}
|
|
1088
1093
|
localOpen(t, e) {
|
|
1089
1094
|
this.sessionState.setTurnOpen(!0), this.eventBusService.gatewayEmitTurnOpen(t ?? "");
|
|
@@ -1177,9 +1182,9 @@ const Ut = 1200 * 1e3, N = class N {
|
|
|
1177
1182
|
return `${this.msg_order}_${e}`;
|
|
1178
1183
|
}
|
|
1179
1184
|
};
|
|
1180
|
-
g(
|
|
1181
|
-
let
|
|
1182
|
-
const
|
|
1185
|
+
g(P, "AgentGatewayService"), a(P, "SUSPENSION_MSG", "SUSPEND"), a(P, "CURRENT_MSG_THROTTLE_MS", 20);
|
|
1186
|
+
let H = P;
|
|
1187
|
+
const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2, ht = 2, V = class V {
|
|
1183
1188
|
constructor(t = "ws://localhost:8000", e) {
|
|
1184
1189
|
a(this, "ws", null);
|
|
1185
1190
|
a(this, "stats");
|
|
@@ -1281,18 +1286,25 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1281
1286
|
}, this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
|
|
1282
1287
|
}
|
|
1283
1288
|
/**
|
|
1284
|
-
* Connect to the WebSocket endpoint
|
|
1289
|
+
* Connect to the WebSocket endpoint.
|
|
1290
|
+
*
|
|
1291
|
+
* `options.resume` keeps the replay cursor so the server can send back everything emitted
|
|
1292
|
+
* while we were away (`?lastSeq=N`). Until it existed, only the socket's OWN
|
|
1293
|
+
* `scheduleReconnect` could resume: every other caller landed in the "fresh connect" branch
|
|
1294
|
+
* below, which discards `lastSeq`. A host that redials deliberately — a mobile app coming
|
|
1295
|
+
* back to the foreground, say — therefore lost every frame emitted while it was suspended,
|
|
1296
|
+
* silently, because the transcript looked intact right up to the gap.
|
|
1285
1297
|
*/
|
|
1286
|
-
connect(t) {
|
|
1287
|
-
return new Promise(async (
|
|
1288
|
-
var
|
|
1298
|
+
connect(t, e) {
|
|
1299
|
+
return new Promise(async (s, i) => {
|
|
1300
|
+
var F;
|
|
1289
1301
|
this.intentionalDisconnect = !1;
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
const
|
|
1295
|
-
if (console.log("Connecting to ",
|
|
1302
|
+
const n = this._internalReconnect || (e == null ? void 0 : e.resume) === !0;
|
|
1303
|
+
n || (this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.lastSeq = -1), this._internalReconnect = !1;
|
|
1304
|
+
const r = (F = this.getToken) == null ? void 0 : F.call(this), l = [];
|
|
1305
|
+
r && l.push(`access_token=${encodeURIComponent(r)}`), t && this.lastSeq >= 0 && l.push(`lastSeq=${this.lastSeq}`);
|
|
1306
|
+
const o = l.length > 0 ? `?${l.join("&")}` : "", d = this.baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"), u = `${d}/ws/connect/${t ?? ""}${o}`, h = `${d}/ws/connect/${t ?? ""}` + (n && t && this.lastSeq >= 0 ? ` (resume lastSeq=${this.lastSeq})` : "");
|
|
1307
|
+
if (console.log("Connecting to ", h), this.ws) {
|
|
1296
1308
|
this.ws.onopen = null, this.ws.onmessage = null, this.ws.onerror = null, this.ws.onclose = null;
|
|
1297
1309
|
try {
|
|
1298
1310
|
this.ws.close();
|
|
@@ -1300,61 +1312,61 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1300
1312
|
}
|
|
1301
1313
|
this.ws = null;
|
|
1302
1314
|
}
|
|
1303
|
-
this.ws = new WebSocket(
|
|
1304
|
-
let
|
|
1315
|
+
this.ws = new WebSocket(u), console.log("[WebSocket] Connecting to:", `${d}/ws/connect/${t ?? ""}`);
|
|
1316
|
+
let C = !1;
|
|
1305
1317
|
this.ws.onopen = () => {
|
|
1306
1318
|
console.log("[WebSocket] Connected");
|
|
1307
|
-
const
|
|
1308
|
-
this.isReconnecting = !1, this.reconnectAttempts = 0, this.pingPongStack.push((/* @__PURE__ */ new Date()).getTime()), this.ping(), this.monitor(), this.onOpen && this.onOpen(),
|
|
1309
|
-
}, this.ws.onmessage = (
|
|
1319
|
+
const y = this.isReconnecting;
|
|
1320
|
+
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);
|
|
1321
|
+
}, this.ws.onmessage = (y) => {
|
|
1310
1322
|
try {
|
|
1311
1323
|
this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
|
|
1312
|
-
const A = this.streamingResponseSerializer.parse(
|
|
1324
|
+
const A = this.streamingResponseSerializer.parse(y.data);
|
|
1313
1325
|
if (!A)
|
|
1314
1326
|
throw "Error parsing event JSON";
|
|
1315
|
-
const
|
|
1316
|
-
!
|
|
1327
|
+
const N = this.handleMessage(A, y.data);
|
|
1328
|
+
!C && (N != null && N.timestamp) && (C = !0, this.hasEverReceivedPacket = !0);
|
|
1317
1329
|
} catch (A) {
|
|
1318
1330
|
console.error("[WebSocket] Error parsing message:", A);
|
|
1319
1331
|
}
|
|
1320
|
-
}, this.ws.onerror = (
|
|
1321
|
-
console.error("[WebSocket] Error:",
|
|
1322
|
-
}, this.ws.onclose = (
|
|
1323
|
-
console.log("[WebSocket] Closed:",
|
|
1332
|
+
}, this.ws.onerror = (y) => {
|
|
1333
|
+
console.error("[WebSocket] Error:", y), this.onError && this.onError("WebSocket error");
|
|
1334
|
+
}, this.ws.onclose = (y) => {
|
|
1335
|
+
console.log("[WebSocket] Closed:", y.code, y.reason), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [];
|
|
1324
1336
|
const A = this.sessionId ?? this.lastKnownSessionId;
|
|
1325
|
-
if (this.sessionId = void 0, (
|
|
1326
|
-
this.scheduleReconnect(A,
|
|
1337
|
+
if (this.sessionId = void 0, (C || this.hasEverReceivedPacket) && this.shouldAttemptReconnect(y.code)) {
|
|
1338
|
+
this.scheduleReconnect(A, y.code, y.reason);
|
|
1327
1339
|
return;
|
|
1328
1340
|
}
|
|
1329
|
-
this.isReconnecting = !1, this.reconnectAttempts = 0, this.onClose && this.onClose(
|
|
1341
|
+
this.isReconnecting = !1, this.reconnectAttempts = 0, this.onClose && this.onClose(y.code, y.reason);
|
|
1330
1342
|
};
|
|
1331
|
-
const
|
|
1343
|
+
const p = 200, O = 3e4, M = 8e3, v = this.ws;
|
|
1332
1344
|
this.sessionId = void 0;
|
|
1333
|
-
let
|
|
1345
|
+
let k = 0, b = 0;
|
|
1334
1346
|
for (; !this.sessionId; ) {
|
|
1335
|
-
if (this.ws !==
|
|
1336
|
-
|
|
1347
|
+
if (this.ws !== v) {
|
|
1348
|
+
i("Connection attempt superseded by a newer connect()");
|
|
1337
1349
|
return;
|
|
1338
1350
|
}
|
|
1339
|
-
if (
|
|
1340
|
-
|
|
1351
|
+
if (v.readyState === WebSocket.CLOSING || v.readyState === WebSocket.CLOSED) {
|
|
1352
|
+
i("Connection closed before a session id was received");
|
|
1341
1353
|
return;
|
|
1342
1354
|
}
|
|
1343
|
-
if (
|
|
1355
|
+
if (v.readyState === WebSocket.CONNECTING && k >= O) {
|
|
1344
1356
|
try {
|
|
1345
|
-
|
|
1357
|
+
v.close();
|
|
1346
1358
|
} catch {
|
|
1347
1359
|
}
|
|
1348
|
-
|
|
1360
|
+
i(`Server did not accept the connection within ${O / 1e3}s`);
|
|
1349
1361
|
return;
|
|
1350
1362
|
}
|
|
1351
|
-
if (
|
|
1352
|
-
|
|
1363
|
+
if (v.readyState === WebSocket.OPEN && b >= M) {
|
|
1364
|
+
i(`Connected but no session id arrived within ${M / 1e3}s`);
|
|
1353
1365
|
return;
|
|
1354
1366
|
}
|
|
1355
|
-
|
|
1367
|
+
k % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(p), k += p, v.readyState === WebSocket.OPEN && (b += p);
|
|
1356
1368
|
}
|
|
1357
|
-
console.log("SUCCESS - GOT SESSION ID", this.sessionId), this.lastKnownSessionId = this.sessionId,
|
|
1369
|
+
console.log("SUCCESS - GOT SESSION ID", this.sessionId), this.lastKnownSessionId = this.sessionId, s(this.sessionId);
|
|
1358
1370
|
});
|
|
1359
1371
|
}
|
|
1360
1372
|
/**
|
|
@@ -1367,7 +1379,7 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1367
1379
|
* - 4000-4099 reserved for app-level fatal codes from the server
|
|
1368
1380
|
*/
|
|
1369
1381
|
shouldAttemptReconnect(t) {
|
|
1370
|
-
return !(this.intentionalDisconnect || t ===
|
|
1382
|
+
return !(this.intentionalDisconnect || t === K || t === Lt || t === 1e3 || t === 1008);
|
|
1371
1383
|
}
|
|
1372
1384
|
cancelPendingReconnect() {
|
|
1373
1385
|
this.reconnectTimer && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
|
|
@@ -1432,15 +1444,15 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1432
1444
|
this.emitFirstToken(u == null ? void 0 : u.iteractionId);
|
|
1433
1445
|
const h = new vt();
|
|
1434
1446
|
if (h.author = "main", h.streamingParts = t.partialEvent.streamingParts, t.partialEvent.partialEventType ? h.eventType = t.partialEvent.partialEventType : h.eventType = u.functionName ? {
|
|
1435
|
-
fullName:
|
|
1436
|
-
type:
|
|
1447
|
+
fullName: B.StreamingFunctionCallUpdateContent,
|
|
1448
|
+
type: I.PartialFunctionCall
|
|
1437
1449
|
} : u.partialReasoning ? {
|
|
1438
|
-
fullName:
|
|
1439
|
-
type:
|
|
1450
|
+
fullName: B.StreamingReasoningContent,
|
|
1451
|
+
type: I.Thought
|
|
1440
1452
|
} : {
|
|
1441
|
-
fullName:
|
|
1442
|
-
type:
|
|
1443
|
-
}, h.interactionId = (u == null ? void 0 : u.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type ==
|
|
1453
|
+
fullName: B.StreamingTextContent,
|
|
1454
|
+
type: I.Text
|
|
1455
|
+
}, h.interactionId = (u == null ? void 0 : u.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type == I.PartialFunctionCall) {
|
|
1444
1456
|
var s = new Et();
|
|
1445
1457
|
s.choiceIndex = 0, s.callId = u.functionCallId, s.arguments = u.partialText, s.name = u.functionName, h.content = {
|
|
1446
1458
|
items: [s],
|
|
@@ -1448,8 +1460,8 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1448
1460
|
label: "Assistant"
|
|
1449
1461
|
}
|
|
1450
1462
|
};
|
|
1451
|
-
} else if (h.eventType.type ==
|
|
1452
|
-
if (h.eventType.fullName ==
|
|
1463
|
+
} else if (h.eventType.type == I.Text)
|
|
1464
|
+
if (h.eventType.fullName == B.StreamingTextContent) {
|
|
1453
1465
|
var i = new Mt();
|
|
1454
1466
|
i.text = u.partialText, h.content = {
|
|
1455
1467
|
items: [i],
|
|
@@ -1466,7 +1478,7 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1466
1478
|
}
|
|
1467
1479
|
};
|
|
1468
1480
|
}
|
|
1469
|
-
else if (h.eventType.type ==
|
|
1481
|
+
else if (h.eventType.type == I.Thought) {
|
|
1470
1482
|
var r = new Ot();
|
|
1471
1483
|
r.text = u.partialReasoning, h.content = {
|
|
1472
1484
|
items: [r],
|
|
@@ -1528,7 +1540,7 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1528
1540
|
}
|
|
1529
1541
|
suspendStream() {
|
|
1530
1542
|
this.sendBaseMessage({
|
|
1531
|
-
Action:
|
|
1543
|
+
Action: W.Suspend,
|
|
1532
1544
|
AgentId: "",
|
|
1533
1545
|
InteractionId: "",
|
|
1534
1546
|
ModelId: ""
|
|
@@ -1547,7 +1559,7 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1547
1559
|
*/
|
|
1548
1560
|
answerHumanTool(t, e) {
|
|
1549
1561
|
const s = {
|
|
1550
|
-
Action:
|
|
1562
|
+
Action: W.AnswerHumanTool,
|
|
1551
1563
|
AgentId: "",
|
|
1552
1564
|
InteractionId: "",
|
|
1553
1565
|
ToolCallId: t,
|
|
@@ -1574,7 +1586,7 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1574
1586
|
}
|
|
1575
1587
|
try {
|
|
1576
1588
|
this.sendBaseMessage({
|
|
1577
|
-
Action:
|
|
1589
|
+
Action: W.AnswerHumanTool,
|
|
1578
1590
|
AgentId: "",
|
|
1579
1591
|
InteractionId: "",
|
|
1580
1592
|
ToolCallId: s.toolCallId,
|
|
@@ -1625,7 +1637,7 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1625
1637
|
* Disconnect the WebSocket
|
|
1626
1638
|
*/
|
|
1627
1639
|
disconnect() {
|
|
1628
|
-
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(
|
|
1640
|
+
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(K, "Intentional disconnect"), this.ws = null);
|
|
1629
1641
|
}
|
|
1630
1642
|
/**
|
|
1631
1643
|
* Check if connected
|
|
@@ -1667,11 +1679,11 @@ const H = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
|
|
|
1667
1679
|
}
|
|
1668
1680
|
}
|
|
1669
1681
|
};
|
|
1670
|
-
g(
|
|
1671
|
-
let ut =
|
|
1672
|
-
const Jt = "envision_agent_sessionId",
|
|
1673
|
-
constructor(e, s, i, n, r, l, o, d, u, h,
|
|
1674
|
-
super(e, s, i, n, r, l, o, u,
|
|
1682
|
+
g(V, "WebSocketConnecionV2");
|
|
1683
|
+
let ut = V;
|
|
1684
|
+
const Jt = "envision_agent_sessionId", tt = class tt extends H {
|
|
1685
|
+
constructor(e, s, i, n, r, l, o, d, u, h, C) {
|
|
1686
|
+
super(e, s, i, n, r, l, o, u, C);
|
|
1675
1687
|
a(this, "suspendState", !1);
|
|
1676
1688
|
a(this, "wsService");
|
|
1677
1689
|
a(this, "root_url", "");
|
|
@@ -1686,32 +1698,32 @@ const Jt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1686
1698
|
a(this, "everConnected", !1);
|
|
1687
1699
|
a(this, "statuses", ["CONNECTING", "OPEN", "CLOSED", "UNKNOWN"]);
|
|
1688
1700
|
a(this, "lastConnectionPromise", null);
|
|
1689
|
-
a(this, "socketState",
|
|
1701
|
+
a(this, "socketState", U.Disconnected);
|
|
1690
1702
|
a(this, "streamOpened", !1);
|
|
1691
|
-
this.hearBeatPort = h, this.root_url = this.base_url, this.wsService = d, this.wsService.onEvent = async (
|
|
1692
|
-
await super.Message(
|
|
1693
|
-
}, this.wsService.onNewPacket = (
|
|
1694
|
-
this.sessionState.setStatistics(
|
|
1695
|
-
}, this.wsService.onPong = (
|
|
1696
|
-
}, this.wsService.onError = (
|
|
1703
|
+
this.hearBeatPort = h, this.root_url = this.base_url, this.wsService = d, this.wsService.onEvent = async (p) => {
|
|
1704
|
+
await super.Message(p);
|
|
1705
|
+
}, this.wsService.onNewPacket = (p) => {
|
|
1706
|
+
this.sessionState.setStatistics(p), this.eventBusService.streamEmitNewChunk(p);
|
|
1707
|
+
}, this.wsService.onPong = (p) => {
|
|
1708
|
+
}, this.wsService.onError = (p) => {
|
|
1697
1709
|
this.streamOpened = !1;
|
|
1698
1710
|
const O = {
|
|
1699
|
-
data: this.getErrorEvent(
|
|
1711
|
+
data: this.getErrorEvent(p),
|
|
1700
1712
|
lastEventId: (/* @__PURE__ */ new Date()).getTime().toString(),
|
|
1701
1713
|
origin: "gatewayService"
|
|
1702
1714
|
};
|
|
1703
|
-
console.error("Stream error:",
|
|
1715
|
+
console.error("Stream error:", p), this.everConnected && this.notificationPort.pushNotification({
|
|
1704
1716
|
message: "Reiniciando a conexão com o servidor",
|
|
1705
1717
|
type: "info"
|
|
1706
1718
|
}), super.Message(O);
|
|
1707
1719
|
}, this.wsService.onOpen = () => {
|
|
1708
|
-
this.everConnected = !0, this.sessionState.setConnectionStatus(
|
|
1709
|
-
}, this.wsService.onReconnected = (
|
|
1710
|
-
this.sessionState.setConnectionStatus(
|
|
1711
|
-
}, this.wsService.onFirstToken = (
|
|
1712
|
-
this.localEmitFirstToken(
|
|
1713
|
-
}, this.wsService.onClose = (
|
|
1714
|
-
|
|
1720
|
+
this.everConnected = !0, this.sessionState.setConnectionStatus(U.Connected);
|
|
1721
|
+
}, this.wsService.onReconnected = (p) => {
|
|
1722
|
+
this.sessionState.setConnectionStatus(U.Connected);
|
|
1723
|
+
}, this.wsService.onFirstToken = (p) => {
|
|
1724
|
+
this.localEmitFirstToken(p);
|
|
1725
|
+
}, this.wsService.onClose = (p, O) => {
|
|
1726
|
+
p != K && this.sessionState.setConnectionStatus(U.Disconnected);
|
|
1715
1727
|
};
|
|
1716
1728
|
}
|
|
1717
1729
|
reset(e, s) {
|
|
@@ -1786,12 +1798,12 @@ const Jt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1786
1798
|
async check() {
|
|
1787
1799
|
return !0;
|
|
1788
1800
|
}
|
|
1789
|
-
async openConnection(e) {
|
|
1790
|
-
return this.lastConnectionPromise ? this.lastConnectionPromise : this.socketState ==
|
|
1791
|
-
this.wsService.connect(e).then((
|
|
1792
|
-
this.sessionId =
|
|
1793
|
-
}).catch((
|
|
1794
|
-
|
|
1801
|
+
async openConnection(e, s) {
|
|
1802
|
+
return this.lastConnectionPromise ? this.lastConnectionPromise : this.socketState == U.Disconnected ? (this.lastConnectionPromise = new Promise((i, n) => {
|
|
1803
|
+
this.wsService.connect(e, s).then((r) => {
|
|
1804
|
+
this.sessionId = r, i(r);
|
|
1805
|
+
}).catch((r) => {
|
|
1806
|
+
n(r);
|
|
1795
1807
|
}).finally(() => {
|
|
1796
1808
|
this.lastConnectionPromise = null;
|
|
1797
1809
|
});
|
|
@@ -1819,7 +1831,7 @@ const Jt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1819
1831
|
}
|
|
1820
1832
|
// Send a message to the server via HTTP POST
|
|
1821
1833
|
async sendMessageInternal(e, s, i) {
|
|
1822
|
-
var l, o, d, u, h,
|
|
1834
|
+
var l, o, d, u, h, C, p, O;
|
|
1823
1835
|
const n = this.suspendState;
|
|
1824
1836
|
this.suspendState = !1;
|
|
1825
1837
|
const r = this.startInteraction(e.friendlyMessage ?? e.data, n);
|
|
@@ -1832,7 +1844,7 @@ const Jt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1832
1844
|
return this.wsService.sendMessage({
|
|
1833
1845
|
Content: e.data,
|
|
1834
1846
|
SessionId: this.sessionId,
|
|
1835
|
-
Action:
|
|
1847
|
+
Action: W.SendMessage,
|
|
1836
1848
|
ModelId: this.config.model,
|
|
1837
1849
|
InteractionId: r.interactionId,
|
|
1838
1850
|
AgentId: (d = this.config.agentConfig) == null ? void 0 : d.id,
|
|
@@ -1844,11 +1856,11 @@ const Jt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1844
1856
|
AgentImplementation: (u = this.config.agentConfig) == null ? void 0 : u.agentImplementation,
|
|
1845
1857
|
Parameters: {
|
|
1846
1858
|
CustomerName: ((h = this.config.customer) == null ? void 0 : h.name) ?? "",
|
|
1847
|
-
DataSet: ((
|
|
1859
|
+
DataSet: ((C = this.config.customer) == null ? void 0 : C.dataSetId) ?? ""
|
|
1848
1860
|
},
|
|
1849
1861
|
// Forward image attachments as a structured payload (PascalCase
|
|
1850
1862
|
// keys to match the C# `Message.Images` / `MessageImage` model).
|
|
1851
|
-
Images: (
|
|
1863
|
+
Images: (p = e.images) != null && p.length ? e.images.map((M) => ({ MimeType: M.mimeType, Data: M.data })) : void 0,
|
|
1852
1864
|
// Client-only UI representation for this turn (PascalCase to match the C# `Message.UserUi`
|
|
1853
1865
|
// model). The server persists it as a UserUiContent sibling and strips it from the model
|
|
1854
1866
|
// request; Content remains the only model-facing text.
|
|
@@ -1859,9 +1871,9 @@ const Jt = "envision_agent_sessionId", V = class V extends G {
|
|
|
1859
1871
|
});
|
|
1860
1872
|
}
|
|
1861
1873
|
};
|
|
1862
|
-
g(
|
|
1863
|
-
let dt =
|
|
1864
|
-
const
|
|
1874
|
+
g(tt, "AgentGatewayWSAsync");
|
|
1875
|
+
let dt = tt;
|
|
1876
|
+
const et = class et {
|
|
1865
1877
|
constructor(t, e) {
|
|
1866
1878
|
a(this, "cache", /* @__PURE__ */ new Map());
|
|
1867
1879
|
a(this, "serverBaseUrl");
|
|
@@ -1916,17 +1928,17 @@ const tt = class tt {
|
|
|
1916
1928
|
}
|
|
1917
1929
|
}
|
|
1918
1930
|
};
|
|
1919
|
-
g(
|
|
1920
|
-
let ft =
|
|
1931
|
+
g(et, "HttpArtifactService");
|
|
1932
|
+
let ft = et;
|
|
1921
1933
|
export {
|
|
1922
|
-
|
|
1923
|
-
|
|
1934
|
+
H as A,
|
|
1935
|
+
G as E,
|
|
1924
1936
|
ft as H,
|
|
1925
|
-
|
|
1937
|
+
q as I,
|
|
1926
1938
|
ot as L,
|
|
1927
1939
|
ct as M,
|
|
1928
1940
|
ut as W,
|
|
1929
1941
|
dt as a,
|
|
1930
1942
|
te as u
|
|
1931
1943
|
};
|
|
1932
|
-
//# sourceMappingURL=httpArtifactService-
|
|
1944
|
+
//# sourceMappingURL=httpArtifactService-JtkC1T7n.js.map
|