@aintela/chat 0.2.15

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