@agentuity/sandbox 3.0.12 → 3.1.1
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/AGENTS.md +3 -3
- package/dist/api-reference.d.ts +1221 -0
- package/dist/api-reference.d.ts.map +1 -0
- package/dist/api-reference.js +1046 -0
- package/dist/api-reference.js.map +1 -0
- package/dist/base64.d.ts +2 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/base64.js +14 -0
- package/dist/base64.js.map +1 -0
- package/dist/client.d.ts +431 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +632 -0
- package/dist/client.js.map +1 -0
- package/dist/create.d.ts +203 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/create.js +235 -0
- package/dist/create.js.map +1 -0
- package/dist/destroy.d.ts +23 -0
- package/dist/destroy.d.ts.map +1 -0
- package/dist/destroy.js +30 -0
- package/dist/destroy.js.map +1 -0
- package/dist/disk-checkpoint.d.ts +108 -0
- package/dist/disk-checkpoint.d.ts.map +1 -0
- package/dist/disk-checkpoint.js +124 -0
- package/dist/disk-checkpoint.js.map +1 -0
- package/dist/events.d.ts +56 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +54 -0
- package/dist/events.js.map +1 -0
- package/dist/execute.d.ts +99 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +138 -0
- package/dist/execute.js.map +1 -0
- package/dist/execution.d.ts +150 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +120 -0
- package/dist/execution.js.map +1 -0
- package/dist/files.d.ts +283 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +471 -0
- package/dist/files.js.map +1 -0
- package/dist/get.d.ts +288 -0
- package/dist/get.d.ts.map +1 -0
- package/dist/get.js +256 -0
- package/dist/get.js.map +1 -0
- package/dist/getStatus.d.ts +23 -0
- package/dist/getStatus.d.ts.map +1 -0
- package/dist/getStatus.js +53 -0
- package/dist/getStatus.js.map +1 -0
- package/dist/index.d.ts +42 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/job.d.ts +227 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +109 -0
- package/dist/job.js.map +1 -0
- package/dist/list.d.ts +330 -0
- package/dist/list.d.ts.map +1 -0
- package/dist/list.js +209 -0
- package/dist/list.js.map +1 -0
- package/dist/pause.d.ts +39 -0
- package/dist/pause.d.ts.map +1 -0
- package/dist/pause.js +48 -0
- package/dist/pause.js.map +1 -0
- package/dist/resolve.d.ts +75 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +76 -0
- package/dist/resolve.js.map +1 -0
- package/dist/resume.d.ts +23 -0
- package/dist/resume.d.ts.map +1 -0
- package/dist/resume.js +30 -0
- package/dist/resume.js.map +1 -0
- package/dist/run.d.ts +73 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +568 -0
- package/dist/run.js.map +1 -0
- package/dist/runtime.d.ts +94 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +82 -0
- package/dist/runtime.js.map +1 -0
- package/dist/snapshot-build.d.ts +48 -0
- package/dist/snapshot-build.d.ts.map +1 -0
- package/dist/snapshot-build.js +72 -0
- package/dist/snapshot-build.js.map +1 -0
- package/dist/snapshot.d.ts +596 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +612 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/types.d.ts +1010 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +853 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +296 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +234 -0
- package/dist/util.js.map +1 -0
- package/package.json +7 -2
- package/src/api-reference.ts +1094 -0
- package/src/base64.ts +14 -0
- package/src/client.ts +998 -0
- package/src/create.ts +273 -0
- package/src/destroy.ts +43 -0
- package/src/disk-checkpoint.ts +184 -0
- package/src/events.ts +72 -0
- package/src/execute.ts +167 -0
- package/src/execution.ts +152 -0
- package/src/files.ts +637 -0
- package/src/get.ts +291 -0
- package/src/getStatus.ts +72 -0
- package/src/index.ts +252 -18
- package/src/job.ts +161 -0
- package/src/list.ts +239 -0
- package/src/pause.ts +75 -0
- package/src/resolve.ts +96 -0
- package/src/resume.ts +41 -0
- package/src/run.ts +783 -0
- package/src/runtime.ts +106 -0
- package/src/snapshot-build.ts +94 -0
- package/src/snapshot.ts +791 -0
- package/src/types.ts +1033 -0
- package/src/util.ts +280 -0
package/src/get.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SandboxInfo,
|
|
3
|
+
SandboxRuntimeInfo,
|
|
4
|
+
SandboxSnapshotInfo,
|
|
5
|
+
SandboxStatus,
|
|
6
|
+
} from './types.ts';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { type APIClient, APIResponseSchema } from '@agentuity/api';
|
|
9
|
+
import { throwSandboxError } from './util.ts';
|
|
10
|
+
|
|
11
|
+
export const SandboxResourcesSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
memory: z.string().optional().describe('Memory limit (e.g., "512Mi", "1Gi")'),
|
|
14
|
+
cpu: z.string().optional().describe('CPU limit in millicores (e.g., "500m", "1000m")'),
|
|
15
|
+
disk: z.string().optional().describe('Disk limit (e.g., "1Gi", "10Gi")'),
|
|
16
|
+
})
|
|
17
|
+
.describe('Resource limits for the sandbox');
|
|
18
|
+
|
|
19
|
+
export const SandboxUserInfoSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
id: z.string().describe('User ID'),
|
|
22
|
+
firstName: z.string().optional().describe("User's first name"),
|
|
23
|
+
lastName: z.string().optional().describe("User's last name"),
|
|
24
|
+
})
|
|
25
|
+
.describe('User who created the sandbox');
|
|
26
|
+
|
|
27
|
+
export const SandboxAgentInfoSchema = z
|
|
28
|
+
.object({
|
|
29
|
+
id: z.string().describe('Agent ID'),
|
|
30
|
+
name: z.string().describe('Agent name'),
|
|
31
|
+
})
|
|
32
|
+
.describe('Agent associated with the sandbox');
|
|
33
|
+
|
|
34
|
+
export const SandboxProjectInfoSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
id: z.string().describe('Project ID'),
|
|
37
|
+
name: z.string().describe('Project name'),
|
|
38
|
+
})
|
|
39
|
+
.describe('Project associated with the sandbox');
|
|
40
|
+
|
|
41
|
+
export const SandboxOrgInfoSchema = z
|
|
42
|
+
.object({
|
|
43
|
+
id: z.string().describe('Organization ID'),
|
|
44
|
+
name: z.string().describe('Organization name'),
|
|
45
|
+
})
|
|
46
|
+
.describe('Organization associated with the sandbox');
|
|
47
|
+
|
|
48
|
+
export const SandboxRuntimeInfoSchema = z
|
|
49
|
+
.object({
|
|
50
|
+
id: z.string().describe('Runtime ID'),
|
|
51
|
+
name: z.string().describe('Runtime name (e.g., "bun:1")'),
|
|
52
|
+
iconUrl: z.string().optional().describe('URL for runtime icon'),
|
|
53
|
+
brandColor: z.string().optional().describe('Brand color for the runtime (hex color code)'),
|
|
54
|
+
tags: z.array(z.string()).optional().describe('Optional tags for categorization'),
|
|
55
|
+
})
|
|
56
|
+
.describe('Runtime information');
|
|
57
|
+
|
|
58
|
+
export const SandboxSnapshotUserInfoSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
id: z.string().describe('User ID'),
|
|
61
|
+
firstName: z.string().optional().describe("User's first name"),
|
|
62
|
+
lastName: z.string().optional().describe("User's last name"),
|
|
63
|
+
})
|
|
64
|
+
.describe('Snapshot user information');
|
|
65
|
+
|
|
66
|
+
export const SandboxSnapshotOrgInfoSchema = z
|
|
67
|
+
.object({
|
|
68
|
+
id: z.string().describe('Organization ID'),
|
|
69
|
+
name: z.string().describe('Organization name'),
|
|
70
|
+
slug: z.string().optional().describe('Organization slug'),
|
|
71
|
+
})
|
|
72
|
+
.describe('Snapshot organization information');
|
|
73
|
+
|
|
74
|
+
export const SandboxSnapshotInfoSchema = z
|
|
75
|
+
.union([
|
|
76
|
+
z
|
|
77
|
+
.object({
|
|
78
|
+
id: z.string().describe('Snapshot ID'),
|
|
79
|
+
name: z.string().optional().describe('Snapshot name'),
|
|
80
|
+
tag: z.string().optional().describe('Snapshot tag'),
|
|
81
|
+
fullName: z.string().optional().describe('Full name with org slug (@slug/name:tag)'),
|
|
82
|
+
public: z.literal(true).describe('Public snapshot'),
|
|
83
|
+
org: SandboxSnapshotOrgInfoSchema.describe(
|
|
84
|
+
'Organization that owns the public snapshot'
|
|
85
|
+
),
|
|
86
|
+
})
|
|
87
|
+
.describe('Public snapshot'),
|
|
88
|
+
z
|
|
89
|
+
.object({
|
|
90
|
+
id: z.string().describe('Snapshot ID'),
|
|
91
|
+
name: z.string().optional().describe('Snapshot name'),
|
|
92
|
+
tag: z.string().optional().describe('Snapshot tag'),
|
|
93
|
+
fullName: z.string().optional().describe('Full name with org slug (@slug/name:tag)'),
|
|
94
|
+
public: z.literal(false).describe('Private snapshot'),
|
|
95
|
+
user: SandboxSnapshotUserInfoSchema.describe('User who created the private snapshot'),
|
|
96
|
+
})
|
|
97
|
+
.describe('Private snapshot'),
|
|
98
|
+
])
|
|
99
|
+
.describe('Snapshot information (discriminated union)');
|
|
100
|
+
|
|
101
|
+
export const SandboxInfoDataSchema = z
|
|
102
|
+
.object({
|
|
103
|
+
sandboxId: z.string().describe('Unique identifier for the sandbox'),
|
|
104
|
+
identifier: z.string().optional().describe('Short identifier for DNS hostname'),
|
|
105
|
+
name: z.string().optional().describe('Sandbox name'),
|
|
106
|
+
description: z.string().optional().describe('Sandbox description'),
|
|
107
|
+
status: z
|
|
108
|
+
.enum([
|
|
109
|
+
'creating',
|
|
110
|
+
'idle',
|
|
111
|
+
'running',
|
|
112
|
+
'paused',
|
|
113
|
+
'stopping',
|
|
114
|
+
'suspended',
|
|
115
|
+
'terminated',
|
|
116
|
+
'failed',
|
|
117
|
+
'deleted',
|
|
118
|
+
])
|
|
119
|
+
.describe('Current status of the sandbox'),
|
|
120
|
+
mode: z.string().optional().describe('Sandbox mode (interactive or oneshot)'),
|
|
121
|
+
createdAt: z.string().describe('ISO timestamp when the sandbox was created'),
|
|
122
|
+
region: z.string().optional().describe('Region where the sandbox is running'),
|
|
123
|
+
runtime: SandboxRuntimeInfoSchema.optional().describe('Runtime information'),
|
|
124
|
+
snapshot: SandboxSnapshotInfoSchema.optional().describe('Snapshot information'),
|
|
125
|
+
executions: z.number().describe('Total number of executions in this sandbox'),
|
|
126
|
+
exitCode: z
|
|
127
|
+
.number()
|
|
128
|
+
.optional()
|
|
129
|
+
.describe('Exit code from the last execution (only for terminated/failed sandboxes)'),
|
|
130
|
+
stdoutStreamUrl: z.string().optional().describe('URL for streaming stdout output'),
|
|
131
|
+
stderrStreamUrl: z.string().optional().describe('URL for streaming stderr output'),
|
|
132
|
+
auditStreamId: z.string().optional().describe('ID of the audit event stream'),
|
|
133
|
+
auditStreamUrl: z.string().optional().describe('URL for streaming audit events'),
|
|
134
|
+
dependencies: z
|
|
135
|
+
.array(z.string())
|
|
136
|
+
.optional()
|
|
137
|
+
.describe('Apt packages installed in the sandbox'),
|
|
138
|
+
packages: z
|
|
139
|
+
.array(z.string())
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('npm/bun packages installed globally in the sandbox'),
|
|
142
|
+
metadata: z
|
|
143
|
+
.record(z.string(), z.unknown())
|
|
144
|
+
.optional()
|
|
145
|
+
.describe('User-defined metadata associated with the sandbox'),
|
|
146
|
+
resources: SandboxResourcesSchema.optional().describe('Resource limits for this sandbox'),
|
|
147
|
+
cpuTimeMs: z.number().optional().describe('Total CPU time consumed in milliseconds'),
|
|
148
|
+
memoryByteSec: z.number().optional().describe('Total memory usage in byte-seconds'),
|
|
149
|
+
networkEgressBytes: z.number().optional().describe('Total network egress in bytes'),
|
|
150
|
+
networkEnabled: z.boolean().optional().describe('Whether network access is enabled'),
|
|
151
|
+
networkPort: z.number().optional().describe('Network port exposed from the sandbox'),
|
|
152
|
+
url: z
|
|
153
|
+
.string()
|
|
154
|
+
.optional()
|
|
155
|
+
.describe('Public URL for the sandbox (only set if networkPort is configured)'),
|
|
156
|
+
user: SandboxUserInfoSchema.optional().describe('User who created the sandbox'),
|
|
157
|
+
agent: SandboxAgentInfoSchema.optional().describe('Agent associated with the sandbox'),
|
|
158
|
+
project: SandboxProjectInfoSchema.optional().describe('Project associated with the sandbox'),
|
|
159
|
+
org: SandboxOrgInfoSchema.nullish().describe('Organization associated with the sandbox'),
|
|
160
|
+
timeout: z
|
|
161
|
+
.object({
|
|
162
|
+
idle: z.string().optional().describe('Idle timeout duration (e.g., "5m", "1h").'),
|
|
163
|
+
execution: z
|
|
164
|
+
.string()
|
|
165
|
+
.optional()
|
|
166
|
+
.describe('Execution timeout duration (e.g., "30m", "2h").'),
|
|
167
|
+
paused: z
|
|
168
|
+
.string()
|
|
169
|
+
.optional()
|
|
170
|
+
.describe('Paused timeout duration (e.g., "24h", "0s" for infinite).'),
|
|
171
|
+
})
|
|
172
|
+
.optional()
|
|
173
|
+
.describe('Timeout configuration for the sandbox.'),
|
|
174
|
+
command: z
|
|
175
|
+
.object({
|
|
176
|
+
exec: z.array(z.string()).describe('Command and arguments to execute.'),
|
|
177
|
+
mode: z
|
|
178
|
+
.enum(['oneshot', 'interactive'])
|
|
179
|
+
.optional()
|
|
180
|
+
.describe('Execution mode for the command.'),
|
|
181
|
+
})
|
|
182
|
+
.optional()
|
|
183
|
+
.describe('Command configuration for the sandbox.'),
|
|
184
|
+
})
|
|
185
|
+
.describe('Detailed information about a sandbox');
|
|
186
|
+
|
|
187
|
+
export const SandboxGetResponseSchema = APIResponseSchema(SandboxInfoDataSchema);
|
|
188
|
+
|
|
189
|
+
export const SandboxGetParamsSchema = z.object({
|
|
190
|
+
sandboxId: z.string().describe('Sandbox ID to fetch'),
|
|
191
|
+
orgId: z.string().optional().describe('Optional org id for CLI auth context'),
|
|
192
|
+
includeDeleted: z
|
|
193
|
+
.boolean()
|
|
194
|
+
.optional()
|
|
195
|
+
.describe('Whether deleted sandboxes should be included in lookup'),
|
|
196
|
+
waitForStatus: z
|
|
197
|
+
.union([z.string(), z.array(z.string())])
|
|
198
|
+
.optional()
|
|
199
|
+
.describe('Optional desired status or statuses to wait for before responding'),
|
|
200
|
+
waitMs: z
|
|
201
|
+
.number()
|
|
202
|
+
.int()
|
|
203
|
+
.nonnegative()
|
|
204
|
+
.optional()
|
|
205
|
+
.describe('Maximum time in milliseconds to wait for the desired status'),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
export type SandboxGetParams = z.infer<typeof SandboxGetParamsSchema>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Retrieves information about a specific sandbox.
|
|
212
|
+
*
|
|
213
|
+
* @param client - The API client to use for the request
|
|
214
|
+
* @param params - Parameters including the sandbox ID
|
|
215
|
+
* @returns Sandbox information including status, creation time, and execution count
|
|
216
|
+
* @throws {SandboxResponseError} If the sandbox is not found or request fails
|
|
217
|
+
*/
|
|
218
|
+
export async function sandboxGet(
|
|
219
|
+
client: APIClient,
|
|
220
|
+
params: SandboxGetParams
|
|
221
|
+
): Promise<SandboxInfo> {
|
|
222
|
+
const { sandboxId, orgId, includeDeleted, waitForStatus, waitMs } = params;
|
|
223
|
+
const queryParams = new URLSearchParams();
|
|
224
|
+
if (orgId) {
|
|
225
|
+
queryParams.set('orgId', orgId);
|
|
226
|
+
}
|
|
227
|
+
if (includeDeleted) {
|
|
228
|
+
queryParams.set('includeDeleted', 'true');
|
|
229
|
+
}
|
|
230
|
+
if (waitForStatus) {
|
|
231
|
+
queryParams.set(
|
|
232
|
+
'waitForStatus',
|
|
233
|
+
Array.isArray(waitForStatus) ? waitForStatus.join(',') : waitForStatus
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
if (waitMs != null) {
|
|
237
|
+
queryParams.set('waitMs', String(waitMs));
|
|
238
|
+
}
|
|
239
|
+
const queryString = queryParams.toString();
|
|
240
|
+
const url = `/sandbox/${encodeURIComponent(sandboxId)}${queryString ? `?${queryString}` : ''}`;
|
|
241
|
+
|
|
242
|
+
const resp = await client.get<z.infer<typeof SandboxGetResponseSchema>>(
|
|
243
|
+
url,
|
|
244
|
+
SandboxGetResponseSchema
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
if (resp.success) {
|
|
248
|
+
// Newly created sandboxes can be served from the server's pending cache before
|
|
249
|
+
// the backing row and related org hydration are fully available. That response
|
|
250
|
+
// serializes `org: null`, so normalize it to a placeholder object instead of
|
|
251
|
+
// failing response validation for an otherwise valid sandbox status poll.
|
|
252
|
+
const org = resp.data.org ?? { id: orgId ?? '', name: '' };
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
sandboxId: resp.data.sandboxId,
|
|
256
|
+
identifier: resp.data.identifier,
|
|
257
|
+
name: resp.data.name,
|
|
258
|
+
description: resp.data.description,
|
|
259
|
+
status: resp.data.status as SandboxStatus,
|
|
260
|
+
mode: resp.data.mode,
|
|
261
|
+
createdAt: resp.data.createdAt,
|
|
262
|
+
region: resp.data.region,
|
|
263
|
+
runtime: resp.data.runtime as SandboxRuntimeInfo | undefined,
|
|
264
|
+
snapshot: resp.data.snapshot as SandboxSnapshotInfo | undefined,
|
|
265
|
+
executions: resp.data.executions,
|
|
266
|
+
exitCode: resp.data.exitCode,
|
|
267
|
+
stdoutStreamUrl: resp.data.stdoutStreamUrl,
|
|
268
|
+
stderrStreamUrl: resp.data.stderrStreamUrl,
|
|
269
|
+
auditStreamId: resp.data.auditStreamId,
|
|
270
|
+
auditStreamUrl: resp.data.auditStreamUrl,
|
|
271
|
+
dependencies: resp.data.dependencies,
|
|
272
|
+
packages: resp.data.packages,
|
|
273
|
+
metadata: resp.data.metadata as Record<string, unknown> | undefined,
|
|
274
|
+
resources: resp.data.resources,
|
|
275
|
+
cpuTimeMs: resp.data.cpuTimeMs,
|
|
276
|
+
memoryByteSec: resp.data.memoryByteSec,
|
|
277
|
+
networkEgressBytes: resp.data.networkEgressBytes,
|
|
278
|
+
networkEnabled: resp.data.networkEnabled,
|
|
279
|
+
networkPort: resp.data.networkPort,
|
|
280
|
+
url: resp.data.url,
|
|
281
|
+
user: resp.data.user,
|
|
282
|
+
agent: resp.data.agent,
|
|
283
|
+
project: resp.data.project,
|
|
284
|
+
org,
|
|
285
|
+
timeout: resp.data.timeout,
|
|
286
|
+
command: resp.data.command,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
throwSandboxError(resp, { sandboxId });
|
|
291
|
+
}
|
package/src/getStatus.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type APIClient, APIResponseSchema } from '@agentuity/api';
|
|
3
|
+
import { throwSandboxError } from './util.ts';
|
|
4
|
+
|
|
5
|
+
const SandboxStatusDataSchema = z.object({
|
|
6
|
+
sandboxId: z.string().describe('Unique identifier for the sandbox.'),
|
|
7
|
+
status: z.string().describe('Current status of the sandbox.'),
|
|
8
|
+
exitCode: z.number().optional().describe('Exit code from the last execution, if terminated.'),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const SandboxStatusResponseSchema = APIResponseSchema(SandboxStatusDataSchema);
|
|
12
|
+
|
|
13
|
+
export const SandboxGetStatusParamsSchema = z.object({
|
|
14
|
+
sandboxId: z.string().describe('Sandbox ID to retrieve status for'),
|
|
15
|
+
orgId: z.string().optional().describe('Optional org id for CLI auth context'),
|
|
16
|
+
waitForStatus: z
|
|
17
|
+
.union([z.string(), z.array(z.string())])
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Optional desired status or statuses to wait for before responding'),
|
|
20
|
+
waitMs: z
|
|
21
|
+
.number()
|
|
22
|
+
.int()
|
|
23
|
+
.nonnegative()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Maximum time in milliseconds to wait for the desired status'),
|
|
26
|
+
signal: z.custom<AbortSignal>().optional().describe('abort signal for cancellation'),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type SandboxGetStatusParams = z.infer<typeof SandboxGetStatusParamsSchema>;
|
|
30
|
+
export type SandboxStatusResult = z.infer<typeof SandboxStatusDataSchema>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves lightweight sandbox status (status + exitCode only).
|
|
34
|
+
* Optimized for the sandbox run flow — backed by Redis for ~1ms response time.
|
|
35
|
+
*/
|
|
36
|
+
export async function sandboxGetStatus(
|
|
37
|
+
client: APIClient,
|
|
38
|
+
params: SandboxGetStatusParams
|
|
39
|
+
): Promise<SandboxStatusResult> {
|
|
40
|
+
const { sandboxId, orgId, waitForStatus, waitMs, signal } = params;
|
|
41
|
+
const queryParams = new URLSearchParams();
|
|
42
|
+
if (orgId) {
|
|
43
|
+
queryParams.set('orgId', orgId);
|
|
44
|
+
}
|
|
45
|
+
if (waitForStatus) {
|
|
46
|
+
queryParams.set(
|
|
47
|
+
'waitForStatus',
|
|
48
|
+
Array.isArray(waitForStatus) ? waitForStatus.join(',') : waitForStatus
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (waitMs != null) {
|
|
52
|
+
queryParams.set('waitMs', String(waitMs));
|
|
53
|
+
}
|
|
54
|
+
const queryString = queryParams.toString();
|
|
55
|
+
const url = `/sandbox/status/${sandboxId}${queryString ? `?${queryString}` : ''}`;
|
|
56
|
+
|
|
57
|
+
const resp = await client.get<z.infer<typeof SandboxStatusResponseSchema>>(
|
|
58
|
+
url,
|
|
59
|
+
SandboxStatusResponseSchema,
|
|
60
|
+
signal
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (resp.success) {
|
|
64
|
+
return {
|
|
65
|
+
sandboxId: resp.data.sandboxId,
|
|
66
|
+
status: resp.data.status,
|
|
67
|
+
exitCode: resp.data.exitCode,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
throwSandboxError(resp, { sandboxId });
|
|
72
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,22 +1,256 @@
|
|
|
1
|
+
export { base64Encode } from './base64.ts';
|
|
2
|
+
export * from './types.ts';
|
|
3
|
+
export type {
|
|
4
|
+
ExecuteOptions,
|
|
5
|
+
SandboxClientOptions,
|
|
6
|
+
SandboxClientRunIO,
|
|
7
|
+
SandboxInstance,
|
|
8
|
+
JobInstance,
|
|
9
|
+
DiskCheckpointInstance,
|
|
10
|
+
} from './client.ts';
|
|
1
11
|
export {
|
|
12
|
+
ExecuteOptionsSchema as SandboxClientExecuteOptionsSchema,
|
|
2
13
|
SandboxClient,
|
|
3
|
-
type SandboxClientOptions,
|
|
4
|
-
type SandboxInstance,
|
|
5
|
-
type ExecuteOptions,
|
|
6
14
|
SandboxClientOptionsSchema,
|
|
7
|
-
SandboxClientExecuteOptionsSchema,
|
|
8
15
|
SandboxClientRunIOSchema,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
} from './client.ts';
|
|
17
|
+
export type { SandboxCreateParams, SandboxCreateResponse } from './create.ts';
|
|
18
|
+
export {
|
|
19
|
+
SandboxCreateDataSchema,
|
|
20
|
+
SandboxCreateParamsSchema,
|
|
21
|
+
SandboxCreateRequestSchema,
|
|
22
|
+
SandboxCreateResponseSchema,
|
|
23
|
+
sandboxCreate,
|
|
24
|
+
} from './create.ts';
|
|
25
|
+
export type { SandboxDestroyParams } from './destroy.ts';
|
|
26
|
+
export { DestroyResponseSchema, SandboxDestroyParamsSchema, sandboxDestroy } from './destroy.ts';
|
|
27
|
+
export type {
|
|
28
|
+
DiskCheckpointInfo,
|
|
29
|
+
DiskCheckpointCreateParams,
|
|
30
|
+
DiskCheckpointListParams,
|
|
31
|
+
DiskCheckpointRestoreParams,
|
|
32
|
+
DiskCheckpointDeleteParams,
|
|
33
|
+
} from './disk-checkpoint.ts';
|
|
34
|
+
export {
|
|
35
|
+
DiskCheckpointInfoSchema,
|
|
36
|
+
CreateDiskCheckpointResponseSchema,
|
|
37
|
+
DiskCheckpointCreateParamsSchema,
|
|
38
|
+
DiskCheckpointDeleteParamsSchema,
|
|
39
|
+
DiskCheckpointListParamsSchema,
|
|
40
|
+
DiskCheckpointRestoreParamsSchema,
|
|
41
|
+
ListDiskCheckpointsResponseSchema,
|
|
42
|
+
RestoreDiskCheckpointResponseSchema,
|
|
43
|
+
DeleteDiskCheckpointResponseSchema,
|
|
44
|
+
diskCheckpointCreate,
|
|
45
|
+
diskCheckpointList,
|
|
46
|
+
diskCheckpointRestore,
|
|
47
|
+
diskCheckpointDelete,
|
|
48
|
+
} from './disk-checkpoint.ts';
|
|
49
|
+
export type { SandboxPauseParams, SandboxPauseResult } from './pause.ts';
|
|
50
|
+
export { PauseResponseSchema, SandboxPauseParamsSchema, sandboxPause } from './pause.ts';
|
|
51
|
+
export type { SandboxResumeParams } from './resume.ts';
|
|
52
|
+
export { ResumeResponseSchema, SandboxResumeParamsSchema, sandboxResume } from './resume.ts';
|
|
53
|
+
export type { SandboxExecuteParams } from './execute.ts';
|
|
54
|
+
export {
|
|
55
|
+
ExecuteDataSchema,
|
|
56
|
+
SandboxExecuteParamsSchema,
|
|
57
|
+
ExecuteRequestSchema,
|
|
58
|
+
ExecuteResponseSchema,
|
|
59
|
+
sandboxExecute,
|
|
60
|
+
} from './execute.ts';
|
|
61
|
+
export type {
|
|
62
|
+
ExecutionGetParams,
|
|
63
|
+
ExecutionInfo,
|
|
64
|
+
ExecutionListParams,
|
|
65
|
+
ExecutionListResponse,
|
|
66
|
+
} from './execution.ts';
|
|
67
|
+
export {
|
|
68
|
+
ExecutionGetParamsSchema,
|
|
69
|
+
ExecutionGetResponseSchema,
|
|
70
|
+
ExecutionInfoSchema,
|
|
71
|
+
ExecutionListParamsSchema,
|
|
72
|
+
ExecutionListDataSchema,
|
|
73
|
+
ExecutionListResponseSchema,
|
|
74
|
+
executionGet,
|
|
75
|
+
executionList,
|
|
76
|
+
} from './execution.ts';
|
|
77
|
+
export type {
|
|
78
|
+
JobCreateParams,
|
|
79
|
+
JobGetParams,
|
|
80
|
+
JobListParams,
|
|
81
|
+
JobListResponse,
|
|
82
|
+
JobStopParams,
|
|
83
|
+
} from './job.ts';
|
|
84
|
+
export {
|
|
85
|
+
JobCreateParamsSchema,
|
|
86
|
+
JobGetParamsSchema,
|
|
87
|
+
JobListParamsSchema,
|
|
88
|
+
JobListResponseSchema,
|
|
89
|
+
JobStopParamsSchema,
|
|
90
|
+
jobCreate,
|
|
91
|
+
jobGet,
|
|
92
|
+
jobList,
|
|
93
|
+
jobStop,
|
|
94
|
+
} from './job.ts';
|
|
95
|
+
export type {
|
|
96
|
+
SandboxEventInfo,
|
|
97
|
+
SandboxEventListParams,
|
|
98
|
+
SandboxEventListResponse,
|
|
99
|
+
} from './events.ts';
|
|
100
|
+
export {
|
|
101
|
+
SandboxEventInfoSchema,
|
|
102
|
+
SandboxEventListDataSchema,
|
|
103
|
+
SandboxEventListParamsSchema,
|
|
104
|
+
SandboxEventListResponseSchema,
|
|
105
|
+
sandboxEventList,
|
|
106
|
+
} from './events.ts';
|
|
107
|
+
export type {
|
|
108
|
+
ArchiveFormat,
|
|
109
|
+
DownloadArchiveParams,
|
|
110
|
+
FileInfo,
|
|
111
|
+
ListFilesParams,
|
|
112
|
+
ListFilesResult,
|
|
113
|
+
MkDirParams,
|
|
114
|
+
ReadFileParams,
|
|
115
|
+
RmDirParams,
|
|
116
|
+
RmFileParams,
|
|
117
|
+
SetEnvParams,
|
|
118
|
+
SetEnvResult,
|
|
119
|
+
UploadArchiveParams,
|
|
120
|
+
WriteFilesParams,
|
|
121
|
+
WriteFilesResult,
|
|
122
|
+
} from './files.ts';
|
|
123
|
+
export {
|
|
124
|
+
DownloadArchiveParamsSchema,
|
|
125
|
+
FileInfoSchema,
|
|
126
|
+
ListFilesDataSchema,
|
|
127
|
+
ListFilesParamsSchema,
|
|
128
|
+
ListFilesResponseSchema,
|
|
129
|
+
MkDirParamsSchema,
|
|
130
|
+
MkDirRequestSchema,
|
|
131
|
+
MkDirResponseSchema,
|
|
132
|
+
ReadFileParamsSchema,
|
|
133
|
+
RmDirParamsSchema,
|
|
134
|
+
RmDirRequestSchema,
|
|
135
|
+
RmDirResponseSchema,
|
|
136
|
+
RmFileParamsSchema,
|
|
137
|
+
RmFileRequestSchema,
|
|
138
|
+
RmFileResponseSchema,
|
|
139
|
+
SetEnvDataSchema,
|
|
140
|
+
SetEnvParamsSchema,
|
|
141
|
+
SetEnvRequestSchema,
|
|
142
|
+
SetEnvResponseSchema,
|
|
143
|
+
sandboxDownloadArchive,
|
|
144
|
+
sandboxListFiles,
|
|
145
|
+
sandboxMkDir,
|
|
146
|
+
sandboxReadFile,
|
|
147
|
+
sandboxRmDir,
|
|
148
|
+
sandboxRmFile,
|
|
149
|
+
sandboxSetEnv,
|
|
150
|
+
sandboxUploadArchive,
|
|
151
|
+
sandboxWriteFiles,
|
|
152
|
+
UploadArchiveParamsSchema,
|
|
153
|
+
UploadArchiveResponseSchema,
|
|
154
|
+
WriteFilesDataSchema,
|
|
155
|
+
WriteFilesParamsSchema,
|
|
156
|
+
WriteFilesRequestSchema,
|
|
157
|
+
WriteFilesResponseSchema,
|
|
158
|
+
} from './files.ts';
|
|
159
|
+
export type { SandboxGetParams } from './get.ts';
|
|
160
|
+
export {
|
|
161
|
+
SandboxGetParamsSchema,
|
|
162
|
+
SandboxGetResponseSchema,
|
|
163
|
+
SandboxInfoDataSchema,
|
|
164
|
+
sandboxGet,
|
|
165
|
+
} from './get.ts';
|
|
166
|
+
export type { SandboxGetStatusParams, SandboxStatusResult } from './getStatus.ts';
|
|
167
|
+
export { SandboxGetStatusParamsSchema, sandboxGetStatus } from './getStatus.ts';
|
|
168
|
+
export type { SandboxListParams } from './list.ts';
|
|
169
|
+
export {
|
|
170
|
+
ListSandboxesDataSchema,
|
|
171
|
+
ListSandboxesResponseSchema,
|
|
172
|
+
SandboxListParamsSchema,
|
|
173
|
+
sandboxList,
|
|
174
|
+
} from './list.ts';
|
|
175
|
+
export type { ResolvedSandboxInfo } from './resolve.ts';
|
|
176
|
+
export {
|
|
177
|
+
SandboxResolveDataSchema,
|
|
178
|
+
SandboxResolveError,
|
|
179
|
+
SandboxResolveResponseSchema,
|
|
180
|
+
sandboxResolve,
|
|
181
|
+
} from './resolve.ts';
|
|
182
|
+
export type { SandboxRunParams } from './run.ts';
|
|
183
|
+
export { SandboxRunParamsSchema, sandboxRun } from './run.ts';
|
|
184
|
+
export type { RuntimeListParams } from './runtime.ts';
|
|
185
|
+
export {
|
|
186
|
+
ListRuntimesDataSchema,
|
|
187
|
+
ListRuntimesResponseSchema,
|
|
188
|
+
RuntimeListParamsSchema,
|
|
189
|
+
RuntimeInfoSchema,
|
|
190
|
+
RuntimeRequirementsSchema,
|
|
191
|
+
runtimeList,
|
|
192
|
+
} from './runtime.ts';
|
|
193
|
+
export type {
|
|
194
|
+
SnapshotBuildFinalizeParams,
|
|
195
|
+
SnapshotBuildGitInfo,
|
|
196
|
+
SnapshotBuildInitParams,
|
|
197
|
+
SnapshotBuildInitResponse,
|
|
198
|
+
SnapshotCreateParams,
|
|
199
|
+
SnapshotDeleteParams,
|
|
200
|
+
SnapshotFileInfo,
|
|
201
|
+
SnapshotGetParams,
|
|
202
|
+
SnapshotInfo,
|
|
203
|
+
SnapshotLineageEntry,
|
|
204
|
+
SnapshotLineageParams,
|
|
205
|
+
SnapshotLineageResponse,
|
|
206
|
+
SnapshotListParams,
|
|
207
|
+
SnapshotListResponse,
|
|
208
|
+
SnapshotPublicGetParams,
|
|
209
|
+
SnapshotPublicListParams,
|
|
210
|
+
SnapshotTagParams,
|
|
211
|
+
SnapshotUploadParams,
|
|
212
|
+
SnapshotUploadResponse,
|
|
213
|
+
} from './snapshot.ts';
|
|
214
|
+
export {
|
|
215
|
+
SnapshotBuildGitInfoSchema,
|
|
216
|
+
SnapshotBuildInitAPIResponseSchema,
|
|
217
|
+
SnapshotBuildInitResponseSchema,
|
|
218
|
+
SnapshotCreateResponseSchema,
|
|
219
|
+
SnapshotDeleteResponseSchema,
|
|
220
|
+
SnapshotGetResponseSchema,
|
|
221
|
+
SnapshotLineageDataSchema,
|
|
222
|
+
SnapshotLineageEntrySchema,
|
|
223
|
+
SnapshotLineageResponseSchema,
|
|
224
|
+
SnapshotListDataSchema,
|
|
225
|
+
SnapshotListResponseSchema,
|
|
226
|
+
SnapshotUploadResponseSchema,
|
|
227
|
+
SnapshotUploadParamsSchema,
|
|
228
|
+
snapshotBuildFinalize,
|
|
229
|
+
snapshotBuildInit,
|
|
230
|
+
snapshotCreate,
|
|
231
|
+
snapshotDelete,
|
|
232
|
+
snapshotGet,
|
|
233
|
+
snapshotLineage,
|
|
234
|
+
snapshotList,
|
|
235
|
+
snapshotPublicGet,
|
|
236
|
+
snapshotPublicList,
|
|
237
|
+
snapshotTag,
|
|
238
|
+
snapshotUpload,
|
|
239
|
+
} from './snapshot.ts';
|
|
240
|
+
export type { SnapshotBuildFile } from './snapshot-build.ts';
|
|
241
|
+
export { SnapshotBuildFileSchema, NPM_PACKAGE_NAME_PATTERN } from './snapshot-build.ts';
|
|
242
|
+
export type { SandboxErrorCode, SandboxErrorContext } from './util.ts';
|
|
243
|
+
export {
|
|
244
|
+
ExecutionCancelledError,
|
|
245
|
+
ExecutionNotFoundError,
|
|
246
|
+
SandboxErrorCodeSchema,
|
|
247
|
+
SandboxErrorContextSchema,
|
|
248
|
+
ExecutionTimeoutError,
|
|
249
|
+
SandboxBusyError,
|
|
250
|
+
SandboxNotFoundError,
|
|
251
|
+
SandboxResponseError,
|
|
252
|
+
SandboxTerminatedError,
|
|
253
|
+
SnapshotNotFoundError,
|
|
254
|
+
throwSandboxError,
|
|
255
|
+
writeAndDrain,
|
|
256
|
+
} from './util.ts';
|