@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/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,18 @@ 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");
|
|
131
136
|
return new undici.Agent({
|
|
132
|
-
connections:
|
|
137
|
+
connections: 10,
|
|
133
138
|
keepAliveTimeout: 3e4,
|
|
134
139
|
keepAliveMaxTimeout: 6e4,
|
|
135
140
|
pipelining: 1,
|
|
141
|
+
allowH2: true,
|
|
136
142
|
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
137
143
|
});
|
|
138
144
|
} catch {
|
|
@@ -2147,6 +2153,27 @@ var Sandbox = class _Sandbox {
|
|
|
2147
2153
|
const raw = data.snapshots ?? [];
|
|
2148
2154
|
return raw.map((s) => parseSnapshot(s));
|
|
2149
2155
|
}
|
|
2156
|
+
/**
|
|
2157
|
+
* Delete a single snapshot of this sandbox by ID.
|
|
2158
|
+
*
|
|
2159
|
+
* The snapshot's PG row and S3 blobs (mem / vmstate / overlay) are
|
|
2160
|
+
* removed. Idempotent: deleting an already-deleted snapshot resolves to
|
|
2161
|
+
* true without throwing.
|
|
2162
|
+
*
|
|
2163
|
+
* The pause snapshot of a currently-paused sandbox is protected — the
|
|
2164
|
+
* server returns 409 because deletion would break Resume. Resume or
|
|
2165
|
+
* kill the sandbox first.
|
|
2166
|
+
*
|
|
2167
|
+
* @param snapshotId - The snapshot to delete.
|
|
2168
|
+
* @param requestTimeout - Optional per-request timeout in milliseconds.
|
|
2169
|
+
* @returns True on success.
|
|
2170
|
+
*/
|
|
2171
|
+
async deleteSnapshot(snapshotId, requestTimeout) {
|
|
2172
|
+
await this._client.delete(`/sandboxes/${this._sandboxId}/snapshots/${snapshotId}`, {
|
|
2173
|
+
timeout: requestTimeout
|
|
2174
|
+
});
|
|
2175
|
+
return true;
|
|
2176
|
+
}
|
|
2150
2177
|
/**
|
|
2151
2178
|
* Restore a sandbox from a snapshot. The restored instance may run on a
|
|
2152
2179
|
* different worker node than the original sandbox.
|
|
@@ -2331,11 +2358,30 @@ var TemplateBase = class {
|
|
|
2331
2358
|
_envs = {};
|
|
2332
2359
|
_aptPackages = [];
|
|
2333
2360
|
_startCmd;
|
|
2361
|
+
/**
|
|
2362
|
+
* When set, the server uses this Dockerfile verbatim and ignores the
|
|
2363
|
+
* structured fields. Use for multi-stage builds, ARG, ONBUILD, etc.
|
|
2364
|
+
*/
|
|
2365
|
+
_dockerfile;
|
|
2334
2366
|
/** Set the base image for the template. */
|
|
2335
2367
|
fromBaseImage(image) {
|
|
2336
2368
|
this._baseImage = image ?? "ubuntu:22.04";
|
|
2337
2369
|
return this;
|
|
2338
2370
|
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Use a raw Dockerfile string instead of the structured helpers.
|
|
2373
|
+
*
|
|
2374
|
+
* When set, all other ``aptInstall`` / ``runCmd`` / ``setEnvs`` /
|
|
2375
|
+
* ``copy`` / ``setStartCmd`` / ``fromBaseImage`` calls on this spec
|
|
2376
|
+
* are ignored — the Dockerfile is sent to the build worker verbatim.
|
|
2377
|
+
*
|
|
2378
|
+
* @param content Full Dockerfile contents. Must contain a ``FROM``
|
|
2379
|
+
* instruction. Capped server-side at 64 KiB.
|
|
2380
|
+
*/
|
|
2381
|
+
fromDockerfile(content) {
|
|
2382
|
+
this._dockerfile = content;
|
|
2383
|
+
return this;
|
|
2384
|
+
}
|
|
2339
2385
|
/** Add a run command (as array of command + args). */
|
|
2340
2386
|
runCmd(cmds) {
|
|
2341
2387
|
this._runCmds.push(cmds);
|
|
@@ -2363,11 +2409,14 @@ var TemplateBase = class {
|
|
|
2363
2409
|
}
|
|
2364
2410
|
/** Serialize the template to a JSON-friendly object. */
|
|
2365
2411
|
toJSON() {
|
|
2412
|
+
if (this._dockerfile !== void 0) {
|
|
2413
|
+
return { dockerfile: this._dockerfile };
|
|
2414
|
+
}
|
|
2366
2415
|
const result = {
|
|
2367
2416
|
base_image: this._baseImage
|
|
2368
2417
|
};
|
|
2369
2418
|
if (this._runCmds.length > 0) {
|
|
2370
|
-
result.run_cmds = this._runCmds;
|
|
2419
|
+
result.run_cmds = this._runCmds.map((c) => c.join(" "));
|
|
2371
2420
|
}
|
|
2372
2421
|
if (this._copies.length > 0) {
|
|
2373
2422
|
result.copies = this._copies;
|