@aintela/chat 0.5.2 → 0.6.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/README.md +3 -3
- package/dist/Memory-BUnmYGNv.js +37 -0
- package/dist/Memory-BUnmYGNv.js.map +1 -0
- package/dist/components.js +4855 -4618
- package/dist/components.js.map +1 -1
- package/dist/detachedRunModel-1ii9qGTW.js +50 -0
- package/dist/detachedRunModel-1ii9qGTW.js.map +1 -0
- package/dist/hooks.js +1 -1
- package/dist/{httpArtifactService-EEhF_mp9.js → httpArtifactService-DYQDPVVH.js} +61 -61
- package/dist/httpArtifactService-DYQDPVVH.js.map +1 -0
- package/dist/{httpSessionService-wBby4ggl.js → httpSessionService-BY7JeW8d.js} +2 -2
- package/dist/{httpSessionService-wBby4ggl.js.map → httpSessionService-BY7JeW8d.js.map} +1 -1
- package/dist/index.js +252 -246
- package/dist/models.js +35 -34
- package/dist/{serializer-CC-nM3ig.js → serializer-BNsp8xs2.js} +161 -161
- package/dist/serializer-BNsp8xs2.js.map +1 -0
- package/dist/services.js +2 -2
- package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.d.ts +1 -1
- package/dist/src/components/AiChat/ChatPane/verbosity.d.ts +8 -1
- package/dist/src/components/AiChat/ChatPane/verbosityContentTools.test.d.ts +1 -0
- package/dist/src/components/AiChat/index.d.ts +1 -1
- package/dist/src/components/AiChat/stateConfiguration.d.ts +5 -5
- package/dist/src/components/index.d.ts +2 -2
- package/dist/src/components/v2/{SubAgentBoxV2.d.ts → DetachedRunBoxV2.d.ts} +6 -6
- package/dist/src/components/v2/DetachedRunTaskBox.d.ts +43 -0
- package/dist/src/components/v2/DetachedRunTaskBox.test.d.ts +1 -0
- package/dist/src/components/v2/index.d.ts +4 -2
- package/dist/src/components/v2/toolCategories.d.ts +1 -1
- package/dist/src/models/ServerEvent.d.ts +3 -3
- package/dist/src/models/detachedRunModel.d.ts +48 -0
- package/dist/src/models/detachedRunModel.test.d.ts +1 -0
- package/dist/src/models/index.d.ts +2 -2
- package/dist/src/models/semanticKernelModel/models.d.ts +5 -5
- package/dist/src/services/WebSocketConnection/streamStats.d.ts +2 -2
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +5 -5
- package/dist/src/services/wire/decodeFrame.d.ts +1 -1
- package/dist/tests/fixtures.d.ts +8 -8
- package/dist/{useChatSessions-C6sYF4U6.js → useChatSessions-Q41Jmr6P.js} +2 -2
- package/dist/{useChatSessions-C6sYF4U6.js.map → useChatSessions-Q41Jmr6P.js.map} +1 -1
- package/package.json +1 -1
- package/dist/ClientMessage-DUby3KyC.js +0 -34
- package/dist/ClientMessage-DUby3KyC.js.map +0 -1
- package/dist/Memory-CjrYSkzB.js +0 -47
- package/dist/Memory-CjrYSkzB.js.map +0 -1
- package/dist/httpArtifactService-EEhF_mp9.js.map +0 -1
- package/dist/serializer-CC-nM3ig.js.map +0 -1
- package/dist/src/models/subAgentModel.d.ts +0 -48
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var r = Object.defineProperty;
|
|
2
|
+
var f = (e, i, t) => i in e ? r(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
|
|
3
|
+
var s = (e, i) => r(e, "name", { value: i, configurable: !0 });
|
|
4
|
+
var a = (e, i, t) => f(e, typeof i != "symbol" ? i + "" : i, t);
|
|
5
|
+
const n = class n {
|
|
6
|
+
constructor(i, t, c, d, o) {
|
|
7
|
+
a(this, "mimeType");
|
|
8
|
+
a(this, "data");
|
|
9
|
+
a(this, "friendlyMessage");
|
|
10
|
+
a(this, "fake");
|
|
11
|
+
/**
|
|
12
|
+
* Optional image attachments that travel as a structured payload
|
|
13
|
+
* on the WS frame (see `IMessage.Images`). Kept separate from
|
|
14
|
+
* `data` so we don't have to encode them into the text body — the
|
|
15
|
+
* server adds them as `ImageContent` entries on the user turn.
|
|
16
|
+
*/
|
|
17
|
+
a(this, "images");
|
|
18
|
+
/**
|
|
19
|
+
* Optional client-only UI representation for this user turn. Carried to the
|
|
20
|
+
* server as a `UserUiContent` sibling (persisted + replayed) but stripped from
|
|
21
|
+
* every model request — `data` stays the only model-facing text. `args` is a
|
|
22
|
+
* serialized JSON string. The gateway also injects a matching `UserAnswer` part
|
|
23
|
+
* on the live interaction so the component renders immediately.
|
|
24
|
+
*/
|
|
25
|
+
a(this, "userUi");
|
|
26
|
+
this.data = i, this.mimeType = t, this.friendlyMessage = d, this.fake = c, this.images = o;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
s(n, "ClientMessage");
|
|
30
|
+
let u = n;
|
|
31
|
+
const l = [
|
|
32
|
+
"Completed",
|
|
33
|
+
"Failed",
|
|
34
|
+
"Cancelled"
|
|
35
|
+
];
|
|
36
|
+
function h(e) {
|
|
37
|
+
return e ? l.includes(e) : !1;
|
|
38
|
+
}
|
|
39
|
+
s(h, "isDetachedRunTerminalStatus");
|
|
40
|
+
function T(e) {
|
|
41
|
+
return e === "WaitingForInput";
|
|
42
|
+
}
|
|
43
|
+
s(T, "isDetachedRunWaitingForInput");
|
|
44
|
+
export {
|
|
45
|
+
u as C,
|
|
46
|
+
l as D,
|
|
47
|
+
T as a,
|
|
48
|
+
h as i
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=detachedRunModel-1ii9qGTW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachedRunModel-1ii9qGTW.js","sources":["../src/models/ClientMessage.ts","../src/models/detachedRunModel.ts"],"sourcesContent":["/**\n * A single image attachment carried alongside a ClientMessage. `data`\n * is the raw base64 payload (no `data:<mime>;base64,` prefix) so the\n * server can `Convert.FromBase64String` directly into bytes.\n */\nexport interface ClientMessageImage {\n mimeType: string;\n data: string;\n}\n\nexport class ClientMessage {\n mimeType: string;\n data: string;\n friendlyMessage?: string;\n fake?: boolean;\n /**\n * Optional image attachments that travel as a structured payload\n * on the WS frame (see `IMessage.Images`). Kept separate from\n * `data` so we don't have to encode them into the text body — the\n * server adds them as `ImageContent` entries on the user turn.\n */\n images?: ClientMessageImage[];\n\n /**\n * Optional client-only UI representation for this user turn. Carried to the\n * server as a `UserUiContent` sibling (persisted + replayed) but stripped from\n * every model request — `data` stays the only model-facing text. `args` is a\n * serialized JSON string. The gateway also injects a matching `UserAnswer` part\n * on the live interaction so the component renders immediately.\n */\n userUi?: { name: string; args?: string };\n\n constructor(data: string, mimeType: string, fake?: boolean, friendlyMessage?: string, images?: ClientMessageImage[]) {\n this.data = data;\n this.mimeType = mimeType;\n this.friendlyMessage = friendlyMessage;\n this.fake = fake;\n this.images = images;\n }\n}","import type { TodoList } from './todoListModel';\n\n/**\n * Mirrors the SDK's `AIA.Agents.Models.Agent.AgentStatus` enum. Values come back as plain strings (the\n * record keeps `Status.ToString()`).\n *\n * `WaitingForInput` (AIntelA.Agents ≥ 0.20): the run stopped to ask a question and nothing is executing.\n * It is NOT terminal — the task resumes when an answer arrives — so a poller should keep watching it.\n */\nexport type DetachedRunStatus =\n | 'Pending'\n | 'Running'\n | 'WaitingForInput'\n | 'Completed'\n | 'Failed'\n | 'Cancelled'\n | 'Unknown';\n\n/**\n * Why a settled run stopped — the SDK's `StopReason`. Absent while a run is active and on records written\n * before the SDK had it.\n */\nexport type DetachedRunStopReason =\n | 'Concluded'\n | 'NeedsInput'\n | 'EndedWithoutConclusion'\n | 'Cancelled'\n | 'Failed';\n\n/**\n * A detached run as the Agents SDK's REST surface returns it (`GET /detached-runs`, `GET /detached-runs/{id}`):\n * the state a client draws — a task box, a page of runs.\n *\n * `percentComplete` is 0–100 (null while the run has no task list). `conclusion` is the run's structured\n * conclusion as raw JSON, in the task's own format.\n */\nexport interface DetachedRunView {\n id: string;\n name: string;\n agentId: string;\n status: DetachedRunStatus | string;\n stopReason?: DetachedRunStopReason | string | null;\n todoList?: TodoList | null;\n percentComplete?: number | null;\n currentStep?: string | null;\n error?: string | null;\n hasConclusion: boolean;\n conclusion?: string | null;\n parentSessionId: string;\n sessionId: string;\n cancelRequested: boolean;\n created?: string | null;\n updatedAt?: string | null;\n settledAt?: string | null;\n}\n\n/**\n * Status values after which the detached run will never change again. `WaitingForInput` is deliberately absent:\n * the run has stopped, but the task resumes when its question is answered.\n */\nexport const DETACHED_RUN_TERMINAL_STATUSES: ReadonlyArray<DetachedRunStatus> = [\n 'Completed',\n 'Failed',\n 'Cancelled',\n];\n\nexport function isDetachedRunTerminalStatus(status: string | undefined | null): boolean {\n if (!status) return false;\n return (DETACHED_RUN_TERMINAL_STATUSES as readonly string[]).includes(status);\n}\n\n/** True when the task stopped to ask a question and is waiting for an answer. */\nexport function isDetachedRunWaitingForInput(status: string | undefined | null): boolean {\n return status === 'WaitingForInput';\n}\n"],"names":["_ClientMessage","data","mimeType","fake","friendlyMessage","images","__publicField","__name","ClientMessage","DETACHED_RUN_TERMINAL_STATUSES","isDetachedRunTerminalStatus","status","isDetachedRunWaitingForInput"],"mappings":";;;;AAUO,MAAMA,IAAN,MAAMA,EAAc;AAAA,EAsBzB,YAAYC,GAAcC,GAAkBC,GAAgBC,GAA0BC,GAA+B;AArBrH,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,EAAA;AASA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,EAAA;AAGE,SAAK,OAAOL,GACZ,KAAK,WAAWC,GAChB,KAAK,kBAAkBE,GACvB,KAAK,OAAOD,GACZ,KAAK,SAASE;AAAA,EAChB;AACF;AA7B2BE,EAAAP,GAAA;AAApB,IAAMQ,IAANR;ACkDA,MAAMS,IAAmE;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AACJ;AAEO,SAASC,EAA4BC,GAA4C;AACpF,SAAKA,IACGF,EAAqD,SAASE,CAAM,IADxD;AAExB;AAHgBJ,EAAAG,GAAA;AAMT,SAASE,EAA6BD,GAA4C;AACrF,SAAOA,MAAW;AACtB;AAFgBJ,EAAAK,GAAA;"}
|
package/dist/hooks.js
CHANGED
|
@@ -2,18 +2,18 @@ var X = Object.defineProperty;
|
|
|
2
2
|
var at = (i, t, e) => t in i ? X(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
3
|
var d = (i, t) => X(i, "name", { value: t, configurable: !0 });
|
|
4
4
|
var o = (i, t, e) => at(i, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
-
import { I as O, E as I, S as N, C as
|
|
5
|
+
import { I as O, E as I, S as N, C as R, L as ct, P as D, l as lt, o as ht, T as ut, m as dt, q as gt } from "./serializer-BNsp8xs2.js";
|
|
6
6
|
import { format as ft } from "date-fns";
|
|
7
7
|
import pt from "lodash";
|
|
8
8
|
import { C as T, P as mt } from "./Prompt-DZb7OaPp.js";
|
|
9
9
|
import { d as wt } from "./environmentUtils-VZNTCzEE.js";
|
|
10
|
-
import { r as St } from "./httpSessionService-
|
|
11
|
-
const
|
|
10
|
+
import { r as St } from "./httpSessionService-BY7JeW8d.js";
|
|
11
|
+
const b = {
|
|
12
12
|
PROMPTS: "envision-prompts"
|
|
13
13
|
}, It = 50, q = class q {
|
|
14
14
|
getPrompts() {
|
|
15
15
|
try {
|
|
16
|
-
const t = localStorage.getItem(
|
|
16
|
+
const t = localStorage.getItem(b.PROMPTS);
|
|
17
17
|
return t ? JSON.parse(t).sort((s, n) => new Date(n.created).getTime() - new Date(s.created).getTime()) : [];
|
|
18
18
|
} catch (t) {
|
|
19
19
|
return console.error("Error loading prompts:", t), [];
|
|
@@ -40,14 +40,14 @@ const _ = {
|
|
|
40
40
|
storePrompt(t) {
|
|
41
41
|
try {
|
|
42
42
|
const e = this.getPrompts().filter((s) => s.promptText !== t.promptText);
|
|
43
|
-
e.unshift(t), localStorage.setItem(
|
|
43
|
+
e.unshift(t), localStorage.setItem(b.PROMPTS, JSON.stringify(e.slice(0, It)));
|
|
44
44
|
} catch (e) {
|
|
45
45
|
console.error("Error storing prompt:", e);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
clearAllPrompts() {
|
|
49
49
|
try {
|
|
50
|
-
localStorage.removeItem(
|
|
50
|
+
localStorage.removeItem(b.PROMPTS);
|
|
51
51
|
} catch (t) {
|
|
52
52
|
console.error("Error clearing prompts:", t);
|
|
53
53
|
}
|
|
@@ -279,7 +279,7 @@ function Et(i, t) {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
d(Et, "foldClientOutput");
|
|
282
|
-
function
|
|
282
|
+
function Mt(i, t, e, s, n) {
|
|
283
283
|
var w;
|
|
284
284
|
const r = i.parts.findIndex((u) => {
|
|
285
285
|
var g;
|
|
@@ -314,8 +314,8 @@ function At(i, t, e, s, n) {
|
|
|
314
314
|
};
|
|
315
315
|
L(i), i.functionMap.set(s, f), f.eventType === I.FunctionResponse && ((w = n == null ? void 0 : n.onFunctionResponse) == null || w.call(n, f.functionDetails)), r > -1 && (k(i), i.parts[r] = f);
|
|
316
316
|
}
|
|
317
|
-
d(
|
|
318
|
-
function
|
|
317
|
+
d(Mt, "foldFunctionEvent");
|
|
318
|
+
function At(i, t, e, s) {
|
|
319
319
|
s && t.functionDetails && (L(i), i.functionMap.set(s, t));
|
|
320
320
|
const n = i.prev.parts[i.prev.parts.length - 1] ?? null;
|
|
321
321
|
n && n.textAppendable && (k(i), i.parts[i.parts.length - 1] = { ...n, ended: /* @__PURE__ */ new Date() });
|
|
@@ -326,7 +326,7 @@ function Mt(i, t, e, s) {
|
|
|
326
326
|
};
|
|
327
327
|
i.parts = [...i.parts, r];
|
|
328
328
|
}
|
|
329
|
-
d(
|
|
329
|
+
d(At, "openPart");
|
|
330
330
|
function Ot(i, t, e, s) {
|
|
331
331
|
const n = i.parts[i.parts.length - 1] ?? null;
|
|
332
332
|
if (!n) return;
|
|
@@ -355,7 +355,7 @@ function kt(i, t) {
|
|
|
355
355
|
return e;
|
|
356
356
|
}
|
|
357
357
|
d(kt, "mergeArtifacts");
|
|
358
|
-
function
|
|
358
|
+
function Dt(i, t, e) {
|
|
359
359
|
var c, h;
|
|
360
360
|
const s = O.FlatParts(t == null ? void 0 : t.parts), n = i.parts[i.parts.length - 1] ?? null, r = {
|
|
361
361
|
prev: i,
|
|
@@ -370,7 +370,7 @@ function $t(i, t, e) {
|
|
|
370
370
|
const w = yt(s.eventType) || vt(s.eventType), u = w ? (h = s.functionDetails) == null ? void 0 : h.id : void 0;
|
|
371
371
|
w && !u && console.error("Got isCall or isResponse without a callId", s);
|
|
372
372
|
const g = u ? r.functionMap.get(u) : void 0;
|
|
373
|
-
g && u && s.functionDetails ?
|
|
373
|
+
g && u && s.functionDetails ? Mt(r, s, g, u, e) : (At(r, s, t, u), a = !0);
|
|
374
374
|
}
|
|
375
375
|
s.textAppendable && Ot(r, s, t, a);
|
|
376
376
|
}
|
|
@@ -385,7 +385,7 @@ function $t(i, t, e) {
|
|
|
385
385
|
asyncFinalResponse: t.asyncFinalResponse
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
|
-
d(
|
|
388
|
+
d(Dt, "reduceInteraction");
|
|
389
389
|
const H = class H {
|
|
390
390
|
constructor(t, e) {
|
|
391
391
|
o(this, "interaction");
|
|
@@ -398,7 +398,7 @@ const H = class H {
|
|
|
398
398
|
* throttled subscribers cannot diverge from live state.
|
|
399
399
|
*/
|
|
400
400
|
merge(t) {
|
|
401
|
-
const e =
|
|
401
|
+
const e = Dt(this.interaction, t, {
|
|
402
402
|
onFunctionResponse: /* @__PURE__ */ d((s) => this.eventBusService.gatewayEmitFunctionResponse(s), "onFunctionResponse")
|
|
403
403
|
});
|
|
404
404
|
return this.interaction = e, e;
|
|
@@ -406,7 +406,7 @@ const H = class H {
|
|
|
406
406
|
};
|
|
407
407
|
d(H, "InteractionService");
|
|
408
408
|
let P = H;
|
|
409
|
-
const ot = 4001,
|
|
409
|
+
const ot = 4001, $t = 4002, Rt = 4004, Lt = 4100, $ = 500, Pt = 2e4, bt = 1e3, _t = 0.2, A = 300 * 1e3, Nt = 0.75, Ut = 2e3, m = "[Connection]", z = class z {
|
|
410
410
|
constructor(t) {
|
|
411
411
|
o(this, "ports");
|
|
412
412
|
o(this, "state");
|
|
@@ -415,7 +415,7 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
415
415
|
o(this, "inflight", null);
|
|
416
416
|
o(this, "retryTimer", null);
|
|
417
417
|
o(this, "idleTimer", null);
|
|
418
|
-
o(this, "wait",
|
|
418
|
+
o(this, "wait", $);
|
|
419
419
|
/** Consecutive failed attempts since the last proven connection. */
|
|
420
420
|
o(this, "attempt", 0);
|
|
421
421
|
o(this, "halted", null);
|
|
@@ -480,7 +480,7 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
480
480
|
/** Stop supervising: hang up, cancel any retry, stop the idle tick. Never throws. */
|
|
481
481
|
close() {
|
|
482
482
|
const t = this.target;
|
|
483
|
-
this.target = null, this.halted = null, this.cancelRetry(), this.stopIdleTick(), this.wait =
|
|
483
|
+
this.target = null, this.halted = null, this.cancelRetry(), this.stopIdleTick(), this.wait = $, this.attempt = 0;
|
|
484
484
|
try {
|
|
485
485
|
this.ports.hangUp();
|
|
486
486
|
} catch (e) {
|
|
@@ -533,7 +533,7 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
533
533
|
throw this.state.setConnectionStatus(T.Disconnected), this.halt("session-gone", { sessionId: t.sessionId, actualSessionId: r }), new Error(`Session ${t.sessionId} no longer exists on the server (it answered with ${r}).`);
|
|
534
534
|
}
|
|
535
535
|
const a = this.everConnected;
|
|
536
|
-
return this.everConnected = !0, t.sessionId = r, t.resume = !0, t.prepare = void 0, this.wait =
|
|
536
|
+
return this.everConnected = !0, t.sessionId = r, t.resume = !0, t.prepare = void 0, this.wait = $, this.attempt = 0, this.state.setConnectionStatus(T.Connected), console.log(`${m} ${a ? "reconnected to" : "connected to"} session ${r} in ${this.now() - e}ms.`), (h = (c = this.ports).onConnected) == null || h.call(c, r, { reconnect: a }), r;
|
|
537
537
|
}).catch((r) => {
|
|
538
538
|
if (this.target === t && !this.halted) {
|
|
539
539
|
const a = this.lastCloseCode;
|
|
@@ -549,8 +549,8 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
549
549
|
judge(t) {
|
|
550
550
|
var s;
|
|
551
551
|
const e = (s = this.target) == null ? void 0 : s.sessionId;
|
|
552
|
-
if (t ===
|
|
553
|
-
if (t ===
|
|
552
|
+
if (t === $t) return this.halt("attached-elsewhere", { sessionId: e, code: t });
|
|
553
|
+
if (t === Rt) return this.halt("session-gone", { sessionId: e, code: t });
|
|
554
554
|
if (t === 1e3 || t === 1008) return this.halt("closed-by-server", { sessionId: e, code: t });
|
|
555
555
|
this.scheduleRetry();
|
|
556
556
|
}
|
|
@@ -571,7 +571,7 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
571
571
|
return;
|
|
572
572
|
}
|
|
573
573
|
const t = this.jittered(this.wait);
|
|
574
|
-
this.wait = Math.min(Math.floor(this.wait + this.wait * this.wait /
|
|
574
|
+
this.wait = Math.min(Math.floor(this.wait + this.wait * this.wait / bt), Pt), this.attempt += 1, console.warn(`${m} redialling session ${this.target.sessionId ?? "(new)"} in ${t}ms (then ${this.wait}ms, attempt ${this.attempt}).`);
|
|
575
575
|
try {
|
|
576
576
|
(s = (e = this.ports).onRetryScheduled) == null || s.call(e, { sessionId: this.target.sessionId, delayMs: t, attempt: this.attempt });
|
|
577
577
|
} catch (n) {
|
|
@@ -586,7 +586,7 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
586
586
|
this.retryTimer && (clearTimeout(this.retryTimer), this.retryTimer = null);
|
|
587
587
|
}
|
|
588
588
|
jittered(t) {
|
|
589
|
-
return Math.max(0, Math.round(t + t *
|
|
589
|
+
return Math.max(0, Math.round(t + t * _t * (Math.random() * 2 - 1)));
|
|
590
590
|
}
|
|
591
591
|
sameTarget(t) {
|
|
592
592
|
var e;
|
|
@@ -611,9 +611,9 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
611
611
|
if (!this.target) return;
|
|
612
612
|
this.state.turnOpen && this.state.setLastActivity();
|
|
613
613
|
const t = this.now() - this.state.lastActivity;
|
|
614
|
-
if (t >
|
|
614
|
+
if (t > A) {
|
|
615
615
|
if (this.state.sessionActive && this.state.setIsSessionActive(!1), this.cancelRetry(), this.state.connectionStatus === T.Connected) {
|
|
616
|
-
console.warn(`${m} idle for ${Math.round(t / 1e3)}s (limit ${
|
|
616
|
+
console.warn(`${m} idle for ${Math.round(t / 1e3)}s (limit ${A / 1e3}s) — closing the socket (session ${this.target.sessionId ?? "(new)"}). Activity, or a send, redials it.`);
|
|
617
617
|
try {
|
|
618
618
|
this.ports.hangUp();
|
|
619
619
|
} catch (e) {
|
|
@@ -623,8 +623,8 @@ const ot = 4001, Dt = 4002, bt = 4004, Lt = 4100, D = 500, Pt = 2e4, _t = 1e3, R
|
|
|
623
623
|
}
|
|
624
624
|
return;
|
|
625
625
|
}
|
|
626
|
-
this.state.sessionActive || (console.log(`${m} activity resumed — the session is active again.`), this.state.setIsSessionActive(!0), this.wait =
|
|
627
|
-
}))), t >
|
|
626
|
+
this.state.sessionActive || (console.log(`${m} activity resumed — the session is active again.`), this.state.setIsSessionActive(!0), this.wait = $, this.state.connectionStatus === T.Disconnected && !this.halted && !this.inflight && (this.target.resume = !0, this.dial().catch(() => {
|
|
627
|
+
}))), t > A * Nt ? this.idleWarningLogged || (this.idleWarningLogged = !0, console.warn(`${m} idle ${Math.round(t / 1e3)}s of ${A / 1e3}s — the socket closes in about ${Math.round((A - t) / 1e3)}s unless something happens.`)) : this.idleWarningLogged = !1;
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
630
|
d(z, "ConnectionSupervisor");
|
|
@@ -704,8 +704,8 @@ const S = class S {
|
|
|
704
704
|
return ((t = this.sessionState.currentMessage) == null ? void 0 : t.version) ?? 0;
|
|
705
705
|
}, "publishedVersion")
|
|
706
706
|
}));
|
|
707
|
-
o(this, "
|
|
708
|
-
o(this, "
|
|
707
|
+
o(this, "detachedRunInteractions", /* @__PURE__ */ new Map());
|
|
708
|
+
o(this, "detachedRunInteractionServices", /* @__PURE__ */ new Map());
|
|
709
709
|
// ─── Artifacts ──────────────────────────────────────────────────────────
|
|
710
710
|
o(this, "runningRequests", /* @__PURE__ */ new Map());
|
|
711
711
|
this.user = t, this.config = r, this.rawJwt = t.access_token, this.base_url = n, this.eventBusService = e, this.sessionId = w, this.artifactService = s, this.sessionState = a.getState(), this.notificationPort = c, this.storageService = f, a.subscribe((u, g) => {
|
|
@@ -723,8 +723,8 @@ const S = class S {
|
|
|
723
723
|
this.sessionId = u, this.sessionState.setConnectionOutage(null), this.eventBusService.gatewayEmitConnected(u, g);
|
|
724
724
|
}, "onConnected"),
|
|
725
725
|
onRetryScheduled: /* @__PURE__ */ d(({ delayMs: u, attempt: g }) => {
|
|
726
|
-
var
|
|
727
|
-
const p = Date.now(), C = ((
|
|
726
|
+
var M;
|
|
727
|
+
const p = Date.now(), C = ((M = this.sessionState.connectionOutage) == null ? void 0 : M.since) ?? p;
|
|
728
728
|
this.sessionState.setConnectionOutage({ since: C, retryAt: p + u, attempt: g, halted: null }), p - C >= S.OUTAGE_CLOSES_TURN_AFTER_MS && this.closeOpenTurnWith(S.OUTAGE_TURN_MESSAGE);
|
|
729
729
|
}, "onRetryScheduled"),
|
|
730
730
|
onHalt: /* @__PURE__ */ d((u, g) => {
|
|
@@ -887,8 +887,8 @@ const S = class S {
|
|
|
887
887
|
console.error("Uknown message type", t);
|
|
888
888
|
return;
|
|
889
889
|
}
|
|
890
|
-
if (e.
|
|
891
|
-
this.
|
|
890
|
+
if (e.detachedRunId) {
|
|
891
|
+
this.handleDetachedRunEvent(e);
|
|
892
892
|
return;
|
|
893
893
|
}
|
|
894
894
|
if (e.serverError && console.error("Stream error: ", e.serverError), e.endMessageData && this.eventBusService.gatewayEmitEndMessageData(e.endMessageData), e.llmArtifacts && e.llmArtifacts.length > 0)
|
|
@@ -908,7 +908,7 @@ const S = class S {
|
|
|
908
908
|
console.error("No updated interaction");
|
|
909
909
|
return;
|
|
910
910
|
}
|
|
911
|
-
this.localEmitMessage(n), (e.turn_complete || e.asyncFinalResponse || s) && (this.committedTurns.has(e.interactionId) || (this.committedTurns.add(e.interactionId), this.turnComplete(e.interactionId, n, e.author, e.
|
|
911
|
+
this.localEmitMessage(n), (e.turn_complete || e.asyncFinalResponse || s) && (this.committedTurns.has(e.interactionId) || (this.committedTurns.add(e.interactionId), this.turnComplete(e.interactionId, n, e.author, e.detachedRunId)));
|
|
912
912
|
const r = e.artifactsDelta;
|
|
913
913
|
r && r.forEach((a) => {
|
|
914
914
|
const c = n.artifactData.filter((f) => f.id == a);
|
|
@@ -926,8 +926,8 @@ const S = class S {
|
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
|
-
|
|
930
|
-
let n = this.
|
|
929
|
+
getOrCreateDetachedRunInteraction(t, e, s) {
|
|
930
|
+
let n = this.detachedRunInteractions.get(t), r = this.detachedRunInteractionServices.get(t);
|
|
931
931
|
return (!n || !r) && (n = {
|
|
932
932
|
created: /* @__PURE__ */ new Date(),
|
|
933
933
|
interactionId: e,
|
|
@@ -938,14 +938,14 @@ const S = class S {
|
|
|
938
938
|
version: 0,
|
|
939
939
|
functionMap: /* @__PURE__ */ new Map(),
|
|
940
940
|
interactionQuestion: s ?? t
|
|
941
|
-
}, r = new P(n, this.eventBusService), this.
|
|
941
|
+
}, r = new P(n, this.eventBusService), this.detachedRunInteractions.set(t, n), this.detachedRunInteractionServices.set(t, r)), { interaction: n, service: r };
|
|
942
942
|
}
|
|
943
|
-
|
|
944
|
-
const e = t.
|
|
943
|
+
handleDetachedRunEvent(t) {
|
|
944
|
+
const e = t.detachedRunId, { service: s } = this.getOrCreateDetachedRunInteraction(e, t.interactionId, t.detachedRunName);
|
|
945
945
|
for (const r of t.parts ?? [])
|
|
946
|
-
r.toolDetails && this.localEmitToolEvent({ ...r.toolDetails,
|
|
946
|
+
r.toolDetails && this.localEmitToolEvent({ ...r.toolDetails, detachedRunId: e });
|
|
947
947
|
const n = s.merge(t);
|
|
948
|
-
n && (this.sessionState.
|
|
948
|
+
n && (this.sessionState.setDetachedRunMessage(e, n, t.detachedRunName), (t.turn_complete ?? !1) && this.sessionState.completeDetachedRun(e));
|
|
949
949
|
}
|
|
950
950
|
localEmitToolEvent(t) {
|
|
951
951
|
this.sessionState.setLastToolEvent(t), this.eventBusService.gatewayEmitToolEvent(t.eventName, t.eventData, t.sessionId);
|
|
@@ -969,7 +969,7 @@ const S = class S {
|
|
|
969
969
|
this.liveMessage.cancelPending(), this.sessionState.setNewMessage(e), this.eventBusService.gatewayEmitTurnComplete(t, e), this.interactionCallIds.delete(t), this.sessionState.setLastToolEvent(null), this.localEmitToolEvent({
|
|
970
970
|
eventName: "todolistUpdated",
|
|
971
971
|
eventData: "",
|
|
972
|
-
|
|
972
|
+
detachedRunId: n
|
|
973
973
|
}), this.sessionState.setTurnOpen(!1);
|
|
974
974
|
}
|
|
975
975
|
async asyncLoadArtifact(t) {
|
|
@@ -1077,7 +1077,7 @@ const S = class S {
|
|
|
1077
1077
|
return this.sessionState.setLastActivity(), await this.ensureConnected(), this.wsService.sendMessage({
|
|
1078
1078
|
Content: t.data,
|
|
1079
1079
|
SessionId: this.sessionId,
|
|
1080
|
-
Action:
|
|
1080
|
+
Action: R.SendMessage,
|
|
1081
1081
|
ModelId: this.config.model,
|
|
1082
1082
|
InteractionId: n.interactionId,
|
|
1083
1083
|
AgentId: (c = this.config.agentConfig) == null ? void 0 : c.id,
|
|
@@ -1178,13 +1178,13 @@ o(S, "NO_CONNECTION_MESSAGE", "Não foi possível obter conexão com o servidor"
|
|
|
1178
1178
|
let tt = S;
|
|
1179
1179
|
function Ft(i) {
|
|
1180
1180
|
const t = new ct();
|
|
1181
|
-
t.author = "main", t.streamingParts = i.streamingParts, i.partialEventType ? t.eventType = i.partialEventType : t.eventType = i.functionName ? { fullName:
|
|
1181
|
+
t.author = "main", t.streamingParts = i.streamingParts, i.partialEventType ? t.eventType = i.partialEventType : t.eventType = i.functionName ? { fullName: D.StreamingFunctionCallUpdateContent, type: I.PartialFunctionCall } : i.partialReasoning ? { fullName: D.StreamingReasoningContent, type: I.Thought } : { fullName: D.StreamingTextContent, type: I.Text }, t.interactionId = i.iteractionId ?? "", t.mimeType = "text/plain", t.partial = !0, t.role = { label: "Assistant" }, t.timestamp = i.timeStamp ?? (/* @__PURE__ */ new Date()).getTime(), t.turnComplete = !1;
|
|
1182
1182
|
const e = t.eventType.type;
|
|
1183
1183
|
if (e == I.PartialFunctionCall) {
|
|
1184
1184
|
const s = new lt();
|
|
1185
1185
|
s.choiceIndex = 0, s.callId = i.functionCallId, s.arguments = i.partialText, s.name = i.functionName, t.content = { items: [s], role: { label: "Assistant" } };
|
|
1186
1186
|
} else if (e == I.Text)
|
|
1187
|
-
if (t.eventType.fullName ==
|
|
1187
|
+
if (t.eventType.fullName == D.StreamingTextContent) {
|
|
1188
1188
|
const s = new ht();
|
|
1189
1189
|
s.text = i.partialText, t.content = { items: [s], role: { label: "Assistant" } };
|
|
1190
1190
|
} else {
|
|
@@ -1201,7 +1201,7 @@ d(Ft, "llmEventFromPartial");
|
|
|
1201
1201
|
function xt(i) {
|
|
1202
1202
|
const t = i.partialEvent ? Ft(i.partialEvent) : i.event;
|
|
1203
1203
|
if (t)
|
|
1204
|
-
return i.
|
|
1204
|
+
return i.detachedRunId && (t.detachedRunId = i.detachedRunId, t.detachedRunName = i.detachedRunName), t;
|
|
1205
1205
|
}
|
|
1206
1206
|
d(xt, "llmEventFromFrame");
|
|
1207
1207
|
function Wt(i) {
|
|
@@ -1263,11 +1263,11 @@ const st = 4, Bt = 3, Ht = 20, E = class E {
|
|
|
1263
1263
|
}
|
|
1264
1264
|
/**
|
|
1265
1265
|
* Account for one decoded frame. `sessionInformation` is only read off main-agent
|
|
1266
|
-
* frames — a
|
|
1266
|
+
* frames — a detached run's reading describes a different session.
|
|
1267
1267
|
*/
|
|
1268
1268
|
record(t) {
|
|
1269
1269
|
const e = Date.now();
|
|
1270
|
-
if (this.events.push([e, t.textLength]), this.stats.eventCount += 1, this.stats.totalTransfered += t.rawLength, t.sessionInformation && !t.
|
|
1270
|
+
if (this.events.push([e, t.textLength]), this.stats.eventCount += 1, this.stats.totalTransfered += t.rawLength, t.sessionInformation && !t.fromDetachedRun) {
|
|
1271
1271
|
const r = Gt(this.previousSessionInformation, t.sessionInformation);
|
|
1272
1272
|
r && (this.sessionCompactions.push(r), this.sessionCompactions.length > Ht && this.sessionCompactions.shift()), this.previousSessionInformation = t.sessionInformation, this.stats.sessionInformation = t.sessionInformation, this.stats.sessionCompactions = this.sessionCompactions;
|
|
1273
1273
|
}
|
|
@@ -1292,7 +1292,7 @@ const st = 4, Bt = 3, Ht = 20, E = class E {
|
|
|
1292
1292
|
};
|
|
1293
1293
|
d(E, "StreamStatsTracker"), o(E, "STATS_FLUSH_MS", 120);
|
|
1294
1294
|
let W = E;
|
|
1295
|
-
const zt = 5e3, Kt = 3e4,
|
|
1295
|
+
const zt = 5e3, Kt = 3e4, _ = 1e4, J = class J {
|
|
1296
1296
|
constructor(t = "ws://localhost:8000", e) {
|
|
1297
1297
|
o(this, "ws", null);
|
|
1298
1298
|
/** Frame counts, byte totals, the token-rate estimate and the compaction history — see StreamStatsTracker. */
|
|
@@ -1390,7 +1390,7 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1390
1390
|
};
|
|
1391
1391
|
const w = 200, u = 3e4, g = 8e3, p = this.ws;
|
|
1392
1392
|
this.sessionId = void 0;
|
|
1393
|
-
let C = 0,
|
|
1393
|
+
let C = 0, M = 0;
|
|
1394
1394
|
for (; ; ) {
|
|
1395
1395
|
if (this.ws !== p) {
|
|
1396
1396
|
n("Connection attempt superseded by a newer connect()");
|
|
@@ -1409,11 +1409,11 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1409
1409
|
n(`Server did not accept the connection within ${u / 1e3}s`);
|
|
1410
1410
|
return;
|
|
1411
1411
|
}
|
|
1412
|
-
if (p.readyState === WebSocket.OPEN &&
|
|
1412
|
+
if (p.readyState === WebSocket.OPEN && M >= g) {
|
|
1413
1413
|
n(`Connected but no session id arrived within ${g / 1e3}s`);
|
|
1414
1414
|
return;
|
|
1415
1415
|
}
|
|
1416
|
-
C % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(w), C += w, p.readyState === WebSocket.OPEN && (
|
|
1416
|
+
C % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(w), C += w, p.readyState === WebSocket.OPEN && (M += w);
|
|
1417
1417
|
}
|
|
1418
1418
|
console.log(`[WebSocket] Session ${this.sessionId} proven${this.lastSeq >= 0 ? ` (replaying from lastSeq=${this.lastSeq})` : ""}.`), this.lastKnownSessionId = this.sessionId, (Y = this.onOpen) == null || Y.call(this), this.flushPendingAnswers(this.sessionId), s(this.sessionId);
|
|
1419
1419
|
});
|
|
@@ -1501,7 +1501,7 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1501
1501
|
}
|
|
1502
1502
|
suspendStream() {
|
|
1503
1503
|
this.sendBaseMessage({
|
|
1504
|
-
Action:
|
|
1504
|
+
Action: R.Suspend,
|
|
1505
1505
|
AgentId: "",
|
|
1506
1506
|
InteractionId: "",
|
|
1507
1507
|
ModelId: ""
|
|
@@ -1520,7 +1520,7 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1520
1520
|
*/
|
|
1521
1521
|
answerHumanTool(t, e) {
|
|
1522
1522
|
const s = {
|
|
1523
|
-
Action:
|
|
1523
|
+
Action: R.AnswerHumanTool,
|
|
1524
1524
|
AgentId: "",
|
|
1525
1525
|
InteractionId: "",
|
|
1526
1526
|
ToolCallId: t,
|
|
@@ -1547,7 +1547,7 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1547
1547
|
}
|
|
1548
1548
|
try {
|
|
1549
1549
|
this.sendBaseMessage({
|
|
1550
|
-
Action:
|
|
1550
|
+
Action: R.AnswerHumanTool,
|
|
1551
1551
|
AgentId: "",
|
|
1552
1552
|
InteractionId: "",
|
|
1553
1553
|
ToolCallId: s.toolCallId,
|
|
@@ -1581,14 +1581,14 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1581
1581
|
const t = Date.now();
|
|
1582
1582
|
if (this.pingSentAt !== null) {
|
|
1583
1583
|
const e = t - this.pingSentAt;
|
|
1584
|
-
if (e >=
|
|
1584
|
+
if (e >= _) {
|
|
1585
1585
|
this.failSocket(
|
|
1586
1586
|
Lt,
|
|
1587
1587
|
`No frame received for ${Math.round(e / 1e3)}s after a Ping`
|
|
1588
1588
|
);
|
|
1589
1589
|
return;
|
|
1590
1590
|
}
|
|
1591
|
-
console.warn(`[WebSocket] Still no reply ${e}ms after the Ping (budget ${
|
|
1591
|
+
console.warn(`[WebSocket] Still no reply ${e}ms after the Ping (budget ${_}ms, session ${this.sessionLabel}) — the peer may be gone.`);
|
|
1592
1592
|
return;
|
|
1593
1593
|
}
|
|
1594
1594
|
t - this.lastActivity >= Kt && this.ping();
|
|
@@ -1606,7 +1606,7 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1606
1606
|
AgentId: "",
|
|
1607
1607
|
InteractionId: "",
|
|
1608
1608
|
ModelId: ""
|
|
1609
|
-
}), this.pingSentAt === null && (this.pingSentAt = Date.now(), console.log(`[WebSocket] Ping sent after ${Date.now() - this.lastActivity}ms of silence (session ${this.sessionLabel}); any frame within ${
|
|
1609
|
+
}), this.pingSentAt === null && (this.pingSentAt = Date.now(), console.log(`[WebSocket] Ping sent after ${Date.now() - this.lastActivity}ms of silence (session ${this.sessionLabel}); any frame within ${_}ms answers it.`));
|
|
1610
1610
|
}
|
|
1611
1611
|
/**
|
|
1612
1612
|
* Behave as if the peer vanished: the socket is closed and reported as an abnormal close (1006),
|
|
@@ -1659,7 +1659,7 @@ const zt = 5e3, Kt = 3e4, R = 1e4, J = class J {
|
|
|
1659
1659
|
rawLength: e.length,
|
|
1660
1660
|
textLength: ((s = t.text) == null ? void 0 : s.length) ?? 0,
|
|
1661
1661
|
sessionInformation: n.session_information,
|
|
1662
|
-
|
|
1662
|
+
fromDetachedRun: !!n.detachedRunId
|
|
1663
1663
|
}), this.onEvent && this.onEvent(n).catch((r) => {
|
|
1664
1664
|
console.error("Lost error on on-event", r);
|
|
1665
1665
|
});
|
|
@@ -1732,13 +1732,13 @@ export {
|
|
|
1732
1732
|
F as C,
|
|
1733
1733
|
Z as E,
|
|
1734
1734
|
it as H,
|
|
1735
|
-
|
|
1735
|
+
A as I,
|
|
1736
1736
|
V as L,
|
|
1737
1737
|
Tt as M,
|
|
1738
1738
|
Nt as W,
|
|
1739
1739
|
P as a,
|
|
1740
1740
|
nt as b,
|
|
1741
|
-
|
|
1741
|
+
Dt as r,
|
|
1742
1742
|
te as u
|
|
1743
1743
|
};
|
|
1744
|
-
//# sourceMappingURL=httpArtifactService-
|
|
1744
|
+
//# sourceMappingURL=httpArtifactService-DYQDPVVH.js.map
|