@agentuity/server 0.1.8 → 0.1.10
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/api/api.d.ts +1 -1
- package/dist/api/api.d.ts.map +1 -1
- package/dist/api/api.js +7 -3
- package/dist/api/api.js.map +1 -1
- package/dist/api/org/resources.d.ts +10 -5
- package/dist/api/org/resources.d.ts.map +1 -1
- package/dist/api/org/resources.js +14 -6
- package/dist/api/org/resources.js.map +1 -1
- package/dist/api/project/deployment.d.ts +14 -0
- package/dist/api/project/deployment.d.ts.map +1 -1
- package/dist/api/project/deployment.js +20 -0
- package/dist/api/project/deployment.js.map +1 -1
- package/dist/api/sandbox/create.d.ts.map +1 -1
- package/dist/api/sandbox/create.js +16 -0
- package/dist/api/sandbox/create.js.map +1 -1
- package/dist/api/sandbox/execution.d.ts +1 -0
- package/dist/api/sandbox/execution.d.ts.map +1 -1
- package/dist/api/sandbox/execution.js +6 -0
- package/dist/api/sandbox/execution.js.map +1 -1
- package/dist/api/sandbox/get.d.ts +1 -0
- package/dist/api/sandbox/get.d.ts.map +1 -1
- package/dist/api/sandbox/get.js +58 -2
- package/dist/api/sandbox/get.js.map +1 -1
- package/dist/api/sandbox/index.d.ts +2 -0
- package/dist/api/sandbox/index.d.ts.map +1 -1
- package/dist/api/sandbox/index.js +1 -0
- package/dist/api/sandbox/index.js.map +1 -1
- package/dist/api/sandbox/list.d.ts +1 -0
- package/dist/api/sandbox/list.d.ts.map +1 -1
- package/dist/api/sandbox/list.js +26 -1
- package/dist/api/sandbox/list.js.map +1 -1
- package/dist/api/sandbox/runtime.d.ts +15 -0
- package/dist/api/sandbox/runtime.d.ts.map +1 -0
- package/dist/api/sandbox/runtime.js +58 -0
- package/dist/api/sandbox/runtime.js.map +1 -0
- package/dist/api/sandbox/snapshot.d.ts +6 -1
- package/dist/api/sandbox/snapshot.d.ts.map +1 -1
- package/dist/api/sandbox/snapshot.js +22 -3
- package/dist/api/sandbox/snapshot.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/util/resources.d.ts +47 -0
- package/dist/util/resources.d.ts.map +1 -0
- package/dist/util/resources.js +171 -0
- package/dist/util/resources.js.map +1 -0
- package/package.json +4 -4
- package/src/api/api.ts +17 -3
- package/src/api/org/resources.ts +21 -6
- package/src/api/project/deployment.ts +28 -0
- package/src/api/sandbox/create.ts +16 -0
- package/src/api/sandbox/execution.ts +7 -0
- package/src/api/sandbox/get.ts +63 -2
- package/src/api/sandbox/index.ts +2 -0
- package/src/api/sandbox/list.ts +28 -1
- package/src/api/sandbox/runtime.ts +79 -0
- package/src/api/sandbox/snapshot.ts +30 -4
- package/src/index.ts +10 -0
- package/src/util/resources.ts +213 -0
package/src/api/api.ts
CHANGED
|
@@ -208,7 +208,8 @@ export class APIClient {
|
|
|
208
208
|
responseSchema?: z.ZodType<TResponse>,
|
|
209
209
|
body?: TBody,
|
|
210
210
|
bodySchema?: z.ZodType<TBody>,
|
|
211
|
-
signal?: AbortSignal
|
|
211
|
+
signal?: AbortSignal,
|
|
212
|
+
extraHeaders?: Record<string, string>
|
|
212
213
|
): Promise<TResponse> {
|
|
213
214
|
// Validate request body if schema provided
|
|
214
215
|
if (body !== undefined && bodySchema) {
|
|
@@ -221,7 +222,14 @@ export class APIClient {
|
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
|
|
224
|
-
const response = await this.#makeRequest(
|
|
225
|
+
const response = await this.#makeRequest(
|
|
226
|
+
method,
|
|
227
|
+
endpoint,
|
|
228
|
+
body,
|
|
229
|
+
signal,
|
|
230
|
+
undefined,
|
|
231
|
+
extraHeaders
|
|
232
|
+
);
|
|
225
233
|
|
|
226
234
|
// Handle empty responses (204 or zero-length body)
|
|
227
235
|
let data: unknown;
|
|
@@ -263,7 +271,8 @@ export class APIClient {
|
|
|
263
271
|
endpoint: string,
|
|
264
272
|
body?: unknown,
|
|
265
273
|
signal?: AbortSignal,
|
|
266
|
-
contentType?: string
|
|
274
|
+
contentType?: string,
|
|
275
|
+
extraHeaders?: Record<string, string>
|
|
267
276
|
): Promise<Response> {
|
|
268
277
|
this.#logger.trace('sending %s to %s%s', method, this.#baseUrl, endpoint);
|
|
269
278
|
|
|
@@ -294,6 +303,11 @@ export class APIClient {
|
|
|
294
303
|
);
|
|
295
304
|
}
|
|
296
305
|
|
|
306
|
+
// Apply per-request extra headers (e.g., x-agentuity-orgid for CLI auth)
|
|
307
|
+
if (extraHeaders) {
|
|
308
|
+
Object.keys(extraHeaders).forEach((key) => (headers[key] = extraHeaders[key]));
|
|
309
|
+
}
|
|
310
|
+
|
|
297
311
|
const canRetry = !(body instanceof ReadableStream); // we cannot safely retry a ReadableStream as body
|
|
298
312
|
|
|
299
313
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
package/src/api/org/resources.ts
CHANGED
|
@@ -34,27 +34,32 @@ export type OrgDBResource = z.infer<typeof OrgDBResource>;
|
|
|
34
34
|
export interface ListOrgResourcesOptions {
|
|
35
35
|
/** Filter by resource type (default: "all") */
|
|
36
36
|
type?: 'all' | 's3' | 'db';
|
|
37
|
+
/** Organization ID (required for CLI auth, extracted from context for SDK auth) */
|
|
38
|
+
orgId?: string;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* List all resources for the authenticated organization (across all regions)
|
|
41
|
-
* Extracts orgId from authentication context (API key, SDK, or CLI token)
|
|
42
43
|
*
|
|
43
44
|
* @param client - Catalyst API client (must be authenticated)
|
|
44
|
-
* @param options - Optional filters
|
|
45
|
+
* @param options - Optional filters including orgId for CLI auth
|
|
45
46
|
* @returns List of S3 and DB resources with their cloud regions
|
|
46
47
|
*
|
|
47
48
|
* @example
|
|
48
|
-
* // Get all resources
|
|
49
|
+
* // Get all resources (SDK auth - orgId from context)
|
|
49
50
|
* const all = await listOrgResources(client);
|
|
50
51
|
*
|
|
51
52
|
* @example
|
|
53
|
+
* // Get all resources (CLI auth - orgId required)
|
|
54
|
+
* const all = await listOrgResources(client, { orgId: 'org_123' });
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
52
57
|
* // Get only S3 buckets
|
|
53
|
-
* const s3Only = await listOrgResources(client, { type: 's3' });
|
|
58
|
+
* const s3Only = await listOrgResources(client, { type: 's3', orgId: 'org_123' });
|
|
54
59
|
*
|
|
55
60
|
* @example
|
|
56
61
|
* // Get only DBs
|
|
57
|
-
* const dbsOnly = await listOrgResources(client, { type: 'db' });
|
|
62
|
+
* const dbsOnly = await listOrgResources(client, { type: 'db', orgId: 'org_123' });
|
|
58
63
|
*/
|
|
59
64
|
export async function listOrgResources(
|
|
60
65
|
client: APIClient,
|
|
@@ -68,10 +73,20 @@ export async function listOrgResources(
|
|
|
68
73
|
const query = params.toString();
|
|
69
74
|
const url = `/resource/2025-11-16${query ? `?${query}` : ''}`;
|
|
70
75
|
|
|
76
|
+
// Build headers - include orgId for CLI auth
|
|
77
|
+
const headers: Record<string, string> = {};
|
|
78
|
+
if (options?.orgId) {
|
|
79
|
+
headers['x-agentuity-orgid'] = options.orgId;
|
|
80
|
+
}
|
|
81
|
+
|
|
71
82
|
const resp = await client.request<OrgResourceListResponse>(
|
|
72
83
|
'GET',
|
|
73
84
|
url,
|
|
74
|
-
OrgResourceListResponseSchema
|
|
85
|
+
OrgResourceListResponseSchema,
|
|
86
|
+
undefined,
|
|
87
|
+
undefined,
|
|
88
|
+
undefined,
|
|
89
|
+
headers
|
|
75
90
|
);
|
|
76
91
|
if (resp.success) {
|
|
77
92
|
return resp.data;
|
|
@@ -90,6 +90,34 @@ export async function projectDeploymentGet(
|
|
|
90
90
|
throw new ProjectResponseError({ message: resp.message });
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
const DeploymentLookupSchema = z.object({
|
|
94
|
+
id: z.string(),
|
|
95
|
+
projectId: z.string(),
|
|
96
|
+
orgId: z.string(),
|
|
97
|
+
cloudRegion: z.string().nullable().optional(),
|
|
98
|
+
state: z.string().nullable().optional(),
|
|
99
|
+
active: z.boolean(),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const DeploymentLookupResponseSchema = APIResponseSchema(DeploymentLookupSchema);
|
|
103
|
+
|
|
104
|
+
export type DeploymentLookup = z.infer<typeof DeploymentLookupSchema>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Get deployment info by ID only (without requiring project ID).
|
|
108
|
+
* Useful for looking up region/project info for a deployment.
|
|
109
|
+
*/
|
|
110
|
+
export async function deploymentGet(
|
|
111
|
+
client: APIClient,
|
|
112
|
+
deploymentId: string
|
|
113
|
+
): Promise<DeploymentLookup> {
|
|
114
|
+
const resp = await client.get(`/cli/deployment/${deploymentId}`, DeploymentLookupResponseSchema);
|
|
115
|
+
if (resp.success) {
|
|
116
|
+
return resp.data;
|
|
117
|
+
}
|
|
118
|
+
throw new ProjectResponseError({ message: resp.message });
|
|
119
|
+
}
|
|
120
|
+
|
|
93
121
|
export async function projectDeploymentDelete(
|
|
94
122
|
client: APIClient,
|
|
95
123
|
projectId: string,
|
|
@@ -5,6 +5,10 @@ import type { SandboxCreateOptions, SandboxStatus } from '@agentuity/core';
|
|
|
5
5
|
|
|
6
6
|
const SandboxCreateRequestSchema = z
|
|
7
7
|
.object({
|
|
8
|
+
runtime: z.string().optional().describe('Runtime name (e.g., "bun:1", "python:3.14")'),
|
|
9
|
+
runtimeId: z.string().optional().describe('Runtime ID (e.g., "srt_xxx")'),
|
|
10
|
+
name: z.string().optional().describe('Optional sandbox name'),
|
|
11
|
+
description: z.string().optional().describe('Optional sandbox description'),
|
|
8
12
|
resources: z
|
|
9
13
|
.object({
|
|
10
14
|
memory: z.string().optional().describe('Memory limit (e.g., "512Mi", "1Gi")'),
|
|
@@ -116,6 +120,18 @@ export async function sandboxCreate(
|
|
|
116
120
|
const { options = {}, orgId } = params;
|
|
117
121
|
const body: z.infer<typeof SandboxCreateRequestSchema> = {};
|
|
118
122
|
|
|
123
|
+
if (options.runtime) {
|
|
124
|
+
body.runtime = options.runtime;
|
|
125
|
+
}
|
|
126
|
+
if (options.runtimeId) {
|
|
127
|
+
body.runtimeId = options.runtimeId;
|
|
128
|
+
}
|
|
129
|
+
if (options.name) {
|
|
130
|
+
body.name = options.name;
|
|
131
|
+
}
|
|
132
|
+
if (options.description) {
|
|
133
|
+
body.description = options.description;
|
|
134
|
+
}
|
|
119
135
|
if (options.resources) {
|
|
120
136
|
body.resources = options.resources;
|
|
121
137
|
}
|
|
@@ -7,6 +7,10 @@ const ExecutionInfoSchema = z
|
|
|
7
7
|
.object({
|
|
8
8
|
executionId: z.string().describe('Unique identifier for the execution'),
|
|
9
9
|
sandboxId: z.string().describe('ID of the sandbox where the execution ran'),
|
|
10
|
+
type: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Type of execution (e.g., exec, write_files, read_file)'),
|
|
10
14
|
status: z
|
|
11
15
|
.enum(['queued', 'running', 'completed', 'failed', 'timeout', 'cancelled'])
|
|
12
16
|
.describe('Current status of the execution'),
|
|
@@ -34,6 +38,7 @@ const ExecutionListResponseSchema = APIResponseSchema(ExecutionListDataSchema);
|
|
|
34
38
|
export interface ExecutionInfo {
|
|
35
39
|
executionId: string;
|
|
36
40
|
sandboxId: string;
|
|
41
|
+
type?: string;
|
|
37
42
|
status: ExecutionStatus;
|
|
38
43
|
command?: string[];
|
|
39
44
|
exitCode?: number;
|
|
@@ -79,6 +84,7 @@ export async function executionGet(
|
|
|
79
84
|
return {
|
|
80
85
|
executionId: resp.data.executionId,
|
|
81
86
|
sandboxId: resp.data.sandboxId,
|
|
87
|
+
type: resp.data.type,
|
|
82
88
|
status: resp.data.status as ExecutionStatus,
|
|
83
89
|
command: resp.data.command,
|
|
84
90
|
exitCode: resp.data.exitCode,
|
|
@@ -137,6 +143,7 @@ export async function executionList(
|
|
|
137
143
|
executions: resp.data.executions.map((exec) => ({
|
|
138
144
|
executionId: exec.executionId,
|
|
139
145
|
sandboxId: exec.sandboxId,
|
|
146
|
+
type: exec.type,
|
|
140
147
|
status: exec.status as ExecutionStatus,
|
|
141
148
|
command: exec.command,
|
|
142
149
|
exitCode: exec.exitCode,
|
package/src/api/sandbox/get.ts
CHANGED
|
@@ -11,14 +11,49 @@ const SandboxResourcesSchema = z
|
|
|
11
11
|
})
|
|
12
12
|
.describe('Resource limits for the sandbox');
|
|
13
13
|
|
|
14
|
+
const SandboxUserInfoSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
id: z.string().describe('User ID'),
|
|
17
|
+
firstName: z.string().optional().describe("User's first name"),
|
|
18
|
+
lastName: z.string().optional().describe("User's last name"),
|
|
19
|
+
})
|
|
20
|
+
.describe('User who created the sandbox');
|
|
21
|
+
|
|
22
|
+
const SandboxAgentInfoSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
id: z.string().describe('Agent ID'),
|
|
25
|
+
name: z.string().describe('Agent name'),
|
|
26
|
+
})
|
|
27
|
+
.describe('Agent associated with the sandbox');
|
|
28
|
+
|
|
29
|
+
const SandboxProjectInfoSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
id: z.string().describe('Project ID'),
|
|
32
|
+
name: z.string().describe('Project name'),
|
|
33
|
+
})
|
|
34
|
+
.describe('Project associated with the sandbox');
|
|
35
|
+
|
|
36
|
+
const SandboxOrgInfoSchema = z
|
|
37
|
+
.object({
|
|
38
|
+
id: z.string().describe('Organization ID'),
|
|
39
|
+
name: z.string().describe('Organization name'),
|
|
40
|
+
})
|
|
41
|
+
.describe('Organization associated with the sandbox');
|
|
42
|
+
|
|
14
43
|
const SandboxInfoDataSchema = z
|
|
15
44
|
.object({
|
|
16
45
|
sandboxId: z.string().describe('Unique identifier for the sandbox'),
|
|
46
|
+
name: z.string().optional().describe('Sandbox name'),
|
|
47
|
+
description: z.string().optional().describe('Sandbox description'),
|
|
17
48
|
status: z
|
|
18
|
-
.enum(['creating', 'idle', 'running', 'terminated', 'failed'])
|
|
49
|
+
.enum(['creating', 'idle', 'running', 'terminated', 'failed', 'deleted'])
|
|
19
50
|
.describe('Current status of the sandbox'),
|
|
51
|
+
mode: z.string().optional().describe('Sandbox mode (interactive or oneshot)'),
|
|
20
52
|
createdAt: z.string().describe('ISO timestamp when the sandbox was created'),
|
|
21
53
|
region: z.string().optional().describe('Region where the sandbox is running'),
|
|
54
|
+
runtimeId: z.string().optional().describe('Runtime ID'),
|
|
55
|
+
runtimeName: z.string().optional().describe('Runtime name (e.g., "bun:1")'),
|
|
56
|
+
runtimeIconUrl: z.string().optional().describe('URL for runtime icon'),
|
|
22
57
|
snapshotId: z.string().optional().describe('Snapshot ID this sandbox was created from'),
|
|
23
58
|
snapshotTag: z.string().optional().describe('Snapshot tag this sandbox was created from'),
|
|
24
59
|
executions: z.number().describe('Total number of executions in this sandbox'),
|
|
@@ -33,6 +68,14 @@ const SandboxInfoDataSchema = z
|
|
|
33
68
|
.optional()
|
|
34
69
|
.describe('User-defined metadata associated with the sandbox'),
|
|
35
70
|
resources: SandboxResourcesSchema.optional().describe('Resource limits for this sandbox'),
|
|
71
|
+
cpuTimeMs: z.number().optional().describe('Total CPU time consumed in milliseconds'),
|
|
72
|
+
memoryByteSec: z.number().optional().describe('Total memory usage in byte-seconds'),
|
|
73
|
+
networkEgressBytes: z.number().optional().describe('Total network egress in bytes'),
|
|
74
|
+
networkEnabled: z.boolean().optional().describe('Whether network access is enabled'),
|
|
75
|
+
user: SandboxUserInfoSchema.optional().describe('User who created the sandbox'),
|
|
76
|
+
agent: SandboxAgentInfoSchema.optional().describe('Agent associated with the sandbox'),
|
|
77
|
+
project: SandboxProjectInfoSchema.optional().describe('Project associated with the sandbox'),
|
|
78
|
+
org: SandboxOrgInfoSchema.describe('Organization associated with the sandbox'),
|
|
36
79
|
})
|
|
37
80
|
.describe('Detailed information about a sandbox');
|
|
38
81
|
|
|
@@ -41,6 +84,7 @@ const SandboxGetResponseSchema = APIResponseSchema(SandboxInfoDataSchema);
|
|
|
41
84
|
export interface SandboxGetParams {
|
|
42
85
|
sandboxId: string;
|
|
43
86
|
orgId?: string;
|
|
87
|
+
includeDeleted?: boolean;
|
|
44
88
|
}
|
|
45
89
|
|
|
46
90
|
/**
|
|
@@ -55,11 +99,14 @@ export async function sandboxGet(
|
|
|
55
99
|
client: APIClient,
|
|
56
100
|
params: SandboxGetParams
|
|
57
101
|
): Promise<SandboxInfo> {
|
|
58
|
-
const { sandboxId, orgId } = params;
|
|
102
|
+
const { sandboxId, orgId, includeDeleted } = params;
|
|
59
103
|
const queryParams = new URLSearchParams();
|
|
60
104
|
if (orgId) {
|
|
61
105
|
queryParams.set('orgId', orgId);
|
|
62
106
|
}
|
|
107
|
+
if (includeDeleted) {
|
|
108
|
+
queryParams.set('includeDeleted', 'true');
|
|
109
|
+
}
|
|
63
110
|
const queryString = queryParams.toString();
|
|
64
111
|
const url = `/sandbox/${API_VERSION}/${sandboxId}${queryString ? `?${queryString}` : ''}`;
|
|
65
112
|
|
|
@@ -71,9 +118,15 @@ export async function sandboxGet(
|
|
|
71
118
|
if (resp.success) {
|
|
72
119
|
return {
|
|
73
120
|
sandboxId: resp.data.sandboxId,
|
|
121
|
+
name: resp.data.name,
|
|
122
|
+
description: resp.data.description,
|
|
74
123
|
status: resp.data.status as SandboxStatus,
|
|
124
|
+
mode: resp.data.mode,
|
|
75
125
|
createdAt: resp.data.createdAt,
|
|
76
126
|
region: resp.data.region,
|
|
127
|
+
runtimeId: resp.data.runtimeId,
|
|
128
|
+
runtimeName: resp.data.runtimeName,
|
|
129
|
+
runtimeIconUrl: resp.data.runtimeIconUrl,
|
|
77
130
|
snapshotId: resp.data.snapshotId,
|
|
78
131
|
snapshotTag: resp.data.snapshotTag,
|
|
79
132
|
executions: resp.data.executions,
|
|
@@ -82,6 +135,14 @@ export async function sandboxGet(
|
|
|
82
135
|
dependencies: resp.data.dependencies,
|
|
83
136
|
metadata: resp.data.metadata as Record<string, unknown> | undefined,
|
|
84
137
|
resources: resp.data.resources,
|
|
138
|
+
cpuTimeMs: resp.data.cpuTimeMs,
|
|
139
|
+
memoryByteSec: resp.data.memoryByteSec,
|
|
140
|
+
networkEgressBytes: resp.data.networkEgressBytes,
|
|
141
|
+
networkEnabled: resp.data.networkEnabled,
|
|
142
|
+
user: resp.data.user,
|
|
143
|
+
agent: resp.data.agent,
|
|
144
|
+
project: resp.data.project,
|
|
145
|
+
org: resp.data.org,
|
|
85
146
|
};
|
|
86
147
|
}
|
|
87
148
|
|
package/src/api/sandbox/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { sandboxGet } from './get';
|
|
|
6
6
|
export type { SandboxGetParams } from './get';
|
|
7
7
|
export { sandboxList } from './list';
|
|
8
8
|
export type { SandboxListParams } from './list';
|
|
9
|
+
export { runtimeList } from './runtime';
|
|
10
|
+
export type { RuntimeListParams } from './runtime';
|
|
9
11
|
export { sandboxDestroy } from './destroy';
|
|
10
12
|
export type { SandboxDestroyParams } from './destroy';
|
|
11
13
|
export { sandboxRun } from './run';
|
package/src/api/sandbox/list.ts
CHANGED
|
@@ -3,19 +3,34 @@ import { APIClient, APIResponseSchema } from '../api';
|
|
|
3
3
|
import { SandboxResponseError, API_VERSION } from './util';
|
|
4
4
|
import type { ListSandboxesParams, ListSandboxesResponse, SandboxStatus } from '@agentuity/core';
|
|
5
5
|
|
|
6
|
+
const SandboxOrgInfoSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
id: z.string().describe('Organization ID'),
|
|
9
|
+
name: z.string().describe('Organization name'),
|
|
10
|
+
})
|
|
11
|
+
.describe('Organization associated with the sandbox');
|
|
12
|
+
|
|
6
13
|
const SandboxInfoSchema = z
|
|
7
14
|
.object({
|
|
8
15
|
sandboxId: z.string().describe('Unique identifier for the sandbox'),
|
|
16
|
+
name: z.string().optional().describe('Sandbox name'),
|
|
17
|
+
description: z.string().optional().describe('Sandbox description'),
|
|
9
18
|
status: z
|
|
10
|
-
.enum(['creating', 'idle', 'running', 'terminated', 'failed'])
|
|
19
|
+
.enum(['creating', 'idle', 'running', 'terminated', 'failed', 'deleted'])
|
|
11
20
|
.describe('Current status of the sandbox'),
|
|
21
|
+
mode: z.string().optional().describe('Sandbox mode (interactive or oneshot)'),
|
|
12
22
|
createdAt: z.string().describe('ISO timestamp when the sandbox was created'),
|
|
13
23
|
region: z.string().optional().describe('Region where the sandbox is running'),
|
|
24
|
+
runtimeId: z.string().optional().describe('Runtime ID'),
|
|
25
|
+
runtimeName: z.string().optional().describe('Runtime name (e.g., "bun:1")'),
|
|
26
|
+
runtimeIconUrl: z.string().optional().describe('URL for runtime icon'),
|
|
14
27
|
snapshotId: z.string().optional().describe('Snapshot ID this sandbox was created from'),
|
|
15
28
|
snapshotTag: z.string().optional().describe('Snapshot tag this sandbox was created from'),
|
|
16
29
|
executions: z.number().describe('Total number of executions in this sandbox'),
|
|
17
30
|
stdoutStreamUrl: z.string().optional().describe('URL for streaming stdout output'),
|
|
18
31
|
stderrStreamUrl: z.string().optional().describe('URL for streaming stderr output'),
|
|
32
|
+
networkEnabled: z.boolean().optional().describe('Whether network access is enabled'),
|
|
33
|
+
org: SandboxOrgInfoSchema.describe('Organization associated with the sandbox'),
|
|
19
34
|
})
|
|
20
35
|
.describe('Summary information about a sandbox');
|
|
21
36
|
|
|
@@ -30,6 +45,7 @@ const ListSandboxesResponseSchema = APIResponseSchema(ListSandboxesDataSchema);
|
|
|
30
45
|
|
|
31
46
|
export interface SandboxListParams extends ListSandboxesParams {
|
|
32
47
|
orgId?: string;
|
|
48
|
+
deletedOnly?: boolean;
|
|
33
49
|
}
|
|
34
50
|
|
|
35
51
|
/**
|
|
@@ -64,6 +80,9 @@ export async function sandboxList(
|
|
|
64
80
|
if (params?.offset !== undefined) {
|
|
65
81
|
queryParams.set('offset', params.offset.toString());
|
|
66
82
|
}
|
|
83
|
+
if (params?.deletedOnly) {
|
|
84
|
+
queryParams.set('deletedOnly', 'true');
|
|
85
|
+
}
|
|
67
86
|
|
|
68
87
|
const queryString = queryParams.toString();
|
|
69
88
|
const url = `/sandbox/${API_VERSION}${queryString ? `?${queryString}` : ''}`;
|
|
@@ -77,14 +96,22 @@ export async function sandboxList(
|
|
|
77
96
|
return {
|
|
78
97
|
sandboxes: resp.data.sandboxes.map((s) => ({
|
|
79
98
|
sandboxId: s.sandboxId,
|
|
99
|
+
name: s.name,
|
|
100
|
+
description: s.description,
|
|
80
101
|
status: s.status as SandboxStatus,
|
|
102
|
+
mode: s.mode,
|
|
81
103
|
createdAt: s.createdAt,
|
|
82
104
|
region: s.region,
|
|
105
|
+
runtimeId: s.runtimeId,
|
|
106
|
+
runtimeName: s.runtimeName,
|
|
107
|
+
runtimeIconUrl: s.runtimeIconUrl,
|
|
83
108
|
snapshotId: s.snapshotId,
|
|
84
109
|
snapshotTag: s.snapshotTag,
|
|
85
110
|
executions: s.executions,
|
|
86
111
|
stdoutStreamUrl: s.stdoutStreamUrl,
|
|
87
112
|
stderrStreamUrl: s.stderrStreamUrl,
|
|
113
|
+
networkEnabled: s.networkEnabled,
|
|
114
|
+
org: s.org,
|
|
88
115
|
})),
|
|
89
116
|
total: resp.data.total,
|
|
90
117
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { SandboxResponseError, API_VERSION } from './util';
|
|
4
|
+
import type { ListRuntimesParams, ListRuntimesResponse, SandboxRuntime } from '@agentuity/core';
|
|
5
|
+
|
|
6
|
+
const RuntimeInfoSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
id: z.string().describe('Unique runtime identifier'),
|
|
9
|
+
name: z.string().describe('Runtime name (e.g., "bun:1", "python:3.14")'),
|
|
10
|
+
description: z.string().optional().describe('Optional description'),
|
|
11
|
+
iconUrl: z.string().optional().describe('URL for runtime icon'),
|
|
12
|
+
url: z.string().optional().describe('URL for runtime documentation or homepage'),
|
|
13
|
+
tags: z.array(z.string()).optional().describe('Optional tags for categorization'),
|
|
14
|
+
})
|
|
15
|
+
.describe('Information about a sandbox runtime');
|
|
16
|
+
|
|
17
|
+
const ListRuntimesDataSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
runtimes: z.array(RuntimeInfoSchema).describe('List of runtime entries'),
|
|
20
|
+
total: z.number().describe('Total number of runtimes'),
|
|
21
|
+
})
|
|
22
|
+
.describe('List of sandbox runtimes');
|
|
23
|
+
|
|
24
|
+
const ListRuntimesResponseSchema = APIResponseSchema(ListRuntimesDataSchema);
|
|
25
|
+
|
|
26
|
+
export interface RuntimeListParams extends ListRuntimesParams {
|
|
27
|
+
orgId?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Lists available sandbox runtimes with optional pagination.
|
|
32
|
+
*
|
|
33
|
+
* @param client - The API client to use for the request
|
|
34
|
+
* @param params - Optional parameters for pagination
|
|
35
|
+
* @returns List of runtimes with total count
|
|
36
|
+
* @throws {SandboxResponseError} If the request fails
|
|
37
|
+
*/
|
|
38
|
+
export async function runtimeList(
|
|
39
|
+
client: APIClient,
|
|
40
|
+
params?: RuntimeListParams
|
|
41
|
+
): Promise<ListRuntimesResponse> {
|
|
42
|
+
const queryParams = new URLSearchParams();
|
|
43
|
+
|
|
44
|
+
if (params?.orgId) {
|
|
45
|
+
queryParams.set('orgId', params.orgId);
|
|
46
|
+
}
|
|
47
|
+
if (params?.limit !== undefined) {
|
|
48
|
+
queryParams.set('limit', params.limit.toString());
|
|
49
|
+
}
|
|
50
|
+
if (params?.offset !== undefined) {
|
|
51
|
+
queryParams.set('offset', params.offset.toString());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const queryString = queryParams.toString();
|
|
55
|
+
const url = `/sandbox/${API_VERSION}/runtimes${queryString ? `?${queryString}` : ''}`;
|
|
56
|
+
|
|
57
|
+
const resp = await client.get<z.infer<typeof ListRuntimesResponseSchema>>(
|
|
58
|
+
url,
|
|
59
|
+
ListRuntimesResponseSchema
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (resp.success) {
|
|
63
|
+
return {
|
|
64
|
+
runtimes: resp.data.runtimes.map(
|
|
65
|
+
(r): SandboxRuntime => ({
|
|
66
|
+
id: r.id,
|
|
67
|
+
name: r.name,
|
|
68
|
+
description: r.description,
|
|
69
|
+
iconUrl: r.iconUrl,
|
|
70
|
+
url: r.url,
|
|
71
|
+
tags: r.tags,
|
|
72
|
+
})
|
|
73
|
+
),
|
|
74
|
+
total: resp.data.total,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
throw new SandboxResponseError({ message: resp.message });
|
|
79
|
+
}
|
|
@@ -12,7 +12,18 @@ const SnapshotFileInfoSchema = z
|
|
|
12
12
|
const SnapshotInfoSchema = z
|
|
13
13
|
.object({
|
|
14
14
|
snapshotId: z.string().describe('Unique identifier for the snapshot'),
|
|
15
|
-
|
|
15
|
+
runtimeId: z
|
|
16
|
+
.string()
|
|
17
|
+
.nullable()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Runtime ID associated with this snapshot'),
|
|
20
|
+
name: z
|
|
21
|
+
.string()
|
|
22
|
+
.describe(
|
|
23
|
+
'Display name for the snapshot (URL-safe: letters, numbers, underscores, dashes)'
|
|
24
|
+
),
|
|
25
|
+
description: z.string().nullable().optional().describe('Description of the snapshot'),
|
|
26
|
+
tag: z.string().nullable().optional().describe('Tag for the snapshot (defaults to "latest")'),
|
|
16
27
|
sizeBytes: z.number().describe('Total size of the snapshot in bytes'),
|
|
17
28
|
fileCount: z.number().describe('Number of files in the snapshot'),
|
|
18
29
|
parentSnapshotId: z
|
|
@@ -22,7 +33,11 @@ const SnapshotInfoSchema = z
|
|
|
22
33
|
.describe('ID of the parent snapshot (for incremental snapshots)'),
|
|
23
34
|
createdAt: z.string().describe('ISO timestamp when the snapshot was created'),
|
|
24
35
|
downloadUrl: z.string().optional().describe('URL to download the snapshot archive'),
|
|
25
|
-
files: z
|
|
36
|
+
files: z
|
|
37
|
+
.array(SnapshotFileInfoSchema)
|
|
38
|
+
.nullable()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('List of files in the snapshot'),
|
|
26
41
|
})
|
|
27
42
|
.describe('Detailed information about a snapshot');
|
|
28
43
|
|
|
@@ -44,17 +59,22 @@ export interface SnapshotFileInfo {
|
|
|
44
59
|
|
|
45
60
|
export interface SnapshotInfo {
|
|
46
61
|
snapshotId: string;
|
|
62
|
+
runtimeId?: string | null;
|
|
63
|
+
name: string;
|
|
64
|
+
description?: string | null;
|
|
47
65
|
tag?: string | null;
|
|
48
66
|
sizeBytes: number;
|
|
49
67
|
fileCount: number;
|
|
50
68
|
parentSnapshotId?: string | null;
|
|
51
69
|
createdAt: string;
|
|
52
70
|
downloadUrl?: string;
|
|
53
|
-
files?: SnapshotFileInfo[];
|
|
71
|
+
files?: SnapshotFileInfo[] | null;
|
|
54
72
|
}
|
|
55
73
|
|
|
56
74
|
export interface SnapshotCreateParams {
|
|
57
75
|
sandboxId: string;
|
|
76
|
+
name?: string;
|
|
77
|
+
description?: string;
|
|
58
78
|
tag?: string;
|
|
59
79
|
orgId?: string;
|
|
60
80
|
}
|
|
@@ -110,11 +130,17 @@ export async function snapshotCreate(
|
|
|
110
130
|
client: APIClient,
|
|
111
131
|
params: SnapshotCreateParams
|
|
112
132
|
): Promise<SnapshotInfo> {
|
|
113
|
-
const { sandboxId, tag, orgId } = params;
|
|
133
|
+
const { sandboxId, name, description, tag, orgId } = params;
|
|
114
134
|
const queryString = buildQueryString({ orgId });
|
|
115
135
|
const url = `/sandbox/${API_VERSION}/${sandboxId}/snapshot${queryString}`;
|
|
116
136
|
|
|
117
137
|
const body: Record<string, string> = {};
|
|
138
|
+
if (name) {
|
|
139
|
+
body.name = name;
|
|
140
|
+
}
|
|
141
|
+
if (description) {
|
|
142
|
+
body.description = description;
|
|
143
|
+
}
|
|
118
144
|
if (tag) {
|
|
119
145
|
body.tag = tag;
|
|
120
146
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,16 @@ export { createServerFetchAdapter } from './server';
|
|
|
13
13
|
// schema.ts exports
|
|
14
14
|
export { toJSONSchema } from './schema';
|
|
15
15
|
|
|
16
|
+
// util/resources.ts exports
|
|
17
|
+
export {
|
|
18
|
+
validateCPUSpec,
|
|
19
|
+
validateMemorySpec,
|
|
20
|
+
validateResources,
|
|
21
|
+
type ResourceValidationResult,
|
|
22
|
+
type ResourcesConfig,
|
|
23
|
+
type ValidatedResources,
|
|
24
|
+
} from './util/resources';
|
|
25
|
+
|
|
16
26
|
// runtime-bootstrap.ts exports
|
|
17
27
|
export { bootstrapRuntimeEnv, type RuntimeBootstrapOptions } from './runtime-bootstrap';
|
|
18
28
|
|