@declaw/sdk 1.1.2 → 1.1.3

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to the Declaw TypeScript / JavaScript SDK are documented in
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.3]
9
+
10
+ ### Changed
11
+
12
+ - **Higher-concurrency HTTP dispatcher on Node.** The SDK now installs a
13
+ module-level `undici.Agent` (128 connections per origin, keep-alive
14
+ tuned) on first use under Node, so callers fanning out many concurrent
15
+ requests are no longer capped by undici's default 10 connections per
16
+ origin. On runtimes that don't ship `undici` (browsers, Cloudflare
17
+ Workers, Deno) the dynamic import silently no-ops and the platform's
18
+ native `fetch` is used unchanged. Opt out with
19
+ `DECLAW_SDK_DISABLE_DISPATCHER=1` if you bring your own dispatcher.
20
+ `undici` is declared as an `optionalDependency`.
21
+
8
22
  ## [1.1.2]
9
23
 
10
24
  ### Fixed
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -223,6 +233,31 @@ var CommandExitError = class extends SandboxError {
223
233
  };
224
234
 
225
235
  // src/api/client.ts
236
+ var _dispatcherPromise;
237
+ function getDispatcher() {
238
+ if (_dispatcherPromise) return _dispatcherPromise;
239
+ _dispatcherPromise = (async () => {
240
+ try {
241
+ if (typeof process === "undefined" || !process.versions?.node) {
242
+ return void 0;
243
+ }
244
+ if (process.env.DECLAW_SDK_DISABLE_DISPATCHER) {
245
+ return void 0;
246
+ }
247
+ const undici = await import("undici");
248
+ return new undici.Agent({
249
+ connections: 128,
250
+ keepAliveTimeout: 3e4,
251
+ keepAliveMaxTimeout: 6e4,
252
+ pipelining: 1,
253
+ connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
254
+ });
255
+ } catch {
256
+ return void 0;
257
+ }
258
+ })();
259
+ return _dispatcherPromise;
260
+ }
226
261
  var STATUS_ERROR_MAP = {
227
262
  401: AuthenticationError,
228
263
  403: AuthenticationError,
@@ -333,12 +368,15 @@ var ApiClient = class {
333
368
  signals.push(AbortSignal.timeout(timeoutMs));
334
369
  }
335
370
  const signal = signals.length === 1 ? signals[0] : AbortSignal.any(signals);
336
- const response = await fetch(url, {
371
+ const dispatcher = await getDispatcher();
372
+ const fetchOpts = {
337
373
  method,
338
374
  headers,
339
375
  body: fetchBody,
340
376
  signal
341
- });
377
+ };
378
+ if (dispatcher) fetchOpts.dispatcher = dispatcher;
379
+ const response = await fetch(url, fetchOpts);
342
380
  if (response.status >= 500 && attempt < this.maxRetries - 1) {
343
381
  await this.delay(attempt);
344
382
  continue;