@aintela/chat 0.12.0 → 0.13.0
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 +2211 -2253
- package/dist/components.js.map +1 -1
- package/dist/{detachedRunActivity-CCrlilHK.js → detachedRunActivity-Do_FRA34.js} +50 -30
- package/dist/detachedRunActivity-Do_FRA34.js.map +1 -0
- package/dist/hooks.js +1 -1
- package/dist/{httpSessionService-BLiZMoLb.js → httpSessionService-Cgf8uqMk.js} +2 -2
- package/dist/{httpSessionService-BLiZMoLb.js.map → httpSessionService-Cgf8uqMk.js.map} +1 -1
- package/dist/index.js +4 -4
- package/dist/models.js +1 -1
- package/dist/{serializer-DvfyE4_t.js → serializer-CdIQS0hy.js} +70 -68
- package/dist/serializer-CdIQS0hy.js.map +1 -0
- package/dist/services.js +2 -2
- package/dist/src/components/AiChat/aiChatEngine.d.ts +6 -0
- package/dist/src/components/LlmResponseRender/LiveJsxBlock.d.ts +8 -0
- package/dist/src/components/LlmResponseRender/LlmResponseRender.d.ts +10 -5
- package/dist/src/components/LlmResponseRender/noInPageEval.test.d.ts +1 -0
- package/dist/src/components/LlmResponseRender/parseBlocks.d.ts +19 -21
- package/dist/src/models/enums.d.ts +3 -1
- package/dist/src/services/WebSocketConnection/webSocketConnection.d.ts +3 -0
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +20 -3
- package/dist/{useChatSessions-BI3bHoOh.js → useChatSessions-DbU4PVLf.js} +2 -2
- package/dist/{useChatSessions-BI3bHoOh.js.map → useChatSessions-DbU4PVLf.js.map} +1 -1
- package/package.json +1 -1
- package/dist/detachedRunActivity-CCrlilHK.js.map +0 -1
- package/dist/serializer-DvfyE4_t.js.map +0 -1
|
@@ -2,12 +2,12 @@ var we = Object.defineProperty;
|
|
|
2
2
|
var be = (i, e, t) => e in i ? we(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var h = (i, e) => we(i, "name", { value: e, configurable: !0 });
|
|
4
4
|
var a = (i, e, t) => be(i, typeof e != "symbol" ? e + "" : e, t);
|
|
5
|
-
import { i as U, E as I, S as q, z as Se, C as
|
|
5
|
+
import { i as U, E as I, S as q, z as Se, C as L, j as Le, L as Pe, P as z, n as Fe, q as Ne, T as _e, o as Ue, s as te, B as qe } from "./serializer-CdIQS0hy.js";
|
|
6
6
|
import { format as xe } from "date-fns";
|
|
7
7
|
import We from "lodash";
|
|
8
8
|
import { C as E, P as Be } from "./Prompt-DZb7OaPp.js";
|
|
9
9
|
import { d as Ge } from "./environmentUtils-VZNTCzEE.js";
|
|
10
|
-
import { r as ze } from "./httpSessionService-
|
|
10
|
+
import { r as ze } from "./httpSessionService-Cgf8uqMk.js";
|
|
11
11
|
const K = {
|
|
12
12
|
PROMPTS: "envision-prompts"
|
|
13
13
|
}, He = 50, ne = class ne {
|
|
@@ -693,7 +693,7 @@ const y = class y {
|
|
|
693
693
|
*/
|
|
694
694
|
a(this, "queuedMessages", /* @__PURE__ */ new Map());
|
|
695
695
|
a(this, "options");
|
|
696
|
-
/** Announcements asked for in this tab, by `runId|settleKey` — a
|
|
696
|
+
/** Announcements asked for in this tab, by `runId|settleKey` (or `host|source|key`) — a repeat is a no-op. */
|
|
697
697
|
a(this, "announceRequested", /* @__PURE__ */ new Set());
|
|
698
698
|
/** Announcements waiting for the chat to be idle (no open turn) and connected, in request order. */
|
|
699
699
|
a(this, "pendingAnnouncements", []);
|
|
@@ -1180,7 +1180,7 @@ const y = class y {
|
|
|
1180
1180
|
throw "no wsService created";
|
|
1181
1181
|
if (!((o = this.config.agentConfig) != null && o.id))
|
|
1182
1182
|
throw "Agent not selected";
|
|
1183
|
-
return this.sessionState.setLastActivity(), await this.ensureConnected(), this.wsService.sendMessage(this.messageFrame(
|
|
1183
|
+
return this.sessionState.setLastActivity(), await this.ensureConnected(), this.wsService.sendMessage(this.messageFrame(L.SendMessage, e, n.interactionId)), this.localOpen(n.interactionId, "system"), {
|
|
1184
1184
|
interaction: n,
|
|
1185
1185
|
success: !0
|
|
1186
1186
|
};
|
|
@@ -1210,7 +1210,7 @@ const y = class y {
|
|
|
1210
1210
|
this.queuedMessages.set(s, t), this.sessionState.addQueuedMessage({ interactionId: s, text: t });
|
|
1211
1211
|
try {
|
|
1212
1212
|
if (!((r = this.config.agentConfig) != null && r.id)) throw new Error("Agent not selected");
|
|
1213
|
-
return this.sessionState.setLastActivity(), await this.ensureConnected(), this.wsService.sendMessage(this.messageFrame(
|
|
1213
|
+
return this.sessionState.setLastActivity(), await this.ensureConnected(), this.wsService.sendMessage(this.messageFrame(L.QueueMessage, { ...e, images: void 0, userUi: void 0 }, s)), this.eventBusService.ChatEmitMessageSent(e.data, n), { success: !0, interaction: n };
|
|
1214
1214
|
} catch (o) {
|
|
1215
1215
|
const c = o instanceof Error ? o.message : String(o ?? "");
|
|
1216
1216
|
return this.queuedMessages.delete(s), this.sessionState.removeQueuedMessages([s]), this.eventBusService.ChatEmitMessageError(c), { success: !1, error: c, interaction: n };
|
|
@@ -1286,8 +1286,29 @@ const y = class y {
|
|
|
1286
1286
|
* is a no-op, a resumed run that settles anew is announced again.</p>
|
|
1287
1287
|
*/
|
|
1288
1288
|
async announceDetachedRun(e, t) {
|
|
1289
|
-
|
|
1290
|
-
|
|
1289
|
+
return this.requestAnnouncement({
|
|
1290
|
+
key: `${e}|${t ?? ""}`,
|
|
1291
|
+
label: `run ${e}`,
|
|
1292
|
+
frame: { Action: L.AnnounceDetachedRun, DetachedRunId: e }
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Ask the server to tell this conversation that something the HOST ran in the background has finished — a batch
|
|
1297
|
+
* job, an import: the `AnnounceHostEvent` socket action. `source` names the host's announcement source and `key`
|
|
1298
|
+
* what finished; the source claims it (one tab wins, a repeat is refused) and supplies the words of an ordinary
|
|
1299
|
+
* `origin: platform` turn on this socket. Same rules as {@link announceDetachedRun}: never over an open turn, and
|
|
1300
|
+
* a repeated request for the same `(source, key, settleKey)` in this tab is a no-op — pass when the work finished
|
|
1301
|
+
* as `settleKey`, so work that is re-run and finishes again is announced again.
|
|
1302
|
+
*/
|
|
1303
|
+
async announceHostEvent(e, t, s) {
|
|
1304
|
+
return this.requestAnnouncement({
|
|
1305
|
+
key: `host|${e}|${t}|${s ?? ""}`,
|
|
1306
|
+
label: `${e} ${t}`,
|
|
1307
|
+
frame: { Action: L.AnnounceHostEvent, AnnouncementSource: e, AnnouncementKey: t }
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
async requestAnnouncement(e) {
|
|
1311
|
+
return this.announceRequested.has(e.key) ? "duplicate" : (this.announceRequested.add(e.key), this.pendingAnnouncements.push(e), await this.flushAnnouncements(), this.pendingAnnouncements.includes(e) ? "queued" : "sent");
|
|
1291
1312
|
}
|
|
1292
1313
|
/** Send the queued announcements, oldest first, while the chat is idle and the socket is open. */
|
|
1293
1314
|
async flushAnnouncements() {
|
|
@@ -1298,24 +1319,23 @@ const y = class y {
|
|
|
1298
1319
|
for (; this.pendingAnnouncements.length > 0 && !this.sessionState.turnOpen; ) {
|
|
1299
1320
|
const s = (e = this.wsService.sendBaseMessage) == null ? void 0 : e.bind(this.wsService);
|
|
1300
1321
|
if (!s) {
|
|
1301
|
-
console.warn("[AgentGateway] transport cannot send an
|
|
1322
|
+
console.warn("[AgentGateway] transport cannot send an announcement request; it stays queued");
|
|
1302
1323
|
return;
|
|
1303
1324
|
}
|
|
1304
1325
|
if (!this.wsService.isConnected() || !this.sessionId) return;
|
|
1305
1326
|
const n = this.pendingAnnouncements[0];
|
|
1306
1327
|
try {
|
|
1307
1328
|
s({
|
|
1308
|
-
|
|
1329
|
+
...n.frame,
|
|
1309
1330
|
AgentId: ((t = this.config.agentConfig) == null ? void 0 : t.id) ?? "",
|
|
1310
|
-
InteractionId: `announce_${
|
|
1311
|
-
SessionId: this.sessionId
|
|
1312
|
-
DetachedRunId: n
|
|
1331
|
+
InteractionId: `announce_${Date.now()}`,
|
|
1332
|
+
SessionId: this.sessionId
|
|
1313
1333
|
});
|
|
1314
1334
|
} catch (r) {
|
|
1315
|
-
console.warn(`[AgentGateway]
|
|
1335
|
+
console.warn(`[AgentGateway] the announcement of ${n.label} could not be sent; it stays queued`, r);
|
|
1316
1336
|
return;
|
|
1317
1337
|
}
|
|
1318
|
-
this.pendingAnnouncements.shift(), console.log(`[AgentGateway] asked for the announcement of
|
|
1338
|
+
this.pendingAnnouncements.shift(), console.log(`[AgentGateway] asked for the announcement of ${n.label} (session ${this.sessionId}).`);
|
|
1319
1339
|
}
|
|
1320
1340
|
} finally {
|
|
1321
1341
|
this.flushingAnnouncements = !1;
|
|
@@ -1443,7 +1463,7 @@ function ve(i, e, t, s) {
|
|
|
1443
1463
|
};
|
|
1444
1464
|
}
|
|
1445
1465
|
h(ve, "entry");
|
|
1446
|
-
const Ee = 4, dt = 3, ft = 20,
|
|
1466
|
+
const Ee = 4, dt = 3, ft = 20, F = class F {
|
|
1447
1467
|
constructor() {
|
|
1448
1468
|
a(this, "stats");
|
|
1449
1469
|
a(this, "onFlush");
|
|
@@ -1491,18 +1511,18 @@ const Ee = 4, dt = 3, ft = 20, P = class P {
|
|
|
1491
1511
|
flushCoalesced() {
|
|
1492
1512
|
if (!this.onFlush) return;
|
|
1493
1513
|
const e = Date.now(), t = e - this.lastFlushed;
|
|
1494
|
-
if (t >=
|
|
1514
|
+
if (t >= F.STATS_FLUSH_MS) {
|
|
1495
1515
|
this.flushTimer && (clearTimeout(this.flushTimer), this.flushTimer = null), this.lastFlushed = e, this.onFlush({ ...this.stats });
|
|
1496
1516
|
return;
|
|
1497
1517
|
}
|
|
1498
1518
|
this.flushTimer || (this.flushTimer = setTimeout(() => {
|
|
1499
1519
|
var s;
|
|
1500
1520
|
this.flushTimer = null, this.lastFlushed = Date.now(), (s = this.onFlush) == null || s.call(this, { ...this.stats });
|
|
1501
|
-
},
|
|
1521
|
+
}, F.STATS_FLUSH_MS - t));
|
|
1502
1522
|
}
|
|
1503
1523
|
};
|
|
1504
|
-
h(
|
|
1505
|
-
let ee =
|
|
1524
|
+
h(F, "StreamStatsTracker"), a(F, "STATS_FLUSH_MS", 120);
|
|
1525
|
+
let ee = F;
|
|
1506
1526
|
const gt = 5e3, pt = 3e4, Y = 1e4, le = class le {
|
|
1507
1527
|
constructor(e = "ws://localhost:8000", t) {
|
|
1508
1528
|
a(this, "ws", null);
|
|
@@ -1720,7 +1740,7 @@ const gt = 5e3, pt = 3e4, Y = 1e4, le = class le {
|
|
|
1720
1740
|
}
|
|
1721
1741
|
suspendStream() {
|
|
1722
1742
|
this.sendBaseMessage({
|
|
1723
|
-
Action:
|
|
1743
|
+
Action: L.Suspend,
|
|
1724
1744
|
AgentId: "",
|
|
1725
1745
|
InteractionId: "",
|
|
1726
1746
|
ModelId: ""
|
|
@@ -1739,7 +1759,7 @@ const gt = 5e3, pt = 3e4, Y = 1e4, le = class le {
|
|
|
1739
1759
|
*/
|
|
1740
1760
|
answerHumanTool(e, t) {
|
|
1741
1761
|
const s = {
|
|
1742
|
-
Action:
|
|
1762
|
+
Action: L.AnswerHumanTool,
|
|
1743
1763
|
AgentId: "",
|
|
1744
1764
|
InteractionId: "",
|
|
1745
1765
|
ToolCallId: e,
|
|
@@ -1766,7 +1786,7 @@ const gt = 5e3, pt = 3e4, Y = 1e4, le = class le {
|
|
|
1766
1786
|
}
|
|
1767
1787
|
try {
|
|
1768
1788
|
this.sendBaseMessage({
|
|
1769
|
-
Action:
|
|
1789
|
+
Action: L.AnswerHumanTool,
|
|
1770
1790
|
AgentId: "",
|
|
1771
1791
|
InteractionId: "",
|
|
1772
1792
|
ToolCallId: s.toolCallId,
|
|
@@ -1968,9 +1988,9 @@ const ue = class ue extends Error {
|
|
|
1968
1988
|
}
|
|
1969
1989
|
};
|
|
1970
1990
|
h(ue, "DetachedRunFramesHttpError");
|
|
1971
|
-
let
|
|
1991
|
+
let P = ue;
|
|
1972
1992
|
function mt(i) {
|
|
1973
|
-
if (i instanceof
|
|
1993
|
+
if (i instanceof P) {
|
|
1974
1994
|
const { status: e } = i;
|
|
1975
1995
|
return { kind: e === 401 ? "unauthorized" : e === 403 ? "forbidden" : e === 404 || e === 410 ? "notFound" : "gaveUp", status: e, cause: i };
|
|
1976
1996
|
}
|
|
@@ -2055,11 +2075,11 @@ async function yt(i) {
|
|
|
2055
2075
|
C = !0;
|
|
2056
2076
|
continue;
|
|
2057
2077
|
}
|
|
2058
|
-
throw new
|
|
2078
|
+
throw new P(401);
|
|
2059
2079
|
}
|
|
2060
2080
|
if (C = !1, !k.ok)
|
|
2061
|
-
throw St(k.status) ? new Error(`GET detached-run frames answered ${k.status}`) : new
|
|
2062
|
-
if (!k.body) throw new
|
|
2081
|
+
throw St(k.status) ? new Error(`GET detached-run frames answered ${k.status}`) : new P(k.status);
|
|
2082
|
+
if (!k.body) throw new P(k.status, "The frames response has no readable body");
|
|
2063
2083
|
o == null || o();
|
|
2064
2084
|
let W = !1;
|
|
2065
2085
|
const B = wt((T) => {
|
|
@@ -2104,7 +2124,7 @@ async function yt(i) {
|
|
|
2104
2124
|
A = new Error(l === "session" ? "The session frames stream closed" : "The frames stream closed before its end event");
|
|
2105
2125
|
} catch (O) {
|
|
2106
2126
|
if (s != null && s.aborted) break;
|
|
2107
|
-
if (O instanceof
|
|
2127
|
+
if (O instanceof P) throw O;
|
|
2108
2128
|
A = O;
|
|
2109
2129
|
}
|
|
2110
2130
|
if (w += 1, w >= u) throw A;
|
|
@@ -2277,7 +2297,7 @@ h(Et, "parseTodoList");
|
|
|
2277
2297
|
export {
|
|
2278
2298
|
ye as A,
|
|
2279
2299
|
V as C,
|
|
2280
|
-
|
|
2300
|
+
P as D,
|
|
2281
2301
|
Te as E,
|
|
2282
2302
|
Ce as H,
|
|
2283
2303
|
_ as I,
|
|
@@ -2295,4 +2315,4 @@ export {
|
|
|
2295
2315
|
mt as t,
|
|
2296
2316
|
Rt as u
|
|
2297
2317
|
};
|
|
2298
|
-
//# sourceMappingURL=detachedRunActivity-
|
|
2318
|
+
//# sourceMappingURL=detachedRunActivity-Do_FRA34.js.map
|