@agentuity/server 0.1.7 → 0.1.9
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/sandbox/create.d.ts.map +1 -1
- package/dist/api/sandbox/create.js +19 -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 +3 -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 +25 -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 +18 -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 +12 -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/sandbox/create.ts +19 -0
- package/src/api/sandbox/execution.ts +4 -0
- package/src/api/sandbox/get.ts +26 -2
- package/src/api/sandbox/index.ts +2 -0
- package/src/api/sandbox/list.ts +19 -1
- package/src/api/sandbox/runtime.ts +77 -0
- package/src/api/sandbox/snapshot.ts +18 -4
- package/src/index.ts +10 -0
- package/src/util/resources.ts +213 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface ResourceValidationSuccess {
|
|
2
|
+
valid: true;
|
|
3
|
+
value: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ResourceValidationFailure {
|
|
6
|
+
valid: false;
|
|
7
|
+
error: string;
|
|
8
|
+
}
|
|
9
|
+
export type ResourceValidationResult = ResourceValidationSuccess | ResourceValidationFailure;
|
|
10
|
+
/**
|
|
11
|
+
* Validates and parses a CPU spec string.
|
|
12
|
+
* Valid formats:
|
|
13
|
+
* - "500m" (millicores)
|
|
14
|
+
* - "1" or "2" (cores, converted to millicores)
|
|
15
|
+
* - "0.5" (fractional cores, converted to millicores)
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateCPUSpec(input: string): ResourceValidationResult;
|
|
18
|
+
/**
|
|
19
|
+
* Validates and parses a memory/disk spec string.
|
|
20
|
+
* Valid formats:
|
|
21
|
+
* - "500Mi", "1Gi", "2Ti" (binary units)
|
|
22
|
+
* - "500M", "1G", "2T" (decimal units)
|
|
23
|
+
* - "1.5Gi", "0.5G" (decimal fractions with units)
|
|
24
|
+
* - "1073741824" (raw bytes)
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateMemorySpec(input: string, fieldName?: 'memory' | 'disk'): ResourceValidationResult;
|
|
27
|
+
export interface ResourcesConfig {
|
|
28
|
+
cpu?: string;
|
|
29
|
+
memory?: string;
|
|
30
|
+
disk?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ValidatedResources {
|
|
33
|
+
cpuUnits?: number;
|
|
34
|
+
memoryUnits?: number;
|
|
35
|
+
diskUnits?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Validates all resource specs and returns either validated values or an array of errors.
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateResources(resources: ResourcesConfig): {
|
|
41
|
+
valid: true;
|
|
42
|
+
values: ValidatedResources;
|
|
43
|
+
} | {
|
|
44
|
+
valid: false;
|
|
45
|
+
errors: string[];
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/util/resources.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACzC,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,yBAAyB;IACzC,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,GAAG,yBAAyB,CAAC;AAE7F;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,wBAAwB,CAmCvE;AAmBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,QAAQ,GAAG,MAAiB,GACrC,wBAAwB,CA6D1B;AAED,MAAM,WAAW,eAAe;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,eAAe,GACxB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAgDlF"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates and parses a CPU spec string.
|
|
3
|
+
* Valid formats:
|
|
4
|
+
* - "500m" (millicores)
|
|
5
|
+
* - "1" or "2" (cores, converted to millicores)
|
|
6
|
+
* - "0.5" (fractional cores, converted to millicores)
|
|
7
|
+
*/
|
|
8
|
+
export function validateCPUSpec(input) {
|
|
9
|
+
if (!input || typeof input !== 'string') {
|
|
10
|
+
return { valid: false, error: 'CPU value is required' };
|
|
11
|
+
}
|
|
12
|
+
const trimmed = input.trim();
|
|
13
|
+
// Match millicores format: "500m", "1000m"
|
|
14
|
+
const milliMatch = trimmed.match(/^([0-9]+)m$/);
|
|
15
|
+
if (milliMatch) {
|
|
16
|
+
const value = parseInt(milliMatch[1], 10);
|
|
17
|
+
if (value <= 0) {
|
|
18
|
+
return { valid: false, error: `Invalid CPU value "${input}": must be greater than 0` };
|
|
19
|
+
}
|
|
20
|
+
return { valid: true, value };
|
|
21
|
+
}
|
|
22
|
+
// Match cores format: "1", "2", "0.5"
|
|
23
|
+
const coreMatch = trimmed.match(/^([0-9]*\.?[0-9]+)$/);
|
|
24
|
+
if (coreMatch) {
|
|
25
|
+
const cores = parseFloat(coreMatch[1]);
|
|
26
|
+
const millicores = Math.round(cores * 1000);
|
|
27
|
+
if (isNaN(millicores) || millicores <= 0) {
|
|
28
|
+
return {
|
|
29
|
+
valid: false,
|
|
30
|
+
error: `Invalid CPU value "${input}": must be at least 1m (0.001 cores)`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { valid: true, value: millicores };
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
valid: false,
|
|
37
|
+
error: `Invalid CPU format "${input}". Use millicores (e.g., "500m", "1000m") or cores (e.g., "1", "2", "0.5")`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const memoryMultipliers = {
|
|
41
|
+
k: 1000,
|
|
42
|
+
M: 1000 ** 2,
|
|
43
|
+
G: 1000 ** 3,
|
|
44
|
+
T: 1000 ** 4,
|
|
45
|
+
P: 1000 ** 5,
|
|
46
|
+
E: 1000 ** 6,
|
|
47
|
+
Ki: 1024,
|
|
48
|
+
Mi: 1024 ** 2,
|
|
49
|
+
Gi: 1024 ** 3,
|
|
50
|
+
Ti: 1024 ** 4,
|
|
51
|
+
Pi: 1024 ** 5,
|
|
52
|
+
Ei: 1024 ** 6,
|
|
53
|
+
};
|
|
54
|
+
const validMemoryUnits = Object.keys(memoryMultipliers).join(', ');
|
|
55
|
+
/**
|
|
56
|
+
* Validates and parses a memory/disk spec string.
|
|
57
|
+
* Valid formats:
|
|
58
|
+
* - "500Mi", "1Gi", "2Ti" (binary units)
|
|
59
|
+
* - "500M", "1G", "2T" (decimal units)
|
|
60
|
+
* - "1.5Gi", "0.5G" (decimal fractions with units)
|
|
61
|
+
* - "1073741824" (raw bytes)
|
|
62
|
+
*/
|
|
63
|
+
export function validateMemorySpec(input, fieldName = 'memory') {
|
|
64
|
+
if (!input || typeof input !== 'string') {
|
|
65
|
+
return { valid: false, error: `${fieldName} value is required` };
|
|
66
|
+
}
|
|
67
|
+
const trimmed = input.trim();
|
|
68
|
+
// Match unit format: "500Mi", "1Gi", "2G", "1.5Gi", "0.5G"
|
|
69
|
+
const unitMatch = trimmed.match(/^([0-9]*\.?[0-9]+)([A-Za-z]{1,2})$/);
|
|
70
|
+
if (unitMatch) {
|
|
71
|
+
const amount = parseFloat(unitMatch[1]);
|
|
72
|
+
const unit = unitMatch[2];
|
|
73
|
+
if (isNaN(amount) || amount <= 0) {
|
|
74
|
+
return {
|
|
75
|
+
valid: false,
|
|
76
|
+
error: `Invalid ${fieldName} value "${input}": must be greater than 0`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const multiplier = memoryMultipliers[unit];
|
|
80
|
+
if (multiplier === undefined) {
|
|
81
|
+
return {
|
|
82
|
+
valid: false,
|
|
83
|
+
error: `Invalid ${fieldName} unit "${unit}" in "${input}". Valid units: ${validMemoryUnits}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const value = Math.round(amount * multiplier);
|
|
87
|
+
if (!Number.isSafeInteger(value)) {
|
|
88
|
+
return {
|
|
89
|
+
valid: false,
|
|
90
|
+
error: `Invalid ${fieldName} value "${input}": exceeds maximum safe integer (value too large)`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return { valid: true, value };
|
|
94
|
+
}
|
|
95
|
+
// Match raw bytes: "1073741824"
|
|
96
|
+
const bytesMatch = trimmed.match(/^([0-9]+)$/);
|
|
97
|
+
if (bytesMatch) {
|
|
98
|
+
const value = parseInt(bytesMatch[1], 10);
|
|
99
|
+
if (value <= 0) {
|
|
100
|
+
return {
|
|
101
|
+
valid: false,
|
|
102
|
+
error: `Invalid ${fieldName} value "${input}": must be greater than 0`,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (!Number.isSafeInteger(value)) {
|
|
106
|
+
return {
|
|
107
|
+
valid: false,
|
|
108
|
+
error: `Invalid ${fieldName} value "${input}": exceeds maximum safe integer (value too large)`,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return { valid: true, value };
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
valid: false,
|
|
115
|
+
error: `Invalid ${fieldName} format "${input}". Use units (e.g., "500Mi", "1Gi", "1.5Gi") or bytes (e.g., "1073741824")`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Validates all resource specs and returns either validated values or an array of errors.
|
|
120
|
+
*/
|
|
121
|
+
export function validateResources(resources) {
|
|
122
|
+
const errors = [];
|
|
123
|
+
const values = {};
|
|
124
|
+
if (resources.cpu !== undefined && resources.cpu !== null) {
|
|
125
|
+
const result = validateCPUSpec(resources.cpu);
|
|
126
|
+
if (result.valid) {
|
|
127
|
+
if (!Number.isFinite(result.value)) {
|
|
128
|
+
errors.push(`Invalid CPU value "${resources.cpu}": parsed to non-finite number`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
values.cpuUnits = result.value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
errors.push(result.error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (resources.memory !== undefined && resources.memory !== null) {
|
|
139
|
+
const result = validateMemorySpec(resources.memory, 'memory');
|
|
140
|
+
if (result.valid) {
|
|
141
|
+
if (!Number.isFinite(result.value)) {
|
|
142
|
+
errors.push(`Invalid memory value "${resources.memory}": parsed to non-finite number`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
values.memoryUnits = result.value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
errors.push(result.error);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (resources.disk !== undefined && resources.disk !== null) {
|
|
153
|
+
const result = validateMemorySpec(resources.disk, 'disk');
|
|
154
|
+
if (result.valid) {
|
|
155
|
+
if (!Number.isFinite(result.value)) {
|
|
156
|
+
errors.push(`Invalid disk value "${resources.disk}": parsed to non-finite number`);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
values.diskUnits = result.value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
errors.push(result.error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (errors.length > 0) {
|
|
167
|
+
return { valid: false, errors };
|
|
168
|
+
}
|
|
169
|
+
return { valid: true, values };
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/util/resources.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,EAAE,KAAK,EAA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F,CAAC;IAED,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC7D,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1D,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpC,MAAM,CAAC,IAAI,CAAC,uBAAuB,SAAS,CAAC,IAAI,gCAAgC,CAAC,CAAC;YACpF,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;YACjC,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACF,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"prepublishOnly": "bun run clean && bun run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentuity/core": "0.1.
|
|
29
|
-
"@agentuity/schema": "0.1.
|
|
28
|
+
"@agentuity/core": "0.1.9",
|
|
29
|
+
"@agentuity/schema": "0.1.9",
|
|
30
30
|
"zod": "^4.3.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@agentuity/test-utils": "0.1.
|
|
33
|
+
"@agentuity/test-utils": "0.1.9",
|
|
34
34
|
"@types/bun": "latest",
|
|
35
35
|
"@types/node": "^22.0.0",
|
|
36
36
|
"bun-types": "latest",
|
|
@@ -5,6 +5,13 @@ import type { SandboxCreateOptions, SandboxStatus } from '@agentuity/core';
|
|
|
5
5
|
|
|
6
6
|
const SandboxCreateRequestSchema = z
|
|
7
7
|
.object({
|
|
8
|
+
runtime: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('Runtime name (e.g., "bun:1", "python:3.14")'),
|
|
12
|
+
runtimeId: z.string().optional().describe('Runtime ID (e.g., "srt_xxx")'),
|
|
13
|
+
name: z.string().optional().describe('Optional sandbox name'),
|
|
14
|
+
description: z.string().optional().describe('Optional sandbox description'),
|
|
8
15
|
resources: z
|
|
9
16
|
.object({
|
|
10
17
|
memory: z.string().optional().describe('Memory limit (e.g., "512Mi", "1Gi")'),
|
|
@@ -116,6 +123,18 @@ export async function sandboxCreate(
|
|
|
116
123
|
const { options = {}, orgId } = params;
|
|
117
124
|
const body: z.infer<typeof SandboxCreateRequestSchema> = {};
|
|
118
125
|
|
|
126
|
+
if (options.runtime) {
|
|
127
|
+
body.runtime = options.runtime;
|
|
128
|
+
}
|
|
129
|
+
if (options.runtimeId) {
|
|
130
|
+
body.runtimeId = options.runtimeId;
|
|
131
|
+
}
|
|
132
|
+
if (options.name) {
|
|
133
|
+
body.name = options.name;
|
|
134
|
+
}
|
|
135
|
+
if (options.description) {
|
|
136
|
+
body.description = options.description;
|
|
137
|
+
}
|
|
119
138
|
if (options.resources) {
|
|
120
139
|
body.resources = options.resources;
|
|
121
140
|
}
|
|
@@ -7,6 +7,7 @@ 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.string().optional().describe('Type of execution (e.g., exec, write_files, read_file)'),
|
|
10
11
|
status: z
|
|
11
12
|
.enum(['queued', 'running', 'completed', 'failed', 'timeout', 'cancelled'])
|
|
12
13
|
.describe('Current status of the execution'),
|
|
@@ -34,6 +35,7 @@ const ExecutionListResponseSchema = APIResponseSchema(ExecutionListDataSchema);
|
|
|
34
35
|
export interface ExecutionInfo {
|
|
35
36
|
executionId: string;
|
|
36
37
|
sandboxId: string;
|
|
38
|
+
type?: string;
|
|
37
39
|
status: ExecutionStatus;
|
|
38
40
|
command?: string[];
|
|
39
41
|
exitCode?: number;
|
|
@@ -79,6 +81,7 @@ export async function executionGet(
|
|
|
79
81
|
return {
|
|
80
82
|
executionId: resp.data.executionId,
|
|
81
83
|
sandboxId: resp.data.sandboxId,
|
|
84
|
+
type: resp.data.type,
|
|
82
85
|
status: resp.data.status as ExecutionStatus,
|
|
83
86
|
command: resp.data.command,
|
|
84
87
|
exitCode: resp.data.exitCode,
|
|
@@ -137,6 +140,7 @@ export async function executionList(
|
|
|
137
140
|
executions: resp.data.executions.map((exec) => ({
|
|
138
141
|
executionId: exec.executionId,
|
|
139
142
|
sandboxId: exec.sandboxId,
|
|
143
|
+
type: exec.type,
|
|
140
144
|
status: exec.status as ExecutionStatus,
|
|
141
145
|
command: exec.command,
|
|
142
146
|
exitCode: exec.exitCode,
|
package/src/api/sandbox/get.ts
CHANGED
|
@@ -14,11 +14,17 @@ const SandboxResourcesSchema = z
|
|
|
14
14
|
const SandboxInfoDataSchema = z
|
|
15
15
|
.object({
|
|
16
16
|
sandboxId: z.string().describe('Unique identifier for the sandbox'),
|
|
17
|
+
name: z.string().optional().describe('Sandbox name'),
|
|
18
|
+
description: z.string().optional().describe('Sandbox description'),
|
|
17
19
|
status: z
|
|
18
|
-
.enum(['creating', 'idle', 'running', 'terminated', 'failed'])
|
|
20
|
+
.enum(['creating', 'idle', 'running', 'terminated', 'failed', 'deleted'])
|
|
19
21
|
.describe('Current status of the sandbox'),
|
|
22
|
+
mode: z.string().optional().describe('Sandbox mode (interactive or oneshot)'),
|
|
20
23
|
createdAt: z.string().describe('ISO timestamp when the sandbox was created'),
|
|
21
24
|
region: z.string().optional().describe('Region where the sandbox is running'),
|
|
25
|
+
runtimeId: z.string().optional().describe('Runtime ID'),
|
|
26
|
+
runtimeName: z.string().optional().describe('Runtime name (e.g., "bun:1")'),
|
|
27
|
+
runtimeIconUrl: z.string().optional().describe('URL for runtime icon'),
|
|
22
28
|
snapshotId: z.string().optional().describe('Snapshot ID this sandbox was created from'),
|
|
23
29
|
snapshotTag: z.string().optional().describe('Snapshot tag this sandbox was created from'),
|
|
24
30
|
executions: z.number().describe('Total number of executions in this sandbox'),
|
|
@@ -33,6 +39,10 @@ const SandboxInfoDataSchema = z
|
|
|
33
39
|
.optional()
|
|
34
40
|
.describe('User-defined metadata associated with the sandbox'),
|
|
35
41
|
resources: SandboxResourcesSchema.optional().describe('Resource limits for this sandbox'),
|
|
42
|
+
cpuTimeMs: z.number().optional().describe('Total CPU time consumed in milliseconds'),
|
|
43
|
+
memoryByteSec: z.number().optional().describe('Total memory usage in byte-seconds'),
|
|
44
|
+
networkEgressBytes: z.number().optional().describe('Total network egress in bytes'),
|
|
45
|
+
networkEnabled: z.boolean().optional().describe('Whether network access is enabled'),
|
|
36
46
|
})
|
|
37
47
|
.describe('Detailed information about a sandbox');
|
|
38
48
|
|
|
@@ -41,6 +51,7 @@ const SandboxGetResponseSchema = APIResponseSchema(SandboxInfoDataSchema);
|
|
|
41
51
|
export interface SandboxGetParams {
|
|
42
52
|
sandboxId: string;
|
|
43
53
|
orgId?: string;
|
|
54
|
+
includeDeleted?: boolean;
|
|
44
55
|
}
|
|
45
56
|
|
|
46
57
|
/**
|
|
@@ -55,11 +66,14 @@ export async function sandboxGet(
|
|
|
55
66
|
client: APIClient,
|
|
56
67
|
params: SandboxGetParams
|
|
57
68
|
): Promise<SandboxInfo> {
|
|
58
|
-
const { sandboxId, orgId } = params;
|
|
69
|
+
const { sandboxId, orgId, includeDeleted } = params;
|
|
59
70
|
const queryParams = new URLSearchParams();
|
|
60
71
|
if (orgId) {
|
|
61
72
|
queryParams.set('orgId', orgId);
|
|
62
73
|
}
|
|
74
|
+
if (includeDeleted) {
|
|
75
|
+
queryParams.set('includeDeleted', 'true');
|
|
76
|
+
}
|
|
63
77
|
const queryString = queryParams.toString();
|
|
64
78
|
const url = `/sandbox/${API_VERSION}/${sandboxId}${queryString ? `?${queryString}` : ''}`;
|
|
65
79
|
|
|
@@ -71,9 +85,15 @@ export async function sandboxGet(
|
|
|
71
85
|
if (resp.success) {
|
|
72
86
|
return {
|
|
73
87
|
sandboxId: resp.data.sandboxId,
|
|
88
|
+
name: resp.data.name,
|
|
89
|
+
description: resp.data.description,
|
|
74
90
|
status: resp.data.status as SandboxStatus,
|
|
91
|
+
mode: resp.data.mode,
|
|
75
92
|
createdAt: resp.data.createdAt,
|
|
76
93
|
region: resp.data.region,
|
|
94
|
+
runtimeId: resp.data.runtimeId,
|
|
95
|
+
runtimeName: resp.data.runtimeName,
|
|
96
|
+
runtimeIconUrl: resp.data.runtimeIconUrl,
|
|
77
97
|
snapshotId: resp.data.snapshotId,
|
|
78
98
|
snapshotTag: resp.data.snapshotTag,
|
|
79
99
|
executions: resp.data.executions,
|
|
@@ -82,6 +102,10 @@ export async function sandboxGet(
|
|
|
82
102
|
dependencies: resp.data.dependencies,
|
|
83
103
|
metadata: resp.data.metadata as Record<string, unknown> | undefined,
|
|
84
104
|
resources: resp.data.resources,
|
|
105
|
+
cpuTimeMs: resp.data.cpuTimeMs,
|
|
106
|
+
memoryByteSec: resp.data.memoryByteSec,
|
|
107
|
+
networkEgressBytes: resp.data.networkEgressBytes,
|
|
108
|
+
networkEnabled: resp.data.networkEnabled,
|
|
85
109
|
};
|
|
86
110
|
}
|
|
87
111
|
|
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
|
@@ -6,16 +6,23 @@ import type { ListSandboxesParams, ListSandboxesResponse, SandboxStatus } from '
|
|
|
6
6
|
const SandboxInfoSchema = z
|
|
7
7
|
.object({
|
|
8
8
|
sandboxId: z.string().describe('Unique identifier for the sandbox'),
|
|
9
|
+
name: z.string().optional().describe('Sandbox name'),
|
|
10
|
+
description: z.string().optional().describe('Sandbox description'),
|
|
9
11
|
status: z
|
|
10
|
-
.enum(['creating', 'idle', 'running', 'terminated', 'failed'])
|
|
12
|
+
.enum(['creating', 'idle', 'running', 'terminated', 'failed', 'deleted'])
|
|
11
13
|
.describe('Current status of the sandbox'),
|
|
14
|
+
mode: z.string().optional().describe('Sandbox mode (interactive or oneshot)'),
|
|
12
15
|
createdAt: z.string().describe('ISO timestamp when the sandbox was created'),
|
|
13
16
|
region: z.string().optional().describe('Region where the sandbox is running'),
|
|
17
|
+
runtimeId: z.string().optional().describe('Runtime ID'),
|
|
18
|
+
runtimeName: z.string().optional().describe('Runtime name (e.g., "bun:1")'),
|
|
19
|
+
runtimeIconUrl: z.string().optional().describe('URL for runtime icon'),
|
|
14
20
|
snapshotId: z.string().optional().describe('Snapshot ID this sandbox was created from'),
|
|
15
21
|
snapshotTag: z.string().optional().describe('Snapshot tag this sandbox was created from'),
|
|
16
22
|
executions: z.number().describe('Total number of executions in this sandbox'),
|
|
17
23
|
stdoutStreamUrl: z.string().optional().describe('URL for streaming stdout output'),
|
|
18
24
|
stderrStreamUrl: z.string().optional().describe('URL for streaming stderr output'),
|
|
25
|
+
networkEnabled: z.boolean().optional().describe('Whether network access is enabled'),
|
|
19
26
|
})
|
|
20
27
|
.describe('Summary information about a sandbox');
|
|
21
28
|
|
|
@@ -30,6 +37,7 @@ const ListSandboxesResponseSchema = APIResponseSchema(ListSandboxesDataSchema);
|
|
|
30
37
|
|
|
31
38
|
export interface SandboxListParams extends ListSandboxesParams {
|
|
32
39
|
orgId?: string;
|
|
40
|
+
deletedOnly?: boolean;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
/**
|
|
@@ -64,6 +72,9 @@ export async function sandboxList(
|
|
|
64
72
|
if (params?.offset !== undefined) {
|
|
65
73
|
queryParams.set('offset', params.offset.toString());
|
|
66
74
|
}
|
|
75
|
+
if (params?.deletedOnly) {
|
|
76
|
+
queryParams.set('deletedOnly', 'true');
|
|
77
|
+
}
|
|
67
78
|
|
|
68
79
|
const queryString = queryParams.toString();
|
|
69
80
|
const url = `/sandbox/${API_VERSION}${queryString ? `?${queryString}` : ''}`;
|
|
@@ -77,14 +88,21 @@ export async function sandboxList(
|
|
|
77
88
|
return {
|
|
78
89
|
sandboxes: resp.data.sandboxes.map((s) => ({
|
|
79
90
|
sandboxId: s.sandboxId,
|
|
91
|
+
name: s.name,
|
|
92
|
+
description: s.description,
|
|
80
93
|
status: s.status as SandboxStatus,
|
|
94
|
+
mode: s.mode,
|
|
81
95
|
createdAt: s.createdAt,
|
|
82
96
|
region: s.region,
|
|
97
|
+
runtimeId: s.runtimeId,
|
|
98
|
+
runtimeName: s.runtimeName,
|
|
99
|
+
runtimeIconUrl: s.runtimeIconUrl,
|
|
83
100
|
snapshotId: s.snapshotId,
|
|
84
101
|
snapshotTag: s.snapshotTag,
|
|
85
102
|
executions: s.executions,
|
|
86
103
|
stdoutStreamUrl: s.stdoutStreamUrl,
|
|
87
104
|
stderrStreamUrl: s.stderrStreamUrl,
|
|
105
|
+
networkEnabled: s.networkEnabled,
|
|
88
106
|
})),
|
|
89
107
|
total: resp.data.total,
|
|
90
108
|
};
|
|
@@ -0,0 +1,77 @@
|
|
|
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((r): SandboxRuntime => ({
|
|
65
|
+
id: r.id,
|
|
66
|
+
name: r.name,
|
|
67
|
+
description: r.description,
|
|
68
|
+
iconUrl: r.iconUrl,
|
|
69
|
+
url: r.url,
|
|
70
|
+
tags: r.tags,
|
|
71
|
+
})),
|
|
72
|
+
total: resp.data.total,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
throw new SandboxResponseError({ message: resp.message });
|
|
77
|
+
}
|
|
@@ -12,7 +12,10 @@ 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.string().nullable().optional().describe('Runtime ID associated with this snapshot'),
|
|
16
|
+
name: z.string().describe('Display name for the snapshot (URL-safe: letters, numbers, underscores, dashes)'),
|
|
17
|
+
description: z.string().nullable().optional().describe('Description of the snapshot'),
|
|
18
|
+
tag: z.string().nullable().optional().describe('Tag for the snapshot (defaults to "latest")'),
|
|
16
19
|
sizeBytes: z.number().describe('Total size of the snapshot in bytes'),
|
|
17
20
|
fileCount: z.number().describe('Number of files in the snapshot'),
|
|
18
21
|
parentSnapshotId: z
|
|
@@ -22,7 +25,7 @@ const SnapshotInfoSchema = z
|
|
|
22
25
|
.describe('ID of the parent snapshot (for incremental snapshots)'),
|
|
23
26
|
createdAt: z.string().describe('ISO timestamp when the snapshot was created'),
|
|
24
27
|
downloadUrl: z.string().optional().describe('URL to download the snapshot archive'),
|
|
25
|
-
files: z.array(SnapshotFileInfoSchema).optional().describe('List of files in the snapshot'),
|
|
28
|
+
files: z.array(SnapshotFileInfoSchema).nullable().optional().describe('List of files in the snapshot'),
|
|
26
29
|
})
|
|
27
30
|
.describe('Detailed information about a snapshot');
|
|
28
31
|
|
|
@@ -44,17 +47,22 @@ export interface SnapshotFileInfo {
|
|
|
44
47
|
|
|
45
48
|
export interface SnapshotInfo {
|
|
46
49
|
snapshotId: string;
|
|
50
|
+
runtimeId?: string | null;
|
|
51
|
+
name: string;
|
|
52
|
+
description?: string | null;
|
|
47
53
|
tag?: string | null;
|
|
48
54
|
sizeBytes: number;
|
|
49
55
|
fileCount: number;
|
|
50
56
|
parentSnapshotId?: string | null;
|
|
51
57
|
createdAt: string;
|
|
52
58
|
downloadUrl?: string;
|
|
53
|
-
files?: SnapshotFileInfo[];
|
|
59
|
+
files?: SnapshotFileInfo[] | null;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
export interface SnapshotCreateParams {
|
|
57
63
|
sandboxId: string;
|
|
64
|
+
name?: string;
|
|
65
|
+
description?: string;
|
|
58
66
|
tag?: string;
|
|
59
67
|
orgId?: string;
|
|
60
68
|
}
|
|
@@ -110,11 +118,17 @@ export async function snapshotCreate(
|
|
|
110
118
|
client: APIClient,
|
|
111
119
|
params: SnapshotCreateParams
|
|
112
120
|
): Promise<SnapshotInfo> {
|
|
113
|
-
const { sandboxId, tag, orgId } = params;
|
|
121
|
+
const { sandboxId, name, description, tag, orgId } = params;
|
|
114
122
|
const queryString = buildQueryString({ orgId });
|
|
115
123
|
const url = `/sandbox/${API_VERSION}/${sandboxId}/snapshot${queryString}`;
|
|
116
124
|
|
|
117
125
|
const body: Record<string, string> = {};
|
|
126
|
+
if (name) {
|
|
127
|
+
body.name = name;
|
|
128
|
+
}
|
|
129
|
+
if (description) {
|
|
130
|
+
body.description = description;
|
|
131
|
+
}
|
|
118
132
|
if (tag) {
|
|
119
133
|
body.tag = tag;
|
|
120
134
|
}
|
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
|
|