@declaw/sdk 1.1.5 → 1.1.7
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 +19 -0
- package/dist/index.cjs +57 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -1
- package/dist/index.d.ts +54 -1
- package/dist/index.js +57 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ 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.7]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `Sandbox.kill(id)` static — kill by id in one HTTP call.
|
|
13
|
+
|
|
14
|
+
## [1.1.6]
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `Sandbox.killMany(ids)` — bulk teardown in one request.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- `sandbox.kill()` returns once the kill is accepted; pass
|
|
23
|
+
`{ wait: true }` to block until teardown finishes.
|
|
24
|
+
- Bump `undici` optional dep to `^7.0.0` (removes the experimental
|
|
25
|
+
`UNDICI-H2` warning). Minimum Node is now 20.18.1.
|
|
26
|
+
|
|
8
27
|
## [1.1.5]
|
|
9
28
|
|
|
10
29
|
### 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,16 +2137,67 @@ 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
|
|
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
|
|
2149
|
-
* @
|
|
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
|
|
2152
|
-
|
|
2153
|
-
|
|
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
|
|
2173
|
+
});
|
|
2174
|
+
return data.results ?? {};
|
|
2175
|
+
}
|
|
2176
|
+
/**
|
|
2177
|
+
* Kill a sandbox by id without first connecting. Sends a single
|
|
2178
|
+
* `DELETE /sandboxes/:id?async=true` and skips the metadata fetch
|
|
2179
|
+
* `Sandbox.connect(id).kill()` would otherwise pay. Useful for bulk
|
|
2180
|
+
* cleanup paths that only have the id.
|
|
2181
|
+
*
|
|
2182
|
+
* @param sandboxId - the sandbox to kill.
|
|
2183
|
+
* @param opts.wait - if true, block until the server finishes the
|
|
2184
|
+
* per-VM teardown. Default is false: server returns 202 once the
|
|
2185
|
+
* kill is queued.
|
|
2186
|
+
* @param opts.requestTimeout - per-request timeout in milliseconds.
|
|
2187
|
+
* @param opts.config - override the default ConnectionConfig.
|
|
2188
|
+
* @returns true if the kill was accepted (default) or completed
|
|
2189
|
+
* (wait=true); false if the server reported the sandbox was
|
|
2190
|
+
* already dead.
|
|
2191
|
+
*/
|
|
2192
|
+
static async kill(sandboxId, opts) {
|
|
2193
|
+
const config = opts?.config ?? new ConnectionConfig();
|
|
2194
|
+
const client = getSharedClient(config);
|
|
2195
|
+
const wait = opts?.wait === true;
|
|
2196
|
+
const path = wait ? `/sandboxes/${sandboxId}` : `/sandboxes/${sandboxId}?async=true`;
|
|
2197
|
+
const data = await client.delete(path, {
|
|
2198
|
+
timeout: opts?.requestTimeout
|
|
2154
2199
|
});
|
|
2200
|
+
if (!wait) return data.queued ?? true;
|
|
2155
2201
|
return data.killed ?? false;
|
|
2156
2202
|
}
|
|
2157
2203
|
/**
|