@credal/sdk 0.0.13 → 0.0.14

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 (202) hide show
  1. package/api/resources/common/types/index.d.ts +1 -0
  2. package/api/resources/common/types/index.js +1 -0
  3. package/api/resources/copilots/client/Client.d.ts +12 -1
  4. package/api/resources/copilots/client/Client.js +79 -9
  5. package/api/resources/copilots/client/requests/SendMessageRequest.d.ts +14 -1
  6. package/api/resources/copilots/client/requests/StreamMessageRequest.d.ts +60 -0
  7. package/api/resources/copilots/client/requests/StreamMessageRequest.js +5 -0
  8. package/api/resources/copilots/client/requests/index.d.ts +1 -0
  9. package/api/resources/copilots/types/BlockedChunk.d.ts +10 -0
  10. package/api/resources/copilots/types/BlockedChunk.js +5 -0
  11. package/api/resources/copilots/types/BooleanFieldSchema.d.ts +8 -0
  12. package/api/resources/copilots/types/BooleanFieldSchema.js +5 -0
  13. package/api/resources/copilots/types/CollectionFilteredData.d.ts +9 -0
  14. package/api/resources/copilots/types/CollectionFilteredData.js +5 -0
  15. package/api/resources/copilots/types/DataChunk.d.ts +6 -0
  16. package/api/resources/copilots/types/DataChunk.js +5 -0
  17. package/api/resources/copilots/types/DataFilter.d.ts +9 -0
  18. package/api/resources/copilots/types/DataFilter.js +5 -0
  19. package/api/resources/copilots/types/DatetimeFieldSchema.d.ts +9 -0
  20. package/api/resources/copilots/types/DatetimeFieldSchema.js +5 -0
  21. package/api/resources/copilots/types/Filter.d.ts +19 -0
  22. package/api/resources/copilots/types/Filter.js +5 -0
  23. package/api/resources/copilots/types/FinalChunk.d.ts +7 -0
  24. package/api/resources/copilots/types/FinalChunk.js +5 -0
  25. package/api/resources/copilots/types/InitialChunk.d.ts +10 -0
  26. package/api/resources/copilots/types/InitialChunk.js +5 -0
  27. package/api/resources/copilots/types/InputVariable.d.ts +7 -0
  28. package/api/resources/copilots/types/InputVariable.js +5 -0
  29. package/api/resources/copilots/types/MessageReply.d.ts +1 -0
  30. package/api/resources/copilots/types/NumberFieldSchema.d.ts +9 -0
  31. package/api/resources/copilots/types/NumberFieldSchema.js +5 -0
  32. package/api/resources/copilots/types/StreamingChunk.d.ts +5 -0
  33. package/api/resources/copilots/types/StreamingChunk.js +5 -0
  34. package/api/resources/copilots/types/StringFieldSchema.d.ts +9 -0
  35. package/api/resources/copilots/types/StringFieldSchema.js +5 -0
  36. package/api/resources/copilots/types/WebSearchResult.d.ts +8 -0
  37. package/api/resources/copilots/types/WebSearchResult.js +5 -0
  38. package/api/resources/copilots/types/index.d.ts +14 -0
  39. package/api/resources/copilots/types/index.js +14 -0
  40. package/api/resources/documentCatalog/client/Client.js +2 -2
  41. package/api/resources/documentCollections/client/Client.js +6 -6
  42. package/api/resources/permissionsService/client/Client.js +3 -3
  43. package/api/resources/search/client/Client.js +1 -1
  44. package/api/resources/search/types/index.d.ts +0 -1
  45. package/api/resources/search/types/index.js +0 -1
  46. package/api/resources/users/client/Client.js +1 -1
  47. package/core/index.d.ts +1 -0
  48. package/core/index.js +1 -0
  49. package/core/streaming-fetcher/Stream.d.ts +48 -0
  50. package/core/streaming-fetcher/Stream.js +170 -0
  51. package/core/streaming-fetcher/index.d.ts +1 -0
  52. package/core/streaming-fetcher/index.js +5 -0
  53. package/dist/api/resources/common/types/index.d.ts +1 -0
  54. package/dist/api/resources/common/types/index.js +1 -0
  55. package/dist/api/resources/copilots/client/Client.d.ts +12 -1
  56. package/dist/api/resources/copilots/client/Client.js +79 -9
  57. package/dist/api/resources/copilots/client/requests/SendMessageRequest.d.ts +14 -1
  58. package/dist/api/resources/copilots/client/requests/StreamMessageRequest.d.ts +60 -0
  59. package/dist/api/resources/copilots/client/requests/StreamMessageRequest.js +5 -0
  60. package/dist/api/resources/copilots/client/requests/index.d.ts +1 -0
  61. package/dist/api/resources/copilots/types/BlockedChunk.d.ts +10 -0
  62. package/dist/api/resources/copilots/types/BlockedChunk.js +5 -0
  63. package/dist/api/resources/copilots/types/BooleanFieldSchema.d.ts +8 -0
  64. package/dist/api/resources/copilots/types/BooleanFieldSchema.js +5 -0
  65. package/dist/api/resources/copilots/types/CollectionFilteredData.d.ts +9 -0
  66. package/dist/api/resources/copilots/types/CollectionFilteredData.js +5 -0
  67. package/dist/api/resources/copilots/types/DataChunk.d.ts +6 -0
  68. package/dist/api/resources/copilots/types/DataChunk.js +5 -0
  69. package/dist/api/resources/copilots/types/DataFilter.d.ts +9 -0
  70. package/dist/api/resources/copilots/types/DataFilter.js +5 -0
  71. package/dist/api/resources/copilots/types/DatetimeFieldSchema.d.ts +9 -0
  72. package/dist/api/resources/copilots/types/DatetimeFieldSchema.js +5 -0
  73. package/dist/api/resources/copilots/types/Filter.d.ts +19 -0
  74. package/dist/api/resources/copilots/types/Filter.js +5 -0
  75. package/dist/api/resources/copilots/types/FinalChunk.d.ts +7 -0
  76. package/dist/api/resources/copilots/types/FinalChunk.js +5 -0
  77. package/dist/api/resources/copilots/types/InitialChunk.d.ts +10 -0
  78. package/dist/api/resources/copilots/types/InitialChunk.js +5 -0
  79. package/dist/api/resources/copilots/types/InputVariable.d.ts +7 -0
  80. package/dist/api/resources/copilots/types/InputVariable.js +5 -0
  81. package/dist/api/resources/copilots/types/MessageReply.d.ts +1 -0
  82. package/dist/api/resources/copilots/types/NumberFieldSchema.d.ts +9 -0
  83. package/dist/api/resources/copilots/types/NumberFieldSchema.js +5 -0
  84. package/dist/api/resources/copilots/types/StreamingChunk.d.ts +5 -0
  85. package/dist/api/resources/copilots/types/StreamingChunk.js +5 -0
  86. package/dist/api/resources/copilots/types/StringFieldSchema.d.ts +9 -0
  87. package/dist/api/resources/copilots/types/StringFieldSchema.js +5 -0
  88. package/dist/api/resources/copilots/types/WebSearchResult.d.ts +8 -0
  89. package/dist/api/resources/copilots/types/WebSearchResult.js +5 -0
  90. package/dist/api/resources/copilots/types/index.d.ts +14 -0
  91. package/dist/api/resources/copilots/types/index.js +14 -0
  92. package/dist/api/resources/documentCatalog/client/Client.js +2 -2
  93. package/dist/api/resources/documentCollections/client/Client.js +6 -6
  94. package/dist/api/resources/permissionsService/client/Client.js +3 -3
  95. package/dist/api/resources/search/client/Client.js +1 -1
  96. package/dist/api/resources/search/types/index.d.ts +0 -1
  97. package/dist/api/resources/search/types/index.js +0 -1
  98. package/dist/api/resources/users/client/Client.js +1 -1
  99. package/dist/core/index.d.ts +1 -0
  100. package/dist/core/index.js +1 -0
  101. package/dist/core/streaming-fetcher/Stream.d.ts +48 -0
  102. package/dist/core/streaming-fetcher/Stream.js +170 -0
  103. package/dist/core/streaming-fetcher/index.d.ts +1 -0
  104. package/dist/core/streaming-fetcher/index.js +5 -0
  105. package/dist/serialization/resources/common/types/index.d.ts +1 -0
  106. package/dist/serialization/resources/common/types/index.js +1 -0
  107. package/dist/serialization/resources/copilots/client/requests/SendMessageRequest.d.ts +2 -0
  108. package/dist/serialization/resources/copilots/client/requests/SendMessageRequest.js +2 -0
  109. package/dist/serialization/resources/copilots/client/requests/StreamMessageRequest.d.ts +17 -0
  110. package/dist/serialization/resources/copilots/client/requests/StreamMessageRequest.js +38 -0
  111. package/dist/serialization/resources/copilots/client/requests/index.d.ts +1 -0
  112. package/dist/serialization/resources/copilots/client/requests/index.js +3 -1
  113. package/dist/serialization/resources/copilots/types/BlockedChunk.d.ts +16 -0
  114. package/dist/serialization/resources/copilots/types/BlockedChunk.js +37 -0
  115. package/dist/serialization/resources/copilots/types/BooleanFieldSchema.d.ts +14 -0
  116. package/dist/serialization/resources/copilots/types/BooleanFieldSchema.js +35 -0
  117. package/dist/serialization/resources/copilots/types/CollectionFilteredData.d.ts +15 -0
  118. package/dist/serialization/resources/copilots/types/CollectionFilteredData.js +36 -0
  119. package/dist/serialization/resources/copilots/types/DataChunk.d.ts +12 -0
  120. package/dist/serialization/resources/copilots/types/DataChunk.js +33 -0
  121. package/dist/serialization/resources/copilots/types/DataFilter.d.ts +15 -0
  122. package/dist/serialization/resources/copilots/types/DataFilter.js +36 -0
  123. package/dist/serialization/resources/copilots/types/DatetimeFieldSchema.d.ts +15 -0
  124. package/dist/serialization/resources/copilots/types/DatetimeFieldSchema.js +36 -0
  125. package/dist/serialization/resources/copilots/types/Filter.d.ts +26 -0
  126. package/dist/serialization/resources/copilots/types/Filter.js +45 -0
  127. package/dist/serialization/resources/copilots/types/FinalChunk.d.ts +13 -0
  128. package/dist/serialization/resources/copilots/types/FinalChunk.js +34 -0
  129. package/dist/serialization/resources/copilots/types/InitialChunk.d.ts +17 -0
  130. package/dist/serialization/resources/copilots/types/InitialChunk.js +38 -0
  131. package/dist/serialization/resources/copilots/types/InputVariable.d.ts +13 -0
  132. package/dist/serialization/resources/copilots/types/InputVariable.js +34 -0
  133. package/dist/serialization/resources/copilots/types/MessageReply.d.ts +2 -0
  134. package/dist/serialization/resources/copilots/types/MessageReply.js +2 -0
  135. package/dist/serialization/resources/copilots/types/NumberFieldSchema.d.ts +15 -0
  136. package/dist/serialization/resources/copilots/types/NumberFieldSchema.js +36 -0
  137. package/dist/serialization/resources/copilots/types/StreamingChunk.d.ts +14 -0
  138. package/dist/serialization/resources/copilots/types/StreamingChunk.js +35 -0
  139. package/dist/serialization/resources/copilots/types/StringFieldSchema.d.ts +15 -0
  140. package/dist/serialization/resources/copilots/types/StringFieldSchema.js +36 -0
  141. package/dist/serialization/resources/copilots/types/WebSearchResult.d.ts +14 -0
  142. package/dist/serialization/resources/copilots/types/WebSearchResult.js +35 -0
  143. package/dist/serialization/resources/copilots/types/index.d.ts +14 -0
  144. package/dist/serialization/resources/copilots/types/index.js +14 -0
  145. package/dist/serialization/resources/search/types/SingleFieldFilter.d.ts +1 -1
  146. package/dist/serialization/resources/search/types/SingleFieldFilter.js +1 -1
  147. package/dist/serialization/resources/search/types/index.d.ts +0 -1
  148. package/dist/serialization/resources/search/types/index.js +0 -1
  149. package/package.json +1 -1
  150. package/reference.md +71 -0
  151. package/serialization/resources/common/types/index.d.ts +1 -0
  152. package/serialization/resources/common/types/index.js +1 -0
  153. package/serialization/resources/copilots/client/requests/SendMessageRequest.d.ts +2 -0
  154. package/serialization/resources/copilots/client/requests/SendMessageRequest.js +2 -0
  155. package/serialization/resources/copilots/client/requests/StreamMessageRequest.d.ts +17 -0
  156. package/serialization/resources/copilots/client/requests/StreamMessageRequest.js +38 -0
  157. package/serialization/resources/copilots/client/requests/index.d.ts +1 -0
  158. package/serialization/resources/copilots/client/requests/index.js +3 -1
  159. package/serialization/resources/copilots/types/BlockedChunk.d.ts +16 -0
  160. package/serialization/resources/copilots/types/BlockedChunk.js +37 -0
  161. package/serialization/resources/copilots/types/BooleanFieldSchema.d.ts +14 -0
  162. package/serialization/resources/copilots/types/BooleanFieldSchema.js +35 -0
  163. package/serialization/resources/copilots/types/CollectionFilteredData.d.ts +15 -0
  164. package/serialization/resources/copilots/types/CollectionFilteredData.js +36 -0
  165. package/serialization/resources/copilots/types/DataChunk.d.ts +12 -0
  166. package/serialization/resources/copilots/types/DataChunk.js +33 -0
  167. package/serialization/resources/copilots/types/DataFilter.d.ts +15 -0
  168. package/serialization/resources/copilots/types/DataFilter.js +36 -0
  169. package/serialization/resources/copilots/types/DatetimeFieldSchema.d.ts +15 -0
  170. package/serialization/resources/copilots/types/DatetimeFieldSchema.js +36 -0
  171. package/serialization/resources/copilots/types/Filter.d.ts +26 -0
  172. package/serialization/resources/copilots/types/Filter.js +45 -0
  173. package/serialization/resources/copilots/types/FinalChunk.d.ts +13 -0
  174. package/serialization/resources/copilots/types/FinalChunk.js +34 -0
  175. package/serialization/resources/copilots/types/InitialChunk.d.ts +17 -0
  176. package/serialization/resources/copilots/types/InitialChunk.js +38 -0
  177. package/serialization/resources/copilots/types/InputVariable.d.ts +13 -0
  178. package/serialization/resources/copilots/types/InputVariable.js +34 -0
  179. package/serialization/resources/copilots/types/MessageReply.d.ts +2 -0
  180. package/serialization/resources/copilots/types/MessageReply.js +2 -0
  181. package/serialization/resources/copilots/types/NumberFieldSchema.d.ts +15 -0
  182. package/serialization/resources/copilots/types/NumberFieldSchema.js +36 -0
  183. package/serialization/resources/copilots/types/StreamingChunk.d.ts +14 -0
  184. package/serialization/resources/copilots/types/StreamingChunk.js +35 -0
  185. package/serialization/resources/copilots/types/StringFieldSchema.d.ts +15 -0
  186. package/serialization/resources/copilots/types/StringFieldSchema.js +36 -0
  187. package/serialization/resources/copilots/types/WebSearchResult.d.ts +14 -0
  188. package/serialization/resources/copilots/types/WebSearchResult.js +35 -0
  189. package/serialization/resources/copilots/types/index.d.ts +14 -0
  190. package/serialization/resources/copilots/types/index.js +14 -0
  191. package/serialization/resources/search/types/SingleFieldFilter.d.ts +1 -1
  192. package/serialization/resources/search/types/SingleFieldFilter.js +1 -1
  193. package/serialization/resources/search/types/index.d.ts +0 -1
  194. package/serialization/resources/search/types/index.js +0 -1
  195. /package/api/resources/{search → common}/types/Operator.d.ts +0 -0
  196. /package/api/resources/{search → common}/types/Operator.js +0 -0
  197. /package/dist/api/resources/{search → common}/types/Operator.d.ts +0 -0
  198. /package/dist/api/resources/{search → common}/types/Operator.js +0 -0
  199. /package/dist/serialization/resources/{search → common}/types/Operator.d.ts +0 -0
  200. /package/dist/serialization/resources/{search → common}/types/Operator.js +0 -0
  201. /package/serialization/resources/{search → common}/types/Operator.d.ts +0 -0
  202. /package/serialization/resources/{search → common}/types/Operator.js +0 -0
@@ -78,7 +78,7 @@ class DocumentCollections {
78
78
  Authorization: yield this._getAuthorizationHeader(),
79
79
  "X-Fern-Language": "JavaScript",
80
80
  "X-Fern-SDK-Name": "@credal/sdk",
81
- "X-Fern-SDK-Version": "0.0.13",
81
+ "X-Fern-SDK-Version": "0.0.14",
82
82
  "X-Fern-Runtime": core.RUNTIME.type,
83
83
  "X-Fern-Runtime-Version": core.RUNTIME.version,
84
84
  },
@@ -144,7 +144,7 @@ class DocumentCollections {
144
144
  Authorization: yield this._getAuthorizationHeader(),
145
145
  "X-Fern-Language": "JavaScript",
146
146
  "X-Fern-SDK-Name": "@credal/sdk",
147
- "X-Fern-SDK-Version": "0.0.13",
147
+ "X-Fern-SDK-Version": "0.0.14",
148
148
  "X-Fern-Runtime": core.RUNTIME.type,
149
149
  "X-Fern-Runtime-Version": core.RUNTIME.version,
150
150
  },
@@ -206,7 +206,7 @@ class DocumentCollections {
206
206
  Authorization: yield this._getAuthorizationHeader(),
207
207
  "X-Fern-Language": "JavaScript",
208
208
  "X-Fern-SDK-Name": "@credal/sdk",
209
- "X-Fern-SDK-Version": "0.0.13",
209
+ "X-Fern-SDK-Version": "0.0.14",
210
210
  "X-Fern-Runtime": core.RUNTIME.type,
211
211
  "X-Fern-Runtime-Version": core.RUNTIME.version,
212
212
  },
@@ -266,7 +266,7 @@ class DocumentCollections {
266
266
  Authorization: yield this._getAuthorizationHeader(),
267
267
  "X-Fern-Language": "JavaScript",
268
268
  "X-Fern-SDK-Name": "@credal/sdk",
269
- "X-Fern-SDK-Version": "0.0.13",
269
+ "X-Fern-SDK-Version": "0.0.14",
270
270
  "X-Fern-Runtime": core.RUNTIME.type,
271
271
  "X-Fern-Runtime-Version": core.RUNTIME.version,
272
272
  },
@@ -342,7 +342,7 @@ class DocumentCollections {
342
342
  Authorization: yield this._getAuthorizationHeader(),
343
343
  "X-Fern-Language": "JavaScript",
344
344
  "X-Fern-SDK-Name": "@credal/sdk",
345
- "X-Fern-SDK-Version": "0.0.13",
345
+ "X-Fern-SDK-Version": "0.0.14",
346
346
  "X-Fern-Runtime": core.RUNTIME.type,
347
347
  "X-Fern-Runtime-Version": core.RUNTIME.version,
348
348
  },
@@ -420,7 +420,7 @@ class DocumentCollections {
420
420
  Authorization: yield this._getAuthorizationHeader(),
421
421
  "X-Fern-Language": "JavaScript",
422
422
  "X-Fern-SDK-Name": "@credal/sdk",
423
- "X-Fern-SDK-Version": "0.0.13",
423
+ "X-Fern-SDK-Version": "0.0.14",
424
424
  "X-Fern-Runtime": core.RUNTIME.type,
425
425
  "X-Fern-Runtime-Version": core.RUNTIME.version,
426
426
  },
@@ -74,7 +74,7 @@ class PermissionsService {
74
74
  Authorization: yield this._getAuthorizationHeader(),
75
75
  "X-Fern-Language": "JavaScript",
76
76
  "X-Fern-SDK-Name": "@credal/sdk",
77
- "X-Fern-SDK-Version": "0.0.13",
77
+ "X-Fern-SDK-Version": "0.0.14",
78
78
  "X-Fern-Runtime": core.RUNTIME.type,
79
79
  "X-Fern-Runtime-Version": core.RUNTIME.version,
80
80
  },
@@ -144,7 +144,7 @@ class PermissionsService {
144
144
  Authorization: yield this._getAuthorizationHeader(),
145
145
  "X-Fern-Language": "JavaScript",
146
146
  "X-Fern-SDK-Name": "@credal/sdk",
147
- "X-Fern-SDK-Version": "0.0.13",
147
+ "X-Fern-SDK-Version": "0.0.14",
148
148
  "X-Fern-Runtime": core.RUNTIME.type,
149
149
  "X-Fern-Runtime-Version": core.RUNTIME.version,
150
150
  },
@@ -206,7 +206,7 @@ class PermissionsService {
206
206
  Authorization: yield this._getAuthorizationHeader(),
207
207
  "X-Fern-Language": "JavaScript",
208
208
  "X-Fern-SDK-Name": "@credal/sdk",
209
- "X-Fern-SDK-Version": "0.0.13",
209
+ "X-Fern-SDK-Version": "0.0.14",
210
210
  "X-Fern-Runtime": core.RUNTIME.type,
211
211
  "X-Fern-Runtime-Version": core.RUNTIME.version,
212
212
  },
@@ -84,7 +84,7 @@ class Search {
84
84
  Authorization: yield this._getAuthorizationHeader(),
85
85
  "X-Fern-Language": "JavaScript",
86
86
  "X-Fern-SDK-Name": "@credal/sdk",
87
- "X-Fern-SDK-Version": "0.0.13",
87
+ "X-Fern-SDK-Version": "0.0.14",
88
88
  "X-Fern-Runtime": core.RUNTIME.type,
89
89
  "X-Fern-Runtime-Version": core.RUNTIME.version,
90
90
  },
@@ -2,5 +2,4 @@ export * from "./DocumentCollectionSearchOptions";
2
2
  export * from "./SearchDocumentCollectionResponse";
3
3
  export * from "./DocumentCollectionSearchResult";
4
4
  export * from "./SearchResultChunk";
5
- export * from "./Operator";
6
5
  export * from "./SingleFieldFilter";
@@ -18,5 +18,4 @@ __exportStar(require("./DocumentCollectionSearchOptions"), exports);
18
18
  __exportStar(require("./SearchDocumentCollectionResponse"), exports);
19
19
  __exportStar(require("./DocumentCollectionSearchResult"), exports);
20
20
  __exportStar(require("./SearchResultChunk"), exports);
21
- __exportStar(require("./Operator"), exports);
22
21
  __exportStar(require("./SingleFieldFilter"), exports);
@@ -79,7 +79,7 @@ class Users {
79
79
  Authorization: yield this._getAuthorizationHeader(),
80
80
  "X-Fern-Language": "JavaScript",
81
81
  "X-Fern-SDK-Name": "@credal/sdk",
82
- "X-Fern-SDK-Version": "0.0.13",
82
+ "X-Fern-SDK-Version": "0.0.14",
83
83
  "X-Fern-Runtime": core.RUNTIME.type,
84
84
  "X-Fern-Runtime-Version": core.RUNTIME.version,
85
85
  },
package/core/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./fetcher";
2
2
  export * from "./auth";
3
3
  export * from "./runtime";
4
+ export * from "./streaming-fetcher";
4
5
  export * as serialization from "./schemas";
package/core/index.js CHANGED
@@ -30,4 +30,5 @@ exports.serialization = void 0;
30
30
  __exportStar(require("./fetcher"), exports);
31
31
  __exportStar(require("./auth"), exports);
32
32
  __exportStar(require("./runtime"), exports);
33
+ __exportStar(require("./streaming-fetcher"), exports);
33
34
  exports.serialization = __importStar(require("./schemas"));
@@ -0,0 +1,48 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from "stream";
3
+ export declare namespace Stream {
4
+ interface Args {
5
+ /**
6
+ * The HTTP response stream to read from.
7
+ */
8
+ stream: Readable | ReadableStream;
9
+ /**
10
+ * The event shape to use for parsing the stream data.
11
+ */
12
+ eventShape: JsonEvent | SseEvent;
13
+ /**
14
+ * An abort signal to stop the stream.
15
+ */
16
+ signal?: AbortSignal;
17
+ }
18
+ interface JsonEvent {
19
+ type: "json";
20
+ messageTerminator: string;
21
+ }
22
+ interface SseEvent {
23
+ type: "sse";
24
+ streamTerminator?: string;
25
+ }
26
+ }
27
+ export declare class Stream<T> implements AsyncIterable<T> {
28
+ private stream;
29
+ private parse;
30
+ /**
31
+ * The prefix to use for each message. For example,
32
+ * for SSE, the prefix is "data: ".
33
+ */
34
+ private prefix;
35
+ private messageTerminator;
36
+ private streamTerminator;
37
+ private controller;
38
+ constructor({ stream, parse, eventShape, signal }: Stream.Args & {
39
+ parse: (val: unknown) => Promise<T>;
40
+ });
41
+ private iterMessages;
42
+ [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
43
+ private decodeChunk;
44
+ }
45
+ /**
46
+ * Browser polyfill for ReadableStream
47
+ */
48
+ export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
18
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
19
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
20
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
22
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
23
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
24
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
25
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
26
+ function fulfill(value) { resume("next", value); }
27
+ function reject(value) { resume("throw", value); }
28
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.readableStreamAsyncIterable = exports.Stream = void 0;
32
+ const runtime_1 = require("../runtime");
33
+ const DATA_PREFIX = "data:";
34
+ class Stream {
35
+ constructor({ stream, parse, eventShape, signal }) {
36
+ this.controller = new AbortController();
37
+ this.stream = stream;
38
+ this.parse = parse;
39
+ if (eventShape.type === "sse") {
40
+ this.prefix = DATA_PREFIX;
41
+ this.messageTerminator = "\n";
42
+ this.streamTerminator = eventShape.streamTerminator;
43
+ }
44
+ else {
45
+ this.messageTerminator = eventShape.messageTerminator;
46
+ }
47
+ signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", () => this.controller.abort());
48
+ }
49
+ iterMessages() {
50
+ return __asyncGenerator(this, arguments, function* iterMessages_1() {
51
+ var e_1, _a;
52
+ this.controller.signal;
53
+ const stream = readableStreamAsyncIterable(this.stream);
54
+ let buf = "";
55
+ let prefixSeen = false;
56
+ try {
57
+ for (var stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), !stream_1_1.done;) {
58
+ const chunk = stream_1_1.value;
59
+ buf += this.decodeChunk(chunk);
60
+ let terminatorIndex;
61
+ // Parse the chunk into as many messages as possible
62
+ while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) {
63
+ // Extract the line from the buffer
64
+ let line = buf.slice(0, terminatorIndex + 1);
65
+ buf = buf.slice(terminatorIndex + 1);
66
+ // Skip empty lines
67
+ if (line.length === 0) {
68
+ continue;
69
+ }
70
+ // Skip the chunk until the prefix is found
71
+ if (!prefixSeen && this.prefix != null) {
72
+ const prefixIndex = line.indexOf(this.prefix);
73
+ if (prefixIndex === -1) {
74
+ continue;
75
+ }
76
+ prefixSeen = true;
77
+ line = line.slice(prefixIndex + this.prefix.length);
78
+ }
79
+ // If the stream terminator is present, return
80
+ if (this.streamTerminator != null && line.includes(this.streamTerminator)) {
81
+ return yield __await(void 0);
82
+ }
83
+ // Otherwise, yield message from the prefix to the terminator
84
+ const message = yield __await(this.parse(JSON.parse(line)));
85
+ yield yield __await(message);
86
+ prefixSeen = false;
87
+ }
88
+ }
89
+ }
90
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
91
+ finally {
92
+ try {
93
+ if (stream_1_1 && !stream_1_1.done && (_a = stream_1.return)) yield __await(_a.call(stream_1));
94
+ }
95
+ finally { if (e_1) throw e_1.error; }
96
+ }
97
+ });
98
+ }
99
+ [Symbol.asyncIterator]() {
100
+ return __asyncGenerator(this, arguments, function* _a() {
101
+ var e_2, _b;
102
+ try {
103
+ for (var _c = __asyncValues(this.iterMessages()), _d; _d = yield __await(_c.next()), !_d.done;) {
104
+ const message = _d.value;
105
+ yield yield __await(message);
106
+ }
107
+ }
108
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
109
+ finally {
110
+ try {
111
+ if (_d && !_d.done && (_b = _c.return)) yield __await(_b.call(_c));
112
+ }
113
+ finally { if (e_2) throw e_2.error; }
114
+ }
115
+ });
116
+ }
117
+ decodeChunk(chunk) {
118
+ let decoded = "";
119
+ // Buffer is present in Node.js environment
120
+ if (runtime_1.RUNTIME.type === "node" && typeof chunk != "undefined") {
121
+ decoded += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
122
+ }
123
+ // TextDecoder is present in Browser environment
124
+ else if (runtime_1.RUNTIME.type === "browser" && typeof TextDecoder !== "undefined") {
125
+ const decoder = new TextDecoder("utf8");
126
+ decoded += decoder.decode(chunk);
127
+ }
128
+ return decoded;
129
+ }
130
+ }
131
+ exports.Stream = Stream;
132
+ /**
133
+ * Browser polyfill for ReadableStream
134
+ */
135
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
+ function readableStreamAsyncIterable(stream) {
137
+ if (stream[Symbol.asyncIterator]) {
138
+ return stream;
139
+ }
140
+ const reader = stream.getReader();
141
+ return {
142
+ next() {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ try {
145
+ const result = yield reader.read();
146
+ if (result === null || result === void 0 ? void 0 : result.done) {
147
+ reader.releaseLock();
148
+ } // release lock when stream becomes closed
149
+ return result;
150
+ }
151
+ catch (e) {
152
+ reader.releaseLock(); // release lock when stream becomes errored
153
+ throw e;
154
+ }
155
+ });
156
+ },
157
+ return() {
158
+ return __awaiter(this, void 0, void 0, function* () {
159
+ const cancelPromise = reader.cancel();
160
+ reader.releaseLock();
161
+ yield cancelPromise;
162
+ return { done: true, value: undefined };
163
+ });
164
+ },
165
+ [Symbol.asyncIterator]() {
166
+ return this;
167
+ },
168
+ };
169
+ }
170
+ exports.readableStreamAsyncIterable = readableStreamAsyncIterable;
@@ -0,0 +1 @@
1
+ export { Stream } from "./Stream";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stream = void 0;
4
+ var Stream_1 = require("./Stream");
5
+ Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return Stream_1.Stream; } });
@@ -4,3 +4,4 @@ export * from "./Url";
4
4
  export * from "./ResourceType";
5
5
  export * from "./Collaborator";
6
6
  export * from "./Role";
7
+ export * from "./Operator";
@@ -20,3 +20,4 @@ __exportStar(require("./Url"), exports);
20
20
  __exportStar(require("./ResourceType"), exports);
21
21
  __exportStar(require("./Collaborator"), exports);
22
22
  __exportStar(require("./Role"), exports);
23
+ __exportStar(require("./Operator"), exports);
@@ -73,10 +73,21 @@ export declare class Copilots {
73
73
  * await credal.copilots.sendMessage({
74
74
  * agentId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
75
75
  * message: "Is Credal SOC 2 compliant?",
76
- * userEmail: "ravin@credal.ai"
76
+ * userEmail: "ravin@credal.ai",
77
+ * inputVariables: [{
78
+ * name: "input1",
79
+ * urls: ["https://drive.google.com/file/d/123456/view"]
80
+ * }, {
81
+ * name: "input2",
82
+ * urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
83
+ * }]
77
84
  * })
78
85
  */
79
86
  sendMessage(request: Credal.SendMessageRequest, requestOptions?: Copilots.RequestOptions): Promise<Credal.SendAgentMessageResponse>;
87
+ /**
88
+ * This endpoint allows you to send a message to a specific copilot and get the response back as a streamed set of Server-Sent Events.
89
+ */
90
+ streamMessage(request: Credal.StreamMessageRequest, requestOptions?: Copilots.RequestOptions): Promise<core.Stream<Credal.StreamingChunk>>;
80
91
  /**
81
92
  * Link a collection with a copilot. The API Key used must be added to both the collection and the copilot beforehand.
82
93
  *
@@ -74,7 +74,7 @@ class Copilots {
74
74
  Authorization: yield this._getAuthorizationHeader(),
75
75
  "X-Fern-Language": "JavaScript",
76
76
  "X-Fern-SDK-Name": "@credal/sdk",
77
- "X-Fern-SDK-Version": "0.0.13",
77
+ "X-Fern-SDK-Version": "0.0.14",
78
78
  "X-Fern-Runtime": core.RUNTIME.type,
79
79
  "X-Fern-Runtime-Version": core.RUNTIME.version,
80
80
  },
@@ -135,7 +135,7 @@ class Copilots {
135
135
  Authorization: yield this._getAuthorizationHeader(),
136
136
  "X-Fern-Language": "JavaScript",
137
137
  "X-Fern-SDK-Name": "@credal/sdk",
138
- "X-Fern-SDK-Version": "0.0.13",
138
+ "X-Fern-SDK-Version": "0.0.14",
139
139
  "X-Fern-Runtime": core.RUNTIME.type,
140
140
  "X-Fern-Runtime-Version": core.RUNTIME.version,
141
141
  },
@@ -199,7 +199,7 @@ class Copilots {
199
199
  Authorization: yield this._getAuthorizationHeader(),
200
200
  "X-Fern-Language": "JavaScript",
201
201
  "X-Fern-SDK-Name": "@credal/sdk",
202
- "X-Fern-SDK-Version": "0.0.13",
202
+ "X-Fern-SDK-Version": "0.0.14",
203
203
  "X-Fern-Runtime": core.RUNTIME.type,
204
204
  "X-Fern-Runtime-Version": core.RUNTIME.version,
205
205
  },
@@ -243,7 +243,14 @@ class Copilots {
243
243
  * await credal.copilots.sendMessage({
244
244
  * agentId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
245
245
  * message: "Is Credal SOC 2 compliant?",
246
- * userEmail: "ravin@credal.ai"
246
+ * userEmail: "ravin@credal.ai",
247
+ * inputVariables: [{
248
+ * name: "input1",
249
+ * urls: ["https://drive.google.com/file/d/123456/view"]
250
+ * }, {
251
+ * name: "input2",
252
+ * urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
253
+ * }]
247
254
  * })
248
255
  */
249
256
  sendMessage(request, requestOptions) {
@@ -256,7 +263,7 @@ class Copilots {
256
263
  Authorization: yield this._getAuthorizationHeader(),
257
264
  "X-Fern-Language": "JavaScript",
258
265
  "X-Fern-SDK-Name": "@credal/sdk",
259
- "X-Fern-SDK-Version": "0.0.13",
266
+ "X-Fern-SDK-Version": "0.0.14",
260
267
  "X-Fern-Runtime": core.RUNTIME.type,
261
268
  "X-Fern-Runtime-Version": core.RUNTIME.version,
262
269
  },
@@ -295,6 +302,69 @@ class Copilots {
295
302
  }
296
303
  });
297
304
  }
305
+ /**
306
+ * This endpoint allows you to send a message to a specific copilot and get the response back as a streamed set of Server-Sent Events.
307
+ */
308
+ streamMessage(request, requestOptions) {
309
+ var _a, _b;
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
312
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CredalEnvironment.Production, "/v0/copilots/streamMessage"),
313
+ method: "POST",
314
+ headers: {
315
+ Authorization: yield this._getAuthorizationHeader(),
316
+ "X-Fern-Language": "JavaScript",
317
+ "X-Fern-SDK-Name": "@credal/sdk",
318
+ "X-Fern-SDK-Version": "0.0.14",
319
+ "X-Fern-Runtime": core.RUNTIME.type,
320
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
321
+ },
322
+ contentType: "application/json",
323
+ body: yield serializers.StreamMessageRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
324
+ responseType: "streaming",
325
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
326
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
327
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
328
+ });
329
+ if (_response.ok) {
330
+ return new core.Stream({
331
+ stream: _response.body,
332
+ parse: (data) => __awaiter(this, void 0, void 0, function* () {
333
+ return yield serializers.StreamingChunk.parseOrThrow(data, {
334
+ unrecognizedObjectKeys: "passthrough",
335
+ allowUnrecognizedUnionMembers: true,
336
+ allowUnrecognizedEnumValues: true,
337
+ breadcrumbsPrefix: ["response"],
338
+ });
339
+ }),
340
+ signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
341
+ eventShape: {
342
+ type: "sse",
343
+ streamTerminator: "[DONE]",
344
+ },
345
+ });
346
+ }
347
+ if (_response.error.reason === "status-code") {
348
+ throw new errors.CredalError({
349
+ statusCode: _response.error.statusCode,
350
+ body: _response.error.body,
351
+ });
352
+ }
353
+ switch (_response.error.reason) {
354
+ case "non-json":
355
+ throw new errors.CredalError({
356
+ statusCode: _response.error.statusCode,
357
+ body: _response.error.rawBody,
358
+ });
359
+ case "timeout":
360
+ throw new errors.CredalTimeoutError();
361
+ case "unknown":
362
+ throw new errors.CredalError({
363
+ message: _response.error.errorMessage,
364
+ });
365
+ }
366
+ });
367
+ }
298
368
  /**
299
369
  * Link a collection with a copilot. The API Key used must be added to both the collection and the copilot beforehand.
300
370
  *
@@ -317,7 +387,7 @@ class Copilots {
317
387
  Authorization: yield this._getAuthorizationHeader(),
318
388
  "X-Fern-Language": "JavaScript",
319
389
  "X-Fern-SDK-Name": "@credal/sdk",
320
- "X-Fern-SDK-Version": "0.0.13",
390
+ "X-Fern-SDK-Version": "0.0.14",
321
391
  "X-Fern-Runtime": core.RUNTIME.type,
322
392
  "X-Fern-Runtime-Version": core.RUNTIME.version,
323
393
  },
@@ -375,7 +445,7 @@ class Copilots {
375
445
  Authorization: yield this._getAuthorizationHeader(),
376
446
  "X-Fern-Language": "JavaScript",
377
447
  "X-Fern-SDK-Name": "@credal/sdk",
378
- "X-Fern-SDK-Version": "0.0.13",
448
+ "X-Fern-SDK-Version": "0.0.14",
379
449
  "X-Fern-Runtime": core.RUNTIME.type,
380
450
  "X-Fern-Runtime-Version": core.RUNTIME.version,
381
451
  },
@@ -441,7 +511,7 @@ class Copilots {
441
511
  Authorization: yield this._getAuthorizationHeader(),
442
512
  "X-Fern-Language": "JavaScript",
443
513
  "X-Fern-SDK-Name": "@credal/sdk",
444
- "X-Fern-SDK-Version": "0.0.13",
514
+ "X-Fern-SDK-Version": "0.0.14",
445
515
  "X-Fern-Runtime": core.RUNTIME.type,
446
516
  "X-Fern-Runtime-Version": core.RUNTIME.version,
447
517
  },
@@ -496,7 +566,7 @@ class Copilots {
496
566
  Authorization: yield this._getAuthorizationHeader(),
497
567
  "X-Fern-Language": "JavaScript",
498
568
  "X-Fern-SDK-Name": "@credal/sdk",
499
- "X-Fern-SDK-Version": "0.0.13",
569
+ "X-Fern-SDK-Version": "0.0.14",
500
570
  "X-Fern-Runtime": core.RUNTIME.type,
501
571
  "X-Fern-Runtime-Version": core.RUNTIME.version,
502
572
  },
@@ -1,12 +1,20 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
+ import * as Credal from "../../../../index";
4
5
  /**
5
6
  * @example
6
7
  * {
7
8
  * agentId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
8
9
  * message: "Is Credal SOC 2 compliant?",
9
- * userEmail: "ravin@credal.ai"
10
+ * userEmail: "ravin@credal.ai",
11
+ * inputVariables: [{
12
+ * name: "input1",
13
+ * urls: ["https://drive.google.com/file/d/123456/view"]
14
+ * }, {
15
+ * name: "input2",
16
+ * urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
17
+ * }]
10
18
  * }
11
19
  */
12
20
  export interface SendMessageRequest {
@@ -30,4 +38,9 @@ export interface SendMessageRequest {
30
38
  *
31
39
  */
32
40
  conversationId?: string;
41
+ /**
42
+ * Optional input variables to be used in the message. Map the name of the variable to a list of urls.
43
+ *
44
+ */
45
+ inputVariables?: Credal.InputVariable[];
33
46
  }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Credal from "../../../../index";
5
+ /**
6
+ * @example
7
+ * {
8
+ * copilotId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
9
+ * message: "Is Credal SOC 2 compliant?",
10
+ * email: "ravin@credal.ai",
11
+ * inputVariables: [{
12
+ * name: "input1",
13
+ * urls: ["https://drive.google.com/file/d/123456/view"]
14
+ * }, {
15
+ * name: "input2",
16
+ * urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
17
+ * }]
18
+ * }
19
+ *
20
+ * @example
21
+ * {
22
+ * copilotId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
23
+ * message: "Is this user eligible for benefits based on their date of birth?",
24
+ * email: "ravin@credal.ai",
25
+ * inputVariables: [{
26
+ * name: "input1",
27
+ * urls: ["https://drive.google.com/file/d/123456/view"]
28
+ * }, {
29
+ * name: "input2",
30
+ * urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
31
+ * }]
32
+ * }
33
+ */
34
+ export interface StreamMessageRequest {
35
+ /**
36
+ * Credal-generated Copilot ID to specify which agent to route the request to.
37
+ *
38
+ */
39
+ copilotId: string;
40
+ /**
41
+ * The message you want to send to your copilot.
42
+ *
43
+ */
44
+ message: string;
45
+ /**
46
+ * The user profile you want to use when sending the message.
47
+ *
48
+ */
49
+ email: string;
50
+ /**
51
+ * Credal-generated conversation ID for sending follow up messages. Conversation ID is returned after initial message. Optional, to be left off for first messages on new conversations.
52
+ *
53
+ */
54
+ conversationId?: string;
55
+ /**
56
+ * Optional input variables to be used in the message. Map the name of the variable to a list of urls.
57
+ *
58
+ */
59
+ inputVariables?: Credal.InputVariable[];
60
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });