mavenagi 1.2.60 → 1.2.62

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 (390) hide show
  1. package/BaseClient.d.ts +12 -0
  2. package/BaseClient.js +5 -3
  3. package/Client.d.ts +9 -0
  4. package/Client.js +43 -28
  5. package/api/resources/actions/client/Client.d.ts +26 -0
  6. package/api/resources/actions/client/Client.js +30 -3
  7. package/api/resources/agents/client/Client.d.ts +12 -0
  8. package/api/resources/agents/client/Client.js +16 -3
  9. package/api/resources/agents/client/requests/AgentPatchRequest.d.ts +3 -3
  10. package/api/resources/agents/types/AgentPrompting.d.ts +3 -3
  11. package/api/resources/analytics/client/Client.d.ts +14 -0
  12. package/api/resources/analytics/client/Client.js +22 -7
  13. package/api/resources/analytics/types/ConversationMedian.d.ts +4 -0
  14. package/api/resources/analytics/types/ConversationPercentile.d.ts +4 -0
  15. package/api/resources/analytics/types/RowBase.d.ts +5 -1
  16. package/api/resources/analytics/types/Series.d.ts +4 -1
  17. package/api/resources/analytics/types/TimeSeries.d.ts +5 -1
  18. package/api/resources/appDirectory/client/Client.d.ts +12 -0
  19. package/api/resources/appDirectory/client/Client.js +16 -3
  20. package/api/resources/appSettings/client/Client.d.ts +6 -0
  21. package/api/resources/appSettings/client/Client.js +8 -1
  22. package/api/resources/assets/client/Client.d.ts +4 -0
  23. package/api/resources/assets/client/Client.js +7 -2
  24. package/api/resources/capabilities/client/Client.d.ts +118 -0
  25. package/api/resources/capabilities/client/Client.js +521 -0
  26. package/api/resources/capabilities/client/index.d.ts +1 -0
  27. package/api/resources/capabilities/client/index.js +17 -0
  28. package/api/resources/capabilities/client/requests/CapabilitiesSearchRequest.d.ts +36 -0
  29. package/api/resources/capabilities/client/requests/CapabilitiesSearchRequest.js +3 -0
  30. package/api/resources/capabilities/client/requests/DeleteCapabilityByTypeRequest.d.ts +18 -0
  31. package/api/resources/capabilities/client/requests/DeleteCapabilityByTypeRequest.js +3 -0
  32. package/api/resources/capabilities/client/requests/GetCapabilityByTypeRequest.d.ts +22 -0
  33. package/api/resources/capabilities/client/requests/GetCapabilityByTypeRequest.js +3 -0
  34. package/api/resources/capabilities/client/requests/PatchCapabilityByTypeRequest.d.ts +24 -0
  35. package/api/resources/capabilities/client/requests/PatchCapabilityByTypeRequest.js +3 -0
  36. package/api/resources/capabilities/client/requests/index.d.ts +4 -0
  37. package/api/resources/capabilities/client/requests/index.js +2 -0
  38. package/api/resources/capabilities/exports.d.ts +2 -0
  39. package/api/resources/capabilities/exports.js +21 -0
  40. package/api/resources/capabilities/index.d.ts +2 -0
  41. package/api/resources/capabilities/index.js +18 -0
  42. package/api/resources/capabilities/types/CapabilitiesSearchResponse.d.ts +43 -0
  43. package/api/resources/capabilities/types/CapabilitiesSearchResponse.js +3 -0
  44. package/api/resources/capabilities/types/CapabilityResponse.d.ts +23 -0
  45. package/api/resources/capabilities/types/CapabilityResponse.js +3 -0
  46. package/api/resources/capabilities/types/CapabilitySortField.d.ts +7 -0
  47. package/api/resources/capabilities/types/CapabilitySortField.js +10 -0
  48. package/api/resources/capabilities/types/CapabilitySummary.d.ts +28 -0
  49. package/api/resources/capabilities/types/CapabilitySummary.js +3 -0
  50. package/api/resources/capabilities/types/index.d.ts +4 -0
  51. package/api/resources/capabilities/types/index.js +20 -0
  52. package/api/resources/charters/client/Client.d.ts +245 -0
  53. package/api/resources/charters/client/Client.js +884 -0
  54. package/api/resources/charters/client/index.d.ts +1 -0
  55. package/api/resources/charters/client/index.js +17 -0
  56. package/api/resources/charters/client/requests/CharterDeleteRequest.d.ts +20 -0
  57. package/api/resources/charters/client/requests/CharterDeleteRequest.js +3 -0
  58. package/api/resources/charters/client/requests/CharterGetAncestorsRequest.d.ts +8 -0
  59. package/api/resources/charters/client/requests/CharterGetAncestorsRequest.js +3 -0
  60. package/api/resources/charters/client/requests/CharterGetRequest.d.ts +8 -0
  61. package/api/resources/charters/client/requests/CharterGetRequest.js +3 -0
  62. package/api/resources/charters/client/requests/CharterPatchRequest.d.ts +67 -0
  63. package/api/resources/charters/client/requests/CharterPatchRequest.js +3 -0
  64. package/api/resources/charters/client/requests/index.d.ts +4 -0
  65. package/api/resources/charters/client/requests/index.js +2 -0
  66. package/api/resources/charters/exports.d.ts +2 -0
  67. package/api/resources/charters/exports.js +21 -0
  68. package/api/resources/charters/index.d.ts +1 -0
  69. package/api/resources/charters/index.js +1 -0
  70. package/api/resources/charters/types/CharterAncestorsResponse.d.ts +8 -0
  71. package/api/resources/charters/types/CharterAncestorsResponse.js +3 -0
  72. package/api/resources/charters/types/CharterBase.d.ts +14 -0
  73. package/api/resources/charters/types/CharterBase.js +3 -0
  74. package/api/resources/charters/types/CharterChildrenExclusionPolicy.d.ts +1 -1
  75. package/api/resources/charters/types/CharterChildrenExclusionPolicy.js +1 -1
  76. package/api/resources/charters/types/CharterChildrenGroup.d.ts +18 -0
  77. package/api/resources/charters/types/CharterChildrenGroup.js +3 -0
  78. package/api/resources/charters/types/CharterContent.d.ts +60 -0
  79. package/api/resources/charters/types/CharterContent.js +3 -0
  80. package/api/resources/charters/types/CharterKnowledgeBaseReference.d.ts +16 -0
  81. package/api/resources/charters/types/CharterKnowledgeBaseReference.js +3 -0
  82. package/api/resources/charters/types/CharterListChildrenRequest.d.ts +18 -0
  83. package/api/resources/charters/types/CharterListChildrenRequest.js +3 -0
  84. package/api/resources/charters/types/CharterListChildrenResponse.d.ts +55 -0
  85. package/api/resources/charters/types/CharterListChildrenResponse.js +3 -0
  86. package/api/resources/charters/types/CharterPatchReferences.d.ts +22 -0
  87. package/api/resources/charters/types/CharterPatchReferences.js +3 -0
  88. package/api/resources/charters/types/CharterReferences.d.ts +21 -0
  89. package/api/resources/charters/types/CharterReferences.js +3 -0
  90. package/api/resources/charters/types/CharterRequest.d.ts +36 -0
  91. package/api/resources/charters/types/CharterRequest.js +3 -0
  92. package/api/resources/charters/types/CharterResponse.d.ts +66 -0
  93. package/api/resources/charters/types/CharterResponse.js +3 -0
  94. package/api/resources/charters/types/CharterSearchField.d.ts +5 -0
  95. package/api/resources/charters/types/CharterSearchField.js +8 -0
  96. package/api/resources/charters/types/CharterSearchFilter.d.ts +18 -0
  97. package/api/resources/charters/types/CharterSearchFilter.js +3 -0
  98. package/api/resources/charters/types/CharterSearchRequest.d.ts +5 -0
  99. package/api/resources/charters/types/CharterSearchRequest.js +3 -0
  100. package/api/resources/charters/types/CharterSearchResponse.d.ts +36 -0
  101. package/api/resources/charters/types/CharterSearchResponse.js +3 -0
  102. package/api/resources/charters/types/CharterStatus.d.ts +2 -2
  103. package/api/resources/charters/types/CharterStatus.js +2 -2
  104. package/api/resources/charters/types/CharterSummary.d.ts +1 -9
  105. package/api/resources/charters/types/CharterType.d.ts +4 -4
  106. package/api/resources/charters/types/CharterType.js +4 -4
  107. package/api/resources/charters/types/index.d.ts +15 -0
  108. package/api/resources/charters/types/index.js +15 -0
  109. package/api/resources/commons/errors/BadRequestError.d.ts +1 -0
  110. package/api/resources/commons/errors/BadRequestError.js +1 -1
  111. package/api/resources/commons/errors/NotFoundError.d.ts +1 -0
  112. package/api/resources/commons/errors/NotFoundError.js +1 -1
  113. package/api/resources/commons/errors/PayloadTooLargeError.d.ts +1 -0
  114. package/api/resources/commons/errors/PayloadTooLargeError.js +1 -1
  115. package/api/resources/commons/errors/ServerError.d.ts +1 -0
  116. package/api/resources/commons/errors/ServerError.js +1 -1
  117. package/api/resources/commons/errors/TooManyRequestsError.d.ts +1 -0
  118. package/api/resources/commons/errors/TooManyRequestsError.js +1 -1
  119. package/api/resources/commons/types/ActionResponse.d.ts +11 -2
  120. package/api/resources/commons/types/AskType.d.ts +2 -2
  121. package/api/resources/commons/types/AskType.js +2 -2
  122. package/api/resources/commons/types/BaseConversationResponse.d.ts +6 -0
  123. package/api/resources/commons/types/BotObjectResponse.d.ts +1 -1
  124. package/api/resources/commons/types/CapabilityBase.d.ts +23 -0
  125. package/api/resources/commons/types/CapabilityBase.js +3 -0
  126. package/api/resources/commons/types/CapabilityStatus.d.ts +17 -0
  127. package/api/resources/commons/types/CapabilityStatus.js +20 -0
  128. package/api/resources/commons/types/CapabilityType.d.ts +8 -0
  129. package/api/resources/commons/types/CapabilityType.js +11 -0
  130. package/api/resources/commons/types/ConversationRound.d.ts +1 -1
  131. package/api/resources/commons/types/ConversationRound.js +1 -1
  132. package/api/resources/commons/types/EntityType.d.ts +5 -1
  133. package/api/resources/commons/types/EntityType.js +5 -1
  134. package/api/resources/commons/types/ErrorMessage.d.ts +3 -0
  135. package/api/resources/commons/types/ErrorReason.d.ts +31 -0
  136. package/api/resources/commons/types/ErrorReason.js +34 -0
  137. package/api/resources/commons/types/IntelligentFieldPrecondition.d.ts +0 -4
  138. package/api/resources/commons/types/LlmPersona.d.ts +1 -1
  139. package/api/resources/commons/types/LlmPersona.js +1 -1
  140. package/api/resources/commons/types/MetadataComparisonCondition.d.ts +10 -0
  141. package/api/resources/commons/types/MetadataComparisonCondition.js +3 -0
  142. package/api/resources/commons/types/MetadataComparisonOperator.d.ts +22 -0
  143. package/api/resources/commons/types/MetadataComparisonOperator.js +25 -0
  144. package/api/resources/commons/types/MetadataCondition.d.ts +21 -0
  145. package/api/resources/commons/types/MetadataCondition.js +3 -0
  146. package/api/resources/commons/types/MetadataEntryCondition.d.ts +10 -0
  147. package/api/resources/commons/types/MetadataEntryCondition.js +3 -0
  148. package/api/resources/commons/types/MetadataFilter.d.ts +41 -0
  149. package/api/resources/commons/types/MetadataFilter.js +3 -0
  150. package/api/resources/commons/types/MetadataFilterGroup.d.ts +14 -0
  151. package/api/resources/commons/types/MetadataFilterGroup.js +3 -0
  152. package/api/resources/commons/types/SimulationContext.d.ts +2 -2
  153. package/api/resources/commons/types/SystemEventName.d.ts +3 -0
  154. package/api/resources/commons/types/SystemEventName.js +3 -0
  155. package/api/resources/commons/types/index.d.ts +10 -0
  156. package/api/resources/commons/types/index.js +10 -0
  157. package/api/resources/conversation/client/Client.d.ts +33 -0
  158. package/api/resources/conversation/client/Client.js +49 -17
  159. package/api/resources/conversation/types/AskRequest.d.ts +10 -10
  160. package/api/resources/conversation/types/ConversationFilter.d.ts +6 -1
  161. package/api/resources/conversationKickoffs/client/Client.d.ts +45 -0
  162. package/api/resources/conversationKickoffs/client/Client.js +175 -0
  163. package/api/resources/conversationKickoffs/client/index.d.ts +1 -0
  164. package/api/resources/conversationKickoffs/client/index.js +17 -0
  165. package/api/resources/conversationKickoffs/client/requests/CreateConversationKickoffRequest.d.ts +22 -0
  166. package/api/resources/conversationKickoffs/client/requests/CreateConversationKickoffRequest.js +3 -0
  167. package/api/resources/conversationKickoffs/client/requests/index.d.ts +1 -0
  168. package/api/resources/conversationKickoffs/client/requests/index.js +2 -0
  169. package/api/resources/conversationKickoffs/exports.d.ts +2 -0
  170. package/api/resources/conversationKickoffs/exports.js +21 -0
  171. package/api/resources/conversationKickoffs/index.d.ts +2 -0
  172. package/api/resources/conversationKickoffs/index.js +18 -0
  173. package/api/resources/conversationKickoffs/types/ConversationKickoff.d.ts +27 -0
  174. package/api/resources/conversationKickoffs/types/ConversationKickoff.js +3 -0
  175. package/api/resources/conversationKickoffs/types/index.d.ts +1 -0
  176. package/api/resources/conversationKickoffs/types/index.js +17 -0
  177. package/api/resources/customers/client/Client.d.ts +8 -0
  178. package/api/resources/customers/client/Client.js +12 -3
  179. package/api/resources/events/client/Client.d.ts +8 -0
  180. package/api/resources/events/client/Client.js +12 -3
  181. package/api/resources/inbox/client/Client.d.ts +16 -0
  182. package/api/resources/inbox/client/Client.js +22 -5
  183. package/api/resources/index.d.ts +7 -0
  184. package/api/resources/index.js +8 -1
  185. package/api/resources/integrations/client/Client.d.ts +2 -0
  186. package/api/resources/integrations/client/Client.js +4 -1
  187. package/api/resources/intelligentFields/client/Client.d.ts +41 -4
  188. package/api/resources/intelligentFields/client/Client.js +49 -9
  189. package/api/resources/intelligentFields/client/requests/IntelligentFieldDeleteRequest.d.ts +1 -1
  190. package/api/resources/intelligentFields/client/requests/IntelligentFieldGetRequest.d.ts +4 -0
  191. package/api/resources/intelligentFields/client/requests/IntelligentFieldPatchRequest.d.ts +14 -5
  192. package/api/resources/intelligentFields/types/EnumOption.d.ts +8 -1
  193. package/api/resources/intelligentFields/types/IntelligentFieldBase.d.ts +1 -1
  194. package/api/resources/intelligentFields/types/IntelligentFieldCore.d.ts +12 -15
  195. package/api/resources/intelligentFields/types/IntelligentFieldDetailResponse.d.ts +5 -2
  196. package/api/resources/intelligentFields/types/IntelligentFieldRequest.d.ts +10 -2
  197. package/api/resources/intelligentFields/types/IntelligentFieldResponse.d.ts +2 -8
  198. package/api/resources/intelligentFields/types/IntelligentFieldType.d.ts +10 -0
  199. package/api/resources/intelligentFields/types/IntelligentFieldType.js +10 -0
  200. package/api/resources/intelligentFields/types/index.d.ts +0 -1
  201. package/api/resources/intelligentFields/types/index.js +0 -1
  202. package/api/resources/knowledge/client/Client.d.ts +35 -0
  203. package/api/resources/knowledge/client/Client.js +50 -16
  204. package/api/resources/knowledge/types/KnowledgeDocumentFilter.d.ts +13 -0
  205. package/api/resources/knowledge/types/KnowledgeDocumentRequest.d.ts +4 -2
  206. package/api/resources/knowledge/types/KnowledgeDocumentResponse.d.ts +33 -9
  207. package/api/resources/knowledge/types/KnowledgeDocumentSearchResponse.d.ts +7 -1
  208. package/api/resources/organizations/client/Client.d.ts +12 -0
  209. package/api/resources/organizations/client/Client.js +17 -4
  210. package/api/resources/segments/client/Client.d.ts +10 -0
  211. package/api/resources/segments/client/Client.js +14 -3
  212. package/api/resources/translations/client/Client.d.ts +2 -0
  213. package/api/resources/translations/client/Client.js +4 -1
  214. package/api/resources/triggers/client/Client.d.ts +31 -0
  215. package/api/resources/triggers/client/Client.js +35 -3
  216. package/api/resources/triggers/types/EventTriggerBase.d.ts +0 -4
  217. package/api/resources/triggers/types/EventTriggerRequest.d.ts +4 -0
  218. package/api/resources/triggers/types/EventTriggerResponse.d.ts +11 -3
  219. package/api/resources/users/client/Client.d.ts +10 -0
  220. package/api/resources/users/client/Client.js +13 -2
  221. package/api/resources/voice/client/Client.d.ts +2 -0
  222. package/api/resources/voice/client/Client.js +4 -1
  223. package/api/resources/voiceConversations/client/Client.d.ts +4 -1
  224. package/api/resources/voiceConversations/client/Client.js +2 -1
  225. package/api/resources/voiceConversations/client/Socket.d.ts +11 -0
  226. package/api/resources/voiceConversations/client/Socket.js +15 -0
  227. package/core/fetcher/Fetcher.js +9 -92
  228. package/core/fetcher/getResponseBody.js +11 -0
  229. package/core/fetcher/makePassthroughRequest.js +26 -4
  230. package/core/fetcher/redactUrl.d.ts +2 -0
  231. package/core/fetcher/redactUrl.js +88 -0
  232. package/core/fetcher/signals.js +9 -1
  233. package/core/file/file.js +3 -0
  234. package/core/form-data-utils/FormDataWrapper.js +3 -0
  235. package/core/requestBody.d.ts +12 -0
  236. package/core/requestBody.js +26 -0
  237. package/core/runtime/index.d.ts +1 -1
  238. package/core/runtime/index.js +2 -1
  239. package/core/runtime/runtime.d.ts +19 -0
  240. package/core/runtime/runtime.js +74 -2
  241. package/core/schemas/builders/schema-utils/JsonError.js +2 -2
  242. package/core/schemas/builders/schema-utils/ParseError.js +2 -2
  243. package/core/stream/Stream.d.ts +45 -1
  244. package/core/stream/Stream.js +323 -84
  245. package/core/stream/index.d.ts +1 -0
  246. package/core/url/qs.js +2 -2
  247. package/core/websocket/ws.d.ts +6 -0
  248. package/core/websocket/ws.js +14 -1
  249. package/errors/MavenAGIError.d.ts +1 -0
  250. package/errors/MavenAGIError.js +5 -1
  251. package/errors/MavenAGITimeoutError.d.ts +2 -2
  252. package/errors/MavenAGITimeoutError.js +40 -6
  253. package/package.json +2 -2
  254. package/reference.md +1170 -126
  255. package/serialization/resources/capabilities/client/index.d.ts +1 -0
  256. package/serialization/resources/capabilities/client/index.js +17 -0
  257. package/serialization/resources/capabilities/client/requests/CapabilitiesSearchRequest.d.ts +21 -0
  258. package/serialization/resources/capabilities/client/requests/CapabilitiesSearchRequest.js +55 -0
  259. package/serialization/resources/capabilities/client/requests/PatchCapabilityByTypeRequest.d.ts +10 -0
  260. package/serialization/resources/capabilities/client/requests/PatchCapabilityByTypeRequest.js +42 -0
  261. package/serialization/resources/capabilities/client/requests/index.d.ts +2 -0
  262. package/serialization/resources/capabilities/client/requests/index.js +7 -0
  263. package/serialization/resources/capabilities/index.d.ts +2 -0
  264. package/serialization/resources/capabilities/index.js +18 -0
  265. package/serialization/resources/capabilities/types/CapabilitiesSearchResponse.d.ts +11 -0
  266. package/serialization/resources/capabilities/types/CapabilitiesSearchResponse.js +45 -0
  267. package/serialization/resources/capabilities/types/CapabilityResponse.d.ts +23 -0
  268. package/serialization/resources/capabilities/types/CapabilityResponse.js +53 -0
  269. package/serialization/resources/capabilities/types/CapabilitySortField.d.ts +7 -0
  270. package/serialization/resources/{intelligentFields/types/IntelligentFieldStatus.js → capabilities/types/CapabilitySortField.js} +2 -2
  271. package/serialization/resources/capabilities/types/CapabilitySummary.d.ts +13 -0
  272. package/serialization/resources/capabilities/types/CapabilitySummary.js +47 -0
  273. package/serialization/resources/capabilities/types/index.d.ts +4 -0
  274. package/serialization/resources/capabilities/types/index.js +20 -0
  275. package/serialization/resources/charters/client/index.d.ts +1 -0
  276. package/serialization/resources/charters/client/index.js +17 -0
  277. package/serialization/resources/charters/client/requests/CharterPatchRequest.d.ts +24 -0
  278. package/serialization/resources/charters/client/requests/CharterPatchRequest.js +57 -0
  279. package/serialization/resources/charters/client/requests/index.d.ts +1 -0
  280. package/serialization/resources/charters/client/requests/index.js +5 -0
  281. package/serialization/resources/charters/index.d.ts +1 -0
  282. package/serialization/resources/charters/index.js +1 -0
  283. package/serialization/resources/charters/types/CharterAncestorsResponse.d.ts +10 -0
  284. package/serialization/resources/charters/types/CharterAncestorsResponse.js +42 -0
  285. package/serialization/resources/charters/types/CharterBase.d.ts +11 -0
  286. package/serialization/resources/charters/types/CharterBase.js +43 -0
  287. package/serialization/resources/charters/types/CharterChildrenGroup.d.ts +13 -0
  288. package/serialization/resources/charters/types/CharterChildrenGroup.js +45 -0
  289. package/serialization/resources/charters/types/CharterContent.d.ts +19 -0
  290. package/serialization/resources/charters/types/CharterContent.js +54 -0
  291. package/serialization/resources/charters/types/CharterKnowledgeBaseReference.d.ts +11 -0
  292. package/serialization/resources/charters/types/CharterKnowledgeBaseReference.js +44 -0
  293. package/serialization/resources/charters/types/CharterListChildrenRequest.d.ts +11 -0
  294. package/serialization/resources/charters/types/CharterListChildrenRequest.js +45 -0
  295. package/serialization/resources/charters/types/CharterListChildrenResponse.d.ts +11 -0
  296. package/serialization/resources/charters/types/CharterListChildrenResponse.js +45 -0
  297. package/serialization/resources/charters/types/CharterPatchReferences.d.ts +12 -0
  298. package/serialization/resources/charters/types/CharterPatchReferences.js +44 -0
  299. package/serialization/resources/charters/types/CharterReferences.d.ts +12 -0
  300. package/serialization/resources/charters/types/CharterReferences.js +44 -0
  301. package/serialization/resources/charters/types/CharterRequest.d.ts +13 -0
  302. package/serialization/resources/charters/types/CharterRequest.js +47 -0
  303. package/serialization/resources/charters/types/CharterResponse.d.ts +25 -0
  304. package/serialization/resources/charters/types/CharterResponse.js +60 -0
  305. package/serialization/resources/charters/types/CharterSearchField.d.ts +7 -0
  306. package/serialization/resources/charters/types/CharterSearchField.js +39 -0
  307. package/serialization/resources/charters/types/CharterSearchFilter.d.ts +12 -0
  308. package/serialization/resources/charters/types/CharterSearchFilter.js +44 -0
  309. package/serialization/resources/charters/types/CharterSearchRequest.d.ts +13 -0
  310. package/serialization/resources/charters/types/CharterSearchRequest.js +47 -0
  311. package/serialization/resources/charters/types/CharterSearchResponse.d.ts +11 -0
  312. package/serialization/resources/charters/types/CharterSearchResponse.js +45 -0
  313. package/serialization/resources/charters/types/CharterSummary.d.ts +0 -2
  314. package/serialization/resources/charters/types/CharterSummary.js +0 -2
  315. package/serialization/resources/charters/types/index.d.ts +15 -0
  316. package/serialization/resources/charters/types/index.js +15 -0
  317. package/serialization/resources/commons/types/ActionResponse.d.ts +3 -2
  318. package/serialization/resources/commons/types/ActionResponse.js +4 -2
  319. package/serialization/resources/commons/types/BaseConversationResponse.d.ts +1 -0
  320. package/serialization/resources/commons/types/BaseConversationResponse.js +1 -0
  321. package/serialization/resources/commons/types/CapabilityBase.d.ts +14 -0
  322. package/serialization/resources/commons/types/CapabilityBase.js +46 -0
  323. package/serialization/resources/{intelligentFields/types/IntelligentFieldStatus.d.ts → commons/types/CapabilityStatus.d.ts} +2 -2
  324. package/serialization/resources/commons/types/CapabilityStatus.js +39 -0
  325. package/serialization/resources/commons/types/CapabilityType.d.ts +7 -0
  326. package/serialization/resources/commons/types/CapabilityType.js +39 -0
  327. package/serialization/resources/commons/types/EntityType.d.ts +1 -1
  328. package/serialization/resources/commons/types/EntityType.js +1 -1
  329. package/serialization/resources/commons/types/ErrorMessage.d.ts +2 -0
  330. package/serialization/resources/commons/types/ErrorMessage.js +2 -0
  331. package/serialization/resources/commons/types/ErrorReason.d.ts +7 -0
  332. package/serialization/resources/commons/types/ErrorReason.js +49 -0
  333. package/serialization/resources/commons/types/MetadataComparisonCondition.d.ts +11 -0
  334. package/serialization/resources/commons/types/MetadataComparisonCondition.js +43 -0
  335. package/serialization/resources/commons/types/MetadataComparisonOperator.d.ts +7 -0
  336. package/serialization/resources/commons/types/MetadataComparisonOperator.js +39 -0
  337. package/serialization/resources/commons/types/MetadataCondition.d.ts +19 -0
  338. package/serialization/resources/commons/types/MetadataCondition.js +51 -0
  339. package/serialization/resources/commons/types/MetadataEntryCondition.d.ts +11 -0
  340. package/serialization/resources/commons/types/MetadataEntryCondition.js +43 -0
  341. package/serialization/resources/commons/types/MetadataFilter.d.ts +14 -0
  342. package/serialization/resources/commons/types/MetadataFilter.js +49 -0
  343. package/serialization/resources/commons/types/MetadataFilterGroup.d.ts +11 -0
  344. package/serialization/resources/commons/types/MetadataFilterGroup.js +44 -0
  345. package/serialization/resources/commons/types/SystemEventName.d.ts +1 -1
  346. package/serialization/resources/commons/types/SystemEventName.js +1 -0
  347. package/serialization/resources/commons/types/index.d.ts +10 -0
  348. package/serialization/resources/commons/types/index.js +10 -0
  349. package/serialization/resources/conversationKickoffs/client/index.d.ts +1 -0
  350. package/serialization/resources/conversationKickoffs/client/index.js +17 -0
  351. package/serialization/resources/conversationKickoffs/client/requests/CreateConversationKickoffRequest.d.ts +12 -0
  352. package/serialization/resources/conversationKickoffs/client/requests/CreateConversationKickoffRequest.js +44 -0
  353. package/serialization/resources/conversationKickoffs/client/requests/index.d.ts +1 -0
  354. package/serialization/resources/conversationKickoffs/client/requests/index.js +5 -0
  355. package/serialization/resources/conversationKickoffs/index.d.ts +2 -0
  356. package/serialization/resources/conversationKickoffs/index.js +18 -0
  357. package/serialization/resources/conversationKickoffs/types/ConversationKickoff.d.ts +11 -0
  358. package/serialization/resources/conversationKickoffs/types/ConversationKickoff.js +45 -0
  359. package/serialization/resources/conversationKickoffs/types/index.d.ts +1 -0
  360. package/serialization/resources/conversationKickoffs/types/index.js +17 -0
  361. package/serialization/resources/index.d.ts +7 -0
  362. package/serialization/resources/index.js +8 -1
  363. package/serialization/resources/intelligentFields/client/requests/IntelligentFieldPatchRequest.d.ts +3 -2
  364. package/serialization/resources/intelligentFields/client/requests/IntelligentFieldPatchRequest.js +3 -2
  365. package/serialization/resources/intelligentFields/types/EnumOption.d.ts +1 -0
  366. package/serialization/resources/intelligentFields/types/EnumOption.js +1 -0
  367. package/serialization/resources/intelligentFields/types/IntelligentFieldCore.d.ts +0 -2
  368. package/serialization/resources/intelligentFields/types/IntelligentFieldCore.js +0 -2
  369. package/serialization/resources/intelligentFields/types/IntelligentFieldRequest.d.ts +2 -0
  370. package/serialization/resources/intelligentFields/types/IntelligentFieldRequest.js +2 -0
  371. package/serialization/resources/intelligentFields/types/IntelligentFieldResponse.d.ts +2 -5
  372. package/serialization/resources/intelligentFields/types/IntelligentFieldResponse.js +3 -5
  373. package/serialization/resources/intelligentFields/types/index.d.ts +0 -1
  374. package/serialization/resources/intelligentFields/types/index.js +0 -1
  375. package/serialization/resources/knowledge/types/KnowledgeDocumentFilter.d.ts +2 -0
  376. package/serialization/resources/knowledge/types/KnowledgeDocumentFilter.js +2 -0
  377. package/serialization/resources/knowledge/types/KnowledgeDocumentResponse.d.ts +0 -2
  378. package/serialization/resources/knowledge/types/KnowledgeDocumentResponse.js +0 -2
  379. package/serialization/resources/knowledge/types/KnowledgeDocumentSearchResponse.d.ts +2 -0
  380. package/serialization/resources/knowledge/types/KnowledgeDocumentSearchResponse.js +2 -0
  381. package/serialization/resources/triggers/types/EventTriggerBase.d.ts +0 -2
  382. package/serialization/resources/triggers/types/EventTriggerBase.js +0 -2
  383. package/serialization/resources/triggers/types/EventTriggerRequest.d.ts +2 -0
  384. package/serialization/resources/triggers/types/EventTriggerRequest.js +2 -0
  385. package/serialization/resources/triggers/types/EventTriggerResponse.d.ts +2 -1
  386. package/serialization/resources/triggers/types/EventTriggerResponse.js +3 -1
  387. package/version.d.ts +1 -1
  388. package/version.js +1 -1
  389. package/api/resources/intelligentFields/types/IntelligentFieldStatus.d.ts +0 -7
  390. package/api/resources/intelligentFields/types/IntelligentFieldStatus.js +0 -10
@@ -40,8 +40,14 @@ const json_1 = require("../json");
40
40
  const runtime_1 = require("../runtime");
41
41
  const DATA_PREFIX = "data:";
42
42
  const EVENT_PREFIX = "event:";
43
+ const ID_PREFIX = "id:";
44
+ const RETRY_PREFIX = "retry:";
45
+ const DEFAULT_MAX_RECONNECTION_ATTEMPTS = 5;
46
+ const DEFAULT_RECONNECT_DELAY_MS = 1000;
47
+ const MAX_RECONNECT_DELAY_MS = 30000;
43
48
  class Stream {
44
- constructor({ stream, parse, eventShape, signal }) {
49
+ constructor({ stream, parse, eventShape, signal, reconnectionEnabled, maxReconnectionAttempts, reconnect, }) {
50
+ var _a;
45
51
  this.controller = new AbortController();
46
52
  this.stream = stream;
47
53
  this.parse = parse;
@@ -50,11 +56,20 @@ class Stream {
50
56
  this.messageTerminator = "\n";
51
57
  this.streamTerminator = eventShape.streamTerminator;
52
58
  this.eventDiscriminator = eventShape.eventDiscriminator;
59
+ this.resumable = (_a = eventShape.resumable) !== null && _a !== void 0 ? _a : false;
53
60
  }
54
61
  else {
55
62
  this.messageTerminator = eventShape.messageTerminator;
63
+ this.resumable = false;
64
+ }
65
+ this.reconnectionEnabled = reconnectionEnabled !== null && reconnectionEnabled !== void 0 ? reconnectionEnabled : true;
66
+ this.maxReconnectionAttempts = maxReconnectionAttempts !== null && maxReconnectionAttempts !== void 0 ? maxReconnectionAttempts : DEFAULT_MAX_RECONNECTION_ATTEMPTS;
67
+ this.reconnect = reconnect;
68
+ if (signal != null) {
69
+ this.externalSignal = signal;
70
+ this.onExternalAbort = () => this.controller.abort();
71
+ signal.addEventListener("abort", this.onExternalAbort, { once: true });
56
72
  }
57
- signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", () => this.controller.abort());
58
73
  // Initialize shared TextDecoder
59
74
  if (typeof TextDecoder !== "undefined") {
60
75
  this.decoder = new TextDecoder("utf-8");
@@ -73,98 +88,227 @@ class Stream {
73
88
  iterDataMessages() {
74
89
  return __asyncGenerator(this, arguments, function* iterDataMessages_1() {
75
90
  var _a, e_1, _b, _c;
76
- const stream = readableStreamAsyncIterable(this.stream);
77
- let buf = "";
78
- let prefixSeen = false;
79
- try {
80
- for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
81
- _c = stream_1_1.value;
82
- _d = false;
83
- const chunk = _c;
84
- buf += this.decodeChunk(chunk);
85
- let terminatorIndex;
86
- while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) {
87
- let line = buf.slice(0, terminatorIndex);
88
- buf = buf.slice(terminatorIndex + this.messageTerminator.length);
89
- if (!line.trim()) {
90
- continue;
91
- }
92
- if (!prefixSeen && this.prefix != null) {
93
- const prefixIndex = line.indexOf(this.prefix);
94
- if (prefixIndex === -1) {
91
+ let reconnectAttempts = 0;
92
+ let currentStream = this.stream;
93
+ let lastId;
94
+ // The id of the most recently *dispatched* event. Per the WHATWG
95
+ // EventSource spec, the "last event ID" is only committed when an event
96
+ // is dispatched, not when the `id:` line is parsed. Reconnecting with a
97
+ // parsed-but-undispatched id would skip an event that was never yielded
98
+ // (e.g. if the connection drops after `id:` but before the event's
99
+ // terminating blank line), so reconnection uses lastDispatchedId.
100
+ let lastDispatchedId;
101
+ let lastRetry;
102
+ while (true) {
103
+ const stream = readableStreamAsyncIterable(currentStream);
104
+ let buf = "";
105
+ let dataValue;
106
+ try {
107
+ for (var _d = true, stream_1 = (e_1 = void 0, __asyncValues(stream)), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
108
+ _c = stream_1_1.value;
109
+ _d = false;
110
+ const chunk = _c;
111
+ buf += this.decodeChunk(chunk);
112
+ let terminatorIndex;
113
+ while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) {
114
+ const line = buf.slice(0, terminatorIndex);
115
+ buf = buf.slice(terminatorIndex + this.messageTerminator.length);
116
+ if (!line.trim()) {
117
+ if (this.prefix != null && dataValue != null) {
118
+ if (this.streamTerminator != null && dataValue.includes(this.streamTerminator)) {
119
+ return yield __await(void 0);
120
+ }
121
+ const data = yield __await(this.parse((0, json_1.fromJson)(dataValue)));
122
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: undefined });
123
+ lastDispatchedId = lastId;
124
+ reconnectAttempts = 0;
125
+ dataValue = undefined;
126
+ }
95
127
  continue;
96
128
  }
97
- prefixSeen = true;
98
- line = line.slice(prefixIndex + this.prefix.length);
99
- }
100
- if (this.streamTerminator != null && line.includes(this.streamTerminator)) {
101
- return yield __await(void 0);
129
+ if (line.startsWith(ID_PREFIX)) {
130
+ const idValue = line.slice(ID_PREFIX.length).trim();
131
+ if (!idValue.includes("\0")) {
132
+ lastId = idValue;
133
+ }
134
+ continue;
135
+ }
136
+ if (line.startsWith(RETRY_PREFIX)) {
137
+ const retryValue = line.slice(RETRY_PREFIX.length).trim();
138
+ const parsed = parseInt(retryValue, 10);
139
+ if (!Number.isNaN(parsed) && String(parsed) === retryValue) {
140
+ lastRetry = parsed;
141
+ }
142
+ continue;
143
+ }
144
+ if (this.prefix != null) {
145
+ const prefixIndex = line.indexOf(this.prefix);
146
+ if (prefixIndex === -1) {
147
+ continue;
148
+ }
149
+ const val = line.slice(prefixIndex + this.prefix.length).trim();
150
+ dataValue = dataValue != null ? `${dataValue}\n${val}` : val;
151
+ }
152
+ else {
153
+ if (this.streamTerminator != null && line.includes(this.streamTerminator)) {
154
+ return yield __await(void 0);
155
+ }
156
+ const data = yield __await(this.parse((0, json_1.fromJson)(line)));
157
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: undefined });
158
+ lastDispatchedId = lastId;
159
+ reconnectAttempts = 0;
160
+ }
102
161
  }
103
- const message = yield __await(this.parse((0, json_1.fromJson)(line)));
104
- yield yield __await(message);
105
- prefixSeen = false;
106
162
  }
107
163
  }
108
- }
109
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
110
- finally {
164
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
165
+ finally {
166
+ try {
167
+ if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
168
+ }
169
+ finally { if (e_1) throw e_1.error; }
170
+ }
171
+ if (this.prefix != null && dataValue != null) {
172
+ if (this.streamTerminator != null && dataValue.includes(this.streamTerminator)) {
173
+ return yield __await(void 0);
174
+ }
175
+ const data = yield __await(this.parse((0, json_1.fromJson)(dataValue)));
176
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: undefined });
177
+ lastDispatchedId = lastId;
178
+ reconnectAttempts = 0;
179
+ }
180
+ if (!this.shouldReconnect(lastDispatchedId, reconnectAttempts)) {
181
+ return yield __await(void 0);
182
+ }
183
+ reconnectAttempts++;
184
+ yield __await(this.delayReconnect(lastRetry));
185
+ if (this.controller.signal.aborted) {
186
+ return yield __await(void 0);
187
+ }
188
+ // Re-check after async delay; needed for TypeScript narrowing.
189
+ const reconnectFn = this.reconnect;
190
+ if (reconnectFn == null || lastDispatchedId == null) {
191
+ return yield __await(void 0);
192
+ }
111
193
  try {
112
- if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
194
+ const reconnected = yield __await(reconnectFn(lastDispatchedId));
195
+ if (reconnected == null) {
196
+ currentStream = this.createEmptyStream();
197
+ continue;
198
+ }
199
+ currentStream = reconnected;
200
+ }
201
+ catch (_e) {
202
+ // Failed reconnect (e.g. HTTP error); assign an empty stream
203
+ // so the next iteration is a safe no-op before shouldReconnect.
204
+ currentStream = this.createEmptyStream();
113
205
  }
114
- finally { if (e_1) throw e_1.error; }
115
206
  }
116
207
  });
117
208
  }
118
209
  iterSseEvents() {
119
210
  return __asyncGenerator(this, arguments, function* iterSseEvents_1() {
120
211
  var _a, e_2, _b, _c;
121
- const stream = readableStreamAsyncIterable(this.stream);
122
- let buf = "";
123
- let eventType;
124
- let dataValue;
125
- try {
126
- for (var _d = true, stream_2 = __asyncValues(stream), stream_2_1; stream_2_1 = yield __await(stream_2.next()), _a = stream_2_1.done, !_a; _d = true) {
127
- _c = stream_2_1.value;
128
- _d = false;
129
- const chunk = _c;
130
- buf += this.decodeChunk(chunk);
131
- let terminatorIndex;
132
- while ((terminatorIndex = buf.indexOf("\n")) >= 0) {
133
- const line = buf.slice(0, terminatorIndex).replace(/\r$/, "");
134
- buf = buf.slice(terminatorIndex + 1);
135
- if (!line.trim()) {
136
- if (dataValue != null) {
137
- const message = yield __await(this.dispatchSseEvent(dataValue, eventType));
138
- if (message == null) {
139
- return yield __await(void 0);
212
+ let reconnectAttempts = 0;
213
+ let currentStream = this.stream;
214
+ let lastId;
215
+ // See iterDataMessages: reconnection uses the last *dispatched* id (per
216
+ // the EventSource spec), not the last *parsed* id, to avoid skipping an
217
+ // event that was never yielded when a drop lands mid-event.
218
+ let lastDispatchedId;
219
+ let lastRetry;
220
+ while (true) {
221
+ const stream = readableStreamAsyncIterable(currentStream);
222
+ let buf = "";
223
+ let eventType;
224
+ let dataValue;
225
+ try {
226
+ for (var _d = true, stream_2 = (e_2 = void 0, __asyncValues(stream)), stream_2_1; stream_2_1 = yield __await(stream_2.next()), _a = stream_2_1.done, !_a; _d = true) {
227
+ _c = stream_2_1.value;
228
+ _d = false;
229
+ const chunk = _c;
230
+ buf += this.decodeChunk(chunk);
231
+ let terminatorIndex;
232
+ while ((terminatorIndex = buf.indexOf("\n")) >= 0) {
233
+ const line = buf.slice(0, terminatorIndex).replace(/\r$/, "");
234
+ buf = buf.slice(terminatorIndex + 1);
235
+ if (!line.trim()) {
236
+ if (dataValue != null) {
237
+ const data = yield __await(this.dispatchSseEvent(dataValue, eventType));
238
+ if (data == null) {
239
+ return yield __await(void 0);
240
+ }
241
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: eventType });
242
+ lastDispatchedId = lastId;
243
+ reconnectAttempts = 0;
244
+ }
245
+ eventType = undefined;
246
+ dataValue = undefined;
247
+ continue;
248
+ }
249
+ if (line.startsWith(EVENT_PREFIX)) {
250
+ eventType = line.slice(EVENT_PREFIX.length).trim();
251
+ }
252
+ else if (line.startsWith(DATA_PREFIX)) {
253
+ const val = line.slice(DATA_PREFIX.length).trim();
254
+ dataValue = dataValue != null ? `${dataValue}\n${val}` : val;
255
+ }
256
+ else if (line.startsWith(ID_PREFIX)) {
257
+ const idValue = line.slice(ID_PREFIX.length).trim();
258
+ if (!idValue.includes("\0")) {
259
+ lastId = idValue;
260
+ }
261
+ }
262
+ else if (line.startsWith(RETRY_PREFIX)) {
263
+ const retryValue = line.slice(RETRY_PREFIX.length).trim();
264
+ const parsed = parseInt(retryValue, 10);
265
+ if (!Number.isNaN(parsed) && String(parsed) === retryValue) {
266
+ lastRetry = parsed;
140
267
  }
141
- yield yield __await(message);
142
268
  }
143
- eventType = undefined;
144
- dataValue = undefined;
145
- continue;
146
- }
147
- if (line.startsWith(EVENT_PREFIX)) {
148
- eventType = line.slice(EVENT_PREFIX.length).trim();
149
- }
150
- else if (line.startsWith(DATA_PREFIX)) {
151
- const val = line.slice(DATA_PREFIX.length).trim();
152
- dataValue = dataValue != null ? `${dataValue}\n${val}` : val;
153
269
  }
154
270
  }
155
271
  }
156
- }
157
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
158
- finally {
272
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
273
+ finally {
274
+ try {
275
+ if (!_d && !_a && (_b = stream_2.return)) yield __await(_b.call(stream_2));
276
+ }
277
+ finally { if (e_2) throw e_2.error; }
278
+ }
279
+ if (dataValue != null) {
280
+ const data = yield __await(this.dispatchSseEvent(dataValue, eventType));
281
+ if (data != null) {
282
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: eventType });
283
+ lastDispatchedId = lastId;
284
+ reconnectAttempts = 0;
285
+ }
286
+ }
287
+ if (!this.shouldReconnect(lastDispatchedId, reconnectAttempts)) {
288
+ return yield __await(void 0);
289
+ }
290
+ reconnectAttempts++;
291
+ yield __await(this.delayReconnect(lastRetry));
292
+ if (this.controller.signal.aborted) {
293
+ return yield __await(void 0);
294
+ }
295
+ // Re-check after async delay; needed for TypeScript narrowing.
296
+ const reconnectFn = this.reconnect;
297
+ if (reconnectFn == null || lastDispatchedId == null) {
298
+ return yield __await(void 0);
299
+ }
159
300
  try {
160
- if (!_d && !_a && (_b = stream_2.return)) yield __await(_b.call(stream_2));
301
+ const reconnected = yield __await(reconnectFn(lastDispatchedId));
302
+ if (reconnected == null) {
303
+ currentStream = this.createEmptyStream();
304
+ continue;
305
+ }
306
+ currentStream = reconnected;
161
307
  }
162
- finally { if (e_2) throw e_2.error; }
163
- }
164
- if (dataValue != null) {
165
- const message = yield __await(this.dispatchSseEvent(dataValue, eventType));
166
- if (message != null) {
167
- yield yield __await(message);
308
+ catch (_e) {
309
+ // Failed reconnect (e.g. HTTP error); assign an empty stream
310
+ // so the next iteration is a safe no-op before shouldReconnect.
311
+ currentStream = this.createEmptyStream();
168
312
  }
169
313
  }
170
314
  });
@@ -180,6 +324,96 @@ class Stream {
180
324
  return this.parse(this.injectDiscriminator((0, json_1.fromJson)(dataValue), eventType));
181
325
  });
182
326
  }
327
+ /**
328
+ * Determines whether a reconnection attempt should be made.
329
+ */
330
+ shouldReconnect(lastId, reconnectAttempts) {
331
+ if (!this.resumable) {
332
+ return false;
333
+ }
334
+ if (this.streamTerminator == null) {
335
+ // Without a terminator the client cannot distinguish a completed
336
+ // stream from a dropped connection, so reconnection is disabled.
337
+ return false;
338
+ }
339
+ // NOTE: When a terminator IS configured but the server never sends it
340
+ // (e.g. it drops the connection after emitting events every time),
341
+ // maxReconnectionAttempts is a per-consecutive-failure cap — each
342
+ // yielded event resets the counter. This matches EventSource semantics
343
+ // but means such a server can cause unbounded reconnections. Callers
344
+ // concerned about this should impose a wall-clock budget externally.
345
+ if (!this.reconnectionEnabled) {
346
+ return false;
347
+ }
348
+ if (this.reconnect == null) {
349
+ return false;
350
+ }
351
+ if (lastId == null || lastId === "") {
352
+ return false;
353
+ }
354
+ if (reconnectAttempts >= this.maxReconnectionAttempts) {
355
+ return false;
356
+ }
357
+ if (this.controller.signal.aborted) {
358
+ return false;
359
+ }
360
+ return true;
361
+ }
362
+ /**
363
+ * Delays before reconnecting, using a server-sent retry directive if provided
364
+ * (clamped to MAX_RECONNECT_DELAY_MS), otherwise falling back to
365
+ * DEFAULT_RECONNECT_DELAY_MS. The delay is abortable: if the stream's abort
366
+ * signal fires during the wait, the promise resolves immediately.
367
+ */
368
+ delayReconnect(lastRetry) {
369
+ return __awaiter(this, void 0, void 0, function* () {
370
+ const base = lastRetry != null && lastRetry > 0 ? lastRetry : DEFAULT_RECONNECT_DELAY_MS;
371
+ const delay = Math.min(base, MAX_RECONNECT_DELAY_MS);
372
+ const signal = this.controller.signal;
373
+ if (signal.aborted) {
374
+ return;
375
+ }
376
+ yield new Promise((resolve) => {
377
+ const timer = setTimeout(() => {
378
+ signal.removeEventListener("abort", onAbort);
379
+ resolve();
380
+ }, delay);
381
+ const onAbort = () => {
382
+ clearTimeout(timer);
383
+ resolve();
384
+ };
385
+ signal.addEventListener("abort", onAbort, { once: true });
386
+ });
387
+ });
388
+ }
389
+ createEmptyStream() {
390
+ return new ReadableStream({
391
+ start(controller) {
392
+ controller.close();
393
+ },
394
+ });
395
+ }
396
+ removeAbortListener() {
397
+ if (this.externalSignal != null && this.onExternalAbort != null) {
398
+ this.externalSignal.removeEventListener("abort", this.onExternalAbort);
399
+ this.onExternalAbort = undefined;
400
+ }
401
+ }
402
+ withMetadata() {
403
+ const self = this;
404
+ return {
405
+ [Symbol.asyncIterator]() {
406
+ return __asyncGenerator(this, arguments, function* _a() {
407
+ try {
408
+ yield __await(yield* __asyncDelegator(__asyncValues(self.iterMessages())));
409
+ }
410
+ finally {
411
+ self.removeAbortListener();
412
+ }
413
+ });
414
+ },
415
+ };
416
+ }
183
417
  injectDiscriminator(parsed, eventType) {
184
418
  if (this.eventDiscriminator == null || eventType == null) {
185
419
  return parsed;
@@ -197,19 +431,24 @@ class Stream {
197
431
  return __asyncGenerator(this, arguments, function* _a() {
198
432
  var _b, e_3, _c, _d;
199
433
  try {
200
- for (var _e = true, _f = __asyncValues(this.iterMessages()), _g; _g = yield __await(_f.next()), _b = _g.done, !_b; _e = true) {
201
- _d = _g.value;
202
- _e = false;
203
- const message = _d;
204
- yield yield __await(message);
434
+ try {
435
+ for (var _e = true, _f = __asyncValues(this.iterMessages()), _g; _g = yield __await(_f.next()), _b = _g.done, !_b; _e = true) {
436
+ _d = _g.value;
437
+ _e = false;
438
+ const event = _d;
439
+ yield yield __await(event.data);
440
+ }
441
+ }
442
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
443
+ finally {
444
+ try {
445
+ if (!_e && !_b && (_c = _f.return)) yield __await(_c.call(_f));
446
+ }
447
+ finally { if (e_3) throw e_3.error; }
205
448
  }
206
449
  }
207
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
208
450
  finally {
209
- try {
210
- if (!_e && !_b && (_c = _f.return)) yield __await(_c.call(_f));
211
- }
212
- finally { if (e_3) throw e_3.error; }
451
+ this.removeAbortListener();
213
452
  }
214
453
  });
215
454
  }
@@ -1 +1,2 @@
1
+ export type { ServerSentEvent } from "./Stream";
1
2
  export { Stream } from "./Stream";
package/core/url/qs.js CHANGED
@@ -19,7 +19,7 @@ function stringifyObject(obj, prefix = "", options) {
19
19
  const parts = [];
20
20
  for (const [key, value] of Object.entries(obj)) {
21
21
  const fullKey = prefix ? `${prefix}[${key}]` : key;
22
- if (value === undefined) {
22
+ if (value == null) {
23
23
  continue;
24
24
  }
25
25
  if (Array.isArray(value)) {
@@ -39,7 +39,7 @@ function stringifyObject(obj, prefix = "", options) {
39
39
  else {
40
40
  for (let i = 0; i < value.length; i++) {
41
41
  const item = value[i];
42
- if (item === undefined) {
42
+ if (item == null) {
43
43
  continue;
44
44
  }
45
45
  if (typeof item === "object" && !Array.isArray(item) && item !== null) {
@@ -22,6 +22,11 @@ export declare namespace ReconnectingWebSocket {
22
22
  maxEnqueuedMessages?: number;
23
23
  startClosed?: boolean;
24
24
  debug?: boolean;
25
+ /**
26
+ * Decides whether a close event should trigger a reconnect. Return `false` to treat the close as terminal.
27
+ * Not consulted when `close()` was called or the abort signal fired. Defaults to `event.code !== 1000`.
28
+ */
29
+ shouldReconnect?: (event: Events.CloseEvent) => boolean;
25
30
  };
26
31
  type UrlProvider = string | (() => string) | (() => Promise<string>);
27
32
  type Message = string | ArrayBuffer | Blob | ArrayBufferView;
@@ -144,6 +149,7 @@ export declare class ReconnectingWebSocket {
144
149
  private _handleMessage;
145
150
  private _handleError;
146
151
  private _handleClose;
152
+ private _isReconnectableClose;
147
153
  private _removeListeners;
148
154
  private _addListeners;
149
155
  private _clearTimeouts;
@@ -52,6 +52,8 @@ const getGlobalWebSocket = () => {
52
52
  * Returns true if given argument looks like a WebSocket class
53
53
  */
54
54
  const isWebSocket = (w) => typeof w !== "undefined" && !!w && w.CLOSING === 2;
55
+ const NORMAL_CLOSURE_CODE = 1000;
56
+ const defaultShouldReconnect = (event) => event.code !== NORMAL_CLOSURE_CODE;
55
57
  const DEFAULT_OPTIONS = {
56
58
  maxReconnectionDelay: 10000,
57
59
  minReconnectionDelay: 1000 + Math.random() * 4000,
@@ -62,6 +64,7 @@ const DEFAULT_OPTIONS = {
62
64
  maxEnqueuedMessages: Infinity,
63
65
  startClosed: false,
64
66
  debug: false,
67
+ shouldReconnect: defaultShouldReconnect,
65
68
  };
66
69
  class ReconnectingWebSocket {
67
70
  constructor({ url, protocols, options, headers, queryParameters, abortSignal }) {
@@ -153,7 +156,7 @@ class ReconnectingWebSocket {
153
156
  this._handleClose = (event) => {
154
157
  this._debug("close event");
155
158
  this._clearTimeouts();
156
- if (event.code === 1000) {
159
+ if (this._shouldReconnect && !this._isReconnectableClose(event)) {
157
160
  this._shouldReconnect = false;
158
161
  }
159
162
  if (this._shouldReconnect) {
@@ -446,6 +449,16 @@ class ReconnectingWebSocket {
446
449
  listener(event);
447
450
  }
448
451
  }
452
+ _isReconnectableClose(event) {
453
+ const { shouldReconnect = DEFAULT_OPTIONS.shouldReconnect } = this._options;
454
+ try {
455
+ return shouldReconnect(event);
456
+ }
457
+ catch (error) {
458
+ this._debug("shouldReconnect threw, treating close as terminal", error);
459
+ return false;
460
+ }
461
+ }
449
462
  _removeListeners() {
450
463
  if (!this._ws) {
451
464
  return;
@@ -11,4 +11,5 @@ export declare class MavenAGIError extends Error {
11
11
  rawResponse?: core.RawResponse;
12
12
  cause?: unknown;
13
13
  });
14
+ get requestId(): string | undefined;
14
15
  }
@@ -10,7 +10,7 @@ class MavenAGIError extends Error {
10
10
  if (Error.captureStackTrace) {
11
11
  Error.captureStackTrace(this, this.constructor);
12
12
  }
13
- this.name = this.constructor.name;
13
+ this.name = "MavenAGIError";
14
14
  this.statusCode = statusCode;
15
15
  this.body = body;
16
16
  this.rawResponse = rawResponse;
@@ -18,6 +18,10 @@ class MavenAGIError extends Error {
18
18
  this.cause = cause;
19
19
  }
20
20
  }
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;
24
+ }
21
25
  }
22
26
  exports.MavenAGIError = MavenAGIError;
23
27
  function buildMessage({ message, statusCode, body, }) {
@@ -1,5 +1,5 @@
1
- export declare class MavenAGITimeoutError extends Error {
2
- readonly cause?: unknown;
1
+ import * as errors from "./index";
2
+ export declare class MavenAGITimeoutError extends errors.MavenAGIError {
3
3
  constructor(message: string, opts?: {
4
4
  cause?: unknown;
5
5
  });
@@ -1,18 +1,52 @@
1
1
  "use strict";
2
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
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
4
37
  exports.MavenAGITimeoutError = void 0;
5
- class MavenAGITimeoutError extends Error {
38
+ const errors = __importStar(require("./index"));
39
+ class MavenAGITimeoutError extends errors.MavenAGIError {
6
40
  constructor(message, opts) {
7
- super(message);
41
+ super({
42
+ message: message,
43
+ cause: opts === null || opts === void 0 ? void 0 : opts.cause,
44
+ });
8
45
  Object.setPrototypeOf(this, new.target.prototype);
9
46
  if (Error.captureStackTrace) {
10
47
  Error.captureStackTrace(this, this.constructor);
11
48
  }
12
- this.name = this.constructor.name;
13
- if ((opts === null || opts === void 0 ? void 0 : opts.cause) != null) {
14
- this.cause = opts.cause;
15
- }
49
+ this.name = "MavenAGITimeoutError";
16
50
  }
17
51
  }
18
52
  exports.MavenAGITimeoutError = MavenAGITimeoutError;