@aintela/chat 0.4.27 → 0.4.29
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 +2578 -2567
- package/dist/components.js.map +1 -1
- package/dist/{httpArtifactService-ogJ9kOTq.js → httpArtifactService-_66bhjGo.js} +169 -151
- package/dist/httpArtifactService-_66bhjGo.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/services.js +1 -1
- package/dist/src/components/v2/PromptV2.d.ts +12 -0
- package/dist/src/services/eventBusService.d.ts +4 -0
- package/package.json +1 -1
- package/dist/httpArtifactService-ogJ9kOTq.js.map +0 -1
|
@@ -3,11 +3,11 @@ var St = (w, t, e) => t in w ? at(w, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var f = (w, t) => at(w, "name", { value: t, configurable: !0 });
|
|
4
4
|
var i = (w, t, e) => St(w, typeof t != "symbol" ? t + "" : t, e);
|
|
5
5
|
import { i as wt, a as yt, d as Tt } from "./environmentUtils-VZNTCzEE.js";
|
|
6
|
-
import { I as _, E as C, j as Ct, S as gt, q as It, L as vt, P as U, l as Et, o as Mt, T as Dt, m as
|
|
7
|
-
import { unified as
|
|
6
|
+
import { I as _, E as C, j as Ct, S as gt, q as It, L as vt, P as U, l as Et, o as Mt, T as Dt, m as At, C as F } from "./serializer-BB8Cz7YD.js";
|
|
7
|
+
import { unified as Ot } from "unified";
|
|
8
8
|
import kt from "remark-parse";
|
|
9
|
-
import { toMarkdown as
|
|
10
|
-
import { format as
|
|
9
|
+
import { toMarkdown as Nt } from "mdast-util-to-markdown";
|
|
10
|
+
import { format as Pt } from "date-fns";
|
|
11
11
|
import _t from "lodash";
|
|
12
12
|
import { P as bt, C as k } from "./Prompt-DZb7OaPp.js";
|
|
13
13
|
import { r as Rt } from "./httpSessionService-B3CxFtl1.js";
|
|
@@ -65,7 +65,7 @@ const re = /* @__PURE__ */ f((w) => {
|
|
|
65
65
|
return { promptState: e + "_" + s + "_" + o + "_" + n };
|
|
66
66
|
} else
|
|
67
67
|
return { promptState: "0" };
|
|
68
|
-
}, "usePromptState"),
|
|
68
|
+
}, "usePromptState"), Q = class Q {
|
|
69
69
|
constructor() {
|
|
70
70
|
i(this, "activityLost", "activityLost");
|
|
71
71
|
i(this, "artifactGenerated", "artifactGenerated");
|
|
@@ -79,6 +79,7 @@ const re = /* @__PURE__ */ f((w) => {
|
|
|
79
79
|
i(this, "sessionUpdated", "sessionUpdated");
|
|
80
80
|
i(this, "gatewayFunctionResponse", "gatewayFunctionResponse");
|
|
81
81
|
i(this, "uiUnsavedPopoverToggle", "uiUnsavedPopoverToggle");
|
|
82
|
+
i(this, "uiAskQuestion", "uiAskQuestion");
|
|
82
83
|
i(this, "artifactsStorageUpdated", "artifactsStorageUpdated");
|
|
83
84
|
i(this, "gatewayStreamEnded", "gatewayStreamEnded");
|
|
84
85
|
i(this, "streamNewChunk", "streamNewChunk");
|
|
@@ -90,9 +91,9 @@ const re = /* @__PURE__ */ f((w) => {
|
|
|
90
91
|
i(this, "gatewayFirstToken", "gatewayFirstToken");
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
|
-
f(
|
|
94
|
-
let H =
|
|
95
|
-
const
|
|
94
|
+
f(Q, "EventTypes");
|
|
95
|
+
let H = Q;
|
|
96
|
+
const r = new H(), X = class X {
|
|
96
97
|
constructor() {
|
|
97
98
|
i(this, "listeners", {});
|
|
98
99
|
i(this, "listenersCount", {});
|
|
@@ -113,239 +114,256 @@ const c = new H(), Y = class Y {
|
|
|
113
114
|
return this.listenersCount[t];
|
|
114
115
|
}
|
|
115
116
|
activityOnLost(t) {
|
|
116
|
-
const e =
|
|
117
|
+
const e = r.activityLost;
|
|
117
118
|
this.addListener(e, t);
|
|
118
119
|
}
|
|
119
120
|
activityEmitLost() {
|
|
120
|
-
this.callListeners(
|
|
121
|
+
this.callListeners(r.activityLost);
|
|
121
122
|
}
|
|
122
123
|
/* typed artifact listeners */
|
|
123
124
|
artifactOnGenerated(t) {
|
|
124
|
-
const e =
|
|
125
|
+
const e = r.artifactGenerated;
|
|
125
126
|
this.addListener(e, t);
|
|
126
127
|
}
|
|
127
128
|
artifactEmitGenerated(t) {
|
|
128
|
-
this.callListeners(
|
|
129
|
+
this.callListeners(r.artifactGenerated, t);
|
|
129
130
|
}
|
|
130
131
|
artifactOffGenerated(t) {
|
|
131
|
-
const e =
|
|
132
|
+
const e = r.artifactGenerated;
|
|
132
133
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
133
134
|
}
|
|
134
135
|
artifactOnSelected(t) {
|
|
135
|
-
const e =
|
|
136
|
+
const e = r.artifactSelected;
|
|
136
137
|
this.addListener(e, t);
|
|
137
138
|
}
|
|
138
139
|
artifactEmitSelected(t) {
|
|
139
|
-
this.callListeners(
|
|
140
|
+
this.callListeners(r.artifactSelected, t);
|
|
140
141
|
}
|
|
141
142
|
artifactOffSelected(t) {
|
|
142
|
-
const e =
|
|
143
|
+
const e = r.artifactSelected;
|
|
143
144
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
144
145
|
}
|
|
145
146
|
artifactOnDeleted(t) {
|
|
146
|
-
const e =
|
|
147
|
+
const e = r.artifactDeleted;
|
|
147
148
|
this.addListener(e, t);
|
|
148
149
|
}
|
|
149
150
|
artifactEmitDeleted(t) {
|
|
150
|
-
this.callListeners(
|
|
151
|
+
this.callListeners(r.artifactDeleted, t);
|
|
151
152
|
}
|
|
152
153
|
artifactOffDeleted(t) {
|
|
153
|
-
const e =
|
|
154
|
+
const e = r.artifactDeleted;
|
|
154
155
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
155
156
|
}
|
|
156
157
|
gatewayOnMessage(t) {
|
|
157
|
-
const e =
|
|
158
|
+
const e = r.gatewayMessage;
|
|
158
159
|
this.addListener(e, t);
|
|
159
160
|
}
|
|
160
161
|
gatewayOnTurnComplete(t) {
|
|
161
|
-
const e =
|
|
162
|
+
const e = r.gatewayTurnComplete;
|
|
162
163
|
this.addListener(e, t);
|
|
163
164
|
}
|
|
164
165
|
gatewayOnTurnOpen(t) {
|
|
165
|
-
const e =
|
|
166
|
+
const e = r.gatewayTurnOpen;
|
|
166
167
|
this.addListener(e, t);
|
|
167
168
|
}
|
|
168
169
|
gatewayOnStreamError(t) {
|
|
169
|
-
const e =
|
|
170
|
+
const e = r.gatewayStreamError;
|
|
170
171
|
this.addListener(e, t);
|
|
171
172
|
}
|
|
172
173
|
gatewayOnStreamEnded(t) {
|
|
173
|
-
const e =
|
|
174
|
+
const e = r.gatewayStreamEnded;
|
|
174
175
|
this.addListener(e, t);
|
|
175
176
|
}
|
|
176
177
|
gatewayOffStreamEnded(t) {
|
|
177
|
-
const e =
|
|
178
|
+
const e = r.gatewayStreamEnded;
|
|
178
179
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
179
180
|
}
|
|
180
181
|
gatewayEmitStreamEnded(t, e) {
|
|
181
|
-
this.callListeners(
|
|
182
|
+
this.callListeners(r.gatewayStreamEnded, t, e);
|
|
182
183
|
}
|
|
183
184
|
gatewayEmitMessage(t, e = null) {
|
|
184
|
-
this.callListeners(
|
|
185
|
+
this.callListeners(r.gatewayMessage, t, e);
|
|
185
186
|
}
|
|
186
187
|
gatewayEmitTurnComplete(t, e) {
|
|
187
|
-
this.callListeners(
|
|
188
|
+
this.callListeners(r.gatewayTurnComplete, t, e);
|
|
188
189
|
}
|
|
189
190
|
gatewayEmitStreamError(t) {
|
|
190
|
-
this.callListeners(
|
|
191
|
+
this.callListeners(r.gatewayStreamError, t);
|
|
191
192
|
}
|
|
192
193
|
gatewayEmitTurnOpen(t) {
|
|
193
|
-
this.callListeners(
|
|
194
|
+
this.callListeners(r.gatewayTurnOpen, t);
|
|
194
195
|
}
|
|
195
196
|
gatewayOffMessage(t) {
|
|
196
|
-
const e =
|
|
197
|
+
const e = r.gatewayMessage;
|
|
197
198
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
198
199
|
}
|
|
199
200
|
gatewayOffTurnComplete(t) {
|
|
200
|
-
const e =
|
|
201
|
+
const e = r.gatewayTurnComplete;
|
|
201
202
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
202
203
|
}
|
|
203
204
|
gatewayOffTurnOpen(t) {
|
|
204
|
-
const e =
|
|
205
|
+
const e = r.gatewayTurnOpen;
|
|
205
206
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
206
207
|
}
|
|
207
208
|
gatewayOffStreamError(t) {
|
|
208
|
-
const e =
|
|
209
|
+
const e = r.gatewayStreamError;
|
|
209
210
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
210
211
|
}
|
|
211
212
|
sessionOnCreated(t) {
|
|
212
|
-
const e =
|
|
213
|
+
const e = r.sessionCreated;
|
|
213
214
|
this.addListener(e, t);
|
|
214
215
|
}
|
|
215
216
|
chatOnMessageSent(t) {
|
|
216
|
-
const e =
|
|
217
|
+
const e = r.onMessageSent;
|
|
217
218
|
this.addListener(e, t);
|
|
218
219
|
}
|
|
219
220
|
chatOffMessageSent(t) {
|
|
220
|
-
const e =
|
|
221
|
+
const e = r.onMessageSent;
|
|
221
222
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
222
223
|
}
|
|
223
224
|
ChatEmitMessageSent(t, e) {
|
|
224
|
-
this.callListeners(
|
|
225
|
+
this.callListeners(r.onMessageSent, t, e);
|
|
225
226
|
}
|
|
226
227
|
chatOnMessageError(t) {
|
|
227
|
-
const e =
|
|
228
|
+
const e = r.onMessageError;
|
|
228
229
|
this.addListener(e, t);
|
|
229
230
|
}
|
|
230
231
|
chatOffMessageError(t) {
|
|
231
|
-
const e =
|
|
232
|
+
const e = r.onMessageError;
|
|
232
233
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
233
234
|
}
|
|
234
235
|
ChatEmitMessageError(t) {
|
|
235
|
-
this.callListeners(
|
|
236
|
+
this.callListeners(r.onMessageError, t);
|
|
236
237
|
}
|
|
237
238
|
sessionOnUpdated(t) {
|
|
238
|
-
const e =
|
|
239
|
+
const e = r.sessionUpdated;
|
|
239
240
|
this.addListener(e, t);
|
|
240
241
|
}
|
|
241
242
|
sessionEmitCreated(t) {
|
|
242
|
-
this.callListeners(
|
|
243
|
+
this.callListeners(r.sessionCreated, t);
|
|
243
244
|
}
|
|
244
245
|
sessionEmitUpdated(t) {
|
|
245
|
-
this.callListeners(
|
|
246
|
+
this.callListeners(r.sessionUpdated, t);
|
|
246
247
|
}
|
|
247
248
|
sessionOffCreated(t) {
|
|
248
|
-
const e =
|
|
249
|
+
const e = r.sessionCreated;
|
|
249
250
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
250
251
|
}
|
|
251
252
|
sessionOffUpdated(t) {
|
|
252
|
-
const e =
|
|
253
|
+
const e = r.sessionUpdated;
|
|
253
254
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
254
255
|
}
|
|
255
256
|
gatewayEmitFunctionResponse(t) {
|
|
256
|
-
this.callListeners(
|
|
257
|
+
this.callListeners(r.gatewayFunctionResponse, t);
|
|
257
258
|
}
|
|
258
259
|
gatewayOffFunctionResponse(t) {
|
|
259
|
-
const e =
|
|
260
|
+
const e = r.gatewayFunctionResponse;
|
|
260
261
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
261
262
|
}
|
|
262
263
|
gatewayOnFunctionResponse(t) {
|
|
263
|
-
const e =
|
|
264
|
+
const e = r.gatewayFunctionResponse;
|
|
264
265
|
this.addListener(e, t);
|
|
265
266
|
}
|
|
266
267
|
// UI events
|
|
267
268
|
uiOnUnsavedPopoverToggle(t) {
|
|
268
|
-
const e =
|
|
269
|
+
const e = r.uiUnsavedPopoverToggle;
|
|
269
270
|
this.addListener(e, t);
|
|
270
271
|
}
|
|
271
272
|
uiEmitUnsavedPopoverToggle(t) {
|
|
272
|
-
this.callListeners(
|
|
273
|
+
this.callListeners(r.uiUnsavedPopoverToggle, t);
|
|
273
274
|
}
|
|
274
275
|
uiOffUnsavedPopoverToggle(t) {
|
|
275
|
-
const e =
|
|
276
|
+
const e = r.uiUnsavedPopoverToggle;
|
|
277
|
+
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
278
|
+
}
|
|
279
|
+
// "Re-ask this" — a `#ask-…` link in the transcript, carrying the link's TEXT as the question.
|
|
280
|
+
// An event rather than component state because the prompt that must send it is not always
|
|
281
|
+
// ChatPane's own: a host that passes `hidePromptInput` mounts its own `PromptV2` elsewhere in
|
|
282
|
+
// its tree, and that instance cannot see ChatPane's `useState`. Whichever prompt is mounted
|
|
283
|
+
// listens; ChatPane publishes only when its internal one is suppressed, so the question is
|
|
284
|
+
// never sent twice.
|
|
285
|
+
uiOnAskQuestion(t) {
|
|
286
|
+
const e = r.uiAskQuestion;
|
|
287
|
+
this.addListener(e, t);
|
|
288
|
+
}
|
|
289
|
+
uiEmitAskQuestion(t) {
|
|
290
|
+
this.callListeners(r.uiAskQuestion, t);
|
|
291
|
+
}
|
|
292
|
+
uiOffAskQuestion(t) {
|
|
293
|
+
const e = r.uiAskQuestion;
|
|
276
294
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
277
295
|
}
|
|
278
296
|
// Artifacts storage update events
|
|
279
297
|
artifactsOnStorageUpdated(t) {
|
|
280
|
-
const e =
|
|
298
|
+
const e = r.artifactsStorageUpdated;
|
|
281
299
|
this.addListener(e, t);
|
|
282
300
|
}
|
|
283
301
|
artifactsEmitStorageUpdated() {
|
|
284
|
-
this.callListeners(
|
|
302
|
+
this.callListeners(r.artifactsStorageUpdated);
|
|
285
303
|
}
|
|
286
304
|
artifactsOffStorageUpdated(t) {
|
|
287
|
-
const e =
|
|
305
|
+
const e = r.artifactsStorageUpdated;
|
|
288
306
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
289
307
|
}
|
|
290
308
|
streamOnNewChunk(t) {
|
|
291
|
-
const e =
|
|
309
|
+
const e = r.streamNewChunk;
|
|
292
310
|
this.addListener(e, t);
|
|
293
311
|
}
|
|
294
312
|
streamEmitNewChunk(t) {
|
|
295
|
-
this.callListeners(
|
|
313
|
+
this.callListeners(r.streamNewChunk, t);
|
|
296
314
|
}
|
|
297
315
|
streamOffNewChunk(t) {
|
|
298
|
-
const e =
|
|
316
|
+
const e = r.streamNewChunk;
|
|
299
317
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
300
318
|
}
|
|
301
319
|
gatewayOnEndMessageData(t) {
|
|
302
|
-
const e =
|
|
320
|
+
const e = r.gatewayEndMessageData;
|
|
303
321
|
this.addListener(e, t);
|
|
304
322
|
}
|
|
305
323
|
gatewayEmitEndMessageData(t) {
|
|
306
|
-
this.callListeners(
|
|
324
|
+
this.callListeners(r.gatewayEndMessageData, t);
|
|
307
325
|
}
|
|
308
326
|
gatewayOffEndMessageData(t) {
|
|
309
|
-
const e =
|
|
327
|
+
const e = r.gatewayEndMessageData;
|
|
310
328
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
311
329
|
}
|
|
312
330
|
gatewayOnConnectionStateChange(t) {
|
|
313
|
-
const e =
|
|
331
|
+
const e = r.connectionStateChange;
|
|
314
332
|
this.addListener(e, t);
|
|
315
333
|
}
|
|
316
334
|
gatewayEmitConnectionStateChange(t) {
|
|
317
|
-
this.callListeners(
|
|
335
|
+
this.callListeners(r.connectionStateChange, t);
|
|
318
336
|
}
|
|
319
337
|
gatewayOffConnectionStateChange(t) {
|
|
320
|
-
const e =
|
|
338
|
+
const e = r.connectionStateChange;
|
|
321
339
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
322
340
|
}
|
|
323
341
|
gatewayOnToolEvent(t) {
|
|
324
|
-
const e =
|
|
342
|
+
const e = r.onToolEvent;
|
|
325
343
|
this.addListener(e, t);
|
|
326
344
|
}
|
|
327
345
|
gatewayEmitToolEvent(t, e, s) {
|
|
328
|
-
this.callListeners(
|
|
346
|
+
this.callListeners(r.onToolEvent, t, e, s);
|
|
329
347
|
}
|
|
330
348
|
gatewayOffToolEvent(t) {
|
|
331
|
-
const e =
|
|
349
|
+
const e = r.onToolEvent;
|
|
332
350
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
333
351
|
}
|
|
334
352
|
gatewayOnFirstToken(t) {
|
|
335
|
-
const e =
|
|
353
|
+
const e = r.gatewayFirstToken;
|
|
336
354
|
this.addListener(e, t);
|
|
337
355
|
}
|
|
338
356
|
gatewayEmitFirstToken(t) {
|
|
339
|
-
this.callListeners(
|
|
357
|
+
this.callListeners(r.gatewayFirstToken, t);
|
|
340
358
|
}
|
|
341
359
|
gatewayOffFirstToken(t) {
|
|
342
|
-
const e =
|
|
360
|
+
const e = r.gatewayFirstToken;
|
|
343
361
|
this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
|
|
344
362
|
}
|
|
345
363
|
};
|
|
346
|
-
f(
|
|
347
|
-
let K =
|
|
348
|
-
const
|
|
364
|
+
f(X, "EventBusService");
|
|
365
|
+
let K = X;
|
|
366
|
+
const Y = class Y extends K {
|
|
349
367
|
constructor() {
|
|
350
368
|
super();
|
|
351
369
|
}
|
|
@@ -371,12 +389,12 @@ const j = class j extends K {
|
|
|
371
389
|
console.log("MockEventBusService.gatewayOffFunctionResponse", t);
|
|
372
390
|
}
|
|
373
391
|
};
|
|
374
|
-
f(
|
|
375
|
-
let ct =
|
|
392
|
+
f(Y, "MockEventBusService");
|
|
393
|
+
let ct = Y;
|
|
376
394
|
const Ut = 2e3, mt = {
|
|
377
395
|
inline: "inline",
|
|
378
396
|
block: "block"
|
|
379
|
-
},
|
|
397
|
+
}, j = class j {
|
|
380
398
|
constructor() {
|
|
381
399
|
i(this, "parts", []);
|
|
382
400
|
i(this, "isLastGroup", !1);
|
|
@@ -396,22 +414,22 @@ const Ut = 2e3, mt = {
|
|
|
396
414
|
i(this, "type", mt.inline);
|
|
397
415
|
}
|
|
398
416
|
};
|
|
399
|
-
f(
|
|
400
|
-
let $ =
|
|
417
|
+
f(j, "InteractionPartGroup");
|
|
418
|
+
let $ = j;
|
|
401
419
|
const Z = class Z {
|
|
402
420
|
constructor(t, e) {
|
|
403
421
|
i(this, "interaction");
|
|
404
422
|
i(this, "eventBusService");
|
|
405
423
|
i(this, "parseTextIntoParts", /* @__PURE__ */ f((t) => {
|
|
406
424
|
if (!t || t.trim().length == 0) return [];
|
|
407
|
-
const e =
|
|
425
|
+
const e = Ot().use(kt).parse(t), s = [];
|
|
408
426
|
let o = null;
|
|
409
427
|
for (const n of e.children)
|
|
410
428
|
n.type === "code" ? (o && (s.push(o), o = null), n.lang === "htmlCanvas" && s.push(`
|
|
411
429
|
\`\`\`liveTsx
|
|
412
430
|
${n.value}
|
|
413
431
|
\`\`\`
|
|
414
|
-
`)) : (o || (o = ""), o +=
|
|
432
|
+
`)) : (o || (o = ""), o += Nt(n));
|
|
415
433
|
return o && s.push(o), s;
|
|
416
434
|
}, "parseTextIntoParts"));
|
|
417
435
|
this.interaction = t, this.eventBusService = e;
|
|
@@ -426,12 +444,12 @@ ${n.value}
|
|
|
426
444
|
return o;
|
|
427
445
|
}
|
|
428
446
|
groupPartsByDisplayType(t, e = !0, s = !1) {
|
|
429
|
-
var l,
|
|
447
|
+
var l, c, d;
|
|
430
448
|
const o = [];
|
|
431
449
|
let n = new $();
|
|
432
450
|
for (let u = 0; u < t.length; u++) {
|
|
433
451
|
const h = t[u];
|
|
434
|
-
let m = !((((l = h.functionDetails) == null ? void 0 : l.isUi) ?? !1) || ((
|
|
452
|
+
let m = !((((l = h.functionDetails) == null ? void 0 : l.isUi) ?? !1) || ((c = h.functionDetails) == null ? void 0 : c.cancelUi) !== !0 && (((d = h.functionDetails) == null ? void 0 : d.isAskUser) ?? !1)) && h.eventType !== C.Text && h.eventType !== C.Thought && (h.eventType === C.FunctionCall || h.eventType === C.PartialFunctionCall || h.eventType === C.FunctionResponse) && u < t.length - 1;
|
|
435
453
|
if (!(!e && m && !s))
|
|
436
454
|
if (m)
|
|
437
455
|
h.eventType == C.Thought && (n.hasThoughts = !0), n.parts.push(h), n.isLastGroup = u === t.length - 1;
|
|
@@ -468,28 +486,28 @@ ${n.value}
|
|
|
468
486
|
// new tree as the last step, so snapshots already handed out to throttled
|
|
469
487
|
// subscribers can't diverge from the live state.
|
|
470
488
|
merge(t) {
|
|
471
|
-
var b, R, y,
|
|
489
|
+
var b, R, y, A, O, st, nt, it;
|
|
472
490
|
const e = this.interaction, s = [], o = [], n = _.FlatParts(t == null ? void 0 : t.parts), a = e.parts[e.parts.length - 1] ?? null;
|
|
473
491
|
let l = !1;
|
|
474
492
|
n && (l = !a || n.mustPush || n.mustPush === !1 && (n.eventType !== (a == null ? void 0 : a.eventType) || ((b = n == null ? void 0 : n.functionDetails) == null ? void 0 : b.id) !== ((R = a.functionDetails) == null ? void 0 : R.id)));
|
|
475
|
-
let
|
|
493
|
+
let c = e.parts, d = e.functionMap ?? /* @__PURE__ */ new Map(), u = !e.functionMap;
|
|
476
494
|
const h = /* @__PURE__ */ f(() => {
|
|
477
495
|
u || (d = new Map(d), u = !0);
|
|
478
496
|
}, "cloneFunctionMap"), v = /* @__PURE__ */ f(() => {
|
|
479
|
-
|
|
497
|
+
c === e.parts && (c = e.parts.slice());
|
|
480
498
|
}, "clonePartsIfShared");
|
|
481
|
-
if (!l && (
|
|
482
|
-
const g =
|
|
483
|
-
(((
|
|
499
|
+
if (!l && (c == null ? void 0 : c.length) > 0 && (n != null && n.textAppendable)) {
|
|
500
|
+
const g = c[c.length - 1];
|
|
501
|
+
(((A = (y = g.thoughtDetails) == null ? void 0 : y.text) == null ? void 0 : A.length) ?? ((O = g.text) == null ? void 0 : O.length) ?? 0) > Ut && (l = !0);
|
|
484
502
|
}
|
|
485
503
|
let m = !1;
|
|
486
504
|
if ((n == null ? void 0 : n.eventType) === C.FunctionClientOutput && !!((st = n.functionDetails) != null && st.id) && n) {
|
|
487
|
-
const g = n.functionDetails.id, I = n.functionDetails.clientOutput, D =
|
|
505
|
+
const g = n.functionDetails.id, I = n.functionDetails.clientOutput, D = c.findIndex((S) => {
|
|
488
506
|
var p;
|
|
489
507
|
return ((p = S.functionDetails) == null ? void 0 : p.id) === g;
|
|
490
508
|
});
|
|
491
509
|
if (D > -1) {
|
|
492
|
-
const S =
|
|
510
|
+
const S = c[D], p = {
|
|
493
511
|
...S,
|
|
494
512
|
functionDetails: {
|
|
495
513
|
...S.functionDetails,
|
|
@@ -498,24 +516,24 @@ ${n.value}
|
|
|
498
516
|
parked: n.functionDetails.parked === !0 || S.functionDetails.parked === !0
|
|
499
517
|
}
|
|
500
518
|
};
|
|
501
|
-
v(),
|
|
519
|
+
v(), c[D] = p, h(), d.set(g, p), s.push(p);
|
|
502
520
|
} else {
|
|
503
521
|
const S = {
|
|
504
522
|
...n,
|
|
505
|
-
id:
|
|
523
|
+
id: c.length + 1 + "-" + e.interactionId,
|
|
506
524
|
functionDetails: { ...n.functionDetails, silent: !0 }
|
|
507
525
|
};
|
|
508
|
-
v(),
|
|
526
|
+
v(), c = c === e.parts ? e.parts.slice() : c, c.push(S), h(), d.set(g, S);
|
|
509
527
|
}
|
|
510
528
|
} else if (l && n) {
|
|
511
529
|
const g = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), I = g ? (nt = n.functionDetails) == null ? void 0 : nt.id : void 0;
|
|
512
530
|
g && !I && console.error("Got isCall or isResponse without a callId", n);
|
|
513
531
|
const D = I ? d.get(I) : void 0;
|
|
514
532
|
if (D && I && n.functionDetails) {
|
|
515
|
-
const S =
|
|
533
|
+
const S = c.findIndex((pt) => {
|
|
516
534
|
var ot;
|
|
517
535
|
return ((ot = pt.functionDetails) == null ? void 0 : ot.id) === I;
|
|
518
|
-
}), p = S > -1 ?
|
|
536
|
+
}), p = S > -1 ? c[S] : D, L = {
|
|
519
537
|
...p,
|
|
520
538
|
eventType: n.eventType,
|
|
521
539
|
functionDetails: {
|
|
@@ -556,7 +574,7 @@ ${n.value}
|
|
|
556
574
|
parked: n.functionDetails.parked === !0 || p.functionDetails.parked === !0
|
|
557
575
|
}
|
|
558
576
|
};
|
|
559
|
-
h(), d.set(I, L), L.eventType === C.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(L.functionDetails), s.push(L), S > -1 && (v(),
|
|
577
|
+
h(), d.set(I, L), L.eventType === C.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(L.functionDetails), s.push(L), S > -1 && (v(), c[S] = L);
|
|
560
578
|
} else {
|
|
561
579
|
if (I && n.functionDetails && !D && (h(), d.set(I, n)), a && a.textAppendable) {
|
|
562
580
|
const p = {
|
|
@@ -564,18 +582,18 @@ ${n.value}
|
|
|
564
582
|
ended: /* @__PURE__ */ new Date(),
|
|
565
583
|
isStillWriting: !1
|
|
566
584
|
};
|
|
567
|
-
v(),
|
|
585
|
+
v(), c[c.length - 1] = p, s.push(p);
|
|
568
586
|
}
|
|
569
587
|
const S = {
|
|
570
588
|
...n,
|
|
571
|
-
id:
|
|
589
|
+
id: c.length + 1 + "-" + e.interactionId,
|
|
572
590
|
isStillWriting: n.textAppendable,
|
|
573
591
|
partial: t.partial
|
|
574
592
|
};
|
|
575
|
-
(it = S.functionDetails) != null && it.silent || s.push(S),
|
|
593
|
+
(it = S.functionDetails) != null && it.silent || s.push(S), c = [...c, S], m = !0;
|
|
576
594
|
}
|
|
577
595
|
}
|
|
578
|
-
let T =
|
|
596
|
+
let T = c[c.length - 1] ?? null;
|
|
579
597
|
if (T && n && n.textAppendable) {
|
|
580
598
|
const g = {
|
|
581
599
|
...T,
|
|
@@ -598,7 +616,7 @@ ${n.value}
|
|
|
598
616
|
...n.thoughtDetails,
|
|
599
617
|
text: n.thoughtDetails.text.trim()
|
|
600
618
|
}), I = !l;
|
|
601
|
-
v(),
|
|
619
|
+
v(), c[c.length - 1] = g, T = g, I && s.push(g);
|
|
602
620
|
}
|
|
603
621
|
let E = e.artifactData ?? [];
|
|
604
622
|
if (t.llmArtifacts && t.llmArtifacts.length > 0) {
|
|
@@ -610,21 +628,21 @@ ${n.value}
|
|
|
610
628
|
S === -1 ? E.push(D) : E[S] = D;
|
|
611
629
|
}
|
|
612
630
|
}
|
|
613
|
-
const
|
|
631
|
+
const N = {
|
|
614
632
|
...e,
|
|
615
633
|
version: e.version + 1,
|
|
616
|
-
parts:
|
|
634
|
+
parts: c,
|
|
617
635
|
artifactData: E,
|
|
618
636
|
functionMap: d,
|
|
619
637
|
turn_complete: t.turn_complete,
|
|
620
638
|
partial: t.partial,
|
|
621
639
|
asyncFinalResponse: t.asyncFinalResponse
|
|
622
640
|
};
|
|
623
|
-
return this.interaction =
|
|
624
|
-
updatedInteraction:
|
|
641
|
+
return this.interaction = N, {
|
|
642
|
+
updatedInteraction: N,
|
|
625
643
|
updatedParts: s,
|
|
626
644
|
newArtifacts: o,
|
|
627
|
-
mainBranch:
|
|
645
|
+
mainBranch: N,
|
|
628
646
|
analyticsBranch: null,
|
|
629
647
|
analyticsBranchPartsChanged: null,
|
|
630
648
|
mainBranchPartsChanged: s
|
|
@@ -633,8 +651,8 @@ ${n.value}
|
|
|
633
651
|
};
|
|
634
652
|
f(Z, "InteractionService");
|
|
635
653
|
let x = Z;
|
|
636
|
-
const Ft = 1200 * 1e3,
|
|
637
|
-
constructor(t, e, s, o, n, a, l,
|
|
654
|
+
const Ft = 1200 * 1e3, P = class P {
|
|
655
|
+
constructor(t, e, s, o, n, a, l, c, d, u = Ct.Interactive) {
|
|
638
656
|
i(this, "base_production_url", yt() ?? "https://agent.tripapi.com.br");
|
|
639
657
|
i(this, "base_url_local", "http://localagent:8000");
|
|
640
658
|
i(this, "base_url");
|
|
@@ -710,7 +728,7 @@ const Ft = 1200 * 1e3, N = class N {
|
|
|
710
728
|
i(this, "subAgentInteractionServices", /* @__PURE__ */ new Map());
|
|
711
729
|
i(this, "lastThorttledTimeout", null);
|
|
712
730
|
i(this, "lastPingStatus", !1);
|
|
713
|
-
this.user = t, this.config = n, this.rawJwt = t.access_token, this.base_url = o, this.eventBusService = e, this.sessionId = d, this.runMode = u, this.artifactService = s, this.sessionState = a.getState(), this.notificationPort = l, this.storageService =
|
|
731
|
+
this.user = t, this.config = n, this.rawJwt = t.access_token, this.base_url = o, this.eventBusService = e, this.sessionId = d, this.runMode = u, this.artifactService = s, this.sessionState = a.getState(), this.notificationPort = l, this.storageService = c, a.subscribe((h, v) => {
|
|
714
732
|
this.sessionState = h;
|
|
715
733
|
});
|
|
716
734
|
}
|
|
@@ -939,9 +957,9 @@ const Ft = 1200 * 1e3, N = class N {
|
|
|
939
957
|
this.localEmitMessage(s.updatedInteraction, s), e.turn_complete && this.turnComplete(e.interactionId, s.updatedInteraction, e.author, e.subAgentId), e.asyncFinalResponse && (e.turn_complete = !0, s.updatedInteraction.turn_complete == !0, this.finalResponse(e.interactionId, s.updatedInteraction, e.author, e.subAgentId));
|
|
940
958
|
const o = e.artifactsDelta;
|
|
941
959
|
o && o.forEach((n) => {
|
|
942
|
-
const a = s.updatedInteraction.artifactData.filter((
|
|
960
|
+
const a = s.updatedInteraction.artifactData.filter((c) => c.id == n);
|
|
943
961
|
let l = null;
|
|
944
|
-
a && a.length > 0 && (l = a[0], l.loadingPromise = this.asyncLoadArtifact(n).then((
|
|
962
|
+
a && a.length > 0 && (l = a[0], l.loadingPromise = this.asyncLoadArtifact(n).then((c) => (c === null ? console.error("Error trying to load artifact id:", l == null ? void 0 : l.id, "Artifact is null") : this.eventBusService.artifactEmitGenerated(c), c)).catch((c) => (console.error("Error trying to load artifact id:", l == null ? void 0 : l.id, c.toString()), null)));
|
|
945
963
|
});
|
|
946
964
|
}
|
|
947
965
|
} catch (e) {
|
|
@@ -976,10 +994,10 @@ const Ft = 1200 * 1e3, N = class N {
|
|
|
976
994
|
}
|
|
977
995
|
localEmitMessage(t, e) {
|
|
978
996
|
const s = (/* @__PURE__ */ new Date()).getTime(), o = s - this.lastCurrentMessageUpdate;
|
|
979
|
-
t.partial === !1 || o >=
|
|
997
|
+
t.partial === !1 || o >= P.CURRENT_MSG_THROTTLE_MS ? (this.lastThorttledTimeout && (clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = null), this.doEmitMessage(t, s, e), this.pendingCurrentMessage = null) : (this.pendingCurrentMessage = t, this.lastThorttledTimeout && clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = setTimeout(() => {
|
|
980
998
|
var a, l;
|
|
981
999
|
this.pendingCurrentMessage && (((a = this.pendingCurrentMessage) == null ? void 0 : a.version) ?? 0) > (((l = this.sessionState.currentMessage) == null ? void 0 : l.version) ?? 0) && (this.doEmitMessage(this.pendingCurrentMessage, s, e), this.lastThorttledTimeout = null);
|
|
982
|
-
},
|
|
1000
|
+
}, P.CURRENT_MSG_THROTTLE_MS * 2));
|
|
983
1001
|
}
|
|
984
1002
|
localOpen(t, e) {
|
|
985
1003
|
this.sessionState.setTurnOpen(!0), this.eventBusService.gatewayEmitTurnOpen(t ?? "");
|
|
@@ -1015,8 +1033,8 @@ const Ft = 1200 * 1e3, N = class N {
|
|
|
1015
1033
|
try {
|
|
1016
1034
|
const { promptAsString: n, json: a } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(t.data) : { promptAsString: t.data, json: void 0 };
|
|
1017
1035
|
this.sessionState.onRenderPrompt && (t.data = a, t.friendlyMessage = n);
|
|
1018
|
-
const l = await this.sendMessageInternal(t, e),
|
|
1019
|
-
this.storageService.storePrompt(
|
|
1036
|
+
const l = await this.sendMessageInternal(t, e), c = bt.createPrompt(n ?? "", (a == null ? void 0 : a.toString()) ?? {});
|
|
1037
|
+
this.storageService.storePrompt(c);
|
|
1020
1038
|
const d = _.fromText("Planejando próximos passos");
|
|
1021
1039
|
return this.sendStatusMessage(t.data, [o, d], s.toString() + "1"), l != null && l.success ? this.eventBusService.ChatEmitMessageSent(t.data, l.interaction) : this.eventBusService.ChatEmitMessageError((l == null ? void 0 : l.error) ?? ""), l;
|
|
1022
1040
|
} catch (n) {
|
|
@@ -1072,12 +1090,12 @@ const Ft = 1200 * 1e3, N = class N {
|
|
|
1072
1090
|
}
|
|
1073
1091
|
}
|
|
1074
1092
|
getNewInteractionId() {
|
|
1075
|
-
const e =
|
|
1093
|
+
const e = Pt(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
|
|
1076
1094
|
return `${this.msg_order}_${e}`;
|
|
1077
1095
|
}
|
|
1078
1096
|
};
|
|
1079
|
-
f(
|
|
1080
|
-
let z =
|
|
1097
|
+
f(P, "AgentGatewayService"), i(P, "SUSPENSION_MSG", "SUSPEND"), i(P, "CURRENT_MSG_THROTTLE_MS", 150);
|
|
1098
|
+
let z = P;
|
|
1081
1099
|
const $t = 0.02;
|
|
1082
1100
|
function xt(w, t) {
|
|
1083
1101
|
if (!t) return null;
|
|
@@ -1101,7 +1119,7 @@ function lt(w, t, e, s) {
|
|
|
1101
1119
|
};
|
|
1102
1120
|
}
|
|
1103
1121
|
f(lt, "entry");
|
|
1104
|
-
const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2, zt = 0.2, q = 2, Jt = 5e3,
|
|
1122
|
+
const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2, zt = 0.2, q = 2, Jt = 5e3, Qt = 3e4, G = 1e4, Xt = 4100, V = class V {
|
|
1105
1123
|
constructor(t = "ws://localhost:8000", e) {
|
|
1106
1124
|
i(this, "ws", null);
|
|
1107
1125
|
i(this, "stats");
|
|
@@ -1230,7 +1248,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1230
1248
|
this._internalReconnect || this.cancelPendingReconnect(), n || (this.isReconnecting = !1, this.reconnectAttempts = 0, this.lastSeq = -1), this._internalReconnect = !1;
|
|
1231
1249
|
const a = (R = this.getToken) == null ? void 0 : R.call(this), l = [];
|
|
1232
1250
|
a && l.push(`access_token=${encodeURIComponent(a)}`), t && this.lastSeq >= 0 && l.push(`lastSeq=${this.lastSeq}`);
|
|
1233
|
-
const
|
|
1251
|
+
const c = l.length > 0 ? `?${l.join("&")}` : "", d = this.baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"), u = `${d}/ws/connect/${t ?? ""}${c}`, h = `${d}/ws/connect/${t ?? ""}` + (n && t && this.lastSeq >= 0 ? ` (resume lastSeq=${this.lastSeq})` : "");
|
|
1234
1252
|
if (console.log("Connecting to ", h), this.ws) {
|
|
1235
1253
|
this.ws.onopen = null, this.ws.onmessage = null, this.ws.onerror = null, this.ws.onclose = null;
|
|
1236
1254
|
try {
|
|
@@ -1248,30 +1266,30 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1248
1266
|
}, this.ws.onmessage = (y) => {
|
|
1249
1267
|
try {
|
|
1250
1268
|
this.lastActivity = (/* @__PURE__ */ new Date()).getTime(), this.pingSentAt = null;
|
|
1251
|
-
const
|
|
1252
|
-
if (!
|
|
1269
|
+
const A = this.streamingResponseSerializer.parse(y.data);
|
|
1270
|
+
if (!A)
|
|
1253
1271
|
throw "Error parsing event JSON";
|
|
1254
|
-
const
|
|
1255
|
-
!v && (
|
|
1256
|
-
} catch (
|
|
1257
|
-
console.error("[WebSocket] Error parsing message:",
|
|
1272
|
+
const O = this.handleMessage(A, y.data);
|
|
1273
|
+
!v && (O != null && O.timestamp) && (v = !0, this.hasEverReceivedPacket = !0);
|
|
1274
|
+
} catch (A) {
|
|
1275
|
+
console.error("[WebSocket] Error parsing message:", A);
|
|
1258
1276
|
}
|
|
1259
1277
|
}, this.ws.onerror = (y) => {
|
|
1260
1278
|
console.error("[WebSocket] Error:", y), this.onError && this.onError("WebSocket error");
|
|
1261
1279
|
}, this.ws.onclose = (y) => {
|
|
1262
1280
|
console.log(`[WebSocket] Closed: code=${y.code} reason="${y.reason}" (session ${this.sessionLabel}, lastSeq=${this.lastSeq}, intentional=${this.intentionalDisconnect})`), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingSentAt = null;
|
|
1263
|
-
const
|
|
1281
|
+
const A = this.sessionId ?? this.lastKnownSessionId;
|
|
1264
1282
|
this.sessionId = void 0;
|
|
1265
|
-
const
|
|
1266
|
-
if (
|
|
1267
|
-
this.scheduleReconnect(
|
|
1283
|
+
const O = v || this.hasEverReceivedPacket;
|
|
1284
|
+
if (O && this.shouldAttemptReconnect(y.code)) {
|
|
1285
|
+
this.scheduleReconnect(A, y.code, y.reason);
|
|
1268
1286
|
return;
|
|
1269
1287
|
}
|
|
1270
|
-
console.warn(`[WebSocket] Inner reconnect declined for code=${y.code}: channelProven=${
|
|
1288
|
+
console.warn(`[WebSocket] Inner reconnect declined for code=${y.code}: channelProven=${O}, codeRetryable=${this.shouldAttemptReconnect(y.code)}. Handing off to the outer state manager (session ${A ?? "none"}).`), this.isReconnecting = !1, this.reconnectAttempts = 0, this.onClose && this.onClose(y.code, y.reason);
|
|
1271
1289
|
};
|
|
1272
1290
|
const m = 200, M = 3e4, T = 8e3, E = this.ws;
|
|
1273
1291
|
this.sessionId = void 0;
|
|
1274
|
-
let
|
|
1292
|
+
let N = 0, b = 0;
|
|
1275
1293
|
for (; !this.sessionId; ) {
|
|
1276
1294
|
if (this.ws !== E) {
|
|
1277
1295
|
o("Connection attempt superseded by a newer connect()");
|
|
@@ -1281,7 +1299,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1281
1299
|
o("Connection closed before a session id was received");
|
|
1282
1300
|
return;
|
|
1283
1301
|
}
|
|
1284
|
-
if (E.readyState === WebSocket.CONNECTING &&
|
|
1302
|
+
if (E.readyState === WebSocket.CONNECTING && N >= M) {
|
|
1285
1303
|
try {
|
|
1286
1304
|
E.close();
|
|
1287
1305
|
} catch {
|
|
@@ -1293,7 +1311,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1293
1311
|
o(`Connected but no session id arrived within ${T / 1e3}s`);
|
|
1294
1312
|
return;
|
|
1295
1313
|
}
|
|
1296
|
-
|
|
1314
|
+
N % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(m), N += m, E.readyState === WebSocket.OPEN && (b += m);
|
|
1297
1315
|
}
|
|
1298
1316
|
console.log("SUCCESS - GOT SESSION ID", this.sessionId), this.lastKnownSessionId = this.sessionId, s(this.sessionId);
|
|
1299
1317
|
});
|
|
@@ -1359,7 +1377,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1359
1377
|
* Handle incoming messages from server
|
|
1360
1378
|
*/
|
|
1361
1379
|
handleMessage(t, e) {
|
|
1362
|
-
var l,
|
|
1380
|
+
var l, c, d;
|
|
1363
1381
|
switch (typeof t.seq == "number" && t.seq > this.lastSeq && (this.lastSeq = t.seq), t.type) {
|
|
1364
1382
|
case "Pong":
|
|
1365
1383
|
if (this.sessionId = t.sessionId, this.lastKnownSessionId = t.sessionId ?? this.lastKnownSessionId, !t.sessionId) {
|
|
@@ -1421,7 +1439,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1421
1439
|
};
|
|
1422
1440
|
}
|
|
1423
1441
|
else if (h.eventType.type == C.Thought) {
|
|
1424
|
-
var a = new
|
|
1442
|
+
var a = new At();
|
|
1425
1443
|
a.text = u.partialReasoning, h.content = {
|
|
1426
1444
|
items: [a],
|
|
1427
1445
|
role: {
|
|
@@ -1434,7 +1452,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1434
1452
|
label: "Assistant"
|
|
1435
1453
|
}, h.timestamp = (u == null ? void 0 : u.timeStamp) ?? (/* @__PURE__ */ new Date()).getTime(), h.turnComplete = !1, t.event = h, t.partialEvent = void 0;
|
|
1436
1454
|
}
|
|
1437
|
-
return t.event ? (t.subAgentId && (t.event.subAgentId = t.subAgentId, t.event.subAgentName = t.subAgentName), ((((
|
|
1455
|
+
return t.event ? (t.subAgentId && (t.event.subAgentId = t.subAgentId, t.event.subAgentName = t.subAgentName), ((((c = (l = t.event.content) == null ? void 0 : l.items) == null ? void 0 : c.length) ?? 0) > 0 || (((d = t.event.streamingParts) == null ? void 0 : d.length) ?? 0) > 0) && this.emitFirstToken(t.event.interactionId), this.handleEvent(t.event, e), t.event) : null;
|
|
1438
1456
|
}
|
|
1439
1457
|
emitFirstToken(t) {
|
|
1440
1458
|
var e;
|
|
@@ -1568,7 +1586,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1568
1586
|
const e = t - this.pingSentAt;
|
|
1569
1587
|
if (e >= G) {
|
|
1570
1588
|
this.failSocket(
|
|
1571
|
-
|
|
1589
|
+
Xt,
|
|
1572
1590
|
`No frame received for ${Math.round(e / 1e3)}s after a Ping`
|
|
1573
1591
|
);
|
|
1574
1592
|
return;
|
|
@@ -1576,7 +1594,7 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1576
1594
|
console.warn(`[WebSocket] Still no reply ${e}ms after the Ping (budget ${G}ms, session ${this.sessionLabel}) — the peer may be gone.`);
|
|
1577
1595
|
return;
|
|
1578
1596
|
}
|
|
1579
|
-
t - this.lastActivity >=
|
|
1597
|
+
t - this.lastActivity >= Qt && this.ping();
|
|
1580
1598
|
} catch (t) {
|
|
1581
1599
|
console.error("Error on monitor", t);
|
|
1582
1600
|
}
|
|
@@ -1650,13 +1668,13 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1650
1668
|
if (!o)
|
|
1651
1669
|
throw "Server event was null";
|
|
1652
1670
|
if (this.events.push([(/* @__PURE__ */ new Date()).getTime(), ((s = t.text) == null ? void 0 : s.length) ?? 0]), this.stats.eventCount += 1, this.stats.totalTransfered += e.length, o.session_information && !o.subAgentId) {
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1671
|
+
const c = xt(this.previousSessionInformation, o.session_information);
|
|
1672
|
+
c && (this.sessionCompactions.push(c), this.sessionCompactions.length > qt && this.sessionCompactions.shift()), this.previousSessionInformation = o.session_information, this.stats.sessionInformation = o.session_information, this.stats.sessionCompactions = this.sessionCompactions;
|
|
1655
1673
|
}
|
|
1656
1674
|
this.stats.elapsed = (Date.now() - this.stats.startTime.getTime()) / 1e3;
|
|
1657
|
-
const n = Date.now() - ht * 1e3, l = this.events.filter((
|
|
1658
|
-
this.stats.tokensPerSecond = l / ht, this.flushStatsCoalesced(), this.onEvent && this.onEvent(o).catch((
|
|
1659
|
-
console.error("Lost error on on-event",
|
|
1675
|
+
const n = Date.now() - ht * 1e3, l = this.events.filter((c) => c[0] > n).reduce((c, d) => c += d[1], 0) / Wt;
|
|
1676
|
+
this.stats.tokensPerSecond = l / ht, this.flushStatsCoalesced(), this.onEvent && this.onEvent(o).catch((c) => {
|
|
1677
|
+
console.error("Lost error on on-event", c);
|
|
1660
1678
|
});
|
|
1661
1679
|
} catch (o) {
|
|
1662
1680
|
console.error("handleEvent error", o);
|
|
@@ -1665,9 +1683,9 @@ const B = 4001, Bt = 4002, ht = 4, Wt = 3, qt = 20, Gt = 500, Ht = 3e4, Kt = 2,
|
|
|
1665
1683
|
};
|
|
1666
1684
|
f(V, "WebSocketConnecionV2");
|
|
1667
1685
|
let ut = V;
|
|
1668
|
-
const
|
|
1669
|
-
constructor(e, s, o, n, a, l,
|
|
1670
|
-
super(e, s, o, n, a, l,
|
|
1686
|
+
const Yt = "envision_agent_sessionId", tt = class tt extends z {
|
|
1687
|
+
constructor(e, s, o, n, a, l, c, d, u, h, v) {
|
|
1688
|
+
super(e, s, o, n, a, l, c, u, v);
|
|
1671
1689
|
i(this, "suspendState", !1);
|
|
1672
1690
|
i(this, "wsService");
|
|
1673
1691
|
i(this, "root_url", "");
|
|
@@ -1720,7 +1738,7 @@ const jt = "envision_agent_sessionId", tt = class tt extends z {
|
|
|
1720
1738
|
return this.suspendState;
|
|
1721
1739
|
}
|
|
1722
1740
|
getStoredSessionId() {
|
|
1723
|
-
const e = localStorage.getItem(
|
|
1741
|
+
const e = localStorage.getItem(Yt);
|
|
1724
1742
|
if (e)
|
|
1725
1743
|
return e;
|
|
1726
1744
|
}
|
|
@@ -1845,7 +1863,7 @@ const jt = "envision_agent_sessionId", tt = class tt extends z {
|
|
|
1845
1863
|
}
|
|
1846
1864
|
// Send a message to the server over the socket
|
|
1847
1865
|
async sendMessageInternal(e, s, o) {
|
|
1848
|
-
var l,
|
|
1866
|
+
var l, c, d, u, h, v, m, M;
|
|
1849
1867
|
const n = this.suspendState;
|
|
1850
1868
|
this.suspendState = !1;
|
|
1851
1869
|
const a = this.startInteraction(e.friendlyMessage ?? e.data, n);
|
|
@@ -1853,7 +1871,7 @@ const jt = "envision_agent_sessionId", tt = class tt extends z {
|
|
|
1853
1871
|
throw "no wsService created";
|
|
1854
1872
|
if (!this.sessionId)
|
|
1855
1873
|
throw "no session id set";
|
|
1856
|
-
if (!((
|
|
1874
|
+
if (!((c = this.config.agentConfig) != null && c.id))
|
|
1857
1875
|
throw "Agent not selected";
|
|
1858
1876
|
return this.sessionState.setLastActivity(), await this.ensureConnected(), this.wsService.sendMessage({
|
|
1859
1877
|
Content: e.data,
|
|
@@ -1955,4 +1973,4 @@ export {
|
|
|
1955
1973
|
dt as a,
|
|
1956
1974
|
re as u
|
|
1957
1975
|
};
|
|
1958
|
-
//# sourceMappingURL=httpArtifactService-
|
|
1976
|
+
//# sourceMappingURL=httpArtifactService-_66bhjGo.js.map
|