@sandbox-engine/sdk 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -70,7 +70,7 @@ Creates and starts a new sandbox. Returns when the sandbox is ready.
70
70
  | `apiKey` | `string` | `$SANDBOX_API_KEY` or `dev-api-key` | API key |
71
71
  | `template` | `string` | `'base'` | Pre-built Docker image tag |
72
72
  | `dockerfile` | `string` | — | Custom Dockerfile content |
73
- | `timeout` | `number` | `300000` | TTL in ms before auto-destroy |
73
+ | `timeout` | `number` | `300000` | Timer duration in ms. Resets on every API call. Use `0` to never expire. |
74
74
 
75
75
  ---
76
76
 
@@ -146,6 +146,19 @@ const ports = await sandbox.ports.list()
146
146
 
147
147
  ---
148
148
 
149
+ ### `sandbox.keepalive(timeout?)`
150
+
151
+ Resets the expiry countdown from now. Use when the orchestrator needs to keep the sandbox alive without doing real work (e.g. an LLM reasoning between steps).
152
+
153
+ ```ts
154
+ await sandbox.keepalive() // reset with original timeout
155
+ await sandbox.keepalive(10 * 60_000) // extend to 10 min from now
156
+ ```
157
+
158
+ Any API call (`exec`, `fs`, `ports`, etc.) also resets the timer automatically.
159
+
160
+ ---
161
+
149
162
  ### `sandbox.close()`
150
163
 
151
164
  Destroys the sandbox and frees all resources. Always call this when done.
package/dist/index.d.mts CHANGED
@@ -112,7 +112,8 @@ interface SandboxApiResponse {
112
112
  status: string;
113
113
  template: string;
114
114
  createdAt: string;
115
- expiresAt: string;
115
+ timeout: number;
116
+ expiresAt: string | null;
116
117
  agentUrl: string;
117
118
  ports: Record<string, number>;
118
119
  }
@@ -136,6 +137,7 @@ declare class Sandbox {
136
137
  unexpose: (containerPort: number) => Promise<void>;
137
138
  };
138
139
  info(): Promise<SandboxApiResponse>;
140
+ keepalive(timeout?: number): Promise<SandboxApiResponse>;
139
141
  close(): Promise<void>;
140
142
  }
141
143
 
package/dist/index.d.ts CHANGED
@@ -112,7 +112,8 @@ interface SandboxApiResponse {
112
112
  status: string;
113
113
  template: string;
114
114
  createdAt: string;
115
- expiresAt: string;
115
+ timeout: number;
116
+ expiresAt: string | null;
116
117
  agentUrl: string;
117
118
  ports: Record<string, number>;
118
119
  }
@@ -136,6 +137,7 @@ declare class Sandbox {
136
137
  unexpose: (containerPort: number) => Promise<void>;
137
138
  };
138
139
  info(): Promise<SandboxApiResponse>;
140
+ keepalive(timeout?: number): Promise<SandboxApiResponse>;
139
141
  close(): Promise<void>;
140
142
  }
141
143
 
package/dist/index.js CHANGED
@@ -313,6 +313,12 @@ var Sandbox = class _Sandbox {
313
313
  async info() {
314
314
  return this.client.get(`/api/sandboxes/${this.id}`);
315
315
  }
316
+ async keepalive(timeout) {
317
+ return this.client.post(
318
+ `/api/sandboxes/${this.id}/keepalive`,
319
+ timeout !== void 0 ? { timeout } : {}
320
+ );
321
+ }
316
322
  async close() {
317
323
  await this.client.delete(`/api/sandboxes/${this.id}`);
318
324
  }
package/dist/index.mjs CHANGED
@@ -274,6 +274,12 @@ var Sandbox = class _Sandbox {
274
274
  async info() {
275
275
  return this.client.get(`/api/sandboxes/${this.id}`);
276
276
  }
277
+ async keepalive(timeout) {
278
+ return this.client.post(
279
+ `/api/sandboxes/${this.id}/keepalive`,
280
+ timeout !== void 0 ? { timeout } : {}
281
+ );
282
+ }
277
283
  async close() {
278
284
  await this.client.delete(`/api/sandboxes/${this.id}`);
279
285
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandbox-engine/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "SDK for creating and managing isolated sandbox environments",
5
5
  "keywords": ["sandbox", "docker", "code-execution", "isolated", "e2b"],
6
6
  "license": "MIT",