@aintela/chat 0.2.58 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +63 -0
  2. package/dist/{ClientMessage-EKgfuTp8.js → ClientMessage-DUby3KyC.js} +16 -22
  3. package/dist/{ClientMessage-EKgfuTp8.js.map → ClientMessage-DUby3KyC.js.map} +1 -1
  4. package/dist/Memory-CjrYSkzB.js +47 -0
  5. package/dist/Memory-CjrYSkzB.js.map +1 -0
  6. package/dist/atMentions-CCNBOf5W.js +954 -0
  7. package/dist/atMentions-CCNBOf5W.js.map +1 -0
  8. package/dist/components.js +5291 -5145
  9. package/dist/components.js.map +1 -1
  10. package/dist/environmentUtils-VZNTCzEE.js +88 -0
  11. package/dist/environmentUtils-VZNTCzEE.js.map +1 -0
  12. package/dist/hooks.js +4 -5
  13. package/dist/{httpArtifactService-JtkC1T7n.js → httpArtifactService-kXjuQtGa.js} +518 -643
  14. package/dist/httpArtifactService-kXjuQtGa.js.map +1 -0
  15. package/dist/{httpSessionService-BDlqebW2.js → httpSessionService-CMT6k-Nu.js} +2 -3
  16. package/dist/{httpSessionService-BDlqebW2.js.map → httpSessionService-CMT6k-Nu.js.map} +1 -1
  17. package/dist/index.js +243 -258
  18. package/dist/models.js +48 -51
  19. package/dist/models.js.map +1 -1
  20. package/dist/serializer-D2W42bdT.js +1730 -0
  21. package/dist/serializer-D2W42bdT.js.map +1 -0
  22. package/dist/services.js +2 -2
  23. package/dist/src/components/AiChat/AiChatProvider.agent.test.d.ts +1 -0
  24. package/dist/src/components/AiChat/AiChatProvider.d.ts +2 -2
  25. package/dist/src/components/AiChat/AiChatTypes.d.ts +45 -16
  26. package/dist/src/components/AiChat/ChatPane/parts/ServerErrorPart.d.ts +19 -0
  27. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRun.d.ts +28 -0
  28. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRunContext.d.ts +18 -0
  29. package/dist/src/components/AiChat/ChatPane/parts/index.d.ts +13 -4
  30. package/dist/src/components/AiChat/ChatPane/parts/thoughtRun.test.d.ts +1 -0
  31. package/dist/src/components/AiChat/ChatPane/parts/types.d.ts +1 -1
  32. package/dist/src/components/AiChat/aiChatEngine.d.ts +24 -5
  33. package/dist/src/components/AiChat/sessionStateManagerService.bind.test.d.ts +1 -0
  34. package/dist/src/components/AiChat/sessionStateManagerService.d.ts +22 -10
  35. package/dist/src/components/AiChat/useAgentEngine.d.ts +69 -0
  36. package/dist/src/components/AiChat/useAgentEngine.test.d.ts +1 -0
  37. package/dist/src/components/index.d.ts +4 -4
  38. package/dist/src/hooks/index.d.ts +1 -1
  39. package/dist/src/hooks/useContainerWidth.d.ts +0 -1
  40. package/dist/src/models/ArtifactData.d.ts +0 -7
  41. package/dist/src/models/ChatSession.d.ts +0 -32
  42. package/dist/src/models/ClientMessage.d.ts +0 -4
  43. package/dist/src/models/ServerEvent.d.ts +7 -36
  44. package/dist/src/models/enums.d.ts +0 -1
  45. package/dist/src/models/index.d.ts +1 -2
  46. package/dist/src/models/interactionPartUtils.test.d.ts +1 -0
  47. package/dist/src/models/semanticKernelModel/sanitizeJsonString.test.d.ts +0 -0
  48. package/dist/src/models/serverEventDecode.test.d.ts +0 -0
  49. package/dist/src/services/WebSocketConnection/webSocketConnectionV2.reconnect.test.d.ts +0 -0
  50. package/dist/src/services/interactionService.d.ts +11 -0
  51. package/dist/src/services/interactionServiceGrouping.test.d.ts +1 -0
  52. package/dist/src/services/servers/AgentGatewayService.d.ts +25 -18
  53. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +0 -1
  54. package/dist/src/services/servers/agentGatewayAgentContext.test.d.ts +1 -0
  55. package/dist/src/services/storageService.d.ts +16 -59
  56. package/dist/src/services/storageService.test.d.ts +1 -0
  57. package/dist/src/utils/index.d.ts +2 -6
  58. package/dist/src/utils/urlParser.d.ts +0 -1
  59. package/dist/tests/fakes/fakeRawWebSocket.d.ts +51 -0
  60. package/dist/tests/fakes/fakeStorage.d.ts +7 -0
  61. package/dist/tests/fakes/makeGateway.d.ts +24 -1
  62. package/dist/{useChatSessions-sbBneRk9.js → useChatSessions-CpHq0e1n.js} +2 -2
  63. package/dist/{useChatSessions-sbBneRk9.js.map → useChatSessions-CpHq0e1n.js.map} +1 -1
  64. package/dist/useContainerWidth-B40_i-NW.js +295 -0
  65. package/dist/{useContainerWidth-B3t1ZTlo.js.map → useContainerWidth-B40_i-NW.js.map} +1 -1
  66. package/dist/utils.js +340 -57
  67. package/dist/utils.js.map +1 -1
  68. package/package.json +1 -1
  69. package/dist/Memory-DjLZqgbF.js +0 -84
  70. package/dist/Memory-DjLZqgbF.js.map +0 -1
  71. package/dist/atMentions-C0dza8DD.js +0 -1000
  72. package/dist/atMentions-C0dza8DD.js.map +0 -1
  73. package/dist/auth-lluJZyQO.js +0 -524
  74. package/dist/auth-lluJZyQO.js.map +0 -1
  75. package/dist/environmentUtils-CUVZ6Dq1.js +0 -478
  76. package/dist/environmentUtils-CUVZ6Dq1.js.map +0 -1
  77. package/dist/httpArtifactService-JtkC1T7n.js.map +0 -1
  78. package/dist/serializer-DNt8QqNO.js +0 -1358
  79. package/dist/serializer-DNt8QqNO.js.map +0 -1
  80. package/dist/src/components/AiChat/useLiveSession.d.ts +0 -52
  81. package/dist/src/utils/jsonDetector.d.ts +0 -50
  82. package/dist/src/utils/jsonUtils.d.ts +0 -1
  83. package/dist/src/utils/materialIconsSvg.d.ts +0 -51
  84. package/dist/src/utils/objectUtils.d.ts +0 -31
  85. package/dist/src/utils/parseArtifact.d.ts +0 -3
  86. package/dist/src/utils/uriUtils.d.ts +0 -39
  87. package/dist/useContainerWidth-B3t1ZTlo.js +0 -309
@@ -1,172 +1,23 @@
1
- var rt = Object.defineProperty;
2
- var St = (D, t, e) => t in D ? rt(D, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : D[t] = e;
3
- var g = (D, t) => rt(D, "name", { value: t, configurable: !0 });
4
- var a = (D, t, e) => St(D, typeof t != "symbol" ? t + "" : t, e);
5
- import { d as x, t as wt, E as I, k as yt, j as Tt, q as It, C as W } from "./environmentUtils-CUVZ6Dq1.js";
6
- import { I as _, S as gt, g as Ct, L as vt, P as B, b as Et, e as Mt, T as Dt, c as Ot } from "./serializer-DNt8QqNO.js";
7
- import { unified as At } from "unified";
8
- import kt from "remark-parse";
9
- import { toMarkdown as Nt } from "mdast-util-to-markdown";
10
- import { format as Pt } from "date-fns";
11
- import _t from "lodash";
12
- import { P as bt, C as U } from "./Prompt-DZb7OaPp.js";
13
- import { r as Ft } from "./httpSessionService-BDlqebW2.js";
14
- const w = {
15
- ARTIFACTS: "envision-artifacts",
16
- SECTIONS: "envision-sections",
1
+ var it = Object.defineProperty;
2
+ var pt = (D, t, e) => t in D ? it(D, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : D[t] = e;
3
+ var f = (D, t) => it(D, "name", { value: t, configurable: !0 });
4
+ var i = (D, t, e) => pt(D, typeof t != "symbol" ? t + "" : t, e);
5
+ import { i as mt, a as St, d as wt } from "./environmentUtils-VZNTCzEE.js";
6
+ import { I as N, E as T, j as Tt, S as dt, q as yt, L as vt, P as L, l as Ct, o as It, T as Et, m as Mt, C as U } from "./serializer-D2W42bdT.js";
7
+ import { unified as Dt } from "unified";
8
+ import Ot from "remark-parse";
9
+ import { toMarkdown as kt } from "mdast-util-to-markdown";
10
+ import { format as At } from "date-fns";
11
+ import Pt from "lodash";
12
+ import { P as Nt, C as F } from "./Prompt-DZb7OaPp.js";
13
+ import { r as _t } from "./httpSessionService-CMT6k-Nu.js";
14
+ const W = {
17
15
  PROMPTS: "envision-prompts"
18
- }, L = [
19
- {
20
- id: "dashboards",
21
- name: "Dashboards",
22
- isDefault: !0,
23
- created: (/* @__PURE__ */ new Date()).toISOString(),
24
- iconType: "dashboard"
25
- },
26
- {
27
- id: "charts",
28
- name: "Chart",
29
- isDefault: !0,
30
- created: (/* @__PURE__ */ new Date()).toISOString(),
31
- iconType: "chart"
32
- },
33
- {
34
- id: "data-analytics",
35
- name: "Data Analytics",
36
- isDefault: !0,
37
- created: (/* @__PURE__ */ new Date()).toISOString(),
38
- iconType: "folder"
39
- }
40
- ], z = class z {
41
- constructor() {
42
- a(this, "onPromptCreated", /* @__PURE__ */ g(() => {
43
- }, "onPromptCreated"));
44
- }
45
- getItem(t) {
46
- return localStorage.getItem(t);
47
- }
48
- setItem(t, e) {
49
- localStorage.setItem(t, e);
50
- }
51
- removeItem(t) {
52
- localStorage.removeItem(t);
53
- }
54
- initializeStorage() {
55
- try {
56
- const t = localStorage.getItem(w.SECTIONS);
57
- if (!t)
58
- localStorage.setItem(w.SECTIONS, JSON.stringify(L));
59
- else {
60
- const s = JSON.parse(t);
61
- if (L.some(
62
- (n) => !s.find((r) => r.id === n.id)
63
- )) {
64
- const n = [...s];
65
- L.forEach((r) => {
66
- s.find((l) => l.id === r.id) || n.push(r);
67
- }), localStorage.setItem(w.SECTIONS, JSON.stringify(n));
68
- }
69
- }
70
- const e = localStorage.getItem(w.ARTIFACTS);
71
- if (e) {
72
- const s = JSON.parse(e);
73
- let i = !1;
74
- const n = s.map((r) => {
75
- if (!r.sectionId) {
76
- i = !0;
77
- let l = "data-analytics";
78
- return r.type === x.Dashboard ? l = "dashboards" : r.type === x.Chart && (l = "charts"), {
79
- ...r,
80
- sectionId: l
81
- };
82
- }
83
- return r;
84
- });
85
- i && localStorage.setItem(w.ARTIFACTS, JSON.stringify(n));
86
- }
87
- } catch (t) {
88
- console.error("Error initializing storage:", t);
89
- }
90
- }
91
- getSections() {
92
- try {
93
- const t = localStorage.getItem(w.SECTIONS);
94
- return t ? JSON.parse(t) : L;
95
- } catch (t) {
96
- return console.error("Error loading sections:", t), L;
97
- }
98
- }
99
- getArtifacts() {
100
- try {
101
- const t = localStorage.getItem(w.ARTIFACTS);
102
- return t ? JSON.parse(t) : [];
103
- } catch (t) {
104
- return console.error("Error loading artifacts:", t), [];
105
- }
106
- }
107
- createSection(t, e = "folder") {
108
- const s = {
109
- id: crypto.randomUUID(),
110
- name: t,
111
- isDefault: !1,
112
- created: (/* @__PURE__ */ new Date()).toISOString(),
113
- iconType: e
114
- }, i = this.getSections();
115
- return i.push(s), localStorage.setItem(w.SECTIONS, JSON.stringify(i)), s;
116
- }
117
- updateSection(t, e) {
118
- const s = this.getSections(), i = s.findIndex((n) => n.id === t);
119
- i >= 0 && (s[i] = { ...s[i], ...e }, localStorage.setItem(w.SECTIONS, JSON.stringify(s)));
120
- }
121
- deleteSection(t) {
122
- const e = this.getSections(), s = e.find((i) => i.id === t);
123
- if (s && !s.isDefault) {
124
- const i = this.getArtifacts(), n = s.iconType === "dashboard" ? "dashboards" : s.iconType === "chart" ? "charts" : "data-analytics", r = i.map((o) => o.sectionId === t ? { ...o, sectionId: n } : o);
125
- localStorage.setItem(w.ARTIFACTS, JSON.stringify(r));
126
- const l = e.filter((o) => o.id !== t);
127
- localStorage.setItem(w.SECTIONS, JSON.stringify(l));
128
- }
129
- }
130
- storeArtifact(t) {
131
- try {
132
- const e = this.getArtifacts(), s = e.findIndex((i) => i.id === t.id);
133
- if (s >= 0)
134
- e[s] = t;
135
- else {
136
- let i = "data-analytics";
137
- t.type === x.Dashboard ? i = "dashboards" : t.type === x.Chart && (i = "charts");
138
- const n = {
139
- ...t,
140
- created: t.created || (/* @__PURE__ */ new Date()).toISOString(),
141
- sectionId: t.sectionId || i
142
- };
143
- e.push(n);
144
- }
145
- localStorage.setItem(w.ARTIFACTS, JSON.stringify(e));
146
- } catch (e) {
147
- console.error("Error storing artifact:", e);
148
- }
149
- }
150
- moveArtifact(t, e) {
151
- const s = this.getArtifacts(), i = s.findIndex((n) => n.id === t);
152
- i >= 0 && (s[i] = { ...s[i], sectionId: e }, localStorage.setItem(w.ARTIFACTS, JSON.stringify(s)));
153
- }
154
- deleteArtifact(t) {
155
- const s = this.getArtifacts().filter((i) => i.id !== t);
156
- localStorage.setItem(w.ARTIFACTS, JSON.stringify(s));
157
- }
158
- updateArtifact(t, e) {
159
- const s = this.getArtifacts(), i = s.findIndex((n) => n.id === t);
160
- i >= 0 && (s[i] = { ...s[i], ...e }, localStorage.setItem(w.ARTIFACTS, JSON.stringify(s)));
161
- }
162
- getArtifactsBySection(t) {
163
- return this.getArtifacts().filter((s) => s.sectionId === t);
164
- }
165
- // Prompt management methods
16
+ }, K = class K {
166
17
  getPrompts() {
167
18
  try {
168
- const t = localStorage.getItem(w.PROMPTS);
169
- return t ? JSON.parse(t).sort((s, i) => new Date(i.created).getTime() - new Date(s.created).getTime()) : [];
19
+ const t = localStorage.getItem(W.PROMPTS);
20
+ return t ? JSON.parse(t).sort((s, a) => new Date(a.created).getTime() - new Date(s.created).getTime()) : [];
170
21
  } catch (t) {
171
22
  return console.error("Error loading prompts:", t), [];
172
23
  }
@@ -176,73 +27,65 @@ const w = {
176
27
  const e = this.getPrompts();
177
28
  e.length > 0 && e[0].promptText === t.promptText && (e[0].created = t.created, e[0].id = t.id), e.unshift(t);
178
29
  const s = e.slice(0, 50);
179
- localStorage.setItem(w.PROMPTS, JSON.stringify(s));
30
+ localStorage.setItem(W.PROMPTS, JSON.stringify(s));
180
31
  } catch (e) {
181
32
  console.error("Error storing prompt:", e);
182
33
  }
183
34
  }
184
- deletePrompt(t) {
185
- try {
186
- const s = this.getPrompts().filter((i) => i.id !== t);
187
- localStorage.setItem(w.PROMPTS, JSON.stringify(s));
188
- } catch (e) {
189
- console.error("Error deleting prompt:", e);
190
- }
191
- }
192
35
  clearAllPrompts() {
193
36
  try {
194
- localStorage.removeItem(w.PROMPTS);
37
+ localStorage.removeItem(W.PROMPTS);
195
38
  } catch (t) {
196
39
  console.error("Error clearing prompts:", t);
197
40
  }
198
41
  }
199
42
  };
200
- g(z, "LocalStorageService");
201
- let ot = z;
202
- const te = /* @__PURE__ */ g((D) => {
43
+ f(K, "LocalStorageService");
44
+ let at = K;
45
+ const Zt = /* @__PURE__ */ f((D) => {
203
46
  const t = D.getPrompts(), e = t.length;
204
47
  if (e > 0) {
205
- const s = t[0].promptText, i = t[t.length - 1].promptText, n = t[0].created;
206
- return { promptState: e + "_" + s + "_" + i + "_" + n };
48
+ const s = t[0].promptText, a = t[t.length - 1].promptText, n = t[0].created;
49
+ return { promptState: e + "_" + s + "_" + a + "_" + n };
207
50
  } else
208
51
  return { promptState: "0" };
209
- }, "usePromptState"), Y = class Y {
52
+ }, "usePromptState"), J = class J {
210
53
  constructor() {
211
- a(this, "activityLost", "activityLost");
212
- a(this, "artifactGenerated", "artifactGenerated");
213
- a(this, "artifactSelected", "artifactSelected");
214
- a(this, "artifactDeleted", "artifactDeleted");
215
- a(this, "gatewayMessage", "gatewayMessage");
216
- a(this, "gatewayTurnComplete", "gatewayTurnComplete");
217
- a(this, "gatewayStreamError", "gatewayStreamError");
218
- a(this, "gatewayTurnOpen", "gatewayTurnOpen");
219
- a(this, "sessionCreated", "sessionCreated");
220
- a(this, "sessionUpdated", "sessionUpdated");
221
- a(this, "gatewayFunctionResponse", "gatewayFunctionResponse");
222
- a(this, "uiUnsavedPopoverToggle", "uiUnsavedPopoverToggle");
223
- a(this, "artifactsStorageUpdated", "artifactsStorageUpdated");
224
- a(this, "gatewayStreamEnded", "gatewayStreamEnded");
225
- a(this, "streamNewChunk", "streamNewChunk");
226
- a(this, "gatewayEndMessageData", "gatewayEndMessageData");
227
- a(this, "connectionStateChange", "connectionStateChange");
228
- a(this, "onMessageSent", "onMessageSent");
229
- a(this, "onMessageError", "onMessageError");
230
- a(this, "onToolEvent", "onToolEvent");
231
- a(this, "gatewayFirstToken", "gatewayFirstToken");
54
+ i(this, "activityLost", "activityLost");
55
+ i(this, "artifactGenerated", "artifactGenerated");
56
+ i(this, "artifactSelected", "artifactSelected");
57
+ i(this, "artifactDeleted", "artifactDeleted");
58
+ i(this, "gatewayMessage", "gatewayMessage");
59
+ i(this, "gatewayTurnComplete", "gatewayTurnComplete");
60
+ i(this, "gatewayStreamError", "gatewayStreamError");
61
+ i(this, "gatewayTurnOpen", "gatewayTurnOpen");
62
+ i(this, "sessionCreated", "sessionCreated");
63
+ i(this, "sessionUpdated", "sessionUpdated");
64
+ i(this, "gatewayFunctionResponse", "gatewayFunctionResponse");
65
+ i(this, "uiUnsavedPopoverToggle", "uiUnsavedPopoverToggle");
66
+ i(this, "artifactsStorageUpdated", "artifactsStorageUpdated");
67
+ i(this, "gatewayStreamEnded", "gatewayStreamEnded");
68
+ i(this, "streamNewChunk", "streamNewChunk");
69
+ i(this, "gatewayEndMessageData", "gatewayEndMessageData");
70
+ i(this, "connectionStateChange", "connectionStateChange");
71
+ i(this, "onMessageSent", "onMessageSent");
72
+ i(this, "onMessageError", "onMessageError");
73
+ i(this, "onToolEvent", "onToolEvent");
74
+ i(this, "gatewayFirstToken", "gatewayFirstToken");
232
75
  }
233
76
  };
234
- g(Y, "EventTypes");
235
- let J = Y;
236
- const c = new J(), j = class j {
77
+ f(J, "EventTypes");
78
+ let $ = J;
79
+ const o = new $(), z = class z {
237
80
  constructor() {
238
- a(this, "listeners", {});
239
- a(this, "listenersCount", {});
81
+ i(this, "listeners", {});
82
+ i(this, "listenersCount", {});
240
83
  }
241
84
  callListeners(t, ...e) {
242
85
  const s = this.listeners[t];
243
86
  if (this.listenersCount[t] = this.listenersCount[t] + 1, s) {
244
- const i = s.map((n) => n(...e));
245
- Promise.all(i).catch((n) => {
87
+ const a = s.map((n) => n(...e));
88
+ Promise.all(a).catch((n) => {
246
89
  console.error(`Lost error in one of the listeners of the event: ${t}, listeners: ${s.length}, error: ${n}`, s);
247
90
  });
248
91
  }
@@ -254,239 +97,239 @@ const c = new J(), j = class j {
254
97
  return this.listenersCount[t];
255
98
  }
256
99
  activityOnLost(t) {
257
- const e = c.activityLost;
100
+ const e = o.activityLost;
258
101
  this.addListener(e, t);
259
102
  }
260
103
  activityEmitLost() {
261
- this.callListeners(c.activityLost);
104
+ this.callListeners(o.activityLost);
262
105
  }
263
106
  /* typed artifact listeners */
264
107
  artifactOnGenerated(t) {
265
- const e = c.artifactGenerated;
108
+ const e = o.artifactGenerated;
266
109
  this.addListener(e, t);
267
110
  }
268
111
  artifactEmitGenerated(t) {
269
- this.callListeners(c.artifactGenerated, t);
112
+ this.callListeners(o.artifactGenerated, t);
270
113
  }
271
114
  artifactOffGenerated(t) {
272
- const e = c.artifactGenerated;
115
+ const e = o.artifactGenerated;
273
116
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
274
117
  }
275
118
  artifactOnSelected(t) {
276
- const e = c.artifactSelected;
119
+ const e = o.artifactSelected;
277
120
  this.addListener(e, t);
278
121
  }
279
122
  artifactEmitSelected(t) {
280
- this.callListeners(c.artifactSelected, t);
123
+ this.callListeners(o.artifactSelected, t);
281
124
  }
282
125
  artifactOffSelected(t) {
283
- const e = c.artifactSelected;
126
+ const e = o.artifactSelected;
284
127
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
285
128
  }
286
129
  artifactOnDeleted(t) {
287
- const e = c.artifactDeleted;
130
+ const e = o.artifactDeleted;
288
131
  this.addListener(e, t);
289
132
  }
290
133
  artifactEmitDeleted(t) {
291
- this.callListeners(c.artifactDeleted, t);
134
+ this.callListeners(o.artifactDeleted, t);
292
135
  }
293
136
  artifactOffDeleted(t) {
294
- const e = c.artifactDeleted;
137
+ const e = o.artifactDeleted;
295
138
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
296
139
  }
297
140
  gatewayOnMessage(t) {
298
- const e = c.gatewayMessage;
141
+ const e = o.gatewayMessage;
299
142
  this.addListener(e, t);
300
143
  }
301
144
  gatewayOnTurnComplete(t) {
302
- const e = c.gatewayTurnComplete;
145
+ const e = o.gatewayTurnComplete;
303
146
  this.addListener(e, t);
304
147
  }
305
148
  gatewayOnTurnOpen(t) {
306
- const e = c.gatewayTurnOpen;
149
+ const e = o.gatewayTurnOpen;
307
150
  this.addListener(e, t);
308
151
  }
309
152
  gatewayOnStreamError(t) {
310
- const e = c.gatewayStreamError;
153
+ const e = o.gatewayStreamError;
311
154
  this.addListener(e, t);
312
155
  }
313
156
  gatewayOnStreamEnded(t) {
314
- const e = c.gatewayStreamEnded;
157
+ const e = o.gatewayStreamEnded;
315
158
  this.addListener(e, t);
316
159
  }
317
160
  gatewayOffStreamEnded(t) {
318
- const e = c.gatewayStreamEnded;
161
+ const e = o.gatewayStreamEnded;
319
162
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
320
163
  }
321
164
  gatewayEmitStreamEnded(t, e) {
322
- this.callListeners(c.gatewayStreamEnded, t, e);
165
+ this.callListeners(o.gatewayStreamEnded, t, e);
323
166
  }
324
167
  gatewayEmitMessage(t, e = null) {
325
- this.callListeners(c.gatewayMessage, t, e);
168
+ this.callListeners(o.gatewayMessage, t, e);
326
169
  }
327
170
  gatewayEmitTurnComplete(t, e) {
328
- this.callListeners(c.gatewayTurnComplete, t, e);
171
+ this.callListeners(o.gatewayTurnComplete, t, e);
329
172
  }
330
173
  gatewayEmitStreamError(t) {
331
- this.callListeners(c.gatewayStreamError, t);
174
+ this.callListeners(o.gatewayStreamError, t);
332
175
  }
333
176
  gatewayEmitTurnOpen(t) {
334
- this.callListeners(c.gatewayTurnOpen, t);
177
+ this.callListeners(o.gatewayTurnOpen, t);
335
178
  }
336
179
  gatewayOffMessage(t) {
337
- const e = c.gatewayMessage;
180
+ const e = o.gatewayMessage;
338
181
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
339
182
  }
340
183
  gatewayOffTurnComplete(t) {
341
- const e = c.gatewayTurnComplete;
184
+ const e = o.gatewayTurnComplete;
342
185
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
343
186
  }
344
187
  gatewayOffTurnOpen(t) {
345
- const e = c.gatewayTurnOpen;
188
+ const e = o.gatewayTurnOpen;
346
189
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
347
190
  }
348
191
  gatewayOffStreamError(t) {
349
- const e = c.gatewayStreamError;
192
+ const e = o.gatewayStreamError;
350
193
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
351
194
  }
352
195
  sessionOnCreated(t) {
353
- const e = c.sessionCreated;
196
+ const e = o.sessionCreated;
354
197
  this.addListener(e, t);
355
198
  }
356
199
  chatOnMessageSent(t) {
357
- const e = c.onMessageSent;
200
+ const e = o.onMessageSent;
358
201
  this.addListener(e, t);
359
202
  }
360
203
  chatOffMessageSent(t) {
361
- const e = c.onMessageSent;
204
+ const e = o.onMessageSent;
362
205
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
363
206
  }
364
207
  ChatEmitMessageSent(t, e) {
365
- this.callListeners(c.onMessageSent, t, e);
208
+ this.callListeners(o.onMessageSent, t, e);
366
209
  }
367
210
  chatOnMessageError(t) {
368
- const e = c.onMessageError;
211
+ const e = o.onMessageError;
369
212
  this.addListener(e, t);
370
213
  }
371
214
  chatOffMessageError(t) {
372
- const e = c.onMessageError;
215
+ const e = o.onMessageError;
373
216
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
374
217
  }
375
218
  ChatEmitMessageError(t) {
376
- this.callListeners(c.onMessageError, t);
219
+ this.callListeners(o.onMessageError, t);
377
220
  }
378
221
  sessionOnUpdated(t) {
379
- const e = c.sessionUpdated;
222
+ const e = o.sessionUpdated;
380
223
  this.addListener(e, t);
381
224
  }
382
225
  sessionEmitCreated(t) {
383
- this.callListeners(c.sessionCreated, t);
226
+ this.callListeners(o.sessionCreated, t);
384
227
  }
385
228
  sessionEmitUpdated(t) {
386
- this.callListeners(c.sessionUpdated, t);
229
+ this.callListeners(o.sessionUpdated, t);
387
230
  }
388
231
  sessionOffCreated(t) {
389
- const e = c.sessionCreated;
232
+ const e = o.sessionCreated;
390
233
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
391
234
  }
392
235
  sessionOffUpdated(t) {
393
- const e = c.sessionUpdated;
236
+ const e = o.sessionUpdated;
394
237
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
395
238
  }
396
239
  gatewayEmitFunctionResponse(t) {
397
- this.callListeners(c.gatewayFunctionResponse, t);
240
+ this.callListeners(o.gatewayFunctionResponse, t);
398
241
  }
399
242
  gatewayOffFunctionResponse(t) {
400
- const e = c.gatewayFunctionResponse;
243
+ const e = o.gatewayFunctionResponse;
401
244
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
402
245
  }
403
246
  gatewayOnFunctionResponse(t) {
404
- const e = c.gatewayFunctionResponse;
247
+ const e = o.gatewayFunctionResponse;
405
248
  this.addListener(e, t);
406
249
  }
407
250
  // UI events
408
251
  uiOnUnsavedPopoverToggle(t) {
409
- const e = c.uiUnsavedPopoverToggle;
252
+ const e = o.uiUnsavedPopoverToggle;
410
253
  this.addListener(e, t);
411
254
  }
412
255
  uiEmitUnsavedPopoverToggle(t) {
413
- this.callListeners(c.uiUnsavedPopoverToggle, t);
256
+ this.callListeners(o.uiUnsavedPopoverToggle, t);
414
257
  }
415
258
  uiOffUnsavedPopoverToggle(t) {
416
- const e = c.uiUnsavedPopoverToggle;
259
+ const e = o.uiUnsavedPopoverToggle;
417
260
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
418
261
  }
419
262
  // Artifacts storage update events
420
263
  artifactsOnStorageUpdated(t) {
421
- const e = c.artifactsStorageUpdated;
264
+ const e = o.artifactsStorageUpdated;
422
265
  this.addListener(e, t);
423
266
  }
424
267
  artifactsEmitStorageUpdated() {
425
- this.callListeners(c.artifactsStorageUpdated);
268
+ this.callListeners(o.artifactsStorageUpdated);
426
269
  }
427
270
  artifactsOffStorageUpdated(t) {
428
- const e = c.artifactsStorageUpdated;
271
+ const e = o.artifactsStorageUpdated;
429
272
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
430
273
  }
431
274
  streamOnNewChunk(t) {
432
- const e = c.streamNewChunk;
275
+ const e = o.streamNewChunk;
433
276
  this.addListener(e, t);
434
277
  }
435
278
  streamEmitNewChunk(t) {
436
- this.callListeners(c.streamNewChunk, t);
279
+ this.callListeners(o.streamNewChunk, t);
437
280
  }
438
281
  streamOffNewChunk(t) {
439
- const e = c.streamNewChunk;
282
+ const e = o.streamNewChunk;
440
283
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
441
284
  }
442
285
  gatewayOnEndMessageData(t) {
443
- const e = c.gatewayEndMessageData;
286
+ const e = o.gatewayEndMessageData;
444
287
  this.addListener(e, t);
445
288
  }
446
289
  gatewayEmitEndMessageData(t) {
447
- this.callListeners(c.gatewayEndMessageData, t);
290
+ this.callListeners(o.gatewayEndMessageData, t);
448
291
  }
449
292
  gatewayOffEndMessageData(t) {
450
- const e = c.gatewayEndMessageData;
293
+ const e = o.gatewayEndMessageData;
451
294
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
452
295
  }
453
296
  gatewayOnConnectionStateChange(t) {
454
- const e = c.connectionStateChange;
297
+ const e = o.connectionStateChange;
455
298
  this.addListener(e, t);
456
299
  }
457
300
  gatewayEmitConnectionStateChange(t) {
458
- this.callListeners(c.connectionStateChange, t);
301
+ this.callListeners(o.connectionStateChange, t);
459
302
  }
460
303
  gatewayOffConnectionStateChange(t) {
461
- const e = c.connectionStateChange;
304
+ const e = o.connectionStateChange;
462
305
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
463
306
  }
464
307
  gatewayOnToolEvent(t) {
465
- const e = c.onToolEvent;
308
+ const e = o.onToolEvent;
466
309
  this.addListener(e, t);
467
310
  }
468
311
  gatewayEmitToolEvent(t, e, s) {
469
- this.callListeners(c.onToolEvent, t, e, s);
312
+ this.callListeners(o.onToolEvent, t, e, s);
470
313
  }
471
314
  gatewayOffToolEvent(t) {
472
- const e = c.onToolEvent;
315
+ const e = o.onToolEvent;
473
316
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
474
317
  }
475
318
  gatewayOnFirstToken(t) {
476
- const e = c.gatewayFirstToken;
319
+ const e = o.gatewayFirstToken;
477
320
  this.addListener(e, t);
478
321
  }
479
322
  gatewayEmitFirstToken(t) {
480
- this.callListeners(c.gatewayFirstToken, t);
323
+ this.callListeners(o.gatewayFirstToken, t);
481
324
  }
482
325
  gatewayOffFirstToken(t) {
483
- const e = c.gatewayFirstToken;
326
+ const e = o.gatewayFirstToken;
484
327
  this.listeners[e] && (this.listeners[e] = this.listeners[e].filter((s) => s !== t));
485
328
  }
486
329
  };
487
- g(j, "EventBusService");
488
- let G = j;
489
- const X = class X extends G {
330
+ f(z, "EventBusService");
331
+ let q = z;
332
+ const Y = class Y extends q {
490
333
  constructor() {
491
334
  super();
492
335
  }
@@ -494,7 +337,7 @@ const X = class X extends G {
494
337
  console.log("MockEventBusService.gatewayEmitConnectionStateChange");
495
338
  }
496
339
  gatewayEmitMessage(t, e) {
497
- wt() ? process.stdout.write(`M${t.version}, `) : console.log("MockEventBusService.gatewayEmitMessage");
340
+ mt() ? process.stdout.write(`M${t.version}, `) : console.log("MockEventBusService.gatewayEmitMessage");
498
341
  }
499
342
  gatewayEmitTurnComplete(t, e) {
500
343
  console.log("MockEventBusService.gatewayEmitTurnComplete");
@@ -512,73 +355,96 @@ const X = class X extends G {
512
355
  console.log("MockEventBusService.gatewayOffFunctionResponse", t);
513
356
  }
514
357
  };
515
- g(X, "MockEventBusService");
516
- let ct = X;
517
- const Rt = 2e3, pt = {
358
+ f(Y, "MockEventBusService");
359
+ let rt = Y;
360
+ const bt = 2e3, gt = {
518
361
  inline: "inline",
519
362
  block: "block"
520
- }, Q = class Q {
363
+ }, j = class j {
521
364
  constructor() {
522
- a(this, "parts", []);
523
- a(this, "isLastGroup", !1);
524
- a(this, "hasThoughts", !1);
525
- a(this, "lastWithThoughts", !1);
526
- a(this, "type", pt.inline);
365
+ i(this, "parts", []);
366
+ i(this, "isLastGroup", !1);
367
+ i(this, "hasThoughts", !1);
368
+ i(this, "lastWithThoughts", !1);
369
+ /**
370
+ * A run of CONSECUTIVE thought parts — one continuous piece of reasoning
371
+ * that `merge` split at {@link MAX_CHAR_PER_TEXT_PART} to keep a very long
372
+ * prose from dragging the browser down.
373
+ *
374
+ * The split is a rendering optimisation and must not be legible as one: the
375
+ * reader gets a single "Pensando…" block whatever the chunk count, drawn by
376
+ * the run's chrome, while each chunk stays its own memoized MessagePart —
377
+ * which is where the CPU saving actually comes from.
378
+ */
379
+ i(this, "isThoughtRun", !1);
380
+ i(this, "type", gt.inline);
527
381
  }
528
382
  };
529
- g(Q, "InteractionPartGroup");
530
- let $ = Q;
531
- const Z = class Z {
383
+ f(j, "InteractionPartGroup");
384
+ let x = j;
385
+ const X = class X {
532
386
  constructor(t, e) {
533
- a(this, "interaction");
534
- a(this, "eventBusService");
535
- a(this, "parseTextIntoParts", /* @__PURE__ */ g((t) => {
387
+ i(this, "interaction");
388
+ i(this, "eventBusService");
389
+ i(this, "parseTextIntoParts", /* @__PURE__ */ f((t) => {
536
390
  if (!t || t.trim().length == 0) return [];
537
- const e = At().use(kt).parse(t), s = [];
538
- let i = null;
391
+ const e = Dt().use(Ot).parse(t), s = [];
392
+ let a = null;
539
393
  for (const n of e.children)
540
- n.type === "code" ? (i && (s.push(i), i = null), n.lang === "htmlCanvas" && s.push(`
394
+ n.type === "code" ? (a && (s.push(a), a = null), n.lang === "htmlCanvas" && s.push(`
541
395
  \`\`\`liveTsx
542
396
  ${n.value}
543
397
  \`\`\`
544
- `)) : (i || (i = ""), i += Nt(n));
545
- return i && s.push(i), s;
398
+ `)) : (a || (a = ""), a += kt(n));
399
+ return a && s.push(a), s;
546
400
  }, "parseTextIntoParts"));
547
401
  this.interaction = t, this.eventBusService = e;
548
402
  }
549
403
  expandSubParts(t, e) {
550
- const s = this.parseTextIntoParts(t), i = [];
404
+ const s = this.parseTextIntoParts(t), a = [];
551
405
  let n = 0;
552
406
  for (const r of s) {
553
- const l = _.fromText(r);
554
- l.id = n + "_" + e, i.push(l), n++;
407
+ const l = N.fromText(r);
408
+ l.id = n + "_" + e, a.push(l), n++;
555
409
  }
556
- return i;
410
+ return a;
557
411
  }
558
412
  groupPartsByDisplayType(t, e = !0, s = !1) {
559
- var l, o, d;
560
- const i = [];
561
- let n = new $();
413
+ var l, c, d;
414
+ const a = [];
415
+ let n = new x();
562
416
  for (let u = 0; u < t.length; u++) {
563
417
  const h = t[u];
564
- let p = !((((l = h.functionDetails) == null ? void 0 : l.isUi) ?? !1) || ((o = h.functionDetails) == null ? void 0 : o.cancelUi) !== !0 && (((d = h.functionDetails) == null ? void 0 : d.isAskUser) ?? !1)) && h.eventType !== I.Text && h.eventType !== I.Thought && (h.eventType === I.FunctionCall || h.eventType === I.PartialFunctionCall || h.eventType === I.FunctionResponse) && u < t.length - 1;
565
- !e && p && !s || (p ? (h.eventType == I.Thought && (n.hasThoughts = !0), n.parts.push(h), n.isLastGroup = u === t.length - 1) : (n.parts.length > 0 && (i.push(n), n = new $()), i.push({
566
- type: pt.block,
567
- parts: [h],
568
- isLastGroup: u === t.length - 1,
569
- hasThoughts: !1,
570
- lastWithThoughts: !1
571
- })));
418
+ let p = !((((l = h.functionDetails) == null ? void 0 : l.isUi) ?? !1) || ((c = h.functionDetails) == null ? void 0 : c.cancelUi) !== !0 && (((d = h.functionDetails) == null ? void 0 : d.isAskUser) ?? !1)) && h.eventType !== T.Text && h.eventType !== T.Thought && (h.eventType === T.FunctionCall || h.eventType === T.PartialFunctionCall || h.eventType === T.FunctionResponse) && u < t.length - 1;
419
+ if (!(!e && p && !s))
420
+ if (p)
421
+ h.eventType == T.Thought && (n.hasThoughts = !0), n.parts.push(h), n.isLastGroup = u === t.length - 1;
422
+ else {
423
+ n.parts.length > 0 && (a.push(n), n = new x());
424
+ const M = h.eventType === T.Thought, w = a[a.length - 1];
425
+ if (M && (w != null && w.isThoughtRun)) {
426
+ w.parts.push(h), w.isLastGroup = u === t.length - 1;
427
+ continue;
428
+ }
429
+ a.push({
430
+ type: gt.block,
431
+ parts: [h],
432
+ isLastGroup: u === t.length - 1,
433
+ hasThoughts: !1,
434
+ lastWithThoughts: !1,
435
+ isThoughtRun: M
436
+ });
437
+ }
572
438
  }
573
- n.parts.length > 0 && i.push(n);
574
- const r = i.filter((u) => u.hasThoughts);
575
- return r.length > 0 && (r[r.length - 1].lastWithThoughts = !0), i;
439
+ n.parts.length > 0 && a.push(n);
440
+ const r = a.filter((u) => u.hasThoughts);
441
+ return r.length > 0 && (r[r.length - 1].lastWithThoughts = !0), a;
576
442
  }
577
443
  isFunctionCall(t) {
578
- return t == I.FunctionCall || t == I.PartialFunctionCall;
444
+ return t == T.FunctionCall || t == T.PartialFunctionCall;
579
445
  }
580
446
  isFunctionResponse(t) {
581
- return t == I.FunctionResponse;
447
+ return t == T.FunctionResponse;
582
448
  }
583
449
  // Computes the next interaction from a server event. Pure with respect to
584
450
  // `prev` — no part or array on the prior tree is mutated; modified entities
@@ -586,54 +452,54 @@ ${n.value}
586
452
  // new tree as the last step, so snapshots already handed out to throttled
587
453
  // subscribers can't diverge from the live state.
588
454
  merge(t) {
589
- var b, F, y, A, N, st, nt, it;
590
- const e = this.interaction, s = [], i = [], n = _.FlatParts(t == null ? void 0 : t.parts), r = e.parts[e.parts.length - 1] ?? null;
455
+ var _, b, y, O, A, tt, et, st;
456
+ const e = this.interaction, s = [], a = [], n = N.FlatParts(t == null ? void 0 : t.parts), r = e.parts[e.parts.length - 1] ?? null;
591
457
  let l = !1;
592
- n && (l = !r || n.mustPush || n.mustPush === !1 && (n.eventType !== (r == null ? void 0 : r.eventType) || ((b = n == null ? void 0 : n.functionDetails) == null ? void 0 : b.id) !== ((F = r.functionDetails) == null ? void 0 : F.id)));
593
- let o = e.parts, d = e.functionMap ?? /* @__PURE__ */ new Map(), u = !e.functionMap;
594
- const h = /* @__PURE__ */ g(() => {
458
+ n && (l = !r || n.mustPush || n.mustPush === !1 && (n.eventType !== (r == null ? void 0 : r.eventType) || ((_ = n == null ? void 0 : n.functionDetails) == null ? void 0 : _.id) !== ((b = r.functionDetails) == null ? void 0 : b.id)));
459
+ let c = e.parts, d = e.functionMap ?? /* @__PURE__ */ new Map(), u = !e.functionMap;
460
+ const h = /* @__PURE__ */ f(() => {
595
461
  u || (d = new Map(d), u = !0);
596
- }, "cloneFunctionMap"), C = /* @__PURE__ */ g(() => {
597
- o === e.parts && (o = e.parts.slice());
462
+ }, "cloneFunctionMap"), C = /* @__PURE__ */ f(() => {
463
+ c === e.parts && (c = e.parts.slice());
598
464
  }, "clonePartsIfShared");
599
- if (!l && (o == null ? void 0 : o.length) > 0 && (n != null && n.textAppendable)) {
600
- const f = o[o.length - 1];
601
- (((A = (y = f.thoughtDetails) == null ? void 0 : y.text) == null ? void 0 : A.length) ?? ((N = f.text) == null ? void 0 : N.length) ?? 0) > Rt && (l = !0);
465
+ if (!l && (c == null ? void 0 : c.length) > 0 && (n != null && n.textAppendable)) {
466
+ const g = c[c.length - 1];
467
+ (((O = (y = g.thoughtDetails) == null ? void 0 : y.text) == null ? void 0 : O.length) ?? ((A = g.text) == null ? void 0 : A.length) ?? 0) > bt && (l = !0);
602
468
  }
603
469
  let p = !1;
604
- if ((n == null ? void 0 : n.eventType) === I.FunctionClientOutput && !!((st = n.functionDetails) != null && st.id) && n) {
605
- const f = n.functionDetails.id, T = n.functionDetails.clientOutput, E = o.findIndex((S) => {
470
+ if ((n == null ? void 0 : n.eventType) === T.FunctionClientOutput && !!((tt = n.functionDetails) != null && tt.id) && n) {
471
+ const g = n.functionDetails.id, v = n.functionDetails.clientOutput, E = c.findIndex((S) => {
606
472
  var m;
607
- return ((m = S.functionDetails) == null ? void 0 : m.id) === f;
473
+ return ((m = S.functionDetails) == null ? void 0 : m.id) === g;
608
474
  });
609
475
  if (E > -1) {
610
- const S = o[E], m = {
476
+ const S = c[E], m = {
611
477
  ...S,
612
478
  functionDetails: {
613
479
  ...S.functionDetails,
614
- clientOutput: T ?? S.functionDetails.clientOutput,
480
+ clientOutput: v ?? S.functionDetails.clientOutput,
615
481
  // Sticky true-wins: this event IS the park, and a later merge must not clear it.
616
482
  parked: n.functionDetails.parked === !0 || S.functionDetails.parked === !0
617
483
  }
618
484
  };
619
- C(), o[E] = m, h(), d.set(f, m), s.push(m);
485
+ C(), c[E] = m, h(), d.set(g, m), s.push(m);
620
486
  } else {
621
487
  const S = {
622
488
  ...n,
623
- id: o.length + 1 + "-" + e.interactionId,
489
+ id: c.length + 1 + "-" + e.interactionId,
624
490
  functionDetails: { ...n.functionDetails, silent: !0 }
625
491
  };
626
- C(), o = o === e.parts ? e.parts.slice() : o, o.push(S), h(), d.set(f, S);
492
+ C(), c = c === e.parts ? e.parts.slice() : c, c.push(S), h(), d.set(g, S);
627
493
  }
628
494
  } else if (l && n) {
629
- const f = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), T = f ? (nt = n.functionDetails) == null ? void 0 : nt.id : void 0;
630
- f && !T && console.error("Got isCall or isResponse without a callId", n);
631
- const E = T ? d.get(T) : void 0;
632
- if (E && T && n.functionDetails) {
633
- const S = o.findIndex((mt) => {
634
- var at;
635
- return ((at = mt.functionDetails) == null ? void 0 : at.id) === T;
636
- }), m = S > -1 ? o[S] : E, R = {
495
+ const g = this.isFunctionCall(n.eventType) || this.isFunctionResponse(n.eventType), v = g ? (et = n.functionDetails) == null ? void 0 : et.id : void 0;
496
+ g && !v && console.error("Got isCall or isResponse without a callId", n);
497
+ const E = v ? d.get(v) : void 0;
498
+ if (E && v && n.functionDetails) {
499
+ const S = c.findIndex((ft) => {
500
+ var nt;
501
+ return ((nt = ft.functionDetails) == null ? void 0 : nt.id) === v;
502
+ }), m = S > -1 ? c[S] : E, R = {
637
503
  ...m,
638
504
  eventType: n.eventType,
639
505
  functionDetails: {
@@ -674,65 +540,65 @@ ${n.value}
674
540
  parked: n.functionDetails.parked === !0 || m.functionDetails.parked === !0
675
541
  }
676
542
  };
677
- h(), d.set(T, R), R.eventType === I.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(R.functionDetails), s.push(R), S > -1 && (C(), o[S] = R);
543
+ h(), d.set(v, R), R.eventType === T.FunctionResponse && this.eventBusService.gatewayEmitFunctionResponse(R.functionDetails), s.push(R), S > -1 && (C(), c[S] = R);
678
544
  } else {
679
- if (T && n.functionDetails && !E && (h(), d.set(T, n)), r && r.textAppendable) {
545
+ if (v && n.functionDetails && !E && (h(), d.set(v, n)), r && r.textAppendable) {
680
546
  const m = {
681
547
  ...r,
682
548
  ended: /* @__PURE__ */ new Date(),
683
549
  isStillWriting: !1
684
550
  };
685
- C(), o[o.length - 1] = m, s.push(m);
551
+ C(), c[c.length - 1] = m, s.push(m);
686
552
  }
687
553
  const S = {
688
554
  ...n,
689
- id: o.length + 1 + "-" + e.interactionId,
555
+ id: c.length + 1 + "-" + e.interactionId,
690
556
  isStillWriting: n.textAppendable,
691
557
  partial: t.partial
692
558
  };
693
- (it = S.functionDetails) != null && it.silent || s.push(S), o = [...o, S], p = !0;
559
+ (st = S.functionDetails) != null && st.silent || s.push(S), c = [...c, S], p = !0;
694
560
  }
695
561
  }
696
- let M = o[o.length - 1] ?? null;
697
- if (M && n && n.textAppendable) {
698
- const f = {
699
- ...M,
562
+ let w = c[c.length - 1] ?? null;
563
+ if (w && n && n.textAppendable) {
564
+ const g = {
565
+ ...w,
700
566
  partial: t.partial,
701
- textDetails: M.textDetails ? { ...M.textDetails } : { version: 0 }
567
+ textDetails: w.textDetails ? { ...w.textDetails } : { version: 0 }
702
568
  };
703
- let T = !1;
569
+ let v = !1;
704
570
  if (t.partial) {
705
571
  try {
706
- f.textDetails.version++, p || (f.text = (M.text ?? "") + (n.text ?? ""));
572
+ g.textDetails.version++, p || (g.text = (w.text ?? "") + (n.text ?? ""));
707
573
  } catch (E) {
708
574
  console.error("Error here", E.toString());
709
575
  }
710
- f.textLastChunk = n.text ?? "", f.isStillWriting = !0, T = !0, n.thoughtDetails && f.thoughtDetails && (n.thoughtDetails.text.length >= 50 || n.thoughtDetails.text.length < 50 && n.thoughtDetails.text !== f.thoughtDetails.text) && (f.thoughtDetails = {
711
- ...f.thoughtDetails,
712
- text: f.thoughtDetails.text + n.thoughtDetails.text
713
- }, f.thoughtLastChunk = n.thoughtDetails.text);
576
+ g.textLastChunk = n.text ?? "", g.isStillWriting = !0, v = !0, n.thoughtDetails && g.thoughtDetails && (n.thoughtDetails.text.length >= 50 || n.thoughtDetails.text.length < 50 && n.thoughtDetails.text !== g.thoughtDetails.text) && (g.thoughtDetails = {
577
+ ...g.thoughtDetails,
578
+ text: g.thoughtDetails.text + n.thoughtDetails.text
579
+ }, g.thoughtLastChunk = n.thoughtDetails.text);
714
580
  } else
715
- f.isStillWriting = !1, f.text = n.text ?? "", f.textDetails.version++, n.thoughtDetails && (f.thoughtDetails = {
581
+ g.isStillWriting = !1, g.text = n.text ?? "", g.textDetails.version++, n.thoughtDetails && (g.thoughtDetails = {
716
582
  ...n.thoughtDetails,
717
583
  text: n.thoughtDetails.text.trim()
718
- }), T = !l;
719
- C(), o[o.length - 1] = f, M = f, T && s.push(f);
584
+ }), v = !l;
585
+ C(), c[c.length - 1] = g, w = g, v && s.push(g);
720
586
  }
721
- let v = e.artifactData ?? [];
587
+ let I = e.artifactData ?? [];
722
588
  if (t.llmArtifacts && t.llmArtifacts.length > 0) {
723
- let f = !1;
724
- for (const T of t.llmArtifacts) {
725
- const E = T.toArtifact();
726
- f || (v = v.slice(), f = !0);
727
- const S = v.findIndex((m) => m.id === E.id);
728
- S === -1 ? v.push(E) : v[S] = E;
589
+ let g = !1;
590
+ for (const v of t.llmArtifacts) {
591
+ const E = v.toArtifact();
592
+ g || (I = I.slice(), g = !0);
593
+ const S = I.findIndex((m) => m.id === E.id);
594
+ S === -1 ? I.push(E) : I[S] = E;
729
595
  }
730
596
  }
731
597
  const k = {
732
598
  ...e,
733
599
  version: e.version + 1,
734
- parts: o,
735
- artifactData: v,
600
+ parts: c,
601
+ artifactData: I,
736
602
  functionMap: d,
737
603
  turn_complete: t.turn_complete,
738
604
  partial: t.partial,
@@ -741,7 +607,7 @@ ${n.value}
741
607
  return this.interaction = k, {
742
608
  updatedInteraction: k,
743
609
  updatedParts: s,
744
- newArtifacts: i,
610
+ newArtifacts: a,
745
611
  mainBranch: k,
746
612
  analyticsBranch: null,
747
613
  analyticsBranchPartsChanged: null,
@@ -749,86 +615,86 @@ ${n.value}
749
615
  };
750
616
  }
751
617
  };
752
- g(Z, "InteractionService");
753
- let q = Z;
754
- const Ut = 1200 * 1e3, P = class P {
755
- constructor(t, e, s, i, n, r, l, o, d, u = Tt.Interactive) {
756
- a(this, "base_production_url", yt() ?? "https://agent.tripapi.com.br");
757
- a(this, "base_url_local", "http://localagent:8000");
758
- a(this, "base_url");
759
- a(this, "isLocal", !1);
760
- a(this, "msg_order", 0);
761
- a(this, "lastPing", /* @__PURE__ */ new Date());
762
- a(this, "interactionsMap", /* @__PURE__ */ new Map());
763
- a(this, "interactionsServiceMap", /* @__PURE__ */ new Map());
764
- a(this, "user");
765
- a(this, "config");
766
- a(this, "currentIS", null);
767
- a(this, "server_session_id");
768
- a(this, "model_session_id");
769
- a(this, "runMode");
770
- a(this, "sessionState");
771
- a(this, "storageService");
772
- a(this, "notificationPort");
773
- a(this, "interactionCallIds", /* @__PURE__ */ new Map());
774
- a(this, "rawJwt");
775
- a(this, "sessionId");
776
- a(this, "isInited", !1);
618
+ f(X, "InteractionService");
619
+ let B = X;
620
+ const Rt = 1200 * 1e3, P = class P {
621
+ constructor(t, e, s, a, n, r, l, c, d, u = Tt.Interactive) {
622
+ i(this, "base_production_url", St() ?? "https://agent.tripapi.com.br");
623
+ i(this, "base_url_local", "http://localagent:8000");
624
+ i(this, "base_url");
625
+ i(this, "isLocal", !1);
626
+ i(this, "msg_order", 0);
627
+ i(this, "lastPing", /* @__PURE__ */ new Date());
628
+ i(this, "interactionsMap", /* @__PURE__ */ new Map());
629
+ i(this, "interactionsServiceMap", /* @__PURE__ */ new Map());
630
+ i(this, "user");
631
+ i(this, "config");
632
+ i(this, "currentIS", null);
633
+ i(this, "server_session_id");
634
+ i(this, "model_session_id");
635
+ i(this, "runMode");
636
+ i(this, "sessionState");
637
+ i(this, "storageService");
638
+ i(this, "notificationPort");
639
+ i(this, "interactionCallIds", /* @__PURE__ */ new Map());
640
+ i(this, "rawJwt");
641
+ i(this, "sessionId");
642
+ i(this, "isInited", !1);
777
643
  //Define all SSEServer methods here, use from SSEServer.ts
778
- a(this, "eventBusService");
779
- a(this, "artifactService");
780
- a(this, "onTurnOpen", /* @__PURE__ */ g((t) => {
644
+ i(this, "eventBusService");
645
+ i(this, "artifactService");
646
+ i(this, "onTurnOpen", /* @__PURE__ */ f((t) => {
781
647
  this.eventBusService.gatewayOnTurnOpen(t);
782
648
  }, "onTurnOpen"));
783
- a(this, "offTurnOpen", /* @__PURE__ */ g((t) => {
649
+ i(this, "offTurnOpen", /* @__PURE__ */ f((t) => {
784
650
  this.eventBusService.gatewayOffTurnOpen(t);
785
651
  }, "offTurnOpen"));
786
- a(this, "onTurnComplete", /* @__PURE__ */ g((t) => {
652
+ i(this, "onTurnComplete", /* @__PURE__ */ f((t) => {
787
653
  this.eventBusService.gatewayOnTurnComplete(t);
788
654
  }, "onTurnComplete"));
789
- a(this, "offTurnComplete", /* @__PURE__ */ g((t) => {
655
+ i(this, "offTurnComplete", /* @__PURE__ */ f((t) => {
790
656
  this.eventBusService.gatewayOffTurnComplete(t);
791
657
  }, "offTurnComplete"));
792
- a(this, "onStreamError", /* @__PURE__ */ g((t) => {
658
+ i(this, "onStreamError", /* @__PURE__ */ f((t) => {
793
659
  this.eventBusService.gatewayOnStreamError(t);
794
660
  }, "onStreamError"));
795
- a(this, "offStreamError", /* @__PURE__ */ g((t) => {
661
+ i(this, "offStreamError", /* @__PURE__ */ f((t) => {
796
662
  this.eventBusService.gatewayOffStreamError(t);
797
663
  }, "offStreamError"));
798
- a(this, "onStreamEnded", /* @__PURE__ */ g((t) => {
664
+ i(this, "onStreamEnded", /* @__PURE__ */ f((t) => {
799
665
  this.eventBusService.gatewayOnStreamEnded(t);
800
666
  }, "onStreamEnded"));
801
- a(this, "offStreamEnded", /* @__PURE__ */ g((t) => {
667
+ i(this, "offStreamEnded", /* @__PURE__ */ f((t) => {
802
668
  this.eventBusService.gatewayOffStreamEnded(t);
803
669
  }, "offStreamEnded"));
804
- a(this, "onMessage", /* @__PURE__ */ g((t) => {
670
+ i(this, "onMessage", /* @__PURE__ */ f((t) => {
805
671
  this.eventBusService.gatewayOnMessage(t);
806
672
  }, "onMessage"));
807
- a(this, "offMessage", /* @__PURE__ */ g((t) => {
673
+ i(this, "offMessage", /* @__PURE__ */ f((t) => {
808
674
  this.eventBusService.gatewayOffMessage(t);
809
675
  }, "offMessage"));
810
- a(this, "onFirstToken", /* @__PURE__ */ g((t) => {
676
+ i(this, "onFirstToken", /* @__PURE__ */ f((t) => {
811
677
  this.eventBusService.gatewayOnFirstToken(t);
812
678
  }, "onFirstToken"));
813
- a(this, "offFirstToken", /* @__PURE__ */ g((t) => {
679
+ i(this, "offFirstToken", /* @__PURE__ */ f((t) => {
814
680
  this.eventBusService.gatewayOffFirstToken(t);
815
681
  }, "offFirstToken"));
816
- a(this, "onFunctionResponse", /* @__PURE__ */ g((t) => {
682
+ i(this, "onFunctionResponse", /* @__PURE__ */ f((t) => {
817
683
  this.eventBusService.gatewayOnFunctionResponse(t);
818
684
  }, "onFunctionResponse"));
819
- a(this, "offFunctionResponse", /* @__PURE__ */ g((t) => {
685
+ i(this, "offFunctionResponse", /* @__PURE__ */ f((t) => {
820
686
  this.eventBusService.gatewayOffFunctionResponse(t);
821
687
  }, "offFunctionResponse"));
822
- a(this, "toolSessionId", null);
823
- a(this, "pendingCurrentMessage", null);
824
- a(this, "lastCurrentMessageUpdate", 0);
825
- a(this, "runningRequests", /* @__PURE__ */ new Map());
826
- a(this, "lastToolInteraction", "");
827
- a(this, "subAgentInteractions", /* @__PURE__ */ new Map());
828
- a(this, "subAgentInteractionServices", /* @__PURE__ */ new Map());
829
- a(this, "lastThorttledTimeout", null);
830
- a(this, "lastPingStatus", !1);
831
- this.user = t, this.config = n, this.rawJwt = t.access_token, this.base_url = i, this.eventBusService = e, this.sessionId = d, this.runMode = u, this.artifactService = s, this.sessionState = r.getState(), this.notificationPort = l, this.storageService = o, r.subscribe((h, C) => {
688
+ i(this, "toolSessionId", null);
689
+ i(this, "pendingCurrentMessage", null);
690
+ i(this, "lastCurrentMessageUpdate", 0);
691
+ i(this, "runningRequests", /* @__PURE__ */ new Map());
692
+ i(this, "lastToolInteraction", "");
693
+ i(this, "subAgentInteractions", /* @__PURE__ */ new Map());
694
+ i(this, "subAgentInteractionServices", /* @__PURE__ */ new Map());
695
+ i(this, "lastThorttledTimeout", null);
696
+ i(this, "lastPingStatus", !1);
697
+ this.user = t, this.config = n, this.rawJwt = t.access_token, this.base_url = a, this.eventBusService = e, this.sessionId = d, this.runMode = u, this.artifactService = s, this.sessionState = r.getState(), this.notificationPort = l, this.storageService = c, r.subscribe((h, C) => {
832
698
  this.sessionState = h;
833
699
  });
834
700
  }
@@ -847,6 +713,12 @@ const Ut = 1200 * 1e3, P = class P {
847
713
  answerHumanTool(t, e) {
848
714
  return console.warn("answerHumanTool: not supported by this gateway", t, e), "queued";
849
715
  }
716
+ /**
717
+ * The agent this gateway speaks to — the ONE truth for the conversation.
718
+ * `sendMessageInternal` stamps every outbound frame's `AgentId` from it,
719
+ * and the session manager binds/rebinds against it. Fixed at construction;
720
+ * see {@link forceAgentContext} for the single exception (issue #59).
721
+ */
850
722
  getAgentContext() {
851
723
  return this.config;
852
724
  }
@@ -857,25 +729,28 @@ const Ut = 1200 * 1e3, P = class P {
857
729
  this.config = { ...this.config, model: t };
858
730
  }
859
731
  /**
860
- * Live update for the agent / customer slice of the gateway's
861
- * config. Mirrors {@link setModel}'s in-place pattern so the
862
- * next outgoing message — `sendMessageInternal` reads
863
- * `this.config.agentConfig?.id` directly at send time, see
864
- * `AgentGatewayWSAsync.sendMessageInternal` — picks up the new
865
- * id without rebuilding the gateway or tearing down the
866
- * WebSocket. This is what the host calls from the agent picker
867
- * so switching agents preserves the current session's
868
- * connection, chat history, and any in-flight stream state
869
- * instead of remounting `AiChatProvider` and losing them.
732
+ * Live update for the ordinary, non-identity slice of the context — the
733
+ * dataset/customer the same agent works over. No "force" needed: swapping
734
+ * datasets mid-conversation is routine and changes nothing about who is
735
+ * answering.
736
+ */
737
+ setCustomer(t) {
738
+ this.config = { ...this.config, customer: t };
739
+ }
740
+ /**
741
+ * Replace the AGENT mid-conversation. The escape hatch for an agent picker,
742
+ * and nothing else: the session already holds another agent's history, and
743
+ * the server stamps `Session.AgentId` on the first turn only — so the
744
+ * conversation keeps reporting the agent it STARTED as, however many times
745
+ * this is called. Prefer a new engine (new key, see `engineKeyFor`) per
746
+ * agent.
870
747
  *
871
- * Callers should pass the FULL replacement context (the same
872
- * shape they originally constructed the gateway with). The
873
- * gateway preserves the `model` slice from its current config
874
- * if the incoming context omits it — the model is owned
875
- * separately by `setModel` and shouldn't get clobbered by an
876
- * agent-only change.
748
+ * Callers pass the FULL replacement context (the same shape the gateway was
749
+ * constructed with). The `model` slice is preserved when the incoming
750
+ * context omits it — the model is owned separately by {@link setModel} and
751
+ * must not be clobbered by an agent-only change.
877
752
  */
878
- setAgentContext(t) {
753
+ forceAgentContext(t) {
879
754
  this.config = {
880
755
  ...t,
881
756
  model: t.model ?? this.config.model
@@ -900,11 +775,11 @@ const Ut = 1200 * 1e3, P = class P {
900
775
  if (e && this.currentIS)
901
776
  return this.currentIS.interaction.isSuspended = !1, this.currentIS.interaction.interactionQuestion += " + " + t, this.currentIS.interaction;
902
777
  this.msg_order += 1;
903
- let i = this.getNewInteractionId();
904
- s && (i = s);
778
+ let a = this.getNewInteractionId();
779
+ s && (a = s);
905
780
  let n = {
906
781
  created: /* @__PURE__ */ new Date(),
907
- interactionId: i,
782
+ interactionId: a,
908
783
  artifactData: [],
909
784
  partial: !0,
910
785
  sessionId: this.sessionId,
@@ -914,7 +789,7 @@ const Ut = 1200 * 1e3, P = class P {
914
789
  functionMap: /* @__PURE__ */ new Map(),
915
790
  interactionQuestion: t
916
791
  };
917
- return this.interactionsMap.set(n.interactionId, n), this.currentIS = new q(n, this.eventBusService), this.interactionsServiceMap.set(n.interactionId, this.currentIS), n;
792
+ return this.interactionsMap.set(n.interactionId, n), this.currentIS = new B(n, this.eventBusService), this.interactionsServiceMap.set(n.interactionId, this.currentIS), n;
918
793
  }
919
794
  getInteractions() {
920
795
  return Array.from(this.interactionsMap.values());
@@ -967,8 +842,8 @@ const Ut = 1200 * 1e3, P = class P {
967
842
  s ? (console.warn("GOT A running promise", t), e = s) : (e = this.artifactService.getArtifact(t), this.runningRequests.set(t, e));
968
843
  try {
969
844
  return await e;
970
- } catch (i) {
971
- return console.error("Error awating on HTML promise", i.toString()), null;
845
+ } catch (a) {
846
+ return console.error("Error awating on HTML promise", a.toString()), null;
972
847
  } finally {
973
848
  this.runningRequests.delete(t);
974
849
  }
@@ -984,8 +859,8 @@ const Ut = 1200 * 1e3, P = class P {
984
859
  return !1;
985
860
  }
986
861
  getOrCreateSubAgentInteraction(t, e, s) {
987
- let i = this.subAgentInteractions.get(t), n = this.subAgentInteractionServices.get(t);
988
- return (!i || !n) && (i = {
862
+ let a = this.subAgentInteractions.get(t), n = this.subAgentInteractionServices.get(t);
863
+ return (!a || !n) && (a = {
989
864
  created: /* @__PURE__ */ new Date(),
990
865
  interactionId: e,
991
866
  artifactData: [],
@@ -995,7 +870,7 @@ const Ut = 1200 * 1e3, P = class P {
995
870
  version: 0,
996
871
  functionMap: /* @__PURE__ */ new Map(),
997
872
  interactionQuestion: s ?? t
998
- }, n = new q(i, this.eventBusService), this.subAgentInteractions.set(t, i), this.subAgentInteractionServices.set(t, n)), { interaction: i, service: n };
873
+ }, n = new B(a, this.eventBusService), this.subAgentInteractions.set(t, a), this.subAgentInteractionServices.set(t, n)), { interaction: a, service: n };
999
874
  }
1000
875
  handleSubAgentEvent(t) {
1001
876
  const e = t.subAgentId, { service: s } = this.getOrCreateSubAgentInteraction(e, t.interactionId, t.subAgentName);
@@ -1006,10 +881,10 @@ const Ut = 1200 * 1e3, P = class P {
1006
881
  continue;
1007
882
  }
1008
883
  }
1009
- const i = s.merge(t);
1010
- if (!i) return;
884
+ const a = s.merge(t);
885
+ if (!a) return;
1011
886
  const n = t.turn_complete ?? !1;
1012
- this.sessionState.setSubAgentMessage(e, i.updatedInteraction, t.subAgentName), n && this.sessionState.completeSubAgent(e);
887
+ this.sessionState.setSubAgentMessage(e, a.updatedInteraction, t.subAgentName), n && this.sessionState.completeSubAgent(e);
1013
888
  }
1014
889
  async Message(t) {
1015
890
  try {
@@ -1046,21 +921,21 @@ const Ut = 1200 * 1e3, P = class P {
1046
921
  return;
1047
922
  }
1048
923
  this.localEmitMessage(s.updatedInteraction, s), e.turn_complete && this.turnComplete(e.interactionId, s.updatedInteraction, e.author, e.subAgentId), e.asyncFinalResponse && (e.turn_complete = !0, s.updatedInteraction.turn_complete == !0, this.finalResponse(e.interactionId, s.updatedInteraction, e.author, e.subAgentId));
1049
- const i = e.artifactsDelta;
1050
- i && i.forEach((n) => {
1051
- const r = s.updatedInteraction.artifactData.filter((o) => o.id == n);
924
+ const a = e.artifactsDelta;
925
+ a && a.forEach((n) => {
926
+ const r = s.updatedInteraction.artifactData.filter((c) => c.id == n);
1052
927
  let l = null;
1053
- r && r.length > 0 && (l = r[0], l.loadingPromise = this.asyncLoadArtifact(n).then((o) => (o === null ? console.error("Error trying to load artifact id:", l == null ? void 0 : l.id, "Artifact is null") : this.eventBusService.artifactEmitGenerated(o), o)).catch((o) => (console.error("Error trying to load artifact id:", l == null ? void 0 : l.id, o.toString()), null)));
928
+ r && r.length > 0 && (l = r[0], l.loadingPromise = this.asyncLoadArtifact(n).then((c) => (c === null ? console.error("Error trying to load artifact id:", l == null ? void 0 : l.id, "Artifact is null") : this.eventBusService.artifactEmitGenerated(c), c)).catch((c) => (console.error("Error trying to load artifact id:", l == null ? void 0 : l.id, c.toString()), null)));
1054
929
  });
1055
930
  }
1056
931
  } catch (e) {
1057
932
  if (this.getCurrentInteractionId()) {
1058
- const s = gt.createErrorEvent("OnMessage error: " + e.toString(), this.getCurrentInteractionId() ?? "Empty Current"), i = this.updateMap(s);
1059
- if (console.error("Error event: ", JSON.stringify(s, void 0, 4)), !i) {
933
+ const s = dt.createErrorEvent("OnMessage error: " + e.toString(), this.getCurrentInteractionId() ?? "Empty Current"), a = this.updateMap(s);
934
+ if (console.error("Error event: ", JSON.stringify(s, void 0, 4)), !a) {
1060
935
  console.error("Error event, could not update interaction: ", JSON.stringify(s, void 0, 4));
1061
936
  return;
1062
937
  }
1063
- this.localEmitMessage(i.updatedInteraction);
938
+ this.localEmitMessage(a.updatedInteraction);
1064
939
  }
1065
940
  }
1066
941
  }
@@ -1084,8 +959,8 @@ const Ut = 1200 * 1e3, P = class P {
1084
959
  this.sessionState.setCurrentMessage(t), this.lastCurrentMessageUpdate = e, this.pendingCurrentMessage = null, this.eventBusService.gatewayEmitMessage(t, s);
1085
960
  }
1086
961
  localEmitMessage(t, e) {
1087
- const s = (/* @__PURE__ */ new Date()).getTime(), i = s - this.lastCurrentMessageUpdate;
1088
- t.partial === !1 || i >= P.CURRENT_MSG_THROTTLE_MS ? (this.lastThorttledTimeout && (clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = null), this.doEmitMessage(t, s, e), this.pendingCurrentMessage = null) : (this.pendingCurrentMessage = t, this.lastThorttledTimeout && clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = setTimeout(() => {
962
+ const s = (/* @__PURE__ */ new Date()).getTime(), a = s - this.lastCurrentMessageUpdate;
963
+ t.partial === !1 || a >= P.CURRENT_MSG_THROTTLE_MS ? (this.lastThorttledTimeout && (clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = null), this.doEmitMessage(t, s, e), this.pendingCurrentMessage = null) : (this.pendingCurrentMessage = t, this.lastThorttledTimeout && clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = setTimeout(() => {
1089
964
  var r, l;
1090
965
  this.pendingCurrentMessage && (((r = this.pendingCurrentMessage) == null ? void 0 : r.version) ?? 0) > (((l = this.sessionState.currentMessage) == null ? void 0 : l.version) ?? 0) && (this.doEmitMessage(this.pendingCurrentMessage, s, e), this.lastThorttledTimeout = null);
1091
966
  }, P.CURRENT_MSG_THROTTLE_MS * 2));
@@ -1108,26 +983,26 @@ const Ut = 1200 * 1e3, P = class P {
1108
983
  cancelPendingCurrentMessage() {
1109
984
  this.lastThorttledTimeout && (clearTimeout(this.lastThorttledTimeout), this.lastThorttledTimeout = null), this.pendingCurrentMessage = null;
1110
985
  }
1111
- async turnComplete(t, e, s, i) {
986
+ async turnComplete(t, e, s, a) {
1112
987
  this.cancelPendingCurrentMessage(), this.sessionState.setNewMessage(e), this.eventBusService.gatewayEmitTurnComplete(t, e), this.interactionCallIds.delete(t), this.sessionState.setLastToolEvent(null), this.localEmitToolEvent({
1113
988
  eventName: "todolistUpdated",
1114
989
  eventData: "",
1115
- subAgentId: i
990
+ subAgentId: a
1116
991
  }), this.sessionState.setTurnOpen(!1);
1117
992
  }
1118
993
  async handlePing() {
1119
- return Date.now() - this.lastPing.getTime() > Ut ? await this.ping() ? (this.lastPing = /* @__PURE__ */ new Date(), this.lastPingStatus = !0, !0) : (this.lastPingStatus = !1, !1) : (this.lastPingStatus = !0, !0);
994
+ return Date.now() - this.lastPing.getTime() > Rt ? await this.ping() ? (this.lastPing = /* @__PURE__ */ new Date(), this.lastPingStatus = !0, !0) : (this.lastPingStatus = !1, !1) : (this.lastPingStatus = !0, !0);
1120
995
  }
1121
996
  async sendMessage(t, e) {
1122
- let s = this.getInteractions().length, i = _.createWaiting(!0, !0, "Overall", /* @__PURE__ */ new Date());
1123
- this.sendStatusMessage(t.data, [i], s.toString() + "1");
997
+ let s = this.getInteractions().length, a = N.createWaiting(!0, !0, "Overall", /* @__PURE__ */ new Date());
998
+ this.sendStatusMessage(t.data, [a], s.toString() + "1");
1124
999
  try {
1125
1000
  const { promptAsString: n, json: r } = this.sessionState.onRenderPrompt ? this.sessionState.onRenderPrompt(t.data) : { promptAsString: t.data, json: void 0 };
1126
1001
  this.sessionState.onRenderPrompt && (t.data = r, t.friendlyMessage = n);
1127
- const l = await this.sendMessageInternal(t, e), o = bt.createPrompt(n ?? "", (r == null ? void 0 : r.toString()) ?? {});
1128
- this.storageService.storePrompt(o);
1129
- const d = _.fromText("Planejando próximos passos");
1130
- return this.sendStatusMessage(t.data, [i, d], s.toString() + "1"), l != null && l.success ? this.eventBusService.ChatEmitMessageSent(t.data, l.interaction) : this.eventBusService.ChatEmitMessageError((l == null ? void 0 : l.error) ?? ""), l;
1002
+ const l = await this.sendMessageInternal(t, e), c = Nt.createPrompt(n ?? "", (r == null ? void 0 : r.toString()) ?? {});
1003
+ this.storageService.storePrompt(c);
1004
+ const d = N.fromText("Planejando próximos passos");
1005
+ return this.sendStatusMessage(t.data, [a, d], s.toString() + "1"), l != null && l.success ? this.eventBusService.ChatEmitMessageSent(t.data, l.interaction) : this.eventBusService.ChatEmitMessageError((l == null ? void 0 : l.error) ?? ""), l;
1131
1006
  } catch (n) {
1132
1007
  return this.eventBusService.ChatEmitMessageError((n == null ? void 0 : n.toString()) ?? ""), {
1133
1008
  success: !1,
@@ -1136,7 +1011,7 @@ const Ut = 1200 * 1e3, P = class P {
1136
1011
  created: /* @__PURE__ */ new Date(),
1137
1012
  interactionId: "",
1138
1013
  partial: !1,
1139
- parts: [_.fromError((n == null ? void 0 : n.toString()) ?? "")],
1014
+ parts: [N.fromError((n == null ? void 0 : n.toString()) ?? "")],
1140
1015
  version: 0
1141
1016
  }
1142
1017
  };
@@ -1144,6 +1019,9 @@ const Ut = 1200 * 1e3, P = class P {
1144
1019
  this.clearStatus();
1145
1020
  }
1146
1021
  }
1022
+ // `reset(user, config?)` is gone (issue #59): a fourth public door that took an
1023
+ // AgentContext, with one implementation that only ever threw. Rebuild the engine
1024
+ // instead — that is what "reset this conversation" means now.
1147
1025
  async check() {
1148
1026
  return !0;
1149
1027
  }
@@ -1154,8 +1032,8 @@ const Ut = 1200 * 1e3, P = class P {
1154
1032
  }
1155
1033
  sendStatusMessage(t, e, s) {
1156
1034
  var n, r;
1157
- let i;
1158
- ((r = (n = this.currentIS) == null ? void 0 : n.interaction) == null ? void 0 : r.turn_complete) === !1 ? (i = _t.cloneDeep(this.currentIS.interaction), i.parts.push(...e)) : i = {
1035
+ let a;
1036
+ ((r = (n = this.currentIS) == null ? void 0 : n.interaction) == null ? void 0 : r.turn_complete) === !1 ? (a = Pt.cloneDeep(this.currentIS.interaction), a.parts.push(...e)) : a = {
1159
1037
  interactionId: "tmp" + s,
1160
1038
  created: /* @__PURE__ */ new Date(),
1161
1039
  partial: !0,
@@ -1164,7 +1042,7 @@ const Ut = 1200 * 1e3, P = class P {
1164
1042
  parts: e,
1165
1043
  interactionQuestion: t,
1166
1044
  artifactData: []
1167
- }, this.localEmitMessage(i);
1045
+ }, this.localEmitMessage(a);
1168
1046
  }
1169
1047
  clearStatus() {
1170
1048
  }
@@ -1178,43 +1056,43 @@ const Ut = 1200 * 1e3, P = class P {
1178
1056
  }
1179
1057
  }
1180
1058
  getNewInteractionId() {
1181
- const e = Pt(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
1059
+ const e = At(/* @__PURE__ */ new Date(), "MMM_dd_HH_mm_ss");
1182
1060
  return `${this.msg_order}_${e}`;
1183
1061
  }
1184
1062
  };
1185
- g(P, "AgentGatewayService"), a(P, "SUSPENSION_MSG", "SUSPEND"), a(P, "CURRENT_MSG_THROTTLE_MS", 20);
1186
- let H = P;
1187
- const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2, ht = 2, V = class V {
1063
+ f(P, "AgentGatewayService"), i(P, "SUSPENSION_MSG", "SUSPEND"), i(P, "CURRENT_MSG_THROTTLE_MS", 20);
1064
+ let G = P;
1065
+ const H = 4001, Ft = 4002, ot = 4, Lt = 3, Ut = 500, xt = 3e4, Bt = 2, Wt = 0.2, ct = 2, Q = class Q {
1188
1066
  constructor(t = "ws://localhost:8000", e) {
1189
- a(this, "ws", null);
1190
- a(this, "stats");
1191
- a(this, "baseUrl");
1067
+ i(this, "ws", null);
1068
+ i(this, "stats");
1069
+ i(this, "baseUrl");
1192
1070
  /**
1193
1071
  * Optional callback that returns the current JWT. We re-evaluate it on every connect/reconnect
1194
1072
  * so that a refreshed token is picked up automatically. Browsers can't set the Authorization
1195
1073
  * header on the WebSocket handshake, so we pass the JWT via the ?access_token= query string,
1196
1074
  * which the .NET JwtBearer events handler reads in Program.cs.
1197
1075
  */
1198
- a(this, "getToken");
1199
- a(this, "onEvent");
1200
- a(this, "onError");
1201
- a(this, "onOpen");
1202
- a(this, "onFirstToken");
1203
- a(this, "onSuspended");
1204
- a(this, "onPong");
1205
- a(this, "onClose");
1076
+ i(this, "getToken");
1077
+ i(this, "onEvent");
1078
+ i(this, "onError");
1079
+ i(this, "onOpen");
1080
+ i(this, "onFirstToken");
1081
+ i(this, "onSuspended");
1082
+ i(this, "onPong");
1083
+ i(this, "onClose");
1206
1084
  /** Fired when an unexpected close triggers a reconnect attempt. */
1207
- a(this, "onReconnecting");
1085
+ i(this, "onReconnecting");
1208
1086
  /** Fired the first time the socket reopens after an unexpected close. */
1209
- a(this, "onReconnected");
1087
+ i(this, "onReconnected");
1210
1088
  /**
1211
1089
  * Fired when the server signals that we lost streaming events on resume — our
1212
1090
  * `lastSeq` fell off the end of the in-memory replay buffer. Consumers should
1213
1091
  * reset partial-streaming UI for this session and rely on persisted history.
1214
1092
  */
1215
- a(this, "onRewindLost");
1216
- a(this, "sessionId");
1217
- a(this, "onNewPacket");
1093
+ i(this, "onRewindLost");
1094
+ i(this, "sessionId");
1095
+ i(this, "onNewPacket");
1218
1096
  /**
1219
1097
  * Stats can fire dozens of times per second during streaming. We
1220
1098
  * coalesce to a fixed cadence so subscribers see steady,
@@ -1225,33 +1103,33 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1225
1103
  * on every packet, with their useEffect-driven setStates pushing
1226
1104
  * React's nested-update counter past its threshold).
1227
1105
  */
1228
- a(this, "statsFlushTimer", null);
1229
- a(this, "statsLastFlushed", 0);
1230
- a(this, "STATS_FLUSH_MS", 120);
1231
- a(this, "monitorInterval", null);
1232
- a(this, "streamingResponseSerializer");
1233
- a(this, "events");
1234
- a(this, "lastActivity");
1235
- a(this, "pingPongStack");
1236
- a(this, "firstTokenInteractions");
1106
+ i(this, "statsFlushTimer", null);
1107
+ i(this, "statsLastFlushed", 0);
1108
+ i(this, "STATS_FLUSH_MS", 120);
1109
+ i(this, "monitorInterval", null);
1110
+ i(this, "streamingResponseSerializer");
1111
+ i(this, "events");
1112
+ i(this, "lastActivity");
1113
+ i(this, "pingPongStack");
1114
+ i(this, "firstTokenInteractions");
1237
1115
  /** Last sessionId we successfully had — used to resume on reconnect. */
1238
- a(this, "lastKnownSessionId");
1116
+ i(this, "lastKnownSessionId");
1239
1117
  /** True when the consumer called `disconnect()` — suppresses auto-reconnect. */
1240
- a(this, "intentionalDisconnect", !1);
1118
+ i(this, "intentionalDisconnect", !1);
1241
1119
  /** Number of reconnect attempts since the last clean open. */
1242
- a(this, "reconnectAttempts", 0);
1243
- a(this, "reconnectTimer", null);
1120
+ i(this, "reconnectAttempts", 0);
1121
+ i(this, "reconnectTimer", null);
1244
1122
  /** True while we are in the middle of an unexpected-close → reconnect cycle. */
1245
- a(this, "isReconnecting", !1);
1123
+ i(this, "isReconnecting", !1);
1246
1124
  /** Internal flag set by `scheduleReconnect` so `connect()` does not reset the backoff state. */
1247
- a(this, "_internalReconnect", !1);
1125
+ i(this, "_internalReconnect", !1);
1248
1126
  /**
1249
1127
  * Highest server-assigned `seq` we have observed and processed. The next
1250
1128
  * reconnect appends `?lastSeq={lastSeq}` so the server can replay anything
1251
1129
  * we missed from the InteractionRun's in-memory buffer. -1 means "haven't
1252
1130
  * seen any sequenced events yet" (fresh connection).
1253
1131
  */
1254
- a(this, "lastSeq", -1);
1132
+ i(this, "lastSeq", -1);
1255
1133
  /**
1256
1134
  * Parked-tool answers that could not be sent because the socket was not OPEN
1257
1135
  * (e.g. the connection idled out while the user was in an IdP sign-in popup).
@@ -1260,7 +1138,7 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1260
1138
  * answer for a session this instance is no longer attached to is dropped —
1261
1139
  * the single-attach policy makes it undeliverable from here anyway.
1262
1140
  */
1263
- a(this, "pendingAnswers", []);
1141
+ i(this, "pendingAnswers", []);
1264
1142
  /**
1265
1143
  * True once *any* socket on this instance has received at least one packet.
1266
1144
  * Used by `onclose` to distinguish a real mid-stream drop (we had a working
@@ -1273,8 +1151,8 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1273
1151
  * when a replacement socket fails before delivering its first message.
1274
1152
  * Cleared by `disconnect()`.
1275
1153
  */
1276
- a(this, "hasEverReceivedPacket", !1);
1277
- this.baseUrl = t, this.getToken = e, this.pingPongStack = [], this.events = [], this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = Ct(), console.log("SOCKET INSTACE", It()), this.stats = {
1154
+ i(this, "hasEverReceivedPacket", !1);
1155
+ this.baseUrl = t, this.getToken = e, this.pingPongStack = [], this.events = [], this.firstTokenInteractions = /* @__PURE__ */ new Set(), this.streamingResponseSerializer = yt(), console.log("SOCKET INSTACE", wt()), this.stats = {
1278
1156
  eventCount: 0,
1279
1157
  unknonwCount: 0,
1280
1158
  buffer: [],
@@ -1296,14 +1174,14 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1296
1174
  * silently, because the transcript looked intact right up to the gap.
1297
1175
  */
1298
1176
  connect(t, e) {
1299
- return new Promise(async (s, i) => {
1300
- var F;
1177
+ return new Promise(async (s, a) => {
1178
+ var b;
1301
1179
  this.intentionalDisconnect = !1;
1302
1180
  const n = this._internalReconnect || (e == null ? void 0 : e.resume) === !0;
1303
1181
  n || (this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.lastSeq = -1), this._internalReconnect = !1;
1304
- const r = (F = this.getToken) == null ? void 0 : F.call(this), l = [];
1182
+ const r = (b = this.getToken) == null ? void 0 : b.call(this), l = [];
1305
1183
  r && l.push(`access_token=${encodeURIComponent(r)}`), t && this.lastSeq >= 0 && l.push(`lastSeq=${this.lastSeq}`);
1306
- const o = l.length > 0 ? `?${l.join("&")}` : "", d = this.baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"), u = `${d}/ws/connect/${t ?? ""}${o}`, h = `${d}/ws/connect/${t ?? ""}` + (n && t && this.lastSeq >= 0 ? ` (resume lastSeq=${this.lastSeq})` : "");
1184
+ const c = l.length > 0 ? `?${l.join("&")}` : "", d = this.baseUrl.replace(/^http:\/\//, "ws://").replace(/^https:\/\//, "wss://"), u = `${d}/ws/connect/${t ?? ""}${c}`, h = `${d}/ws/connect/${t ?? ""}` + (n && t && this.lastSeq >= 0 ? ` (resume lastSeq=${this.lastSeq})` : "");
1307
1185
  if (console.log("Connecting to ", h), this.ws) {
1308
1186
  this.ws.onopen = null, this.ws.onmessage = null, this.ws.onerror = null, this.ws.onclose = null;
1309
1187
  try {
@@ -1321,50 +1199,50 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1321
1199
  }, this.ws.onmessage = (y) => {
1322
1200
  try {
1323
1201
  this.lastActivity = (/* @__PURE__ */ new Date()).getTime();
1324
- const A = this.streamingResponseSerializer.parse(y.data);
1325
- if (!A)
1202
+ const O = this.streamingResponseSerializer.parse(y.data);
1203
+ if (!O)
1326
1204
  throw "Error parsing event JSON";
1327
- const N = this.handleMessage(A, y.data);
1328
- !C && (N != null && N.timestamp) && (C = !0, this.hasEverReceivedPacket = !0);
1329
- } catch (A) {
1330
- console.error("[WebSocket] Error parsing message:", A);
1205
+ const A = this.handleMessage(O, y.data);
1206
+ !C && (A != null && A.timestamp) && (C = !0, this.hasEverReceivedPacket = !0);
1207
+ } catch (O) {
1208
+ console.error("[WebSocket] Error parsing message:", O);
1331
1209
  }
1332
1210
  }, this.ws.onerror = (y) => {
1333
1211
  console.error("[WebSocket] Error:", y), this.onError && this.onError("WebSocket error");
1334
1212
  }, this.ws.onclose = (y) => {
1335
1213
  console.log("[WebSocket] Closed:", y.code, y.reason), this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [];
1336
- const A = this.sessionId ?? this.lastKnownSessionId;
1214
+ const O = this.sessionId ?? this.lastKnownSessionId;
1337
1215
  if (this.sessionId = void 0, (C || this.hasEverReceivedPacket) && this.shouldAttemptReconnect(y.code)) {
1338
- this.scheduleReconnect(A, y.code, y.reason);
1216
+ this.scheduleReconnect(O, y.code, y.reason);
1339
1217
  return;
1340
1218
  }
1341
1219
  this.isReconnecting = !1, this.reconnectAttempts = 0, this.onClose && this.onClose(y.code, y.reason);
1342
1220
  };
1343
- const p = 200, O = 3e4, M = 8e3, v = this.ws;
1221
+ const p = 200, M = 3e4, w = 8e3, I = this.ws;
1344
1222
  this.sessionId = void 0;
1345
- let k = 0, b = 0;
1223
+ let k = 0, _ = 0;
1346
1224
  for (; !this.sessionId; ) {
1347
- if (this.ws !== v) {
1348
- i("Connection attempt superseded by a newer connect()");
1225
+ if (this.ws !== I) {
1226
+ a("Connection attempt superseded by a newer connect()");
1349
1227
  return;
1350
1228
  }
1351
- if (v.readyState === WebSocket.CLOSING || v.readyState === WebSocket.CLOSED) {
1352
- i("Connection closed before a session id was received");
1229
+ if (I.readyState === WebSocket.CLOSING || I.readyState === WebSocket.CLOSED) {
1230
+ a("Connection closed before a session id was received");
1353
1231
  return;
1354
1232
  }
1355
- if (v.readyState === WebSocket.CONNECTING && k >= O) {
1233
+ if (I.readyState === WebSocket.CONNECTING && k >= M) {
1356
1234
  try {
1357
- v.close();
1235
+ I.close();
1358
1236
  } catch {
1359
1237
  }
1360
- i(`Server did not accept the connection within ${O / 1e3}s`);
1238
+ a(`Server did not accept the connection within ${M / 1e3}s`);
1361
1239
  return;
1362
1240
  }
1363
- if (v.readyState === WebSocket.OPEN && b >= M) {
1364
- i(`Connected but no session id arrived within ${M / 1e3}s`);
1241
+ if (I.readyState === WebSocket.OPEN && _ >= w) {
1242
+ a(`Connected but no session id arrived within ${w / 1e3}s`);
1365
1243
  return;
1366
1244
  }
1367
- k % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(p), k += p, v.readyState === WebSocket.OPEN && (b += p);
1245
+ k % 2e3 === 0 && console.log("Aguardando session Id"), await this.sleep(p), k += p, I.readyState === WebSocket.OPEN && (_ += p);
1368
1246
  }
1369
1247
  console.log("SUCCESS - GOT SESSION ID", this.sessionId), this.lastKnownSessionId = this.sessionId, s(this.sessionId);
1370
1248
  });
@@ -1379,36 +1257,36 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1379
1257
  * - 4000-4099 reserved for app-level fatal codes from the server
1380
1258
  */
1381
1259
  shouldAttemptReconnect(t) {
1382
- return !(this.intentionalDisconnect || t === K || t === Lt || t === 1e3 || t === 1008);
1260
+ return !(this.intentionalDisconnect || t === H || t === Ft || t === 1e3 || t === 1008);
1383
1261
  }
1384
1262
  cancelPendingReconnect() {
1385
1263
  this.reconnectTimer && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
1386
1264
  }
1387
1265
  computeBackoffDelay() {
1388
- const t = Bt * Math.pow($t, this.reconnectAttempts), e = Math.min(t, Wt), s = e * qt * (Math.random() * 2 - 1);
1266
+ const t = Ut * Math.pow(Bt, this.reconnectAttempts), e = Math.min(t, xt), s = e * Wt * (Math.random() * 2 - 1);
1389
1267
  return Math.max(0, Math.round(e + s));
1390
1268
  }
1391
1269
  scheduleReconnect(t, e, s) {
1392
1270
  var n, r;
1393
1271
  if (this.intentionalDisconnect) return;
1394
- if (this.reconnectAttempts >= ht) {
1272
+ if (this.reconnectAttempts >= ct) {
1395
1273
  console.warn(
1396
1274
  `[WebSocket] Reconnect exhausted after ${this.reconnectAttempts} attempts (last code=${e}, reason="${s}"). Handing off to outer state manager.`
1397
1275
  ), this.isReconnecting = !1, this.reconnectAttempts = 0, this.cancelPendingReconnect(), (n = this.onClose) == null || n.call(this, e, s);
1398
1276
  return;
1399
1277
  }
1400
1278
  this.isReconnecting = !0, this.reconnectAttempts += 1;
1401
- const i = this.computeBackoffDelay();
1279
+ const a = this.computeBackoffDelay();
1402
1280
  console.warn(
1403
- `[WebSocket] Unexpected close (code=${e}, reason="${s}"). Reconnect attempt #${this.reconnectAttempts}/${ht} in ${i}ms (resume sessionId=${t ?? "none"}).`
1404
- ), (r = this.onReconnecting) == null || r.call(this, this.reconnectAttempts, i), this.cancelPendingReconnect(), this.reconnectTimer = setTimeout(async () => {
1281
+ `[WebSocket] Unexpected close (code=${e}, reason="${s}"). Reconnect attempt #${this.reconnectAttempts}/${ct} in ${a}ms (resume sessionId=${t ?? "none"}).`
1282
+ ), (r = this.onReconnecting) == null || r.call(this, this.reconnectAttempts, a), this.cancelPendingReconnect(), this.reconnectTimer = setTimeout(async () => {
1405
1283
  if (this.reconnectTimer = null, !this.intentionalDisconnect)
1406
1284
  try {
1407
1285
  this.ws && (this.ws.onopen = null, this.ws.onmessage = null, this.ws.onerror = null, this.ws.onclose = null, this.ws = null), this._internalReconnect = !0, await this.connect(t);
1408
1286
  } catch (l) {
1409
1287
  console.error("[WebSocket] Reconnect attempt failed:", l);
1410
1288
  }
1411
- }, i);
1289
+ }, a);
1412
1290
  }
1413
1291
  async sleep(t) {
1414
1292
  return new Promise((e) => setTimeout(e, t));
@@ -1417,7 +1295,7 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1417
1295
  * Handle incoming messages from server
1418
1296
  */
1419
1297
  handleMessage(t, e) {
1420
- var l, o, d;
1298
+ var l, c, d;
1421
1299
  switch (typeof t.seq == "number" && t.seq > this.lastSeq && (this.lastSeq = t.seq), t.type) {
1422
1300
  case "Pong":
1423
1301
  if (this.sessionId = t.sessionId, this.lastKnownSessionId = t.sessionId ?? this.lastKnownSessionId, !t.sessionId) {
@@ -1444,33 +1322,33 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1444
1322
  this.emitFirstToken(u == null ? void 0 : u.iteractionId);
1445
1323
  const h = new vt();
1446
1324
  if (h.author = "main", h.streamingParts = t.partialEvent.streamingParts, t.partialEvent.partialEventType ? h.eventType = t.partialEvent.partialEventType : h.eventType = u.functionName ? {
1447
- fullName: B.StreamingFunctionCallUpdateContent,
1448
- type: I.PartialFunctionCall
1325
+ fullName: L.StreamingFunctionCallUpdateContent,
1326
+ type: T.PartialFunctionCall
1449
1327
  } : u.partialReasoning ? {
1450
- fullName: B.StreamingReasoningContent,
1451
- type: I.Thought
1328
+ fullName: L.StreamingReasoningContent,
1329
+ type: T.Thought
1452
1330
  } : {
1453
- fullName: B.StreamingTextContent,
1454
- type: I.Text
1455
- }, h.interactionId = (u == null ? void 0 : u.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type == I.PartialFunctionCall) {
1456
- var s = new Et();
1331
+ fullName: L.StreamingTextContent,
1332
+ type: T.Text
1333
+ }, h.interactionId = (u == null ? void 0 : u.iteractionId) ?? "", h.mimeType = "text/plain", h.partial = !0, h.eventType.type == T.PartialFunctionCall) {
1334
+ var s = new Ct();
1457
1335
  s.choiceIndex = 0, s.callId = u.functionCallId, s.arguments = u.partialText, s.name = u.functionName, h.content = {
1458
1336
  items: [s],
1459
1337
  role: {
1460
1338
  label: "Assistant"
1461
1339
  }
1462
1340
  };
1463
- } else if (h.eventType.type == I.Text)
1464
- if (h.eventType.fullName == B.StreamingTextContent) {
1465
- var i = new Mt();
1466
- i.text = u.partialText, h.content = {
1467
- items: [i],
1341
+ } else if (h.eventType.type == T.Text)
1342
+ if (h.eventType.fullName == L.StreamingTextContent) {
1343
+ var a = new It();
1344
+ a.text = u.partialText, h.content = {
1345
+ items: [a],
1468
1346
  role: {
1469
1347
  label: "Assistant"
1470
1348
  }
1471
1349
  };
1472
1350
  } else {
1473
- var n = new Dt();
1351
+ var n = new Et();
1474
1352
  n.text = u.partialText, h.content = {
1475
1353
  items: [n],
1476
1354
  role: {
@@ -1478,8 +1356,8 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1478
1356
  }
1479
1357
  };
1480
1358
  }
1481
- else if (h.eventType.type == I.Thought) {
1482
- var r = new Ot();
1359
+ else if (h.eventType.type == T.Thought) {
1360
+ var r = new Mt();
1483
1361
  r.text = u.partialReasoning, h.content = {
1484
1362
  items: [r],
1485
1363
  role: {
@@ -1492,7 +1370,7 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1492
1370
  label: "Assistant"
1493
1371
  }, h.timestamp = (u == null ? void 0 : u.timeStamp) ?? (/* @__PURE__ */ new Date()).getTime(), h.turnComplete = !1, t.event = h, t.partialEvent = void 0;
1494
1372
  }
1495
- return t.event ? (t.subAgentId && (t.event.subAgentId = t.subAgentId, t.event.subAgentName = t.subAgentName), ((((o = (l = t.event.content) == null ? void 0 : l.items) == null ? void 0 : o.length) ?? 0) > 0 || (((d = t.event.streamingParts) == null ? void 0 : d.length) ?? 0) > 0) && this.emitFirstToken(t.event.interactionId), this.handleEvent(t.event, e), t.event) : null;
1373
+ return t.event ? (t.subAgentId && (t.event.subAgentId = t.subAgentId, t.event.subAgentName = t.subAgentName), ((((c = (l = t.event.content) == null ? void 0 : l.items) == null ? void 0 : c.length) ?? 0) > 0 || (((d = t.event.streamingParts) == null ? void 0 : d.length) ?? 0) > 0) && this.emitFirstToken(t.event.interactionId), this.handleEvent(t.event, e), t.event) : null;
1496
1374
  }
1497
1375
  emitFirstToken(t) {
1498
1376
  var e;
@@ -1528,9 +1406,9 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1528
1406
  console.warn("[WebSocket] WS-refreshed token received but no stored user — dropping");
1529
1407
  return;
1530
1408
  }
1531
- const i = JSON.parse(s);
1532
- if ((i == null ? void 0 : i.access_token) === t) return;
1533
- i.access_token = t, localStorage.setItem(e, JSON.stringify(i)), console.info("[WebSocket] Mirrored WS-refreshed JWT into stored user");
1409
+ const a = JSON.parse(s);
1410
+ if ((a == null ? void 0 : a.access_token) === t) return;
1411
+ a.access_token = t, localStorage.setItem(e, JSON.stringify(a)), console.info("[WebSocket] Mirrored WS-refreshed JWT into stored user");
1534
1412
  } catch (s) {
1535
1413
  console.error("[WebSocket] Failed to persist WS-refreshed token", s);
1536
1414
  }
@@ -1540,7 +1418,7 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1540
1418
  }
1541
1419
  suspendStream() {
1542
1420
  this.sendBaseMessage({
1543
- Action: W.Suspend,
1421
+ Action: U.Suspend,
1544
1422
  AgentId: "",
1545
1423
  InteractionId: "",
1546
1424
  ModelId: ""
@@ -1559,7 +1437,7 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1559
1437
  */
1560
1438
  answerHumanTool(t, e) {
1561
1439
  const s = {
1562
- Action: W.AnswerHumanTool,
1440
+ Action: U.AnswerHumanTool,
1563
1441
  AgentId: "",
1564
1442
  InteractionId: "",
1565
1443
  ToolCallId: t,
@@ -1586,7 +1464,7 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1586
1464
  }
1587
1465
  try {
1588
1466
  this.sendBaseMessage({
1589
- Action: W.AnswerHumanTool,
1467
+ Action: U.AnswerHumanTool,
1590
1468
  AgentId: "",
1591
1469
  InteractionId: "",
1592
1470
  ToolCallId: s.toolCallId,
@@ -1615,10 +1493,10 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1615
1493
  const t = this, e = this.pingPongStack, s = 3e4;
1616
1494
  this.monitorInterval = setInterval(() => {
1617
1495
  try {
1618
- const i = (/* @__PURE__ */ new Date()).getTime() - this.lastActivity;
1619
- t.isConnected() && i >= s - 200 && (e.length > 0 && console.warn("Ping pong stack broke here, on pinging"), e.push((/* @__PURE__ */ new Date()).getTime()), t.ping());
1620
- } catch (i) {
1621
- console.error("Error on monitor", i);
1496
+ const a = (/* @__PURE__ */ new Date()).getTime() - this.lastActivity;
1497
+ t.isConnected() && a >= s - 200 && (e.length > 0 && console.warn("Ping pong stack broke here, on pinging"), e.push((/* @__PURE__ */ new Date()).getTime()), t.ping());
1498
+ } catch (a) {
1499
+ console.error("Error on monitor", a);
1622
1500
  }
1623
1501
  }, s);
1624
1502
  }
@@ -1637,7 +1515,7 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1637
1515
  * Disconnect the WebSocket
1638
1516
  */
1639
1517
  disconnect() {
1640
- console.warn("Chamou DISCONNECT!!!"), this.intentionalDisconnect = !0, this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [], this.firstTokenInteractions.clear(), this.lastKnownSessionId = void 0, this.lastSeq = -1, this.hasEverReceivedPacket = !1, this.ws && (this.ws.close(K, "Intentional disconnect"), this.ws = null);
1518
+ console.warn("Chamou DISCONNECT!!!"), this.intentionalDisconnect = !0, this.cancelPendingReconnect(), this.isReconnecting = !1, this.reconnectAttempts = 0, this.monitorInterval && (clearInterval(this.monitorInterval), this.monitorInterval = null), this.pingPongStack = [], this.firstTokenInteractions.clear(), this.lastKnownSessionId = void 0, this.lastSeq = -1, this.hasEverReceivedPacket = !1, this.ws && (this.ws.close(H, "Intentional disconnect"), this.ws = null);
1641
1519
  }
1642
1520
  /**
1643
1521
  * Check if connected
@@ -1666,40 +1544,40 @@ const K = 4001, Lt = 4002, lt = 4, xt = 3, Bt = 500, Wt = 3e4, $t = 2, qt = 0.2,
1666
1544
  async handleEvent(t, e) {
1667
1545
  var s;
1668
1546
  try {
1669
- const i = gt.parseFromTypedEvent(t);
1670
- if (!i)
1547
+ const a = dt.parseFromTypedEvent(t);
1548
+ if (!a)
1671
1549
  throw "Server event was null";
1672
- this.events.push([(/* @__PURE__ */ new Date()).getTime(), ((s = t.text) == null ? void 0 : s.length) ?? 0]), this.stats.eventCount += 1, this.stats.totalTransfered += e.length, i.session_information && !i.subAgentId && (this.stats.sessionInformation = i.session_information), this.stats.elapsed = (Date.now() - this.stats.startTime.getTime()) / 1e3;
1673
- const n = Date.now() - lt * 1e3, l = this.events.filter((o) => o[0] > n).reduce((o, d) => o += d[1], 0) / xt;
1674
- this.stats.tokensPerSecond = l / lt, this.flushStatsCoalesced(), this.onEvent && this.onEvent(i).catch((o) => {
1675
- console.error("Lost error on on-event", o);
1550
+ this.events.push([(/* @__PURE__ */ new Date()).getTime(), ((s = t.text) == null ? void 0 : s.length) ?? 0]), this.stats.eventCount += 1, this.stats.totalTransfered += e.length, a.session_information && !a.subAgentId && (this.stats.sessionInformation = a.session_information), this.stats.elapsed = (Date.now() - this.stats.startTime.getTime()) / 1e3;
1551
+ const n = Date.now() - ot * 1e3, l = this.events.filter((c) => c[0] > n).reduce((c, d) => c += d[1], 0) / Lt;
1552
+ this.stats.tokensPerSecond = l / ot, this.flushStatsCoalesced(), this.onEvent && this.onEvent(a).catch((c) => {
1553
+ console.error("Lost error on on-event", c);
1676
1554
  });
1677
- } catch (i) {
1678
- console.error("handleEvent error", i);
1555
+ } catch (a) {
1556
+ console.error("handleEvent error", a);
1679
1557
  }
1680
1558
  }
1681
1559
  };
1682
- g(V, "WebSocketConnecionV2");
1683
- let ut = V;
1684
- const Jt = "envision_agent_sessionId", tt = class tt extends H {
1685
- constructor(e, s, i, n, r, l, o, d, u, h, C) {
1686
- super(e, s, i, n, r, l, o, u, C);
1687
- a(this, "suspendState", !1);
1688
- a(this, "wsService");
1689
- a(this, "root_url", "");
1690
- a(this, "hearBeatPort");
1691
- a(this, "connectionAttempts", 0);
1560
+ f(Q, "WebSocketConnecionV2");
1561
+ let lt = Q;
1562
+ const $t = "envision_agent_sessionId", Z = class Z extends G {
1563
+ constructor(e, s, a, n, r, l, c, d, u, h, C) {
1564
+ super(e, s, a, n, r, l, c, u, C);
1565
+ i(this, "suspendState", !1);
1566
+ i(this, "wsService");
1567
+ i(this, "root_url", "");
1568
+ i(this, "hearBeatPort");
1569
+ i(this, "connectionAttempts", 0);
1692
1570
  /**
1693
1571
  * True once a WS has successfully opened at least once in this gateway's
1694
1572
  * lifetime. Gates the "Reiniciando a conexão" toast: a drop of a working
1695
1573
  * connection is worth telling the user about, a failed initial dial is not
1696
1574
  * (the Connecting state already covers it).
1697
1575
  */
1698
- a(this, "everConnected", !1);
1699
- a(this, "statuses", ["CONNECTING", "OPEN", "CLOSED", "UNKNOWN"]);
1700
- a(this, "lastConnectionPromise", null);
1701
- a(this, "socketState", U.Disconnected);
1702
- a(this, "streamOpened", !1);
1576
+ i(this, "everConnected", !1);
1577
+ i(this, "statuses", ["CONNECTING", "OPEN", "CLOSED", "UNKNOWN"]);
1578
+ i(this, "lastConnectionPromise", null);
1579
+ i(this, "socketState", F.Disconnected);
1580
+ i(this, "streamOpened", !1);
1703
1581
  this.hearBeatPort = h, this.root_url = this.base_url, this.wsService = d, this.wsService.onEvent = async (p) => {
1704
1582
  await super.Message(p);
1705
1583
  }, this.wsService.onNewPacket = (p) => {
@@ -1707,7 +1585,7 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1707
1585
  }, this.wsService.onPong = (p) => {
1708
1586
  }, this.wsService.onError = (p) => {
1709
1587
  this.streamOpened = !1;
1710
- const O = {
1588
+ const M = {
1711
1589
  data: this.getErrorEvent(p),
1712
1590
  lastEventId: (/* @__PURE__ */ new Date()).getTime().toString(),
1713
1591
  origin: "gatewayService"
@@ -1715,20 +1593,17 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1715
1593
  console.error("Stream error:", p), this.everConnected && this.notificationPort.pushNotification({
1716
1594
  message: "Reiniciando a conexão com o servidor",
1717
1595
  type: "info"
1718
- }), super.Message(O);
1596
+ }), super.Message(M);
1719
1597
  }, this.wsService.onOpen = () => {
1720
- this.everConnected = !0, this.sessionState.setConnectionStatus(U.Connected);
1598
+ this.everConnected = !0, this.sessionState.setConnectionStatus(F.Connected);
1721
1599
  }, this.wsService.onReconnected = (p) => {
1722
- this.sessionState.setConnectionStatus(U.Connected);
1600
+ this.sessionState.setConnectionStatus(F.Connected);
1723
1601
  }, this.wsService.onFirstToken = (p) => {
1724
1602
  this.localEmitFirstToken(p);
1725
- }, this.wsService.onClose = (p, O) => {
1726
- p != K && this.sessionState.setConnectionStatus(U.Disconnected);
1603
+ }, this.wsService.onClose = (p, M) => {
1604
+ p != H && this.sessionState.setConnectionStatus(F.Disconnected);
1727
1605
  };
1728
1606
  }
1729
- reset(e, s) {
1730
- throw new Error("Method not implemented.");
1731
- }
1732
1607
  startStream(e) {
1733
1608
  throw new Error("Method not implemented.");
1734
1609
  }
@@ -1736,7 +1611,7 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1736
1611
  return this.suspendState;
1737
1612
  }
1738
1613
  getStoredSessionId() {
1739
- const e = localStorage.getItem(Jt);
1614
+ const e = localStorage.getItem($t);
1740
1615
  if (e)
1741
1616
  return e;
1742
1617
  }
@@ -1748,15 +1623,15 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1748
1623
  const s = this.interactionsMap.get(e);
1749
1624
  return s == null ? void 0 : s.turn_complete;
1750
1625
  }
1751
- async finalResponse(e, s, i) {
1752
- super.turnComplete(e, s, i);
1626
+ async finalResponse(e, s, a) {
1627
+ super.turnComplete(e, s, a);
1753
1628
  }
1754
1629
  stopStream(e = !0) {
1755
1630
  e && this.sessionState.setTurnOpen(!1), this.wsService && this.wsService.closeStream();
1756
1631
  }
1757
1632
  async suspend() {
1758
1633
  const e = this.wsService;
1759
- return new Promise(async (i, n) => {
1634
+ return new Promise(async (a, n) => {
1760
1635
  let r = !1;
1761
1636
  e.onSuspended = () => {
1762
1637
  r = !0;
@@ -1768,7 +1643,7 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1768
1643
  if (r)
1769
1644
  if (this.currentIS) {
1770
1645
  const u = this.currentIS.interaction;
1771
- u.isSuspended = !0, this.sessionState.setCurrentMessage(u), this.sessionState.setTurnOpen(!1), i(!0);
1646
+ u.isSuspended = !0, this.sessionState.setCurrentMessage(u), this.sessionState.setTurnOpen(!1), a(!0);
1772
1647
  } else
1773
1648
  console.error("CurrentIS is null"), n("CurrentIS is null");
1774
1649
  else
@@ -1787,8 +1662,8 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1787
1662
  */
1788
1663
  answerHumanTool(e, s) {
1789
1664
  var n;
1790
- const i = (n = this.wsService.answerHumanTool) == null ? void 0 : n.bind(this.wsService);
1791
- return i ? i(e, s) : (console.warn("[AgentGateway] transport cannot deliver parked-tool answers", e), "queued");
1665
+ const a = (n = this.wsService.answerHumanTool) == null ? void 0 : n.bind(this.wsService);
1666
+ return a ? a(e, s) : (console.warn("[AgentGateway] transport cannot deliver parked-tool answers", e), "queued");
1792
1667
  }
1793
1668
  async cancelSuspend() {
1794
1669
  var s;
@@ -1799,9 +1674,9 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1799
1674
  return !0;
1800
1675
  }
1801
1676
  async openConnection(e, s) {
1802
- return this.lastConnectionPromise ? this.lastConnectionPromise : this.socketState == U.Disconnected ? (this.lastConnectionPromise = new Promise((i, n) => {
1677
+ return this.lastConnectionPromise ? this.lastConnectionPromise : this.socketState == F.Disconnected ? (this.lastConnectionPromise = new Promise((a, n) => {
1803
1678
  this.wsService.connect(e, s).then((r) => {
1804
- this.sessionId = r, i(r);
1679
+ this.sessionId = r, a(r);
1805
1680
  }).catch((r) => {
1806
1681
  n(r);
1807
1682
  }).finally(() => {
@@ -1823,28 +1698,28 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1823
1698
  }
1824
1699
  }
1825
1700
  simulateDisconnect(e = 4500, s = "Debug simulated disconnect") {
1826
- const i = this.wsService;
1827
- i != null && i.ws && i.ws.close(e, s);
1701
+ const a = this.wsService;
1702
+ a != null && a.ws && a.ws.close(e, s);
1828
1703
  }
1829
1704
  async sleep(e) {
1830
1705
  return new Promise((s) => setTimeout(s, e));
1831
1706
  }
1832
1707
  // Send a message to the server via HTTP POST
1833
- async sendMessageInternal(e, s, i) {
1834
- var l, o, d, u, h, C, p, O;
1708
+ async sendMessageInternal(e, s, a) {
1709
+ var l, c, d, u, h, C, p, M;
1835
1710
  const n = this.suspendState;
1836
1711
  this.suspendState = !1;
1837
1712
  const r = this.startInteraction(e.friendlyMessage ?? e.data, n);
1838
- if (this.registerInteractionCallId(r.interactionId, s), (l = e.userUi) != null && l.name && r.parts.push(_.fromUserUi(e.userUi.name, e.userUi.args)), !this.wsService)
1713
+ if (this.registerInteractionCallId(r.interactionId, s), (l = e.userUi) != null && l.name && r.parts.push(N.fromUserUi(e.userUi.name, e.userUi.args)), !this.wsService)
1839
1714
  throw "no wsService created";
1840
1715
  if (!this.sessionId)
1841
1716
  throw "no session id set";
1842
- if (!((o = this.config.agentConfig) != null && o.id))
1717
+ if (!((c = this.config.agentConfig) != null && c.id))
1843
1718
  throw "Agent not selected";
1844
1719
  return this.wsService.sendMessage({
1845
1720
  Content: e.data,
1846
1721
  SessionId: this.sessionId,
1847
- Action: W.SendMessage,
1722
+ Action: U.SendMessage,
1848
1723
  ModelId: this.config.model,
1849
1724
  InteractionId: r.interactionId,
1850
1725
  AgentId: (d = this.config.agentConfig) == null ? void 0 : d.id,
@@ -1860,28 +1735,28 @@ const Jt = "envision_agent_sessionId", tt = class tt extends H {
1860
1735
  },
1861
1736
  // Forward image attachments as a structured payload (PascalCase
1862
1737
  // keys to match the C# `Message.Images` / `MessageImage` model).
1863
- Images: (p = e.images) != null && p.length ? e.images.map((M) => ({ MimeType: M.mimeType, Data: M.data })) : void 0,
1738
+ Images: (p = e.images) != null && p.length ? e.images.map((w) => ({ MimeType: w.mimeType, Data: w.data })) : void 0,
1864
1739
  // Client-only UI representation for this turn (PascalCase to match the C# `Message.UserUi`
1865
1740
  // model). The server persists it as a UserUiContent sibling and strips it from the model
1866
1741
  // request; Content remains the only model-facing text.
1867
- UserUi: (O = e.userUi) != null && O.name ? { Name: e.userUi.name, Args: e.userUi.args } : void 0
1742
+ UserUi: (M = e.userUi) != null && M.name ? { Name: e.userUi.name, Args: e.userUi.args } : void 0
1868
1743
  }), this.localOpen(r.interactionId, "system"), Promise.resolve({
1869
1744
  interaction: r,
1870
1745
  success: !0
1871
1746
  });
1872
1747
  }
1873
1748
  };
1874
- g(tt, "AgentGatewayWSAsync");
1875
- let dt = tt;
1876
- const et = class et {
1749
+ f(Z, "AgentGatewayWSAsync");
1750
+ let ht = Z;
1751
+ const V = class V {
1877
1752
  constructor(t, e) {
1878
- a(this, "cache", /* @__PURE__ */ new Map());
1879
- a(this, "serverBaseUrl");
1880
- a(this, "accessToken");
1753
+ i(this, "cache", /* @__PURE__ */ new Map());
1754
+ i(this, "serverBaseUrl");
1755
+ i(this, "accessToken");
1881
1756
  this.serverBaseUrl = t.replace(/\/$/, ""), this.accessToken = e;
1882
1757
  }
1883
1758
  get headers() {
1884
- return { Authorization: `Bearer ${Ft(this.accessToken)}` };
1759
+ return { Authorization: `Bearer ${_t(this.accessToken)}` };
1885
1760
  }
1886
1761
  async init() {
1887
1762
  }
@@ -1910,8 +1785,8 @@ const et = class et {
1910
1785
  headers: this.headers
1911
1786
  });
1912
1787
  if (!s.ok) return null;
1913
- const i = await s.json();
1914
- return this.cache.set(i.id, i), i;
1788
+ const a = await s.json();
1789
+ return this.cache.set(a.id, a), a;
1915
1790
  } catch {
1916
1791
  return null;
1917
1792
  }
@@ -1928,17 +1803,17 @@ const et = class et {
1928
1803
  }
1929
1804
  }
1930
1805
  };
1931
- g(et, "HttpArtifactService");
1932
- let ft = et;
1806
+ f(V, "HttpArtifactService");
1807
+ let ut = V;
1933
1808
  export {
1934
- H as A,
1935
- G as E,
1936
- ft as H,
1937
- q as I,
1938
- ot as L,
1939
- ct as M,
1940
- ut as W,
1941
- dt as a,
1942
- te as u
1809
+ G as A,
1810
+ q as E,
1811
+ ut as H,
1812
+ B as I,
1813
+ at as L,
1814
+ rt as M,
1815
+ lt as W,
1816
+ ht as a,
1817
+ Zt as u
1943
1818
  };
1944
- //# sourceMappingURL=httpArtifactService-JtkC1T7n.js.map
1819
+ //# sourceMappingURL=httpArtifactService-kXjuQtGa.js.map