@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/dist/index.d.cts CHANGED
@@ -1113,10 +1113,63 @@ declare class Sandbox {
1113
1113
  /**
1114
1114
  * Kill this sandbox.
1115
1115
  *
1116
+ * Returns once the kill has been accepted by the server. The per-VM
1117
+ * teardown (firecracker shutdown + netns + iptables cleanup) runs in
1118
+ * the background. Pass `{ wait: true }` to block until the teardown
1119
+ * has fully completed.
1120
+ *
1116
1121
  * @param requestTimeout - Optional per-request timeout in milliseconds.
1117
- * @returns True if the sandbox was killed, false if it was already dead.
1122
+ * @returns True if the sandbox was killed (or queued); false if the
1123
+ * server reported it was already dead.
1118
1124
  */
1119
1125
  kill(requestTimeout?: number): Promise<boolean>;
1126
+ kill(opts?: {
1127
+ requestTimeout?: number;
1128
+ wait?: boolean;
1129
+ }): Promise<boolean>;
1130
+ /**
1131
+ * Kill many sandboxes in a single request. Server fans out internally
1132
+ * with bounded concurrency, eliminating per-id round-trip overhead.
1133
+ *
1134
+ * @param ids - sandbox IDs to kill.
1135
+ * @param opts.wait - If true, wait for each VM's teardown to finish
1136
+ * before returning. Default is false (server returns 202 once the
1137
+ * request is queued).
1138
+ * @param opts.requestTimeout - Per-request timeout in milliseconds.
1139
+ * @returns Map of sandbox-id → outcome. Outcome is `{killed: true}`
1140
+ * (wait=true), `{queued: true}` (default), or `{error: string}` if
1141
+ * the server reported a per-id failure.
1142
+ */
1143
+ static killMany(ids: string[], opts?: {
1144
+ wait?: boolean;
1145
+ requestTimeout?: number;
1146
+ config?: ConnectionConfig;
1147
+ }): Promise<Record<string, {
1148
+ killed?: boolean;
1149
+ queued?: boolean;
1150
+ error?: string;
1151
+ }>>;
1152
+ /**
1153
+ * Kill a sandbox by id without first connecting. Sends a single
1154
+ * `DELETE /sandboxes/:id?async=true` and skips the metadata fetch
1155
+ * `Sandbox.connect(id).kill()` would otherwise pay. Useful for bulk
1156
+ * cleanup paths that only have the id.
1157
+ *
1158
+ * @param sandboxId - the sandbox to kill.
1159
+ * @param opts.wait - if true, block until the server finishes the
1160
+ * per-VM teardown. Default is false: server returns 202 once the
1161
+ * kill is queued.
1162
+ * @param opts.requestTimeout - per-request timeout in milliseconds.
1163
+ * @param opts.config - override the default ConnectionConfig.
1164
+ * @returns true if the kill was accepted (default) or completed
1165
+ * (wait=true); false if the server reported the sandbox was
1166
+ * already dead.
1167
+ */
1168
+ static kill(sandboxId: string, opts?: {
1169
+ wait?: boolean;
1170
+ requestTimeout?: number;
1171
+ config?: ConnectionConfig;
1172
+ }): Promise<boolean>;
1120
1173
  /**
1121
1174
  * Check if this sandbox is currently running.
1122
1175
  *
package/dist/index.d.ts CHANGED
@@ -1113,10 +1113,63 @@ declare class Sandbox {
1113
1113
  /**
1114
1114
  * Kill this sandbox.
1115
1115
  *
1116
+ * Returns once the kill has been accepted by the server. The per-VM
1117
+ * teardown (firecracker shutdown + netns + iptables cleanup) runs in
1118
+ * the background. Pass `{ wait: true }` to block until the teardown
1119
+ * has fully completed.
1120
+ *
1116
1121
  * @param requestTimeout - Optional per-request timeout in milliseconds.
1117
- * @returns True if the sandbox was killed, false if it was already dead.
1122
+ * @returns True if the sandbox was killed (or queued); false if the
1123
+ * server reported it was already dead.
1118
1124
  */
1119
1125
  kill(requestTimeout?: number): Promise<boolean>;
1126
+ kill(opts?: {
1127
+ requestTimeout?: number;
1128
+ wait?: boolean;
1129
+ }): Promise<boolean>;
1130
+ /**
1131
+ * Kill many sandboxes in a single request. Server fans out internally
1132
+ * with bounded concurrency, eliminating per-id round-trip overhead.
1133
+ *
1134
+ * @param ids - sandbox IDs to kill.
1135
+ * @param opts.wait - If true, wait for each VM's teardown to finish
1136
+ * before returning. Default is false (server returns 202 once the
1137
+ * request is queued).
1138
+ * @param opts.requestTimeout - Per-request timeout in milliseconds.
1139
+ * @returns Map of sandbox-id → outcome. Outcome is `{killed: true}`
1140
+ * (wait=true), `{queued: true}` (default), or `{error: string}` if
1141
+ * the server reported a per-id failure.
1142
+ */
1143
+ static killMany(ids: string[], opts?: {
1144
+ wait?: boolean;
1145
+ requestTimeout?: number;
1146
+ config?: ConnectionConfig;
1147
+ }): Promise<Record<string, {
1148
+ killed?: boolean;
1149
+ queued?: boolean;
1150
+ error?: string;
1151
+ }>>;
1152
+ /**
1153
+ * Kill a sandbox by id without first connecting. Sends a single
1154
+ * `DELETE /sandboxes/:id?async=true` and skips the metadata fetch
1155
+ * `Sandbox.connect(id).kill()` would otherwise pay. Useful for bulk
1156
+ * cleanup paths that only have the id.
1157
+ *
1158
+ * @param sandboxId - the sandbox to kill.
1159
+ * @param opts.wait - if true, block until the server finishes the
1160
+ * per-VM teardown. Default is false: server returns 202 once the
1161
+ * kill is queued.
1162
+ * @param opts.requestTimeout - per-request timeout in milliseconds.
1163
+ * @param opts.config - override the default ConnectionConfig.
1164
+ * @returns true if the kill was accepted (default) or completed
1165
+ * (wait=true); false if the server reported the sandbox was
1166
+ * already dead.
1167
+ */
1168
+ static kill(sandboxId: string, opts?: {
1169
+ wait?: boolean;
1170
+ requestTimeout?: number;
1171
+ config?: ConnectionConfig;
1172
+ }): Promise<boolean>;
1120
1173
  /**
1121
1174
  * Check if this sandbox is currently running.
1122
1175
  *
package/dist/index.js CHANGED
@@ -127,11 +127,6 @@ 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
- });
135
130
  const undici = await import("undici");
136
131
  const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
137
132
  const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 64;
@@ -2025,16 +2020,67 @@ var Sandbox = class _Sandbox {
2025
2020
  nextToken: data.next_token ?? void 0
2026
2021
  };
2027
2022
  }
2023
+ async kill(arg) {
2024
+ const opts = typeof arg === "number" ? { requestTimeout: arg } : arg ?? {};
2025
+ const wait = opts.wait === true;
2026
+ const path = wait ? `/sandboxes/${this._sandboxId}` : `/sandboxes/${this._sandboxId}?async=true`;
2027
+ const data = await this._client.delete(path, {
2028
+ timeout: opts.requestTimeout
2029
+ });
2030
+ if (!wait) {
2031
+ return data.queued ?? true;
2032
+ }
2033
+ return data.killed ?? false;
2034
+ }
2028
2035
  /**
2029
- * Kill this sandbox.
2036
+ * Kill many sandboxes in a single request. Server fans out internally
2037
+ * with bounded concurrency, eliminating per-id round-trip overhead.
2030
2038
  *
2031
- * @param requestTimeout - Optional per-request timeout in milliseconds.
2032
- * @returns True if the sandbox was killed, false if it was already dead.
2039
+ * @param ids - sandbox IDs to kill.
2040
+ * @param opts.wait - If true, wait for each VM's teardown to finish
2041
+ * before returning. Default is false (server returns 202 once the
2042
+ * request is queued).
2043
+ * @param opts.requestTimeout - Per-request timeout in milliseconds.
2044
+ * @returns Map of sandbox-id → outcome. Outcome is `{killed: true}`
2045
+ * (wait=true), `{queued: true}` (default), or `{error: string}` if
2046
+ * the server reported a per-id failure.
2033
2047
  */
2034
- async kill(requestTimeout) {
2035
- const data = await this._client.delete(`/sandboxes/${this._sandboxId}`, {
2036
- timeout: requestTimeout
2048
+ static async killMany(ids, opts) {
2049
+ if (!ids || ids.length === 0) return {};
2050
+ const config = opts?.config ?? new ConnectionConfig();
2051
+ const client = getSharedClient(config);
2052
+ const path = opts?.wait ? "/sandboxes/kill-many" : "/sandboxes/kill-many?async=true";
2053
+ const data = await client.post(path, {
2054
+ json: { sandbox_ids: ids },
2055
+ timeout: opts?.requestTimeout
2056
+ });
2057
+ return data.results ?? {};
2058
+ }
2059
+ /**
2060
+ * Kill a sandbox by id without first connecting. Sends a single
2061
+ * `DELETE /sandboxes/:id?async=true` and skips the metadata fetch
2062
+ * `Sandbox.connect(id).kill()` would otherwise pay. Useful for bulk
2063
+ * cleanup paths that only have the id.
2064
+ *
2065
+ * @param sandboxId - the sandbox to kill.
2066
+ * @param opts.wait - if true, block until the server finishes the
2067
+ * per-VM teardown. Default is false: server returns 202 once the
2068
+ * kill is queued.
2069
+ * @param opts.requestTimeout - per-request timeout in milliseconds.
2070
+ * @param opts.config - override the default ConnectionConfig.
2071
+ * @returns true if the kill was accepted (default) or completed
2072
+ * (wait=true); false if the server reported the sandbox was
2073
+ * already dead.
2074
+ */
2075
+ static async kill(sandboxId, opts) {
2076
+ const config = opts?.config ?? new ConnectionConfig();
2077
+ const client = getSharedClient(config);
2078
+ const wait = opts?.wait === true;
2079
+ const path = wait ? `/sandboxes/${sandboxId}` : `/sandboxes/${sandboxId}?async=true`;
2080
+ const data = await client.delete(path, {
2081
+ timeout: opts?.requestTimeout
2037
2082
  });
2083
+ if (!wait) return data.queued ?? true;
2038
2084
  return data.killed ?? false;
2039
2085
  }
2040
2086
  /**