vellum-ai 0.3.5 → 0.3.6

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 (39) hide show
  1. package/Client.js +27 -9
  2. package/api/resources/deployments/client/Client.js +9 -3
  3. package/api/resources/documentIndexes/client/Client.js +6 -2
  4. package/api/resources/documents/client/Client.js +12 -4
  5. package/api/resources/modelVersions/client/Client.js +3 -1
  6. package/api/resources/registeredPrompts/client/Client.js +3 -1
  7. package/api/resources/sandboxes/client/Client.js +6 -2
  8. package/api/resources/testSuites/client/Client.js +6 -2
  9. package/api/resources/workflowDeployments/client/Client.js +3 -1
  10. package/core/fetcher/Fetcher.js +8 -1
  11. package/core/index.d.ts +1 -0
  12. package/core/index.js +1 -0
  13. package/core/runtime/index.d.ts +1 -0
  14. package/core/runtime/index.js +5 -0
  15. package/core/runtime/runtime.d.ts +8 -0
  16. package/core/runtime/runtime.js +82 -0
  17. package/core/streaming-fetcher/Stream.d.ts +4 -0
  18. package/core/streaming-fetcher/Stream.js +63 -5
  19. package/dist/Client.js +27 -9
  20. package/dist/api/resources/deployments/client/Client.js +9 -3
  21. package/dist/api/resources/documentIndexes/client/Client.js +6 -2
  22. package/dist/api/resources/documents/client/Client.js +12 -4
  23. package/dist/api/resources/modelVersions/client/Client.js +3 -1
  24. package/dist/api/resources/registeredPrompts/client/Client.js +3 -1
  25. package/dist/api/resources/sandboxes/client/Client.js +6 -2
  26. package/dist/api/resources/testSuites/client/Client.js +6 -2
  27. package/dist/api/resources/workflowDeployments/client/Client.js +3 -1
  28. package/dist/core/fetcher/Fetcher.js +8 -1
  29. package/dist/core/index.d.ts +1 -0
  30. package/dist/core/index.js +1 -0
  31. package/dist/core/runtime/index.d.ts +1 -0
  32. package/dist/core/runtime/index.js +5 -0
  33. package/dist/core/runtime/runtime.d.ts +8 -0
  34. package/dist/core/runtime/runtime.js +82 -0
  35. package/dist/core/streaming-fetcher/Stream.d.ts +4 -0
  36. package/dist/core/streaming-fetcher/Stream.js +63 -5
  37. package/jest.config.js +5 -0
  38. package/package.json +6 -2
  39. package/tests/client.test.ts +11 -0
package/Client.js CHANGED
@@ -75,7 +75,9 @@ class VellumClient {
75
75
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
76
76
  "X-Fern-Language": "JavaScript",
77
77
  "X-Fern-SDK-Name": "vellum-ai",
78
- "X-Fern-SDK-Version": "0.3.5",
78
+ "X-Fern-SDK-Version": "0.3.6",
79
+ "X-Fern-Runtime": core.RUNTIME.type,
80
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
79
81
  },
80
82
  contentType: "application/json",
81
83
  body: yield serializers.ExecutePromptRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -136,7 +138,9 @@ class VellumClient {
136
138
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
137
139
  "X-Fern-Language": "JavaScript",
138
140
  "X-Fern-SDK-Name": "vellum-ai",
139
- "X-Fern-SDK-Version": "0.3.5",
141
+ "X-Fern-SDK-Version": "0.3.6",
142
+ "X-Fern-Runtime": core.RUNTIME.type,
143
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
140
144
  },
141
145
  contentType: "application/json",
142
146
  body: yield serializers.ExecutePromptStreamRequest.jsonOrThrow(request, {
@@ -209,7 +213,9 @@ class VellumClient {
209
213
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
210
214
  "X-Fern-Language": "JavaScript",
211
215
  "X-Fern-SDK-Name": "vellum-ai",
212
- "X-Fern-SDK-Version": "0.3.5",
216
+ "X-Fern-SDK-Version": "0.3.6",
217
+ "X-Fern-Runtime": core.RUNTIME.type,
218
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
213
219
  },
214
220
  contentType: "application/json",
215
221
  body: yield serializers.ExecuteWorkflowRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -268,7 +274,9 @@ class VellumClient {
268
274
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
269
275
  "X-Fern-Language": "JavaScript",
270
276
  "X-Fern-SDK-Name": "vellum-ai",
271
- "X-Fern-SDK-Version": "0.3.5",
277
+ "X-Fern-SDK-Version": "0.3.6",
278
+ "X-Fern-Runtime": core.RUNTIME.type,
279
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
272
280
  },
273
281
  contentType: "application/json",
274
282
  body: yield serializers.ExecuteWorkflowStreamRequest.jsonOrThrow(request, {
@@ -349,7 +357,9 @@ class VellumClient {
349
357
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
350
358
  "X-Fern-Language": "JavaScript",
351
359
  "X-Fern-SDK-Name": "vellum-ai",
352
- "X-Fern-SDK-Version": "0.3.5",
360
+ "X-Fern-SDK-Version": "0.3.6",
361
+ "X-Fern-Runtime": core.RUNTIME.type,
362
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
353
363
  },
354
364
  contentType: "application/json",
355
365
  body: yield serializers.GenerateBodyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -412,7 +422,9 @@ class VellumClient {
412
422
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
413
423
  "X-Fern-Language": "JavaScript",
414
424
  "X-Fern-SDK-Name": "vellum-ai",
415
- "X-Fern-SDK-Version": "0.3.5",
425
+ "X-Fern-SDK-Version": "0.3.6",
426
+ "X-Fern-Runtime": core.RUNTIME.type,
427
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
416
428
  },
417
429
  contentType: "application/json",
418
430
  body: yield serializers.GenerateStreamBodyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -490,7 +502,9 @@ class VellumClient {
490
502
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
491
503
  "X-Fern-Language": "JavaScript",
492
504
  "X-Fern-SDK-Name": "vellum-ai",
493
- "X-Fern-SDK-Version": "0.3.5",
505
+ "X-Fern-SDK-Version": "0.3.6",
506
+ "X-Fern-Runtime": core.RUNTIME.type,
507
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
494
508
  },
495
509
  contentType: "application/json",
496
510
  body: yield serializers.SearchRequestBodyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -559,7 +573,9 @@ class VellumClient {
559
573
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
560
574
  "X-Fern-Language": "JavaScript",
561
575
  "X-Fern-SDK-Name": "vellum-ai",
562
- "X-Fern-SDK-Version": "0.3.5",
576
+ "X-Fern-SDK-Version": "0.3.6",
577
+ "X-Fern-Runtime": core.RUNTIME.type,
578
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
563
579
  },
564
580
  contentType: "application/json",
565
581
  body: yield serializers.SubmitCompletionActualsRequest.jsonOrThrow(request, {
@@ -622,7 +638,9 @@ class VellumClient {
622
638
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
623
639
  "X-Fern-Language": "JavaScript",
624
640
  "X-Fern-SDK-Name": "vellum-ai",
625
- "X-Fern-SDK-Version": "0.3.5",
641
+ "X-Fern-SDK-Version": "0.3.6",
642
+ "X-Fern-Runtime": core.RUNTIME.type,
643
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
626
644
  },
627
645
  contentType: "application/json",
628
646
  body: yield serializers.SubmitWorkflowExecutionActualsRequest.jsonOrThrow(request, {
@@ -73,7 +73,9 @@ class Deployments {
73
73
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
74
74
  "X-Fern-Language": "JavaScript",
75
75
  "X-Fern-SDK-Name": "vellum-ai",
76
- "X-Fern-SDK-Version": "0.3.5",
76
+ "X-Fern-SDK-Version": "0.3.6",
77
+ "X-Fern-Runtime": core.RUNTIME.type,
78
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
77
79
  },
78
80
  contentType: "application/json",
79
81
  queryParameters: _queryParams,
@@ -126,7 +128,9 @@ class Deployments {
126
128
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
127
129
  "X-Fern-Language": "JavaScript",
128
130
  "X-Fern-SDK-Name": "vellum-ai",
129
- "X-Fern-SDK-Version": "0.3.5",
131
+ "X-Fern-SDK-Version": "0.3.6",
132
+ "X-Fern-Runtime": core.RUNTIME.type,
133
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
130
134
  },
131
135
  contentType: "application/json",
132
136
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -172,7 +176,9 @@ class Deployments {
172
176
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
173
177
  "X-Fern-Language": "JavaScript",
174
178
  "X-Fern-SDK-Name": "vellum-ai",
175
- "X-Fern-SDK-Version": "0.3.5",
179
+ "X-Fern-SDK-Version": "0.3.6",
180
+ "X-Fern-Runtime": core.RUNTIME.type,
181
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
176
182
  },
177
183
  contentType: "application/json",
178
184
  body: yield serializers.DeploymentProviderPayloadRequest.jsonOrThrow(request, {
@@ -85,7 +85,9 @@ class DocumentIndexes {
85
85
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
86
86
  "X-Fern-Language": "JavaScript",
87
87
  "X-Fern-SDK-Name": "vellum-ai",
88
- "X-Fern-SDK-Version": "0.3.5",
88
+ "X-Fern-SDK-Version": "0.3.6",
89
+ "X-Fern-Runtime": core.RUNTIME.type,
90
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
89
91
  },
90
92
  contentType: "application/json",
91
93
  body: yield serializers.DocumentIndexCreateRequest.jsonOrThrow(request, {
@@ -140,7 +142,9 @@ class DocumentIndexes {
140
142
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
141
143
  "X-Fern-Language": "JavaScript",
142
144
  "X-Fern-SDK-Name": "vellum-ai",
143
- "X-Fern-SDK-Version": "0.3.5",
145
+ "X-Fern-SDK-Version": "0.3.6",
146
+ "X-Fern-Runtime": core.RUNTIME.type,
147
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
144
148
  },
145
149
  contentType: "application/json",
146
150
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -81,7 +81,9 @@ class Documents {
81
81
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
82
82
  "X-Fern-Language": "JavaScript",
83
83
  "X-Fern-SDK-Name": "vellum-ai",
84
- "X-Fern-SDK-Version": "0.3.5",
84
+ "X-Fern-SDK-Version": "0.3.6",
85
+ "X-Fern-Runtime": core.RUNTIME.type,
86
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
85
87
  },
86
88
  contentType: "application/json",
87
89
  queryParameters: _queryParams,
@@ -128,7 +130,9 @@ class Documents {
128
130
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
129
131
  "X-Fern-Language": "JavaScript",
130
132
  "X-Fern-SDK-Name": "vellum-ai",
131
- "X-Fern-SDK-Version": "0.3.5",
133
+ "X-Fern-SDK-Version": "0.3.6",
134
+ "X-Fern-Runtime": core.RUNTIME.type,
135
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
132
136
  },
133
137
  contentType: "application/json",
134
138
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -175,7 +179,9 @@ class Documents {
175
179
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
176
180
  "X-Fern-Language": "JavaScript",
177
181
  "X-Fern-SDK-Name": "vellum-ai",
178
- "X-Fern-SDK-Version": "0.3.5",
182
+ "X-Fern-SDK-Version": "0.3.6",
183
+ "X-Fern-Runtime": core.RUNTIME.type,
184
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
179
185
  },
180
186
  contentType: "application/json",
181
187
  body: yield serializers.PatchedDocumentUpdateRequest.jsonOrThrow(request, {
@@ -259,7 +265,9 @@ class Documents {
259
265
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
260
266
  "X-Fern-Language": "JavaScript",
261
267
  "X-Fern-SDK-Name": "vellum-ai",
262
- "X-Fern-SDK-Version": "0.3.5",
268
+ "X-Fern-SDK-Version": "0.3.6",
269
+ "X-Fern-Runtime": core.RUNTIME.type,
270
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
263
271
  },
264
272
  contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
265
273
  body: _request,
@@ -65,7 +65,9 @@ class ModelVersions {
65
65
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
66
66
  "X-Fern-Language": "JavaScript",
67
67
  "X-Fern-SDK-Name": "vellum-ai",
68
- "X-Fern-SDK-Version": "0.3.5",
68
+ "X-Fern-SDK-Version": "0.3.6",
69
+ "X-Fern-Runtime": core.RUNTIME.type,
70
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
69
71
  },
70
72
  contentType: "application/json",
71
73
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -96,7 +96,9 @@ class RegisteredPrompts {
96
96
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
97
97
  "X-Fern-Language": "JavaScript",
98
98
  "X-Fern-SDK-Name": "vellum-ai",
99
- "X-Fern-SDK-Version": "0.3.5",
99
+ "X-Fern-SDK-Version": "0.3.6",
100
+ "X-Fern-Runtime": core.RUNTIME.type,
101
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
100
102
  },
101
103
  contentType: "application/json",
102
104
  body: yield serializers.RegisterPromptRequestRequest.jsonOrThrow(request, {
@@ -84,7 +84,9 @@ class Sandboxes {
84
84
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
85
85
  "X-Fern-Language": "JavaScript",
86
86
  "X-Fern-SDK-Name": "vellum-ai",
87
- "X-Fern-SDK-Version": "0.3.5",
87
+ "X-Fern-SDK-Version": "0.3.6",
88
+ "X-Fern-Runtime": core.RUNTIME.type,
89
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
88
90
  },
89
91
  contentType: "application/json",
90
92
  body: yield serializers.UpsertSandboxScenarioRequestRequest.jsonOrThrow(request, {
@@ -139,7 +141,9 @@ class Sandboxes {
139
141
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
140
142
  "X-Fern-Language": "JavaScript",
141
143
  "X-Fern-SDK-Name": "vellum-ai",
142
- "X-Fern-SDK-Version": "0.3.5",
144
+ "X-Fern-SDK-Version": "0.3.6",
145
+ "X-Fern-Runtime": core.RUNTIME.type,
146
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
143
147
  },
144
148
  contentType: "application/json",
145
149
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -74,7 +74,9 @@ class TestSuites {
74
74
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
75
75
  "X-Fern-Language": "JavaScript",
76
76
  "X-Fern-SDK-Name": "vellum-ai",
77
- "X-Fern-SDK-Version": "0.3.5",
77
+ "X-Fern-SDK-Version": "0.3.6",
78
+ "X-Fern-Runtime": core.RUNTIME.type,
79
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
78
80
  },
79
81
  contentType: "application/json",
80
82
  body: yield serializers.UpsertTestSuiteTestCaseRequest.jsonOrThrow(request, {
@@ -129,7 +131,9 @@ class TestSuites {
129
131
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
130
132
  "X-Fern-Language": "JavaScript",
131
133
  "X-Fern-SDK-Name": "vellum-ai",
132
- "X-Fern-SDK-Version": "0.3.5",
134
+ "X-Fern-SDK-Version": "0.3.6",
135
+ "X-Fern-Runtime": core.RUNTIME.type,
136
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
133
137
  },
134
138
  contentType: "application/json",
135
139
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -73,7 +73,9 @@ class WorkflowDeployments {
73
73
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
74
74
  "X-Fern-Language": "JavaScript",
75
75
  "X-Fern-SDK-Name": "vellum-ai",
76
- "X-Fern-SDK-Version": "0.3.5",
76
+ "X-Fern-SDK-Version": "0.3.6",
77
+ "X-Fern-Runtime": core.RUNTIME.type,
78
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
77
79
  },
78
80
  contentType: "application/json",
79
81
  queryParameters: _queryParams,
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.fetcher = void 0;
16
16
  const form_data_1 = __importDefault(require("form-data"));
17
17
  const qs_1 = __importDefault(require("qs"));
18
+ const runtime_1 = require("../runtime");
18
19
  const INITIAL_RETRY_DELAY = 1;
19
20
  const MAX_RETRY_DELAY = 60;
20
21
  const DEFAULT_MAX_RETRIES = 2;
@@ -40,10 +41,16 @@ function fetcherImpl(args) {
40
41
  // @ts-expect-error
41
42
  body = args.body;
42
43
  }
44
+ else if (args.body instanceof Uint8Array) {
45
+ body = args.body;
46
+ }
43
47
  else {
44
48
  body = JSON.stringify(args.body);
45
49
  }
46
- const fetchFn = typeof fetch == "function" ? fetch : require("node-fetch");
50
+ // In Node.js environments, the SDK always uses`node-fetch`.
51
+ // If not in Node.js the SDK uses global fetch if available,
52
+ // and falls back to node-fetch.
53
+ const fetchFn = runtime_1.RUNTIME.type === "node" ? require("node-fetch") : typeof fetch == "function" ? fetch : require("node-fetch");
47
54
  const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
48
55
  const controller = new AbortController();
49
56
  let abortId = undefined;
package/core/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./fetcher";
2
+ export * from "./runtime";
2
3
  export * from "./streaming-fetcher";
3
4
  export * as serialization from "./schemas";
package/core/index.js CHANGED
@@ -28,5 +28,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.serialization = void 0;
30
30
  __exportStar(require("./fetcher"), exports);
31
+ __exportStar(require("./runtime"), exports);
31
32
  __exportStar(require("./streaming-fetcher"), exports);
32
33
  exports.serialization = __importStar(require("./schemas"));
@@ -0,0 +1 @@
1
+ export { RUNTIME } from "./runtime";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RUNTIME = void 0;
4
+ var runtime_1 = require("./runtime");
5
+ Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return runtime_1.RUNTIME; } });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A constant that indicates which environment and version the SDK is running in.
3
+ */
4
+ export declare const RUNTIME: Runtime;
5
+ export interface Runtime {
6
+ type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown";
7
+ version?: string;
8
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RUNTIME = void 0;
5
+ /**
6
+ * A constant that indicates whether the environment the code is running is a Web Browser.
7
+ */
8
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
9
+ /**
10
+ * A constant that indicates whether the environment the code is running is a Web Worker.
11
+ */
12
+ const isWebWorker = typeof self === "object" &&
13
+ // @ts-ignore
14
+ typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
15
+ (((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
16
+ ((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
17
+ ((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
18
+ /**
19
+ * A constant that indicates whether the environment the code is running is Deno.
20
+ */
21
+ const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
22
+ /**
23
+ * A constant that indicates whether the environment the code is running is Bun.sh.
24
+ */
25
+ const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
26
+ /**
27
+ * A constant that indicates whether the environment the code is running is Node.JS.
28
+ */
29
+ const isNode = typeof process !== "undefined" &&
30
+ Boolean(process.version) &&
31
+ Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) &&
32
+ // Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
33
+ !isDeno &&
34
+ !isBun;
35
+ /**
36
+ * A constant that indicates whether the environment the code is running is in React-Native.
37
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
38
+ */
39
+ const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
40
+ /**
41
+ * A constant that indicates which environment and version the SDK is running in.
42
+ */
43
+ exports.RUNTIME = evaluateRuntime();
44
+ function evaluateRuntime() {
45
+ if (isBrowser) {
46
+ return {
47
+ type: "browser",
48
+ version: window.navigator.userAgent,
49
+ };
50
+ }
51
+ if (isWebWorker) {
52
+ return {
53
+ type: "web-worker",
54
+ };
55
+ }
56
+ if (isDeno) {
57
+ return {
58
+ type: "deno",
59
+ version: Deno.version.deno,
60
+ };
61
+ }
62
+ if (isBun) {
63
+ return {
64
+ type: "bun",
65
+ version: Bun.version,
66
+ };
67
+ }
68
+ if (isNode) {
69
+ return {
70
+ type: "node",
71
+ version: process.versions.node,
72
+ };
73
+ }
74
+ if (isReactNative) {
75
+ return {
76
+ type: "react-native",
77
+ };
78
+ }
79
+ return {
80
+ type: "unknown",
81
+ };
82
+ }
@@ -13,3 +13,7 @@ export declare class Stream<T> implements AsyncIterable<T> {
13
13
  private iterMessages;
14
14
  [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
15
15
  }
16
+ /**
17
+ * Browser polyfill for ReadableStream
18
+ */
19
+ export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
@@ -1,4 +1,13 @@
1
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
+ };
2
11
  var __asyncValues = (this && this.__asyncValues) || function (o) {
3
12
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
4
13
  var m = o[Symbol.asyncIterator], i;
@@ -19,7 +28,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
19
28
  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
20
29
  };
21
30
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.Stream = void 0;
31
+ exports.readableStreamAsyncIterable = exports.Stream = void 0;
23
32
  class Stream {
24
33
  constructor({ stream, parse, terminator, }) {
25
34
  this.stream = stream;
@@ -29,11 +38,21 @@ class Stream {
29
38
  iterMessages() {
30
39
  return __asyncGenerator(this, arguments, function* iterMessages_1() {
31
40
  var e_1, _a;
41
+ const decoder = new TextDecoder("utf8");
42
+ const stream = readableStreamAsyncIterable(this.stream);
32
43
  let previous = "";
33
44
  try {
34
- for (var _b = __asyncValues(this.stream), _c; _c = yield __await(_b.next()), !_c.done;) {
35
- const chunk = _c.value;
36
- const bufferChunk = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
45
+ for (var stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), !stream_1_1.done;) {
46
+ const chunk = stream_1_1.value;
47
+ let bufferChunk = "";
48
+ // Buffer is present in Node.js environment
49
+ if (typeof Buffer !== "undefined") {
50
+ bufferChunk += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
51
+ }
52
+ // TextDecoder is present in Browser environment
53
+ else if (typeof TextDecoder !== "undefined") {
54
+ bufferChunk += decoder.decode(chunk);
55
+ }
37
56
  previous += bufferChunk;
38
57
  let terminatorIndex;
39
58
  while ((terminatorIndex = previous.indexOf(this.terminator)) >= 0) {
@@ -47,7 +66,7 @@ class Stream {
47
66
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
48
67
  finally {
49
68
  try {
50
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
69
+ if (stream_1_1 && !stream_1_1.done && (_a = stream_1.return)) yield __await(_a.call(stream_1));
51
70
  }
52
71
  finally { if (e_1) throw e_1.error; }
53
72
  }
@@ -73,3 +92,42 @@ class Stream {
73
92
  }
74
93
  }
75
94
  exports.Stream = Stream;
95
+ /**
96
+ * Browser polyfill for ReadableStream
97
+ */
98
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
+ function readableStreamAsyncIterable(stream) {
100
+ if (stream[Symbol.asyncIterator]) {
101
+ return stream;
102
+ }
103
+ const reader = stream.getReader();
104
+ return {
105
+ next() {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ try {
108
+ const result = yield reader.read();
109
+ if (result === null || result === void 0 ? void 0 : result.done) {
110
+ reader.releaseLock();
111
+ } // release lock when stream becomes closed
112
+ return result;
113
+ }
114
+ catch (e) {
115
+ reader.releaseLock(); // release lock when stream becomes errored
116
+ throw e;
117
+ }
118
+ });
119
+ },
120
+ return() {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const cancelPromise = reader.cancel();
123
+ reader.releaseLock();
124
+ yield cancelPromise;
125
+ return { done: true, value: undefined };
126
+ });
127
+ },
128
+ [Symbol.asyncIterator]() {
129
+ return this;
130
+ },
131
+ };
132
+ }
133
+ exports.readableStreamAsyncIterable = readableStreamAsyncIterable;
package/dist/Client.js CHANGED
@@ -75,7 +75,9 @@ class VellumClient {
75
75
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
76
76
  "X-Fern-Language": "JavaScript",
77
77
  "X-Fern-SDK-Name": "vellum-ai",
78
- "X-Fern-SDK-Version": "0.3.5",
78
+ "X-Fern-SDK-Version": "0.3.6",
79
+ "X-Fern-Runtime": core.RUNTIME.type,
80
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
79
81
  },
80
82
  contentType: "application/json",
81
83
  body: yield serializers.ExecutePromptRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -136,7 +138,9 @@ class VellumClient {
136
138
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
137
139
  "X-Fern-Language": "JavaScript",
138
140
  "X-Fern-SDK-Name": "vellum-ai",
139
- "X-Fern-SDK-Version": "0.3.5",
141
+ "X-Fern-SDK-Version": "0.3.6",
142
+ "X-Fern-Runtime": core.RUNTIME.type,
143
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
140
144
  },
141
145
  contentType: "application/json",
142
146
  body: yield serializers.ExecutePromptStreamRequest.jsonOrThrow(request, {
@@ -209,7 +213,9 @@ class VellumClient {
209
213
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
210
214
  "X-Fern-Language": "JavaScript",
211
215
  "X-Fern-SDK-Name": "vellum-ai",
212
- "X-Fern-SDK-Version": "0.3.5",
216
+ "X-Fern-SDK-Version": "0.3.6",
217
+ "X-Fern-Runtime": core.RUNTIME.type,
218
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
213
219
  },
214
220
  contentType: "application/json",
215
221
  body: yield serializers.ExecuteWorkflowRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -268,7 +274,9 @@ class VellumClient {
268
274
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
269
275
  "X-Fern-Language": "JavaScript",
270
276
  "X-Fern-SDK-Name": "vellum-ai",
271
- "X-Fern-SDK-Version": "0.3.5",
277
+ "X-Fern-SDK-Version": "0.3.6",
278
+ "X-Fern-Runtime": core.RUNTIME.type,
279
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
272
280
  },
273
281
  contentType: "application/json",
274
282
  body: yield serializers.ExecuteWorkflowStreamRequest.jsonOrThrow(request, {
@@ -349,7 +357,9 @@ class VellumClient {
349
357
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
350
358
  "X-Fern-Language": "JavaScript",
351
359
  "X-Fern-SDK-Name": "vellum-ai",
352
- "X-Fern-SDK-Version": "0.3.5",
360
+ "X-Fern-SDK-Version": "0.3.6",
361
+ "X-Fern-Runtime": core.RUNTIME.type,
362
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
353
363
  },
354
364
  contentType: "application/json",
355
365
  body: yield serializers.GenerateBodyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -412,7 +422,9 @@ class VellumClient {
412
422
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
413
423
  "X-Fern-Language": "JavaScript",
414
424
  "X-Fern-SDK-Name": "vellum-ai",
415
- "X-Fern-SDK-Version": "0.3.5",
425
+ "X-Fern-SDK-Version": "0.3.6",
426
+ "X-Fern-Runtime": core.RUNTIME.type,
427
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
416
428
  },
417
429
  contentType: "application/json",
418
430
  body: yield serializers.GenerateStreamBodyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -490,7 +502,9 @@ class VellumClient {
490
502
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
491
503
  "X-Fern-Language": "JavaScript",
492
504
  "X-Fern-SDK-Name": "vellum-ai",
493
- "X-Fern-SDK-Version": "0.3.5",
505
+ "X-Fern-SDK-Version": "0.3.6",
506
+ "X-Fern-Runtime": core.RUNTIME.type,
507
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
494
508
  },
495
509
  contentType: "application/json",
496
510
  body: yield serializers.SearchRequestBodyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -559,7 +573,9 @@ class VellumClient {
559
573
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
560
574
  "X-Fern-Language": "JavaScript",
561
575
  "X-Fern-SDK-Name": "vellum-ai",
562
- "X-Fern-SDK-Version": "0.3.5",
576
+ "X-Fern-SDK-Version": "0.3.6",
577
+ "X-Fern-Runtime": core.RUNTIME.type,
578
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
563
579
  },
564
580
  contentType: "application/json",
565
581
  body: yield serializers.SubmitCompletionActualsRequest.jsonOrThrow(request, {
@@ -622,7 +638,9 @@ class VellumClient {
622
638
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
623
639
  "X-Fern-Language": "JavaScript",
624
640
  "X-Fern-SDK-Name": "vellum-ai",
625
- "X-Fern-SDK-Version": "0.3.5",
641
+ "X-Fern-SDK-Version": "0.3.6",
642
+ "X-Fern-Runtime": core.RUNTIME.type,
643
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
626
644
  },
627
645
  contentType: "application/json",
628
646
  body: yield serializers.SubmitWorkflowExecutionActualsRequest.jsonOrThrow(request, {
@@ -73,7 +73,9 @@ class Deployments {
73
73
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
74
74
  "X-Fern-Language": "JavaScript",
75
75
  "X-Fern-SDK-Name": "vellum-ai",
76
- "X-Fern-SDK-Version": "0.3.5",
76
+ "X-Fern-SDK-Version": "0.3.6",
77
+ "X-Fern-Runtime": core.RUNTIME.type,
78
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
77
79
  },
78
80
  contentType: "application/json",
79
81
  queryParameters: _queryParams,
@@ -126,7 +128,9 @@ class Deployments {
126
128
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
127
129
  "X-Fern-Language": "JavaScript",
128
130
  "X-Fern-SDK-Name": "vellum-ai",
129
- "X-Fern-SDK-Version": "0.3.5",
131
+ "X-Fern-SDK-Version": "0.3.6",
132
+ "X-Fern-Runtime": core.RUNTIME.type,
133
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
130
134
  },
131
135
  contentType: "application/json",
132
136
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -172,7 +176,9 @@ class Deployments {
172
176
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
173
177
  "X-Fern-Language": "JavaScript",
174
178
  "X-Fern-SDK-Name": "vellum-ai",
175
- "X-Fern-SDK-Version": "0.3.5",
179
+ "X-Fern-SDK-Version": "0.3.6",
180
+ "X-Fern-Runtime": core.RUNTIME.type,
181
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
176
182
  },
177
183
  contentType: "application/json",
178
184
  body: yield serializers.DeploymentProviderPayloadRequest.jsonOrThrow(request, {
@@ -85,7 +85,9 @@ class DocumentIndexes {
85
85
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
86
86
  "X-Fern-Language": "JavaScript",
87
87
  "X-Fern-SDK-Name": "vellum-ai",
88
- "X-Fern-SDK-Version": "0.3.5",
88
+ "X-Fern-SDK-Version": "0.3.6",
89
+ "X-Fern-Runtime": core.RUNTIME.type,
90
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
89
91
  },
90
92
  contentType: "application/json",
91
93
  body: yield serializers.DocumentIndexCreateRequest.jsonOrThrow(request, {
@@ -140,7 +142,9 @@ class DocumentIndexes {
140
142
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
141
143
  "X-Fern-Language": "JavaScript",
142
144
  "X-Fern-SDK-Name": "vellum-ai",
143
- "X-Fern-SDK-Version": "0.3.5",
145
+ "X-Fern-SDK-Version": "0.3.6",
146
+ "X-Fern-Runtime": core.RUNTIME.type,
147
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
144
148
  },
145
149
  contentType: "application/json",
146
150
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -81,7 +81,9 @@ class Documents {
81
81
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
82
82
  "X-Fern-Language": "JavaScript",
83
83
  "X-Fern-SDK-Name": "vellum-ai",
84
- "X-Fern-SDK-Version": "0.3.5",
84
+ "X-Fern-SDK-Version": "0.3.6",
85
+ "X-Fern-Runtime": core.RUNTIME.type,
86
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
85
87
  },
86
88
  contentType: "application/json",
87
89
  queryParameters: _queryParams,
@@ -128,7 +130,9 @@ class Documents {
128
130
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
129
131
  "X-Fern-Language": "JavaScript",
130
132
  "X-Fern-SDK-Name": "vellum-ai",
131
- "X-Fern-SDK-Version": "0.3.5",
133
+ "X-Fern-SDK-Version": "0.3.6",
134
+ "X-Fern-Runtime": core.RUNTIME.type,
135
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
132
136
  },
133
137
  contentType: "application/json",
134
138
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -175,7 +179,9 @@ class Documents {
175
179
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
176
180
  "X-Fern-Language": "JavaScript",
177
181
  "X-Fern-SDK-Name": "vellum-ai",
178
- "X-Fern-SDK-Version": "0.3.5",
182
+ "X-Fern-SDK-Version": "0.3.6",
183
+ "X-Fern-Runtime": core.RUNTIME.type,
184
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
179
185
  },
180
186
  contentType: "application/json",
181
187
  body: yield serializers.PatchedDocumentUpdateRequest.jsonOrThrow(request, {
@@ -259,7 +265,9 @@ class Documents {
259
265
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
260
266
  "X-Fern-Language": "JavaScript",
261
267
  "X-Fern-SDK-Name": "vellum-ai",
262
- "X-Fern-SDK-Version": "0.3.5",
268
+ "X-Fern-SDK-Version": "0.3.6",
269
+ "X-Fern-Runtime": core.RUNTIME.type,
270
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
263
271
  },
264
272
  contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
265
273
  body: _request,
@@ -65,7 +65,9 @@ class ModelVersions {
65
65
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
66
66
  "X-Fern-Language": "JavaScript",
67
67
  "X-Fern-SDK-Name": "vellum-ai",
68
- "X-Fern-SDK-Version": "0.3.5",
68
+ "X-Fern-SDK-Version": "0.3.6",
69
+ "X-Fern-Runtime": core.RUNTIME.type,
70
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
69
71
  },
70
72
  contentType: "application/json",
71
73
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -96,7 +96,9 @@ class RegisteredPrompts {
96
96
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
97
97
  "X-Fern-Language": "JavaScript",
98
98
  "X-Fern-SDK-Name": "vellum-ai",
99
- "X-Fern-SDK-Version": "0.3.5",
99
+ "X-Fern-SDK-Version": "0.3.6",
100
+ "X-Fern-Runtime": core.RUNTIME.type,
101
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
100
102
  },
101
103
  contentType: "application/json",
102
104
  body: yield serializers.RegisterPromptRequestRequest.jsonOrThrow(request, {
@@ -84,7 +84,9 @@ class Sandboxes {
84
84
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
85
85
  "X-Fern-Language": "JavaScript",
86
86
  "X-Fern-SDK-Name": "vellum-ai",
87
- "X-Fern-SDK-Version": "0.3.5",
87
+ "X-Fern-SDK-Version": "0.3.6",
88
+ "X-Fern-Runtime": core.RUNTIME.type,
89
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
88
90
  },
89
91
  contentType: "application/json",
90
92
  body: yield serializers.UpsertSandboxScenarioRequestRequest.jsonOrThrow(request, {
@@ -139,7 +141,9 @@ class Sandboxes {
139
141
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
140
142
  "X-Fern-Language": "JavaScript",
141
143
  "X-Fern-SDK-Name": "vellum-ai",
142
- "X-Fern-SDK-Version": "0.3.5",
144
+ "X-Fern-SDK-Version": "0.3.6",
145
+ "X-Fern-Runtime": core.RUNTIME.type,
146
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
143
147
  },
144
148
  contentType: "application/json",
145
149
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -74,7 +74,9 @@ class TestSuites {
74
74
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
75
75
  "X-Fern-Language": "JavaScript",
76
76
  "X-Fern-SDK-Name": "vellum-ai",
77
- "X-Fern-SDK-Version": "0.3.5",
77
+ "X-Fern-SDK-Version": "0.3.6",
78
+ "X-Fern-Runtime": core.RUNTIME.type,
79
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
78
80
  },
79
81
  contentType: "application/json",
80
82
  body: yield serializers.UpsertTestSuiteTestCaseRequest.jsonOrThrow(request, {
@@ -129,7 +131,9 @@ class TestSuites {
129
131
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
130
132
  "X-Fern-Language": "JavaScript",
131
133
  "X-Fern-SDK-Name": "vellum-ai",
132
- "X-Fern-SDK-Version": "0.3.5",
134
+ "X-Fern-SDK-Version": "0.3.6",
135
+ "X-Fern-Runtime": core.RUNTIME.type,
136
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
133
137
  },
134
138
  contentType: "application/json",
135
139
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : undefined,
@@ -73,7 +73,9 @@ class WorkflowDeployments {
73
73
  X_API_KEY: yield core.Supplier.get(this._options.apiKey),
74
74
  "X-Fern-Language": "JavaScript",
75
75
  "X-Fern-SDK-Name": "vellum-ai",
76
- "X-Fern-SDK-Version": "0.3.5",
76
+ "X-Fern-SDK-Version": "0.3.6",
77
+ "X-Fern-Runtime": core.RUNTIME.type,
78
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
77
79
  },
78
80
  contentType: "application/json",
79
81
  queryParameters: _queryParams,
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.fetcher = void 0;
16
16
  const form_data_1 = __importDefault(require("form-data"));
17
17
  const qs_1 = __importDefault(require("qs"));
18
+ const runtime_1 = require("../runtime");
18
19
  const INITIAL_RETRY_DELAY = 1;
19
20
  const MAX_RETRY_DELAY = 60;
20
21
  const DEFAULT_MAX_RETRIES = 2;
@@ -40,10 +41,16 @@ function fetcherImpl(args) {
40
41
  // @ts-expect-error
41
42
  body = args.body;
42
43
  }
44
+ else if (args.body instanceof Uint8Array) {
45
+ body = args.body;
46
+ }
43
47
  else {
44
48
  body = JSON.stringify(args.body);
45
49
  }
46
- const fetchFn = typeof fetch == "function" ? fetch : require("node-fetch");
50
+ // In Node.js environments, the SDK always uses`node-fetch`.
51
+ // If not in Node.js the SDK uses global fetch if available,
52
+ // and falls back to node-fetch.
53
+ const fetchFn = runtime_1.RUNTIME.type === "node" ? require("node-fetch") : typeof fetch == "function" ? fetch : require("node-fetch");
47
54
  const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
48
55
  const controller = new AbortController();
49
56
  let abortId = undefined;
@@ -1,3 +1,4 @@
1
1
  export * from "./fetcher";
2
+ export * from "./runtime";
2
3
  export * from "./streaming-fetcher";
3
4
  export * as serialization from "./schemas";
@@ -28,5 +28,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.serialization = void 0;
30
30
  __exportStar(require("./fetcher"), exports);
31
+ __exportStar(require("./runtime"), exports);
31
32
  __exportStar(require("./streaming-fetcher"), exports);
32
33
  exports.serialization = __importStar(require("./schemas"));
@@ -0,0 +1 @@
1
+ export { RUNTIME } from "./runtime";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RUNTIME = void 0;
4
+ var runtime_1 = require("./runtime");
5
+ Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return runtime_1.RUNTIME; } });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A constant that indicates which environment and version the SDK is running in.
3
+ */
4
+ export declare const RUNTIME: Runtime;
5
+ export interface Runtime {
6
+ type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown";
7
+ version?: string;
8
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RUNTIME = void 0;
5
+ /**
6
+ * A constant that indicates whether the environment the code is running is a Web Browser.
7
+ */
8
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
9
+ /**
10
+ * A constant that indicates whether the environment the code is running is a Web Worker.
11
+ */
12
+ const isWebWorker = typeof self === "object" &&
13
+ // @ts-ignore
14
+ typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
15
+ (((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
16
+ ((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
17
+ ((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
18
+ /**
19
+ * A constant that indicates whether the environment the code is running is Deno.
20
+ */
21
+ const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
22
+ /**
23
+ * A constant that indicates whether the environment the code is running is Bun.sh.
24
+ */
25
+ const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
26
+ /**
27
+ * A constant that indicates whether the environment the code is running is Node.JS.
28
+ */
29
+ const isNode = typeof process !== "undefined" &&
30
+ Boolean(process.version) &&
31
+ Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) &&
32
+ // Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
33
+ !isDeno &&
34
+ !isBun;
35
+ /**
36
+ * A constant that indicates whether the environment the code is running is in React-Native.
37
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
38
+ */
39
+ const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
40
+ /**
41
+ * A constant that indicates which environment and version the SDK is running in.
42
+ */
43
+ exports.RUNTIME = evaluateRuntime();
44
+ function evaluateRuntime() {
45
+ if (isBrowser) {
46
+ return {
47
+ type: "browser",
48
+ version: window.navigator.userAgent,
49
+ };
50
+ }
51
+ if (isWebWorker) {
52
+ return {
53
+ type: "web-worker",
54
+ };
55
+ }
56
+ if (isDeno) {
57
+ return {
58
+ type: "deno",
59
+ version: Deno.version.deno,
60
+ };
61
+ }
62
+ if (isBun) {
63
+ return {
64
+ type: "bun",
65
+ version: Bun.version,
66
+ };
67
+ }
68
+ if (isNode) {
69
+ return {
70
+ type: "node",
71
+ version: process.versions.node,
72
+ };
73
+ }
74
+ if (isReactNative) {
75
+ return {
76
+ type: "react-native",
77
+ };
78
+ }
79
+ return {
80
+ type: "unknown",
81
+ };
82
+ }
@@ -13,3 +13,7 @@ export declare class Stream<T> implements AsyncIterable<T> {
13
13
  private iterMessages;
14
14
  [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
15
15
  }
16
+ /**
17
+ * Browser polyfill for ReadableStream
18
+ */
19
+ export declare function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T>;
@@ -1,4 +1,13 @@
1
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
+ };
2
11
  var __asyncValues = (this && this.__asyncValues) || function (o) {
3
12
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
4
13
  var m = o[Symbol.asyncIterator], i;
@@ -19,7 +28,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
19
28
  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
20
29
  };
21
30
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.Stream = void 0;
31
+ exports.readableStreamAsyncIterable = exports.Stream = void 0;
23
32
  class Stream {
24
33
  constructor({ stream, parse, terminator, }) {
25
34
  this.stream = stream;
@@ -29,11 +38,21 @@ class Stream {
29
38
  iterMessages() {
30
39
  return __asyncGenerator(this, arguments, function* iterMessages_1() {
31
40
  var e_1, _a;
41
+ const decoder = new TextDecoder("utf8");
42
+ const stream = readableStreamAsyncIterable(this.stream);
32
43
  let previous = "";
33
44
  try {
34
- for (var _b = __asyncValues(this.stream), _c; _c = yield __await(_b.next()), !_c.done;) {
35
- const chunk = _c.value;
36
- const bufferChunk = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
45
+ for (var stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), !stream_1_1.done;) {
46
+ const chunk = stream_1_1.value;
47
+ let bufferChunk = "";
48
+ // Buffer is present in Node.js environment
49
+ if (typeof Buffer !== "undefined") {
50
+ bufferChunk += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
51
+ }
52
+ // TextDecoder is present in Browser environment
53
+ else if (typeof TextDecoder !== "undefined") {
54
+ bufferChunk += decoder.decode(chunk);
55
+ }
37
56
  previous += bufferChunk;
38
57
  let terminatorIndex;
39
58
  while ((terminatorIndex = previous.indexOf(this.terminator)) >= 0) {
@@ -47,7 +66,7 @@ class Stream {
47
66
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
48
67
  finally {
49
68
  try {
50
- if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
69
+ if (stream_1_1 && !stream_1_1.done && (_a = stream_1.return)) yield __await(_a.call(stream_1));
51
70
  }
52
71
  finally { if (e_1) throw e_1.error; }
53
72
  }
@@ -73,3 +92,42 @@ class Stream {
73
92
  }
74
93
  }
75
94
  exports.Stream = Stream;
95
+ /**
96
+ * Browser polyfill for ReadableStream
97
+ */
98
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
+ function readableStreamAsyncIterable(stream) {
100
+ if (stream[Symbol.asyncIterator]) {
101
+ return stream;
102
+ }
103
+ const reader = stream.getReader();
104
+ return {
105
+ next() {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ try {
108
+ const result = yield reader.read();
109
+ if (result === null || result === void 0 ? void 0 : result.done) {
110
+ reader.releaseLock();
111
+ } // release lock when stream becomes closed
112
+ return result;
113
+ }
114
+ catch (e) {
115
+ reader.releaseLock(); // release lock when stream becomes errored
116
+ throw e;
117
+ }
118
+ });
119
+ },
120
+ return() {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const cancelPromise = reader.cancel();
123
+ reader.releaseLock();
124
+ yield cancelPromise;
125
+ return { done: true, value: undefined };
126
+ });
127
+ },
128
+ [Symbol.asyncIterator]() {
129
+ return this;
130
+ },
131
+ };
132
+ }
133
+ exports.readableStreamAsyncIterable = readableStreamAsyncIterable;
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: "ts-jest",
4
+ testEnvironment: "node",
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vellum-ai",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "private": false,
5
5
  "repository": "https://github.com/vellum-ai/vellum-client-node",
6
6
  "license": "MIT",
@@ -9,7 +9,8 @@
9
9
  "scripts": {
10
10
  "format": "prettier --write 'src/**/*.ts'",
11
11
  "build": "tsc",
12
- "prepack": "cp -rv dist/. ."
12
+ "prepack": "cp -rv dist/. .",
13
+ "test": "jest"
13
14
  },
14
15
  "dependencies": {
15
16
  "url-join": "4.0.1",
@@ -21,6 +22,9 @@
21
22
  "@types/url-join": "4.0.1",
22
23
  "@types/qs": "6.9.8",
23
24
  "@types/node-fetch": "2.6.9",
25
+ "jest": "^29.7.0",
26
+ "@types/jest": "^29.5.5",
27
+ "ts-jest": "^29.1.1",
24
28
  "@types/node": "17.0.33",
25
29
  "prettier": "2.7.1",
26
30
  "typescript": "4.6.4"
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This is a test file for the SDK.
3
+ *
4
+ * Add any tests here and make sure to mark this file
5
+ * in `.fernignore`.
6
+ */
7
+ describe("test", () => {
8
+ it("default", () => {
9
+ expect(true).toBe(true);
10
+ });
11
+ });