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