@aintela/chat 0.2.25 → 0.2.27

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.
Files changed (30) hide show
  1. package/dist/{auth-DbmLacBc.js → auth-GFZAFz7L.js} +2 -2
  2. package/dist/{auth-DbmLacBc.js.map → auth-GFZAFz7L.js.map} +1 -1
  3. package/dist/components.js +2626 -2589
  4. package/dist/components.js.map +1 -1
  5. package/dist/{environmentUtils-BaKw5_VD.js → environmentUtils-CUVZ6Dq1.js} +44 -28
  6. package/dist/environmentUtils-CUVZ6Dq1.js.map +1 -0
  7. package/dist/hooks.js +1 -1
  8. package/dist/{httpArtifactService-Dh9LGQ9a.js → httpArtifactService-B668XBHO.js} +465 -436
  9. package/dist/httpArtifactService-B668XBHO.js.map +1 -0
  10. package/dist/{httpSessionService-5Kr__oQL.js → httpSessionService-BuT5FlDc.js} +3 -3
  11. package/dist/{httpSessionService-5Kr__oQL.js.map → httpSessionService-BuT5FlDc.js.map} +1 -1
  12. package/dist/index.js +6 -6
  13. package/dist/models.js +2 -2
  14. package/dist/serializer-BPina6fX.js +1337 -0
  15. package/dist/serializer-BPina6fX.js.map +1 -0
  16. package/dist/services.js +2 -2
  17. package/dist/src/components/AiChat/ChatPane/parts/AskUserDispatcher.d.ts +22 -0
  18. package/dist/src/components/AiChat/ChatPane/parts/types.d.ts +17 -0
  19. package/dist/src/components/AiChat/ChatPane/parts/uiToolRegistry.d.ts +47 -2
  20. package/dist/src/models/InteractionPart.test.d.ts +1 -0
  21. package/dist/src/models/ServerEvent.d.ts +11 -0
  22. package/dist/src/models/semanticKernelModel/models.d.ts +14 -4
  23. package/dist/{useChatSessions-DttlifVk.js → useChatSessions-DsHPo0GV.js} +2 -2
  24. package/dist/{useChatSessions-DttlifVk.js.map → useChatSessions-DsHPo0GV.js.map} +1 -1
  25. package/dist/utils.js +2 -2
  26. package/package.json +1 -1
  27. package/dist/environmentUtils-BaKw5_VD.js.map +0 -1
  28. package/dist/httpArtifactService-Dh9LGQ9a.js.map +0 -1
  29. package/dist/serializer-DyHZxlAG.js +0 -1276
  30. package/dist/serializer-DyHZxlAG.js.map +0 -1
@@ -0,0 +1,1337 @@
1
+ var wt = Object.defineProperty;
2
+ var Jt = (s, t, i) => t in s ? wt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[t] = i;
3
+ var l = (s, t) => wt(s, "name", { value: t, configurable: !0 });
4
+ var e = (s, t, i) => Jt(s, typeof t != "symbol" ? t + "" : t, i);
5
+ import { E as m, q as Et, A as Wt, G as $t } from "./environmentUtils-CUVZ6Dq1.js";
6
+ import { jsonMember as o, jsonObject as d, AnyT as Ft, jsonArrayMember as ft, TypedJSON as Pt } from "typedjson";
7
+ const w = class w {
8
+ static replaceFirstTwoTabsPerLine(t) {
9
+ const i = /^\s{15}/gm;
10
+ return typeof t == "string" ? t.replaceAll(i, (r) => r.substring(15)) : t ?? "";
11
+ }
12
+ static jsonToString(t) {
13
+ if (t == null) return "";
14
+ if (typeof t != "object") return String(t);
15
+ const i = Array.isArray(t) ? w.isCharArray(t) ? t.join("") : null : w.tryCollapseCharIndexedObject(t);
16
+ if (i != null) return i;
17
+ if (Array.isArray(t))
18
+ try {
19
+ return JSON.stringify(t, null, 2);
20
+ } catch {
21
+ return String(t);
22
+ }
23
+ const r = Object.keys(t), a = [];
24
+ return r.forEach((p) => {
25
+ let c = t[p];
26
+ typeof c == "object" && (c = JSON.stringify(t[p], null, 2));
27
+ const g = (c == null ? void 0 : c.toString().indexOf(`
28
+ `)) > -1 ? `
29
+ ` : "";
30
+ a.push(`${p}:${g}${c}`);
31
+ }), a.join(`
32
+ `);
33
+ }
34
+ static functionDetailsToString(t) {
35
+ if (t == null) return "";
36
+ if (typeof t == "string") {
37
+ t = t.replaceAll('"{', "{").replaceAll('}"', "}").replaceAll("'{", "{").replaceAll("}'", "}"), t = t.replaceAll('\\"', '"');
38
+ try {
39
+ t = JSON.parse(t);
40
+ } catch {
41
+ return t;
42
+ }
43
+ if (typeof t != "object" || t == null) return String(t);
44
+ }
45
+ if (Array.isArray(t))
46
+ try {
47
+ return JSON.stringify(t, null, 2);
48
+ } catch {
49
+ return String(t);
50
+ }
51
+ const i = Object.keys(t), r = [];
52
+ return i.forEach((a) => {
53
+ let p = t == null ? void 0 : t[a];
54
+ typeof p == "object" && (p = JSON.stringify(p, null, 2));
55
+ const c = (p == null ? void 0 : p.toString().indexOf(`
56
+ `)) > -1 ? `
57
+ ` : "";
58
+ r.push(`${a}:${c}${p}`);
59
+ }), r.join(`
60
+ `);
61
+ }
62
+ /**
63
+ * Reads the server-generated SlotId from a UI render tool's result. The
64
+ * result reaches the client as a plain object on the live path, but as a
65
+ * JSON string — sometimes double-encoded (a JSON string of a JSON string) —
66
+ * on the persisted / session-replay path. Unwrap up to two string layers
67
+ * before reading the field. Returns undefined when absent or unparseable.
68
+ */
69
+ static uiSlotId(t) {
70
+ var p;
71
+ let i = (p = t == null ? void 0 : t.functionDetails) == null ? void 0 : p.response;
72
+ for (let c = 0; c < 2 && typeof i == "string"; c++)
73
+ try {
74
+ i = JSON.parse(i);
75
+ } catch {
76
+ return;
77
+ }
78
+ if (!i || typeof i != "object") return;
79
+ const r = i, a = r.SlotId ?? r.slotId;
80
+ return typeof a == "string" ? a : void 0;
81
+ }
82
+ static fromError(t) {
83
+ return {
84
+ errorDetails: { errorMessage: t },
85
+ eventType: m.ServerError,
86
+ id: "",
87
+ author: "main",
88
+ created: /* @__PURE__ */ new Date(),
89
+ partial: !1,
90
+ isStillWriting: !1,
91
+ mustPush: !1,
92
+ textAppendable: !1
93
+ };
94
+ }
95
+ static fromText(t, i, r) {
96
+ return {
97
+ text: t,
98
+ eventType: m.Text,
99
+ id: r ?? Et(),
100
+ created: /* @__PURE__ */ new Date(),
101
+ author: i ?? "main",
102
+ partial: !1,
103
+ isStillWriting: !1,
104
+ mustPush: !1,
105
+ textAppendable: !1
106
+ };
107
+ }
108
+ /**
109
+ * Builds the user-authored UI part for a `sendMessage(text, { ui })` turn. Mirrors the
110
+ * shape `ServerEvent` produces from a persisted `UserUiContent` on reload, so the live
111
+ * and replayed parts are identical: an `EventType.UserAnswer` carrying functionDetails
112
+ * {name, args, isUi, status:'Done'} that routes through the uiTool dispatcher/registry.
113
+ */
114
+ static fromUserUi(t, i, r) {
115
+ return {
116
+ id: r ?? Et(),
117
+ eventType: m.UserAnswer,
118
+ author: "user",
119
+ created: /* @__PURE__ */ new Date(),
120
+ partial: !1,
121
+ isStillWriting: !1,
122
+ mustPush: !1,
123
+ textAppendable: !1,
124
+ functionDetails: {
125
+ id: "",
126
+ name: t,
127
+ args: i,
128
+ status: "Done",
129
+ isUi: !0
130
+ }
131
+ };
132
+ }
133
+ static createWaiting(t = !1, i = !0, r, a, p) {
134
+ r || (r = "Waiting");
135
+ const c = w.fromText("...", void 0, "waitingpart");
136
+ return c.eventType = m.Waiting, c.waitingDetails = {
137
+ startingPoint: a,
138
+ addTimer: t,
139
+ isTimerRunning: i,
140
+ status: r,
141
+ stopPoint: p
142
+ }, c;
143
+ }
144
+ static createSuspended() {
145
+ const t = w.fromText("SUSPEND");
146
+ return t.eventType = m.Suspended, t;
147
+ }
148
+ static getPartTextContent(t) {
149
+ return t.text ?? "";
150
+ }
151
+ static FlatParts(t) {
152
+ if (t.length === 0)
153
+ return;
154
+ const i = t.filter((p) => p.eventType == m.Text), r = i.length > 0 ? i[0] : t[0], a = [...new Set(t.map((p) => p.eventType))];
155
+ a.length == 1 ? r.eventType = a[0] : i.length > 0 && (r.eventType = m.Text), r.mustPush = !(r.eventType == m.Text || r.eventType == m.Thought || r.eventType == m.NotDefined || r.eventType == m.PartialFunctionCall), r.textAppendable = r.eventType == m.Text || r.eventType == m.Thought || r.eventType == m.PartialFunctionCall;
156
+ for (const p of t) {
157
+ if (!r.codeExecutionResultDetails && p.codeExecutionResultDetails && (r.codeExecutionResultDetails = p.codeExecutionResultDetails), !r.errorDetails && p.errorDetails && (r.errorDetails = p.errorDetails), !r.executableCodeDetails && p.executableCodeDetails && (r.executableCodeDetails = p.executableCodeDetails), !r.functionDetails && p.functionDetails && (r.functionDetails = p.functionDetails), r.functionDetails && p.functionDetails && p !== r) {
158
+ const c = r.functionDetails, g = p.functionDetails;
159
+ !c.askUserComponent && g.askUserComponent && (c.askUserComponent = g.askUserComponent), !c.isUi && g.isUi && (c.isUi = !0), !c.clientOutput && g.clientOutput && (c.clientOutput = g.clientOutput), c.isAskUser = c.isAskUser || g.isAskUser || !!c.askUserComponent;
160
+ }
161
+ !r.rawDetails && p.rawDetails && (r.rawDetails = p.rawDetails), !r.thoughtDetails && p.thoughtDetails && (r.thoughtDetails = p.thoughtDetails), !r.errorDetails && p.errorDetails && (r.errorDetails = p.errorDetails);
162
+ }
163
+ return r;
164
+ }
165
+ static isCharArray(t) {
166
+ return Array.isArray(t) && t.length > 0 && t.every((i) => typeof i == "string" && i.length === 1);
167
+ }
168
+ /**
169
+ * Detects objects like `{0: "a", 1: "b", 2: "c", ...}` — a string that was
170
+ * spread/indexed into an object (e.g. `{...someString}` or the server
171
+ * serializing a string as a char-indexed dict). Returns the reassembled
172
+ * string, or `null` if the value doesn't match this pattern.
173
+ */
174
+ static tryCollapseCharIndexedObject(t) {
175
+ if (t == null || typeof t != "object" || Array.isArray(t)) return null;
176
+ const i = Object.keys(t);
177
+ if (i.length === 0) return null;
178
+ for (let r = 0; r < i.length; r++) {
179
+ if (i[r] !== String(r)) return null;
180
+ const a = t[i[r]];
181
+ if (typeof a != "string" || a.length !== 1) return null;
182
+ }
183
+ return i.map((r) => t[r]).join("");
184
+ }
185
+ static isCodeExecution(t) {
186
+ return t.eventType === m.CodeExecutionResult || t.eventType === m.ExecutableCode;
187
+ }
188
+ };
189
+ l(w, "InteractionPartUtils");
190
+ let Nt = w;
191
+ var Gt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, n = /* @__PURE__ */ l((s, t, i, r) => {
192
+ for (var a = r > 1 ? void 0 : r ? qt(t, i) : t, p = s.length - 1, c; p >= 0; p--)
193
+ (c = s[p]) && (a = (r ? c(t, i, a) : c(a)) || a);
194
+ return r && a && Gt(t, i, a), a;
195
+ }, "__decorateClass");
196
+ const x = {
197
+ // KernelContent derived types
198
+ TextContent: "TextContent",
199
+ ToolEventContent: "ToolEventContent",
200
+ StreamingToolEventContent: "StreamingToolEventContent",
201
+ StreamingReasoningContent: "StreamingReasoningContent",
202
+ FunctionCallContent: "FunctionCallContent",
203
+ FunctionResultContent: "FunctionResultContent",
204
+ FunctionClientOutputContent: "FunctionClientOutputContent",
205
+ UserUiContent: "UserUiContent",
206
+ // StreamingKernelContent derived types
207
+ StreamingTextContent: "StreamingTextContent",
208
+ StreamingFunctionCallUpdateContent: "StreamingFunctionCallUpdateContent",
209
+ StreamingFinalFunctionCallContent: "StreamingFinalFunctionCallContent",
210
+ StreamingFinalFunctionResultContent: "StreamingFinalFunctionResultContent",
211
+ StreamingClientOutputContent: "StreamingClientOutputContent"
212
+ };
213
+ var _;
214
+ let Tt = (_ = class {
215
+ constructor() {
216
+ e(this, "label");
217
+ }
218
+ }, l(_, "AuthorRole"), _);
219
+ n([
220
+ o(String)
221
+ ], Tt.prototype, "label", 2);
222
+ Tt = n([
223
+ d({ name: "AuthorRole" })
224
+ ], Tt);
225
+ var L;
226
+ let ut = (L = class {
227
+ constructor() {
228
+ e(this, "type");
229
+ e(this, "fullName");
230
+ }
231
+ }, l(L, "EventTypeInformation"), L);
232
+ n([
233
+ o(String)
234
+ ], ut.prototype, "type", 2);
235
+ n([
236
+ o(String)
237
+ ], ut.prototype, "fullName", 2);
238
+ ut = n([
239
+ d({ name: "EventTypeInformation" })
240
+ ], ut);
241
+ var J;
242
+ let R = (J = class {
243
+ constructor() {
244
+ e(this, "id");
245
+ e(this, "name");
246
+ e(this, "mimeType");
247
+ e(this, "description");
248
+ }
249
+ toArtifact() {
250
+ return {
251
+ created: /* @__PURE__ */ new Date(),
252
+ updatedAt: /* @__PURE__ */ new Date(),
253
+ name: this.name ?? "Not Defined",
254
+ description: this.description,
255
+ mimeType: this.mimeType,
256
+ id: this.id
257
+ };
258
+ }
259
+ }, l(J, "LlmArtifact"), J);
260
+ n([
261
+ o(String)
262
+ ], R.prototype, "id", 2);
263
+ n([
264
+ o(String)
265
+ ], R.prototype, "name", 2);
266
+ n([
267
+ o(String)
268
+ ], R.prototype, "mimeType", 2);
269
+ n([
270
+ o(String)
271
+ ], R.prototype, "description", 2);
272
+ R = n([
273
+ d({ name: "LlmArtifact" })
274
+ ], R);
275
+ var W;
276
+ let h = (W = class {
277
+ constructor() {
278
+ e(this, "mimeType");
279
+ // InnerContent is ignored (JsonIgnore in C#)
280
+ // Not decorated with @jsonMember
281
+ e(this, "innerContent");
282
+ e(this, "modelId");
283
+ e(this, "metadata");
284
+ }
285
+ }, l(W, "KernelContent"), W);
286
+ n([
287
+ o(String)
288
+ ], h.prototype, "mimeType", 2);
289
+ n([
290
+ o(String)
291
+ ], h.prototype, "modelId", 2);
292
+ n([
293
+ o(Ft)
294
+ ], h.prototype, "metadata", 2);
295
+ h = n([
296
+ d({ name: "KernelContent" })
297
+ ], h);
298
+ var $;
299
+ let C = ($ = class {
300
+ constructor() {
301
+ e(this, "choiceIndex", 0);
302
+ // InnerContent is ignored (JsonIgnore in C#)
303
+ // Not decorated with @jsonMember
304
+ e(this, "innerContent");
305
+ e(this, "modelId");
306
+ e(this, "metadata");
307
+ }
308
+ }, l($, "StreamingKernelContent"), $);
309
+ n([
310
+ o(Number)
311
+ ], C.prototype, "choiceIndex", 2);
312
+ n([
313
+ o(String)
314
+ ], C.prototype, "modelId", 2);
315
+ n([
316
+ o(Object)
317
+ ], C.prototype, "metadata", 2);
318
+ C = n([
319
+ d({ name: "StreamingKernelContent" })
320
+ ], C);
321
+ var G;
322
+ let xt = (G = class extends h {
323
+ constructor() {
324
+ super();
325
+ e(this, "text");
326
+ // Encoding is ignored (JsonIgnore in C#)
327
+ // Not decorated with @jsonMember
328
+ e(this, "encoding");
329
+ this.encoding = "UTF8";
330
+ }
331
+ toString() {
332
+ return this.text ?? "";
333
+ }
334
+ }, l(G, "TextContent"), G);
335
+ n([
336
+ o(String)
337
+ ], xt.prototype, "text", 2);
338
+ xt = n([
339
+ d({ name: "TextContent" })
340
+ ], xt);
341
+ var q;
342
+ let ct = (q = class extends C {
343
+ constructor() {
344
+ super();
345
+ e(this, "eventName");
346
+ e(this, "eventData");
347
+ e(this, "sessionId");
348
+ }
349
+ }, l(q, "StreamingToolEventContent"), q);
350
+ n([
351
+ o(String)
352
+ ], ct.prototype, "eventName", 2);
353
+ n([
354
+ o(String)
355
+ ], ct.prototype, "eventData", 2);
356
+ n([
357
+ o(String)
358
+ ], ct.prototype, "sessionId", 2);
359
+ ct = n([
360
+ d({ name: "StreamingToolEventContent" })
361
+ ], ct);
362
+ var M;
363
+ let P = (M = class extends h {
364
+ constructor() {
365
+ super();
366
+ e(this, "eventName");
367
+ e(this, "eventData");
368
+ e(this, "sessionId");
369
+ }
370
+ }, l(M, "ToolEventContent"), M);
371
+ n([
372
+ o(String)
373
+ ], P.prototype, "eventName", 2);
374
+ n([
375
+ o(String)
376
+ ], P.prototype, "eventData", 2);
377
+ n([
378
+ o(String)
379
+ ], P.prototype, "sessionId", 2);
380
+ P = n([
381
+ d({ name: "ToolEventContent" })
382
+ ], P);
383
+ var B;
384
+ let ht = (B = class extends h {
385
+ constructor() {
386
+ super(...arguments);
387
+ e(this, "url");
388
+ e(this, "dataUri");
389
+ }
390
+ }, l(B, "ImageContent"), B);
391
+ n([
392
+ o(String)
393
+ ], ht.prototype, "url", 2);
394
+ n([
395
+ o(String)
396
+ ], ht.prototype, "dataUri", 2);
397
+ ht = n([
398
+ d({ name: "ImageContent" })
399
+ ], ht);
400
+ var K;
401
+ let A = (K = class extends h {
402
+ constructor() {
403
+ super(...arguments);
404
+ e(this, "id");
405
+ e(this, "pluginName");
406
+ e(this, "functionName");
407
+ e(this, "arguments");
408
+ // Exception is not serializable - omit jsonMember decorator
409
+ e(this, "exception");
410
+ }
411
+ }, l(K, "FunctionCallContent"), K);
412
+ n([
413
+ o(String)
414
+ ], A.prototype, "id", 2);
415
+ n([
416
+ o(String)
417
+ ], A.prototype, "pluginName", 2);
418
+ n([
419
+ o(String)
420
+ ], A.prototype, "functionName", 2);
421
+ n([
422
+ o(Ft)
423
+ ], A.prototype, "arguments", 2);
424
+ A = n([
425
+ d({ name: "FunctionCallContent" })
426
+ ], A);
427
+ var H;
428
+ let v = (H = class {
429
+ constructor() {
430
+ e(this, "isUi");
431
+ e(this, "askUserComponent");
432
+ e(this, "argsDescription");
433
+ }
434
+ }, l(H, "ToolCallPresentation"), H);
435
+ n([
436
+ o(Boolean)
437
+ ], v.prototype, "isUi", 2);
438
+ n([
439
+ o(String)
440
+ ], v.prototype, "askUserComponent", 2);
441
+ n([
442
+ o(String)
443
+ ], v.prototype, "argsDescription", 2);
444
+ v = n([
445
+ d({ name: "ToolCallPresentation" })
446
+ ], v);
447
+ const Mt = "aia:presentation";
448
+ var Y;
449
+ let b = (Y = class extends C {
450
+ constructor() {
451
+ super(...arguments);
452
+ e(this, "id");
453
+ e(this, "functionName");
454
+ e(this, "arguments");
455
+ e(this, "presentation");
456
+ }
457
+ }, l(Y, "StreamingFinalFunctionCallContent"), Y);
458
+ n([
459
+ o(String, { name: "callId" })
460
+ ], b.prototype, "id", 2);
461
+ n([
462
+ o(String, { name: "name" })
463
+ ], b.prototype, "functionName", 2);
464
+ n([
465
+ o(String)
466
+ ], b.prototype, "arguments", 2);
467
+ n([
468
+ o(v)
469
+ ], b.prototype, "presentation", 2);
470
+ b = n([
471
+ d({ name: "StreamingFinalFunctionCallContent" })
472
+ ], b);
473
+ var Q;
474
+ let U = (Q = class extends h {
475
+ constructor() {
476
+ super(...arguments);
477
+ e(this, "id");
478
+ e(this, "pluginName");
479
+ e(this, "functionName");
480
+ e(this, "result");
481
+ }
482
+ }, l(Q, "FunctionResultContent"), Q);
483
+ n([
484
+ o(String, { name: "callId" })
485
+ ], U.prototype, "id", 2);
486
+ n([
487
+ o(String)
488
+ ], U.prototype, "pluginName", 2);
489
+ n([
490
+ o(String)
491
+ ], U.prototype, "functionName", 2);
492
+ n([
493
+ o(Ft)
494
+ ], U.prototype, "result", 2);
495
+ U = n([
496
+ d({ name: "FunctionResultContent" })
497
+ ], U);
498
+ var V;
499
+ let I = (V = class extends C {
500
+ constructor() {
501
+ super(...arguments);
502
+ e(this, "id");
503
+ e(this, "pluginName");
504
+ e(this, "functionName");
505
+ e(this, "result");
506
+ e(this, "presentation");
507
+ e(this, "clientOutput");
508
+ }
509
+ }, l(V, "StreamingFinalFunctionResultContent"), V);
510
+ n([
511
+ o(String, { name: "callId" })
512
+ ], I.prototype, "id", 2);
513
+ n([
514
+ o(String)
515
+ ], I.prototype, "pluginName", 2);
516
+ n([
517
+ o(String)
518
+ ], I.prototype, "functionName", 2);
519
+ n([
520
+ o(Ft)
521
+ ], I.prototype, "result", 2);
522
+ n([
523
+ o(v)
524
+ ], I.prototype, "presentation", 2);
525
+ n([
526
+ o(String)
527
+ ], I.prototype, "clientOutput", 2);
528
+ I = n([
529
+ d({ name: "StreamingFinalFunctionResultContent" })
530
+ ], I);
531
+ var X;
532
+ let mt = (X = class extends h {
533
+ constructor() {
534
+ super(...arguments);
535
+ e(this, "id");
536
+ e(this, "data");
537
+ }
538
+ }, l(X, "FunctionClientOutputContent"), X);
539
+ n([
540
+ o(String, { name: "callId" })
541
+ ], mt.prototype, "id", 2);
542
+ n([
543
+ o(String)
544
+ ], mt.prototype, "data", 2);
545
+ mt = n([
546
+ d({ name: "FunctionClientOutputContent" })
547
+ ], mt);
548
+ var Z;
549
+ let gt = (Z = class extends C {
550
+ constructor() {
551
+ super(...arguments);
552
+ e(this, "id");
553
+ e(this, "clientOutput");
554
+ }
555
+ }, l(Z, "StreamingClientOutputContent"), Z);
556
+ n([
557
+ o(String, { name: "callId" })
558
+ ], gt.prototype, "id", 2);
559
+ n([
560
+ o(String)
561
+ ], gt.prototype, "clientOutput", 2);
562
+ gt = n([
563
+ d({ name: "StreamingClientOutputContent" })
564
+ ], gt);
565
+ var j;
566
+ let dt = (j = class extends h {
567
+ constructor() {
568
+ super(...arguments);
569
+ e(this, "name");
570
+ e(this, "args");
571
+ }
572
+ }, l(j, "UserUiContent"), j);
573
+ n([
574
+ o(String)
575
+ ], dt.prototype, "name", 2);
576
+ n([
577
+ o(String)
578
+ ], dt.prototype, "args", 2);
579
+ dt = n([
580
+ d({ name: "UserUiContent" })
581
+ ], dt);
582
+ var tt;
583
+ let yt = (tt = class extends h {
584
+ constructor() {
585
+ super(...arguments);
586
+ e(this, "role");
587
+ e(this, "items");
588
+ }
589
+ }, l(tt, "ChatMessageContent"), tt);
590
+ n([
591
+ o(Tt)
592
+ ], yt.prototype, "role", 2);
593
+ n([
594
+ ft(() => h)
595
+ ], yt.prototype, "items", 2);
596
+ yt = n([
597
+ d({ name: "ChatMessageContent" })
598
+ ], yt);
599
+ var et;
600
+ let O = (et = class extends C {
601
+ constructor() {
602
+ super(...arguments);
603
+ e(this, "callId");
604
+ e(this, "name");
605
+ e(this, "arguments");
606
+ e(this, "functionCallIndex", 0);
607
+ }
608
+ }, l(et, "StreamingFunctionCallUpdateContent"), et);
609
+ n([
610
+ o(String)
611
+ ], O.prototype, "callId", 2);
612
+ n([
613
+ o(String)
614
+ ], O.prototype, "name", 2);
615
+ n([
616
+ o(String)
617
+ ], O.prototype, "arguments", 2);
618
+ n([
619
+ o(Number)
620
+ ], O.prototype, "functionCallIndex", 2);
621
+ O = n([
622
+ d({ name: "StreamingFunctionCallUpdateContent" })
623
+ ], O);
624
+ var nt;
625
+ let Ct = (nt = class extends C {
626
+ constructor() {
627
+ super(...arguments);
628
+ e(this, "text");
629
+ // Encoding is not explicitly serialized in C#
630
+ // Not decorated with @jsonMember
631
+ e(this, "encoding");
632
+ }
633
+ }, l(nt, "StreamingTextContent"), nt);
634
+ n([
635
+ o(String)
636
+ ], Ct.prototype, "text", 2);
637
+ Ct = n([
638
+ d({ name: "StreamingTextContent" })
639
+ ], Ct);
640
+ var it;
641
+ let Dt = (it = class extends C {
642
+ constructor() {
643
+ super(...arguments);
644
+ e(this, "text");
645
+ // Encoding is not explicitly serialized in C#
646
+ // Not decorated with @jsonMember
647
+ e(this, "encoding");
648
+ }
649
+ }, l(it, "StreamingReasoningContent"), it);
650
+ n([
651
+ o(String)
652
+ ], Dt.prototype, "text", 2);
653
+ Dt = n([
654
+ d({ name: "StreamingReasoningContent" })
655
+ ], Dt);
656
+ var ot;
657
+ let k = (ot = class {
658
+ constructor() {
659
+ e(this, "instructionCategory", "");
660
+ e(this, "description", "");
661
+ e(this, "interactionId", "");
662
+ }
663
+ }, l(ot, "InstructionSummary"), ot);
664
+ n([
665
+ o(String)
666
+ ], k.prototype, "instructionCategory", 2);
667
+ n([
668
+ o(String)
669
+ ], k.prototype, "description", 2);
670
+ n([
671
+ o(String)
672
+ ], k.prototype, "interactionId", 2);
673
+ k = n([
674
+ d({ name: "InstructionSummary" })
675
+ ], k);
676
+ var rt;
677
+ let E = (rt = class {
678
+ constructor() {
679
+ e(this, "size", 0);
680
+ e(this, "originalSize", 0);
681
+ e(this, "ratio", 0);
682
+ e(this, "previousRatio", 0);
683
+ e(this, "threshold", 0);
684
+ e(this, "maxSize", 0);
685
+ e(this, "id");
686
+ e(this, "instructionSummaries", []);
687
+ }
688
+ }, l(rt, "SessionInformation"), rt);
689
+ n([
690
+ o(Number)
691
+ ], E.prototype, "size", 2);
692
+ n([
693
+ o(Number)
694
+ ], E.prototype, "originalSize", 2);
695
+ n([
696
+ o(Number)
697
+ ], E.prototype, "ratio", 2);
698
+ n([
699
+ o(Number)
700
+ ], E.prototype, "previousRatio", 2);
701
+ n([
702
+ o(Number)
703
+ ], E.prototype, "threshold", 2);
704
+ n([
705
+ o(Number)
706
+ ], E.prototype, "maxSize", 2);
707
+ n([
708
+ o(String)
709
+ ], E.prototype, "id", 2);
710
+ n([
711
+ ft(k)
712
+ ], E.prototype, "instructionSummaries", 2);
713
+ E = n([
714
+ d({ name: "SessionInformation" })
715
+ ], E);
716
+ var at;
717
+ let S = (at = class {
718
+ constructor() {
719
+ e(this, "timestamp");
720
+ e(this, "mimeType");
721
+ e(this, "partial");
722
+ e(this, "turnComplete");
723
+ e(this, "visible");
724
+ e(this, "serverError");
725
+ e(this, "interactionId");
726
+ e(this, "sessionInformation");
727
+ e(this, "eventType");
728
+ e(this, "artifactsGenerated", []);
729
+ e(this, "author");
730
+ e(this, "role");
731
+ e(this, "command");
732
+ e(this, "content");
733
+ e(this, "streamingParts");
734
+ e(this, "subAgentId");
735
+ e(this, "subAgentName");
736
+ e(this, "text");
737
+ }
738
+ }, l(at, "LlmEvent"), at);
739
+ n([
740
+ o(Number)
741
+ ], S.prototype, "timestamp", 2);
742
+ n([
743
+ o(String)
744
+ ], S.prototype, "mimeType", 2);
745
+ n([
746
+ o(Boolean)
747
+ ], S.prototype, "partial", 2);
748
+ n([
749
+ o(Boolean)
750
+ ], S.prototype, "turnComplete", 2);
751
+ n([
752
+ o(Boolean)
753
+ ], S.prototype, "visible", 2);
754
+ n([
755
+ o(String)
756
+ ], S.prototype, "serverError", 2);
757
+ n([
758
+ o(String)
759
+ ], S.prototype, "interactionId", 2);
760
+ n([
761
+ o(E)
762
+ ], S.prototype, "sessionInformation", 2);
763
+ n([
764
+ o(ut)
765
+ ], S.prototype, "eventType", 2);
766
+ n([
767
+ ft(R)
768
+ ], S.prototype, "artifactsGenerated", 2);
769
+ n([
770
+ o(String)
771
+ ], S.prototype, "author", 2);
772
+ n([
773
+ o(Tt)
774
+ ], S.prototype, "role", 2);
775
+ n([
776
+ o(String)
777
+ ], S.prototype, "command", 2);
778
+ n([
779
+ o(yt)
780
+ ], S.prototype, "content", 2);
781
+ n([
782
+ ft(() => C)
783
+ ], S.prototype, "streamingParts", 2);
784
+ S = n([
785
+ d({ name: "LlmEvent" })
786
+ ], S);
787
+ var st;
788
+ let D = (st = class {
789
+ constructor() {
790
+ e(this, "timeStamp");
791
+ e(this, "partialText");
792
+ e(this, "partialReasoning");
793
+ e(this, "functionName");
794
+ e(this, "streamingParts");
795
+ e(this, "functionCallId");
796
+ e(this, "type");
797
+ e(this, "iteractionId");
798
+ e(this, "partialEventType");
799
+ e(this, "subAgentId");
800
+ }
801
+ }, l(st, "PartialLlmEvent"), st);
802
+ n([
803
+ o(Number, { name: "ts" })
804
+ ], D.prototype, "timeStamp", 2);
805
+ n([
806
+ o(String, { name: "pt" })
807
+ ], D.prototype, "partialText", 2);
808
+ n([
809
+ o(String, { name: "pr" })
810
+ ], D.prototype, "partialReasoning", 2);
811
+ n([
812
+ o(String, { name: "fn" })
813
+ ], D.prototype, "functionName", 2);
814
+ n([
815
+ ft(() => C)
816
+ ], D.prototype, "streamingParts", 2);
817
+ n([
818
+ o(String, { name: "fid" })
819
+ ], D.prototype, "functionCallId", 2);
820
+ n([
821
+ o(String, { name: "tp" })
822
+ ], D.prototype, "type", 2);
823
+ n([
824
+ o(String, { name: "itid" })
825
+ ], D.prototype, "iteractionId", 2);
826
+ n([
827
+ o(ut)
828
+ ], D.prototype, "partialEventType", 2);
829
+ n([
830
+ o(String, { name: "said" })
831
+ ], D.prototype, "subAgentId", 2);
832
+ D = n([
833
+ d({ name: "PartialLlmEvent" })
834
+ ], D);
835
+ var pt;
836
+ let F = (pt = class {
837
+ constructor() {
838
+ e(this, "type");
839
+ e(this, "event");
840
+ e(this, "sessionId");
841
+ e(this, "accessToken");
842
+ e(this, "partialEvent");
843
+ e(this, "subAgentId");
844
+ e(this, "subAgentName");
845
+ e(this, "seq");
846
+ }
847
+ }, l(pt, "StreamingResponse"), pt);
848
+ n([
849
+ o(String)
850
+ ], F.prototype, "type", 2);
851
+ n([
852
+ o(S)
853
+ ], F.prototype, "event", 2);
854
+ n([
855
+ o(String)
856
+ ], F.prototype, "sessionId", 2);
857
+ n([
858
+ o(String)
859
+ ], F.prototype, "accessToken", 2);
860
+ n([
861
+ o(D, { name: "pe" })
862
+ ], F.prototype, "partialEvent", 2);
863
+ n([
864
+ o(String)
865
+ ], F.prototype, "subAgentId", 2);
866
+ n([
867
+ o(String)
868
+ ], F.prototype, "subAgentName", 2);
869
+ n([
870
+ o(Number)
871
+ ], F.prototype, "seq", 2);
872
+ F = n([
873
+ d({ name: "StreamingResponse" })
874
+ ], F);
875
+ var lt;
876
+ let At = (lt = class {
877
+ constructor() {
878
+ e(this, "events");
879
+ }
880
+ }, l(lt, "Payload"), lt);
881
+ n([
882
+ ft(S)
883
+ ], At.prototype, "events", 2);
884
+ At = n([
885
+ d({ name: "Payload" })
886
+ ], At);
887
+ function Bt(s) {
888
+ var a;
889
+ const t = (s == null ? void 0 : s.presentation) ?? ((a = s == null ? void 0 : s.metadata) == null ? void 0 : a[Mt]);
890
+ if (!t || typeof t != "object") return { isUi: !1 };
891
+ const i = t, r = /* @__PURE__ */ l((p, c) => i[p] ?? i[c], "pick");
892
+ return {
893
+ isUi: r("isUi", "IsUi") === !0,
894
+ askUserComponent: r("askUserComponent", "AskUserComponent") || void 0,
895
+ argsDescription: r("argsDescription", "ArgsDescription") || void 0
896
+ };
897
+ }
898
+ l(Bt, "readPresentation");
899
+ const N = class N {
900
+ constructor(t) {
901
+ e(this, "uniqueId");
902
+ e(this, "mimeType");
903
+ e(this, "created");
904
+ e(this, "author");
905
+ e(this, "eventType");
906
+ e(this, "allEventTypes", []);
907
+ e(this, "interactionId");
908
+ e(this, "artifactsDelta", []);
909
+ e(this, "llmArtifacts", []);
910
+ e(this, "partial");
911
+ e(this, "turn_complete");
912
+ e(this, "isFinalResponse");
913
+ e(this, "interrupted");
914
+ e(this, "model_session_id");
915
+ e(this, "functionDetails");
916
+ e(this, "executableCodeDetails");
917
+ e(this, "codeExecutionResultDetails");
918
+ e(this, "thoughtDefails");
919
+ e(this, "rawDetails");
920
+ e(this, "rendered");
921
+ e(this, "serverError");
922
+ e(this, "server_session_id");
923
+ e(this, "asyncFinalResponse");
924
+ e(this, "agentServerBaseUrl");
925
+ e(this, "parts", []);
926
+ e(this, "endMessageData");
927
+ e(this, "command");
928
+ e(this, "session_information");
929
+ e(this, "subAgentId");
930
+ e(this, "subAgentName");
931
+ e(this, "visible", !0);
932
+ this.interactionId = t, this.author = "main";
933
+ }
934
+ static createErrorEvent(t, i) {
935
+ const r = new N(i);
936
+ r.turn_complete = !0, r.partial = !1, r.parts = [];
937
+ const a = {
938
+ eventType: m.ServerError,
939
+ errorDetails: {
940
+ errorMessage: t
941
+ },
942
+ id: "",
943
+ author: "main",
944
+ created: /* @__PURE__ */ new Date(),
945
+ partial: !1,
946
+ isStillWriting: !1,
947
+ mustPush: !1,
948
+ textAppendable: !1
949
+ };
950
+ return r.parts.push(a), r;
951
+ }
952
+ static parseFlatPropertiesTypedEvent(t) {
953
+ var r, a, p;
954
+ const i = new N(t.interactionId);
955
+ if (i.serverError = t.serverError, !t.interactionId)
956
+ throw new Error("Interaction ID is required");
957
+ switch (i.model_session_id = "", i.server_session_id = null, i.asyncFinalResponse = t.turnComplete, i.command = (r = t.command) == null ? void 0 : r.toString(), t.sessionInformation && (i.session_information = t.sessionInformation), (!t.author || t.author == "") && console.warn('[ServerEvent] event with no author; defaulting to "main"', {
958
+ interactionId: t.interactionId,
959
+ turnComplete: t.turnComplete
960
+ }), t == null ? void 0 : t.author) {
961
+ case Wt:
962
+ i.author = "tool";
963
+ break;
964
+ case "system":
965
+ i.author = "system";
966
+ break;
967
+ default:
968
+ i.author = "main";
969
+ }
970
+ return i.mimeType = t.mimeType, i.created = new Date(t.timestamp), i.eventType = m.NotDefined, i.partial = ((p = (a = t.partial) == null ? void 0 : a.toString()) == null ? void 0 : p.toLowerCase()) === "true", i.turn_complete = t.turnComplete, i.visible = t.visible, i.isFinalResponse = t.turnComplete ?? !1, i.artifactsDelta = [], t.artifactsGenerated && t.artifactsGenerated.length > 0 && (i.created = new Date(t.timestamp), i.llmArtifacts = t.artifactsGenerated), i.subAgentId = t.subAgentId, i.subAgentName = t.subAgentName, i;
971
+ }
972
+ static getPartType(t) {
973
+ return t instanceof xt ? "TextContent" : t instanceof A ? "FunctionCallContent" : t instanceof U ? "FunctionResultContent" : t instanceof O ? "StreamingFunctionCallUpdateContent" : t instanceof b ? "StreamingFinalFunctionCallContent" : t instanceof I ? "StreamingFinalFunctionResultContent" : t instanceof mt ? "FunctionClientOutputContent" : t instanceof gt ? "StreamingClientOutputContent" : t instanceof dt ? "UserUiContent" : t instanceof Ct ? "StreamingTextContent" : t instanceof Dt ? "StreamingReasoningContent" : t instanceof P ? "ToolEventContent" : t instanceof ct ? "StreamingToolEventContent" : "Unknown";
974
+ }
975
+ static parseFromTypedEvent(t) {
976
+ var p, c, g, z, bt, Ut, Ot;
977
+ const i = N.parseFlatPropertiesTypedEvent(t);
978
+ if (i.serverError)
979
+ return i.parts.push(Nt.fromError(i.serverError)), i;
980
+ if (!t.content && !t.streamingParts)
981
+ return i;
982
+ i.parts = [];
983
+ const r = [...((p = t.content) == null ? void 0 : p.items) ?? [], ...t.streamingParts ?? []];
984
+ i.eventType = $t(((c = t.eventType) == null ? void 0 : c.type) ?? "");
985
+ for (const f of r) {
986
+ let u = {
987
+ id: "",
988
+ author: i.author,
989
+ eventType: i.eventType,
990
+ created: /* @__PURE__ */ new Date(),
991
+ visible: i.visible,
992
+ partial: i.partial,
993
+ isStillWriting: !1,
994
+ mustPush: !1,
995
+ textAppendable: !1
996
+ };
997
+ const T = N.getPartType(f);
998
+ if (T == x.FunctionCallContent || T == x.FunctionResultContent || T == x.StreamingFinalFunctionCallContent || T == x.StreamingFinalFunctionResultContent) {
999
+ var a = f;
1000
+ if (a.id == "Server Error")
1001
+ u.eventType = m.ServerError, u.errorDetails = {
1002
+ errorMessage: JSON.stringify(a.arguments)
1003
+ }, u.functionDetails = void 0;
1004
+ else {
1005
+ u.eventType = T == x.FunctionCallContent || T == x.StreamingFinalFunctionCallContent ? m.FunctionCall : m.FunctionResponse;
1006
+ let y;
1007
+ try {
1008
+ if (a != null && a.result)
1009
+ if (typeof a.result == "object")
1010
+ y = a.result;
1011
+ else if (typeof a.result == "string") {
1012
+ const St = JSON.parse(a.result);
1013
+ y = typeof St == "object" && St !== null ? St : a.result;
1014
+ } else
1015
+ y = a.result;
1016
+ } catch (St) {
1017
+ console.warn("Parse function error", St), y = a == null ? void 0 : a.result;
1018
+ }
1019
+ u.thoughtDetails = {
1020
+ text: ""
1021
+ };
1022
+ const It = Bt(a);
1023
+ u.functionDetails = {
1024
+ id: (a == null ? void 0 : a.id) ?? "",
1025
+ args: a == null ? void 0 : a.arguments,
1026
+ start: T == x.FunctionCallContent ? i.created : void 0,
1027
+ end: T == x.FunctionResultContent ? i.created : void 0,
1028
+ text: JSON.stringify(a == null ? void 0 : a.arguments) ?? "",
1029
+ name: (a == null ? void 0 : a.functionName) ?? "",
1030
+ status: u.eventType == m.FunctionCall ? "Executing" : "Done",
1031
+ response: y,
1032
+ isUi: It.isUi,
1033
+ argsDescription: It.argsDescription,
1034
+ // Client-only payload riding the RESULT event: live top-level `clientOutput`, or
1035
+ // metadata.clientOutput on the collapsed/persisted result. Calls leave it undefined.
1036
+ // The persisted-replay form also folds in via FunctionClientOutputContent.
1037
+ clientOutput: (a == null ? void 0 : a.clientOutput) ?? ((g = a == null ? void 0 : a.metadata) == null ? void 0 : g.clientOutput),
1038
+ askUserComponent: It.askUserComponent
1039
+ }, u.functionDetails.isAskUser = !!u.functionDetails.askUserComponent, t.text = a == null ? void 0 : a.arguments;
1040
+ }
1041
+ } else if (T == x.StreamingTextContent)
1042
+ u.eventType = m.Text, u.text = (z = f == null ? void 0 : f.text) == null ? void 0 : z.replaceAll("\\n", `
1043
+ `), u.textLastChunk = f.text, t.text = u.text;
1044
+ else if (T == x.TextContent)
1045
+ u.eventType = m.Text, u.text = (bt = f == null ? void 0 : f.text) == null ? void 0 : bt.replaceAll("\\n", `
1046
+ `), u.textLastChunk = f.text, t.text = u.text;
1047
+ else if (T == x.StreamingReasoningContent)
1048
+ u.eventType = m.Thought, u.thoughtDetails = {
1049
+ text: ((Ut = f == null ? void 0 : f.text) == null ? void 0 : Ut.replaceAll("\\n", `
1050
+ `)) ?? ""
1051
+ }, u.text = (Ot = f == null ? void 0 : f.text) == null ? void 0 : Ot.replaceAll("\\n", `
1052
+ `), u.textLastChunk = f.text, t.text = u.text;
1053
+ else if (T == x.StreamingFunctionCallUpdateContent) {
1054
+ const y = f;
1055
+ u.eventType = m.PartialFunctionCall, u.text = y.arguments, u.thoughtDetails = {
1056
+ text: ""
1057
+ }, u.functionDetails = {
1058
+ id: y.callId ?? "",
1059
+ text: u.text,
1060
+ status: "Composing",
1061
+ name: (y == null ? void 0 : y.name) ?? "Unknown"
1062
+ }, t.text = u.text;
1063
+ } else if (T == x.ToolEventContent || T == x.StreamingToolEventContent) {
1064
+ u.eventType = m.ToolEvent;
1065
+ const y = f;
1066
+ u.toolDetails = {
1067
+ eventName: y.eventName ?? "",
1068
+ eventData: y.eventData ?? "",
1069
+ sessionId: y.sessionId ?? void 0
1070
+ };
1071
+ } else if (T == x.FunctionClientOutputContent) {
1072
+ const y = f;
1073
+ u.eventType = m.FunctionClientOutput, u.functionDetails = {
1074
+ id: y.id ?? "",
1075
+ name: "",
1076
+ status: "Done",
1077
+ clientOutput: y.data
1078
+ };
1079
+ } else if (T == x.StreamingClientOutputContent) {
1080
+ const y = f;
1081
+ u.eventType = m.FunctionClientOutput, u.functionDetails = {
1082
+ id: y.id ?? "",
1083
+ name: "",
1084
+ // The parked call stays Executing; interactionService folds only clientOutput onto it and
1085
+ // leaves the existing status untouched, so this is just to satisfy the type.
1086
+ status: "Executing",
1087
+ clientOutput: y.clientOutput
1088
+ };
1089
+ } else if (T == x.UserUiContent) {
1090
+ const y = f;
1091
+ u.eventType = m.UserAnswer, u.author = "user", u.functionDetails = {
1092
+ id: "",
1093
+ name: y.name ?? "",
1094
+ args: y.args,
1095
+ status: "Done",
1096
+ isUi: !0
1097
+ };
1098
+ } else {
1099
+ u.eventType = m.NotDefined, console.warn(`Got a unmapped event_type:${i.eventType}, data:`, T, f);
1100
+ continue;
1101
+ }
1102
+ i.parts.push(u);
1103
+ }
1104
+ return i;
1105
+ }
1106
+ static createFromThought(t, i) {
1107
+ return {
1108
+ author: "main",
1109
+ visible: !0,
1110
+ eventType: m.Thought,
1111
+ uniqueId: (/* @__PURE__ */ new Date()).getTime().toString(),
1112
+ interactionId: t,
1113
+ allEventTypes: [m.Thought],
1114
+ artifactsDelta: [""],
1115
+ model_session_id: "",
1116
+ created: /* @__PURE__ */ new Date(),
1117
+ turn_complete: !1,
1118
+ partial: !0,
1119
+ asyncFinalResponse: !1,
1120
+ mimeType: "text/plain",
1121
+ parts: [
1122
+ {
1123
+ thoughtDetails: {
1124
+ text: i
1125
+ },
1126
+ id: Et(),
1127
+ created: /* @__PURE__ */ new Date(),
1128
+ eventType: m.Thought,
1129
+ author: "main",
1130
+ isStillWriting: !1,
1131
+ textAppendable: !0,
1132
+ partial: !0,
1133
+ mustPush: !0
1134
+ }
1135
+ ]
1136
+ };
1137
+ }
1138
+ static createFromFunctionName(t, i, r) {
1139
+ const a = N.createFromText("", i);
1140
+ return a.parts[0].text = void 0, a.parts[0].thoughtDetails = void 0, a.parts[0].textAppendable = !1, a.parts[0].mustPush = !0, a.parts[0].functionDetails = {
1141
+ name: t,
1142
+ id: "callId",
1143
+ status: "Executing",
1144
+ start: /* @__PURE__ */ new Date(),
1145
+ end: void 0,
1146
+ text: "dfsdfdf",
1147
+ args: r
1148
+ }, a;
1149
+ }
1150
+ static createFromText(t, i, r) {
1151
+ return {
1152
+ author: "main",
1153
+ visible: !0,
1154
+ eventType: m.Text,
1155
+ uniqueId: (/* @__PURE__ */ new Date()).getTime().toString(),
1156
+ interactionId: i,
1157
+ allEventTypes: [m.Text],
1158
+ artifactsDelta: [""],
1159
+ model_session_id: "",
1160
+ created: /* @__PURE__ */ new Date(),
1161
+ turn_complete: !1,
1162
+ partial: !0,
1163
+ asyncFinalResponse: !1,
1164
+ mimeType: "text/plain",
1165
+ parts: [
1166
+ {
1167
+ // Optional reasoning trace shown next to the message. Parts
1168
+ // with `eventType: Text` AND a populated `thoughtDetails`
1169
+ // render the text in the body and the trace in the
1170
+ // thinking strip.
1171
+ thoughtDetails: r ? {
1172
+ text: r
1173
+ } : void 0,
1174
+ id: Et(),
1175
+ created: /* @__PURE__ */ new Date(),
1176
+ // Part eventType MUST match the outer event's eventType.
1177
+ // Was previously `Thought` here, which made the merger
1178
+ // classify a streamed Text part as a Thought (rendered
1179
+ // in the trace strip instead of the message body) —
1180
+ // the chat would show the message during streaming and
1181
+ // then "disappear" once the part was reclassified.
1182
+ eventType: m.Text,
1183
+ author: "main",
1184
+ isStillWriting: !1,
1185
+ textAppendable: !0,
1186
+ partial: !0,
1187
+ mustPush: !0,
1188
+ text: t
1189
+ }
1190
+ ]
1191
+ };
1192
+ }
1193
+ };
1194
+ l(N, "ServerEvent");
1195
+ let Rt = N;
1196
+ const vt = [
1197
+ // KernelContent derived types
1198
+ xt,
1199
+ ht,
1200
+ A,
1201
+ P,
1202
+ U,
1203
+ mt,
1204
+ dt,
1205
+ yt,
1206
+ // StreamingKernelContent derived types
1207
+ Ct,
1208
+ O,
1209
+ Dt,
1210
+ b,
1211
+ I,
1212
+ gt,
1213
+ k
1214
+ ];
1215
+ function Kt(s) {
1216
+ return s.name;
1217
+ }
1218
+ l(Kt, "getConstructorName");
1219
+ function kt(s, t, i, r) {
1220
+ t.constructor !== i && (s.$type = (r == null ? void 0 : r.name) ?? Kt(t.constructor));
1221
+ }
1222
+ l(kt, "dotNetTypeEmitter");
1223
+ function zt(s, t) {
1224
+ if (s.$type != null)
1225
+ return t.get(s.$type);
1226
+ }
1227
+ l(zt, "dotnetTypeResolver");
1228
+ function _t() {
1229
+ const s = new Pt(S);
1230
+ return s.config({
1231
+ knownTypes: vt,
1232
+ typeHintEmitter: kt,
1233
+ typeResolver: zt
1234
+ }), s;
1235
+ }
1236
+ l(_t, "createEventSerializer");
1237
+ function Ht() {
1238
+ const s = new Pt(F);
1239
+ return s.config({
1240
+ knownTypes: vt,
1241
+ typeHintEmitter: kt,
1242
+ typeResolver: zt
1243
+ }), s;
1244
+ }
1245
+ l(Ht, "createStreamingResponseSerializer");
1246
+ function Lt(s) {
1247
+ try {
1248
+ return JSON.parse(s), s;
1249
+ } catch {
1250
+ let i = "", r = !1;
1251
+ for (let a = 0; a < s.length; a++) {
1252
+ const p = s[a], c = p.charCodeAt(0);
1253
+ if (p === "\\" && r && a + 1 < s.length) {
1254
+ const g = s[a + 1];
1255
+ if (g === '"' || g === "\\" || g === "/" || g === "b" || g === "f" || g === "n" || g === "r" || g === "t") {
1256
+ i += p + g, a++;
1257
+ continue;
1258
+ } else if (g === "u" && a + 5 < s.length) {
1259
+ i += s.substring(a, a + 6), a += 5;
1260
+ continue;
1261
+ } else {
1262
+ i += p;
1263
+ continue;
1264
+ }
1265
+ }
1266
+ if (p === '"') {
1267
+ let g = 0;
1268
+ for (let z = a - 1; z >= 0 && s[z] === "\\"; z--)
1269
+ g++;
1270
+ g % 2 === 0 && (r = !r), i += p;
1271
+ continue;
1272
+ }
1273
+ if (r && c < 32)
1274
+ switch (p) {
1275
+ case `
1276
+ `:
1277
+ i += "\\n";
1278
+ break;
1279
+ case "\r":
1280
+ i += "\\r";
1281
+ break;
1282
+ case " ":
1283
+ i += "\\t";
1284
+ break;
1285
+ case "\f":
1286
+ i += "\\f";
1287
+ break;
1288
+ case "\b":
1289
+ i += "\\b";
1290
+ break;
1291
+ default:
1292
+ const g = c.toString(16).padStart(4, "0");
1293
+ i += `\\u${g}`;
1294
+ break;
1295
+ }
1296
+ else
1297
+ i += p;
1298
+ }
1299
+ return i;
1300
+ }
1301
+ }
1302
+ l(Lt, "sanitizeJsonString");
1303
+ function Xt(s) {
1304
+ const t = Lt(s);
1305
+ return Ht().parse(t);
1306
+ }
1307
+ l(Xt, "deserializePayload");
1308
+ function Zt(s) {
1309
+ const t = Lt(s);
1310
+ return _t().parse(t);
1311
+ }
1312
+ l(Zt, "deserializeEvent");
1313
+ function jt(s) {
1314
+ return _t().stringify(s);
1315
+ }
1316
+ l(jt, "serializeEvent");
1317
+ export {
1318
+ yt as C,
1319
+ A as F,
1320
+ Nt as I,
1321
+ S as L,
1322
+ x as P,
1323
+ Rt as S,
1324
+ xt as T,
1325
+ U as a,
1326
+ O as b,
1327
+ Dt as c,
1328
+ F as d,
1329
+ Ct as e,
1330
+ _t as f,
1331
+ Ht as g,
1332
+ Zt as h,
1333
+ Xt as i,
1334
+ jt as j,
1335
+ Lt as s
1336
+ };
1337
+ //# sourceMappingURL=serializer-BPina6fX.js.map