@aintela/chat 0.2.59 → 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 (85) 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 +4239 -4165
  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-CpbRpTHb.js → httpArtifactService-kXjuQtGa.js} +518 -643
  14. package/dist/httpArtifactService-kXjuQtGa.js.map +1 -0
  15. package/dist/{httpSessionService-BEQMIKfv.js → httpSessionService-CMT6k-Nu.js} +2 -3
  16. package/dist/{httpSessionService-BEQMIKfv.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/ThoughtRun.d.ts +28 -0
  27. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRunContext.d.ts +18 -0
  28. package/dist/src/components/AiChat/ChatPane/parts/index.d.ts +5 -1
  29. package/dist/src/components/AiChat/ChatPane/parts/thoughtRun.test.d.ts +1 -0
  30. package/dist/src/components/AiChat/aiChatEngine.d.ts +24 -5
  31. package/dist/src/components/AiChat/sessionStateManagerService.bind.test.d.ts +1 -0
  32. package/dist/src/components/AiChat/sessionStateManagerService.d.ts +22 -10
  33. package/dist/src/components/AiChat/useAgentEngine.d.ts +69 -0
  34. package/dist/src/components/AiChat/useAgentEngine.test.d.ts +1 -0
  35. package/dist/src/components/index.d.ts +4 -4
  36. package/dist/src/hooks/index.d.ts +1 -1
  37. package/dist/src/hooks/useContainerWidth.d.ts +0 -1
  38. package/dist/src/models/ArtifactData.d.ts +0 -7
  39. package/dist/src/models/ChatSession.d.ts +0 -32
  40. package/dist/src/models/ClientMessage.d.ts +0 -4
  41. package/dist/src/models/ServerEvent.d.ts +0 -36
  42. package/dist/src/models/enums.d.ts +0 -1
  43. package/dist/src/models/index.d.ts +1 -2
  44. package/dist/src/models/interactionPartUtils.test.d.ts +1 -0
  45. package/dist/src/models/semanticKernelModel/sanitizeJsonString.test.d.ts +0 -0
  46. package/dist/src/models/serverEventDecode.test.d.ts +0 -0
  47. package/dist/src/services/WebSocketConnection/webSocketConnectionV2.reconnect.test.d.ts +0 -0
  48. package/dist/src/services/interactionService.d.ts +11 -0
  49. package/dist/src/services/interactionServiceGrouping.test.d.ts +1 -0
  50. package/dist/src/services/servers/AgentGatewayService.d.ts +25 -18
  51. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +0 -1
  52. package/dist/src/services/servers/agentGatewayAgentContext.test.d.ts +1 -0
  53. package/dist/src/services/storageService.d.ts +16 -59
  54. package/dist/src/services/storageService.test.d.ts +1 -0
  55. package/dist/src/utils/index.d.ts +2 -6
  56. package/dist/src/utils/urlParser.d.ts +0 -1
  57. package/dist/tests/fakes/fakeRawWebSocket.d.ts +51 -0
  58. package/dist/tests/fakes/fakeStorage.d.ts +7 -0
  59. package/dist/tests/fakes/makeGateway.d.ts +24 -1
  60. package/dist/{useChatSessions-BQP7DhY1.js → useChatSessions-CpHq0e1n.js} +2 -2
  61. package/dist/{useChatSessions-BQP7DhY1.js.map → useChatSessions-CpHq0e1n.js.map} +1 -1
  62. package/dist/useContainerWidth-B40_i-NW.js +295 -0
  63. package/dist/{useContainerWidth-B3t1ZTlo.js.map → useContainerWidth-B40_i-NW.js.map} +1 -1
  64. package/dist/utils.js +340 -57
  65. package/dist/utils.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/Memory-DjLZqgbF.js +0 -84
  68. package/dist/Memory-DjLZqgbF.js.map +0 -1
  69. package/dist/atMentions-C0dza8DD.js +0 -1000
  70. package/dist/atMentions-C0dza8DD.js.map +0 -1
  71. package/dist/auth-lluJZyQO.js +0 -524
  72. package/dist/auth-lluJZyQO.js.map +0 -1
  73. package/dist/environmentUtils-CUVZ6Dq1.js +0 -478
  74. package/dist/environmentUtils-CUVZ6Dq1.js.map +0 -1
  75. package/dist/httpArtifactService-CpbRpTHb.js.map +0 -1
  76. package/dist/serializer-BXSH9aYQ.js +0 -1360
  77. package/dist/serializer-BXSH9aYQ.js.map +0 -1
  78. package/dist/src/components/AiChat/useLiveSession.d.ts +0 -52
  79. package/dist/src/utils/jsonDetector.d.ts +0 -50
  80. package/dist/src/utils/jsonUtils.d.ts +0 -1
  81. package/dist/src/utils/materialIconsSvg.d.ts +0 -51
  82. package/dist/src/utils/objectUtils.d.ts +0 -31
  83. package/dist/src/utils/parseArtifact.d.ts +0 -3
  84. package/dist/src/utils/uriUtils.d.ts +0 -39
  85. package/dist/useContainerWidth-B3t1ZTlo.js +0 -309
@@ -1,1360 +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 y, AnyT as L, jsonArrayMember as Tt, TypedJSON as vt } 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 d = (c == null ? void 0 : c.toString().indexOf(`
28
- `)) > -1 ? `
29
- ` : "";
30
- a.push(`${p}:${d}${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, d = p.functionDetails;
159
- !c.askUserComponent && d.askUserComponent && (c.askUserComponent = d.askUserComponent), !c.isUi && d.isUi && (c.isUi = !0), !c.clientOutput && d.clientOutput && (c.clientOutput = d.clientOutput), c.isAskUser = c.isAskUser || d.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 $;
214
- let ht = ($ = class {
215
- constructor() {
216
- e(this, "label");
217
- }
218
- }, l($, "AuthorRole"), $);
219
- n([
220
- o(String)
221
- ], ht.prototype, "label", 2);
222
- ht = n([
223
- y({ name: "AuthorRole" })
224
- ], ht);
225
- var G;
226
- let dt = (G = class {
227
- constructor() {
228
- e(this, "type");
229
- e(this, "fullName");
230
- }
231
- }, l(G, "EventTypeInformation"), G);
232
- n([
233
- o(String)
234
- ], dt.prototype, "type", 2);
235
- n([
236
- o(String)
237
- ], dt.prototype, "fullName", 2);
238
- dt = n([
239
- y({ name: "EventTypeInformation" })
240
- ], dt);
241
- var q;
242
- let k = (q = 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(q, "LlmArtifact"), q);
260
- n([
261
- o(String)
262
- ], k.prototype, "id", 2);
263
- n([
264
- o(String)
265
- ], k.prototype, "name", 2);
266
- n([
267
- o(String)
268
- ], k.prototype, "mimeType", 2);
269
- n([
270
- o(String)
271
- ], k.prototype, "description", 2);
272
- k = n([
273
- y({ name: "LlmArtifact" })
274
- ], k);
275
- var B;
276
- let h = (B = 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(B, "KernelContent"), B);
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
- y({ name: "KernelContent" })
297
- ], h);
298
- var M;
299
- let C = (M = 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(M, "StreamingKernelContent"), M);
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
- y({ name: "StreamingKernelContent" })
320
- ], C);
321
- var K;
322
- let Ct = (K = 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(K, "TextContent"), K);
335
- n([
336
- o(String)
337
- ], Ct.prototype, "text", 2);
338
- Ct = n([
339
- y({ name: "TextContent" })
340
- ], Ct);
341
- var H;
342
- let v = (H = class extends C {
343
- constructor() {
344
- super();
345
- e(this, "eventName");
346
- e(this, "eventData");
347
- e(this, "sessionId");
348
- }
349
- }, l(H, "StreamingToolEventContent"), H);
350
- n([
351
- o(String)
352
- ], v.prototype, "eventName", 2);
353
- n([
354
- o(String)
355
- ], v.prototype, "eventData", 2);
356
- n([
357
- o(String)
358
- ], v.prototype, "sessionId", 2);
359
- v = n([
360
- y({ name: "StreamingToolEventContent" })
361
- ], v);
362
- var Y;
363
- let P = (Y = class extends h {
364
- constructor() {
365
- super();
366
- e(this, "eventName");
367
- e(this, "eventData");
368
- e(this, "sessionId");
369
- }
370
- }, l(Y, "ToolEventContent"), Y);
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
- y({ name: "ToolEventContent" })
382
- ], P);
383
- var Q;
384
- let Dt = (Q = class extends h {
385
- constructor() {
386
- super(...arguments);
387
- e(this, "url");
388
- e(this, "dataUri");
389
- }
390
- }, l(Q, "ImageContent"), Q);
391
- n([
392
- o(String)
393
- ], Dt.prototype, "url", 2);
394
- n([
395
- o(String)
396
- ], Dt.prototype, "dataUri", 2);
397
- Dt = n([
398
- y({ name: "ImageContent" })
399
- ], Dt);
400
- var V;
401
- let U = (V = 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(V, "FunctionCallContent"), V);
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
- y({ name: "FunctionCallContent" })
426
- ], U);
427
- var X;
428
- let I = (X = 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(X, "ToolCallPresentation"), X);
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
- y({ name: "ToolCallPresentation" })
454
- ], I);
455
- const Mt = "aia:presentation";
456
- var Z;
457
- let b = (Z = 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(Z, "StreamingFinalFunctionCallContent"), Z);
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
- y({ name: "StreamingFinalFunctionCallContent" })
480
- ], b);
481
- var j;
482
- let O = (j = 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(j, "FunctionResultContent"), j);
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
- y({ name: "FunctionResultContent" })
505
- ], O);
506
- var tt;
507
- let N = (tt = 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(tt, "StreamingFinalFunctionResultContent"), tt);
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
- y({ name: "StreamingFinalFunctionResultContent" })
538
- ], N);
539
- var et;
540
- let yt = (et = class extends h {
541
- constructor() {
542
- super(...arguments);
543
- e(this, "id");
544
- e(this, "data");
545
- }
546
- }, l(et, "FunctionClientOutputContent"), et);
547
- n([
548
- o(String, { name: "callId" })
549
- ], yt.prototype, "id", 2);
550
- n([
551
- o(L)
552
- ], yt.prototype, "data", 2);
553
- yt = n([
554
- y({ name: "FunctionClientOutputContent" })
555
- ], yt);
556
- var nt;
557
- let z = (nt = class extends C {
558
- constructor() {
559
- super(...arguments);
560
- e(this, "id");
561
- e(this, "clientOutput");
562
- e(this, "presentation");
563
- }
564
- }, l(nt, "StreamingClientOutputContent"), nt);
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
- y({ name: "StreamingClientOutputContent" })
576
- ], z);
577
- var it;
578
- let ft = (it = class extends h {
579
- constructor() {
580
- super(...arguments);
581
- e(this, "name");
582
- e(this, "args");
583
- }
584
- }, l(it, "UserUiContent"), it);
585
- n([
586
- o(String)
587
- ], ft.prototype, "name", 2);
588
- n([
589
- o(String)
590
- ], ft.prototype, "args", 2);
591
- ft = n([
592
- y({ name: "UserUiContent" })
593
- ], ft);
594
- var ot;
595
- let St = (ot = class extends h {
596
- constructor() {
597
- super(...arguments);
598
- e(this, "role");
599
- e(this, "items");
600
- }
601
- }, l(ot, "ChatMessageContent"), ot);
602
- n([
603
- o(ht)
604
- ], St.prototype, "role", 2);
605
- n([
606
- Tt(() => h)
607
- ], St.prototype, "items", 2);
608
- St = n([
609
- y({ name: "ChatMessageContent" })
610
- ], St);
611
- var rt;
612
- let w = (rt = 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(rt, "StreamingFunctionCallUpdateContent"), rt);
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
- y({ name: "StreamingFunctionCallUpdateContent" })
635
- ], w);
636
- var at;
637
- let Et = (at = 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(at, "StreamingTextContent"), at);
646
- n([
647
- o(String)
648
- ], Et.prototype, "text", 2);
649
- Et = n([
650
- y({ name: "StreamingTextContent" })
651
- ], Et);
652
- var st;
653
- let Ft = (st = 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(st, "StreamingReasoningContent"), st);
662
- n([
663
- o(String)
664
- ], Ft.prototype, "text", 2);
665
- Ft = n([
666
- y({ name: "StreamingReasoningContent" })
667
- ], Ft);
668
- var pt;
669
- let _ = (pt = class {
670
- constructor() {
671
- e(this, "instructionCategory", "");
672
- e(this, "description", "");
673
- e(this, "interactionId", "");
674
- }
675
- }, l(pt, "InstructionSummary"), pt);
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
- y({ name: "InstructionSummary" })
687
- ], _);
688
- var lt;
689
- let E = (lt = 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(lt, "SessionInformation"), lt);
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
- Tt(_)
724
- ], E.prototype, "instructionSummaries", 2);
725
- E = n([
726
- y({ name: "SessionInformation" })
727
- ], E);
728
- var ut;
729
- let S = (ut = 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(ut, "LlmEvent"), ut);
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(dt)
777
- ], S.prototype, "eventType", 2);
778
- n([
779
- Tt(k)
780
- ], S.prototype, "artifactsGenerated", 2);
781
- n([
782
- o(String)
783
- ], S.prototype, "author", 2);
784
- n([
785
- o(ht)
786
- ], S.prototype, "role", 2);
787
- n([
788
- o(String)
789
- ], S.prototype, "command", 2);
790
- n([
791
- o(St)
792
- ], S.prototype, "content", 2);
793
- n([
794
- Tt(() => C)
795
- ], S.prototype, "streamingParts", 2);
796
- S = n([
797
- y({ name: "LlmEvent" })
798
- ], S);
799
- var ct;
800
- let D = (ct = 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(ct, "PartialLlmEvent"), ct);
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
- Tt(() => 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(dt)
840
- ], D.prototype, "partialEventType", 2);
841
- n([
842
- o(String, { name: "said" })
843
- ], D.prototype, "subAgentId", 2);
844
- D = n([
845
- y({ name: "PartialLlmEvent" })
846
- ], D);
847
- var mt;
848
- let F = (mt = 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(mt, "StreamingResponse"), mt);
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
- y({ name: "StreamingResponse" })
886
- ], F);
887
- var gt;
888
- let At = (gt = class {
889
- constructor() {
890
- e(this, "events");
891
- }
892
- }, l(gt, "Payload"), gt);
893
- n([
894
- Tt(S)
895
- ], At.prototype, "events", 2);
896
- At = n([
897
- y({ 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 Ct ? "TextContent" : t instanceof U ? "FunctionCallContent" : t instanceof O ? "FunctionResultContent" : t instanceof w ? "StreamingFunctionCallUpdateContent" : t instanceof b ? "StreamingFinalFunctionCallContent" : t instanceof N ? "StreamingFinalFunctionResultContent" : t instanceof yt ? "FunctionClientOutputContent" : t instanceof z ? "StreamingClientOutputContent" : t instanceof ft ? "UserUiContent" : t instanceof Et ? "StreamingTextContent" : t instanceof Ft ? "StreamingReasoningContent" : t instanceof P ? "ToolEventContent" : t instanceof v ? "StreamingToolEventContent" : "Unknown";
990
- }
991
- static parseFromTypedEvent(t) {
992
- var p, c, d, 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
- const g = a.arguments ?? {}, W = typeof g.error == "string" && g.error.trim().length > 0 ? g.error : JSON.stringify(a.arguments);
1018
- u.eventType = m.ServerError, u.errorDetails = {
1019
- errorMessage: W,
1020
- stackTrace: typeof g.stackTrace == "string" ? g.stackTrace : void 0
1021
- }, u.functionDetails = void 0;
1022
- } else {
1023
- u.eventType = T == x.FunctionCallContent || T == x.StreamingFinalFunctionCallContent ? m.FunctionCall : m.FunctionResponse;
1024
- let g;
1025
- try {
1026
- if (a != null && a.result)
1027
- if (typeof a.result == "object")
1028
- g = a.result;
1029
- else if (typeof a.result == "string") {
1030
- const xt = JSON.parse(a.result);
1031
- g = typeof xt == "object" && xt !== null ? xt : a.result;
1032
- } else
1033
- g = a.result;
1034
- } catch (xt) {
1035
- console.warn("Parse function error", xt), g = a == null ? void 0 : a.result;
1036
- }
1037
- u.thoughtDetails = {
1038
- text: ""
1039
- };
1040
- const W = Rt(a);
1041
- u.functionDetails = {
1042
- id: (a == null ? void 0 : a.id) ?? "",
1043
- args: a == null ? void 0 : a.arguments,
1044
- start: T == x.FunctionCallContent ? i.created : void 0,
1045
- end: T == x.FunctionResultContent ? i.created : void 0,
1046
- text: JSON.stringify(a == null ? void 0 : a.arguments) ?? "",
1047
- name: (a == null ? void 0 : a.functionName) ?? "",
1048
- status: u.eventType == m.FunctionCall ? "Executing" : "Done",
1049
- response: g,
1050
- isUi: W.isUi,
1051
- argsDescription: W.argsDescription,
1052
- // Client-only payload riding the RESULT event: live top-level `clientOutput`, or
1053
- // metadata.clientOutput on the collapsed/persisted result. Calls leave it undefined.
1054
- // The persisted-replay form also folds in via FunctionClientOutputContent.
1055
- clientOutput: (a == null ? void 0 : a.clientOutput) ?? ((d = a == null ? void 0 : a.metadata) == null ? void 0 : d.clientOutput),
1056
- askUserComponent: W.askUserComponent,
1057
- // Runtime "don't render" override on a RESULT (CallContext.CancelUiRender).
1058
- cancelUi: W.cancelUi
1059
- }, u.functionDetails.isAskUser = !!u.functionDetails.askUserComponent, t.text = a == null ? void 0 : a.arguments;
1060
- }
1061
- } else if (T == x.StreamingTextContent)
1062
- u.eventType = m.Text, u.text = (J = f == null ? void 0 : f.text) == null ? void 0 : J.replaceAll("\\n", `
1063
- `), u.textLastChunk = f.text, t.text = u.text;
1064
- else if (T == x.TextContent)
1065
- u.eventType = m.Text, u.text = (Ut = f == null ? void 0 : f.text) == null ? void 0 : Ut.replaceAll("\\n", `
1066
- `), u.textLastChunk = f.text, t.text = u.text;
1067
- else if (T == x.StreamingReasoningContent)
1068
- u.eventType = m.Thought, u.thoughtDetails = {
1069
- text: ((bt = f == null ? void 0 : f.text) == null ? void 0 : bt.replaceAll("\\n", `
1070
- `)) ?? ""
1071
- }, u.text = (Ot = f == null ? void 0 : f.text) == null ? void 0 : Ot.replaceAll("\\n", `
1072
- `), u.textLastChunk = f.text, t.text = u.text;
1073
- else if (T == x.StreamingFunctionCallUpdateContent) {
1074
- const g = f;
1075
- u.eventType = m.PartialFunctionCall, u.text = g.arguments, u.thoughtDetails = {
1076
- text: ""
1077
- }, u.functionDetails = {
1078
- id: g.callId ?? "",
1079
- text: u.text,
1080
- status: "Composing",
1081
- name: (g == null ? void 0 : g.name) ?? "Unknown"
1082
- }, t.text = u.text;
1083
- } else if (T == x.ToolEventContent || T == x.StreamingToolEventContent) {
1084
- u.eventType = m.ToolEvent;
1085
- const g = f;
1086
- u.toolDetails = {
1087
- eventName: g.eventName ?? "",
1088
- eventData: g.eventData ?? "",
1089
- sessionId: g.sessionId ?? void 0
1090
- };
1091
- } else if (T == x.FunctionClientOutputContent) {
1092
- const g = f;
1093
- u.eventType = m.FunctionClientOutput, u.functionDetails = {
1094
- id: g.id ?? "",
1095
- name: "",
1096
- status: "Done",
1097
- clientOutput: g.data
1098
- };
1099
- } else if (T == x.StreamingClientOutputContent) {
1100
- const g = f;
1101
- u.eventType = m.FunctionClientOutput, u.functionDetails = {
1102
- id: g.id ?? "",
1103
- name: "",
1104
- // The parked call stays Executing; interactionService folds only clientOutput onto it and
1105
- // leaves the existing status untouched, so this is just to satisfy the type.
1106
- status: "Executing",
1107
- clientOutput: g.clientOutput,
1108
- // The park signal itself (the reason this event fires even with no prefill).
1109
- parked: Rt(g).parked
1110
- };
1111
- } else if (T == x.UserUiContent) {
1112
- const g = f;
1113
- u.eventType = m.UserAnswer, u.author = "user", u.functionDetails = {
1114
- id: "",
1115
- name: g.name ?? "",
1116
- args: g.args,
1117
- status: "Done",
1118
- isUi: !0
1119
- };
1120
- } else {
1121
- u.eventType = m.NotDefined, console.warn(`Got a unmapped event_type:${i.eventType}, data:`, T, f);
1122
- continue;
1123
- }
1124
- i.parts.push(u);
1125
- }
1126
- return i;
1127
- }
1128
- static createFromThought(t, i) {
1129
- return {
1130
- author: "main",
1131
- visible: !0,
1132
- eventType: m.Thought,
1133
- uniqueId: (/* @__PURE__ */ new Date()).getTime().toString(),
1134
- interactionId: t,
1135
- allEventTypes: [m.Thought],
1136
- artifactsDelta: [""],
1137
- model_session_id: "",
1138
- created: /* @__PURE__ */ new Date(),
1139
- turn_complete: !1,
1140
- partial: !0,
1141
- asyncFinalResponse: !1,
1142
- mimeType: "text/plain",
1143
- parts: [
1144
- {
1145
- thoughtDetails: {
1146
- text: i
1147
- },
1148
- id: It(),
1149
- created: /* @__PURE__ */ new Date(),
1150
- eventType: m.Thought,
1151
- author: "main",
1152
- isStillWriting: !1,
1153
- textAppendable: !0,
1154
- partial: !0,
1155
- mustPush: !0
1156
- }
1157
- ]
1158
- };
1159
- }
1160
- static createFromFunctionName(t, i, r) {
1161
- const a = A.createFromText("", i);
1162
- 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 = {
1163
- name: t,
1164
- id: "callId",
1165
- status: "Executing",
1166
- start: /* @__PURE__ */ new Date(),
1167
- end: void 0,
1168
- text: "dfsdfdf",
1169
- args: r
1170
- }, a;
1171
- }
1172
- static createFromText(t, i, r) {
1173
- return {
1174
- author: "main",
1175
- visible: !0,
1176
- eventType: m.Text,
1177
- uniqueId: (/* @__PURE__ */ new Date()).getTime().toString(),
1178
- interactionId: i,
1179
- allEventTypes: [m.Text],
1180
- artifactsDelta: [""],
1181
- model_session_id: "",
1182
- created: /* @__PURE__ */ new Date(),
1183
- turn_complete: !1,
1184
- partial: !0,
1185
- asyncFinalResponse: !1,
1186
- mimeType: "text/plain",
1187
- parts: [
1188
- {
1189
- // Optional reasoning trace shown next to the message. Parts
1190
- // with `eventType: Text` AND a populated `thoughtDetails`
1191
- // render the text in the body and the trace in the
1192
- // thinking strip.
1193
- thoughtDetails: r ? {
1194
- text: r
1195
- } : void 0,
1196
- id: It(),
1197
- created: /* @__PURE__ */ new Date(),
1198
- // Part eventType MUST match the outer event's eventType.
1199
- // Was previously `Thought` here, which made the merger
1200
- // classify a streamed Text part as a Thought (rendered
1201
- // in the trace strip instead of the message body) —
1202
- // the chat would show the message during streaming and
1203
- // then "disappear" once the part was reclassified.
1204
- eventType: m.Text,
1205
- author: "main",
1206
- isStillWriting: !1,
1207
- textAppendable: !0,
1208
- partial: !0,
1209
- mustPush: !0,
1210
- text: t
1211
- }
1212
- ]
1213
- };
1214
- }
1215
- };
1216
- l(A, "ServerEvent");
1217
- let kt = A;
1218
- const Pt = [
1219
- // KernelContent derived types
1220
- Ct,
1221
- Dt,
1222
- U,
1223
- P,
1224
- O,
1225
- yt,
1226
- ft,
1227
- St,
1228
- // StreamingKernelContent derived types
1229
- Et,
1230
- w,
1231
- Ft,
1232
- v,
1233
- b,
1234
- N,
1235
- z,
1236
- _
1237
- ];
1238
- function Kt(s) {
1239
- return s.name;
1240
- }
1241
- l(Kt, "getConstructorName");
1242
- function zt(s, t, i, r) {
1243
- t.constructor !== i && (s.$type = (r == null ? void 0 : r.name) ?? Kt(t.constructor));
1244
- }
1245
- l(zt, "dotNetTypeEmitter");
1246
- function _t(s, t) {
1247
- if (s.$type != null)
1248
- return t.get(s.$type);
1249
- }
1250
- l(_t, "dotnetTypeResolver");
1251
- function Lt() {
1252
- const s = new vt(S);
1253
- return s.config({
1254
- knownTypes: Pt,
1255
- typeHintEmitter: zt,
1256
- typeResolver: _t
1257
- }), s;
1258
- }
1259
- l(Lt, "createEventSerializer");
1260
- function Ht() {
1261
- const s = new vt(F);
1262
- return s.config({
1263
- knownTypes: Pt,
1264
- typeHintEmitter: zt,
1265
- typeResolver: _t
1266
- }), s;
1267
- }
1268
- l(Ht, "createStreamingResponseSerializer");
1269
- function Jt(s) {
1270
- try {
1271
- return JSON.parse(s), s;
1272
- } catch {
1273
- let i = "", r = !1;
1274
- for (let a = 0; a < s.length; a++) {
1275
- const p = s[a], c = p.charCodeAt(0);
1276
- if (p === "\\" && r && a + 1 < s.length) {
1277
- const d = s[a + 1];
1278
- if (d === '"' || d === "\\" || d === "/" || d === "b" || d === "f" || d === "n" || d === "r" || d === "t") {
1279
- i += p + d, a++;
1280
- continue;
1281
- } else if (d === "u" && a + 5 < s.length) {
1282
- i += s.substring(a, a + 6), a += 5;
1283
- continue;
1284
- } else {
1285
- i += p;
1286
- continue;
1287
- }
1288
- }
1289
- if (p === '"') {
1290
- let d = 0;
1291
- for (let J = a - 1; J >= 0 && s[J] === "\\"; J--)
1292
- d++;
1293
- d % 2 === 0 && (r = !r), i += p;
1294
- continue;
1295
- }
1296
- if (r && c < 32)
1297
- switch (p) {
1298
- case `
1299
- `:
1300
- i += "\\n";
1301
- break;
1302
- case "\r":
1303
- i += "\\r";
1304
- break;
1305
- case " ":
1306
- i += "\\t";
1307
- break;
1308
- case "\f":
1309
- i += "\\f";
1310
- break;
1311
- case "\b":
1312
- i += "\\b";
1313
- break;
1314
- default:
1315
- const d = c.toString(16).padStart(4, "0");
1316
- i += `\\u${d}`;
1317
- break;
1318
- }
1319
- else
1320
- i += p;
1321
- }
1322
- return i;
1323
- }
1324
- }
1325
- l(Jt, "sanitizeJsonString");
1326
- function Xt(s) {
1327
- const t = Jt(s);
1328
- return Ht().parse(t);
1329
- }
1330
- l(Xt, "deserializePayload");
1331
- function Zt(s) {
1332
- const t = Jt(s);
1333
- return Lt().parse(t);
1334
- }
1335
- l(Zt, "deserializeEvent");
1336
- function jt(s) {
1337
- return Lt().stringify(s);
1338
- }
1339
- l(jt, "serializeEvent");
1340
- export {
1341
- St as C,
1342
- U as F,
1343
- Nt as I,
1344
- S as L,
1345
- x as P,
1346
- kt as S,
1347
- Ct as T,
1348
- O as a,
1349
- w as b,
1350
- Ft as c,
1351
- F as d,
1352
- Et as e,
1353
- Lt as f,
1354
- Ht as g,
1355
- Zt as h,
1356
- Xt as i,
1357
- jt as j,
1358
- Jt as s
1359
- };
1360
- //# sourceMappingURL=serializer-BXSH9aYQ.js.map