mavenagi 1.2.64 → 1.2.65

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 (241) hide show
  1. package/BaseClient.js +2 -2
  2. package/api/resources/actions/client/Client.js +3 -3
  3. package/api/resources/agents/client/Client.js +5 -5
  4. package/api/resources/agents/client/requests/AgentPatchRequest.d.ts +10 -2
  5. package/api/resources/agents/types/Agent.d.ts +3 -1
  6. package/api/resources/agents/types/AgentPrompting.d.ts +12 -2
  7. package/api/resources/appDirectory/client/Client.js +5 -5
  8. package/api/resources/assets/client/Client.js +1 -1
  9. package/api/resources/capabilities/client/Client.d.ts +33 -0
  10. package/api/resources/capabilities/client/Client.js +126 -3
  11. package/api/resources/capabilities/client/requests/SimulateCapabilityByTypeRequest.d.ts +14 -0
  12. package/api/resources/capabilities/client/requests/SimulateCapabilityByTypeRequest.js +3 -0
  13. package/api/resources/capabilities/client/requests/index.d.ts +1 -0
  14. package/api/resources/capabilities/types/ActionSimulationInput.d.ts +5 -0
  15. package/api/resources/capabilities/types/ActionSimulationInput.js +3 -0
  16. package/api/resources/capabilities/types/CapabilitySimulationInput.d.ts +11 -0
  17. package/api/resources/capabilities/types/CapabilitySimulationInput.js +3 -0
  18. package/api/resources/capabilities/types/CapabilitySimulationResult.d.ts +10 -0
  19. package/api/resources/capabilities/types/CapabilitySimulationResult.js +3 -0
  20. package/api/resources/capabilities/types/ConversationContextSimulationInput.d.ts +14 -0
  21. package/api/resources/capabilities/types/ConversationContextSimulationInput.js +3 -0
  22. package/api/resources/capabilities/types/SimulatedUser.d.ts +9 -0
  23. package/api/resources/capabilities/types/SimulatedUser.js +3 -0
  24. package/api/resources/capabilities/types/SimulatedUserData.d.ts +6 -0
  25. package/api/resources/capabilities/types/SimulatedUserData.js +3 -0
  26. package/api/resources/capabilities/types/index.d.ts +6 -0
  27. package/api/resources/capabilities/types/index.js +6 -0
  28. package/api/resources/charters/client/Client.js +4 -4
  29. package/api/resources/charters/types/CharterBase.d.ts +5 -1
  30. package/api/resources/charters/types/CharterChildrenExclusionPolicy.d.ts +2 -0
  31. package/api/resources/charters/types/CharterChildrenExclusionPolicy.js +2 -0
  32. package/api/resources/charters/types/CharterContent.d.ts +2 -0
  33. package/api/resources/charters/types/CharterPatchReferences.d.ts +2 -0
  34. package/api/resources/charters/types/CharterReferences.d.ts +2 -0
  35. package/api/resources/charters/types/CharterResponse.d.ts +5 -1
  36. package/api/resources/charters/types/CharterStatus.d.ts +4 -0
  37. package/api/resources/charters/types/CharterStatus.js +4 -0
  38. package/api/resources/charters/types/CharterSummary.d.ts +5 -1
  39. package/api/resources/charters/types/index.d.ts +0 -1
  40. package/api/resources/charters/types/index.js +0 -1
  41. package/api/resources/commons/types/ActionExecutionStatus.d.ts +6 -0
  42. package/api/resources/commons/types/ActionExecutionStatus.js +9 -0
  43. package/api/resources/commons/types/ActionProperties.d.ts +1 -1
  44. package/api/resources/commons/types/AdditionalDataKey.d.ts +3 -0
  45. package/api/resources/commons/types/AdditionalDataKey.js +3 -0
  46. package/api/resources/commons/types/AppUserRequest.d.ts +11 -0
  47. package/api/resources/commons/types/BotLogicCharterDetail.d.ts +2 -0
  48. package/api/resources/commons/types/BotMessage.d.ts +5 -0
  49. package/api/resources/commons/types/BotMessageStatusReason.d.ts +13 -0
  50. package/api/resources/commons/types/BotMessageStatusReason.js +16 -0
  51. package/api/resources/commons/types/Capability.d.ts +4 -0
  52. package/api/resources/commons/types/Capability.js +4 -0
  53. package/api/resources/commons/types/CapabilityStatus.d.ts +2 -2
  54. package/api/resources/commons/types/CapabilityStatus.js +2 -2
  55. package/api/resources/commons/types/ConversationAnalysis.d.ts +1 -1
  56. package/api/resources/commons/types/ConversationMetadataValueSource.d.ts +7 -0
  57. package/api/resources/commons/types/ConversationMetadataValueSource.js +3 -0
  58. package/api/resources/commons/types/ConversationSummary.d.ts +5 -3
  59. package/api/resources/commons/types/ConversationValueSource.d.ts +10 -0
  60. package/api/resources/commons/types/ConversationValueSource.js +3 -0
  61. package/api/resources/commons/types/EntityType.d.ts +5 -0
  62. package/api/resources/commons/types/EntityType.js +5 -0
  63. package/api/resources/commons/types/ErrorReason.d.ts +4 -1
  64. package/api/resources/commons/types/ErrorReason.js +4 -1
  65. package/api/resources/commons/types/EventFilter.d.ts +1 -0
  66. package/api/resources/commons/types/ExecuteActionResponse.d.ts +14 -0
  67. package/api/resources/commons/types/ExecuteActionResponse.js +3 -0
  68. package/api/resources/commons/types/ExecutionMode.d.ts +10 -0
  69. package/api/resources/commons/types/ExecutionMode.js +13 -0
  70. package/api/resources/commons/types/FunctionVersionBinding.d.ts +11 -0
  71. package/api/resources/commons/types/FunctionVersionBinding.js +3 -0
  72. package/api/resources/commons/types/InboxItemDuplicateDocuments.d.ts +1 -1
  73. package/api/resources/commons/types/InboxItemStatus.d.ts +1 -1
  74. package/api/resources/commons/types/InboxItemStatus.js +1 -1
  75. package/api/resources/commons/types/LlmInclusionStatus.d.ts +3 -0
  76. package/api/resources/commons/types/LlmInclusionStatus.js +3 -0
  77. package/api/resources/commons/types/MetadataConversationValueFilter.d.ts +15 -0
  78. package/api/resources/commons/types/MetadataConversationValueFilter.js +3 -0
  79. package/api/resources/commons/types/MetadataFilter.d.ts +33 -6
  80. package/api/resources/commons/types/Quality.d.ts +2 -0
  81. package/api/resources/commons/types/Quality.js +2 -0
  82. package/api/resources/commons/types/QualityReason.d.ts +4 -0
  83. package/api/resources/commons/types/QualityReason.js +4 -0
  84. package/api/resources/commons/types/RelationshipType.d.ts +2 -2
  85. package/api/resources/commons/types/RelationshipType.js +2 -2
  86. package/api/resources/commons/types/ResolutionStatus.d.ts +2 -0
  87. package/api/resources/commons/types/ResolutionStatus.js +2 -0
  88. package/api/resources/commons/types/ResponseConfig.d.ts +2 -0
  89. package/api/resources/commons/types/SimulationActionBehavior.d.ts +18 -0
  90. package/api/resources/commons/types/SimulationActionBehavior.js +3 -0
  91. package/api/resources/commons/types/SimulationActionCallApp.d.ts +1 -0
  92. package/api/resources/commons/types/SimulationActionCallApp.js +3 -0
  93. package/api/resources/commons/types/SimulationActionMock.d.ts +6 -0
  94. package/api/resources/commons/types/SimulationActionMock.js +3 -0
  95. package/api/resources/commons/types/SimulationContext.d.ts +19 -0
  96. package/api/resources/commons/types/SystemEventName.d.ts +5 -2
  97. package/api/resources/commons/types/SystemEventName.js +5 -2
  98. package/api/resources/commons/types/UserEvent.d.ts +1 -1
  99. package/api/resources/commons/types/UserEventName.d.ts +1 -1
  100. package/api/resources/commons/types/UserEventName.js +1 -1
  101. package/api/resources/commons/types/index.d.ts +12 -0
  102. package/api/resources/commons/types/index.js +12 -0
  103. package/api/resources/conversation/client/Client.d.ts +11 -7
  104. package/api/resources/conversation/client/Client.js +21 -17
  105. package/api/resources/conversation/client/requests/ConversationDeleteRequest.d.ts +1 -1
  106. package/api/resources/conversation/types/BillableFilterField.d.ts +3 -3
  107. package/api/resources/conversation/types/BillableFilterField.js +3 -3
  108. package/api/resources/conversation/types/ConversationField.d.ts +8 -0
  109. package/api/resources/conversation/types/ConversationField.js +8 -0
  110. package/api/resources/conversation/types/ConversationFilter.d.ts +7 -1
  111. package/api/resources/conversation/types/ConversationPatchRequest.d.ts +1 -1
  112. package/api/resources/customers/client/Client.js +2 -2
  113. package/api/resources/customers/types/CustomerFilter.d.ts +2 -0
  114. package/api/resources/customers/types/CustomerResponse.d.ts +2 -2
  115. package/api/resources/events/client/Client.js +1 -1
  116. package/api/resources/inbox/client/Client.js +6 -6
  117. package/api/resources/integrations/client/Client.js +1 -1
  118. package/api/resources/intelligentFields/client/Client.d.ts +3 -2
  119. package/api/resources/intelligentFields/client/Client.js +6 -5
  120. package/api/resources/intelligentFields/types/EnumOption.d.ts +1 -1
  121. package/api/resources/intelligentFields/types/IntelligentFieldBase.d.ts +1 -1
  122. package/api/resources/intelligentFields/types/IntelligentFieldCore.d.ts +5 -1
  123. package/api/resources/intelligentFields/types/IntelligentFieldType.d.ts +1 -1
  124. package/api/resources/intelligentFields/types/IntelligentFieldType.js +1 -1
  125. package/api/resources/knowledge/client/Client.js +13 -13
  126. package/api/resources/knowledge/types/KnowledgeBaseIndexingStatus.d.ts +1 -1
  127. package/api/resources/knowledge/types/KnowledgeBaseIndexingStatus.js +1 -1
  128. package/api/resources/knowledge/types/KnowledgeBaseResponse.d.ts +3 -1
  129. package/api/resources/knowledge/types/KnowledgeBaseType.d.ts +2 -0
  130. package/api/resources/knowledge/types/KnowledgeBaseType.js +2 -0
  131. package/api/resources/knowledge/types/KnowledgeBaseVersion.d.ts +2 -0
  132. package/api/resources/knowledge/types/KnowledgeBaseVersionStatus.d.ts +4 -0
  133. package/api/resources/knowledge/types/KnowledgeBaseVersionStatus.js +4 -0
  134. package/api/resources/organizations/client/Client.js +4 -4
  135. package/api/resources/segments/client/Client.d.ts +1 -1
  136. package/api/resources/segments/client/Client.js +4 -4
  137. package/api/resources/segments/types/SegmentStatus.d.ts +4 -0
  138. package/api/resources/segments/types/SegmentStatus.js +4 -0
  139. package/api/resources/triggers/client/Client.js +3 -3
  140. package/api/resources/triggers/types/EventTriggerBase.d.ts +2 -0
  141. package/api/resources/users/client/Client.d.ts +42 -1
  142. package/api/resources/users/client/Client.js +116 -4
  143. package/api/resources/users/types/AgentUser.d.ts +3 -0
  144. package/api/resources/users/types/AgentUserFilter.d.ts +4 -0
  145. package/api/resources/voiceConversations/client/Client.d.ts +1 -1
  146. package/api/resources/voiceConversations/client/Socket.d.ts +2 -2
  147. package/api/resources/voiceConversations/client/Socket.js +16 -17
  148. package/core/fetcher/Fetcher.js +33 -3
  149. package/core/fetcher/getErrorResponseBody.js +20 -7
  150. package/core/fetcher/getResponseBody.d.ts +16 -0
  151. package/core/fetcher/getResponseBody.js +27 -22
  152. package/core/fetcher/makePassthroughRequest.js +20 -4
  153. package/core/fetcher/makeRequest.d.ts +6 -1
  154. package/core/fetcher/makeRequest.js +38 -5
  155. package/core/fetcher/requestWithRetries.d.ts +1 -1
  156. package/core/fetcher/requestWithRetries.js +23 -2
  157. package/core/fetcher/signals.d.ts +1 -0
  158. package/core/fetcher/signals.js +3 -2
  159. package/core/stream/Stream.d.ts +3 -0
  160. package/core/stream/Stream.js +5 -0
  161. package/core/url/encodePathParam.d.ts +3 -1
  162. package/core/url/encodePathParam.js +8 -2
  163. package/core/websocket/ws.d.ts +16 -2
  164. package/core/websocket/ws.js +110 -20
  165. package/errors/MavenAGIError.js +16 -2
  166. package/package.json +1 -1
  167. package/reference.md +188 -11
  168. package/serialization/resources/capabilities/types/ActionSimulationInput.d.ts +10 -0
  169. package/serialization/resources/capabilities/types/ActionSimulationInput.js +44 -0
  170. package/serialization/resources/capabilities/types/CapabilitySimulationInput.d.ts +11 -0
  171. package/serialization/resources/capabilities/types/CapabilitySimulationInput.js +47 -0
  172. package/serialization/resources/capabilities/types/CapabilitySimulationResult.d.ts +11 -0
  173. package/serialization/resources/capabilities/types/CapabilitySimulationResult.js +47 -0
  174. package/serialization/resources/capabilities/types/ConversationContextSimulationInput.d.ts +12 -0
  175. package/serialization/resources/capabilities/types/ConversationContextSimulationInput.js +46 -0
  176. package/serialization/resources/capabilities/types/SimulatedUser.d.ts +10 -0
  177. package/serialization/resources/capabilities/types/SimulatedUser.js +44 -0
  178. package/serialization/resources/capabilities/types/SimulatedUserData.d.ts +10 -0
  179. package/serialization/resources/capabilities/types/SimulatedUserData.js +42 -0
  180. package/serialization/resources/capabilities/types/index.d.ts +6 -0
  181. package/serialization/resources/capabilities/types/index.js +6 -0
  182. package/serialization/resources/charters/types/CharterContent.d.ts +1 -1
  183. package/serialization/resources/charters/types/CharterContent.js +1 -1
  184. package/serialization/resources/charters/types/CharterResponse.d.ts +1 -1
  185. package/serialization/resources/charters/types/CharterResponse.js +1 -1
  186. package/serialization/resources/charters/types/CharterSummary.d.ts +1 -1
  187. package/serialization/resources/charters/types/CharterSummary.js +1 -1
  188. package/serialization/resources/charters/types/index.d.ts +0 -1
  189. package/serialization/resources/charters/types/index.js +0 -1
  190. package/serialization/resources/commons/types/ActionExecutionStatus.d.ts +7 -0
  191. package/serialization/resources/commons/types/ActionExecutionStatus.js +39 -0
  192. package/serialization/resources/commons/types/AdditionalDataKey.d.ts +1 -1
  193. package/serialization/resources/commons/types/AdditionalDataKey.js +1 -0
  194. package/serialization/resources/commons/types/AppUserRequest.d.ts +2 -0
  195. package/serialization/resources/commons/types/AppUserRequest.js +2 -0
  196. package/serialization/resources/commons/types/BotLogicCharterDetail.d.ts +2 -0
  197. package/serialization/resources/commons/types/BotLogicCharterDetail.js +2 -0
  198. package/serialization/resources/commons/types/BotMessage.d.ts +2 -0
  199. package/serialization/resources/commons/types/BotMessage.js +2 -0
  200. package/serialization/resources/commons/types/BotMessageStatusReason.d.ts +7 -0
  201. package/serialization/resources/commons/types/BotMessageStatusReason.js +43 -0
  202. package/serialization/resources/commons/types/ConversationMetadataValueSource.d.ts +9 -0
  203. package/serialization/resources/commons/types/ConversationMetadataValueSource.js +41 -0
  204. package/serialization/resources/commons/types/ConversationValueSource.d.ts +11 -0
  205. package/serialization/resources/commons/types/ConversationValueSource.js +47 -0
  206. package/serialization/resources/commons/types/EntityType.d.ts +1 -1
  207. package/serialization/resources/commons/types/EntityType.js +5 -0
  208. package/serialization/resources/commons/types/ErrorReason.d.ts +1 -1
  209. package/serialization/resources/commons/types/ErrorReason.js +1 -0
  210. package/serialization/resources/commons/types/ExecuteActionResponse.d.ts +13 -0
  211. package/serialization/resources/commons/types/ExecuteActionResponse.js +45 -0
  212. package/serialization/resources/commons/types/ExecutionMode.d.ts +7 -0
  213. package/serialization/resources/commons/types/ExecutionMode.js +39 -0
  214. package/serialization/resources/commons/types/FunctionVersionBinding.d.ts +11 -0
  215. package/serialization/resources/commons/types/FunctionVersionBinding.js +43 -0
  216. package/serialization/resources/commons/types/MetadataConversationValueFilter.d.ts +11 -0
  217. package/serialization/resources/commons/types/MetadataConversationValueFilter.js +43 -0
  218. package/serialization/resources/commons/types/MetadataFilter.d.ts +5 -1
  219. package/serialization/resources/commons/types/MetadataFilter.js +2 -0
  220. package/serialization/resources/commons/types/SimulationActionBehavior.d.ts +15 -0
  221. package/serialization/resources/commons/types/SimulationActionBehavior.js +49 -0
  222. package/serialization/resources/commons/types/SimulationActionCallApp.d.ts +7 -0
  223. package/serialization/resources/commons/types/SimulationActionCallApp.js +39 -0
  224. package/serialization/resources/commons/types/SimulationActionMock.d.ts +12 -0
  225. package/serialization/resources/commons/types/SimulationActionMock.js +44 -0
  226. package/serialization/resources/commons/types/SimulationContext.d.ts +4 -0
  227. package/serialization/resources/commons/types/SimulationContext.js +4 -0
  228. package/serialization/resources/commons/types/SystemEventName.d.ts +1 -1
  229. package/serialization/resources/commons/types/SystemEventName.js +1 -0
  230. package/serialization/resources/commons/types/index.d.ts +12 -0
  231. package/serialization/resources/commons/types/index.js +12 -0
  232. package/serialization/resources/users/types/AgentUser.d.ts +2 -0
  233. package/serialization/resources/users/types/AgentUser.js +2 -0
  234. package/serialization/resources/users/types/AgentUserFilter.d.ts +2 -0
  235. package/serialization/resources/users/types/AgentUserFilter.js +2 -0
  236. package/version.d.ts +1 -1
  237. package/version.js +1 -1
  238. /package/api/resources/{charters → commons}/types/CharterType.d.ts +0 -0
  239. /package/api/resources/{charters → commons}/types/CharterType.js +0 -0
  240. /package/serialization/resources/{charters → commons}/types/CharterType.d.ts +0 -0
  241. /package/serialization/resources/{charters → commons}/types/CharterType.js +0 -0
@@ -80,6 +80,7 @@ class ReconnectingWebSocket {
80
80
  this._binaryType = "blob";
81
81
  this._closeCalled = false;
82
82
  this._messageQueue = [];
83
+ this._openWaiters = new Set();
83
84
  this.CONNECTING = ReconnectingWebSocket.CONNECTING;
84
85
  this.OPEN = ReconnectingWebSocket.OPEN;
85
86
  this.CLOSING = ReconnectingWebSocket.CLOSING;
@@ -109,17 +110,20 @@ class ReconnectingWebSocket {
109
110
  this._shouldReconnect = false;
110
111
  this._closeCalled = true;
111
112
  this._clearTimeouts();
112
- if (this._ws) {
113
- this._removeListeners();
114
- // Absorb async errors emitted by ws when closing during CONNECTING state
115
- this._ws.addEventListener("error", () => { });
116
- try {
117
- this._ws.close(1000, "aborted");
118
- this._handleClose(new Events.CloseEvent(1000, "aborted", this));
119
- }
120
- catch (_error) {
121
- // ignore
122
- }
113
+ this._notifyOpenWaiters();
114
+ if (!this._ws) {
115
+ this._emitClose(new Events.CloseEvent(1000, "aborted", this));
116
+ return;
117
+ }
118
+ this._removeListeners();
119
+ // Absorb async errors emitted by ws when closing during CONNECTING state
120
+ this._ws.addEventListener("error", () => { });
121
+ try {
122
+ this._ws.close(1000, "aborted");
123
+ this._emitClose(new Events.CloseEvent(1000, "aborted", this));
124
+ }
125
+ catch (_error) {
126
+ // ignore
123
127
  }
124
128
  };
125
129
  this._handleOpen = (event) => {
@@ -162,10 +166,7 @@ class ReconnectingWebSocket {
162
166
  if (this._shouldReconnect) {
163
167
  this._connect();
164
168
  }
165
- if (this.onclose) {
166
- this.onclose(event);
167
- }
168
- this._listeners.close.forEach((listener) => this._callEventListener(event, listener));
169
+ this._emitClose(event);
169
170
  };
170
171
  this._url = url;
171
172
  this._protocols = protocols;
@@ -236,12 +237,14 @@ class ReconnectingWebSocket {
236
237
  * The current state of the connection; this is one of the Ready state constants
237
238
  */
238
239
  get readyState() {
240
+ var _a;
239
241
  if (this._ws) {
240
242
  return this._ws.readyState;
241
243
  }
242
- return this._options.startClosed
243
- ? ReconnectingWebSocket.ReadyState.CLOSED
244
- : ReconnectingWebSocket.ReadyState.CONNECTING;
244
+ if (this._options.startClosed || this._closeCalled || ((_a = this._abortSignal) === null || _a === void 0 ? void 0 : _a.aborted)) {
245
+ return ReconnectingWebSocket.ReadyState.CLOSED;
246
+ }
247
+ return ReconnectingWebSocket.ReadyState.CONNECTING;
245
248
  }
246
249
  /**
247
250
  * The URL as resolved by the constructor
@@ -257,6 +260,7 @@ class ReconnectingWebSocket {
257
260
  this._closeCalled = true;
258
261
  this._shouldReconnect = false;
259
262
  this._clearTimeouts();
263
+ this._notifyOpenWaiters();
260
264
  if (!this._ws) {
261
265
  this._debug("close enqueued: no ws instance");
262
266
  return;
@@ -308,6 +312,58 @@ class ReconnectingWebSocket {
308
312
  this._listeners[type].push(listener);
309
313
  }
310
314
  }
315
+ /**
316
+ * Resolves once the connection is open. Rejects on an error event, or once the connection is closed and no
317
+ * connection attempt or reconnect is pending (for example after close(), an abort, or a terminal close).
318
+ */
319
+ waitForOpen() {
320
+ if (this.readyState === ReconnectingWebSocket.ReadyState.OPEN) {
321
+ return Promise.resolve();
322
+ }
323
+ if (this._willNotOpen()) {
324
+ return Promise.reject(new Error("WebSocket closed before the connection was opened"));
325
+ }
326
+ return new Promise((resolve, reject) => {
327
+ const cleanup = () => {
328
+ this._openWaiters.delete(check);
329
+ this.removeEventListener("open", onOpen);
330
+ this.removeEventListener("error", onError);
331
+ this.removeEventListener("close", check);
332
+ };
333
+ const onOpen = () => {
334
+ cleanup();
335
+ resolve();
336
+ };
337
+ const onError = (event) => {
338
+ cleanup();
339
+ reject(event);
340
+ };
341
+ // Deferred so that a reconnect or error triggered by the same close is accounted for first
342
+ const check = () => {
343
+ Promise.resolve().then(() => {
344
+ if (this._openWaiters.has(check) && this._willNotOpen()) {
345
+ cleanup();
346
+ reject(new Error("WebSocket closed before the connection was opened"));
347
+ }
348
+ });
349
+ };
350
+ this._openWaiters.add(check);
351
+ this.addEventListener("open", onOpen);
352
+ this.addEventListener("error", onError);
353
+ this.addEventListener("close", check);
354
+ });
355
+ }
356
+ /**
357
+ * Returns whether the given listener is registered for the event type
358
+ */
359
+ hasEventListener(type, listener) {
360
+ const listeners = this._listeners[type];
361
+ if (!listeners) {
362
+ return false;
363
+ }
364
+ // @ts-ignore
365
+ return listeners.some((l) => l === listener);
366
+ }
311
367
  dispatchEvent(event) {
312
368
  const listeners = this._listeners[event.type];
313
369
  if (listeners) {
@@ -378,12 +434,12 @@ class ReconnectingWebSocket {
378
434
  this._debug("connect aborted");
379
435
  return;
380
436
  }
381
- this._connectLock = true;
382
437
  const { maxRetries = DEFAULT_OPTIONS.maxRetries, connectionTimeout = DEFAULT_OPTIONS.connectionTimeout, WebSocket = getGlobalWebSocket(), } = this._options;
383
438
  if (this._retryCount >= maxRetries) {
384
439
  this._debug("max retries reached", this._retryCount, ">=", maxRetries);
385
440
  return;
386
441
  }
442
+ this._connectLock = true;
387
443
  this._retryCount++;
388
444
  this._debug("connect", this._retryCount);
389
445
  this._removeListeners();
@@ -413,8 +469,36 @@ class ReconnectingWebSocket {
413
469
  this._connectLock = false;
414
470
  this._addListeners();
415
471
  this._connectTimeout = setTimeout(() => this._handleTimeout(), connectionTimeout);
472
+ })
473
+ .catch((error) => {
474
+ this._debug("connect failed", error);
475
+ this._connectLock = false;
476
+ const event = new Events.ErrorEvent(error instanceof Error ? error : new Error(String(error)), this);
477
+ if (this.onerror) {
478
+ this.onerror(event);
479
+ }
480
+ this._listeners.error.forEach((listener) => this._callEventListener(event, listener));
481
+ this._connect();
416
482
  });
417
483
  }
484
+ _willNotOpen() {
485
+ var _a;
486
+ if (this._closeCalled || ((_a = this._abortSignal) === null || _a === void 0 ? void 0 : _a.aborted)) {
487
+ return true;
488
+ }
489
+ if (this._connectLock) {
490
+ return false;
491
+ }
492
+ if (!this._ws) {
493
+ return true;
494
+ }
495
+ return this._ws.readyState === ReconnectingWebSocket.ReadyState.CLOSED;
496
+ }
497
+ _notifyOpenWaiters() {
498
+ for (const waiter of [...this._openWaiters]) {
499
+ waiter();
500
+ }
501
+ }
418
502
  _handleTimeout() {
419
503
  this._debug("timeout event");
420
504
  this._handleError(new Events.ErrorEvent(Error("TIMEOUT"), this));
@@ -429,7 +513,7 @@ class ReconnectingWebSocket {
429
513
  this._ws.addEventListener("error", () => { });
430
514
  try {
431
515
  this._ws.close(code, reason);
432
- this._handleClose(new Events.CloseEvent(code, reason, this));
516
+ this._emitClose(new Events.CloseEvent(code, reason, this));
433
517
  }
434
518
  catch (_error) {
435
519
  // ignore
@@ -449,6 +533,12 @@ class ReconnectingWebSocket {
449
533
  listener(event);
450
534
  }
451
535
  }
536
+ _emitClose(event) {
537
+ if (this.onclose) {
538
+ this.onclose(event);
539
+ }
540
+ this._listeners.close.forEach((listener) => this._callEventListener(event, listener));
541
+ }
452
542
  _isReconnectableClose(event) {
453
543
  const { shouldReconnect = DEFAULT_OPTIONS.shouldReconnect } = this._options;
454
544
  try {
@@ -19,8 +19,22 @@ class MavenAGIError extends Error {
19
19
  }
20
20
  }
21
21
  get requestId() {
22
- var _a, _b, _c;
23
- return (_c = (_b = (_a = this.rawResponse) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.get("x-request-id")) !== null && _c !== void 0 ? _c : undefined;
22
+ var _a;
23
+ const headers = (_a = this.rawResponse) === null || _a === void 0 ? void 0 : _a.headers;
24
+ if (headers == null) {
25
+ return undefined;
26
+ }
27
+ const requestId = headers.get("X-Request-Id");
28
+ if (requestId != null) {
29
+ return requestId;
30
+ }
31
+ let fallback;
32
+ headers.forEach((value, name) => {
33
+ if (fallback === undefined && /request[-_]?id$/i.test(name)) {
34
+ fallback = value;
35
+ }
36
+ });
37
+ return fallback;
24
38
  }
25
39
  }
26
40
  exports.MavenAGIError = MavenAGIError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mavenagi",
3
- "version": "1.2.64",
3
+ "version": "1.2.65",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/reference.md CHANGED
@@ -2373,6 +2373,97 @@ await client.capabilities.deleteCapability("ACTION", "referenceId");
2373
2373
  </dl>
2374
2374
 
2375
2375
 
2376
+ </dd>
2377
+ </dl>
2378
+ </details>
2379
+
2380
+ <details><summary><code>client.capabilities.<a href="/src/api/resources/capabilities/client/Client.ts">simulateCapability</a>(capabilityType, referenceId, { ...params }) -> MavenAGI.CapabilitySimulationResult</code></summary>
2381
+ <dl>
2382
+ <dd>
2383
+
2384
+ #### 📝 Description
2385
+
2386
+ <dl>
2387
+ <dd>
2388
+
2389
+ <dl>
2390
+ <dd>
2391
+
2392
+ Run one of an agent's capabilities once, as a simulation, and return what it produced.
2393
+
2394
+ The caller supplies everything the capability reads, so it runs in isolation: no
2395
+ conversation or agent user has to exist first. The capability is told its mode is
2396
+ `SIMULATION`, the same as in a test suite run, so an app that honours it can avoid side
2397
+ effects in real systems. Nothing here runs a capability live.
2398
+
2399
+ Only actions can be simulated today. Triggers and conversation kickoffs are rejected with a
2400
+ 400 until they can run as simulations. Intelligent fields cannot be simulated.
2401
+ </dd>
2402
+ </dl>
2403
+ </dd>
2404
+ </dl>
2405
+
2406
+ #### 🔌 Usage
2407
+
2408
+ <dl>
2409
+ <dd>
2410
+
2411
+ <dl>
2412
+ <dd>
2413
+
2414
+ ```typescript
2415
+ await client.capabilities.simulateCapability("ACTION", "referenceId", {
2416
+ body: {
2417
+ capabilityType: "ACTION"
2418
+ }
2419
+ });
2420
+
2421
+ ```
2422
+ </dd>
2423
+ </dl>
2424
+ </dd>
2425
+ </dl>
2426
+
2427
+ #### ⚙️ Parameters
2428
+
2429
+ <dl>
2430
+ <dd>
2431
+
2432
+ <dl>
2433
+ <dd>
2434
+
2435
+ **capabilityType:** `MavenAGI.CapabilityType` — Which kind of capability to simulate. Must match the body's `capabilityType`.
2436
+
2437
+ </dd>
2438
+ </dl>
2439
+
2440
+ <dl>
2441
+ <dd>
2442
+
2443
+ **referenceId:** `string` — The capability's reference ID, unique within its type and app.
2444
+
2445
+ </dd>
2446
+ </dl>
2447
+
2448
+ <dl>
2449
+ <dd>
2450
+
2451
+ **request:** `MavenAGI.SimulateCapabilityByTypeRequest`
2452
+
2453
+ </dd>
2454
+ </dl>
2455
+
2456
+ <dl>
2457
+ <dd>
2458
+
2459
+ **requestOptions:** `CapabilitiesClient.RequestOptions`
2460
+
2461
+ </dd>
2462
+ </dl>
2463
+ </dd>
2464
+ </dl>
2465
+
2466
+
2376
2467
  </dd>
2377
2468
  </dl>
2378
2469
  </details>
@@ -3429,17 +3520,19 @@ await client.conversation.get("conversationId");
3429
3520
  <dl>
3430
3521
  <dd>
3431
3522
 
3432
- Wipes a conversation of all user data.
3433
- The conversation ID will still exist and non-user specific data will still be retained.
3434
- Attempts to modify or add messages to the conversation will throw an error.
3435
- The conversation is sealed against further writes as soon as this call returns. A `202 Accepted` response means the wipe is still completing and will finish on its own.
3523
+ Wipes the user content from a conversation.
3524
+ The conversation and its ID still exist afterwards, and so does its non-content data, so it still counts in metrics.
3525
+ The conversation is sealed against further writes as soon as this call returns: adding or changing messages fails with `409 Conflict`, and so does deleting it again once the wipe has finished.
3526
+ A `202 Accepted` response means the wipe is still completing and will finish on its own.
3436
3527
 
3437
3528
  Simulation conversations will no longer be visible in search results nor metrics.
3438
- Non-simulation conversations will remain visible - they can not be fully removed from the system.
3529
+ Non-simulation conversations remain visible; they cannot be fully removed from the system.
3439
3530
 
3440
3531
  <Warning>This is a destructive operation and cannot be undone. <br/><br/>
3441
- The exact fields cleared include: the conversation subject, userRequest, agentResponse.
3442
- As well as the text response, followup questions, and backend LLM prompt of all messages.</Warning>
3532
+ What is wiped: the conversation's `subject` and `analysis.agentResponse` are cleared, and `analysis.userRequest` is replaced with `reason`.
3533
+ Every message's text, from the user and the agent alike, is replaced with `reason`, and its attachments, follow-up questions, backend LLM prompt and history, the data actions returned, and action arguments are cleared.
3534
+ Evaluation results for the conversation are deleted, and the payloads recorded on its trigger and action executions are cleared. <br/><br/>
3535
+ What is kept: the conversation's metadata, each message's charts, structured answer and app-supplied metadata, the conversation's intelligent field values, its feedback and events, and the users who took part. To wipe a user's data, use `DELETE /users/{userId}` or `DELETE /agentusers/{agentUserId}`.</Warning>
3443
3536
  </dd>
3444
3537
  </dl>
3445
3538
  </dd>
@@ -5964,8 +6057,9 @@ deletes any kind of capability the same way. That endpoint returns no body.
5964
6057
  Soft delete an intelligent field. Only INACTIVE fields can be deleted.
5965
6058
 
5966
6059
  Deleted fields are excluded from search results, and getting one by ID returns 404.
5967
- Creating a new field with the same referenceId as a deleted field will overwrite
5968
- the deleted field and restore it with the status a new field gets.
6060
+ Creating a field with the same referenceId as a deleted field reclaims it: the field keeps
6061
+ its identity and entityType, every other setting comes from the request, and it gets the
6062
+ status a new field gets.
5969
6063
 
5970
6064
  Deleted fields cannot be modified.
5971
6065
  </dd>
@@ -8088,7 +8182,7 @@ await client.segments.patch("segmentReferenceId", {});
8088
8182
 
8089
8183
  Soft delete a segment. Only INACTIVE segments can be deleted.
8090
8184
 
8091
- Deleted segments are excluded from search results but can still be retrieved by ID for archival purposes. Creating a new segment with the same referenceId as a deleted segment will overwrite the deleted segment and restore it to ACTIVE status.
8185
+ Deleted segments are excluded from search results but can still be retrieved by ID for archival purposes. Creating a segment with the same referenceId as a deleted segment reclaims it: the segment keeps its identity, and every other setting comes from the request.
8092
8186
 
8093
8187
  Deleted segments cannot be modified.
8094
8188
  </dd>
@@ -8684,6 +8778,84 @@ await client.users.getAgentUser("aus_1234567890");
8684
8778
  </dl>
8685
8779
 
8686
8780
 
8781
+ </dd>
8782
+ </dl>
8783
+ </details>
8784
+
8785
+ <details><summary><code>client.users.<a href="/src/api/resources/users/client/Client.ts">deleteAgentUser</a>(agentUserId) -> void</code></summary>
8786
+ <dl>
8787
+ <dd>
8788
+
8789
+ #### 📝 Description
8790
+
8791
+ <dl>
8792
+ <dd>
8793
+
8794
+ <dl>
8795
+ <dd>
8796
+
8797
+ Deletes the identifiers and user data that every app has saved for an agent user.
8798
+ This is the same as calling `DELETE /users/{userId}` for each of the agent user's app users.
8799
+
8800
+ The agent user and its app users still exist afterwards, with no identifiers or user data.
8801
+ Apps can keep writing to them; a later create or update adds data back to the same users.
8802
+
8803
+ Conversations, their messages and events are not modified, apart from the intelligent field values below. To wipe a conversation, use `DELETE /conversations/{conversationId}`.
8804
+
8805
+ If the ID belongs to an agent user that has been merged into another, the agent user it was merged into is wiped.
8806
+
8807
+ <Warning>This is a destructive operation and cannot be undone.</Warning>
8808
+
8809
+ ### Intelligent fields
8810
+
8811
+ The agent user's intelligent field values are deleted too, and removed from their `INTELLIGENT_FIELD_VALUE_CHANGED` events; the events themselves are kept.
8812
+ Unlike `DELETE /users/{userId}`, the wipe does not recompute the values. They can be computed again later from the user's remaining conversations, for example after the user sends another message; wipe those conversations first to prevent that.
8813
+ </dd>
8814
+ </dl>
8815
+ </dd>
8816
+ </dl>
8817
+
8818
+ #### 🔌 Usage
8819
+
8820
+ <dl>
8821
+ <dd>
8822
+
8823
+ <dl>
8824
+ <dd>
8825
+
8826
+ ```typescript
8827
+ await client.users.deleteAgentUser("aus_1234567890");
8828
+
8829
+ ```
8830
+ </dd>
8831
+ </dl>
8832
+ </dd>
8833
+ </dl>
8834
+
8835
+ #### ⚙️ Parameters
8836
+
8837
+ <dl>
8838
+ <dd>
8839
+
8840
+ <dl>
8841
+ <dd>
8842
+
8843
+ **agentUserId:** `string` — The ID of the agent user to wipe.
8844
+
8845
+ </dd>
8846
+ </dl>
8847
+
8848
+ <dl>
8849
+ <dd>
8850
+
8851
+ **requestOptions:** `UsersClient.RequestOptions`
8852
+
8853
+ </dd>
8854
+ </dl>
8855
+ </dd>
8856
+ </dl>
8857
+
8858
+
8687
8859
  </dd>
8688
8860
  </dl>
8689
8861
  </details>
@@ -8848,9 +9020,14 @@ await client.users.get("user-0");
8848
9020
  <dl>
8849
9021
  <dd>
8850
9022
 
8851
- Deletes all identifiers and user data saved by the specified app.
9023
+ Deletes all identifiers and user data saved by the specified app for this user.
8852
9024
  Does not modify data or identifiers saved by other apps.
8853
9025
 
9026
+ The app user still exists afterwards, with no identifiers or user data, and the app can keep writing to it.
9027
+ Conversations, their messages and events are not modified.
9028
+ The agent user's intelligent field values are not deleted; they are recomputed without this app's data.
9029
+ To wipe a conversation, use `DELETE /conversations/{conversationId}`. To wipe every app's data for a user, use `DELETE /agentusers/{agentUserId}`.
9030
+
8854
9031
  If this user is linked to a user from another app, it will not be unlinked. Unlinking of users is not yet supported.
8855
9032
 
8856
9033
  <Warning>This is a destructive operation and cannot be undone.</Warning>
@@ -0,0 +1,10 @@
1
+ import type * as MavenAGI from "../../../../api/index";
2
+ import * as core from "../../../../core";
3
+ import type * as serializers from "../../../index";
4
+ import { ConversationContextSimulationInput } from "./ConversationContextSimulationInput";
5
+ export declare const ActionSimulationInput: core.serialization.ObjectSchema<serializers.ActionSimulationInput.Raw, MavenAGI.ActionSimulationInput>;
6
+ export declare namespace ActionSimulationInput {
7
+ interface Raw extends ConversationContextSimulationInput.Raw {
8
+ parameters?: Record<string, unknown> | null;
9
+ }
10
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.ActionSimulationInput = void 0;
38
+ const core = __importStar(require("../../../../core"));
39
+ const ConversationContextSimulationInput_1 = require("./ConversationContextSimulationInput");
40
+ exports.ActionSimulationInput = core.serialization
41
+ .object({
42
+ parameters: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(),
43
+ })
44
+ .extend(ConversationContextSimulationInput_1.ConversationContextSimulationInput);
@@ -0,0 +1,11 @@
1
+ import type * as MavenAGI from "../../../../api/index";
2
+ import * as core from "../../../../core";
3
+ import type * as serializers from "../../../index";
4
+ import { ActionSimulationInput } from "./ActionSimulationInput";
5
+ export declare const CapabilitySimulationInput: core.serialization.Schema<serializers.CapabilitySimulationInput.Raw, MavenAGI.CapabilitySimulationInput>;
6
+ export declare namespace CapabilitySimulationInput {
7
+ type Raw = CapabilitySimulationInput.Action;
8
+ interface Action extends ActionSimulationInput.Raw {
9
+ capabilityType: "ACTION";
10
+ }
11
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.CapabilitySimulationInput = void 0;
38
+ const core = __importStar(require("../../../../core"));
39
+ const ActionSimulationInput_1 = require("./ActionSimulationInput");
40
+ exports.CapabilitySimulationInput = core.serialization
41
+ .union("capabilityType", {
42
+ ACTION: ActionSimulationInput_1.ActionSimulationInput,
43
+ })
44
+ .transform({
45
+ transform: (value) => value,
46
+ untransform: (value) => value,
47
+ });
@@ -0,0 +1,11 @@
1
+ import type * as MavenAGI from "../../../../api/index";
2
+ import * as core from "../../../../core";
3
+ import type * as serializers from "../../../index";
4
+ import { ExecuteActionResponse } from "../../commons/types/ExecuteActionResponse";
5
+ export declare const CapabilitySimulationResult: core.serialization.Schema<serializers.CapabilitySimulationResult.Raw, MavenAGI.CapabilitySimulationResult>;
6
+ export declare namespace CapabilitySimulationResult {
7
+ type Raw = CapabilitySimulationResult.Action;
8
+ interface Action extends ExecuteActionResponse.Raw {
9
+ capabilityType: "ACTION";
10
+ }
11
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.CapabilitySimulationResult = void 0;
38
+ const core = __importStar(require("../../../../core"));
39
+ const ExecuteActionResponse_1 = require("../../commons/types/ExecuteActionResponse");
40
+ exports.CapabilitySimulationResult = core.serialization
41
+ .union("capabilityType", {
42
+ ACTION: ExecuteActionResponse_1.ExecuteActionResponse,
43
+ })
44
+ .transform({
45
+ transform: (value) => value,
46
+ untransform: (value) => value,
47
+ });