@blaxel/core 0.2.0-dev1
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/LICENSE +21 -0
- package/dist/agents/index.d.ts +15 -0
- package/dist/agents/index.js +114 -0
- package/dist/authentication/apikey.d.ts +10 -0
- package/dist/authentication/apikey.js +24 -0
- package/dist/authentication/clientcredentials.d.ts +15 -0
- package/dist/authentication/clientcredentials.js +70 -0
- package/dist/authentication/credentials.d.ts +6 -0
- package/dist/authentication/credentials.js +17 -0
- package/dist/authentication/deviceMode.d.ts +15 -0
- package/dist/authentication/deviceMode.js +70 -0
- package/dist/authentication/index.d.ts +3 -0
- package/dist/authentication/index.js +63 -0
- package/dist/authentication/types.d.ts +9 -0
- package/dist/authentication/types.js +2 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.js +26 -0
- package/dist/client/authentication.d.ts +25 -0
- package/dist/client/authentication.js +15 -0
- package/dist/client/client.d.ts +2 -0
- package/dist/client/client.gen.d.ts +12 -0
- package/dist/client/client.gen.js +8 -0
- package/dist/client/client.js +17 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +19 -0
- package/dist/client/interceptors.d.ts +3 -0
- package/dist/client/interceptors.js +17 -0
- package/dist/client/sdk.gen.d.ts +410 -0
- package/dist/client/sdk.gen.js +1436 -0
- package/dist/client/types.gen.d.ts +3534 -0
- package/dist/client/types.gen.js +4 -0
- package/dist/common/autoload.d.ts +3 -0
- package/dist/common/autoload.js +27 -0
- package/dist/common/env.d.ts +5 -0
- package/dist/common/env.js +43 -0
- package/dist/common/errors.d.ts +1 -0
- package/dist/common/errors.js +17 -0
- package/dist/common/internal.d.ts +2 -0
- package/dist/common/internal.js +19 -0
- package/dist/common/logger.d.ts +1 -0
- package/dist/common/logger.js +4 -0
- package/dist/common/node.d.ts +3 -0
- package/dist/common/node.js +14 -0
- package/dist/common/settings.d.ts +26 -0
- package/dist/common/settings.js +84 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +30 -0
- package/dist/mcp/client.d.ts +19 -0
- package/dist/mcp/client.js +151 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +18 -0
- package/dist/mcp/server.d.ts +24 -0
- package/dist/mcp/server.js +213 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.js +31 -0
- package/dist/sandbox/action.d.ts +18 -0
- package/dist/sandbox/action.js +74 -0
- package/dist/sandbox/client/client.gen.d.ts +12 -0
- package/dist/sandbox/client/client.gen.js +6 -0
- package/dist/sandbox/client/index.d.ts +2 -0
- package/dist/sandbox/client/index.js +19 -0
- package/dist/sandbox/client/sdk.gen.d.ts +83 -0
- package/dist/sandbox/client/sdk.gen.js +153 -0
- package/dist/sandbox/client/types.gen.d.ts +410 -0
- package/dist/sandbox/client/types.gen.js +4 -0
- package/dist/sandbox/filesystem.d.ts +18 -0
- package/dist/sandbox/filesystem.js +121 -0
- package/dist/sandbox/index.d.ts +1 -0
- package/dist/sandbox/index.js +17 -0
- package/dist/sandbox/network.d.ts +5 -0
- package/dist/sandbox/network.js +10 -0
- package/dist/sandbox/process.d.ts +12 -0
- package/dist/sandbox/process.js +61 -0
- package/dist/sandbox/sandbox.d.ts +23 -0
- package/dist/sandbox/sandbox.js +92 -0
- package/dist/telemetry/telemetry.d.ts +58 -0
- package/dist/telemetry/telemetry.js +59 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/mcpTool.d.ts +21 -0
- package/dist/tools/mcpTool.js +193 -0
- package/dist/tools/types.d.ts +8 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/zodSchema.d.ts +9 -0
- package/dist/tools/zodSchema.js +46 -0
- package/package.json +76 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
export type ErrorResponse = {
|
|
2
|
+
error?: string;
|
|
3
|
+
};
|
|
4
|
+
export type File = {
|
|
5
|
+
group?: string;
|
|
6
|
+
lastModified?: string;
|
|
7
|
+
owner?: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
/**
|
|
10
|
+
* swagger:strfmt string
|
|
11
|
+
*/
|
|
12
|
+
permissions?: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
};
|
|
15
|
+
export type FileRequest = {
|
|
16
|
+
content?: string;
|
|
17
|
+
isDirectory?: boolean;
|
|
18
|
+
permissions?: string;
|
|
19
|
+
};
|
|
20
|
+
export type PortMonitorRequest = {
|
|
21
|
+
/**
|
|
22
|
+
* URL to call when a new port is detected
|
|
23
|
+
*/
|
|
24
|
+
callback?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ProcessKillRequest = {
|
|
27
|
+
signal?: string;
|
|
28
|
+
};
|
|
29
|
+
export type ProcessRequest = {
|
|
30
|
+
command: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
streamLogs?: boolean;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
waitForCompletion?: boolean;
|
|
35
|
+
waitForPorts?: Array<number>;
|
|
36
|
+
workingDir?: string;
|
|
37
|
+
};
|
|
38
|
+
export type ProcessResponse = {
|
|
39
|
+
command?: string;
|
|
40
|
+
completedAt?: string;
|
|
41
|
+
exitCode?: number;
|
|
42
|
+
name?: string;
|
|
43
|
+
pid?: string;
|
|
44
|
+
startedAt?: string;
|
|
45
|
+
status?: string;
|
|
46
|
+
workingDir?: string;
|
|
47
|
+
};
|
|
48
|
+
export type SuccessResponse = {
|
|
49
|
+
message?: string;
|
|
50
|
+
path?: string;
|
|
51
|
+
};
|
|
52
|
+
export type Directory = {
|
|
53
|
+
files?: Array<File>;
|
|
54
|
+
path?: string;
|
|
55
|
+
/**
|
|
56
|
+
* @name Subdirectories
|
|
57
|
+
*/
|
|
58
|
+
subdirectories?: Array<Directory>;
|
|
59
|
+
};
|
|
60
|
+
export type DeleteFilesystemByPathData = {
|
|
61
|
+
body?: never;
|
|
62
|
+
path: {
|
|
63
|
+
/**
|
|
64
|
+
* File or directory path
|
|
65
|
+
*/
|
|
66
|
+
path: string;
|
|
67
|
+
};
|
|
68
|
+
query?: {
|
|
69
|
+
/**
|
|
70
|
+
* Delete directory recursively
|
|
71
|
+
*/
|
|
72
|
+
recursive?: boolean;
|
|
73
|
+
};
|
|
74
|
+
url: '/filesystem/{path}';
|
|
75
|
+
};
|
|
76
|
+
export type DeleteFilesystemByPathErrors = {
|
|
77
|
+
/**
|
|
78
|
+
* File or directory not found
|
|
79
|
+
*/
|
|
80
|
+
404: ErrorResponse;
|
|
81
|
+
/**
|
|
82
|
+
* Internal server error
|
|
83
|
+
*/
|
|
84
|
+
500: ErrorResponse;
|
|
85
|
+
};
|
|
86
|
+
export type DeleteFilesystemByPathError = DeleteFilesystemByPathErrors[keyof DeleteFilesystemByPathErrors];
|
|
87
|
+
export type DeleteFilesystemByPathResponses = {
|
|
88
|
+
/**
|
|
89
|
+
* Success message
|
|
90
|
+
*/
|
|
91
|
+
200: SuccessResponse;
|
|
92
|
+
};
|
|
93
|
+
export type DeleteFilesystemByPathResponse = DeleteFilesystemByPathResponses[keyof DeleteFilesystemByPathResponses];
|
|
94
|
+
export type GetFilesystemByPathData = {
|
|
95
|
+
body?: never;
|
|
96
|
+
path: {
|
|
97
|
+
/**
|
|
98
|
+
* File or directory path
|
|
99
|
+
*/
|
|
100
|
+
path: string;
|
|
101
|
+
};
|
|
102
|
+
query?: never;
|
|
103
|
+
url: '/filesystem/{path}';
|
|
104
|
+
};
|
|
105
|
+
export type GetFilesystemByPathErrors = {
|
|
106
|
+
/**
|
|
107
|
+
* File or directory not found
|
|
108
|
+
*/
|
|
109
|
+
404: ErrorResponse;
|
|
110
|
+
/**
|
|
111
|
+
* Internal server error
|
|
112
|
+
*/
|
|
113
|
+
500: ErrorResponse;
|
|
114
|
+
};
|
|
115
|
+
export type GetFilesystemByPathError = GetFilesystemByPathErrors[keyof GetFilesystemByPathErrors];
|
|
116
|
+
export type GetFilesystemByPathResponses = {
|
|
117
|
+
/**
|
|
118
|
+
* Directory listing
|
|
119
|
+
*/
|
|
120
|
+
200: Directory;
|
|
121
|
+
};
|
|
122
|
+
export type GetFilesystemByPathResponse = GetFilesystemByPathResponses[keyof GetFilesystemByPathResponses];
|
|
123
|
+
export type PutFilesystemByPathData = {
|
|
124
|
+
/**
|
|
125
|
+
* File or directory information
|
|
126
|
+
*/
|
|
127
|
+
body: FileRequest;
|
|
128
|
+
path: {
|
|
129
|
+
/**
|
|
130
|
+
* File or directory path
|
|
131
|
+
*/
|
|
132
|
+
path: string;
|
|
133
|
+
};
|
|
134
|
+
query?: never;
|
|
135
|
+
url: '/filesystem/{path}';
|
|
136
|
+
};
|
|
137
|
+
export type PutFilesystemByPathErrors = {
|
|
138
|
+
/**
|
|
139
|
+
* Invalid request
|
|
140
|
+
*/
|
|
141
|
+
400: ErrorResponse;
|
|
142
|
+
/**
|
|
143
|
+
* Internal server error
|
|
144
|
+
*/
|
|
145
|
+
500: ErrorResponse;
|
|
146
|
+
};
|
|
147
|
+
export type PutFilesystemByPathError = PutFilesystemByPathErrors[keyof PutFilesystemByPathErrors];
|
|
148
|
+
export type PutFilesystemByPathResponses = {
|
|
149
|
+
/**
|
|
150
|
+
* Success message
|
|
151
|
+
*/
|
|
152
|
+
200: SuccessResponse;
|
|
153
|
+
};
|
|
154
|
+
export type PutFilesystemByPathResponse = PutFilesystemByPathResponses[keyof PutFilesystemByPathResponses];
|
|
155
|
+
export type DeleteNetworkProcessByPidMonitorData = {
|
|
156
|
+
body?: never;
|
|
157
|
+
path: {
|
|
158
|
+
/**
|
|
159
|
+
* Process ID
|
|
160
|
+
*/
|
|
161
|
+
pid: number;
|
|
162
|
+
};
|
|
163
|
+
query?: never;
|
|
164
|
+
url: '/network/process/{pid}/monitor';
|
|
165
|
+
};
|
|
166
|
+
export type DeleteNetworkProcessByPidMonitorErrors = {
|
|
167
|
+
/**
|
|
168
|
+
* Invalid process ID
|
|
169
|
+
*/
|
|
170
|
+
400: ErrorResponse;
|
|
171
|
+
/**
|
|
172
|
+
* Internal server error
|
|
173
|
+
*/
|
|
174
|
+
500: ErrorResponse;
|
|
175
|
+
};
|
|
176
|
+
export type DeleteNetworkProcessByPidMonitorError = DeleteNetworkProcessByPidMonitorErrors[keyof DeleteNetworkProcessByPidMonitorErrors];
|
|
177
|
+
export type DeleteNetworkProcessByPidMonitorResponses = {
|
|
178
|
+
/**
|
|
179
|
+
* Object containing PID and success message
|
|
180
|
+
*/
|
|
181
|
+
200: {
|
|
182
|
+
[key: string]: unknown;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
export type DeleteNetworkProcessByPidMonitorResponse = DeleteNetworkProcessByPidMonitorResponses[keyof DeleteNetworkProcessByPidMonitorResponses];
|
|
186
|
+
export type PostNetworkProcessByPidMonitorData = {
|
|
187
|
+
/**
|
|
188
|
+
* Port monitor configuration
|
|
189
|
+
*/
|
|
190
|
+
body: PortMonitorRequest;
|
|
191
|
+
path: {
|
|
192
|
+
/**
|
|
193
|
+
* Process ID
|
|
194
|
+
*/
|
|
195
|
+
pid: number;
|
|
196
|
+
};
|
|
197
|
+
query?: never;
|
|
198
|
+
url: '/network/process/{pid}/monitor';
|
|
199
|
+
};
|
|
200
|
+
export type PostNetworkProcessByPidMonitorErrors = {
|
|
201
|
+
/**
|
|
202
|
+
* Invalid request
|
|
203
|
+
*/
|
|
204
|
+
400: ErrorResponse;
|
|
205
|
+
/**
|
|
206
|
+
* Internal server error
|
|
207
|
+
*/
|
|
208
|
+
500: ErrorResponse;
|
|
209
|
+
};
|
|
210
|
+
export type PostNetworkProcessByPidMonitorError = PostNetworkProcessByPidMonitorErrors[keyof PostNetworkProcessByPidMonitorErrors];
|
|
211
|
+
export type PostNetworkProcessByPidMonitorResponses = {
|
|
212
|
+
/**
|
|
213
|
+
* Object containing PID and success message
|
|
214
|
+
*/
|
|
215
|
+
200: {
|
|
216
|
+
[key: string]: unknown;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
export type PostNetworkProcessByPidMonitorResponse = PostNetworkProcessByPidMonitorResponses[keyof PostNetworkProcessByPidMonitorResponses];
|
|
220
|
+
export type GetNetworkProcessByPidPortsData = {
|
|
221
|
+
body?: never;
|
|
222
|
+
path: {
|
|
223
|
+
/**
|
|
224
|
+
* Process ID
|
|
225
|
+
*/
|
|
226
|
+
pid: number;
|
|
227
|
+
};
|
|
228
|
+
query?: never;
|
|
229
|
+
url: '/network/process/{pid}/ports';
|
|
230
|
+
};
|
|
231
|
+
export type GetNetworkProcessByPidPortsErrors = {
|
|
232
|
+
/**
|
|
233
|
+
* Invalid process ID
|
|
234
|
+
*/
|
|
235
|
+
400: ErrorResponse;
|
|
236
|
+
/**
|
|
237
|
+
* Internal server error
|
|
238
|
+
*/
|
|
239
|
+
500: ErrorResponse;
|
|
240
|
+
};
|
|
241
|
+
export type GetNetworkProcessByPidPortsError = GetNetworkProcessByPidPortsErrors[keyof GetNetworkProcessByPidPortsErrors];
|
|
242
|
+
export type GetNetworkProcessByPidPortsResponses = {
|
|
243
|
+
/**
|
|
244
|
+
* Object containing PID and array of network.PortInfo
|
|
245
|
+
*/
|
|
246
|
+
200: {
|
|
247
|
+
[key: string]: unknown;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
export type GetNetworkProcessByPidPortsResponse = GetNetworkProcessByPidPortsResponses[keyof GetNetworkProcessByPidPortsResponses];
|
|
251
|
+
export type GetProcessData = {
|
|
252
|
+
body?: never;
|
|
253
|
+
path?: never;
|
|
254
|
+
query?: never;
|
|
255
|
+
url: '/process';
|
|
256
|
+
};
|
|
257
|
+
export type GetProcessResponses = {
|
|
258
|
+
/**
|
|
259
|
+
* Process list
|
|
260
|
+
*/
|
|
261
|
+
200: Array<ProcessResponse>;
|
|
262
|
+
};
|
|
263
|
+
export type GetProcessResponse = GetProcessResponses[keyof GetProcessResponses];
|
|
264
|
+
export type PostProcessData = {
|
|
265
|
+
/**
|
|
266
|
+
* Process execution request
|
|
267
|
+
*/
|
|
268
|
+
body: ProcessRequest;
|
|
269
|
+
path?: never;
|
|
270
|
+
query?: never;
|
|
271
|
+
url: '/process';
|
|
272
|
+
};
|
|
273
|
+
export type PostProcessErrors = {
|
|
274
|
+
/**
|
|
275
|
+
* Invalid request
|
|
276
|
+
*/
|
|
277
|
+
400: ErrorResponse;
|
|
278
|
+
/**
|
|
279
|
+
* Internal server error
|
|
280
|
+
*/
|
|
281
|
+
500: ErrorResponse;
|
|
282
|
+
};
|
|
283
|
+
export type PostProcessError = PostProcessErrors[keyof PostProcessErrors];
|
|
284
|
+
export type PostProcessResponses = {
|
|
285
|
+
/**
|
|
286
|
+
* Process information
|
|
287
|
+
*/
|
|
288
|
+
200: ProcessResponse;
|
|
289
|
+
};
|
|
290
|
+
export type PostProcessResponse = PostProcessResponses[keyof PostProcessResponses];
|
|
291
|
+
export type DeleteProcessByIdentifierData = {
|
|
292
|
+
body?: never;
|
|
293
|
+
path: {
|
|
294
|
+
/**
|
|
295
|
+
* Process identifier (PID or name)
|
|
296
|
+
*/
|
|
297
|
+
identifier: string;
|
|
298
|
+
};
|
|
299
|
+
query?: never;
|
|
300
|
+
url: '/process/{identifier}';
|
|
301
|
+
};
|
|
302
|
+
export type DeleteProcessByIdentifierErrors = {
|
|
303
|
+
/**
|
|
304
|
+
* Process not found
|
|
305
|
+
*/
|
|
306
|
+
404: ErrorResponse;
|
|
307
|
+
/**
|
|
308
|
+
* Internal server error
|
|
309
|
+
*/
|
|
310
|
+
500: ErrorResponse;
|
|
311
|
+
};
|
|
312
|
+
export type DeleteProcessByIdentifierError = DeleteProcessByIdentifierErrors[keyof DeleteProcessByIdentifierErrors];
|
|
313
|
+
export type DeleteProcessByIdentifierResponses = {
|
|
314
|
+
/**
|
|
315
|
+
* Process stopped
|
|
316
|
+
*/
|
|
317
|
+
200: SuccessResponse;
|
|
318
|
+
};
|
|
319
|
+
export type DeleteProcessByIdentifierResponse = DeleteProcessByIdentifierResponses[keyof DeleteProcessByIdentifierResponses];
|
|
320
|
+
export type GetProcessByIdentifierData = {
|
|
321
|
+
body?: never;
|
|
322
|
+
path: {
|
|
323
|
+
/**
|
|
324
|
+
* Process identifier (PID or name)
|
|
325
|
+
*/
|
|
326
|
+
identifier: string;
|
|
327
|
+
};
|
|
328
|
+
query?: never;
|
|
329
|
+
url: '/process/{identifier}';
|
|
330
|
+
};
|
|
331
|
+
export type GetProcessByIdentifierErrors = {
|
|
332
|
+
/**
|
|
333
|
+
* Process not found
|
|
334
|
+
*/
|
|
335
|
+
404: ErrorResponse;
|
|
336
|
+
};
|
|
337
|
+
export type GetProcessByIdentifierError = GetProcessByIdentifierErrors[keyof GetProcessByIdentifierErrors];
|
|
338
|
+
export type GetProcessByIdentifierResponses = {
|
|
339
|
+
/**
|
|
340
|
+
* Process information
|
|
341
|
+
*/
|
|
342
|
+
200: ProcessResponse;
|
|
343
|
+
};
|
|
344
|
+
export type GetProcessByIdentifierResponse = GetProcessByIdentifierResponses[keyof GetProcessByIdentifierResponses];
|
|
345
|
+
export type DeleteProcessByIdentifierKillData = {
|
|
346
|
+
/**
|
|
347
|
+
* Kill options
|
|
348
|
+
*/
|
|
349
|
+
body?: ProcessKillRequest;
|
|
350
|
+
path: {
|
|
351
|
+
/**
|
|
352
|
+
* Process identifier (PID or name)
|
|
353
|
+
*/
|
|
354
|
+
identifier: string;
|
|
355
|
+
};
|
|
356
|
+
query?: never;
|
|
357
|
+
url: '/process/{identifier}/kill';
|
|
358
|
+
};
|
|
359
|
+
export type DeleteProcessByIdentifierKillErrors = {
|
|
360
|
+
/**
|
|
361
|
+
* Process not found
|
|
362
|
+
*/
|
|
363
|
+
404: ErrorResponse;
|
|
364
|
+
/**
|
|
365
|
+
* Internal server error
|
|
366
|
+
*/
|
|
367
|
+
500: ErrorResponse;
|
|
368
|
+
};
|
|
369
|
+
export type DeleteProcessByIdentifierKillError = DeleteProcessByIdentifierKillErrors[keyof DeleteProcessByIdentifierKillErrors];
|
|
370
|
+
export type DeleteProcessByIdentifierKillResponses = {
|
|
371
|
+
/**
|
|
372
|
+
* Process killed
|
|
373
|
+
*/
|
|
374
|
+
200: SuccessResponse;
|
|
375
|
+
};
|
|
376
|
+
export type DeleteProcessByIdentifierKillResponse = DeleteProcessByIdentifierKillResponses[keyof DeleteProcessByIdentifierKillResponses];
|
|
377
|
+
export type GetProcessByIdentifierLogsData = {
|
|
378
|
+
body?: never;
|
|
379
|
+
path: {
|
|
380
|
+
/**
|
|
381
|
+
* Process identifier (PID or name)
|
|
382
|
+
*/
|
|
383
|
+
identifier: string;
|
|
384
|
+
};
|
|
385
|
+
query?: never;
|
|
386
|
+
url: '/process/{identifier}/logs';
|
|
387
|
+
};
|
|
388
|
+
export type GetProcessByIdentifierLogsErrors = {
|
|
389
|
+
/**
|
|
390
|
+
* Process not found
|
|
391
|
+
*/
|
|
392
|
+
404: ErrorResponse;
|
|
393
|
+
/**
|
|
394
|
+
* Internal server error
|
|
395
|
+
*/
|
|
396
|
+
500: ErrorResponse;
|
|
397
|
+
};
|
|
398
|
+
export type GetProcessByIdentifierLogsError = GetProcessByIdentifierLogsErrors[keyof GetProcessByIdentifierLogsErrors];
|
|
399
|
+
export type GetProcessByIdentifierLogsResponses = {
|
|
400
|
+
/**
|
|
401
|
+
* Process logs
|
|
402
|
+
*/
|
|
403
|
+
200: {
|
|
404
|
+
[key: string]: string;
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
export type GetProcessByIdentifierLogsResponse = GetProcessByIdentifierLogsResponses[keyof GetProcessByIdentifierLogsResponses];
|
|
408
|
+
export type ClientOptions = {
|
|
409
|
+
baseUrl: `${string}://localhost:8080` | (string & {});
|
|
410
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Sandbox } from "../client/types.gen.js";
|
|
2
|
+
import { SandboxAction } from "./action.js";
|
|
3
|
+
import { Directory, SuccessResponse } from "./client/index.js";
|
|
4
|
+
export type CopyResponse = {
|
|
5
|
+
message: string;
|
|
6
|
+
source: string;
|
|
7
|
+
destination: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class SandboxFileSystem extends SandboxAction {
|
|
10
|
+
constructor(sandbox: Sandbox);
|
|
11
|
+
mkdir(path: string, permissions?: string): Promise<SuccessResponse>;
|
|
12
|
+
write(path: string, content: string): Promise<SuccessResponse>;
|
|
13
|
+
read(path: string): Promise<string>;
|
|
14
|
+
rm(path: string, recursive?: boolean): Promise<SuccessResponse>;
|
|
15
|
+
ls(path: string): Promise<Directory>;
|
|
16
|
+
cp(source: string, destination: string): Promise<CopyResponse>;
|
|
17
|
+
private formatPath;
|
|
18
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxFileSystem = void 0;
|
|
4
|
+
const action_js_1 = require("./action.js");
|
|
5
|
+
const index_js_1 = require("./client/index.js");
|
|
6
|
+
class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
7
|
+
constructor(sandbox) {
|
|
8
|
+
super(sandbox);
|
|
9
|
+
}
|
|
10
|
+
async mkdir(path, permissions = "0755") {
|
|
11
|
+
path = this.formatPath(path);
|
|
12
|
+
const { response, data, error } = await (0, index_js_1.putFilesystemByPath)({
|
|
13
|
+
path: { path },
|
|
14
|
+
body: { isDirectory: true, permissions },
|
|
15
|
+
baseUrl: this.url,
|
|
16
|
+
});
|
|
17
|
+
this.handleResponseError(response, data, error);
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
async write(path, content) {
|
|
21
|
+
path = this.formatPath(path);
|
|
22
|
+
const { response, data, error } = await (0, index_js_1.putFilesystemByPath)({
|
|
23
|
+
path: { path },
|
|
24
|
+
body: { content },
|
|
25
|
+
baseUrl: this.url,
|
|
26
|
+
});
|
|
27
|
+
this.handleResponseError(response, data, error);
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
async read(path) {
|
|
31
|
+
path = this.formatPath(path);
|
|
32
|
+
const { response, data, error } = await (0, index_js_1.getFilesystemByPath)({
|
|
33
|
+
path: { path },
|
|
34
|
+
baseUrl: this.url,
|
|
35
|
+
});
|
|
36
|
+
this.handleResponseError(response, data, error);
|
|
37
|
+
if (data && 'content' in data) {
|
|
38
|
+
return data.content;
|
|
39
|
+
}
|
|
40
|
+
throw new Error("Unsupported file type");
|
|
41
|
+
}
|
|
42
|
+
async rm(path, recursive = false) {
|
|
43
|
+
path = this.formatPath(path);
|
|
44
|
+
const { response, data, error } = await (0, index_js_1.deleteFilesystemByPath)({
|
|
45
|
+
path: { path },
|
|
46
|
+
query: { recursive },
|
|
47
|
+
baseUrl: this.url,
|
|
48
|
+
});
|
|
49
|
+
this.handleResponseError(response, data, error);
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
async ls(path) {
|
|
53
|
+
path = this.formatPath(path);
|
|
54
|
+
const { response, data, error } = await (0, index_js_1.getFilesystemByPath)({
|
|
55
|
+
path: { path },
|
|
56
|
+
baseUrl: this.url,
|
|
57
|
+
});
|
|
58
|
+
this.handleResponseError(response, data, error);
|
|
59
|
+
if (!data || !('files' in data || 'subdirectories' in data)) {
|
|
60
|
+
throw new Error(JSON.stringify({ error: "Directory not found" }));
|
|
61
|
+
}
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
async cp(source, destination) {
|
|
65
|
+
source = this.formatPath(source);
|
|
66
|
+
destination = this.formatPath(destination);
|
|
67
|
+
const { response, data, error } = await (0, index_js_1.getFilesystemByPath)({
|
|
68
|
+
path: { path: source },
|
|
69
|
+
baseUrl: this.url,
|
|
70
|
+
});
|
|
71
|
+
this.handleResponseError(response, data, error);
|
|
72
|
+
if (data && ('files' in data || 'subdirectories' in data)) {
|
|
73
|
+
// Create destination directory
|
|
74
|
+
await this.mkdir(destination);
|
|
75
|
+
// Process subdirectories in batches of 5
|
|
76
|
+
const subdirectories = data.subdirectories || [];
|
|
77
|
+
for (let i = 0; i < subdirectories.length; i += 5) {
|
|
78
|
+
const batch = subdirectories.slice(i, i + 5);
|
|
79
|
+
await Promise.all(batch.map(async (subdir) => {
|
|
80
|
+
const sourcePath = subdir.path || `${source}/${subdir.path}`;
|
|
81
|
+
const destPath = `${destination}/${subdir.path}`;
|
|
82
|
+
await this.cp(sourcePath, destPath);
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
// Process files in batches of 10
|
|
86
|
+
const files = data.files || [];
|
|
87
|
+
for (let i = 0; i < files.length; i += 10) {
|
|
88
|
+
const batch = files.slice(i, i + 10);
|
|
89
|
+
await Promise.all(batch.map(async (file) => {
|
|
90
|
+
const sourcePath = file.path || `${source}/${file.path}`;
|
|
91
|
+
const destPath = `${destination}/${file.path}`;
|
|
92
|
+
const fileContent = await this.read(sourcePath);
|
|
93
|
+
if (typeof fileContent === 'string') {
|
|
94
|
+
await this.write(destPath, fileContent);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
message: "Directory copied successfully",
|
|
100
|
+
source,
|
|
101
|
+
destination,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else if (data && 'content' in data) {
|
|
105
|
+
await this.write(destination, data.content);
|
|
106
|
+
return {
|
|
107
|
+
message: "File copied successfully",
|
|
108
|
+
source,
|
|
109
|
+
destination,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
throw new Error("Unsupported file type");
|
|
113
|
+
}
|
|
114
|
+
formatPath(path) {
|
|
115
|
+
if (path.startsWith("/")) {
|
|
116
|
+
path = path.slice(1);
|
|
117
|
+
}
|
|
118
|
+
return path;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.SandboxFileSystem = SandboxFileSystem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./sandbox.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./sandbox.js"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxNetwork = void 0;
|
|
4
|
+
const action_js_1 = require("./action.js");
|
|
5
|
+
class SandboxNetwork extends action_js_1.SandboxAction {
|
|
6
|
+
constructor(sandbox) {
|
|
7
|
+
super(sandbox);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SandboxNetwork = SandboxNetwork;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Sandbox } from "../client/types.gen.js";
|
|
2
|
+
import { SandboxAction } from "./action.js";
|
|
3
|
+
import { DeleteProcessByIdentifierKillResponse, DeleteProcessByIdentifierResponse, GetProcessByIdentifierResponse, GetProcessResponse, PostProcessResponse, ProcessRequest } from "./client/index.js";
|
|
4
|
+
export declare class SandboxProcess extends SandboxAction {
|
|
5
|
+
constructor(sandbox: Sandbox);
|
|
6
|
+
exec(process: ProcessRequest): Promise<PostProcessResponse>;
|
|
7
|
+
get(identifier: string): Promise<GetProcessByIdentifierResponse>;
|
|
8
|
+
list(): Promise<GetProcessResponse>;
|
|
9
|
+
stop(identifier: string): Promise<DeleteProcessByIdentifierResponse>;
|
|
10
|
+
kill(identifier: string): Promise<DeleteProcessByIdentifierKillResponse>;
|
|
11
|
+
logs(identifier: string, type?: "stdout" | "stderr"): Promise<string>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxProcess = void 0;
|
|
4
|
+
const action_js_1 = require("./action.js");
|
|
5
|
+
const index_js_1 = require("./client/index.js");
|
|
6
|
+
class SandboxProcess extends action_js_1.SandboxAction {
|
|
7
|
+
constructor(sandbox) {
|
|
8
|
+
super(sandbox);
|
|
9
|
+
}
|
|
10
|
+
async exec(process) {
|
|
11
|
+
const { response, data, error } = await (0, index_js_1.postProcess)({
|
|
12
|
+
body: process,
|
|
13
|
+
baseUrl: this.url,
|
|
14
|
+
});
|
|
15
|
+
this.handleResponseError(response, data, error);
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
async get(identifier) {
|
|
19
|
+
const { response, data, error } = await (0, index_js_1.getProcessByIdentifier)({
|
|
20
|
+
path: { identifier },
|
|
21
|
+
baseUrl: this.url,
|
|
22
|
+
});
|
|
23
|
+
this.handleResponseError(response, data, error);
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
async list() {
|
|
27
|
+
const { response, data, error } = await (0, index_js_1.getProcess)({
|
|
28
|
+
baseUrl: this.url,
|
|
29
|
+
});
|
|
30
|
+
this.handleResponseError(response, data, error);
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
async stop(identifier) {
|
|
34
|
+
const { response, data, error } = await (0, index_js_1.deleteProcessByIdentifier)({
|
|
35
|
+
path: { identifier },
|
|
36
|
+
baseUrl: this.url,
|
|
37
|
+
});
|
|
38
|
+
this.handleResponseError(response, data, error);
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
async kill(identifier) {
|
|
42
|
+
const { response, data, error } = await (0, index_js_1.deleteProcessByIdentifierKill)({
|
|
43
|
+
path: { identifier },
|
|
44
|
+
baseUrl: this.url,
|
|
45
|
+
});
|
|
46
|
+
this.handleResponseError(response, data, error);
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
async logs(identifier, type = "stdout") {
|
|
50
|
+
const { response, data, error } = await (0, index_js_1.getProcessByIdentifierLogs)({
|
|
51
|
+
path: { identifier },
|
|
52
|
+
baseUrl: this.url,
|
|
53
|
+
});
|
|
54
|
+
this.handleResponseError(response, data, error);
|
|
55
|
+
if (data && type in data) {
|
|
56
|
+
return data[type];
|
|
57
|
+
}
|
|
58
|
+
throw new Error("Unsupported log type");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.SandboxProcess = SandboxProcess;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Sandbox as SandboxModel } from "../client/index.js";
|
|
2
|
+
import { SandboxFileSystem } from "./filesystem.js";
|
|
3
|
+
import { SandboxNetwork } from "./network.js";
|
|
4
|
+
import { SandboxProcess } from "./process.js";
|
|
5
|
+
export declare class SandboxInstance {
|
|
6
|
+
private sandbox;
|
|
7
|
+
fs: SandboxFileSystem;
|
|
8
|
+
network: SandboxNetwork;
|
|
9
|
+
process: SandboxProcess;
|
|
10
|
+
constructor(sandbox: SandboxModel);
|
|
11
|
+
get metadata(): import("../client/types.gen.js").Metadata | undefined;
|
|
12
|
+
get status(): string | undefined;
|
|
13
|
+
get events(): import("../client/types.gen.js").CoreEvents | undefined;
|
|
14
|
+
get spec(): import("../client/types.gen.js").CoreSpec | undefined;
|
|
15
|
+
wait({ maxWait, interval }?: {
|
|
16
|
+
maxWait?: number;
|
|
17
|
+
interval?: number;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
static create(sandbox: SandboxModel): Promise<SandboxInstance>;
|
|
20
|
+
static get(sandboxName: string): Promise<SandboxInstance>;
|
|
21
|
+
static list(): Promise<SandboxInstance[]>;
|
|
22
|
+
static delete(sandboxName: string): Promise<SandboxModel>;
|
|
23
|
+
}
|