@declaw/sdk 1.1.4 → 1.1.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.
- package/CHANGELOG.md +20 -0
- package/dist/index.cjs +34 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +34 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,26 @@ 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.6]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `Sandbox.killMany(ids)` — bulk teardown in one request.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- `sandbox.kill()` returns once the kill is accepted; pass
|
|
17
|
+
`{ wait: true }` to block until teardown finishes.
|
|
18
|
+
- Bump `undici` optional dep to `^7.0.0` (removes the experimental
|
|
19
|
+
`UNDICI-H2` warning). Minimum Node is now 20.18.1.
|
|
20
|
+
|
|
21
|
+
## [1.1.5]
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Set Node dispatcher pool size to 64 (overridable via
|
|
26
|
+
`DECLAW_SDK_CONNECTIONS`).
|
|
27
|
+
|
|
8
28
|
## [1.1.4]
|
|
9
29
|
|
|
10
30
|
### Changed
|
package/dist/index.cjs
CHANGED
|
@@ -244,14 +244,11 @@ function getDispatcher() {
|
|
|
244
244
|
if (process.env.DECLAW_SDK_DISABLE_DISPATCHER) {
|
|
245
245
|
return void 0;
|
|
246
246
|
}
|
|
247
|
-
const origEmit = process.emitWarning;
|
|
248
|
-
process.emitWarning = ((warning, ...rest) => {
|
|
249
|
-
if (rest[0] === "UNDICI-H2") return;
|
|
250
|
-
return origEmit.call(process, warning, ...rest);
|
|
251
|
-
});
|
|
252
247
|
const undici = await import("undici");
|
|
248
|
+
const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
|
|
249
|
+
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 64;
|
|
253
250
|
return new undici.Agent({
|
|
254
|
-
connections
|
|
251
|
+
connections,
|
|
255
252
|
keepAliveTimeout: 3e4,
|
|
256
253
|
keepAliveMaxTimeout: 6e4,
|
|
257
254
|
pipelining: 1,
|
|
@@ -2140,17 +2137,41 @@ var Sandbox = class _Sandbox {
|
|
|
2140
2137
|
nextToken: data.next_token ?? void 0
|
|
2141
2138
|
};
|
|
2142
2139
|
}
|
|
2140
|
+
async kill(arg) {
|
|
2141
|
+
const opts = typeof arg === "number" ? { requestTimeout: arg } : arg ?? {};
|
|
2142
|
+
const wait = opts.wait === true;
|
|
2143
|
+
const path = wait ? `/sandboxes/${this._sandboxId}` : `/sandboxes/${this._sandboxId}?async=true`;
|
|
2144
|
+
const data = await this._client.delete(path, {
|
|
2145
|
+
timeout: opts.requestTimeout
|
|
2146
|
+
});
|
|
2147
|
+
if (!wait) {
|
|
2148
|
+
return data.queued ?? true;
|
|
2149
|
+
}
|
|
2150
|
+
return data.killed ?? false;
|
|
2151
|
+
}
|
|
2143
2152
|
/**
|
|
2144
|
-
* Kill
|
|
2153
|
+
* Kill many sandboxes in a single request. Server fans out internally
|
|
2154
|
+
* with bounded concurrency, eliminating per-id round-trip overhead.
|
|
2145
2155
|
*
|
|
2146
|
-
* @param
|
|
2147
|
-
* @
|
|
2156
|
+
* @param ids - sandbox IDs to kill.
|
|
2157
|
+
* @param opts.wait - If true, wait for each VM's teardown to finish
|
|
2158
|
+
* before returning. Default is false (server returns 202 once the
|
|
2159
|
+
* request is queued).
|
|
2160
|
+
* @param opts.requestTimeout - Per-request timeout in milliseconds.
|
|
2161
|
+
* @returns Map of sandbox-id → outcome. Outcome is `{killed: true}`
|
|
2162
|
+
* (wait=true), `{queued: true}` (default), or `{error: string}` if
|
|
2163
|
+
* the server reported a per-id failure.
|
|
2148
2164
|
*/
|
|
2149
|
-
async
|
|
2150
|
-
|
|
2151
|
-
|
|
2165
|
+
static async killMany(ids, opts) {
|
|
2166
|
+
if (!ids || ids.length === 0) return {};
|
|
2167
|
+
const config = opts?.config ?? new ConnectionConfig();
|
|
2168
|
+
const client = getSharedClient(config);
|
|
2169
|
+
const path = opts?.wait ? "/sandboxes/kill-many" : "/sandboxes/kill-many?async=true";
|
|
2170
|
+
const data = await client.post(path, {
|
|
2171
|
+
json: { sandbox_ids: ids },
|
|
2172
|
+
timeout: opts?.requestTimeout
|
|
2152
2173
|
});
|
|
2153
|
-
return data.
|
|
2174
|
+
return data.results ?? {};
|
|
2154
2175
|
}
|
|
2155
2176
|
/**
|
|
2156
2177
|
* Check if this sandbox is currently running.
|