@declaw/sdk 1.1.3 → 1.1.5
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 +13 -0
- package/dist/index.cjs +53 -2
- 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 +53 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.5]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Set Node dispatcher pool size to 64 (overridable via
|
|
13
|
+
`DECLAW_SDK_CONNECTIONS`).
|
|
14
|
+
|
|
15
|
+
## [1.1.4]
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Enable HTTP/2 multiplexing on the Node dispatcher (`allowH2: true`).
|
|
20
|
+
|
|
8
21
|
## [1.1.3]
|
|
9
22
|
|
|
10
23
|
### Changed
|
package/dist/index.cjs
CHANGED
|
@@ -244,12 +244,20 @@ 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
|
+
});
|
|
247
252
|
const undici = await import("undici");
|
|
253
|
+
const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
|
|
254
|
+
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 64;
|
|
248
255
|
return new undici.Agent({
|
|
249
|
-
connections
|
|
256
|
+
connections,
|
|
250
257
|
keepAliveTimeout: 3e4,
|
|
251
258
|
keepAliveMaxTimeout: 6e4,
|
|
252
259
|
pipelining: 1,
|
|
260
|
+
allowH2: true,
|
|
253
261
|
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
254
262
|
});
|
|
255
263
|
} catch {
|
|
@@ -2264,6 +2272,27 @@ var Sandbox = class _Sandbox {
|
|
|
2264
2272
|
const raw = data.snapshots ?? [];
|
|
2265
2273
|
return raw.map((s) => parseSnapshot(s));
|
|
2266
2274
|
}
|
|
2275
|
+
/**
|
|
2276
|
+
* Delete a single snapshot of this sandbox by ID.
|
|
2277
|
+
*
|
|
2278
|
+
* The snapshot's PG row and S3 blobs (mem / vmstate / overlay) are
|
|
2279
|
+
* removed. Idempotent: deleting an already-deleted snapshot resolves to
|
|
2280
|
+
* true without throwing.
|
|
2281
|
+
*
|
|
2282
|
+
* The pause snapshot of a currently-paused sandbox is protected — the
|
|
2283
|
+
* server returns 409 because deletion would break Resume. Resume or
|
|
2284
|
+
* kill the sandbox first.
|
|
2285
|
+
*
|
|
2286
|
+
* @param snapshotId - The snapshot to delete.
|
|
2287
|
+
* @param requestTimeout - Optional per-request timeout in milliseconds.
|
|
2288
|
+
* @returns True on success.
|
|
2289
|
+
*/
|
|
2290
|
+
async deleteSnapshot(snapshotId, requestTimeout) {
|
|
2291
|
+
await this._client.delete(`/sandboxes/${this._sandboxId}/snapshots/${snapshotId}`, {
|
|
2292
|
+
timeout: requestTimeout
|
|
2293
|
+
});
|
|
2294
|
+
return true;
|
|
2295
|
+
}
|
|
2267
2296
|
/**
|
|
2268
2297
|
* Restore a sandbox from a snapshot. The restored instance may run on a
|
|
2269
2298
|
* different worker node than the original sandbox.
|
|
@@ -2448,11 +2477,30 @@ var TemplateBase = class {
|
|
|
2448
2477
|
_envs = {};
|
|
2449
2478
|
_aptPackages = [];
|
|
2450
2479
|
_startCmd;
|
|
2480
|
+
/**
|
|
2481
|
+
* When set, the server uses this Dockerfile verbatim and ignores the
|
|
2482
|
+
* structured fields. Use for multi-stage builds, ARG, ONBUILD, etc.
|
|
2483
|
+
*/
|
|
2484
|
+
_dockerfile;
|
|
2451
2485
|
/** Set the base image for the template. */
|
|
2452
2486
|
fromBaseImage(image) {
|
|
2453
2487
|
this._baseImage = image ?? "ubuntu:22.04";
|
|
2454
2488
|
return this;
|
|
2455
2489
|
}
|
|
2490
|
+
/**
|
|
2491
|
+
* Use a raw Dockerfile string instead of the structured helpers.
|
|
2492
|
+
*
|
|
2493
|
+
* When set, all other ``aptInstall`` / ``runCmd`` / ``setEnvs`` /
|
|
2494
|
+
* ``copy`` / ``setStartCmd`` / ``fromBaseImage`` calls on this spec
|
|
2495
|
+
* are ignored — the Dockerfile is sent to the build worker verbatim.
|
|
2496
|
+
*
|
|
2497
|
+
* @param content Full Dockerfile contents. Must contain a ``FROM``
|
|
2498
|
+
* instruction. Capped server-side at 64 KiB.
|
|
2499
|
+
*/
|
|
2500
|
+
fromDockerfile(content) {
|
|
2501
|
+
this._dockerfile = content;
|
|
2502
|
+
return this;
|
|
2503
|
+
}
|
|
2456
2504
|
/** Add a run command (as array of command + args). */
|
|
2457
2505
|
runCmd(cmds) {
|
|
2458
2506
|
this._runCmds.push(cmds);
|
|
@@ -2480,11 +2528,14 @@ var TemplateBase = class {
|
|
|
2480
2528
|
}
|
|
2481
2529
|
/** Serialize the template to a JSON-friendly object. */
|
|
2482
2530
|
toJSON() {
|
|
2531
|
+
if (this._dockerfile !== void 0) {
|
|
2532
|
+
return { dockerfile: this._dockerfile };
|
|
2533
|
+
}
|
|
2483
2534
|
const result = {
|
|
2484
2535
|
base_image: this._baseImage
|
|
2485
2536
|
};
|
|
2486
2537
|
if (this._runCmds.length > 0) {
|
|
2487
|
-
result.run_cmds = this._runCmds;
|
|
2538
|
+
result.run_cmds = this._runCmds.map((c) => c.join(" "));
|
|
2488
2539
|
}
|
|
2489
2540
|
if (this._copies.length > 0) {
|
|
2490
2541
|
result.copies = this._copies;
|