@aintela/chat 0.14.3 → 0.14.5
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 +3946 -3922
- package/dist/components.js.map +1 -1
- package/dist/{detachedRunActivity-B85--SdS.js → detachedRunActivity-Cf-RPK9j.js} +41 -7
- package/dist/detachedRunActivity-Cf-RPK9j.js.map +1 -0
- package/dist/index.js +224 -222
- package/dist/services.js +1 -1
- package/dist/src/components/AiChat/ChatPane/AskUserDialog.d.ts +2 -2
- package/dist/src/components/AiChat/ChatPane/FriendlyPartDisplay.d.ts +2 -0
- package/dist/src/components/AiChat/ChatPane/friendlyToolConfig.d.ts +27 -1
- package/dist/src/components/AiChat/ChatPane/parts/askUserPartStrings.test.d.ts +1 -0
- package/dist/src/components/index.d.ts +2 -1
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +14 -0
- package/dist/src/services/servers/gatewaySessionSwitch.test.d.ts +1 -0
- package/package.json +3 -3
- package/dist/detachedRunActivity-B85--SdS.js.map +0 -1
|
@@ -89,7 +89,13 @@ const d = new V(), ae = class ae {
|
|
|
89
89
|
callListeners(e, ...t) {
|
|
90
90
|
const s = this.listeners[e];
|
|
91
91
|
if (s) {
|
|
92
|
-
const n = s.map((r) =>
|
|
92
|
+
const n = s.map((r) => {
|
|
93
|
+
try {
|
|
94
|
+
return r(...t);
|
|
95
|
+
} catch (o) {
|
|
96
|
+
return Promise.reject(o);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
93
99
|
Promise.all(n).catch((r) => {
|
|
94
100
|
console.error(`Lost error in one of the listeners of the event: ${e}, listeners: ${s.length}, error: ${r}`, s);
|
|
95
101
|
});
|
|
@@ -1163,7 +1169,29 @@ const y = class y {
|
|
|
1163
1169
|
* session is never swapped for another.
|
|
1164
1170
|
*/
|
|
1165
1171
|
async openConnection(e, t) {
|
|
1166
|
-
return this.connection.open(e, t);
|
|
1172
|
+
return this.isSessionSwitch(e) && this.forgetSession(), this.connection.open(e, t);
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Opening `sessionId` leaves the session this gateway is on: a different id, or a fresh session (undefined) while
|
|
1176
|
+
* one is held. Re-opening the same session (a resume, a redial) is not a switch, and neither is the first open.
|
|
1177
|
+
*/
|
|
1178
|
+
isSessionSwitch(e) {
|
|
1179
|
+
return this.sessionId === void 0 ? !1 : e === void 0 || e !== this.sessionId;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Drop every piece of per-session turn state (AIA Issue 2261). The store's transcript is reset by the session
|
|
1183
|
+
* record's bind, but the gateway is not: a turn of the previous conversation still open here (an `ask_user` card
|
|
1184
|
+
* parked at its end, say) used to survive the switch, and the next conversation's first turn-complete handed the
|
|
1185
|
+
* live message over to it — conversation A's question rendered in B, under B's agent, with A's timestamp. The
|
|
1186
|
+
* status bubble of B's first send was a clone of A's interaction for the same reason, and a paused A merged B's
|
|
1187
|
+
* first message into A's interaction id. Nothing here belongs to the next session, so none of it is carried over.
|
|
1188
|
+
*/
|
|
1189
|
+
forgetSession() {
|
|
1190
|
+
this.liveMessage.cancelPending(), this.openTurns.clear(), this.currentIS = null, this.suspendState = !1, this.interactionsMap.clear(), this.interactionsServiceMap.clear(), this.interactionCallIds.clear(), this.committedTurns.clear(), this.localInteractionIds.clear();
|
|
1191
|
+
const e = [...this.queuedMessages.keys()];
|
|
1192
|
+
this.queuedMessages.clear(), e.length > 0 && this.sessionState.removeQueuedMessages(e);
|
|
1193
|
+
for (const t of this.pendingAnnouncements) this.announceRequested.delete(t.key);
|
|
1194
|
+
this.pendingAnnouncements = [], this.sessionState.setLastToolEvent(null), this.sessionState.setCurrentMessage(null), this.sessionState.setTurnOpen(!1);
|
|
1167
1195
|
}
|
|
1168
1196
|
async closeConnection(e = !0) {
|
|
1169
1197
|
try {
|
|
@@ -1213,10 +1241,16 @@ const y = class y {
|
|
|
1213
1241
|
try {
|
|
1214
1242
|
const { promptAsString: r, json: o } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(e.data) : { promptAsString: e.data, json: void 0 };
|
|
1215
1243
|
this.sessionState.onRenderPrompt && (e.data = o, e.friendlyMessage = r);
|
|
1216
|
-
const c = await this.sendMessageInternal(e, t)
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1244
|
+
const c = await this.sendMessageInternal(e, t);
|
|
1245
|
+
try {
|
|
1246
|
+
const l = He.createPrompt(r ?? "", (o == null ? void 0 : o.toString()) ?? {});
|
|
1247
|
+
this.storageService.storePrompt(l);
|
|
1248
|
+
const f = _.fromText("Planejando próximos passos");
|
|
1249
|
+
this.sendStatusMessage(e.data, [n, f], s.toString() + "1"), c != null && c.success ? this.eventBusService.ChatEmitMessageSent(e.data, c.interaction) : this.eventBusService.ChatEmitMessageError((c == null ? void 0 : c.error) ?? "");
|
|
1250
|
+
} catch (l) {
|
|
1251
|
+
console.error("[AgentGateway] the message was sent, but what follows the send failed", l);
|
|
1252
|
+
}
|
|
1253
|
+
return c;
|
|
1220
1254
|
} catch (r) {
|
|
1221
1255
|
const o = r instanceof Error ? r.message : String(r ?? "");
|
|
1222
1256
|
return this.liveMessage.cancelPending(), this.sessionState.setCurrentMessage(null), this.sessionState.setTurnOpen(this.openTurns.size > 0), this.eventBusService.ChatEmitMessageError(o), {
|
|
@@ -2379,4 +2413,4 @@ export {
|
|
|
2379
2413
|
yt as t,
|
|
2380
2414
|
xt as u
|
|
2381
2415
|
};
|
|
2382
|
-
//# sourceMappingURL=detachedRunActivity-
|
|
2416
|
+
//# sourceMappingURL=detachedRunActivity-Cf-RPK9j.js.map
|