@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/dist/index.d.cts
CHANGED
|
@@ -993,7 +993,7 @@ interface SandboxOpts {
|
|
|
993
993
|
volumes?: VolumeAttachment[];
|
|
994
994
|
/** API key override. */
|
|
995
995
|
apiKey?: string;
|
|
996
|
-
/** Domain override (supports "host:port" format, e.g. "
|
|
996
|
+
/** Domain override (supports "host:port" format, e.g. "myhost.example.com:8080"). */
|
|
997
997
|
domain?: string;
|
|
998
998
|
/** Full API URL override. If set, domain/port/scheme are ignored. */
|
|
999
999
|
apiUrl?: string;
|
|
@@ -1186,6 +1186,22 @@ declare class Sandbox {
|
|
|
1186
1186
|
* @returns Array of Snapshot metadata objects.
|
|
1187
1187
|
*/
|
|
1188
1188
|
listSnapshots(requestTimeout?: number): Promise<Snapshot[]>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Delete a single snapshot of this sandbox by ID.
|
|
1191
|
+
*
|
|
1192
|
+
* The snapshot's PG row and S3 blobs (mem / vmstate / overlay) are
|
|
1193
|
+
* removed. Idempotent: deleting an already-deleted snapshot resolves to
|
|
1194
|
+
* true without throwing.
|
|
1195
|
+
*
|
|
1196
|
+
* The pause snapshot of a currently-paused sandbox is protected — the
|
|
1197
|
+
* server returns 409 because deletion would break Resume. Resume or
|
|
1198
|
+
* kill the sandbox first.
|
|
1199
|
+
*
|
|
1200
|
+
* @param snapshotId - The snapshot to delete.
|
|
1201
|
+
* @param requestTimeout - Optional per-request timeout in milliseconds.
|
|
1202
|
+
* @returns True on success.
|
|
1203
|
+
*/
|
|
1204
|
+
deleteSnapshot(snapshotId: string, requestTimeout?: number): Promise<boolean>;
|
|
1189
1205
|
/**
|
|
1190
1206
|
* Restore a sandbox from a snapshot. The restored instance may run on a
|
|
1191
1207
|
* different worker node than the original sandbox.
|
|
@@ -1372,8 +1388,24 @@ declare class TemplateBase {
|
|
|
1372
1388
|
private _envs;
|
|
1373
1389
|
private _aptPackages;
|
|
1374
1390
|
private _startCmd?;
|
|
1391
|
+
/**
|
|
1392
|
+
* When set, the server uses this Dockerfile verbatim and ignores the
|
|
1393
|
+
* structured fields. Use for multi-stage builds, ARG, ONBUILD, etc.
|
|
1394
|
+
*/
|
|
1395
|
+
private _dockerfile?;
|
|
1375
1396
|
/** Set the base image for the template. */
|
|
1376
1397
|
fromBaseImage(image?: string): this;
|
|
1398
|
+
/**
|
|
1399
|
+
* Use a raw Dockerfile string instead of the structured helpers.
|
|
1400
|
+
*
|
|
1401
|
+
* When set, all other ``aptInstall`` / ``runCmd`` / ``setEnvs`` /
|
|
1402
|
+
* ``copy`` / ``setStartCmd`` / ``fromBaseImage`` calls on this spec
|
|
1403
|
+
* are ignored — the Dockerfile is sent to the build worker verbatim.
|
|
1404
|
+
*
|
|
1405
|
+
* @param content Full Dockerfile contents. Must contain a ``FROM``
|
|
1406
|
+
* instruction. Capped server-side at 64 KiB.
|
|
1407
|
+
*/
|
|
1408
|
+
fromDockerfile(content: string): this;
|
|
1377
1409
|
/** Add a run command (as array of command + args). */
|
|
1378
1410
|
runCmd(cmds: string[]): this;
|
|
1379
1411
|
/** Add a file copy operation. */
|
package/dist/index.d.ts
CHANGED
|
@@ -993,7 +993,7 @@ interface SandboxOpts {
|
|
|
993
993
|
volumes?: VolumeAttachment[];
|
|
994
994
|
/** API key override. */
|
|
995
995
|
apiKey?: string;
|
|
996
|
-
/** Domain override (supports "host:port" format, e.g. "
|
|
996
|
+
/** Domain override (supports "host:port" format, e.g. "myhost.example.com:8080"). */
|
|
997
997
|
domain?: string;
|
|
998
998
|
/** Full API URL override. If set, domain/port/scheme are ignored. */
|
|
999
999
|
apiUrl?: string;
|
|
@@ -1186,6 +1186,22 @@ declare class Sandbox {
|
|
|
1186
1186
|
* @returns Array of Snapshot metadata objects.
|
|
1187
1187
|
*/
|
|
1188
1188
|
listSnapshots(requestTimeout?: number): Promise<Snapshot[]>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Delete a single snapshot of this sandbox by ID.
|
|
1191
|
+
*
|
|
1192
|
+
* The snapshot's PG row and S3 blobs (mem / vmstate / overlay) are
|
|
1193
|
+
* removed. Idempotent: deleting an already-deleted snapshot resolves to
|
|
1194
|
+
* true without throwing.
|
|
1195
|
+
*
|
|
1196
|
+
* The pause snapshot of a currently-paused sandbox is protected — the
|
|
1197
|
+
* server returns 409 because deletion would break Resume. Resume or
|
|
1198
|
+
* kill the sandbox first.
|
|
1199
|
+
*
|
|
1200
|
+
* @param snapshotId - The snapshot to delete.
|
|
1201
|
+
* @param requestTimeout - Optional per-request timeout in milliseconds.
|
|
1202
|
+
* @returns True on success.
|
|
1203
|
+
*/
|
|
1204
|
+
deleteSnapshot(snapshotId: string, requestTimeout?: number): Promise<boolean>;
|
|
1189
1205
|
/**
|
|
1190
1206
|
* Restore a sandbox from a snapshot. The restored instance may run on a
|
|
1191
1207
|
* different worker node than the original sandbox.
|
|
@@ -1372,8 +1388,24 @@ declare class TemplateBase {
|
|
|
1372
1388
|
private _envs;
|
|
1373
1389
|
private _aptPackages;
|
|
1374
1390
|
private _startCmd?;
|
|
1391
|
+
/**
|
|
1392
|
+
* When set, the server uses this Dockerfile verbatim and ignores the
|
|
1393
|
+
* structured fields. Use for multi-stage builds, ARG, ONBUILD, etc.
|
|
1394
|
+
*/
|
|
1395
|
+
private _dockerfile?;
|
|
1375
1396
|
/** Set the base image for the template. */
|
|
1376
1397
|
fromBaseImage(image?: string): this;
|
|
1398
|
+
/**
|
|
1399
|
+
* Use a raw Dockerfile string instead of the structured helpers.
|
|
1400
|
+
*
|
|
1401
|
+
* When set, all other ``aptInstall`` / ``runCmd`` / ``setEnvs`` /
|
|
1402
|
+
* ``copy`` / ``setStartCmd`` / ``fromBaseImage`` calls on this spec
|
|
1403
|
+
* are ignored — the Dockerfile is sent to the build worker verbatim.
|
|
1404
|
+
*
|
|
1405
|
+
* @param content Full Dockerfile contents. Must contain a ``FROM``
|
|
1406
|
+
* instruction. Capped server-side at 64 KiB.
|
|
1407
|
+
*/
|
|
1408
|
+
fromDockerfile(content: string): this;
|
|
1377
1409
|
/** Add a run command (as array of command + args). */
|
|
1378
1410
|
runCmd(cmds: string[]): this;
|
|
1379
1411
|
/** Add a file copy operation. */
|
package/dist/index.js
CHANGED
|
@@ -127,12 +127,20 @@ function getDispatcher() {
|
|
|
127
127
|
if (process.env.DECLAW_SDK_DISABLE_DISPATCHER) {
|
|
128
128
|
return void 0;
|
|
129
129
|
}
|
|
130
|
+
const origEmit = process.emitWarning;
|
|
131
|
+
process.emitWarning = ((warning, ...rest) => {
|
|
132
|
+
if (rest[0] === "UNDICI-H2") return;
|
|
133
|
+
return origEmit.call(process, warning, ...rest);
|
|
134
|
+
});
|
|
130
135
|
const undici = await import("undici");
|
|
136
|
+
const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
|
|
137
|
+
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 64;
|
|
131
138
|
return new undici.Agent({
|
|
132
|
-
connections
|
|
139
|
+
connections,
|
|
133
140
|
keepAliveTimeout: 3e4,
|
|
134
141
|
keepAliveMaxTimeout: 6e4,
|
|
135
142
|
pipelining: 1,
|
|
143
|
+
allowH2: true,
|
|
136
144
|
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
137
145
|
});
|
|
138
146
|
} catch {
|
|
@@ -2147,6 +2155,27 @@ var Sandbox = class _Sandbox {
|
|
|
2147
2155
|
const raw = data.snapshots ?? [];
|
|
2148
2156
|
return raw.map((s) => parseSnapshot(s));
|
|
2149
2157
|
}
|
|
2158
|
+
/**
|
|
2159
|
+
* Delete a single snapshot of this sandbox by ID.
|
|
2160
|
+
*
|
|
2161
|
+
* The snapshot's PG row and S3 blobs (mem / vmstate / overlay) are
|
|
2162
|
+
* removed. Idempotent: deleting an already-deleted snapshot resolves to
|
|
2163
|
+
* true without throwing.
|
|
2164
|
+
*
|
|
2165
|
+
* The pause snapshot of a currently-paused sandbox is protected — the
|
|
2166
|
+
* server returns 409 because deletion would break Resume. Resume or
|
|
2167
|
+
* kill the sandbox first.
|
|
2168
|
+
*
|
|
2169
|
+
* @param snapshotId - The snapshot to delete.
|
|
2170
|
+
* @param requestTimeout - Optional per-request timeout in milliseconds.
|
|
2171
|
+
* @returns True on success.
|
|
2172
|
+
*/
|
|
2173
|
+
async deleteSnapshot(snapshotId, requestTimeout) {
|
|
2174
|
+
await this._client.delete(`/sandboxes/${this._sandboxId}/snapshots/${snapshotId}`, {
|
|
2175
|
+
timeout: requestTimeout
|
|
2176
|
+
});
|
|
2177
|
+
return true;
|
|
2178
|
+
}
|
|
2150
2179
|
/**
|
|
2151
2180
|
* Restore a sandbox from a snapshot. The restored instance may run on a
|
|
2152
2181
|
* different worker node than the original sandbox.
|
|
@@ -2331,11 +2360,30 @@ var TemplateBase = class {
|
|
|
2331
2360
|
_envs = {};
|
|
2332
2361
|
_aptPackages = [];
|
|
2333
2362
|
_startCmd;
|
|
2363
|
+
/**
|
|
2364
|
+
* When set, the server uses this Dockerfile verbatim and ignores the
|
|
2365
|
+
* structured fields. Use for multi-stage builds, ARG, ONBUILD, etc.
|
|
2366
|
+
*/
|
|
2367
|
+
_dockerfile;
|
|
2334
2368
|
/** Set the base image for the template. */
|
|
2335
2369
|
fromBaseImage(image) {
|
|
2336
2370
|
this._baseImage = image ?? "ubuntu:22.04";
|
|
2337
2371
|
return this;
|
|
2338
2372
|
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Use a raw Dockerfile string instead of the structured helpers.
|
|
2375
|
+
*
|
|
2376
|
+
* When set, all other ``aptInstall`` / ``runCmd`` / ``setEnvs`` /
|
|
2377
|
+
* ``copy`` / ``setStartCmd`` / ``fromBaseImage`` calls on this spec
|
|
2378
|
+
* are ignored — the Dockerfile is sent to the build worker verbatim.
|
|
2379
|
+
*
|
|
2380
|
+
* @param content Full Dockerfile contents. Must contain a ``FROM``
|
|
2381
|
+
* instruction. Capped server-side at 64 KiB.
|
|
2382
|
+
*/
|
|
2383
|
+
fromDockerfile(content) {
|
|
2384
|
+
this._dockerfile = content;
|
|
2385
|
+
return this;
|
|
2386
|
+
}
|
|
2339
2387
|
/** Add a run command (as array of command + args). */
|
|
2340
2388
|
runCmd(cmds) {
|
|
2341
2389
|
this._runCmds.push(cmds);
|
|
@@ -2363,11 +2411,14 @@ var TemplateBase = class {
|
|
|
2363
2411
|
}
|
|
2364
2412
|
/** Serialize the template to a JSON-friendly object. */
|
|
2365
2413
|
toJSON() {
|
|
2414
|
+
if (this._dockerfile !== void 0) {
|
|
2415
|
+
return { dockerfile: this._dockerfile };
|
|
2416
|
+
}
|
|
2366
2417
|
const result = {
|
|
2367
2418
|
base_image: this._baseImage
|
|
2368
2419
|
};
|
|
2369
2420
|
if (this._runCmds.length > 0) {
|
|
2370
|
-
result.run_cmds = this._runCmds;
|
|
2421
|
+
result.run_cmds = this._runCmds.map((c) => c.join(" "));
|
|
2371
2422
|
}
|
|
2372
2423
|
if (this._copies.length > 0) {
|
|
2373
2424
|
result.copies = this._copies;
|