@aintela/chat 0.7.0 → 0.8.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 +7915 -6965
- package/dist/components.js.map +1 -1
- package/dist/{detachedRunActivity-CjyFTKSw.js → detachedRunActivity-RNg1JDDW.js} +129 -109
- package/dist/detachedRunActivity-RNg1JDDW.js.map +1 -0
- package/dist/hooks.js +1 -1
- package/dist/{httpSessionService-Ckb9Cxia.js → httpSessionService-DLdoBZRW.js} +2 -2
- package/dist/{httpSessionService-Ckb9Cxia.js.map → httpSessionService-DLdoBZRW.js.map} +1 -1
- package/dist/index.js +286 -258
- package/dist/models.js +1 -1
- package/dist/{serializer-DNUH6kgE.js → serializer-DvR3nOcf.js} +786 -717
- package/dist/serializer-DvR3nOcf.js.map +1 -0
- package/dist/services.js +2 -2
- package/dist/src/components/AgentTeam/BillingLimitBanner.d.ts +7 -0
- package/dist/src/components/AgentTeam/ChatAgentHeader.d.ts +34 -0
- package/dist/src/components/AgentTeam/HandoffDivider.d.ts +13 -0
- package/dist/src/components/AgentTeam/PersonaAvatar.d.ts +20 -0
- package/dist/src/components/AgentTeam/__tests__/agentTeam.test.d.ts +0 -0
- package/dist/src/components/AgentTeam/__tests__/billingLimit.test.d.ts +0 -0
- package/dist/src/components/AgentTeam/__tests__/messagePersona.test.d.ts +0 -0
- package/dist/src/components/AgentTeam/agentRoles.d.ts +33 -0
- package/dist/src/components/AgentTeam/chatAgent.d.ts +24 -0
- package/dist/src/components/AgentTeam/index.d.ts +7 -0
- package/dist/src/components/AgentTeam/personas.d.ts +60 -0
- package/dist/src/components/AiChat/AiChatContext.d.ts +6 -0
- package/dist/src/components/AiChat/AiChatTypes.d.ts +10 -0
- package/dist/src/components/AiChat/stateConfiguration.d.ts +7 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/models/Interaction.d.ts +11 -0
- package/dist/src/models/ServerEvent.d.ts +3 -0
- package/dist/src/models/billingLimit.d.ts +23 -0
- package/dist/src/models/index.d.ts +2 -1
- package/dist/src/models/semanticKernelModel/models.d.ts +19 -1
- package/dist/src/services/WebSocketConnection/WebSocketConnectionV2.d.ts +2 -0
- package/dist/src/services/WebSocketConnection/webSocketConnection.d.ts +3 -0
- package/dist/{useChatSessions-aTjNcj8q.js → useChatSessions-DwqgYo79.js} +2 -2
- package/dist/{useChatSessions-aTjNcj8q.js.map → useChatSessions-DwqgYo79.js.map} +1 -1
- package/package.json +1 -1
- package/dist/detachedRunActivity-CjyFTKSw.js.map +0 -1
- package/dist/serializer-DNUH6kgE.js.map +0 -1
|
@@ -2,15 +2,15 @@ var mt = Object.defineProperty;
|
|
|
2
2
|
var Rt = (i, t, e) => t in i ? mt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
3
|
var h = (i, t) => mt(i, "name", { value: t, configurable: !0 });
|
|
4
4
|
var o = (i, t, e) => Rt(i, typeof t != "symbol" ? t + "" : t, e);
|
|
5
|
-
import { i as N, E as I, S as x, z as wt, C as U, j as bt, L as Lt, P as z, n as Pt, q as Ft, T as _t, o as Nt, s as et } from "./serializer-
|
|
6
|
-
import { format as
|
|
7
|
-
import
|
|
8
|
-
import { C as E, P as
|
|
9
|
-
import { d as
|
|
10
|
-
import { r as Gt } from "./httpSessionService-
|
|
5
|
+
import { i as N, E as I, S as x, z as wt, C as U, j as bt, L as Lt, P as z, n as Pt, q as Ft, T as _t, o as Nt, s as et, B as Ut } from "./serializer-DvR3nOcf.js";
|
|
6
|
+
import { format as xt } from "date-fns";
|
|
7
|
+
import qt from "lodash";
|
|
8
|
+
import { C as E, P as Wt } from "./Prompt-DZb7OaPp.js";
|
|
9
|
+
import { d as Bt } from "./environmentUtils-VZNTCzEE.js";
|
|
10
|
+
import { r as Gt } from "./httpSessionService-DLdoBZRW.js";
|
|
11
11
|
const Q = {
|
|
12
12
|
PROMPTS: "envision-prompts"
|
|
13
|
-
},
|
|
13
|
+
}, zt = 50, nt = class nt {
|
|
14
14
|
getPrompts() {
|
|
15
15
|
try {
|
|
16
16
|
const t = localStorage.getItem(Q.PROMPTS);
|
|
@@ -40,7 +40,7 @@ const Q = {
|
|
|
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(Q.PROMPTS, JSON.stringify(e.slice(0,
|
|
43
|
+
e.unshift(t), localStorage.setItem(Q.PROMPTS, JSON.stringify(e.slice(0, zt)));
|
|
44
44
|
} catch (e) {
|
|
45
45
|
console.error("Error storing prompt:", e);
|
|
46
46
|
}
|
|
@@ -55,7 +55,7 @@ const Q = {
|
|
|
55
55
|
};
|
|
56
56
|
h(nt, "LocalStorageService");
|
|
57
57
|
let St = nt;
|
|
58
|
-
const
|
|
58
|
+
const $e = /* @__PURE__ */ h((i) => {
|
|
59
59
|
const t = i.getPrompts(), e = t.length;
|
|
60
60
|
if (e > 0) {
|
|
61
61
|
const s = t[0].promptText, n = t[t.length - 1].promptText, r = t[0].created;
|
|
@@ -238,7 +238,7 @@ const d = new X(), rt = class rt {
|
|
|
238
238
|
};
|
|
239
239
|
h(rt, "EventBusService");
|
|
240
240
|
let It = rt;
|
|
241
|
-
const
|
|
241
|
+
const Ht = 2e3;
|
|
242
242
|
function q(i) {
|
|
243
243
|
i.parts === i.prev.parts && (i.parts = i.prev.parts.slice());
|
|
244
244
|
}
|
|
@@ -247,13 +247,13 @@ function J(i) {
|
|
|
247
247
|
i.functionMap === i.prev.functionMap && (i.functionMap = new Map(i.functionMap));
|
|
248
248
|
}
|
|
249
249
|
h(J, "ownFunctionMap");
|
|
250
|
-
const
|
|
251
|
-
function
|
|
250
|
+
const Jt = /* @__PURE__ */ h((i) => i == I.FunctionCall || i == I.PartialFunctionCall, "isFunctionCall"), jt = /* @__PURE__ */ h((i) => i == I.FunctionResponse, "isFunctionResponse"), At = /* @__PURE__ */ h((i) => i.parts.length + 1 + "-" + i.prev.interactionId, "nextPartId");
|
|
251
|
+
function Kt(i, t) {
|
|
252
252
|
var e, s, n, r, a;
|
|
253
|
-
return !!(!t || i.mustPush || i.mustPush === !1 && (i.eventType !== t.eventType || ((e = i.functionDetails) == null ? void 0 : e.id) !== ((s = t.functionDetails) == null ? void 0 : s.id)) || i.textAppendable && (((r = (n = t.thoughtDetails) == null ? void 0 : n.text) == null ? void 0 : r.length) ?? ((a = t.text) == null ? void 0 : a.length) ?? 0) >
|
|
253
|
+
return !!(!t || i.mustPush || i.mustPush === !1 && (i.eventType !== t.eventType || ((e = i.functionDetails) == null ? void 0 : e.id) !== ((s = t.functionDetails) == null ? void 0 : s.id)) || i.textAppendable && (((r = (n = t.thoughtDetails) == null ? void 0 : n.text) == null ? void 0 : r.length) ?? ((a = t.text) == null ? void 0 : a.length) ?? 0) > Ht);
|
|
254
254
|
}
|
|
255
|
-
h(
|
|
256
|
-
function
|
|
255
|
+
h(Kt, "opensNewPart");
|
|
256
|
+
function Qt(i, t) {
|
|
257
257
|
const e = t.functionDetails.id, s = t.functionDetails.clientOutput, n = i.parts.findIndex((r) => {
|
|
258
258
|
var a;
|
|
259
259
|
return ((a = r.functionDetails) == null ? void 0 : a.id) === e;
|
|
@@ -278,8 +278,8 @@ function Kt(i, t) {
|
|
|
278
278
|
q(i), i.parts.push(r), J(i), i.functionMap.set(e, r);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
h(
|
|
282
|
-
function
|
|
281
|
+
h(Qt, "foldClientOutput");
|
|
282
|
+
function Yt(i, t, e, s, n) {
|
|
283
283
|
var p;
|
|
284
284
|
const r = i.parts.findIndex((m) => {
|
|
285
285
|
var u;
|
|
@@ -314,8 +314,8 @@ function Qt(i, t, e, s, n) {
|
|
|
314
314
|
};
|
|
315
315
|
J(i), i.functionMap.set(s, f), f.eventType === I.FunctionResponse && ((p = n == null ? void 0 : n.onFunctionResponse) == null || p.call(n, f.functionDetails)), r > -1 && (q(i), i.parts[r] = f);
|
|
316
316
|
}
|
|
317
|
-
h(
|
|
318
|
-
function
|
|
317
|
+
h(Yt, "foldFunctionEvent");
|
|
318
|
+
function Xt(i, t, e, s) {
|
|
319
319
|
s && t.functionDetails && (J(i), i.functionMap.set(s, t));
|
|
320
320
|
const n = i.prev.parts[i.prev.parts.length - 1] ?? null;
|
|
321
321
|
n && n.textAppendable && (q(i), i.parts[i.parts.length - 1] = { ...n, ended: /* @__PURE__ */ new Date() });
|
|
@@ -326,8 +326,8 @@ function Yt(i, t, e, s) {
|
|
|
326
326
|
};
|
|
327
327
|
i.parts = [...i.parts, r];
|
|
328
328
|
}
|
|
329
|
-
h(
|
|
330
|
-
function
|
|
329
|
+
h(Xt, "openPart");
|
|
330
|
+
function Vt(i, t, e, s) {
|
|
331
331
|
const n = i.parts[i.parts.length - 1] ?? null;
|
|
332
332
|
if (!n) return;
|
|
333
333
|
const r = {
|
|
@@ -344,8 +344,8 @@ function Xt(i, t, e, s) {
|
|
|
344
344
|
r.text = t.text ?? "", r.textDetails.version++, t.thoughtDetails && (r.thoughtDetails = { ...t.thoughtDetails, text: t.thoughtDetails.text.trim() });
|
|
345
345
|
q(i), i.parts[i.parts.length - 1] = r;
|
|
346
346
|
}
|
|
347
|
-
h(
|
|
348
|
-
function
|
|
347
|
+
h(Vt, "appendText");
|
|
348
|
+
function Zt(i, t) {
|
|
349
349
|
if (!t || t.length === 0) return i;
|
|
350
350
|
const e = i.slice();
|
|
351
351
|
for (const s of t) {
|
|
@@ -354,8 +354,8 @@ function Vt(i, t) {
|
|
|
354
354
|
}
|
|
355
355
|
return e;
|
|
356
356
|
}
|
|
357
|
-
h(
|
|
358
|
-
function
|
|
357
|
+
h(Zt, "mergeArtifacts");
|
|
358
|
+
function te(i, t, e) {
|
|
359
359
|
var c, l;
|
|
360
360
|
const s = N.FlatParts(t == null ? void 0 : t.parts), n = i.parts[i.parts.length - 1] ?? null, r = {
|
|
361
361
|
prev: i,
|
|
@@ -365,27 +365,28 @@ function Zt(i, t, e) {
|
|
|
365
365
|
let a = !1;
|
|
366
366
|
if (s) {
|
|
367
367
|
if (s.eventType === I.FunctionClientOutput && !!((c = s.functionDetails) != null && c.id))
|
|
368
|
-
|
|
369
|
-
else if (
|
|
370
|
-
const p =
|
|
368
|
+
Qt(r, s);
|
|
369
|
+
else if (Kt(s, n)) {
|
|
370
|
+
const p = Jt(s.eventType) || jt(s.eventType), m = p ? (l = s.functionDetails) == null ? void 0 : l.id : void 0;
|
|
371
371
|
p && !m && console.error("Got isCall or isResponse without a callId", s);
|
|
372
372
|
const u = m ? r.functionMap.get(m) : void 0;
|
|
373
|
-
u && m && s.functionDetails ?
|
|
373
|
+
u && m && s.functionDetails ? Yt(r, s, u, m, e) : (Xt(r, s, t, m), a = !0);
|
|
374
374
|
}
|
|
375
|
-
s.textAppendable &&
|
|
375
|
+
s.textAppendable && Vt(r, s, t, a);
|
|
376
376
|
}
|
|
377
377
|
return {
|
|
378
378
|
...i,
|
|
379
379
|
version: i.version + 1,
|
|
380
380
|
parts: r.parts,
|
|
381
|
-
artifactData:
|
|
381
|
+
artifactData: Zt(i.artifactData ?? [], t.llmArtifacts),
|
|
382
382
|
functionMap: r.functionMap,
|
|
383
383
|
turn_complete: t.turn_complete,
|
|
384
384
|
partial: t.partial,
|
|
385
|
-
asyncFinalResponse: t.asyncFinalResponse
|
|
385
|
+
asyncFinalResponse: t.asyncFinalResponse,
|
|
386
|
+
agent: t.agent ?? i.agent
|
|
386
387
|
};
|
|
387
388
|
}
|
|
388
|
-
h(
|
|
389
|
+
h(te, "reduceInteraction");
|
|
389
390
|
const ot = class ot {
|
|
390
391
|
constructor(t, e) {
|
|
391
392
|
o(this, "interaction");
|
|
@@ -398,7 +399,7 @@ const ot = class ot {
|
|
|
398
399
|
* throttled subscribers cannot diverge from live state.
|
|
399
400
|
*/
|
|
400
401
|
merge(t) {
|
|
401
|
-
const e =
|
|
402
|
+
const e = te(this.interaction, t, {
|
|
402
403
|
onFunctionResponse: /* @__PURE__ */ h((s) => this.eventBusService.gatewayEmitFunctionResponse(s), "onFunctionResponse")
|
|
403
404
|
});
|
|
404
405
|
return this.interaction = e, e;
|
|
@@ -406,7 +407,7 @@ const ot = class ot {
|
|
|
406
407
|
};
|
|
407
408
|
h(ot, "InteractionService");
|
|
408
409
|
let j = ot;
|
|
409
|
-
const Ot = 4001,
|
|
410
|
+
const Ot = 4001, ee = 4002, kt = 4004, se = 4100, H = 500, ne = 2e4, ie = 1e3, re = 0.2, _ = 300 * 1e3, oe = 0.75, ae = 2e3, w = "[Connection]", at = class at {
|
|
410
411
|
constructor(t) {
|
|
411
412
|
o(this, "ports");
|
|
412
413
|
o(this, "state");
|
|
@@ -549,7 +550,7 @@ const Ot = 4001, te = 4002, kt = 4004, ee = 4100, H = 500, se = 2e4, ne = 1e3, i
|
|
|
549
550
|
judge(t) {
|
|
550
551
|
var s;
|
|
551
552
|
const e = (s = this.target) == null ? void 0 : s.sessionId;
|
|
552
|
-
if (t ===
|
|
553
|
+
if (t === ee) return this.halt("attached-elsewhere", { sessionId: e, code: t });
|
|
553
554
|
if (t === kt) return this.halt("session-gone", { sessionId: e, code: t });
|
|
554
555
|
if (t === 1e3 || t === 1008) return this.halt("closed-by-server", { sessionId: e, code: t });
|
|
555
556
|
this.scheduleRetry();
|
|
@@ -571,7 +572,7 @@ const Ot = 4001, te = 4002, kt = 4004, ee = 4100, H = 500, se = 2e4, ne = 1e3, i
|
|
|
571
572
|
return;
|
|
572
573
|
}
|
|
573
574
|
const t = this.jittered(this.wait);
|
|
574
|
-
this.wait = Math.min(Math.floor(this.wait + this.wait * this.wait /
|
|
575
|
+
this.wait = Math.min(Math.floor(this.wait + this.wait * this.wait / ie), ne), this.attempt += 1, console.warn(`${w} redialling session ${this.target.sessionId ?? "(new)"} in ${t}ms (then ${this.wait}ms, attempt ${this.attempt}).`);
|
|
575
576
|
try {
|
|
576
577
|
(s = (e = this.ports).onRetryScheduled) == null || s.call(e, { sessionId: this.target.sessionId, delayMs: t, attempt: this.attempt });
|
|
577
578
|
} catch (n) {
|
|
@@ -586,7 +587,7 @@ const Ot = 4001, te = 4002, kt = 4004, ee = 4100, H = 500, se = 2e4, ne = 1e3, i
|
|
|
586
587
|
this.retryTimer && (clearTimeout(this.retryTimer), this.retryTimer = null);
|
|
587
588
|
}
|
|
588
589
|
jittered(t) {
|
|
589
|
-
return Math.max(0, Math.round(t + t *
|
|
590
|
+
return Math.max(0, Math.round(t + t * re * (Math.random() * 2 - 1)));
|
|
590
591
|
}
|
|
591
592
|
sameTarget(t) {
|
|
592
593
|
var e;
|
|
@@ -594,7 +595,7 @@ const Ot = 4001, te = 4002, kt = 4004, ee = 4100, H = 500, se = 2e4, ne = 1e3, i
|
|
|
594
595
|
}
|
|
595
596
|
// ─── Idle ───────────────────────────────────────────────────────────────
|
|
596
597
|
startIdleTick() {
|
|
597
|
-
this.idleTimer || (this.idleTimer = setInterval(() => this.tick(),
|
|
598
|
+
this.idleTimer || (this.idleTimer = setInterval(() => this.tick(), ae));
|
|
598
599
|
}
|
|
599
600
|
stopIdleTick() {
|
|
600
601
|
this.idleTimer && (clearInterval(this.idleTimer), this.idleTimer = null);
|
|
@@ -624,7 +625,7 @@ const Ot = 4001, te = 4002, kt = 4004, ee = 4100, H = 500, se = 2e4, ne = 1e3, i
|
|
|
624
625
|
return;
|
|
625
626
|
}
|
|
626
627
|
this.state.sessionActive || (console.log(`${w} activity resumed — the session is active again.`), this.state.setIsSessionActive(!0), this.wait = H, this.state.connectionStatus === E.Disconnected && !this.halted && !this.inflight && (this.target.resume = !0, this.dial().catch(() => {
|
|
627
|
-
}))), t > _ *
|
|
628
|
+
}))), t > _ * oe ? this.idleWarningLogged || (this.idleWarningLogged = !0, console.warn(`${w} idle ${Math.round(t / 1e3)}s of ${_ / 1e3}s — the socket closes in about ${Math.round((_ - t) / 1e3)}s unless something happens.`)) : this.idleWarningLogged = !1;
|
|
628
629
|
}
|
|
629
630
|
};
|
|
630
631
|
h(at, "ConnectionSupervisor");
|
|
@@ -766,6 +767,8 @@ const y = class y {
|
|
|
766
767
|
this.eventBusService.gatewayEmitStreamError(u);
|
|
767
768
|
}, this.wsService.onOpen = () => {
|
|
768
769
|
this.everConnected = !0;
|
|
770
|
+
}, this.wsService.onBillingLimit = (u) => {
|
|
771
|
+
a.getState().setBillingLimit(u);
|
|
769
772
|
}, this.wsService.onFirstToken = (u) => {
|
|
770
773
|
this.localEmitFirstToken(u);
|
|
771
774
|
}, this.wsService.onClose = (u, g) => {
|
|
@@ -924,7 +927,7 @@ const y = class y {
|
|
|
924
927
|
return e || (e = this.openRemoteInteraction(t.interactionId, "", void 0, !1)), e.merge(t);
|
|
925
928
|
}
|
|
926
929
|
getNewInteractionId() {
|
|
927
|
-
const e =
|
|
930
|
+
const e = xt(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
|
|
928
931
|
return `${this.msg_order}_${e}`;
|
|
929
932
|
}
|
|
930
933
|
// ─── Inbound: server events ─────────────────────────────────────────────
|
|
@@ -1109,7 +1112,7 @@ const y = class y {
|
|
|
1109
1112
|
try {
|
|
1110
1113
|
const { promptAsString: r, json: a } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(t.data) : { promptAsString: t.data, json: void 0 };
|
|
1111
1114
|
this.sessionState.onRenderPrompt && (t.data = a, t.friendlyMessage = r);
|
|
1112
|
-
const c = await this.sendMessageInternal(t, e), l =
|
|
1115
|
+
const c = await this.sendMessageInternal(t, e), l = Wt.createPrompt(r ?? "", (a == null ? void 0 : a.toString()) ?? {});
|
|
1113
1116
|
this.storageService.storePrompt(l);
|
|
1114
1117
|
const f = N.fromText("Planejando próximos passos");
|
|
1115
1118
|
return this.sendStatusMessage(t.data, [n, f], s.toString() + "1"), c != null && c.success ? this.eventBusService.ChatEmitMessageSent(t.data, c.interaction) : this.eventBusService.ChatEmitMessageError((c == null ? void 0 : c.error) ?? ""), c;
|
|
@@ -1171,7 +1174,7 @@ const y = class y {
|
|
|
1171
1174
|
sendStatusMessage(t, e, s) {
|
|
1172
1175
|
var r, a;
|
|
1173
1176
|
let n;
|
|
1174
|
-
((a = (r = this.currentIS) == null ? void 0 : r.interaction) == null ? void 0 : a.turn_complete) === !1 && !this.currentIS.interaction.remote ? (n =
|
|
1177
|
+
((a = (r = this.currentIS) == null ? void 0 : r.interaction) == null ? void 0 : a.turn_complete) === !1 && !this.currentIS.interaction.remote ? (n = qt.cloneDeep(this.currentIS.interaction), n.parts.push(...e)) : n = {
|
|
1175
1178
|
interactionId: "tmp" + s,
|
|
1176
1179
|
created: /* @__PURE__ */ new Date(),
|
|
1177
1180
|
partial: !0,
|
|
@@ -1289,7 +1292,7 @@ o(y, "NO_CONNECTION_MESSAGE", "Não foi possível obter conexão com o servidor"
|
|
|
1289
1292
|
"closed-by-server": "O servidor encerrou a conexão. A resposta foi interrompida."
|
|
1290
1293
|
});
|
|
1291
1294
|
let Tt = y;
|
|
1292
|
-
function
|
|
1295
|
+
function ce(i) {
|
|
1293
1296
|
const t = new Lt();
|
|
1294
1297
|
t.author = "main", t.streamingParts = i.streamingParts, i.partialEventType ? t.eventType = i.partialEventType : t.eventType = i.functionName ? { fullName: z.StreamingFunctionCallUpdateContent, type: I.PartialFunctionCall } : i.partialReasoning ? { fullName: z.StreamingReasoningContent, type: I.Thought } : { fullName: z.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;
|
|
1295
1298
|
const e = t.eventType.type;
|
|
@@ -1310,9 +1313,9 @@ function ae(i) {
|
|
|
1310
1313
|
}
|
|
1311
1314
|
return t;
|
|
1312
1315
|
}
|
|
1313
|
-
h(
|
|
1316
|
+
h(ce, "llmEventFromPartial");
|
|
1314
1317
|
function st(i) {
|
|
1315
|
-
const t = i.partialEvent ?
|
|
1318
|
+
const t = i.partialEvent ? ce(i.partialEvent) : i.event;
|
|
1316
1319
|
if (t)
|
|
1317
1320
|
return i.detachedRunId && (t.detachedRunId = i.detachedRunId, t.detachedRunName = i.detachedRunName), t;
|
|
1318
1321
|
}
|
|
@@ -1330,16 +1333,16 @@ function $t(i) {
|
|
|
1330
1333
|
return t.detachedRunId = i.detachedRunId, t;
|
|
1331
1334
|
}
|
|
1332
1335
|
h($t, "interactionStartFromFrame");
|
|
1333
|
-
const
|
|
1334
|
-
function
|
|
1336
|
+
const le = 0.02;
|
|
1337
|
+
function he(i, t) {
|
|
1335
1338
|
if (!t) return null;
|
|
1336
1339
|
const e = (t.interactionsCompressed ?? 0) > 0 || (t.compressionRatio ?? 0) > 0;
|
|
1337
1340
|
if (!i)
|
|
1338
1341
|
return e ? yt(t, t.size, t.size) : null;
|
|
1339
|
-
const s = i.size - t.size, n = t.maxSize || i.maxSize || 0, r = n > 0 ? s / n >=
|
|
1342
|
+
const s = i.size - t.size, n = t.maxSize || i.maxSize || 0, r = n > 0 ? s / n >= le : i.size > 0 && s / i.size >= 0.1;
|
|
1340
1343
|
return !e && !r ? null : yt(t, i.size, t.size, i.ratio);
|
|
1341
1344
|
}
|
|
1342
|
-
h(
|
|
1345
|
+
h(he, "detectCompaction");
|
|
1343
1346
|
function yt(i, t, e, s) {
|
|
1344
1347
|
return {
|
|
1345
1348
|
at: Date.now(),
|
|
@@ -1353,7 +1356,7 @@ function yt(i, t, e, s) {
|
|
|
1353
1356
|
};
|
|
1354
1357
|
}
|
|
1355
1358
|
h(yt, "entry");
|
|
1356
|
-
const vt = 4,
|
|
1359
|
+
const vt = 4, ue = 3, de = 20, P = class P {
|
|
1357
1360
|
constructor() {
|
|
1358
1361
|
o(this, "stats");
|
|
1359
1362
|
o(this, "onFlush");
|
|
@@ -1389,14 +1392,14 @@ const vt = 4, he = 3, ue = 20, P = class P {
|
|
|
1389
1392
|
record(t) {
|
|
1390
1393
|
const e = Date.now();
|
|
1391
1394
|
if (this.events.push([e, t.textLength]), this.stats.eventCount += 1, this.stats.totalTransfered += t.rawLength, t.sessionInformation && !t.fromDetachedRun) {
|
|
1392
|
-
const r =
|
|
1393
|
-
r && (this.sessionCompactions.push(r), this.sessionCompactions.length >
|
|
1395
|
+
const r = he(this.previousSessionInformation, t.sessionInformation);
|
|
1396
|
+
r && (this.sessionCompactions.push(r), this.sessionCompactions.length > de && this.sessionCompactions.shift()), this.previousSessionInformation = t.sessionInformation, this.stats.sessionInformation = t.sessionInformation, this.stats.sessionCompactions = this.sessionCompactions;
|
|
1394
1397
|
}
|
|
1395
1398
|
this.stats.elapsed = (e - this.stats.startTime.getTime()) / 1e3;
|
|
1396
1399
|
const s = e - vt * 1e3;
|
|
1397
1400
|
for (; this.events.length > 0 && this.events[0][0] <= s; ) this.events.shift();
|
|
1398
1401
|
const n = this.events.reduce((r, a) => r + a[1], 0);
|
|
1399
|
-
this.stats.tokensPerSecond = n /
|
|
1402
|
+
this.stats.tokensPerSecond = n / ue / vt, this.flushCoalesced();
|
|
1400
1403
|
}
|
|
1401
1404
|
flushCoalesced() {
|
|
1402
1405
|
if (!this.onFlush) return;
|
|
@@ -1413,7 +1416,7 @@ const vt = 4, he = 3, ue = 20, P = class P {
|
|
|
1413
1416
|
};
|
|
1414
1417
|
h(P, "StreamStatsTracker"), o(P, "STATS_FLUSH_MS", 120);
|
|
1415
1418
|
let tt = P;
|
|
1416
|
-
const
|
|
1419
|
+
const fe = 5e3, ge = 3e4, Y = 1e4, lt = class lt {
|
|
1417
1420
|
constructor(t = "ws://localhost:8000", e) {
|
|
1418
1421
|
o(this, "ws", null);
|
|
1419
1422
|
/** Frame counts, byte totals, the token-rate estimate and the compaction history — see StreamStatsTracker. */
|
|
@@ -1431,6 +1434,7 @@ const de = 5e3, fe = 3e4, Y = 1e4, lt = class lt {
|
|
|
1431
1434
|
o(this, "onOpen");
|
|
1432
1435
|
o(this, "onFirstToken");
|
|
1433
1436
|
o(this, "onSuspended");
|
|
1437
|
+
o(this, "onBillingLimit");
|
|
1434
1438
|
o(this, "onClose");
|
|
1435
1439
|
/**
|
|
1436
1440
|
* Fired when the server signals that we lost streaming events on resume — our
|
|
@@ -1464,7 +1468,7 @@ const de = 5e3, fe = 3e4, Y = 1e4, lt = class lt {
|
|
|
1464
1468
|
* the single-attach policy makes it undeliverable from here anyway.
|
|
1465
1469
|
*/
|
|
1466
1470
|
o(this, "pendingAnswers", []);
|
|
1467
|
-
this.baseUrl = t, this.getToken = e, this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = et(), console.log("SOCKET INSTACE",
|
|
1471
|
+
this.baseUrl = t, this.getToken = e, this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = et(), console.log("SOCKET INSTACE", Bt()), this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
|
|
1468
1472
|
}
|
|
1469
1473
|
get stats() {
|
|
1470
1474
|
return this.statsTracker.stats;
|
|
@@ -1711,7 +1715,7 @@ const de = 5e3, fe = 3e4, Y = 1e4, lt = class lt {
|
|
|
1711
1715
|
const e = t - this.pingSentAt;
|
|
1712
1716
|
if (e >= Y) {
|
|
1713
1717
|
this.failSocket(
|
|
1714
|
-
|
|
1718
|
+
se,
|
|
1715
1719
|
`No frame received for ${Math.round(e / 1e3)}s after a Ping`
|
|
1716
1720
|
);
|
|
1717
1721
|
return;
|
|
@@ -1719,11 +1723,11 @@ const de = 5e3, fe = 3e4, Y = 1e4, lt = class lt {
|
|
|
1719
1723
|
console.warn(`[WebSocket] Still no reply ${e}ms after the Ping (budget ${Y}ms, session ${this.sessionLabel}) — the peer may be gone.`);
|
|
1720
1724
|
return;
|
|
1721
1725
|
}
|
|
1722
|
-
t - this.lastActivity >=
|
|
1726
|
+
t - this.lastActivity >= ge && this.ping();
|
|
1723
1727
|
} catch (t) {
|
|
1724
1728
|
console.error("Error on monitor", t);
|
|
1725
1729
|
}
|
|
1726
|
-
},
|
|
1730
|
+
}, fe);
|
|
1727
1731
|
}
|
|
1728
1732
|
/**
|
|
1729
1733
|
* Send a heartbeat ping and start the reply clock (unless one is already running).
|
|
@@ -1778,21 +1782,37 @@ const de = 5e3, fe = 3e4, Y = 1e4, lt = class lt {
|
|
|
1778
1782
|
return this.ws !== null && this.ws.readyState === WebSocket.OPEN;
|
|
1779
1783
|
}
|
|
1780
1784
|
async handleEvent(t, e) {
|
|
1781
|
-
var
|
|
1785
|
+
var n, r, a, c;
|
|
1786
|
+
const s = (r = (n = t.content) == null ? void 0 : n.items) == null ? void 0 : r.find((l) => l instanceof Ut);
|
|
1787
|
+
if (s) {
|
|
1788
|
+
(a = this.onBillingLimit) == null || a.call(this, {
|
|
1789
|
+
plan: s.plan ?? "team",
|
|
1790
|
+
state: s.state ?? "ok",
|
|
1791
|
+
used: s.used ?? 0,
|
|
1792
|
+
included: s.included ?? 0,
|
|
1793
|
+
limitReached: s.limitReached ?? !1,
|
|
1794
|
+
canManage: s.canManage ?? !1,
|
|
1795
|
+
title: s.title,
|
|
1796
|
+
message: s.message,
|
|
1797
|
+
actionUrl: s.actionUrl,
|
|
1798
|
+
interactionId: t.interactionId || void 0
|
|
1799
|
+
});
|
|
1800
|
+
return;
|
|
1801
|
+
}
|
|
1782
1802
|
try {
|
|
1783
|
-
const
|
|
1784
|
-
if (!
|
|
1803
|
+
const l = x.parseFromTypedEvent(t);
|
|
1804
|
+
if (!l)
|
|
1785
1805
|
throw "Server event was null";
|
|
1786
1806
|
this.statsTracker.record({
|
|
1787
1807
|
rawLength: e.length,
|
|
1788
|
-
textLength: ((
|
|
1789
|
-
sessionInformation:
|
|
1790
|
-
fromDetachedRun: !!
|
|
1791
|
-
}), this.onEvent && this.onEvent(
|
|
1792
|
-
console.error("Lost error on on-event",
|
|
1808
|
+
textLength: ((c = t.text) == null ? void 0 : c.length) ?? 0,
|
|
1809
|
+
sessionInformation: l.session_information,
|
|
1810
|
+
fromDetachedRun: !!l.detachedRunId
|
|
1811
|
+
}), this.onEvent && this.onEvent(l).catch((f) => {
|
|
1812
|
+
console.error("Lost error on on-event", f);
|
|
1793
1813
|
});
|
|
1794
|
-
} catch (
|
|
1795
|
-
console.error("handleEvent error",
|
|
1814
|
+
} catch (l) {
|
|
1815
|
+
console.error("handleEvent error", l);
|
|
1796
1816
|
}
|
|
1797
1817
|
}
|
|
1798
1818
|
};
|
|
@@ -1862,15 +1882,15 @@ const ut = class ut extends Error {
|
|
|
1862
1882
|
};
|
|
1863
1883
|
h(ut, "DetachedRunFramesHttpError");
|
|
1864
1884
|
let L = ut;
|
|
1865
|
-
function
|
|
1885
|
+
function pe(i) {
|
|
1866
1886
|
if (i instanceof L) {
|
|
1867
1887
|
const { status: t } = i;
|
|
1868
1888
|
return { kind: t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 404 || t === 410 ? "notFound" : "gaveUp", status: t, cause: i };
|
|
1869
1889
|
}
|
|
1870
1890
|
return { kind: "gaveUp", cause: i };
|
|
1871
1891
|
}
|
|
1872
|
-
h(
|
|
1873
|
-
function
|
|
1892
|
+
h(pe, "toDetachedRunFollowError");
|
|
1893
|
+
function me(i) {
|
|
1874
1894
|
let t = "", e = [], s, n;
|
|
1875
1895
|
const r = /* @__PURE__ */ h(() => {
|
|
1876
1896
|
(e.length > 0 || s !== void 0) && i({ event: s, data: e.join(`
|
|
@@ -1901,12 +1921,12 @@ function pe(i) {
|
|
|
1901
1921
|
}
|
|
1902
1922
|
};
|
|
1903
1923
|
}
|
|
1904
|
-
h(
|
|
1905
|
-
function
|
|
1924
|
+
h(me, "createSseParser");
|
|
1925
|
+
function we(i) {
|
|
1906
1926
|
return i >= 500 || i === 408 || i === 429;
|
|
1907
1927
|
}
|
|
1908
|
-
h(
|
|
1909
|
-
function
|
|
1928
|
+
h(we, "retryable");
|
|
1929
|
+
function Se(i, t) {
|
|
1910
1930
|
return new Promise((e) => {
|
|
1911
1931
|
if (t != null && t.aborted) return e();
|
|
1912
1932
|
const s = setTimeout(n, i);
|
|
@@ -1916,12 +1936,12 @@ function we(i, t) {
|
|
|
1916
1936
|
h(n, "done"), t == null || t.addEventListener("abort", n, { once: !0 });
|
|
1917
1937
|
});
|
|
1918
1938
|
}
|
|
1919
|
-
h(
|
|
1920
|
-
function
|
|
1939
|
+
h(Se, "sleep");
|
|
1940
|
+
function Ie(i, t, e) {
|
|
1921
1941
|
return `${i.replace(/\/+$/, "")}/detached-runs/${encodeURIComponent(t)}/frames?afterSeq=${e}`;
|
|
1922
1942
|
}
|
|
1923
|
-
h(
|
|
1924
|
-
async function
|
|
1943
|
+
h(Ie, "framesUrl");
|
|
1944
|
+
async function Te(i) {
|
|
1925
1945
|
var M, F, v, C, ft;
|
|
1926
1946
|
const { baseUrl: t, runId: e, signal: s, onFrame: n, onEnd: r, onOpen: a, onRetry: c } = i, l = i.fetchImpl ?? ((A, $) => fetch(A, $)), f = ((M = i.retry) == null ? void 0 : M.initialMs) ?? 500, p = ((F = i.retry) == null ? void 0 : F.maxMs) ?? 15e3, m = ((v = i.retry) == null ? void 0 : v.maxAttempts) ?? Number.POSITIVE_INFINITY;
|
|
1927
1947
|
let u = i.afterSeq ?? 0, g = 0, S = !1;
|
|
@@ -1941,7 +1961,7 @@ async function Ie(i) {
|
|
|
1941
1961
|
try {
|
|
1942
1962
|
const O = { Accept: "text/event-stream" }, K = await ((C = i.getToken) == null ? void 0 : C.call(i)) ?? void 0;
|
|
1943
1963
|
K && (O.Authorization = `Bearer ${K}`);
|
|
1944
|
-
const k = await l(
|
|
1964
|
+
const k = await l(Ie(t, e, u), { method: "GET", headers: O, signal: s, cache: "no-store" });
|
|
1945
1965
|
if (k.status === 401) {
|
|
1946
1966
|
if (!S && await D(K)) {
|
|
1947
1967
|
S = !0;
|
|
@@ -1950,11 +1970,11 @@ async function Ie(i) {
|
|
|
1950
1970
|
throw new L(401);
|
|
1951
1971
|
}
|
|
1952
1972
|
if (S = !1, !k.ok)
|
|
1953
|
-
throw
|
|
1973
|
+
throw we(k.status) ? new Error(`GET detached-run frames answered ${k.status}`) : new L(k.status);
|
|
1954
1974
|
if (!k.body) throw new L(k.status, "The frames response has no readable body");
|
|
1955
1975
|
a == null || a();
|
|
1956
1976
|
let W = !1;
|
|
1957
|
-
const
|
|
1977
|
+
const B = me((T) => {
|
|
1958
1978
|
if (T.event === "end") {
|
|
1959
1979
|
const b = Number(T.data);
|
|
1960
1980
|
T.data !== "" && Number.isFinite(b) && b > u && (u = b), W = !0;
|
|
@@ -1980,16 +2000,16 @@ async function Ie(i) {
|
|
|
1980
2000
|
} catch (b) {
|
|
1981
2001
|
console.error(`[DetachedRunFrames] run ${e}: onFrame threw on seq ${T.id ?? "?"}`, b);
|
|
1982
2002
|
}
|
|
1983
|
-
}),
|
|
2003
|
+
}), G = k.body.getReader(), gt = new TextDecoder();
|
|
1984
2004
|
try {
|
|
1985
2005
|
for (; ; ) {
|
|
1986
|
-
const { done: T, value: R } = await
|
|
2006
|
+
const { done: T, value: R } = await G.read();
|
|
1987
2007
|
if (T) break;
|
|
1988
|
-
|
|
2008
|
+
B.push(gt.decode(R, { stream: !0 }));
|
|
1989
2009
|
}
|
|
1990
|
-
|
|
2010
|
+
B.push(gt.decode()), B.idle() || (W = !1), B.flush();
|
|
1991
2011
|
} finally {
|
|
1992
|
-
(ft =
|
|
2012
|
+
(ft = G.releaseLock) == null || ft.call(G);
|
|
1993
2013
|
}
|
|
1994
2014
|
if (W)
|
|
1995
2015
|
return r == null || r(u), { reason: "end", lastSeq: u };
|
|
@@ -2005,11 +2025,11 @@ async function Ie(i) {
|
|
|
2005
2025
|
c == null || c(A, g, $);
|
|
2006
2026
|
} catch {
|
|
2007
2027
|
}
|
|
2008
|
-
await
|
|
2028
|
+
await Se($, s);
|
|
2009
2029
|
}
|
|
2010
2030
|
return { reason: "aborted", lastSeq: u };
|
|
2011
2031
|
}
|
|
2012
|
-
h(
|
|
2032
|
+
h(Te, "streamDetachedRunFrames");
|
|
2013
2033
|
const dt = class dt {
|
|
2014
2034
|
constructor(t) {
|
|
2015
2035
|
o(this, "onEvent");
|
|
@@ -2057,7 +2077,7 @@ const dt = class dt {
|
|
|
2057
2077
|
const e = new AbortController();
|
|
2058
2078
|
return this.controller = e, this.following = !0, new Promise((n, r) => {
|
|
2059
2079
|
let a = !1;
|
|
2060
|
-
|
|
2080
|
+
Te({
|
|
2061
2081
|
...this.options,
|
|
2062
2082
|
runId: t,
|
|
2063
2083
|
afterSeq: this.lastSeq,
|
|
@@ -2080,7 +2100,7 @@ const dt = class dt {
|
|
|
2080
2100
|
a || r(new Error("The frames stream stopped before it opened"));
|
|
2081
2101
|
}).catch((c) => {
|
|
2082
2102
|
var p, m, u;
|
|
2083
|
-
const l =
|
|
2103
|
+
const l = pe(c), f = l.kind === "notFound" ? kt : l.kind === "forbidden" || l.kind === "unauthorized" ? 1008 : 1011;
|
|
2084
2104
|
console.error(`[DetachedRunFrames] run ${t}: following stopped (${l.kind})`, c);
|
|
2085
2105
|
try {
|
|
2086
2106
|
(p = this.onFollowError) == null || p.call(this, l);
|
|
@@ -2135,8 +2155,8 @@ const dt = class dt {
|
|
|
2135
2155
|
};
|
|
2136
2156
|
h(dt, "DetachedRunFramesTransport");
|
|
2137
2157
|
let Mt = dt;
|
|
2138
|
-
const
|
|
2139
|
-
function
|
|
2158
|
+
const ye = "todolistUpdated";
|
|
2159
|
+
function Re(i, t = et()) {
|
|
2140
2160
|
var n, r;
|
|
2141
2161
|
let e;
|
|
2142
2162
|
try {
|
|
@@ -2148,14 +2168,14 @@ function $e(i, t = et()) {
|
|
|
2148
2168
|
if (!e) return [];
|
|
2149
2169
|
const s = [];
|
|
2150
2170
|
for (const a of e.parts ?? [])
|
|
2151
|
-
if (a.eventType === I.ToolEvent && ((n = a.toolDetails) == null ? void 0 : n.eventName) ===
|
|
2152
|
-
const c =
|
|
2171
|
+
if (a.eventType === I.ToolEvent && ((n = a.toolDetails) == null ? void 0 : n.eventName) === ye) {
|
|
2172
|
+
const c = ve(a.toolDetails.eventData);
|
|
2153
2173
|
c && s.push({ kind: "todo", todoList: c });
|
|
2154
2174
|
} else (a.eventType === I.FunctionCall || a.eventType === I.PartialFunctionCall) && ((r = a.functionDetails) != null && r.name) ? s.push({ kind: "tool", name: a.functionDetails.name, interactionId: e.interactionId }) : a.eventType === I.Text && a.text && s.push({ kind: "text", text: a.text, partial: !!e.partial, interactionId: e.interactionId });
|
|
2155
2175
|
return s;
|
|
2156
2176
|
}
|
|
2157
|
-
h(
|
|
2158
|
-
function
|
|
2177
|
+
h(Re, "readDetachedRunActivity");
|
|
2178
|
+
function ve(i) {
|
|
2159
2179
|
if (!i) return null;
|
|
2160
2180
|
try {
|
|
2161
2181
|
const t = JSON.parse(i);
|
|
@@ -2164,7 +2184,7 @@ function ye(i) {
|
|
|
2164
2184
|
return null;
|
|
2165
2185
|
}
|
|
2166
2186
|
}
|
|
2167
|
-
h(
|
|
2187
|
+
h(ve, "parseTodoList");
|
|
2168
2188
|
export {
|
|
2169
2189
|
Tt as A,
|
|
2170
2190
|
V as C,
|
|
@@ -2173,17 +2193,17 @@ export {
|
|
|
2173
2193
|
Ct as H,
|
|
2174
2194
|
_ as I,
|
|
2175
2195
|
St as L,
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2196
|
+
Ht as M,
|
|
2197
|
+
ye as T,
|
|
2198
|
+
oe as W,
|
|
2179
2199
|
Mt as a,
|
|
2180
2200
|
j as b,
|
|
2181
2201
|
Et as c,
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2202
|
+
me as d,
|
|
2203
|
+
te as e,
|
|
2204
|
+
Re as r,
|
|
2205
|
+
Te as s,
|
|
2206
|
+
pe as t,
|
|
2207
|
+
$e as u
|
|
2188
2208
|
};
|
|
2189
|
-
//# sourceMappingURL=detachedRunActivity-
|
|
2209
|
+
//# sourceMappingURL=detachedRunActivity-RNg1JDDW.js.map
|