@declaw/sdk 1.1.4 → 1.1.6

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,42 @@ 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
+ }>>;
1120
1152
  /**
1121
1153
  * Check if this sandbox is currently running.
1122
1154
  *
package/dist/index.d.ts CHANGED
@@ -1113,10 +1113,42 @@ 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
+ }>>;
1120
1152
  /**
1121
1153
  * Check if this sandbox is currently running.
1122
1154
  *
package/dist/index.js CHANGED
@@ -127,14 +127,11 @@ 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");
131
+ const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
132
+ const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 64;
136
133
  return new undici.Agent({
137
- connections: 10,
134
+ connections,
138
135
  keepAliveTimeout: 3e4,
139
136
  keepAliveMaxTimeout: 6e4,
140
137
  pipelining: 1,
@@ -2023,17 +2020,41 @@ var Sandbox = class _Sandbox {
2023
2020
  nextToken: data.next_token ?? void 0
2024
2021
  };
2025
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
+ }
2026
2035
  /**
2027
- * 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.
2028
2038
  *
2029
- * @param requestTimeout - Optional per-request timeout in milliseconds.
2030
- * @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.
2031
2047
  */
2032
- async kill(requestTimeout) {
2033
- const data = await this._client.delete(`/sandboxes/${this._sandboxId}`, {
2034
- 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
2035
2056
  });
2036
- return data.killed ?? false;
2057
+ return data.results ?? {};
2037
2058
  }
2038
2059
  /**
2039
2060
  * Check if this sandbox is currently running.