@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 +14 -0
- package/dist/index.cjs +40 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -116,6 +116,31 @@ var CommandExitError = class extends SandboxError {
|
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
// src/api/client.ts
|
|
119
|
+
var _dispatcherPromise;
|
|
120
|
+
function getDispatcher() {
|
|
121
|
+
if (_dispatcherPromise) return _dispatcherPromise;
|
|
122
|
+
_dispatcherPromise = (async () => {
|
|
123
|
+
try {
|
|
124
|
+
if (typeof process === "undefined" || !process.versions?.node) {
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
if (process.env.DECLAW_SDK_DISABLE_DISPATCHER) {
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
const undici = await import("undici");
|
|
131
|
+
return new undici.Agent({
|
|
132
|
+
connections: 128,
|
|
133
|
+
keepAliveTimeout: 3e4,
|
|
134
|
+
keepAliveMaxTimeout: 6e4,
|
|
135
|
+
pipelining: 1,
|
|
136
|
+
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
137
|
+
});
|
|
138
|
+
} catch {
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
return _dispatcherPromise;
|
|
143
|
+
}
|
|
119
144
|
var STATUS_ERROR_MAP = {
|
|
120
145
|
401: AuthenticationError,
|
|
121
146
|
403: AuthenticationError,
|
|
@@ -226,12 +251,15 @@ var ApiClient = class {
|
|
|
226
251
|
signals.push(AbortSignal.timeout(timeoutMs));
|
|
227
252
|
}
|
|
228
253
|
const signal = signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
229
|
-
const
|
|
254
|
+
const dispatcher = await getDispatcher();
|
|
255
|
+
const fetchOpts = {
|
|
230
256
|
method,
|
|
231
257
|
headers,
|
|
232
258
|
body: fetchBody,
|
|
233
259
|
signal
|
|
234
|
-
}
|
|
260
|
+
};
|
|
261
|
+
if (dispatcher) fetchOpts.dispatcher = dispatcher;
|
|
262
|
+
const response = await fetch(url, fetchOpts);
|
|
235
263
|
if (response.status >= 500 && attempt < this.maxRetries - 1) {
|
|
236
264
|
await this.delay(attempt);
|
|
237
265
|
continue;
|