@declaw/sdk 1.1.5 → 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 CHANGED
@@ -5,6 +5,19 @@ 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
+
8
21
  ## [1.1.5]
9
22
 
10
23
  ### Changed
package/dist/index.cjs CHANGED
@@ -244,11 +244,6 @@ 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");
253
248
  const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
254
249
  const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 64;
@@ -2142,17 +2137,41 @@ var Sandbox = class _Sandbox {
2142
2137
  nextToken: data.next_token ?? void 0
2143
2138
  };
2144
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
+ }
2145
2152
  /**
2146
- * Kill this sandbox.
2153
+ * Kill many sandboxes in a single request. Server fans out internally
2154
+ * with bounded concurrency, eliminating per-id round-trip overhead.
2147
2155
  *
2148
- * @param requestTimeout - Optional per-request timeout in milliseconds.
2149
- * @returns True if the sandbox was killed, false if it was already dead.
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.
2150
2164
  */
2151
- async kill(requestTimeout) {
2152
- const data = await this._client.delete(`/sandboxes/${this._sandboxId}`, {
2153
- timeout: requestTimeout
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
2154
2173
  });
2155
- return data.killed ?? false;
2174
+ return data.results ?? {};
2156
2175
  }
2157
2176
  /**
2158
2177
  * Check if this sandbox is currently running.