@aintela/chat 0.3.0 → 0.3.1
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/README.md +14 -0
- package/dist/{atMentions-CCNBOf5W.js → atMentions-CnHuJKhX.js} +92 -87
- package/dist/atMentions-CnHuJKhX.js.map +1 -0
- package/dist/components.js +9274 -10531
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/{httpArtifactService-kXjuQtGa.js → httpArtifactService-Ba9xFy1E.js} +43 -27
- package/dist/httpArtifactService-Ba9xFy1E.js.map +1 -0
- package/dist/{httpSessionService-CMT6k-Nu.js → httpSessionService-DXlT2vxT.js} +33 -22
- package/dist/httpSessionService-DXlT2vxT.js.map +1 -0
- package/dist/index.js +231 -217
- package/dist/services.js +2 -2
- package/dist/src/components/AiChat/AiChatContext.d.ts +0 -3
- package/dist/src/components/AiChat/AiChatTypes.d.ts +0 -11
- package/dist/src/components/AiChat/ChatPane/ChatPane.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/MessageAgent.d.ts +0 -1
- package/dist/src/components/AiChat/ChatPane/MessagePart.d.ts +5 -3
- package/dist/src/components/AiChat/ChatPane/MessagePart.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/friendlyToolConfig.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/messageAgentThoughts.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/parts/uiToolDispatcher.test.d.ts +1 -0
- package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.test.d.ts +1 -0
- package/dist/src/components/AiChat/index.d.ts +1 -3
- package/dist/src/components/index.d.ts +0 -3
- package/dist/src/components/v2/AiChatFloating.d.ts +3 -0
- package/dist/src/components/v2/PromptV2.d.ts +21 -6
- package/dist/src/components/v2/PromptV2.test.d.ts +1 -0
- package/dist/src/components/v2/icons.d.ts +1 -0
- package/dist/src/components/v2/index.d.ts +25 -25
- package/dist/src/services/storageService.d.ts +18 -0
- package/dist/src/utils/urlParser.test.d.ts +1 -0
- package/dist/tests/fakes/fakeChatServices.d.ts +42 -0
- package/dist/{useChatSessions-CpHq0e1n.js → useChatSessions-1AAvAdPW.js} +2 -2
- package/dist/{useChatSessions-CpHq0e1n.js.map → useChatSessions-1AAvAdPW.js.map} +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/atMentions-CCNBOf5W.js.map +0 -1
- package/dist/httpArtifactService-kXjuQtGa.js.map +0 -1
- package/dist/httpSessionService-CMT6k-Nu.js.map +0 -1
- package/dist/src/components/AiChat/AiChatFloating.d.ts +0 -3
- package/dist/src/components/AiChat/ChatPane/LastPrompts.d.ts +0 -9
- package/dist/src/components/AiChat/ChatPane/Prompt.d.ts +0 -9
- package/dist/src/components/AiChat/ChatPane/SubAgentBox.d.ts +0 -9
- package/dist/src/components/AiChat/ChatPane/TaskList.d.ts +0 -6
- package/dist/src/components/v2/AiChatFloatingV2.d.ts +0 -3
package/dist/hooks.js
CHANGED
|
@@ -10,10 +10,10 @@ import { toMarkdown as kt } from "mdast-util-to-markdown";
|
|
|
10
10
|
import { format as At } from "date-fns";
|
|
11
11
|
import Pt from "lodash";
|
|
12
12
|
import { P as Nt, C as F } from "./Prompt-DZb7OaPp.js";
|
|
13
|
-
import { r as _t } from "./httpSessionService-
|
|
13
|
+
import { r as _t } from "./httpSessionService-DXlT2vxT.js";
|
|
14
14
|
const W = {
|
|
15
15
|
PROMPTS: "envision-prompts"
|
|
16
|
-
}, K = class K {
|
|
16
|
+
}, bt = 50, K = class K {
|
|
17
17
|
getPrompts() {
|
|
18
18
|
try {
|
|
19
19
|
const t = localStorage.getItem(W.PROMPTS);
|
|
@@ -22,12 +22,28 @@ const W = {
|
|
|
22
22
|
return console.error("Error loading prompts:", t), [];
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Record a sent prompt, most recent first, de-duplicated by text.
|
|
27
|
+
*
|
|
28
|
+
* Asking the same thing again MOVES that entry to the top rather than adding
|
|
29
|
+
* a second copy — the history is a list of distinct things you have asked,
|
|
30
|
+
* and a repeated question spending two of the twelve visible rows costs a
|
|
31
|
+
* suggestion for nothing. The repeat's own `id` and `created` win, because
|
|
32
|
+
* what the list orders by is when you last asked.
|
|
33
|
+
*
|
|
34
|
+
* The dedupe used to look only at `prompts[0]`, and then unshifted anyway:
|
|
35
|
+
* a consecutive repeat overwrote the older copy's id and timestamp AND
|
|
36
|
+
* appended a new row, so the same text appeared twice with the same id.
|
|
37
|
+
*
|
|
38
|
+
* Matching is exact on `promptText` (`PromptUtils.createPrompt` has already
|
|
39
|
+
* trimmed it). Two prompts differing only in case or inner whitespace stay
|
|
40
|
+
* separate entries — that is deliberate, not an oversight: normalising them
|
|
41
|
+
* would mean re-surfacing text the user never typed.
|
|
42
|
+
*/
|
|
25
43
|
storePrompt(t) {
|
|
26
44
|
try {
|
|
27
|
-
const e = this.getPrompts();
|
|
28
|
-
e.
|
|
29
|
-
const s = e.slice(0, 50);
|
|
30
|
-
localStorage.setItem(W.PROMPTS, JSON.stringify(s));
|
|
45
|
+
const e = this.getPrompts().filter((s) => s.promptText !== t.promptText);
|
|
46
|
+
e.unshift(t), localStorage.setItem(W.PROMPTS, JSON.stringify(e.slice(0, bt)));
|
|
31
47
|
} catch (e) {
|
|
32
48
|
console.error("Error storing prompt:", e);
|
|
33
49
|
}
|
|
@@ -42,7 +58,7 @@ const W = {
|
|
|
42
58
|
};
|
|
43
59
|
f(K, "LocalStorageService");
|
|
44
60
|
let at = K;
|
|
45
|
-
const
|
|
61
|
+
const Vt = /* @__PURE__ */ f((D) => {
|
|
46
62
|
const t = D.getPrompts(), e = t.length;
|
|
47
63
|
if (e > 0) {
|
|
48
64
|
const s = t[0].promptText, a = t[t.length - 1].promptText, n = t[0].created;
|
|
@@ -357,10 +373,10 @@ const Y = class Y extends q {
|
|
|
357
373
|
};
|
|
358
374
|
f(Y, "MockEventBusService");
|
|
359
375
|
let rt = Y;
|
|
360
|
-
const
|
|
376
|
+
const Rt = 2e3, gt = {
|
|
361
377
|
inline: "inline",
|
|
362
378
|
block: "block"
|
|
363
|
-
},
|
|
379
|
+
}, X = class X {
|
|
364
380
|
constructor() {
|
|
365
381
|
i(this, "parts", []);
|
|
366
382
|
i(this, "isLastGroup", !1);
|
|
@@ -380,9 +396,9 @@ const bt = 2e3, gt = {
|
|
|
380
396
|
i(this, "type", gt.inline);
|
|
381
397
|
}
|
|
382
398
|
};
|
|
383
|
-
f(
|
|
384
|
-
let x =
|
|
385
|
-
const
|
|
399
|
+
f(X, "InteractionPartGroup");
|
|
400
|
+
let x = X;
|
|
401
|
+
const j = class j {
|
|
386
402
|
constructor(t, e) {
|
|
387
403
|
i(this, "interaction");
|
|
388
404
|
i(this, "eventBusService");
|
|
@@ -464,7 +480,7 @@ ${n.value}
|
|
|
464
480
|
}, "clonePartsIfShared");
|
|
465
481
|
if (!l && (c == null ? void 0 : c.length) > 0 && (n != null && n.textAppendable)) {
|
|
466
482
|
const g = c[c.length - 1];
|
|
467
|
-
(((O = (y = g.thoughtDetails) == null ? void 0 : y.text) == null ? void 0 : O.length) ?? ((A = g.text) == null ? void 0 : A.length) ?? 0) >
|
|
483
|
+
(((O = (y = g.thoughtDetails) == null ? void 0 : y.text) == null ? void 0 : O.length) ?? ((A = g.text) == null ? void 0 : A.length) ?? 0) > Rt && (l = !0);
|
|
468
484
|
}
|
|
469
485
|
let p = !1;
|
|
470
486
|
if ((n == null ? void 0 : n.eventType) === T.FunctionClientOutput && !!((tt = n.functionDetails) != null && tt.id) && n) {
|
|
@@ -573,7 +589,7 @@ ${n.value}
|
|
|
573
589
|
} catch (E) {
|
|
574
590
|
console.error("Error here", E.toString());
|
|
575
591
|
}
|
|
576
|
-
g.textLastChunk = n.text ?? "", g.isStillWriting = !0, v = !0, n.thoughtDetails && g.thoughtDetails && (n.thoughtDetails.text.length >= 50 || n.thoughtDetails.text.length < 50 && n.thoughtDetails.text !== g.thoughtDetails.text) && (g.thoughtDetails = {
|
|
592
|
+
g.textLastChunk = n.text ?? "", g.isStillWriting = !0, v = !0, !p && n.thoughtDetails && g.thoughtDetails && (n.thoughtDetails.text.length >= 50 || n.thoughtDetails.text.length < 50 && n.thoughtDetails.text !== g.thoughtDetails.text) && (g.thoughtDetails = {
|
|
577
593
|
...g.thoughtDetails,
|
|
578
594
|
text: g.thoughtDetails.text + n.thoughtDetails.text
|
|
579
595
|
}, g.thoughtLastChunk = n.thoughtDetails.text);
|
|
@@ -615,9 +631,9 @@ ${n.value}
|
|
|
615
631
|
};
|
|
616
632
|
}
|
|
617
633
|
};
|
|
618
|
-
f(
|
|
619
|
-
let B =
|
|
620
|
-
const
|
|
634
|
+
f(j, "InteractionService");
|
|
635
|
+
let B = j;
|
|
636
|
+
const Ft = 1200 * 1e3, P = class P {
|
|
621
637
|
constructor(t, e, s, a, n, r, l, c, d, u = Tt.Interactive) {
|
|
622
638
|
i(this, "base_production_url", St() ?? "https://agent.tripapi.com.br");
|
|
623
639
|
i(this, "base_url_local", "http://localagent:8000");
|
|
@@ -991,7 +1007,7 @@ const Rt = 1200 * 1e3, P = class P {
|
|
|
991
1007
|
}), this.sessionState.setTurnOpen(!1);
|
|
992
1008
|
}
|
|
993
1009
|
async handlePing() {
|
|
994
|
-
return Date.now() - this.lastPing.getTime() >
|
|
1010
|
+
return Date.now() - this.lastPing.getTime() > Ft ? await this.ping() ? (this.lastPing = /* @__PURE__ */ new Date(), this.lastPingStatus = !0, !0) : (this.lastPingStatus = !1, !1) : (this.lastPingStatus = !0, !0);
|
|
995
1011
|
}
|
|
996
1012
|
async sendMessage(t, e) {
|
|
997
1013
|
let s = this.getInteractions().length, a = N.createWaiting(!0, !0, "Overall", /* @__PURE__ */ new Date());
|
|
@@ -1060,9 +1076,9 @@ const Rt = 1200 * 1e3, P = class P {
|
|
|
1060
1076
|
return `${this.msg_order}_${e}`;
|
|
1061
1077
|
}
|
|
1062
1078
|
};
|
|
1063
|
-
f(P, "AgentGatewayService"), i(P, "SUSPENSION_MSG", "SUSPEND"), i(P, "CURRENT_MSG_THROTTLE_MS",
|
|
1079
|
+
f(P, "AgentGatewayService"), i(P, "SUSPENSION_MSG", "SUSPEND"), i(P, "CURRENT_MSG_THROTTLE_MS", 150);
|
|
1064
1080
|
let G = P;
|
|
1065
|
-
const H = 4001,
|
|
1081
|
+
const H = 4001, Lt = 4002, ot = 4, Ut = 3, xt = 500, Bt = 3e4, Wt = 2, $t = 0.2, ct = 2, Q = class Q {
|
|
1066
1082
|
constructor(t = "ws://localhost:8000", e) {
|
|
1067
1083
|
i(this, "ws", null);
|
|
1068
1084
|
i(this, "stats");
|
|
@@ -1257,13 +1273,13 @@ const H = 4001, Ft = 4002, ot = 4, Lt = 3, Ut = 500, xt = 3e4, Bt = 2, Wt = 0.2,
|
|
|
1257
1273
|
* - 4000-4099 reserved for app-level fatal codes from the server
|
|
1258
1274
|
*/
|
|
1259
1275
|
shouldAttemptReconnect(t) {
|
|
1260
|
-
return !(this.intentionalDisconnect || t === H || t ===
|
|
1276
|
+
return !(this.intentionalDisconnect || t === H || t === Lt || t === 1e3 || t === 1008);
|
|
1261
1277
|
}
|
|
1262
1278
|
cancelPendingReconnect() {
|
|
1263
1279
|
this.reconnectTimer && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
|
|
1264
1280
|
}
|
|
1265
1281
|
computeBackoffDelay() {
|
|
1266
|
-
const t =
|
|
1282
|
+
const t = xt * Math.pow(Wt, this.reconnectAttempts), e = Math.min(t, Bt), s = e * $t * (Math.random() * 2 - 1);
|
|
1267
1283
|
return Math.max(0, Math.round(e + s));
|
|
1268
1284
|
}
|
|
1269
1285
|
scheduleReconnect(t, e, s) {
|
|
@@ -1548,7 +1564,7 @@ const H = 4001, Ft = 4002, ot = 4, Lt = 3, Ut = 500, xt = 3e4, Bt = 2, Wt = 0.2,
|
|
|
1548
1564
|
if (!a)
|
|
1549
1565
|
throw "Server event was null";
|
|
1550
1566
|
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, a.session_information && !a.subAgentId && (this.stats.sessionInformation = a.session_information), this.stats.elapsed = (Date.now() - this.stats.startTime.getTime()) / 1e3;
|
|
1551
|
-
const n = Date.now() - ot * 1e3, l = this.events.filter((c) => c[0] > n).reduce((c, d) => c += d[1], 0) /
|
|
1567
|
+
const n = Date.now() - ot * 1e3, l = this.events.filter((c) => c[0] > n).reduce((c, d) => c += d[1], 0) / Ut;
|
|
1552
1568
|
this.stats.tokensPerSecond = l / ot, this.flushStatsCoalesced(), this.onEvent && this.onEvent(a).catch((c) => {
|
|
1553
1569
|
console.error("Lost error on on-event", c);
|
|
1554
1570
|
});
|
|
@@ -1559,7 +1575,7 @@ const H = 4001, Ft = 4002, ot = 4, Lt = 3, Ut = 500, xt = 3e4, Bt = 2, Wt = 0.2,
|
|
|
1559
1575
|
};
|
|
1560
1576
|
f(Q, "WebSocketConnecionV2");
|
|
1561
1577
|
let lt = Q;
|
|
1562
|
-
const
|
|
1578
|
+
const qt = "envision_agent_sessionId", Z = class Z extends G {
|
|
1563
1579
|
constructor(e, s, a, n, r, l, c, d, u, h, C) {
|
|
1564
1580
|
super(e, s, a, n, r, l, c, u, C);
|
|
1565
1581
|
i(this, "suspendState", !1);
|
|
@@ -1611,7 +1627,7 @@ const $t = "envision_agent_sessionId", Z = class Z extends G {
|
|
|
1611
1627
|
return this.suspendState;
|
|
1612
1628
|
}
|
|
1613
1629
|
getStoredSessionId() {
|
|
1614
|
-
const e = localStorage.getItem(
|
|
1630
|
+
const e = localStorage.getItem(qt);
|
|
1615
1631
|
if (e)
|
|
1616
1632
|
return e;
|
|
1617
1633
|
}
|
|
@@ -1814,6 +1830,6 @@ export {
|
|
|
1814
1830
|
rt as M,
|
|
1815
1831
|
lt as W,
|
|
1816
1832
|
ht as a,
|
|
1817
|
-
|
|
1833
|
+
Vt as u
|
|
1818
1834
|
};
|
|
1819
|
-
//# sourceMappingURL=httpArtifactService-
|
|
1835
|
+
//# sourceMappingURL=httpArtifactService-Ba9xFy1E.js.map
|