@aintela/chat 0.2.58 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +63 -0
  2. package/dist/{ClientMessage-EKgfuTp8.js → ClientMessage-DUby3KyC.js} +16 -22
  3. package/dist/{ClientMessage-EKgfuTp8.js.map → ClientMessage-DUby3KyC.js.map} +1 -1
  4. package/dist/Memory-CjrYSkzB.js +47 -0
  5. package/dist/Memory-CjrYSkzB.js.map +1 -0
  6. package/dist/atMentions-CCNBOf5W.js +954 -0
  7. package/dist/atMentions-CCNBOf5W.js.map +1 -0
  8. package/dist/components.js +5291 -5145
  9. package/dist/components.js.map +1 -1
  10. package/dist/environmentUtils-VZNTCzEE.js +88 -0
  11. package/dist/environmentUtils-VZNTCzEE.js.map +1 -0
  12. package/dist/hooks.js +4 -5
  13. package/dist/{httpArtifactService-JtkC1T7n.js → httpArtifactService-kXjuQtGa.js} +518 -643
  14. package/dist/httpArtifactService-kXjuQtGa.js.map +1 -0
  15. package/dist/{httpSessionService-BDlqebW2.js → httpSessionService-CMT6k-Nu.js} +2 -3
  16. package/dist/{httpSessionService-BDlqebW2.js.map → httpSessionService-CMT6k-Nu.js.map} +1 -1
  17. package/dist/index.js +243 -258
  18. package/dist/models.js +48 -51
  19. package/dist/models.js.map +1 -1
  20. package/dist/serializer-D2W42bdT.js +1730 -0
  21. package/dist/serializer-D2W42bdT.js.map +1 -0
  22. package/dist/services.js +2 -2
  23. package/dist/src/components/AiChat/AiChatProvider.agent.test.d.ts +1 -0
  24. package/dist/src/components/AiChat/AiChatProvider.d.ts +2 -2
  25. package/dist/src/components/AiChat/AiChatTypes.d.ts +45 -16
  26. package/dist/src/components/AiChat/ChatPane/parts/ServerErrorPart.d.ts +19 -0
  27. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRun.d.ts +28 -0
  28. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRunContext.d.ts +18 -0
  29. package/dist/src/components/AiChat/ChatPane/parts/index.d.ts +13 -4
  30. package/dist/src/components/AiChat/ChatPane/parts/thoughtRun.test.d.ts +1 -0
  31. package/dist/src/components/AiChat/ChatPane/parts/types.d.ts +1 -1
  32. package/dist/src/components/AiChat/aiChatEngine.d.ts +24 -5
  33. package/dist/src/components/AiChat/sessionStateManagerService.bind.test.d.ts +1 -0
  34. package/dist/src/components/AiChat/sessionStateManagerService.d.ts +22 -10
  35. package/dist/src/components/AiChat/useAgentEngine.d.ts +69 -0
  36. package/dist/src/components/AiChat/useAgentEngine.test.d.ts +1 -0
  37. package/dist/src/components/index.d.ts +4 -4
  38. package/dist/src/hooks/index.d.ts +1 -1
  39. package/dist/src/hooks/useContainerWidth.d.ts +0 -1
  40. package/dist/src/models/ArtifactData.d.ts +0 -7
  41. package/dist/src/models/ChatSession.d.ts +0 -32
  42. package/dist/src/models/ClientMessage.d.ts +0 -4
  43. package/dist/src/models/ServerEvent.d.ts +7 -36
  44. package/dist/src/models/enums.d.ts +0 -1
  45. package/dist/src/models/index.d.ts +1 -2
  46. package/dist/src/models/interactionPartUtils.test.d.ts +1 -0
  47. package/dist/src/models/semanticKernelModel/sanitizeJsonString.test.d.ts +0 -0
  48. package/dist/src/models/serverEventDecode.test.d.ts +0 -0
  49. package/dist/src/services/WebSocketConnection/webSocketConnectionV2.reconnect.test.d.ts +0 -0
  50. package/dist/src/services/interactionService.d.ts +11 -0
  51. package/dist/src/services/interactionServiceGrouping.test.d.ts +1 -0
  52. package/dist/src/services/servers/AgentGatewayService.d.ts +25 -18
  53. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +0 -1
  54. package/dist/src/services/servers/agentGatewayAgentContext.test.d.ts +1 -0
  55. package/dist/src/services/storageService.d.ts +16 -59
  56. package/dist/src/services/storageService.test.d.ts +1 -0
  57. package/dist/src/utils/index.d.ts +2 -6
  58. package/dist/src/utils/urlParser.d.ts +0 -1
  59. package/dist/tests/fakes/fakeRawWebSocket.d.ts +51 -0
  60. package/dist/tests/fakes/fakeStorage.d.ts +7 -0
  61. package/dist/tests/fakes/makeGateway.d.ts +24 -1
  62. package/dist/{useChatSessions-sbBneRk9.js → useChatSessions-CpHq0e1n.js} +2 -2
  63. package/dist/{useChatSessions-sbBneRk9.js.map → useChatSessions-CpHq0e1n.js.map} +1 -1
  64. package/dist/useContainerWidth-B40_i-NW.js +295 -0
  65. package/dist/{useContainerWidth-B3t1ZTlo.js.map → useContainerWidth-B40_i-NW.js.map} +1 -1
  66. package/dist/utils.js +340 -57
  67. package/dist/utils.js.map +1 -1
  68. package/package.json +1 -1
  69. package/dist/Memory-DjLZqgbF.js +0 -84
  70. package/dist/Memory-DjLZqgbF.js.map +0 -1
  71. package/dist/atMentions-C0dza8DD.js +0 -1000
  72. package/dist/atMentions-C0dza8DD.js.map +0 -1
  73. package/dist/auth-lluJZyQO.js +0 -524
  74. package/dist/auth-lluJZyQO.js.map +0 -1
  75. package/dist/environmentUtils-CUVZ6Dq1.js +0 -478
  76. package/dist/environmentUtils-CUVZ6Dq1.js.map +0 -1
  77. package/dist/httpArtifactService-JtkC1T7n.js.map +0 -1
  78. package/dist/serializer-DNt8QqNO.js +0 -1358
  79. package/dist/serializer-DNt8QqNO.js.map +0 -1
  80. package/dist/src/components/AiChat/useLiveSession.d.ts +0 -52
  81. package/dist/src/utils/jsonDetector.d.ts +0 -50
  82. package/dist/src/utils/jsonUtils.d.ts +0 -1
  83. package/dist/src/utils/materialIconsSvg.d.ts +0 -51
  84. package/dist/src/utils/objectUtils.d.ts +0 -31
  85. package/dist/src/utils/parseArtifact.d.ts +0 -3
  86. package/dist/src/utils/uriUtils.d.ts +0 -39
  87. package/dist/useContainerWidth-B3t1ZTlo.js +0 -309
@@ -1,1358 +0,0 @@
1
- var wt = Object.defineProperty;
2
- var Wt = (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) => Wt(s, typeof t != "symbol" ? t + "" : t, i);
5
- import { E as m, q as It, A as $t, G as Gt } from "./environmentUtils-CUVZ6Dq1.js";
6
- import { jsonMember as o, jsonObject as d, AnyT as L, jsonArrayMember as St, TypedJSON as Pt } from "typedjson";
7
- const R = class R {
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) ? R.isCharArray(t) ? t.join("") : null : R.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 ?? It(),
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 ?? It(),
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 = R.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 = R.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(R, "InteractionPartUtils");
190
- let Nt = R;
191
- var qt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, n = /* @__PURE__ */ l((s, t, i, r) => {
192
- for (var a = r > 1 ? void 0 : r ? Bt(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 && qt(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 W;
214
- let xt = (W = class {
215
- constructor() {
216
- e(this, "label");
217
- }
218
- }, l(W, "AuthorRole"), W);
219
- n([
220
- o(String)
221
- ], xt.prototype, "label", 2);
222
- xt = n([
223
- d({ name: "AuthorRole" })
224
- ], xt);
225
- var $;
226
- let gt = ($ = class {
227
- constructor() {
228
- e(this, "type");
229
- e(this, "fullName");
230
- }
231
- }, l($, "EventTypeInformation"), $);
232
- n([
233
- o(String)
234
- ], gt.prototype, "type", 2);
235
- n([
236
- o(String)
237
- ], gt.prototype, "fullName", 2);
238
- gt = n([
239
- d({ name: "EventTypeInformation" })
240
- ], gt);
241
- var G;
242
- let v = (G = 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(G, "LlmArtifact"), G);
260
- n([
261
- o(String)
262
- ], v.prototype, "id", 2);
263
- n([
264
- o(String)
265
- ], v.prototype, "name", 2);
266
- n([
267
- o(String)
268
- ], v.prototype, "mimeType", 2);
269
- n([
270
- o(String)
271
- ], v.prototype, "description", 2);
272
- v = n([
273
- d({ name: "LlmArtifact" })
274
- ], v);
275
- var q;
276
- let h = (q = 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(q, "KernelContent"), q);
286
- n([
287
- o(String)
288
- ], h.prototype, "mimeType", 2);
289
- n([
290
- o(String)
291
- ], h.prototype, "modelId", 2);
292
- n([
293
- o(L)
294
- ], h.prototype, "metadata", 2);
295
- h = n([
296
- d({ name: "KernelContent" })
297
- ], h);
298
- var B;
299
- let C = (B = 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(B, "StreamingKernelContent"), B);
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 M;
322
- let ht = (M = 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(M, "TextContent"), M);
335
- n([
336
- o(String)
337
- ], ht.prototype, "text", 2);
338
- ht = n([
339
- d({ name: "TextContent" })
340
- ], ht);
341
- var K;
342
- let P = (K = class extends C {
343
- constructor() {
344
- super();
345
- e(this, "eventName");
346
- e(this, "eventData");
347
- e(this, "sessionId");
348
- }
349
- }, l(K, "StreamingToolEventContent"), K);
350
- n([
351
- o(String)
352
- ], P.prototype, "eventName", 2);
353
- n([
354
- o(String)
355
- ], P.prototype, "eventData", 2);
356
- n([
357
- o(String)
358
- ], P.prototype, "sessionId", 2);
359
- P = n([
360
- d({ name: "StreamingToolEventContent" })
361
- ], P);
362
- var H;
363
- let k = (H = class extends h {
364
- constructor() {
365
- super();
366
- e(this, "eventName");
367
- e(this, "eventData");
368
- e(this, "sessionId");
369
- }
370
- }, l(H, "ToolEventContent"), H);
371
- n([
372
- o(String)
373
- ], k.prototype, "eventName", 2);
374
- n([
375
- o(String)
376
- ], k.prototype, "eventData", 2);
377
- n([
378
- o(String)
379
- ], k.prototype, "sessionId", 2);
380
- k = n([
381
- d({ name: "ToolEventContent" })
382
- ], k);
383
- var Y;
384
- let Ct = (Y = class extends h {
385
- constructor() {
386
- super(...arguments);
387
- e(this, "url");
388
- e(this, "dataUri");
389
- }
390
- }, l(Y, "ImageContent"), Y);
391
- n([
392
- o(String)
393
- ], Ct.prototype, "url", 2);
394
- n([
395
- o(String)
396
- ], Ct.prototype, "dataUri", 2);
397
- Ct = n([
398
- d({ name: "ImageContent" })
399
- ], Ct);
400
- var Q;
401
- let U = (Q = 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(Q, "FunctionCallContent"), Q);
412
- n([
413
- o(String)
414
- ], U.prototype, "id", 2);
415
- n([
416
- o(String)
417
- ], U.prototype, "pluginName", 2);
418
- n([
419
- o(String)
420
- ], U.prototype, "functionName", 2);
421
- n([
422
- o(L)
423
- ], U.prototype, "arguments", 2);
424
- U = n([
425
- d({ name: "FunctionCallContent" })
426
- ], U);
427
- var V;
428
- let I = (V = class {
429
- constructor() {
430
- e(this, "isUi");
431
- e(this, "askUserComponent");
432
- e(this, "argsDescription");
433
- e(this, "cancelUi");
434
- e(this, "parked");
435
- }
436
- }, l(V, "ToolCallPresentation"), V);
437
- n([
438
- o(Boolean)
439
- ], I.prototype, "isUi", 2);
440
- n([
441
- o(String)
442
- ], I.prototype, "askUserComponent", 2);
443
- n([
444
- o(String)
445
- ], I.prototype, "argsDescription", 2);
446
- n([
447
- o(Boolean)
448
- ], I.prototype, "cancelUi", 2);
449
- n([
450
- o(Boolean)
451
- ], I.prototype, "parked", 2);
452
- I = n([
453
- d({ name: "ToolCallPresentation" })
454
- ], I);
455
- const Mt = "aia:presentation";
456
- var X;
457
- let b = (X = class extends C {
458
- constructor() {
459
- super(...arguments);
460
- e(this, "id");
461
- e(this, "functionName");
462
- e(this, "arguments");
463
- e(this, "presentation");
464
- }
465
- }, l(X, "StreamingFinalFunctionCallContent"), X);
466
- n([
467
- o(String, { name: "callId" })
468
- ], b.prototype, "id", 2);
469
- n([
470
- o(String, { name: "name" })
471
- ], b.prototype, "functionName", 2);
472
- n([
473
- o(String)
474
- ], b.prototype, "arguments", 2);
475
- n([
476
- o(I)
477
- ], b.prototype, "presentation", 2);
478
- b = n([
479
- d({ name: "StreamingFinalFunctionCallContent" })
480
- ], b);
481
- var Z;
482
- let O = (Z = class extends h {
483
- constructor() {
484
- super(...arguments);
485
- e(this, "id");
486
- e(this, "pluginName");
487
- e(this, "functionName");
488
- e(this, "result");
489
- }
490
- }, l(Z, "FunctionResultContent"), Z);
491
- n([
492
- o(String, { name: "callId" })
493
- ], O.prototype, "id", 2);
494
- n([
495
- o(String)
496
- ], O.prototype, "pluginName", 2);
497
- n([
498
- o(String)
499
- ], O.prototype, "functionName", 2);
500
- n([
501
- o(L)
502
- ], O.prototype, "result", 2);
503
- O = n([
504
- d({ name: "FunctionResultContent" })
505
- ], O);
506
- var j;
507
- let N = (j = class extends C {
508
- constructor() {
509
- super(...arguments);
510
- e(this, "id");
511
- e(this, "pluginName");
512
- e(this, "functionName");
513
- e(this, "result");
514
- e(this, "presentation");
515
- e(this, "clientOutput");
516
- }
517
- }, l(j, "StreamingFinalFunctionResultContent"), j);
518
- n([
519
- o(String, { name: "callId" })
520
- ], N.prototype, "id", 2);
521
- n([
522
- o(String)
523
- ], N.prototype, "pluginName", 2);
524
- n([
525
- o(String)
526
- ], N.prototype, "functionName", 2);
527
- n([
528
- o(L)
529
- ], N.prototype, "result", 2);
530
- n([
531
- o(I)
532
- ], N.prototype, "presentation", 2);
533
- n([
534
- o(L)
535
- ], N.prototype, "clientOutput", 2);
536
- N = n([
537
- d({ name: "StreamingFinalFunctionResultContent" })
538
- ], N);
539
- var tt;
540
- let dt = (tt = class extends h {
541
- constructor() {
542
- super(...arguments);
543
- e(this, "id");
544
- e(this, "data");
545
- }
546
- }, l(tt, "FunctionClientOutputContent"), tt);
547
- n([
548
- o(String, { name: "callId" })
549
- ], dt.prototype, "id", 2);
550
- n([
551
- o(L)
552
- ], dt.prototype, "data", 2);
553
- dt = n([
554
- d({ name: "FunctionClientOutputContent" })
555
- ], dt);
556
- var et;
557
- let z = (et = class extends C {
558
- constructor() {
559
- super(...arguments);
560
- e(this, "id");
561
- e(this, "clientOutput");
562
- e(this, "presentation");
563
- }
564
- }, l(et, "StreamingClientOutputContent"), et);
565
- n([
566
- o(String, { name: "callId" })
567
- ], z.prototype, "id", 2);
568
- n([
569
- o(L)
570
- ], z.prototype, "clientOutput", 2);
571
- n([
572
- o(I)
573
- ], z.prototype, "presentation", 2);
574
- z = n([
575
- d({ name: "StreamingClientOutputContent" })
576
- ], z);
577
- var nt;
578
- let yt = (nt = class extends h {
579
- constructor() {
580
- super(...arguments);
581
- e(this, "name");
582
- e(this, "args");
583
- }
584
- }, l(nt, "UserUiContent"), nt);
585
- n([
586
- o(String)
587
- ], yt.prototype, "name", 2);
588
- n([
589
- o(String)
590
- ], yt.prototype, "args", 2);
591
- yt = n([
592
- d({ name: "UserUiContent" })
593
- ], yt);
594
- var it;
595
- let ft = (it = class extends h {
596
- constructor() {
597
- super(...arguments);
598
- e(this, "role");
599
- e(this, "items");
600
- }
601
- }, l(it, "ChatMessageContent"), it);
602
- n([
603
- o(xt)
604
- ], ft.prototype, "role", 2);
605
- n([
606
- St(() => h)
607
- ], ft.prototype, "items", 2);
608
- ft = n([
609
- d({ name: "ChatMessageContent" })
610
- ], ft);
611
- var ot;
612
- let w = (ot = class extends C {
613
- constructor() {
614
- super(...arguments);
615
- e(this, "callId");
616
- e(this, "name");
617
- e(this, "arguments");
618
- e(this, "functionCallIndex", 0);
619
- }
620
- }, l(ot, "StreamingFunctionCallUpdateContent"), ot);
621
- n([
622
- o(String)
623
- ], w.prototype, "callId", 2);
624
- n([
625
- o(String)
626
- ], w.prototype, "name", 2);
627
- n([
628
- o(String)
629
- ], w.prototype, "arguments", 2);
630
- n([
631
- o(Number)
632
- ], w.prototype, "functionCallIndex", 2);
633
- w = n([
634
- d({ name: "StreamingFunctionCallUpdateContent" })
635
- ], w);
636
- var rt;
637
- let Dt = (rt = class extends C {
638
- constructor() {
639
- super(...arguments);
640
- e(this, "text");
641
- // Encoding is not explicitly serialized in C#
642
- // Not decorated with @jsonMember
643
- e(this, "encoding");
644
- }
645
- }, l(rt, "StreamingTextContent"), rt);
646
- n([
647
- o(String)
648
- ], Dt.prototype, "text", 2);
649
- Dt = n([
650
- d({ name: "StreamingTextContent" })
651
- ], Dt);
652
- var at;
653
- let Et = (at = class extends C {
654
- constructor() {
655
- super(...arguments);
656
- e(this, "text");
657
- // Encoding is not explicitly serialized in C#
658
- // Not decorated with @jsonMember
659
- e(this, "encoding");
660
- }
661
- }, l(at, "StreamingReasoningContent"), at);
662
- n([
663
- o(String)
664
- ], Et.prototype, "text", 2);
665
- Et = n([
666
- d({ name: "StreamingReasoningContent" })
667
- ], Et);
668
- var st;
669
- let _ = (st = class {
670
- constructor() {
671
- e(this, "instructionCategory", "");
672
- e(this, "description", "");
673
- e(this, "interactionId", "");
674
- }
675
- }, l(st, "InstructionSummary"), st);
676
- n([
677
- o(String)
678
- ], _.prototype, "instructionCategory", 2);
679
- n([
680
- o(String)
681
- ], _.prototype, "description", 2);
682
- n([
683
- o(String)
684
- ], _.prototype, "interactionId", 2);
685
- _ = n([
686
- d({ name: "InstructionSummary" })
687
- ], _);
688
- var pt;
689
- let E = (pt = class {
690
- constructor() {
691
- e(this, "size", 0);
692
- e(this, "originalSize", 0);
693
- e(this, "ratio", 0);
694
- e(this, "previousRatio", 0);
695
- e(this, "threshold", 0);
696
- e(this, "maxSize", 0);
697
- e(this, "id");
698
- e(this, "instructionSummaries", []);
699
- }
700
- }, l(pt, "SessionInformation"), pt);
701
- n([
702
- o(Number)
703
- ], E.prototype, "size", 2);
704
- n([
705
- o(Number)
706
- ], E.prototype, "originalSize", 2);
707
- n([
708
- o(Number)
709
- ], E.prototype, "ratio", 2);
710
- n([
711
- o(Number)
712
- ], E.prototype, "previousRatio", 2);
713
- n([
714
- o(Number)
715
- ], E.prototype, "threshold", 2);
716
- n([
717
- o(Number)
718
- ], E.prototype, "maxSize", 2);
719
- n([
720
- o(String)
721
- ], E.prototype, "id", 2);
722
- n([
723
- St(_)
724
- ], E.prototype, "instructionSummaries", 2);
725
- E = n([
726
- d({ name: "SessionInformation" })
727
- ], E);
728
- var lt;
729
- let S = (lt = class {
730
- constructor() {
731
- e(this, "timestamp");
732
- e(this, "mimeType");
733
- e(this, "partial");
734
- e(this, "turnComplete");
735
- e(this, "visible");
736
- e(this, "serverError");
737
- e(this, "interactionId");
738
- e(this, "sessionInformation");
739
- e(this, "eventType");
740
- e(this, "artifactsGenerated", []);
741
- e(this, "author");
742
- e(this, "role");
743
- e(this, "command");
744
- e(this, "content");
745
- e(this, "streamingParts");
746
- e(this, "subAgentId");
747
- e(this, "subAgentName");
748
- e(this, "text");
749
- }
750
- }, l(lt, "LlmEvent"), lt);
751
- n([
752
- o(Number)
753
- ], S.prototype, "timestamp", 2);
754
- n([
755
- o(String)
756
- ], S.prototype, "mimeType", 2);
757
- n([
758
- o(Boolean)
759
- ], S.prototype, "partial", 2);
760
- n([
761
- o(Boolean)
762
- ], S.prototype, "turnComplete", 2);
763
- n([
764
- o(Boolean)
765
- ], S.prototype, "visible", 2);
766
- n([
767
- o(String)
768
- ], S.prototype, "serverError", 2);
769
- n([
770
- o(String)
771
- ], S.prototype, "interactionId", 2);
772
- n([
773
- o(E)
774
- ], S.prototype, "sessionInformation", 2);
775
- n([
776
- o(gt)
777
- ], S.prototype, "eventType", 2);
778
- n([
779
- St(v)
780
- ], S.prototype, "artifactsGenerated", 2);
781
- n([
782
- o(String)
783
- ], S.prototype, "author", 2);
784
- n([
785
- o(xt)
786
- ], S.prototype, "role", 2);
787
- n([
788
- o(String)
789
- ], S.prototype, "command", 2);
790
- n([
791
- o(ft)
792
- ], S.prototype, "content", 2);
793
- n([
794
- St(() => C)
795
- ], S.prototype, "streamingParts", 2);
796
- S = n([
797
- d({ name: "LlmEvent" })
798
- ], S);
799
- var ut;
800
- let D = (ut = class {
801
- constructor() {
802
- e(this, "timeStamp");
803
- e(this, "partialText");
804
- e(this, "partialReasoning");
805
- e(this, "functionName");
806
- e(this, "streamingParts");
807
- e(this, "functionCallId");
808
- e(this, "type");
809
- e(this, "iteractionId");
810
- e(this, "partialEventType");
811
- e(this, "subAgentId");
812
- }
813
- }, l(ut, "PartialLlmEvent"), ut);
814
- n([
815
- o(Number, { name: "ts" })
816
- ], D.prototype, "timeStamp", 2);
817
- n([
818
- o(String, { name: "pt" })
819
- ], D.prototype, "partialText", 2);
820
- n([
821
- o(String, { name: "pr" })
822
- ], D.prototype, "partialReasoning", 2);
823
- n([
824
- o(String, { name: "fn" })
825
- ], D.prototype, "functionName", 2);
826
- n([
827
- St(() => C)
828
- ], D.prototype, "streamingParts", 2);
829
- n([
830
- o(String, { name: "fid" })
831
- ], D.prototype, "functionCallId", 2);
832
- n([
833
- o(String, { name: "tp" })
834
- ], D.prototype, "type", 2);
835
- n([
836
- o(String, { name: "itid" })
837
- ], D.prototype, "iteractionId", 2);
838
- n([
839
- o(gt)
840
- ], D.prototype, "partialEventType", 2);
841
- n([
842
- o(String, { name: "said" })
843
- ], D.prototype, "subAgentId", 2);
844
- D = n([
845
- d({ name: "PartialLlmEvent" })
846
- ], D);
847
- var ct;
848
- let F = (ct = class {
849
- constructor() {
850
- e(this, "type");
851
- e(this, "event");
852
- e(this, "sessionId");
853
- e(this, "accessToken");
854
- e(this, "partialEvent");
855
- e(this, "subAgentId");
856
- e(this, "subAgentName");
857
- e(this, "seq");
858
- }
859
- }, l(ct, "StreamingResponse"), ct);
860
- n([
861
- o(String)
862
- ], F.prototype, "type", 2);
863
- n([
864
- o(S)
865
- ], F.prototype, "event", 2);
866
- n([
867
- o(String)
868
- ], F.prototype, "sessionId", 2);
869
- n([
870
- o(String)
871
- ], F.prototype, "accessToken", 2);
872
- n([
873
- o(D, { name: "pe" })
874
- ], F.prototype, "partialEvent", 2);
875
- n([
876
- o(String)
877
- ], F.prototype, "subAgentId", 2);
878
- n([
879
- o(String)
880
- ], F.prototype, "subAgentName", 2);
881
- n([
882
- o(Number)
883
- ], F.prototype, "seq", 2);
884
- F = n([
885
- d({ name: "StreamingResponse" })
886
- ], F);
887
- var mt;
888
- let At = (mt = class {
889
- constructor() {
890
- e(this, "events");
891
- }
892
- }, l(mt, "Payload"), mt);
893
- n([
894
- St(S)
895
- ], At.prototype, "events", 2);
896
- At = n([
897
- d({ name: "Payload" })
898
- ], At);
899
- function Rt(s) {
900
- var a;
901
- const t = (s == null ? void 0 : s.presentation) ?? ((a = s == null ? void 0 : s.metadata) == null ? void 0 : a[Mt]);
902
- if (!t || typeof t != "object") return { isUi: !1 };
903
- const i = t, r = /* @__PURE__ */ l((p, c) => i[p] ?? i[c], "pick");
904
- return {
905
- isUi: r("isUi", "IsUi") === !0,
906
- askUserComponent: r("askUserComponent", "AskUserComponent") || void 0,
907
- argsDescription: r("argsDescription", "ArgsDescription") || void 0,
908
- // Runtime override on a RESULT: the UI tool chose not to render (CallContext.CancelUiRender).
909
- cancelUi: r("cancelUi", "CancelUi") === !0 || void 0,
910
- // Live signal on the PARK event: the tool is now waiting on a human, so the drawer may open.
911
- parked: r("parked", "Parked") === !0 || void 0
912
- };
913
- }
914
- l(Rt, "readPresentation");
915
- const A = class A {
916
- constructor(t) {
917
- e(this, "uniqueId");
918
- e(this, "mimeType");
919
- e(this, "created");
920
- e(this, "author");
921
- e(this, "eventType");
922
- e(this, "allEventTypes", []);
923
- e(this, "interactionId");
924
- e(this, "artifactsDelta", []);
925
- e(this, "llmArtifacts", []);
926
- e(this, "partial");
927
- e(this, "turn_complete");
928
- e(this, "isFinalResponse");
929
- e(this, "interrupted");
930
- e(this, "model_session_id");
931
- e(this, "functionDetails");
932
- e(this, "executableCodeDetails");
933
- e(this, "codeExecutionResultDetails");
934
- e(this, "thoughtDefails");
935
- e(this, "rawDetails");
936
- e(this, "rendered");
937
- e(this, "serverError");
938
- e(this, "server_session_id");
939
- e(this, "asyncFinalResponse");
940
- e(this, "agentServerBaseUrl");
941
- e(this, "parts", []);
942
- e(this, "endMessageData");
943
- e(this, "command");
944
- e(this, "session_information");
945
- e(this, "subAgentId");
946
- e(this, "subAgentName");
947
- e(this, "visible", !0);
948
- this.interactionId = t, this.author = "main";
949
- }
950
- static createErrorEvent(t, i) {
951
- const r = new A(i);
952
- r.turn_complete = !0, r.partial = !1, r.parts = [];
953
- const a = {
954
- eventType: m.ServerError,
955
- errorDetails: {
956
- errorMessage: t
957
- },
958
- id: "",
959
- author: "main",
960
- created: /* @__PURE__ */ new Date(),
961
- partial: !1,
962
- isStillWriting: !1,
963
- mustPush: !1,
964
- textAppendable: !1
965
- };
966
- return r.parts.push(a), r;
967
- }
968
- static parseFlatPropertiesTypedEvent(t) {
969
- var r, a, p;
970
- const i = new A(t.interactionId);
971
- if (i.serverError = t.serverError, !t.interactionId)
972
- throw new Error("Interaction ID is required");
973
- 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"', {
974
- interactionId: t.interactionId,
975
- turnComplete: t.turnComplete
976
- }), t == null ? void 0 : t.author) {
977
- case $t:
978
- i.author = "tool";
979
- break;
980
- case "system":
981
- i.author = "system";
982
- break;
983
- default:
984
- i.author = "main";
985
- }
986
- 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;
987
- }
988
- static getPartType(t) {
989
- return t instanceof ht ? "TextContent" : t instanceof U ? "FunctionCallContent" : t instanceof O ? "FunctionResultContent" : t instanceof w ? "StreamingFunctionCallUpdateContent" : t instanceof b ? "StreamingFinalFunctionCallContent" : t instanceof N ? "StreamingFinalFunctionResultContent" : t instanceof dt ? "FunctionClientOutputContent" : t instanceof z ? "StreamingClientOutputContent" : t instanceof yt ? "UserUiContent" : t instanceof Dt ? "StreamingTextContent" : t instanceof Et ? "StreamingReasoningContent" : t instanceof k ? "ToolEventContent" : t instanceof P ? "StreamingToolEventContent" : "Unknown";
990
- }
991
- static parseFromTypedEvent(t) {
992
- var p, c, g, J, Ut, bt, Ot;
993
- const i = A.parseFlatPropertiesTypedEvent(t);
994
- if (i.serverError)
995
- return i.parts.push(Nt.fromError(i.serverError)), i;
996
- if (!t.content && !t.streamingParts)
997
- return i;
998
- i.parts = [];
999
- const r = [...((p = t.content) == null ? void 0 : p.items) ?? [], ...t.streamingParts ?? []];
1000
- i.eventType = Gt(((c = t.eventType) == null ? void 0 : c.type) ?? "");
1001
- for (const f of r) {
1002
- let u = {
1003
- id: "",
1004
- author: i.author,
1005
- eventType: i.eventType,
1006
- created: /* @__PURE__ */ new Date(),
1007
- visible: i.visible,
1008
- partial: i.partial,
1009
- isStillWriting: !1,
1010
- mustPush: !1,
1011
- textAppendable: !1
1012
- };
1013
- const T = A.getPartType(f);
1014
- if (T == x.FunctionCallContent || T == x.FunctionResultContent || T == x.StreamingFinalFunctionCallContent || T == x.StreamingFinalFunctionResultContent) {
1015
- var a = f;
1016
- if (a.id == "Server Error")
1017
- u.eventType = m.ServerError, u.errorDetails = {
1018
- errorMessage: JSON.stringify(a.arguments)
1019
- }, u.functionDetails = void 0;
1020
- else {
1021
- u.eventType = T == x.FunctionCallContent || T == x.StreamingFinalFunctionCallContent ? m.FunctionCall : m.FunctionResponse;
1022
- let y;
1023
- try {
1024
- if (a != null && a.result)
1025
- if (typeof a.result == "object")
1026
- y = a.result;
1027
- else if (typeof a.result == "string") {
1028
- const Tt = JSON.parse(a.result);
1029
- y = typeof Tt == "object" && Tt !== null ? Tt : a.result;
1030
- } else
1031
- y = a.result;
1032
- } catch (Tt) {
1033
- console.warn("Parse function error", Tt), y = a == null ? void 0 : a.result;
1034
- }
1035
- u.thoughtDetails = {
1036
- text: ""
1037
- };
1038
- const Ft = Rt(a);
1039
- u.functionDetails = {
1040
- id: (a == null ? void 0 : a.id) ?? "",
1041
- args: a == null ? void 0 : a.arguments,
1042
- start: T == x.FunctionCallContent ? i.created : void 0,
1043
- end: T == x.FunctionResultContent ? i.created : void 0,
1044
- text: JSON.stringify(a == null ? void 0 : a.arguments) ?? "",
1045
- name: (a == null ? void 0 : a.functionName) ?? "",
1046
- status: u.eventType == m.FunctionCall ? "Executing" : "Done",
1047
- response: y,
1048
- isUi: Ft.isUi,
1049
- argsDescription: Ft.argsDescription,
1050
- // Client-only payload riding the RESULT event: live top-level `clientOutput`, or
1051
- // metadata.clientOutput on the collapsed/persisted result. Calls leave it undefined.
1052
- // The persisted-replay form also folds in via FunctionClientOutputContent.
1053
- clientOutput: (a == null ? void 0 : a.clientOutput) ?? ((g = a == null ? void 0 : a.metadata) == null ? void 0 : g.clientOutput),
1054
- askUserComponent: Ft.askUserComponent,
1055
- // Runtime "don't render" override on a RESULT (CallContext.CancelUiRender).
1056
- cancelUi: Ft.cancelUi
1057
- }, u.functionDetails.isAskUser = !!u.functionDetails.askUserComponent, t.text = a == null ? void 0 : a.arguments;
1058
- }
1059
- } else if (T == x.StreamingTextContent)
1060
- u.eventType = m.Text, u.text = (J = f == null ? void 0 : f.text) == null ? void 0 : J.replaceAll("\\n", `
1061
- `), u.textLastChunk = f.text, t.text = u.text;
1062
- else if (T == x.TextContent)
1063
- u.eventType = m.Text, u.text = (Ut = f == null ? void 0 : f.text) == null ? void 0 : Ut.replaceAll("\\n", `
1064
- `), u.textLastChunk = f.text, t.text = u.text;
1065
- else if (T == x.StreamingReasoningContent)
1066
- u.eventType = m.Thought, u.thoughtDetails = {
1067
- text: ((bt = f == null ? void 0 : f.text) == null ? void 0 : bt.replaceAll("\\n", `
1068
- `)) ?? ""
1069
- }, u.text = (Ot = f == null ? void 0 : f.text) == null ? void 0 : Ot.replaceAll("\\n", `
1070
- `), u.textLastChunk = f.text, t.text = u.text;
1071
- else if (T == x.StreamingFunctionCallUpdateContent) {
1072
- const y = f;
1073
- u.eventType = m.PartialFunctionCall, u.text = y.arguments, u.thoughtDetails = {
1074
- text: ""
1075
- }, u.functionDetails = {
1076
- id: y.callId ?? "",
1077
- text: u.text,
1078
- status: "Composing",
1079
- name: (y == null ? void 0 : y.name) ?? "Unknown"
1080
- }, t.text = u.text;
1081
- } else if (T == x.ToolEventContent || T == x.StreamingToolEventContent) {
1082
- u.eventType = m.ToolEvent;
1083
- const y = f;
1084
- u.toolDetails = {
1085
- eventName: y.eventName ?? "",
1086
- eventData: y.eventData ?? "",
1087
- sessionId: y.sessionId ?? void 0
1088
- };
1089
- } else if (T == x.FunctionClientOutputContent) {
1090
- const y = f;
1091
- u.eventType = m.FunctionClientOutput, u.functionDetails = {
1092
- id: y.id ?? "",
1093
- name: "",
1094
- status: "Done",
1095
- clientOutput: y.data
1096
- };
1097
- } else if (T == x.StreamingClientOutputContent) {
1098
- const y = f;
1099
- u.eventType = m.FunctionClientOutput, u.functionDetails = {
1100
- id: y.id ?? "",
1101
- name: "",
1102
- // The parked call stays Executing; interactionService folds only clientOutput onto it and
1103
- // leaves the existing status untouched, so this is just to satisfy the type.
1104
- status: "Executing",
1105
- clientOutput: y.clientOutput,
1106
- // The park signal itself (the reason this event fires even with no prefill).
1107
- parked: Rt(y).parked
1108
- };
1109
- } else if (T == x.UserUiContent) {
1110
- const y = f;
1111
- u.eventType = m.UserAnswer, u.author = "user", u.functionDetails = {
1112
- id: "",
1113
- name: y.name ?? "",
1114
- args: y.args,
1115
- status: "Done",
1116
- isUi: !0
1117
- };
1118
- } else {
1119
- u.eventType = m.NotDefined, console.warn(`Got a unmapped event_type:${i.eventType}, data:`, T, f);
1120
- continue;
1121
- }
1122
- i.parts.push(u);
1123
- }
1124
- return i;
1125
- }
1126
- static createFromThought(t, i) {
1127
- return {
1128
- author: "main",
1129
- visible: !0,
1130
- eventType: m.Thought,
1131
- uniqueId: (/* @__PURE__ */ new Date()).getTime().toString(),
1132
- interactionId: t,
1133
- allEventTypes: [m.Thought],
1134
- artifactsDelta: [""],
1135
- model_session_id: "",
1136
- created: /* @__PURE__ */ new Date(),
1137
- turn_complete: !1,
1138
- partial: !0,
1139
- asyncFinalResponse: !1,
1140
- mimeType: "text/plain",
1141
- parts: [
1142
- {
1143
- thoughtDetails: {
1144
- text: i
1145
- },
1146
- id: It(),
1147
- created: /* @__PURE__ */ new Date(),
1148
- eventType: m.Thought,
1149
- author: "main",
1150
- isStillWriting: !1,
1151
- textAppendable: !0,
1152
- partial: !0,
1153
- mustPush: !0
1154
- }
1155
- ]
1156
- };
1157
- }
1158
- static createFromFunctionName(t, i, r) {
1159
- const a = A.createFromText("", i);
1160
- 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 = {
1161
- name: t,
1162
- id: "callId",
1163
- status: "Executing",
1164
- start: /* @__PURE__ */ new Date(),
1165
- end: void 0,
1166
- text: "dfsdfdf",
1167
- args: r
1168
- }, a;
1169
- }
1170
- static createFromText(t, i, r) {
1171
- return {
1172
- author: "main",
1173
- visible: !0,
1174
- eventType: m.Text,
1175
- uniqueId: (/* @__PURE__ */ new Date()).getTime().toString(),
1176
- interactionId: i,
1177
- allEventTypes: [m.Text],
1178
- artifactsDelta: [""],
1179
- model_session_id: "",
1180
- created: /* @__PURE__ */ new Date(),
1181
- turn_complete: !1,
1182
- partial: !0,
1183
- asyncFinalResponse: !1,
1184
- mimeType: "text/plain",
1185
- parts: [
1186
- {
1187
- // Optional reasoning trace shown next to the message. Parts
1188
- // with `eventType: Text` AND a populated `thoughtDetails`
1189
- // render the text in the body and the trace in the
1190
- // thinking strip.
1191
- thoughtDetails: r ? {
1192
- text: r
1193
- } : void 0,
1194
- id: It(),
1195
- created: /* @__PURE__ */ new Date(),
1196
- // Part eventType MUST match the outer event's eventType.
1197
- // Was previously `Thought` here, which made the merger
1198
- // classify a streamed Text part as a Thought (rendered
1199
- // in the trace strip instead of the message body) —
1200
- // the chat would show the message during streaming and
1201
- // then "disappear" once the part was reclassified.
1202
- eventType: m.Text,
1203
- author: "main",
1204
- isStillWriting: !1,
1205
- textAppendable: !0,
1206
- partial: !0,
1207
- mustPush: !0,
1208
- text: t
1209
- }
1210
- ]
1211
- };
1212
- }
1213
- };
1214
- l(A, "ServerEvent");
1215
- let vt = A;
1216
- const kt = [
1217
- // KernelContent derived types
1218
- ht,
1219
- Ct,
1220
- U,
1221
- k,
1222
- O,
1223
- dt,
1224
- yt,
1225
- ft,
1226
- // StreamingKernelContent derived types
1227
- Dt,
1228
- w,
1229
- Et,
1230
- P,
1231
- b,
1232
- N,
1233
- z,
1234
- _
1235
- ];
1236
- function Kt(s) {
1237
- return s.name;
1238
- }
1239
- l(Kt, "getConstructorName");
1240
- function zt(s, t, i, r) {
1241
- t.constructor !== i && (s.$type = (r == null ? void 0 : r.name) ?? Kt(t.constructor));
1242
- }
1243
- l(zt, "dotNetTypeEmitter");
1244
- function _t(s, t) {
1245
- if (s.$type != null)
1246
- return t.get(s.$type);
1247
- }
1248
- l(_t, "dotnetTypeResolver");
1249
- function Lt() {
1250
- const s = new Pt(S);
1251
- return s.config({
1252
- knownTypes: kt,
1253
- typeHintEmitter: zt,
1254
- typeResolver: _t
1255
- }), s;
1256
- }
1257
- l(Lt, "createEventSerializer");
1258
- function Ht() {
1259
- const s = new Pt(F);
1260
- return s.config({
1261
- knownTypes: kt,
1262
- typeHintEmitter: zt,
1263
- typeResolver: _t
1264
- }), s;
1265
- }
1266
- l(Ht, "createStreamingResponseSerializer");
1267
- function Jt(s) {
1268
- try {
1269
- return JSON.parse(s), s;
1270
- } catch {
1271
- let i = "", r = !1;
1272
- for (let a = 0; a < s.length; a++) {
1273
- const p = s[a], c = p.charCodeAt(0);
1274
- if (p === "\\" && r && a + 1 < s.length) {
1275
- const g = s[a + 1];
1276
- if (g === '"' || g === "\\" || g === "/" || g === "b" || g === "f" || g === "n" || g === "r" || g === "t") {
1277
- i += p + g, a++;
1278
- continue;
1279
- } else if (g === "u" && a + 5 < s.length) {
1280
- i += s.substring(a, a + 6), a += 5;
1281
- continue;
1282
- } else {
1283
- i += p;
1284
- continue;
1285
- }
1286
- }
1287
- if (p === '"') {
1288
- let g = 0;
1289
- for (let J = a - 1; J >= 0 && s[J] === "\\"; J--)
1290
- g++;
1291
- g % 2 === 0 && (r = !r), i += p;
1292
- continue;
1293
- }
1294
- if (r && c < 32)
1295
- switch (p) {
1296
- case `
1297
- `:
1298
- i += "\\n";
1299
- break;
1300
- case "\r":
1301
- i += "\\r";
1302
- break;
1303
- case " ":
1304
- i += "\\t";
1305
- break;
1306
- case "\f":
1307
- i += "\\f";
1308
- break;
1309
- case "\b":
1310
- i += "\\b";
1311
- break;
1312
- default:
1313
- const g = c.toString(16).padStart(4, "0");
1314
- i += `\\u${g}`;
1315
- break;
1316
- }
1317
- else
1318
- i += p;
1319
- }
1320
- return i;
1321
- }
1322
- }
1323
- l(Jt, "sanitizeJsonString");
1324
- function Xt(s) {
1325
- const t = Jt(s);
1326
- return Ht().parse(t);
1327
- }
1328
- l(Xt, "deserializePayload");
1329
- function Zt(s) {
1330
- const t = Jt(s);
1331
- return Lt().parse(t);
1332
- }
1333
- l(Zt, "deserializeEvent");
1334
- function jt(s) {
1335
- return Lt().stringify(s);
1336
- }
1337
- l(jt, "serializeEvent");
1338
- export {
1339
- ft as C,
1340
- U as F,
1341
- Nt as I,
1342
- S as L,
1343
- x as P,
1344
- vt as S,
1345
- ht as T,
1346
- O as a,
1347
- w as b,
1348
- Et as c,
1349
- F as d,
1350
- Dt as e,
1351
- Lt as f,
1352
- Ht as g,
1353
- Zt as h,
1354
- Xt as i,
1355
- jt as j,
1356
- Jt as s
1357
- };
1358
- //# sourceMappingURL=serializer-DNt8QqNO.js.map