@sandbox-engine/sdk 0.1.1 → 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 +14 -1
- package/dist/index.d.mts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +18 -0
- package/dist/index.mjs +18 -0
- package/package.json +1 -1
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` |
|
|
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
|
@@ -54,6 +54,18 @@ interface FileEntry {
|
|
|
54
54
|
isDirectory: boolean;
|
|
55
55
|
isFile: boolean;
|
|
56
56
|
}
|
|
57
|
+
interface FileWriteEntry {
|
|
58
|
+
path: string;
|
|
59
|
+
content: string;
|
|
60
|
+
encoding?: BufferEncoding;
|
|
61
|
+
}
|
|
62
|
+
interface FileWriteManyResult {
|
|
63
|
+
results: Array<{
|
|
64
|
+
path: string;
|
|
65
|
+
success: boolean;
|
|
66
|
+
error?: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
57
69
|
interface PortMapping {
|
|
58
70
|
containerPort: number;
|
|
59
71
|
hostPort: number;
|
|
@@ -75,6 +87,8 @@ declare class Filesystem {
|
|
|
75
87
|
read(filePath: string): Promise<string>;
|
|
76
88
|
write(filePath: string, content: string): Promise<void>;
|
|
77
89
|
list(dirPath: string): Promise<FileEntry[]>;
|
|
90
|
+
writeMany(files: FileWriteEntry[]): Promise<FileWriteManyResult>;
|
|
91
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
78
92
|
delete(filePath: string): Promise<void>;
|
|
79
93
|
}
|
|
80
94
|
|
|
@@ -98,7 +112,8 @@ interface SandboxApiResponse {
|
|
|
98
112
|
status: string;
|
|
99
113
|
template: string;
|
|
100
114
|
createdAt: string;
|
|
101
|
-
|
|
115
|
+
timeout: number;
|
|
116
|
+
expiresAt: string | null;
|
|
102
117
|
agentUrl: string;
|
|
103
118
|
ports: Record<string, number>;
|
|
104
119
|
}
|
|
@@ -122,7 +137,8 @@ declare class Sandbox {
|
|
|
122
137
|
unexpose: (containerPort: number) => Promise<void>;
|
|
123
138
|
};
|
|
124
139
|
info(): Promise<SandboxApiResponse>;
|
|
140
|
+
keepalive(timeout?: number): Promise<SandboxApiResponse>;
|
|
125
141
|
close(): Promise<void>;
|
|
126
142
|
}
|
|
127
143
|
|
|
128
|
-
export { type ExecOptions, type ExecResult, type FileEntry, Filesystem, type PortMapping, Process, type ProxyEnvResult, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
|
144
|
+
export { type ExecOptions, type ExecResult, type FileEntry, type FileWriteEntry, type FileWriteManyResult, Filesystem, type PortMapping, Process, type ProxyEnvResult, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,18 @@ interface FileEntry {
|
|
|
54
54
|
isDirectory: boolean;
|
|
55
55
|
isFile: boolean;
|
|
56
56
|
}
|
|
57
|
+
interface FileWriteEntry {
|
|
58
|
+
path: string;
|
|
59
|
+
content: string;
|
|
60
|
+
encoding?: BufferEncoding;
|
|
61
|
+
}
|
|
62
|
+
interface FileWriteManyResult {
|
|
63
|
+
results: Array<{
|
|
64
|
+
path: string;
|
|
65
|
+
success: boolean;
|
|
66
|
+
error?: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
57
69
|
interface PortMapping {
|
|
58
70
|
containerPort: number;
|
|
59
71
|
hostPort: number;
|
|
@@ -75,6 +87,8 @@ declare class Filesystem {
|
|
|
75
87
|
read(filePath: string): Promise<string>;
|
|
76
88
|
write(filePath: string, content: string): Promise<void>;
|
|
77
89
|
list(dirPath: string): Promise<FileEntry[]>;
|
|
90
|
+
writeMany(files: FileWriteEntry[]): Promise<FileWriteManyResult>;
|
|
91
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
78
92
|
delete(filePath: string): Promise<void>;
|
|
79
93
|
}
|
|
80
94
|
|
|
@@ -98,7 +112,8 @@ interface SandboxApiResponse {
|
|
|
98
112
|
status: string;
|
|
99
113
|
template: string;
|
|
100
114
|
createdAt: string;
|
|
101
|
-
|
|
115
|
+
timeout: number;
|
|
116
|
+
expiresAt: string | null;
|
|
102
117
|
agentUrl: string;
|
|
103
118
|
ports: Record<string, number>;
|
|
104
119
|
}
|
|
@@ -122,7 +137,8 @@ declare class Sandbox {
|
|
|
122
137
|
unexpose: (containerPort: number) => Promise<void>;
|
|
123
138
|
};
|
|
124
139
|
info(): Promise<SandboxApiResponse>;
|
|
140
|
+
keepalive(timeout?: number): Promise<SandboxApiResponse>;
|
|
125
141
|
close(): Promise<void>;
|
|
126
142
|
}
|
|
127
143
|
|
|
128
|
-
export { type ExecOptions, type ExecResult, type FileEntry, Filesystem, type PortMapping, Process, type ProxyEnvResult, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
|
144
|
+
export { type ExecOptions, type ExecResult, type FileEntry, type FileWriteEntry, type FileWriteManyResult, Filesystem, type PortMapping, Process, type ProxyEnvResult, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
package/dist/index.js
CHANGED
|
@@ -126,6 +126,18 @@ var Filesystem = class {
|
|
|
126
126
|
);
|
|
127
127
|
return res.files;
|
|
128
128
|
}
|
|
129
|
+
async writeMany(files) {
|
|
130
|
+
return this.client.post(
|
|
131
|
+
`/api/sandboxes/${this.sandboxId}/files/batch`,
|
|
132
|
+
{ files }
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
async rename(oldPath, newPath) {
|
|
136
|
+
await this.client.post(`/api/sandboxes/${this.sandboxId}/files/rename`, {
|
|
137
|
+
from: oldPath,
|
|
138
|
+
to: newPath
|
|
139
|
+
});
|
|
140
|
+
}
|
|
129
141
|
async delete(filePath) {
|
|
130
142
|
await this.client.delete(`/api/sandboxes/${this.sandboxId}/files`, { path: filePath });
|
|
131
143
|
}
|
|
@@ -301,6 +313,12 @@ var Sandbox = class _Sandbox {
|
|
|
301
313
|
async info() {
|
|
302
314
|
return this.client.get(`/api/sandboxes/${this.id}`);
|
|
303
315
|
}
|
|
316
|
+
async keepalive(timeout) {
|
|
317
|
+
return this.client.post(
|
|
318
|
+
`/api/sandboxes/${this.id}/keepalive`,
|
|
319
|
+
timeout !== void 0 ? { timeout } : {}
|
|
320
|
+
);
|
|
321
|
+
}
|
|
304
322
|
async close() {
|
|
305
323
|
await this.client.delete(`/api/sandboxes/${this.id}`);
|
|
306
324
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -87,6 +87,18 @@ var Filesystem = class {
|
|
|
87
87
|
);
|
|
88
88
|
return res.files;
|
|
89
89
|
}
|
|
90
|
+
async writeMany(files) {
|
|
91
|
+
return this.client.post(
|
|
92
|
+
`/api/sandboxes/${this.sandboxId}/files/batch`,
|
|
93
|
+
{ files }
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
async rename(oldPath, newPath) {
|
|
97
|
+
await this.client.post(`/api/sandboxes/${this.sandboxId}/files/rename`, {
|
|
98
|
+
from: oldPath,
|
|
99
|
+
to: newPath
|
|
100
|
+
});
|
|
101
|
+
}
|
|
90
102
|
async delete(filePath) {
|
|
91
103
|
await this.client.delete(`/api/sandboxes/${this.sandboxId}/files`, { path: filePath });
|
|
92
104
|
}
|
|
@@ -262,6 +274,12 @@ var Sandbox = class _Sandbox {
|
|
|
262
274
|
async info() {
|
|
263
275
|
return this.client.get(`/api/sandboxes/${this.id}`);
|
|
264
276
|
}
|
|
277
|
+
async keepalive(timeout) {
|
|
278
|
+
return this.client.post(
|
|
279
|
+
`/api/sandboxes/${this.id}/keepalive`,
|
|
280
|
+
timeout !== void 0 ? { timeout } : {}
|
|
281
|
+
);
|
|
282
|
+
}
|
|
265
283
|
async close() {
|
|
266
284
|
await this.client.delete(`/api/sandboxes/${this.id}`);
|
|
267
285
|
}
|
package/package.json
CHANGED