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