@aintela/chat 0.14.5 → 0.14.6
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 +1427 -1405
- package/dist/components.js.map +1 -1
- package/dist/{detachedRunActivity-Cf-RPK9j.js → detachedRunActivity-Dw1Far2p.js} +83 -54
- package/dist/detachedRunActivity-Dw1Far2p.js.map +1 -0
- package/dist/hooks.js +1 -1
- package/dist/{httpSessionService-B2wgAfly.js → httpSessionService-BCe4DpgA.js} +2 -2
- package/dist/{httpSessionService-B2wgAfly.js.map → httpSessionService-BCe4DpgA.js.map} +1 -1
- package/dist/index.js +4 -4
- package/dist/models.js +1 -1
- package/dist/{serializer-CdIQS0hy.js → serializer-Dagz_6VT.js} +95 -94
- package/dist/serializer-Dagz_6VT.js.map +1 -0
- package/dist/services.js +2 -2
- package/dist/src/components/AiChat/ChatPane/askUserInlineOutage.test.d.ts +1 -0
- package/dist/src/components/AiChat/sessionStateManagerService.d.ts +8 -0
- package/dist/src/models/ServerEvent.d.ts +8 -1
- package/dist/src/services/eventBusService.d.ts +6 -0
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +14 -0
- package/dist/src/services/servers/gatewayRewindLost.test.d.ts +1 -0
- package/dist/tests/fakes/fakeWebSocket.d.ts +3 -1
- package/dist/{useChatSessions-BVpCsm8u.js → useChatSessions-BgfeYkcc.js} +2 -2
- package/dist/{useChatSessions-BVpCsm8u.js.map → useChatSessions-BgfeYkcc.js.map} +1 -1
- package/package.json +1 -1
- package/dist/detachedRunActivity-Cf-RPK9j.js.map +0 -1
- package/dist/serializer-CdIQS0hy.js.map +0 -1
|
@@ -2,12 +2,12 @@ var Ie = Object.defineProperty;
|
|
|
2
2
|
var Fe = (i, e, t) => e in i ? Ie(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var h = (i, e) => Ie(i, "name", { value: e, configurable: !0 });
|
|
4
4
|
var a = (i, e, t) => Fe(i, typeof e != "symbol" ? e + "" : e, t);
|
|
5
|
-
import { i as
|
|
5
|
+
import { i as x, E as I, S as U, z as Te, C as L, j as Ne, L as _e, P as z, n as xe, q as Ue, T as qe, o as We, s as ne, B as Be } from "./serializer-Dagz_6VT.js";
|
|
6
6
|
import { format as Ge } from "date-fns";
|
|
7
7
|
import ze from "lodash";
|
|
8
8
|
import { C as E, P as He } from "./Prompt-DZb7OaPp.js";
|
|
9
9
|
import { d as Qe } from "./environmentUtils-VZNTCzEE.js";
|
|
10
|
-
import { r as je } from "./httpSessionService-
|
|
10
|
+
import { r as je } from "./httpSessionService-BCe4DpgA.js";
|
|
11
11
|
const K = {
|
|
12
12
|
PROMPTS: "envision-prompts"
|
|
13
13
|
}, Je = 50, re = class re {
|
|
@@ -55,7 +55,7 @@ const K = {
|
|
|
55
55
|
};
|
|
56
56
|
h(re, "LocalStorageService");
|
|
57
57
|
let ye = re;
|
|
58
|
-
const
|
|
58
|
+
const Nt = /* @__PURE__ */ h((i) => {
|
|
59
59
|
const e = i.getPrompts(), t = e.length;
|
|
60
60
|
if (t > 0) {
|
|
61
61
|
const s = e[0].promptText, n = e[e.length - 1].promptText, r = e[0].created;
|
|
@@ -70,6 +70,7 @@ const xt = /* @__PURE__ */ h((i) => {
|
|
|
70
70
|
a(this, "gatewayTurnComplete", "gatewayTurnComplete");
|
|
71
71
|
a(this, "gatewayStreamError", "gatewayStreamError");
|
|
72
72
|
a(this, "gatewayConnected", "gatewayConnected");
|
|
73
|
+
a(this, "gatewayRewindLost", "gatewayRewindLost");
|
|
73
74
|
a(this, "gatewayTurnOpen", "gatewayTurnOpen");
|
|
74
75
|
a(this, "gatewayFunctionResponse", "gatewayFunctionResponse");
|
|
75
76
|
a(this, "uiAskQuestion", "uiAskQuestion");
|
|
@@ -172,6 +173,17 @@ const d = new V(), ae = class ae {
|
|
|
172
173
|
gatewayOffConnected(e) {
|
|
173
174
|
this.removeListener(d.gatewayConnected, e);
|
|
174
175
|
}
|
|
176
|
+
/** A resume lost events for good (the server's replay window no longer reaches the cursor): the local
|
|
177
|
+
* transcript is stale and whoever holds the session record should reload it. */
|
|
178
|
+
gatewayOnRewindLost(e) {
|
|
179
|
+
this.addListener(d.gatewayRewindLost, e);
|
|
180
|
+
}
|
|
181
|
+
gatewayEmitRewindLost(e) {
|
|
182
|
+
this.callListeners(d.gatewayRewindLost, e);
|
|
183
|
+
}
|
|
184
|
+
gatewayOffRewindLost(e) {
|
|
185
|
+
this.removeListener(d.gatewayRewindLost, e);
|
|
186
|
+
}
|
|
175
187
|
chatOnMessageSent(e) {
|
|
176
188
|
this.addListener(d.onMessageSent, e);
|
|
177
189
|
}
|
|
@@ -391,7 +403,7 @@ function nt(i, e) {
|
|
|
391
403
|
h(nt, "mergeArtifacts");
|
|
392
404
|
function it(i, e, t) {
|
|
393
405
|
var c, l;
|
|
394
|
-
const s =
|
|
406
|
+
const s = x.FlatParts(e == null ? void 0 : e.parts), n = i.parts[i.parts.length - 1] ?? null, r = {
|
|
395
407
|
prev: i,
|
|
396
408
|
parts: i.parts,
|
|
397
409
|
functionMap: i.functionMap ?? /* @__PURE__ */ new Map()
|
|
@@ -449,7 +461,7 @@ const ce = class ce {
|
|
|
449
461
|
};
|
|
450
462
|
h(ce, "InteractionService");
|
|
451
463
|
let j = ce;
|
|
452
|
-
const Re = 4001, rt = 4002, be = 4004, ot = 4100, H = 500, at = 2e4, ct = 1e3, lt = 0.2,
|
|
464
|
+
const Re = 4001, rt = 4002, be = 4004, ot = 4100, H = 500, at = 2e4, ct = 1e3, lt = 0.2, _ = 300 * 1e3, ht = 0.75, ut = 2e3, w = "[Connection]", le = class le {
|
|
453
465
|
constructor(e) {
|
|
454
466
|
a(this, "ports");
|
|
455
467
|
a(this, "state");
|
|
@@ -660,9 +672,9 @@ const Re = 4001, rt = 4002, be = 4004, ot = 4100, H = 500, at = 2e4, ct = 1e3, l
|
|
|
660
672
|
if (!this.target) return;
|
|
661
673
|
this.state.turnOpen && this.state.setLastActivity();
|
|
662
674
|
const e = this.now() - this.state.lastActivity;
|
|
663
|
-
if (e >
|
|
675
|
+
if (e > _) {
|
|
664
676
|
if (this.state.sessionActive && this.state.setIsSessionActive(!1), this.cancelRetry(), this.state.connectionStatus === E.Connected) {
|
|
665
|
-
console.warn(`${w} idle for ${Math.round(e / 1e3)}s (limit ${
|
|
677
|
+
console.warn(`${w} idle for ${Math.round(e / 1e3)}s (limit ${_ / 1e3}s) — closing the socket (session ${this.target.sessionId ?? "(new)"}). Activity, or a send, redials it.`);
|
|
666
678
|
try {
|
|
667
679
|
this.ports.hangUp();
|
|
668
680
|
} catch (t) {
|
|
@@ -673,7 +685,7 @@ const Re = 4001, rt = 4002, be = 4004, ot = 4100, H = 500, at = 2e4, ct = 1e3, l
|
|
|
673
685
|
return;
|
|
674
686
|
}
|
|
675
687
|
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(() => {
|
|
676
|
-
}))), e >
|
|
688
|
+
}))), e > _ * ht ? this.idleWarningLogged || (this.idleWarningLogged = !0, console.warn(`${w} idle ${Math.round(e / 1e3)}s of ${_ / 1e3}s — the socket closes in about ${Math.round((_ - e) / 1e3)}s unless something happens.`)) : this.idleWarningLogged = !1;
|
|
677
689
|
}
|
|
678
690
|
};
|
|
679
691
|
h(le, "ConnectionSupervisor");
|
|
@@ -731,7 +743,7 @@ function ft(i) {
|
|
|
731
743
|
};
|
|
732
744
|
}
|
|
733
745
|
h(ft, "builtInCredentialCheck");
|
|
734
|
-
const
|
|
746
|
+
const T = class T {
|
|
735
747
|
constructor(e, t, s, n, r, o, c, l, f, g, m) {
|
|
736
748
|
a(this, "base_url");
|
|
737
749
|
a(this, "msg_order", 0);
|
|
@@ -782,7 +794,7 @@ const y = class y {
|
|
|
782
794
|
a(this, "everConnected", !1);
|
|
783
795
|
/** Publishes the live message to the store; see ThrottledEmitter for the cadence rules. */
|
|
784
796
|
a(this, "liveMessage", new te({
|
|
785
|
-
windowMs:
|
|
797
|
+
windowMs: T.CURRENT_MSG_THROTTLE_MS,
|
|
786
798
|
publish: /* @__PURE__ */ h((e) => {
|
|
787
799
|
this.sessionState.setCurrentMessage(e), this.eventBusService.gatewayEmitMessage(e);
|
|
788
800
|
}, "publish"),
|
|
@@ -813,11 +825,11 @@ const y = class y {
|
|
|
813
825
|
onRetryScheduled: /* @__PURE__ */ h(({ delayMs: u, attempt: p }) => {
|
|
814
826
|
var D;
|
|
815
827
|
const S = Date.now(), C = ((D = this.sessionState.connectionOutage) == null ? void 0 : D.since) ?? S;
|
|
816
|
-
this.sessionState.setConnectionOutage({ since: C, retryAt: S + u, attempt: p, halted: null }), S - C >=
|
|
828
|
+
this.sessionState.setConnectionOutage({ since: C, retryAt: S + u, attempt: p, halted: null }), S - C >= T.OUTAGE_CLOSES_TURN_AFTER_MS && this.closeOpenTurnWith(T.OUTAGE_TURN_MESSAGE);
|
|
817
829
|
}, "onRetryScheduled"),
|
|
818
830
|
onHalt: /* @__PURE__ */ h((u, p) => {
|
|
819
831
|
const S = this.sessionState.connectionOutage;
|
|
820
|
-
this.sessionState.setConnectionOutage({ since: (S == null ? void 0 : S.since) ?? Date.now(), retryAt: null, attempt: (S == null ? void 0 : S.attempt) ?? 0, halted: u }), this.notifyHalt(u, p), this.closeOpenTurnWith(
|
|
832
|
+
this.sessionState.setConnectionOutage({ since: (S == null ? void 0 : S.since) ?? Date.now(), retryAt: null, attempt: (S == null ? void 0 : S.attempt) ?? 0, halted: u }), this.notifyHalt(u, p), this.closeOpenTurnWith(T.HALT_TURN_MESSAGE[u]);
|
|
821
833
|
}, "onHalt")
|
|
822
834
|
}), this.wsService.onEvent = async (u) => {
|
|
823
835
|
await this.Message(u);
|
|
@@ -847,6 +859,8 @@ const y = class y {
|
|
|
847
859
|
this.localEmitFirstToken(u);
|
|
848
860
|
}, this.wsService.onClose = (u, p) => {
|
|
849
861
|
this.connection.transportClosed(u, p);
|
|
862
|
+
}, this.wsService.onRewindLost = (u, p) => {
|
|
863
|
+
this.handleRewindLost(u, p);
|
|
850
864
|
};
|
|
851
865
|
}
|
|
852
866
|
/**
|
|
@@ -857,7 +871,21 @@ const y = class y {
|
|
|
857
871
|
if (!this.sessionState.turnOpen) return;
|
|
858
872
|
const t = this.getCurrentInteractionId(), s = this.openTurns.size > 0 ? [...this.openTurns] : t ? [t] : [];
|
|
859
873
|
for (const n of s)
|
|
860
|
-
console.warn(`[AgentGateway] closing interaction ${n} from the client side: ${e}`), this.Message(U.createErrorEvent(e, n));
|
|
874
|
+
console.warn(`[AgentGateway] closing interaction ${n} from the client side: ${e}`), this.Message(U.createErrorEvent(e, n, { connectionCutoff: !0 }));
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* The resume lost events for good: the server's replay window (SessionReplayFrames, 2 h TTL) no longer
|
|
878
|
+
* reaches back to this tab's cursor, so whatever the session did in between will NEVER arrive — a turn
|
|
879
|
+
* that ended while we were away stays open here, a parked ask-user that was answered or expired keeps
|
|
880
|
+
* showing "aguardando", and the transcript silently disagrees with the server until a full reload.
|
|
881
|
+
* The transport used to log the RewindLost frame and carry on; nobody listened (AIA, 2026-11-15).
|
|
882
|
+
*
|
|
883
|
+
* The local copy is stale by definition here: close anything still waiting (no replay can continue it)
|
|
884
|
+
* and tell the host through the bus — SessionStateManagerService reloads the session record over REST
|
|
885
|
+
* and rebinds the transcript to the server's truth.
|
|
886
|
+
*/
|
|
887
|
+
handleRewindLost(e, t) {
|
|
888
|
+
console.warn(`[AgentGateway] the resume lost events (session ${e}, server resumes from seq ${t}) — asking for the record to be reloaded.`), this.closeOpenTurnWith(T.REWIND_LOST_TURN_MESSAGE), this.eventBusService.gatewayEmitRewindLost(e);
|
|
861
889
|
}
|
|
862
890
|
/** The supervisor gave up on its own (another tab holds the session, the session is gone, …): tell the user. */
|
|
863
891
|
notifyHalt(e, t) {
|
|
@@ -1231,12 +1259,12 @@ const y = class y {
|
|
|
1231
1259
|
const s = await this.connection.ensure(e);
|
|
1232
1260
|
console.log(`[AgentGateway] send guard: reconnected to ${s} in ${Date.now() - t}ms — sending now.`);
|
|
1233
1261
|
} catch (s) {
|
|
1234
|
-
throw console.error(`[AgentGateway] send guard: redial FAILED after ${Date.now() - t}ms — the message was not sent.`, s), new Error(
|
|
1262
|
+
throw console.error(`[AgentGateway] send guard: redial FAILED after ${Date.now() - t}ms — the message was not sent.`, s), new Error(T.NO_CONNECTION_MESSAGE, { cause: s });
|
|
1235
1263
|
}
|
|
1236
1264
|
}
|
|
1237
1265
|
// ─── Outbound: the user's turns ─────────────────────────────────────────
|
|
1238
1266
|
async sendMessage(e, t) {
|
|
1239
|
-
let s = this.getInteractions().length, n =
|
|
1267
|
+
let s = this.getInteractions().length, n = x.createWaiting(!0, !0, "Overall", /* @__PURE__ */ new Date());
|
|
1240
1268
|
this.sendStatusMessage(e.data, [n], s.toString() + "1");
|
|
1241
1269
|
try {
|
|
1242
1270
|
const { promptAsString: r, json: o } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(e.data) : { promptAsString: e.data, json: void 0 };
|
|
@@ -1245,7 +1273,7 @@ const y = class y {
|
|
|
1245
1273
|
try {
|
|
1246
1274
|
const l = He.createPrompt(r ?? "", (o == null ? void 0 : o.toString()) ?? {});
|
|
1247
1275
|
this.storageService.storePrompt(l);
|
|
1248
|
-
const f =
|
|
1276
|
+
const f = x.fromText("Planejando próximos passos");
|
|
1249
1277
|
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
1278
|
} catch (l) {
|
|
1251
1279
|
console.error("[AgentGateway] the message was sent, but what follows the send failed", l);
|
|
@@ -1261,7 +1289,7 @@ const y = class y {
|
|
|
1261
1289
|
created: /* @__PURE__ */ new Date(),
|
|
1262
1290
|
interactionId: "",
|
|
1263
1291
|
partial: !1,
|
|
1264
|
-
parts: [
|
|
1292
|
+
parts: [x.fromError(o)],
|
|
1265
1293
|
version: 0
|
|
1266
1294
|
}
|
|
1267
1295
|
};
|
|
@@ -1273,7 +1301,7 @@ const y = class y {
|
|
|
1273
1301
|
const s = this.suspendState;
|
|
1274
1302
|
this.suspendState = !1;
|
|
1275
1303
|
const n = this.startInteraction(e.friendlyMessage ?? e.data, s);
|
|
1276
|
-
if (this.localInteractionIds.add(n.interactionId), this.registerInteractionCallId(n.interactionId, t), (r = e.userUi) != null && r.name && n.parts.push(
|
|
1304
|
+
if (this.localInteractionIds.add(n.interactionId), this.registerInteractionCallId(n.interactionId, t), (r = e.userUi) != null && r.name && n.parts.push(x.fromUserUi(e.userUi.name, e.userUi.args)), !this.wsService)
|
|
1277
1305
|
throw "no wsService created";
|
|
1278
1306
|
if (!((o = this.config.agentConfig) != null && o.id))
|
|
1279
1307
|
throw "Agent not selected";
|
|
@@ -1479,30 +1507,31 @@ const y = class y {
|
|
|
1479
1507
|
return new Promise((t) => setTimeout(t, e));
|
|
1480
1508
|
}
|
|
1481
1509
|
};
|
|
1482
|
-
h(
|
|
1510
|
+
h(T, "AgentGatewayWSAsync"), // How often the streaming message re-renders. 150 ms made a reasoning highlight, or a burst of them, visibly lag the
|
|
1483
1511
|
// server (Ciro, 2026-10-07). The server already merges deltas over a 50 ms window (the SDK's DeltaCoalescer), so
|
|
1484
1512
|
// frames arrive at ~20/s per kind and 20 ms here costs little: it mostly stops adding a second delay on top.
|
|
1485
|
-
a(
|
|
1513
|
+
a(T, "CURRENT_MSG_THROTTLE_MS", 20), /**
|
|
1486
1514
|
* How long an open turn survives a connection outage. While the supervisor is redialling the
|
|
1487
1515
|
* turn stays open — a short blip resumes it from the replay cursor, and a server that comes back
|
|
1488
1516
|
* (or another instance) closes it with an error if its run is gone. Past this, nobody can tell
|
|
1489
1517
|
* us anything, and a turn that is still open is a composer that is still locked: the client
|
|
1490
1518
|
* closes it itself, with an error part, so the user can go on.
|
|
1491
1519
|
*/
|
|
1492
|
-
a(
|
|
1493
|
-
a(
|
|
1520
|
+
a(T, "OUTAGE_CLOSES_TURN_AFTER_MS", 6e4), a(T, "OUTAGE_TURN_MESSAGE", "Sem conexão com o servidor há mais de um minuto. A resposta foi interrompida."), /** What the cutoff note says when a resume could not replay what was missed (see {@link handleRewindLost}). */
|
|
1521
|
+
a(T, "REWIND_LOST_TURN_MESSAGE", "A conexão ficou fora do ar por muito tempo e esta resposta não pôde ser recuperada."), /** What a send reports when the socket could not be brought up for it. */
|
|
1522
|
+
a(T, "NO_CONNECTION_MESSAGE", "Não foi possível obter conexão com o servidor"), a(T, "HALT_TURN_MESSAGE", {
|
|
1494
1523
|
"attached-elsewhere": "Esta sessão está aberta em outra janela. A resposta foi interrompida.",
|
|
1495
1524
|
"session-gone": "A sessão não existe mais no servidor. A resposta foi interrompida.",
|
|
1496
1525
|
"closed-by-server": "O servidor encerrou a conexão. A resposta foi interrompida.",
|
|
1497
1526
|
"credentials-expired": "Sua sessão expirou. Entre novamente para continuar. A resposta foi interrompida."
|
|
1498
1527
|
});
|
|
1499
|
-
let Me =
|
|
1528
|
+
let Me = T;
|
|
1500
1529
|
function gt(i) {
|
|
1501
|
-
const e = new
|
|
1530
|
+
const e = new _e();
|
|
1502
1531
|
e.author = "main", e.streamingParts = i.streamingParts, i.partialEventType ? e.eventType = i.partialEventType : e.eventType = i.functionName ? { fullName: z.StreamingFunctionCallUpdateContent, type: I.PartialFunctionCall } : i.partialReasoning ? { fullName: z.StreamingReasoningContent, type: I.Thought } : { fullName: z.StreamingTextContent, type: I.Text }, e.interactionId = i.iteractionId ?? "", e.mimeType = "text/plain", e.partial = !0, e.role = { label: "Assistant" }, e.timestamp = i.timeStamp ?? (/* @__PURE__ */ new Date()).getTime(), e.turnComplete = !1;
|
|
1503
1532
|
const t = e.eventType.type;
|
|
1504
1533
|
if (t == I.PartialFunctionCall) {
|
|
1505
|
-
const s = new
|
|
1534
|
+
const s = new xe();
|
|
1506
1535
|
s.choiceIndex = 0, s.callId = i.functionCallId, s.arguments = i.partialText, s.name = i.functionName, e.content = { items: [s], role: { label: "Assistant" } };
|
|
1507
1536
|
} else if (t == I.Text)
|
|
1508
1537
|
if (e.eventType.fullName == z.StreamingTextContent) {
|
|
@@ -1513,7 +1542,7 @@ function gt(i) {
|
|
|
1513
1542
|
s.text = i.partialText, e.content = { items: [s], role: { label: "Assistant" } };
|
|
1514
1543
|
}
|
|
1515
1544
|
else if (t == I.Thought) {
|
|
1516
|
-
const s = new
|
|
1545
|
+
const s = new We();
|
|
1517
1546
|
s.text = i.partialReasoning, e.content = { items: [s], role: { label: "Assistant" } };
|
|
1518
1547
|
}
|
|
1519
1548
|
return e;
|
|
@@ -1534,7 +1563,7 @@ function Pe(i) {
|
|
|
1534
1563
|
var t;
|
|
1535
1564
|
if (i.type !== "InteractionStarted" || !((t = i.interaction) != null && t.interactionId)) return;
|
|
1536
1565
|
if (i.interaction.detachedRunId || !i.detachedRunId) return i.interaction;
|
|
1537
|
-
const e = Object.assign(new
|
|
1566
|
+
const e = Object.assign(new Ne(), i.interaction);
|
|
1538
1567
|
return e.detachedRunId = i.detachedRunId, e;
|
|
1539
1568
|
}
|
|
1540
1569
|
h(Pe, "interactionStartFromFrame");
|
|
@@ -1696,7 +1725,7 @@ const It = 5e3, Tt = 3e4, X = 1e4, ue = class ue {
|
|
|
1696
1725
|
*/
|
|
1697
1726
|
connect(e, t) {
|
|
1698
1727
|
return new Promise(async (s, n) => {
|
|
1699
|
-
var D,
|
|
1728
|
+
var D, N;
|
|
1700
1729
|
t != null && t.resume || (this.lastSeq = -1);
|
|
1701
1730
|
const r = (D = this.getToken) == null ? void 0 : D.call(this), o = [];
|
|
1702
1731
|
r && o.push(`access_token=${encodeURIComponent(r)}`), e && this.lastSeq >= 0 && o.push(`lastSeq=${this.lastSeq}`), e && (t != null && t.resume) && t.openInteractionId && o.push(`openInteraction=${encodeURIComponent(t.openInteractionId)}`);
|
|
@@ -1746,7 +1775,7 @@ const It = 5e3, Tt = 3e4, X = 1e4, ue = class ue {
|
|
|
1746
1775
|
}
|
|
1747
1776
|
S % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(g), S += g, p.readyState === WebSocket.OPEN && (C += g);
|
|
1748
1777
|
}
|
|
1749
|
-
console.log(`[WebSocket] Session ${this.sessionId} proven${this.lastSeq >= 0 ? ` (replaying from lastSeq=${this.lastSeq})` : ""}.`), this.lastKnownSessionId = this.sessionId, (
|
|
1778
|
+
console.log(`[WebSocket] Session ${this.sessionId} proven${this.lastSeq >= 0 ? ` (replaying from lastSeq=${this.lastSeq})` : ""}.`), this.lastKnownSessionId = this.sessionId, (N = this.onOpen) == null || N.call(this), this.flushPendingAnswers(this.sessionId), s(this.sessionId);
|
|
1750
1779
|
});
|
|
1751
1780
|
}
|
|
1752
1781
|
/** Drop the current socket without reporting it: handlers off, then close. */
|
|
@@ -1988,7 +2017,7 @@ const It = 5e3, Tt = 3e4, X = 1e4, ue = class ue {
|
|
|
1988
2017
|
}
|
|
1989
2018
|
async handleEvent(e, t) {
|
|
1990
2019
|
var n, r, o, c;
|
|
1991
|
-
const s = (r = (n = e.content) == null ? void 0 : n.items) == null ? void 0 : r.find((l) => l instanceof
|
|
2020
|
+
const s = (r = (n = e.content) == null ? void 0 : n.items) == null ? void 0 : r.find((l) => l instanceof Be);
|
|
1992
2021
|
if (s) {
|
|
1993
2022
|
(o = this.onBillingLimit) == null || o.call(this, {
|
|
1994
2023
|
plan: s.plan ?? "team",
|
|
@@ -2148,8 +2177,8 @@ function Ct(i, e, t, s) {
|
|
|
2148
2177
|
}
|
|
2149
2178
|
h(Ct, "framesUrl");
|
|
2150
2179
|
async function At(i) {
|
|
2151
|
-
var
|
|
2152
|
-
const { baseUrl: e, runId: t, signal: s, onFrame: n, onEnd: r, onOpen: o, onRetry: c } = i, l = i.resource ?? "detachedRun", f = i.fetchImpl ?? ((A, $) => fetch(A, $)), g = ((
|
|
2180
|
+
var N, v, M, pe, me;
|
|
2181
|
+
const { baseUrl: e, runId: t, signal: s, onFrame: n, onEnd: r, onOpen: o, onRetry: c } = i, l = i.resource ?? "detachedRun", f = i.fetchImpl ?? ((A, $) => fetch(A, $)), g = ((N = i.retry) == null ? void 0 : N.initialMs) ?? 500, m = ((v = i.retry) == null ? void 0 : v.maxMs) ?? 15e3, u = ((M = i.retry) == null ? void 0 : M.maxAttempts) ?? Number.POSITIVE_INFINITY;
|
|
2153
2182
|
let p = i.afterSeq ?? 0, S = 0, C = !1;
|
|
2154
2183
|
async function D(A) {
|
|
2155
2184
|
if (i.onUnauthorized)
|
|
@@ -2179,45 +2208,45 @@ async function At(i) {
|
|
|
2179
2208
|
throw Et(O.status) ? new Error(`GET detached-run frames answered ${O.status}`) : new P(O.status);
|
|
2180
2209
|
if (!O.body) throw new P(O.status, "The frames response has no readable body");
|
|
2181
2210
|
o == null || o();
|
|
2182
|
-
let
|
|
2183
|
-
const
|
|
2184
|
-
if (
|
|
2185
|
-
const b = Number(
|
|
2186
|
-
|
|
2211
|
+
let W = !1;
|
|
2212
|
+
const B = vt((y) => {
|
|
2213
|
+
if (y.event === "end") {
|
|
2214
|
+
const b = Number(y.data);
|
|
2215
|
+
y.data !== "" && Number.isFinite(b) && b > p && (p = b), W = !0;
|
|
2187
2216
|
return;
|
|
2188
2217
|
}
|
|
2189
|
-
if (
|
|
2190
|
-
const R =
|
|
2218
|
+
if (y.event !== void 0 && y.event !== "message" || y.data === "") return;
|
|
2219
|
+
const R = y.id !== void 0 && y.id !== "" ? Number(y.id) : void 0;
|
|
2191
2220
|
if (R !== void 0 && Number.isFinite(R)) {
|
|
2192
2221
|
if (R <= p) return;
|
|
2193
2222
|
p = R;
|
|
2194
2223
|
}
|
|
2195
|
-
|
|
2224
|
+
W = !1;
|
|
2196
2225
|
let Se;
|
|
2197
2226
|
try {
|
|
2198
|
-
Se = JSON.parse(
|
|
2227
|
+
Se = JSON.parse(y.data);
|
|
2199
2228
|
} catch (b) {
|
|
2200
|
-
console.warn(`[DetachedRunFrames] run ${t}: a frame that is not JSON was skipped (seq ${
|
|
2229
|
+
console.warn(`[DetachedRunFrames] run ${t}: a frame that is not JSON was skipped (seq ${y.id ?? "?"})`, b);
|
|
2201
2230
|
return;
|
|
2202
2231
|
}
|
|
2203
2232
|
S = 0;
|
|
2204
2233
|
try {
|
|
2205
2234
|
n(Se, R);
|
|
2206
2235
|
} catch (b) {
|
|
2207
|
-
console.error(`[DetachedRunFrames] run ${t}: onFrame threw on seq ${
|
|
2236
|
+
console.error(`[DetachedRunFrames] run ${t}: onFrame threw on seq ${y.id ?? "?"}`, b);
|
|
2208
2237
|
}
|
|
2209
2238
|
}), G = O.body.getReader(), we = new TextDecoder();
|
|
2210
2239
|
try {
|
|
2211
2240
|
for (; ; ) {
|
|
2212
|
-
const { done:
|
|
2213
|
-
if (
|
|
2214
|
-
|
|
2241
|
+
const { done: y, value: R } = await G.read();
|
|
2242
|
+
if (y) break;
|
|
2243
|
+
B.push(we.decode(R, { stream: !0 }));
|
|
2215
2244
|
}
|
|
2216
|
-
|
|
2245
|
+
B.push(we.decode()), B.idle() || (W = !1), B.flush();
|
|
2217
2246
|
} finally {
|
|
2218
2247
|
(me = G.releaseLock) == null || me.call(G);
|
|
2219
2248
|
}
|
|
2220
|
-
if (
|
|
2249
|
+
if (W && l !== "session")
|
|
2221
2250
|
return r == null || r(p), { reason: "end", lastSeq: p };
|
|
2222
2251
|
A = new Error(l === "session" ? "The session frames stream closed" : "The frames stream closed before its end event");
|
|
2223
2252
|
} catch (k) {
|
|
@@ -2363,7 +2392,7 @@ const ge = class ge {
|
|
|
2363
2392
|
h(ge, "DetachedRunFramesTransport");
|
|
2364
2393
|
let De = ge;
|
|
2365
2394
|
const kt = "todolistUpdated";
|
|
2366
|
-
function
|
|
2395
|
+
function _t(i, e = ne()) {
|
|
2367
2396
|
var n, r;
|
|
2368
2397
|
let t;
|
|
2369
2398
|
try {
|
|
@@ -2381,7 +2410,7 @@ function Nt(i, e = ne()) {
|
|
|
2381
2410
|
} else (o.eventType === I.FunctionCall || o.eventType === I.PartialFunctionCall) && ((r = o.functionDetails) != null && r.name) ? s.push({ kind: "tool", name: o.functionDetails.name, interactionId: t.interactionId }) : o.eventType === I.Text && o.text && s.push({ kind: "text", text: o.text, partial: !!t.partial, interactionId: t.interactionId });
|
|
2382
2411
|
return s;
|
|
2383
2412
|
}
|
|
2384
|
-
h(
|
|
2413
|
+
h(_t, "readDetachedRunActivity");
|
|
2385
2414
|
function Ot(i) {
|
|
2386
2415
|
if (!i) return null;
|
|
2387
2416
|
try {
|
|
@@ -2398,7 +2427,7 @@ export {
|
|
|
2398
2427
|
P as D,
|
|
2399
2428
|
ve as E,
|
|
2400
2429
|
Oe as H,
|
|
2401
|
-
|
|
2430
|
+
_ as I,
|
|
2402
2431
|
ye as L,
|
|
2403
2432
|
Z as M,
|
|
2404
2433
|
kt as T,
|
|
@@ -2408,9 +2437,9 @@ export {
|
|
|
2408
2437
|
ke as c,
|
|
2409
2438
|
vt as d,
|
|
2410
2439
|
it as e,
|
|
2411
|
-
|
|
2440
|
+
_t as r,
|
|
2412
2441
|
At as s,
|
|
2413
2442
|
yt as t,
|
|
2414
|
-
|
|
2443
|
+
Nt as u
|
|
2415
2444
|
};
|
|
2416
|
-
//# sourceMappingURL=detachedRunActivity-
|
|
2445
|
+
//# sourceMappingURL=detachedRunActivity-Dw1Far2p.js.map
|