rl-rock 1.2.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/dist/index.d.mts +1308 -0
- package/dist/index.d.ts +1308 -0
- package/dist/index.js +2037 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1950 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +61 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1308 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ChildProcess } from 'child_process';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ROCK status codes enumeration
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Status codes with phrase descriptions
|
|
9
|
+
*/
|
|
10
|
+
declare enum Codes {
|
|
11
|
+
/**
|
|
12
|
+
* Success codes (2xxx)
|
|
13
|
+
*/
|
|
14
|
+
OK = 2000,
|
|
15
|
+
/**
|
|
16
|
+
* Client error codes (4xxx)
|
|
17
|
+
*/
|
|
18
|
+
BAD_REQUEST = 4000,
|
|
19
|
+
/**
|
|
20
|
+
* Server error codes (5xxx)
|
|
21
|
+
*/
|
|
22
|
+
INTERNAL_SERVER_ERROR = 5000,
|
|
23
|
+
/**
|
|
24
|
+
* Command/execution error codes (6xxx)
|
|
25
|
+
*/
|
|
26
|
+
COMMAND_ERROR = 6000
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Human-readable reason phrases for status codes
|
|
30
|
+
*/
|
|
31
|
+
declare const ReasonPhrases: Record<Codes, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the reason phrase for a given status code
|
|
34
|
+
*/
|
|
35
|
+
declare function getReasonPhrase(code: Codes): string;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a status code indicates success (2xxx range)
|
|
38
|
+
*/
|
|
39
|
+
declare function isSuccess(code: Codes): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a status code indicates a client error (4xxx range)
|
|
42
|
+
*/
|
|
43
|
+
declare function isClientError(code: Codes): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a status code indicates a server error (5xxx range)
|
|
46
|
+
*/
|
|
47
|
+
declare function isServerError(code: Codes): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a status code indicates a command error (6xxx range)
|
|
50
|
+
*/
|
|
51
|
+
declare function isCommandError(code: Codes): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a status code indicates any kind of error
|
|
54
|
+
*/
|
|
55
|
+
declare function isError(code: Codes): boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Request types
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Command execution request
|
|
63
|
+
*/
|
|
64
|
+
declare const CommandSchema: z.ZodObject<{
|
|
65
|
+
command: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
66
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
67
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
68
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
command: string | string[];
|
|
71
|
+
timeout: number;
|
|
72
|
+
env?: Record<string, string> | undefined;
|
|
73
|
+
cwd?: string | undefined;
|
|
74
|
+
}, {
|
|
75
|
+
command: string | string[];
|
|
76
|
+
timeout?: number | undefined;
|
|
77
|
+
env?: Record<string, string> | undefined;
|
|
78
|
+
cwd?: string | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
type Command = z.infer<typeof CommandSchema>;
|
|
81
|
+
/**
|
|
82
|
+
* Bash session creation request
|
|
83
|
+
*/
|
|
84
|
+
declare const CreateBashSessionRequestSchema: z.ZodObject<{
|
|
85
|
+
session: z.ZodDefault<z.ZodString>;
|
|
86
|
+
startupSource: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
87
|
+
envEnable: z.ZodDefault<z.ZodBoolean>;
|
|
88
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
89
|
+
remoteUser: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
session: string;
|
|
92
|
+
startupSource: string[];
|
|
93
|
+
envEnable: boolean;
|
|
94
|
+
env?: Record<string, string> | undefined;
|
|
95
|
+
remoteUser?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
env?: Record<string, string> | undefined;
|
|
98
|
+
session?: string | undefined;
|
|
99
|
+
startupSource?: string[] | undefined;
|
|
100
|
+
envEnable?: boolean | undefined;
|
|
101
|
+
remoteUser?: string | undefined;
|
|
102
|
+
}>;
|
|
103
|
+
type CreateBashSessionRequest = z.infer<typeof CreateBashSessionRequestSchema>;
|
|
104
|
+
/**
|
|
105
|
+
* Bash action for session execution
|
|
106
|
+
*/
|
|
107
|
+
declare const BashActionSchema: z.ZodObject<{
|
|
108
|
+
command: z.ZodString;
|
|
109
|
+
session: z.ZodDefault<z.ZodString>;
|
|
110
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
check: z.ZodDefault<z.ZodEnum<["silent", "raise", "ignore"]>>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
command: string;
|
|
114
|
+
session: string;
|
|
115
|
+
check: "silent" | "raise" | "ignore";
|
|
116
|
+
timeout?: number | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
command: string;
|
|
119
|
+
timeout?: number | undefined;
|
|
120
|
+
session?: string | undefined;
|
|
121
|
+
check?: "silent" | "raise" | "ignore" | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
type BashAction = z.infer<typeof BashActionSchema>;
|
|
124
|
+
/**
|
|
125
|
+
* Write file request
|
|
126
|
+
*/
|
|
127
|
+
declare const WriteFileRequestSchema: z.ZodObject<{
|
|
128
|
+
content: z.ZodString;
|
|
129
|
+
path: z.ZodString;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
path: string;
|
|
132
|
+
content: string;
|
|
133
|
+
}, {
|
|
134
|
+
path: string;
|
|
135
|
+
content: string;
|
|
136
|
+
}>;
|
|
137
|
+
type WriteFileRequest = z.infer<typeof WriteFileRequestSchema>;
|
|
138
|
+
/**
|
|
139
|
+
* Read file request
|
|
140
|
+
*/
|
|
141
|
+
declare const ReadFileRequestSchema: z.ZodObject<{
|
|
142
|
+
path: z.ZodString;
|
|
143
|
+
encoding: z.ZodOptional<z.ZodString>;
|
|
144
|
+
errors: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
path: string;
|
|
147
|
+
encoding?: string | undefined;
|
|
148
|
+
errors?: string | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
path: string;
|
|
151
|
+
encoding?: string | undefined;
|
|
152
|
+
errors?: string | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
type ReadFileRequest = z.infer<typeof ReadFileRequestSchema>;
|
|
155
|
+
/**
|
|
156
|
+
* Upload file request
|
|
157
|
+
*/
|
|
158
|
+
declare const UploadRequestSchema: z.ZodObject<{
|
|
159
|
+
sourcePath: z.ZodString;
|
|
160
|
+
targetPath: z.ZodString;
|
|
161
|
+
}, "strip", z.ZodTypeAny, {
|
|
162
|
+
sourcePath: string;
|
|
163
|
+
targetPath: string;
|
|
164
|
+
}, {
|
|
165
|
+
sourcePath: string;
|
|
166
|
+
targetPath: string;
|
|
167
|
+
}>;
|
|
168
|
+
type UploadRequest = z.infer<typeof UploadRequestSchema>;
|
|
169
|
+
/**
|
|
170
|
+
* Close session request
|
|
171
|
+
*/
|
|
172
|
+
declare const CloseSessionRequestSchema: z.ZodObject<{
|
|
173
|
+
session: z.ZodDefault<z.ZodString>;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
session: string;
|
|
176
|
+
}, {
|
|
177
|
+
session?: string | undefined;
|
|
178
|
+
}>;
|
|
179
|
+
type CloseSessionRequest = z.infer<typeof CloseSessionRequestSchema>;
|
|
180
|
+
/**
|
|
181
|
+
* Chown request
|
|
182
|
+
*/
|
|
183
|
+
declare const ChownRequestSchema: z.ZodObject<{
|
|
184
|
+
remoteUser: z.ZodString;
|
|
185
|
+
paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
186
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
remoteUser: string;
|
|
189
|
+
paths: string[];
|
|
190
|
+
recursive: boolean;
|
|
191
|
+
}, {
|
|
192
|
+
remoteUser: string;
|
|
193
|
+
paths?: string[] | undefined;
|
|
194
|
+
recursive?: boolean | undefined;
|
|
195
|
+
}>;
|
|
196
|
+
type ChownRequest = z.infer<typeof ChownRequestSchema>;
|
|
197
|
+
/**
|
|
198
|
+
* Chmod request
|
|
199
|
+
*/
|
|
200
|
+
declare const ChmodRequestSchema: z.ZodObject<{
|
|
201
|
+
paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
202
|
+
mode: z.ZodDefault<z.ZodString>;
|
|
203
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
204
|
+
}, "strip", z.ZodTypeAny, {
|
|
205
|
+
paths: string[];
|
|
206
|
+
recursive: boolean;
|
|
207
|
+
mode: string;
|
|
208
|
+
}, {
|
|
209
|
+
paths?: string[] | undefined;
|
|
210
|
+
recursive?: boolean | undefined;
|
|
211
|
+
mode?: string | undefined;
|
|
212
|
+
}>;
|
|
213
|
+
type ChmodRequest = z.infer<typeof ChmodRequestSchema>;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Response types
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Base sandbox response
|
|
221
|
+
*/
|
|
222
|
+
declare const SandboxResponseSchema: z.ZodObject<{
|
|
223
|
+
code: z.ZodOptional<z.ZodNativeEnum<typeof Codes>>;
|
|
224
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
225
|
+
failureReason: z.ZodOptional<z.ZodString>;
|
|
226
|
+
}, "strip", z.ZodTypeAny, {
|
|
227
|
+
code?: Codes | undefined;
|
|
228
|
+
exitCode?: number | undefined;
|
|
229
|
+
failureReason?: string | undefined;
|
|
230
|
+
}, {
|
|
231
|
+
code?: Codes | undefined;
|
|
232
|
+
exitCode?: number | undefined;
|
|
233
|
+
failureReason?: string | undefined;
|
|
234
|
+
}>;
|
|
235
|
+
type SandboxResponse = z.infer<typeof SandboxResponseSchema>;
|
|
236
|
+
/**
|
|
237
|
+
* Is alive response
|
|
238
|
+
*/
|
|
239
|
+
declare const IsAliveResponseSchema: z.ZodObject<{
|
|
240
|
+
isAlive: z.ZodBoolean;
|
|
241
|
+
message: z.ZodDefault<z.ZodString>;
|
|
242
|
+
}, "strip", z.ZodTypeAny, {
|
|
243
|
+
message: string;
|
|
244
|
+
isAlive: boolean;
|
|
245
|
+
}, {
|
|
246
|
+
isAlive: boolean;
|
|
247
|
+
message?: string | undefined;
|
|
248
|
+
}>;
|
|
249
|
+
type IsAliveResponse = z.infer<typeof IsAliveResponseSchema>;
|
|
250
|
+
/**
|
|
251
|
+
* Sandbox status response
|
|
252
|
+
*/
|
|
253
|
+
declare const SandboxStatusResponseSchema: z.ZodObject<{
|
|
254
|
+
sandboxId: z.ZodOptional<z.ZodString>;
|
|
255
|
+
status: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
256
|
+
portMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
257
|
+
hostName: z.ZodOptional<z.ZodString>;
|
|
258
|
+
hostIp: z.ZodOptional<z.ZodString>;
|
|
259
|
+
isAlive: z.ZodDefault<z.ZodBoolean>;
|
|
260
|
+
image: z.ZodOptional<z.ZodString>;
|
|
261
|
+
gatewayVersion: z.ZodOptional<z.ZodString>;
|
|
262
|
+
sweRexVersion: z.ZodOptional<z.ZodString>;
|
|
263
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
264
|
+
experimentId: z.ZodOptional<z.ZodString>;
|
|
265
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
266
|
+
cpus: z.ZodOptional<z.ZodNumber>;
|
|
267
|
+
memory: z.ZodOptional<z.ZodString>;
|
|
268
|
+
}, "strip", z.ZodTypeAny, {
|
|
269
|
+
isAlive: boolean;
|
|
270
|
+
status?: Record<string, unknown> | undefined;
|
|
271
|
+
sandboxId?: string | undefined;
|
|
272
|
+
portMapping?: Record<string, unknown> | undefined;
|
|
273
|
+
hostName?: string | undefined;
|
|
274
|
+
hostIp?: string | undefined;
|
|
275
|
+
image?: string | undefined;
|
|
276
|
+
gatewayVersion?: string | undefined;
|
|
277
|
+
sweRexVersion?: string | undefined;
|
|
278
|
+
userId?: string | undefined;
|
|
279
|
+
experimentId?: string | undefined;
|
|
280
|
+
namespace?: string | undefined;
|
|
281
|
+
cpus?: number | undefined;
|
|
282
|
+
memory?: string | undefined;
|
|
283
|
+
}, {
|
|
284
|
+
status?: Record<string, unknown> | undefined;
|
|
285
|
+
isAlive?: boolean | undefined;
|
|
286
|
+
sandboxId?: string | undefined;
|
|
287
|
+
portMapping?: Record<string, unknown> | undefined;
|
|
288
|
+
hostName?: string | undefined;
|
|
289
|
+
hostIp?: string | undefined;
|
|
290
|
+
image?: string | undefined;
|
|
291
|
+
gatewayVersion?: string | undefined;
|
|
292
|
+
sweRexVersion?: string | undefined;
|
|
293
|
+
userId?: string | undefined;
|
|
294
|
+
experimentId?: string | undefined;
|
|
295
|
+
namespace?: string | undefined;
|
|
296
|
+
cpus?: number | undefined;
|
|
297
|
+
memory?: string | undefined;
|
|
298
|
+
}>;
|
|
299
|
+
type SandboxStatusResponse = z.infer<typeof SandboxStatusResponseSchema>;
|
|
300
|
+
/**
|
|
301
|
+
* Command execution response
|
|
302
|
+
*/
|
|
303
|
+
declare const CommandResponseSchema: z.ZodObject<{
|
|
304
|
+
stdout: z.ZodDefault<z.ZodString>;
|
|
305
|
+
stderr: z.ZodDefault<z.ZodString>;
|
|
306
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
307
|
+
}, "strip", z.ZodTypeAny, {
|
|
308
|
+
stdout: string;
|
|
309
|
+
stderr: string;
|
|
310
|
+
exitCode?: number | undefined;
|
|
311
|
+
}, {
|
|
312
|
+
exitCode?: number | undefined;
|
|
313
|
+
stdout?: string | undefined;
|
|
314
|
+
stderr?: string | undefined;
|
|
315
|
+
}>;
|
|
316
|
+
type CommandResponse = z.infer<typeof CommandResponseSchema>;
|
|
317
|
+
/**
|
|
318
|
+
* Write file response
|
|
319
|
+
*/
|
|
320
|
+
declare const WriteFileResponseSchema: z.ZodObject<{
|
|
321
|
+
success: z.ZodDefault<z.ZodBoolean>;
|
|
322
|
+
message: z.ZodDefault<z.ZodString>;
|
|
323
|
+
}, "strip", z.ZodTypeAny, {
|
|
324
|
+
message: string;
|
|
325
|
+
success: boolean;
|
|
326
|
+
}, {
|
|
327
|
+
message?: string | undefined;
|
|
328
|
+
success?: boolean | undefined;
|
|
329
|
+
}>;
|
|
330
|
+
type WriteFileResponse = z.infer<typeof WriteFileResponseSchema>;
|
|
331
|
+
/**
|
|
332
|
+
* Read file response
|
|
333
|
+
*/
|
|
334
|
+
declare const ReadFileResponseSchema: z.ZodObject<{
|
|
335
|
+
content: z.ZodDefault<z.ZodString>;
|
|
336
|
+
}, "strip", z.ZodTypeAny, {
|
|
337
|
+
content: string;
|
|
338
|
+
}, {
|
|
339
|
+
content?: string | undefined;
|
|
340
|
+
}>;
|
|
341
|
+
type ReadFileResponse = z.infer<typeof ReadFileResponseSchema>;
|
|
342
|
+
/**
|
|
343
|
+
* Upload response
|
|
344
|
+
*/
|
|
345
|
+
declare const UploadResponseSchema: z.ZodObject<{
|
|
346
|
+
success: z.ZodDefault<z.ZodBoolean>;
|
|
347
|
+
message: z.ZodDefault<z.ZodString>;
|
|
348
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
349
|
+
}, "strip", z.ZodTypeAny, {
|
|
350
|
+
message: string;
|
|
351
|
+
success: boolean;
|
|
352
|
+
fileName?: string | undefined;
|
|
353
|
+
}, {
|
|
354
|
+
message?: string | undefined;
|
|
355
|
+
success?: boolean | undefined;
|
|
356
|
+
fileName?: string | undefined;
|
|
357
|
+
}>;
|
|
358
|
+
type UploadResponse = z.infer<typeof UploadResponseSchema>;
|
|
359
|
+
/**
|
|
360
|
+
* Bash observation (execution result)
|
|
361
|
+
*/
|
|
362
|
+
declare const ObservationSchema: z.ZodObject<{
|
|
363
|
+
output: z.ZodDefault<z.ZodString>;
|
|
364
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
365
|
+
failureReason: z.ZodDefault<z.ZodString>;
|
|
366
|
+
expectString: z.ZodDefault<z.ZodString>;
|
|
367
|
+
}, "strip", z.ZodTypeAny, {
|
|
368
|
+
failureReason: string;
|
|
369
|
+
output: string;
|
|
370
|
+
expectString: string;
|
|
371
|
+
exitCode?: number | undefined;
|
|
372
|
+
}, {
|
|
373
|
+
exitCode?: number | undefined;
|
|
374
|
+
failureReason?: string | undefined;
|
|
375
|
+
output?: string | undefined;
|
|
376
|
+
expectString?: string | undefined;
|
|
377
|
+
}>;
|
|
378
|
+
type Observation = z.infer<typeof ObservationSchema>;
|
|
379
|
+
/**
|
|
380
|
+
* Create session response
|
|
381
|
+
*/
|
|
382
|
+
declare const CreateSessionResponseSchema: z.ZodObject<{
|
|
383
|
+
output: z.ZodDefault<z.ZodString>;
|
|
384
|
+
}, "strip", z.ZodTypeAny, {
|
|
385
|
+
output: string;
|
|
386
|
+
}, {
|
|
387
|
+
output?: string | undefined;
|
|
388
|
+
}>;
|
|
389
|
+
type CreateSessionResponse = z.infer<typeof CreateSessionResponseSchema>;
|
|
390
|
+
/**
|
|
391
|
+
* Close session response
|
|
392
|
+
*/
|
|
393
|
+
declare const CloseSessionResponseSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
394
|
+
type CloseSessionResponse = z.infer<typeof CloseSessionResponseSchema>;
|
|
395
|
+
/**
|
|
396
|
+
* Close response
|
|
397
|
+
*/
|
|
398
|
+
declare const CloseResponseSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
399
|
+
type CloseResponse = z.infer<typeof CloseResponseSchema>;
|
|
400
|
+
/**
|
|
401
|
+
* Chown response
|
|
402
|
+
*/
|
|
403
|
+
declare const ChownResponseSchema: z.ZodObject<{
|
|
404
|
+
success: z.ZodDefault<z.ZodBoolean>;
|
|
405
|
+
message: z.ZodDefault<z.ZodString>;
|
|
406
|
+
}, "strip", z.ZodTypeAny, {
|
|
407
|
+
message: string;
|
|
408
|
+
success: boolean;
|
|
409
|
+
}, {
|
|
410
|
+
message?: string | undefined;
|
|
411
|
+
success?: boolean | undefined;
|
|
412
|
+
}>;
|
|
413
|
+
type ChownResponse = z.infer<typeof ChownResponseSchema>;
|
|
414
|
+
/**
|
|
415
|
+
* Chmod response
|
|
416
|
+
*/
|
|
417
|
+
declare const ChmodResponseSchema: z.ZodObject<{
|
|
418
|
+
success: z.ZodDefault<z.ZodBoolean>;
|
|
419
|
+
message: z.ZodDefault<z.ZodString>;
|
|
420
|
+
}, "strip", z.ZodTypeAny, {
|
|
421
|
+
message: string;
|
|
422
|
+
success: boolean;
|
|
423
|
+
}, {
|
|
424
|
+
message?: string | undefined;
|
|
425
|
+
success?: boolean | undefined;
|
|
426
|
+
}>;
|
|
427
|
+
type ChmodResponse = z.infer<typeof ChmodResponseSchema>;
|
|
428
|
+
/**
|
|
429
|
+
* Execute bash session response
|
|
430
|
+
*/
|
|
431
|
+
declare const ExecuteBashSessionResponseSchema: z.ZodObject<{
|
|
432
|
+
success: z.ZodDefault<z.ZodBoolean>;
|
|
433
|
+
message: z.ZodDefault<z.ZodString>;
|
|
434
|
+
}, "strip", z.ZodTypeAny, {
|
|
435
|
+
message: string;
|
|
436
|
+
success: boolean;
|
|
437
|
+
}, {
|
|
438
|
+
message?: string | undefined;
|
|
439
|
+
success?: boolean | undefined;
|
|
440
|
+
}>;
|
|
441
|
+
type ExecuteBashSessionResponse = z.infer<typeof ExecuteBashSessionResponseSchema>;
|
|
442
|
+
/**
|
|
443
|
+
* OSS setup response
|
|
444
|
+
*/
|
|
445
|
+
declare const OssSetupResponseSchema: z.ZodObject<{
|
|
446
|
+
success: z.ZodDefault<z.ZodBoolean>;
|
|
447
|
+
message: z.ZodDefault<z.ZodString>;
|
|
448
|
+
}, "strip", z.ZodTypeAny, {
|
|
449
|
+
message: string;
|
|
450
|
+
success: boolean;
|
|
451
|
+
}, {
|
|
452
|
+
message?: string | undefined;
|
|
453
|
+
success?: boolean | undefined;
|
|
454
|
+
}>;
|
|
455
|
+
type OssSetupResponse = z.infer<typeof OssSetupResponseSchema>;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Common constants
|
|
459
|
+
*/
|
|
460
|
+
/**
|
|
461
|
+
* Run mode type
|
|
462
|
+
*/
|
|
463
|
+
type RunModeType$1 = 'normal' | 'nohup';
|
|
464
|
+
/**
|
|
465
|
+
* Run mode enum
|
|
466
|
+
*/
|
|
467
|
+
declare const RunMode: {
|
|
468
|
+
NORMAL: "normal";
|
|
469
|
+
NOHUP: "nohup";
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Constants class (deprecated, use envs module instead)
|
|
473
|
+
* @deprecated Use envs module instead
|
|
474
|
+
*/
|
|
475
|
+
declare class Constants {
|
|
476
|
+
static readonly BASE_URL_PRODUCT = "";
|
|
477
|
+
static readonly BASE_URL_ALIYUN = "";
|
|
478
|
+
static readonly BASE_URL_INNER = "";
|
|
479
|
+
static readonly BASE_URL_PRE = "";
|
|
480
|
+
static readonly BASE_URL_LOCAL = "";
|
|
481
|
+
static readonly REQUEST_TIMEOUT_SECONDS = 180;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* PID prefix and suffix for nohup output parsing
|
|
485
|
+
*/
|
|
486
|
+
declare const PID_PREFIX = "__ROCK_PID_START__";
|
|
487
|
+
declare const PID_SUFFIX = "__ROCK_PID_END__";
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* ROCK Exception classes
|
|
491
|
+
*/
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Base ROCK exception
|
|
495
|
+
*/
|
|
496
|
+
declare class RockException extends Error {
|
|
497
|
+
protected _code: Codes | null;
|
|
498
|
+
constructor(message: string, code?: Codes);
|
|
499
|
+
get code(): Codes | null;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Invalid parameter exception (deprecated)
|
|
503
|
+
* @deprecated Use BadRequestRockError instead
|
|
504
|
+
*/
|
|
505
|
+
declare class InvalidParameterRockException extends RockException {
|
|
506
|
+
constructor(message: string);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Bad request error (4xxx)
|
|
510
|
+
*/
|
|
511
|
+
declare class BadRequestRockError extends RockException {
|
|
512
|
+
constructor(message: string, code?: Codes);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Internal server error (5xxx)
|
|
516
|
+
*/
|
|
517
|
+
declare class InternalServerRockError extends RockException {
|
|
518
|
+
constructor(message: string, code?: Codes);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Command execution error (6xxx)
|
|
522
|
+
*/
|
|
523
|
+
declare class CommandRockError extends RockException {
|
|
524
|
+
constructor(message: string, code?: Codes);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Raise appropriate exception based on status code
|
|
528
|
+
*/
|
|
529
|
+
declare function raiseForCode(code: Codes | null | undefined, message: string): void;
|
|
530
|
+
/**
|
|
531
|
+
* Convert RockException to SandboxResponse
|
|
532
|
+
*/
|
|
533
|
+
declare function fromRockException(e: RockException): SandboxResponse;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* HTTP utilities class
|
|
537
|
+
*/
|
|
538
|
+
declare class HttpUtils {
|
|
539
|
+
private static defaultTimeout;
|
|
540
|
+
private static defaultConnectTimeout;
|
|
541
|
+
/**
|
|
542
|
+
* Create axios instance with default config
|
|
543
|
+
*/
|
|
544
|
+
private static createClient;
|
|
545
|
+
/**
|
|
546
|
+
* Send POST request
|
|
547
|
+
*/
|
|
548
|
+
static post<T = unknown>(url: string, headers: Record<string, string>, data: Record<string, unknown>, readTimeout?: number): Promise<T>;
|
|
549
|
+
/**
|
|
550
|
+
* Send GET request
|
|
551
|
+
*/
|
|
552
|
+
static get<T = unknown>(url: string, headers: Record<string, string>): Promise<T>;
|
|
553
|
+
/**
|
|
554
|
+
* Send multipart/form-data request
|
|
555
|
+
*/
|
|
556
|
+
static postMultipart<T = unknown>(url: string, headers: Record<string, string>, data?: Record<string, string | number | boolean>, files?: Record<string, File | Buffer | [string, Buffer, string]>): Promise<T>;
|
|
557
|
+
/**
|
|
558
|
+
* Guess MIME type from filename
|
|
559
|
+
*/
|
|
560
|
+
static guessContentType(filename: string): string;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Retry utilities
|
|
565
|
+
*/
|
|
566
|
+
/**
|
|
567
|
+
* Retry options
|
|
568
|
+
*/
|
|
569
|
+
interface RetryOptions {
|
|
570
|
+
maxAttempts?: number;
|
|
571
|
+
delaySeconds?: number;
|
|
572
|
+
backoff?: number;
|
|
573
|
+
jitter?: boolean;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Retry decorator for async functions
|
|
577
|
+
*/
|
|
578
|
+
declare function retryAsync<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
579
|
+
/**
|
|
580
|
+
* Sleep utility
|
|
581
|
+
*/
|
|
582
|
+
declare function sleep(ms: number): Promise<void>;
|
|
583
|
+
/**
|
|
584
|
+
* Create a retry wrapper for a function
|
|
585
|
+
*/
|
|
586
|
+
declare function withRetry<T extends (...args: unknown[]) => Promise<unknown>>(fn: T, options?: RetryOptions): T;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Deprecated decorator utilities
|
|
590
|
+
*/
|
|
591
|
+
/**
|
|
592
|
+
* Mark a function as deprecated
|
|
593
|
+
*/
|
|
594
|
+
declare function deprecated(reason?: string): (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
595
|
+
/**
|
|
596
|
+
* Mark a class as deprecated
|
|
597
|
+
*/
|
|
598
|
+
declare function deprecatedClass(reason?: string): <T extends new (...args: any[]) => any>(constructor: T) => T;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* System utilities
|
|
602
|
+
*/
|
|
603
|
+
/**
|
|
604
|
+
* Check if running in Node.js environment
|
|
605
|
+
*/
|
|
606
|
+
declare function isNode(): boolean;
|
|
607
|
+
/**
|
|
608
|
+
* Check if running in browser environment
|
|
609
|
+
*/
|
|
610
|
+
declare function isBrowser(): boolean;
|
|
611
|
+
/**
|
|
612
|
+
* Get environment variable
|
|
613
|
+
*/
|
|
614
|
+
declare function getEnv(key: string, defaultValue?: string): string | undefined;
|
|
615
|
+
/**
|
|
616
|
+
* Get required environment variable
|
|
617
|
+
*/
|
|
618
|
+
declare function getRequiredEnv(key: string): string;
|
|
619
|
+
/**
|
|
620
|
+
* Check if environment variable is set
|
|
621
|
+
*/
|
|
622
|
+
declare function isEnvSet(key: string): boolean;
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* EnvHub data model definitions
|
|
626
|
+
*/
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* EnvHub client configuration
|
|
630
|
+
*/
|
|
631
|
+
declare const EnvHubClientConfigSchema: z.ZodObject<{
|
|
632
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
633
|
+
}, "strip", z.ZodTypeAny, {
|
|
634
|
+
baseUrl: string;
|
|
635
|
+
}, {
|
|
636
|
+
baseUrl?: string | undefined;
|
|
637
|
+
}>;
|
|
638
|
+
type EnvHubClientConfig = z.infer<typeof EnvHubClientConfigSchema>;
|
|
639
|
+
/**
|
|
640
|
+
* Rock environment info
|
|
641
|
+
*/
|
|
642
|
+
declare const RockEnvInfoSchema: z.ZodObject<{
|
|
643
|
+
envName: z.ZodString;
|
|
644
|
+
image: z.ZodString;
|
|
645
|
+
owner: z.ZodDefault<z.ZodString>;
|
|
646
|
+
createAt: z.ZodDefault<z.ZodString>;
|
|
647
|
+
updateAt: z.ZodDefault<z.ZodString>;
|
|
648
|
+
description: z.ZodDefault<z.ZodString>;
|
|
649
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
650
|
+
extraSpec: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
651
|
+
}, "strip", z.ZodTypeAny, {
|
|
652
|
+
image: string;
|
|
653
|
+
envName: string;
|
|
654
|
+
owner: string;
|
|
655
|
+
createAt: string;
|
|
656
|
+
updateAt: string;
|
|
657
|
+
description: string;
|
|
658
|
+
tags: string[];
|
|
659
|
+
extraSpec?: Record<string, unknown> | undefined;
|
|
660
|
+
}, {
|
|
661
|
+
image: string;
|
|
662
|
+
envName: string;
|
|
663
|
+
owner?: string | undefined;
|
|
664
|
+
createAt?: string | undefined;
|
|
665
|
+
updateAt?: string | undefined;
|
|
666
|
+
description?: string | undefined;
|
|
667
|
+
tags?: string[] | undefined;
|
|
668
|
+
extraSpec?: Record<string, unknown> | undefined;
|
|
669
|
+
}>;
|
|
670
|
+
type RockEnvInfo = z.infer<typeof RockEnvInfoSchema>;
|
|
671
|
+
/**
|
|
672
|
+
* Create RockEnvInfo from plain object
|
|
673
|
+
*/
|
|
674
|
+
declare function createRockEnvInfo(data: Record<string, unknown>): RockEnvInfo;
|
|
675
|
+
/**
|
|
676
|
+
* Convert RockEnvInfo to plain object (snake_case for API)
|
|
677
|
+
*/
|
|
678
|
+
declare function rockEnvInfoToDict(env: RockEnvInfo): Record<string, unknown>;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* EnvHub client for communicating with EnvHub server
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* EnvHub error exception
|
|
686
|
+
*/
|
|
687
|
+
declare class EnvHubError extends Error {
|
|
688
|
+
constructor(message: string);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* EnvHub client for communicating with EnvHub server
|
|
692
|
+
*/
|
|
693
|
+
declare class EnvHubClient {
|
|
694
|
+
private config;
|
|
695
|
+
private baseUrl;
|
|
696
|
+
private headers;
|
|
697
|
+
constructor(config?: Partial<EnvHubClientConfig>);
|
|
698
|
+
/**
|
|
699
|
+
* Register or update an environment
|
|
700
|
+
*/
|
|
701
|
+
register(options: {
|
|
702
|
+
envName: string;
|
|
703
|
+
image: string;
|
|
704
|
+
owner?: string;
|
|
705
|
+
description?: string;
|
|
706
|
+
tags?: string[];
|
|
707
|
+
extraSpec?: Record<string, unknown>;
|
|
708
|
+
}): Promise<RockEnvInfo>;
|
|
709
|
+
/**
|
|
710
|
+
* Get environment by name
|
|
711
|
+
*/
|
|
712
|
+
getEnv(envName: string): Promise<RockEnvInfo>;
|
|
713
|
+
/**
|
|
714
|
+
* List environments
|
|
715
|
+
*/
|
|
716
|
+
listEnvs(options?: {
|
|
717
|
+
owner?: string;
|
|
718
|
+
tags?: string[];
|
|
719
|
+
}): Promise<RockEnvInfo[]>;
|
|
720
|
+
/**
|
|
721
|
+
* Delete environment
|
|
722
|
+
*/
|
|
723
|
+
deleteEnv(envName: string): Promise<boolean>;
|
|
724
|
+
/**
|
|
725
|
+
* Health check
|
|
726
|
+
*/
|
|
727
|
+
healthCheck(): Promise<Record<string, string>>;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* RockEnv - Gym-style environment interface
|
|
732
|
+
*/
|
|
733
|
+
/**
|
|
734
|
+
* Step result tuple type
|
|
735
|
+
*/
|
|
736
|
+
type StepResult = [
|
|
737
|
+
observation: unknown,
|
|
738
|
+
reward: number,
|
|
739
|
+
terminated: boolean,
|
|
740
|
+
truncated: boolean,
|
|
741
|
+
info: Record<string, unknown>
|
|
742
|
+
];
|
|
743
|
+
/**
|
|
744
|
+
* Reset result tuple type
|
|
745
|
+
*/
|
|
746
|
+
type ResetResult = [observation: unknown, info: Record<string, unknown>];
|
|
747
|
+
/**
|
|
748
|
+
* RockEnv configuration
|
|
749
|
+
*/
|
|
750
|
+
interface RockEnvConfig {
|
|
751
|
+
envId: string;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* RockEnv - Gym-style environment for ROCK
|
|
755
|
+
*/
|
|
756
|
+
declare class RockEnv {
|
|
757
|
+
private readonly envId;
|
|
758
|
+
private sandboxId;
|
|
759
|
+
private isClosed;
|
|
760
|
+
private client;
|
|
761
|
+
constructor(config: RockEnvConfig);
|
|
762
|
+
/**
|
|
763
|
+
* Initialize environment instance
|
|
764
|
+
*/
|
|
765
|
+
private initializeEnvironment;
|
|
766
|
+
/**
|
|
767
|
+
* Execute an action step
|
|
768
|
+
*
|
|
769
|
+
* @param action - Action ID to execute
|
|
770
|
+
* @returns Tuple containing observation, reward, terminated, truncated, info
|
|
771
|
+
*/
|
|
772
|
+
step(action: string | number): Promise<StepResult>;
|
|
773
|
+
/**
|
|
774
|
+
* Reset environment to initial state
|
|
775
|
+
*
|
|
776
|
+
* @param seed - Optional random seed
|
|
777
|
+
* @returns Tuple containing initial observation and info
|
|
778
|
+
*/
|
|
779
|
+
reset(seed?: number): Promise<ResetResult>;
|
|
780
|
+
/**
|
|
781
|
+
* Close environment and clean up resources
|
|
782
|
+
*/
|
|
783
|
+
close(): Promise<void>;
|
|
784
|
+
/**
|
|
785
|
+
* Parse step result from API response
|
|
786
|
+
*/
|
|
787
|
+
private parseStepResult;
|
|
788
|
+
/**
|
|
789
|
+
* Parse reset result from API response
|
|
790
|
+
*/
|
|
791
|
+
private parseResetResult;
|
|
792
|
+
/**
|
|
793
|
+
* Ensure environment is not closed
|
|
794
|
+
*/
|
|
795
|
+
private ensureNotClosed;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Environment factory function
|
|
800
|
+
*/
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Create a Rock environment instance
|
|
804
|
+
*
|
|
805
|
+
* @param envId - Environment ID
|
|
806
|
+
* @param options - Environment options
|
|
807
|
+
* @returns RockEnv instance
|
|
808
|
+
*/
|
|
809
|
+
declare function make(envId: string, options?: Record<string, unknown>): RockEnv;
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Sandbox configuration
|
|
813
|
+
*/
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Base configuration schema
|
|
817
|
+
*/
|
|
818
|
+
declare const BaseConfigSchema: z.ZodObject<{
|
|
819
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
820
|
+
xrlAuthorization: z.ZodOptional<z.ZodString>;
|
|
821
|
+
extraHeaders: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
822
|
+
}, "strip", z.ZodTypeAny, {
|
|
823
|
+
baseUrl: string;
|
|
824
|
+
extraHeaders: Record<string, string>;
|
|
825
|
+
xrlAuthorization?: string | undefined;
|
|
826
|
+
}, {
|
|
827
|
+
baseUrl?: string | undefined;
|
|
828
|
+
xrlAuthorization?: string | undefined;
|
|
829
|
+
extraHeaders?: Record<string, string> | undefined;
|
|
830
|
+
}>;
|
|
831
|
+
type BaseConfig = z.infer<typeof BaseConfigSchema>;
|
|
832
|
+
/**
|
|
833
|
+
* Sandbox configuration schema
|
|
834
|
+
*/
|
|
835
|
+
declare const SandboxConfigSchema: z.ZodObject<{
|
|
836
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
837
|
+
xrlAuthorization: z.ZodOptional<z.ZodString>;
|
|
838
|
+
extraHeaders: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
839
|
+
} & {
|
|
840
|
+
image: z.ZodDefault<z.ZodString>;
|
|
841
|
+
autoClearSeconds: z.ZodDefault<z.ZodNumber>;
|
|
842
|
+
routeKey: z.ZodOptional<z.ZodString>;
|
|
843
|
+
startupTimeout: z.ZodDefault<z.ZodNumber>;
|
|
844
|
+
memory: z.ZodDefault<z.ZodString>;
|
|
845
|
+
cpus: z.ZodDefault<z.ZodNumber>;
|
|
846
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
847
|
+
experimentId: z.ZodOptional<z.ZodString>;
|
|
848
|
+
cluster: z.ZodDefault<z.ZodString>;
|
|
849
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
850
|
+
}, "strip", z.ZodTypeAny, {
|
|
851
|
+
image: string;
|
|
852
|
+
cpus: number;
|
|
853
|
+
memory: string;
|
|
854
|
+
baseUrl: string;
|
|
855
|
+
extraHeaders: Record<string, string>;
|
|
856
|
+
autoClearSeconds: number;
|
|
857
|
+
startupTimeout: number;
|
|
858
|
+
cluster: string;
|
|
859
|
+
userId?: string | undefined;
|
|
860
|
+
experimentId?: string | undefined;
|
|
861
|
+
namespace?: string | undefined;
|
|
862
|
+
xrlAuthorization?: string | undefined;
|
|
863
|
+
routeKey?: string | undefined;
|
|
864
|
+
}, {
|
|
865
|
+
image?: string | undefined;
|
|
866
|
+
userId?: string | undefined;
|
|
867
|
+
experimentId?: string | undefined;
|
|
868
|
+
namespace?: string | undefined;
|
|
869
|
+
cpus?: number | undefined;
|
|
870
|
+
memory?: string | undefined;
|
|
871
|
+
baseUrl?: string | undefined;
|
|
872
|
+
xrlAuthorization?: string | undefined;
|
|
873
|
+
extraHeaders?: Record<string, string> | undefined;
|
|
874
|
+
autoClearSeconds?: number | undefined;
|
|
875
|
+
routeKey?: string | undefined;
|
|
876
|
+
startupTimeout?: number | undefined;
|
|
877
|
+
cluster?: string | undefined;
|
|
878
|
+
}>;
|
|
879
|
+
type SandboxConfig = z.infer<typeof SandboxConfigSchema>;
|
|
880
|
+
/**
|
|
881
|
+
* Sandbox group configuration schema
|
|
882
|
+
*/
|
|
883
|
+
declare const SandboxGroupConfigSchema: z.ZodObject<{
|
|
884
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
885
|
+
xrlAuthorization: z.ZodOptional<z.ZodString>;
|
|
886
|
+
extraHeaders: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
887
|
+
} & {
|
|
888
|
+
image: z.ZodDefault<z.ZodString>;
|
|
889
|
+
autoClearSeconds: z.ZodDefault<z.ZodNumber>;
|
|
890
|
+
routeKey: z.ZodOptional<z.ZodString>;
|
|
891
|
+
startupTimeout: z.ZodDefault<z.ZodNumber>;
|
|
892
|
+
memory: z.ZodDefault<z.ZodString>;
|
|
893
|
+
cpus: z.ZodDefault<z.ZodNumber>;
|
|
894
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
895
|
+
experimentId: z.ZodOptional<z.ZodString>;
|
|
896
|
+
cluster: z.ZodDefault<z.ZodString>;
|
|
897
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
898
|
+
} & {
|
|
899
|
+
size: z.ZodDefault<z.ZodNumber>;
|
|
900
|
+
startConcurrency: z.ZodDefault<z.ZodNumber>;
|
|
901
|
+
startRetryTimes: z.ZodDefault<z.ZodNumber>;
|
|
902
|
+
}, "strip", z.ZodTypeAny, {
|
|
903
|
+
image: string;
|
|
904
|
+
cpus: number;
|
|
905
|
+
memory: string;
|
|
906
|
+
baseUrl: string;
|
|
907
|
+
extraHeaders: Record<string, string>;
|
|
908
|
+
autoClearSeconds: number;
|
|
909
|
+
startupTimeout: number;
|
|
910
|
+
cluster: string;
|
|
911
|
+
size: number;
|
|
912
|
+
startConcurrency: number;
|
|
913
|
+
startRetryTimes: number;
|
|
914
|
+
userId?: string | undefined;
|
|
915
|
+
experimentId?: string | undefined;
|
|
916
|
+
namespace?: string | undefined;
|
|
917
|
+
xrlAuthorization?: string | undefined;
|
|
918
|
+
routeKey?: string | undefined;
|
|
919
|
+
}, {
|
|
920
|
+
image?: string | undefined;
|
|
921
|
+
userId?: string | undefined;
|
|
922
|
+
experimentId?: string | undefined;
|
|
923
|
+
namespace?: string | undefined;
|
|
924
|
+
cpus?: number | undefined;
|
|
925
|
+
memory?: string | undefined;
|
|
926
|
+
baseUrl?: string | undefined;
|
|
927
|
+
xrlAuthorization?: string | undefined;
|
|
928
|
+
extraHeaders?: Record<string, string> | undefined;
|
|
929
|
+
autoClearSeconds?: number | undefined;
|
|
930
|
+
routeKey?: string | undefined;
|
|
931
|
+
startupTimeout?: number | undefined;
|
|
932
|
+
cluster?: string | undefined;
|
|
933
|
+
size?: number | undefined;
|
|
934
|
+
startConcurrency?: number | undefined;
|
|
935
|
+
startRetryTimes?: number | undefined;
|
|
936
|
+
}>;
|
|
937
|
+
type SandboxGroupConfig = z.infer<typeof SandboxGroupConfigSchema>;
|
|
938
|
+
/**
|
|
939
|
+
* Create sandbox config with defaults
|
|
940
|
+
*/
|
|
941
|
+
declare function createSandboxConfig(config?: Partial<SandboxConfig>): SandboxConfig;
|
|
942
|
+
/**
|
|
943
|
+
* Create sandbox group config with defaults
|
|
944
|
+
*/
|
|
945
|
+
declare function createSandboxGroupConfig(config?: Partial<SandboxGroupConfig>): SandboxGroupConfig;
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Deploy - Sandbox resource deployment manager
|
|
949
|
+
*/
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Deploy - Manages deployment of local directories to sandbox
|
|
953
|
+
*/
|
|
954
|
+
declare class Deploy {
|
|
955
|
+
private sandbox;
|
|
956
|
+
private workingDir;
|
|
957
|
+
constructor(sandbox: Sandbox);
|
|
958
|
+
/**
|
|
959
|
+
* Get the current working directory
|
|
960
|
+
*/
|
|
961
|
+
getWorkingDir(): string | null;
|
|
962
|
+
/**
|
|
963
|
+
* Deploy local directory to sandbox
|
|
964
|
+
*
|
|
965
|
+
* @param localPath - Local directory path
|
|
966
|
+
* @param targetPath - Target path in sandbox (optional)
|
|
967
|
+
* @returns The target path in sandbox
|
|
968
|
+
*/
|
|
969
|
+
deployWorkingDir(localPath: string, targetPath?: string): Promise<string>;
|
|
970
|
+
/**
|
|
971
|
+
* Format command template supporting ${} and <<>> syntax
|
|
972
|
+
*
|
|
973
|
+
* @param template - Template string with placeholders
|
|
974
|
+
* @param kwargs - Additional substitution variables
|
|
975
|
+
* @returns Formatted string
|
|
976
|
+
*/
|
|
977
|
+
format(template: string, kwargs?: Record<string, string>): string;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* FileSystem - File system operations for sandbox
|
|
982
|
+
*/
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Abstract file system interface
|
|
986
|
+
*/
|
|
987
|
+
declare abstract class FileSystem {
|
|
988
|
+
protected sandbox: AbstractSandbox;
|
|
989
|
+
constructor(sandbox: AbstractSandbox);
|
|
990
|
+
abstract chown(request: ChownRequest): Promise<{
|
|
991
|
+
success: boolean;
|
|
992
|
+
message: string;
|
|
993
|
+
}>;
|
|
994
|
+
abstract chmod(request: ChmodRequest): Promise<{
|
|
995
|
+
success: boolean;
|
|
996
|
+
message: string;
|
|
997
|
+
}>;
|
|
998
|
+
abstract uploadDir(sourceDir: string, targetDir: string, extractTimeout?: number): Promise<Observation>;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Linux file system implementation
|
|
1002
|
+
*/
|
|
1003
|
+
declare class LinuxFileSystem extends FileSystem {
|
|
1004
|
+
constructor(sandbox: AbstractSandbox);
|
|
1005
|
+
chown(request: ChownRequest): Promise<{
|
|
1006
|
+
success: boolean;
|
|
1007
|
+
message: string;
|
|
1008
|
+
}>;
|
|
1009
|
+
chmod(request: ChmodRequest): Promise<{
|
|
1010
|
+
success: boolean;
|
|
1011
|
+
message: string;
|
|
1012
|
+
}>;
|
|
1013
|
+
uploadDir(sourceDir: string, targetDir: string, extractTimeout?: number): Promise<Observation>;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Sandbox types
|
|
1018
|
+
*/
|
|
1019
|
+
/**
|
|
1020
|
+
* Run mode type
|
|
1021
|
+
*/
|
|
1022
|
+
type RunModeType = 'normal' | 'nohup';
|
|
1023
|
+
/**
|
|
1024
|
+
* Speedup type enum
|
|
1025
|
+
*/
|
|
1026
|
+
declare enum SpeedupType {
|
|
1027
|
+
APT = "apt",
|
|
1028
|
+
PIP = "pip",
|
|
1029
|
+
GITHUB = "github"
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Network - Network management for sandbox
|
|
1034
|
+
*/
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Network management for sandbox
|
|
1038
|
+
*/
|
|
1039
|
+
declare class Network {
|
|
1040
|
+
private sandbox;
|
|
1041
|
+
constructor(sandbox: Sandbox);
|
|
1042
|
+
/**
|
|
1043
|
+
* Configure acceleration for package managers or network resources
|
|
1044
|
+
*
|
|
1045
|
+
* @param speedupType - Type of speedup configuration
|
|
1046
|
+
* @param speedupValue - Speedup value (mirror URL or IP address)
|
|
1047
|
+
* @param timeout - Execution timeout in seconds
|
|
1048
|
+
* @returns Observation with execution result
|
|
1049
|
+
*/
|
|
1050
|
+
speedup(speedupType: SpeedupType, speedupValue: string, timeout?: number): Promise<Observation>;
|
|
1051
|
+
private buildAptSpeedupCommand;
|
|
1052
|
+
private buildPipSpeedupCommand;
|
|
1053
|
+
private buildGithubSpeedupCommand;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Process - Process management for sandbox execution
|
|
1058
|
+
*/
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Process management for sandbox execution
|
|
1062
|
+
*/
|
|
1063
|
+
declare class Process {
|
|
1064
|
+
private sandbox;
|
|
1065
|
+
constructor(sandbox: Sandbox);
|
|
1066
|
+
/**
|
|
1067
|
+
* Execute a script in the sandbox
|
|
1068
|
+
*
|
|
1069
|
+
* @param scriptContent - The script content to execute
|
|
1070
|
+
* @param scriptName - Optional custom script name
|
|
1071
|
+
* @param waitTimeout - Maximum time to wait for script completion
|
|
1072
|
+
* @param waitInterval - Interval between process checks
|
|
1073
|
+
* @param cleanup - Whether to delete the script file after execution
|
|
1074
|
+
* @returns Observation with execution result
|
|
1075
|
+
*/
|
|
1076
|
+
executeScript(options: {
|
|
1077
|
+
scriptContent: string;
|
|
1078
|
+
scriptName?: string;
|
|
1079
|
+
waitTimeout?: number;
|
|
1080
|
+
waitInterval?: number;
|
|
1081
|
+
cleanup?: boolean;
|
|
1082
|
+
}): Promise<Observation>;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* RemoteUser - Remote user management for sandbox
|
|
1087
|
+
*/
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Abstract remote user interface
|
|
1091
|
+
*/
|
|
1092
|
+
declare abstract class RemoteUser {
|
|
1093
|
+
protected sandbox: AbstractSandbox;
|
|
1094
|
+
protected currentUser: string;
|
|
1095
|
+
constructor(sandbox: AbstractSandbox);
|
|
1096
|
+
getCurrentUser(): string;
|
|
1097
|
+
abstract createRemoteUser(userName: string): Promise<boolean>;
|
|
1098
|
+
abstract isUserExist(userName: string): Promise<boolean>;
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Linux remote user implementation
|
|
1102
|
+
*/
|
|
1103
|
+
declare class LinuxRemoteUser extends RemoteUser {
|
|
1104
|
+
constructor(sandbox: AbstractSandbox);
|
|
1105
|
+
createRemoteUser(userName: string): Promise<boolean>;
|
|
1106
|
+
isUserExist(userName: string): Promise<boolean>;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Sandbox client - Core sandbox management
|
|
1111
|
+
*/
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Abstract sandbox interface
|
|
1115
|
+
*/
|
|
1116
|
+
declare abstract class AbstractSandbox {
|
|
1117
|
+
abstract isAlive(): Promise<IsAliveResponse>;
|
|
1118
|
+
abstract createSession(request: CreateBashSessionRequest): Promise<CreateSessionResponse>;
|
|
1119
|
+
abstract execute(command: Command): Promise<CommandResponse>;
|
|
1120
|
+
abstract read_file(request: ReadFileRequest): Promise<ReadFileResponse>;
|
|
1121
|
+
abstract write_file(request: WriteFileRequest): Promise<WriteFileResponse>;
|
|
1122
|
+
abstract upload(request: UploadRequest): Promise<UploadResponse>;
|
|
1123
|
+
abstract closeSession(request: CloseSessionRequest): Promise<CloseSessionResponse>;
|
|
1124
|
+
abstract close(): Promise<void>;
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Sandbox - Main sandbox client
|
|
1128
|
+
*/
|
|
1129
|
+
declare class Sandbox extends AbstractSandbox {
|
|
1130
|
+
private config;
|
|
1131
|
+
private url;
|
|
1132
|
+
private routeKey;
|
|
1133
|
+
private sandboxId;
|
|
1134
|
+
private hostName;
|
|
1135
|
+
private hostIp;
|
|
1136
|
+
private cluster;
|
|
1137
|
+
private deploy;
|
|
1138
|
+
private fs;
|
|
1139
|
+
private network;
|
|
1140
|
+
private process;
|
|
1141
|
+
private remoteUser;
|
|
1142
|
+
constructor(config?: Partial<SandboxConfig>);
|
|
1143
|
+
getSandboxId(): string;
|
|
1144
|
+
getHostName(): string | null;
|
|
1145
|
+
getHostIp(): string | null;
|
|
1146
|
+
getCluster(): string;
|
|
1147
|
+
getUrl(): string;
|
|
1148
|
+
getFs(): LinuxFileSystem;
|
|
1149
|
+
getNetwork(): Network;
|
|
1150
|
+
getProcess(): Process;
|
|
1151
|
+
getRemoteUser(): LinuxRemoteUser;
|
|
1152
|
+
getDeploy(): Deploy;
|
|
1153
|
+
getConfig(): SandboxConfig;
|
|
1154
|
+
private buildHeaders;
|
|
1155
|
+
private addUserDefinedTags;
|
|
1156
|
+
start(): Promise<void>;
|
|
1157
|
+
stop(): Promise<void>;
|
|
1158
|
+
isAlive(): Promise<IsAliveResponse>;
|
|
1159
|
+
getStatus(): Promise<SandboxStatusResponse>;
|
|
1160
|
+
execute(command: Command): Promise<CommandResponse>;
|
|
1161
|
+
createSession(request: CreateBashSessionRequest): Promise<CreateSessionResponse>;
|
|
1162
|
+
closeSession(request: CloseSessionRequest): Promise<CloseSessionResponse>;
|
|
1163
|
+
arun(cmd: string, options?: {
|
|
1164
|
+
session?: string;
|
|
1165
|
+
mode?: RunModeType;
|
|
1166
|
+
waitTimeout?: number;
|
|
1167
|
+
waitInterval?: number;
|
|
1168
|
+
responseLimitedBytesInNohup?: number;
|
|
1169
|
+
ignoreOutput?: boolean;
|
|
1170
|
+
outputFile?: string;
|
|
1171
|
+
}): Promise<Observation>;
|
|
1172
|
+
private runInSession;
|
|
1173
|
+
private arunWithNohup;
|
|
1174
|
+
private waitForProcessCompletion;
|
|
1175
|
+
write_file(request: WriteFileRequest): Promise<WriteFileResponse>;
|
|
1176
|
+
read_file(request: ReadFileRequest): Promise<ReadFileResponse>;
|
|
1177
|
+
upload(request: UploadRequest): Promise<UploadResponse>;
|
|
1178
|
+
uploadByPath(sourcePath: string, targetPath: string): Promise<UploadResponse>;
|
|
1179
|
+
close(): Promise<void>;
|
|
1180
|
+
toString(): string;
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* SandboxGroup - Group of sandboxes with concurrent operations
|
|
1184
|
+
*/
|
|
1185
|
+
declare class SandboxGroup {
|
|
1186
|
+
private config;
|
|
1187
|
+
private sandboxList;
|
|
1188
|
+
constructor(config?: Partial<SandboxGroupConfig>);
|
|
1189
|
+
getSandboxList(): Sandbox[];
|
|
1190
|
+
start(): Promise<void>;
|
|
1191
|
+
stop(): Promise<void>;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Sandbox utilities
|
|
1196
|
+
*/
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Decorator to add timing and logging to functions
|
|
1200
|
+
*/
|
|
1201
|
+
declare function withTimeLogging(operationName: string): (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
1202
|
+
/**
|
|
1203
|
+
* Run command with retry
|
|
1204
|
+
*/
|
|
1205
|
+
declare function arunWithRetry(sandbox: Sandbox, cmd: string, session: string, mode: RunModeType, options?: {
|
|
1206
|
+
waitTimeout?: number;
|
|
1207
|
+
waitInterval?: number;
|
|
1208
|
+
maxAttempts?: number;
|
|
1209
|
+
errorMsg?: string;
|
|
1210
|
+
}): Promise<Observation>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Extract nohup PID from output
|
|
1213
|
+
*/
|
|
1214
|
+
declare function extractNohupPid(output: string): number | null;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* Model client for LLM interaction
|
|
1218
|
+
*/
|
|
1219
|
+
/**
|
|
1220
|
+
* Model client configuration
|
|
1221
|
+
*/
|
|
1222
|
+
interface ModelClientConfig {
|
|
1223
|
+
logFileName?: string;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Model client for LLM interaction
|
|
1227
|
+
*/
|
|
1228
|
+
declare class ModelClient {
|
|
1229
|
+
private logFile;
|
|
1230
|
+
constructor(config?: ModelClientConfig);
|
|
1231
|
+
/**
|
|
1232
|
+
* Anti-call LLM - input is response, output is next request
|
|
1233
|
+
*/
|
|
1234
|
+
antiCallLlm(index: number, lastResponse?: string): Promise<string>;
|
|
1235
|
+
/**
|
|
1236
|
+
* Push response to log file
|
|
1237
|
+
*/
|
|
1238
|
+
pushResponse(index: number, lastResponse: string): Promise<void>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Pop request from log file
|
|
1241
|
+
*/
|
|
1242
|
+
popRequest(index: number): Promise<string>;
|
|
1243
|
+
/**
|
|
1244
|
+
* Wait for first request
|
|
1245
|
+
*/
|
|
1246
|
+
waitForFirstRequest(): Promise<void>;
|
|
1247
|
+
private parseRequestLine;
|
|
1248
|
+
private parseResponseLine;
|
|
1249
|
+
private readLastRequestLine;
|
|
1250
|
+
private readLastResponseLine;
|
|
1251
|
+
private appendResponse;
|
|
1252
|
+
private constructResponse;
|
|
1253
|
+
private sleep;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Model service for managing local LLM service
|
|
1258
|
+
*/
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* Model service configuration
|
|
1262
|
+
*/
|
|
1263
|
+
interface ModelServiceConfig {
|
|
1264
|
+
modelServiceType?: string;
|
|
1265
|
+
configFile?: string;
|
|
1266
|
+
host?: string;
|
|
1267
|
+
port?: number;
|
|
1268
|
+
proxyBaseUrl?: string;
|
|
1269
|
+
retryableStatusCodes?: string;
|
|
1270
|
+
requestTimeout?: number;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Model service for managing local LLM service
|
|
1274
|
+
*/
|
|
1275
|
+
declare class ModelService {
|
|
1276
|
+
private process;
|
|
1277
|
+
/**
|
|
1278
|
+
* Start sandbox service
|
|
1279
|
+
*/
|
|
1280
|
+
startSandboxService(config?: ModelServiceConfig): ChildProcess;
|
|
1281
|
+
/**
|
|
1282
|
+
* Start and wait for service to be available
|
|
1283
|
+
*/
|
|
1284
|
+
start(config?: ModelServiceConfig & {
|
|
1285
|
+
timeoutSeconds?: number;
|
|
1286
|
+
}): Promise<string>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Start watching agent
|
|
1289
|
+
*/
|
|
1290
|
+
startWatchAgent(agentPid: number, host?: string, port?: number): Promise<void>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Stop service
|
|
1293
|
+
*/
|
|
1294
|
+
stop(pid: string): Promise<void>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Wait for service to be available
|
|
1297
|
+
*/
|
|
1298
|
+
private waitServiceAvailable;
|
|
1299
|
+
private sleep;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* ROCK TypeScript SDK
|
|
1304
|
+
* Main entry point
|
|
1305
|
+
*/
|
|
1306
|
+
declare const VERSION = "1.2.1";
|
|
1307
|
+
|
|
1308
|
+
export { BadRequestRockError, type BaseConfig, type BashAction, BashActionSchema, type ChmodRequest, ChmodRequestSchema, type ChmodResponse, ChmodResponseSchema, type ChownRequest, ChownRequestSchema, type ChownResponse, ChownResponseSchema, type CloseResponse, CloseResponseSchema, type CloseSessionRequest, CloseSessionRequestSchema, type CloseSessionResponse, CloseSessionResponseSchema, Codes, type Command, type CommandResponse, CommandResponseSchema, CommandRockError, CommandSchema, Constants, type CreateBashSessionRequest, CreateBashSessionRequestSchema, type CreateSessionResponse, CreateSessionResponseSchema, Deploy, EnvHubClient, type EnvHubClientConfig, EnvHubClientConfigSchema, EnvHubError, type ExecuteBashSessionResponse, ExecuteBashSessionResponseSchema, HttpUtils, InternalServerRockError, InvalidParameterRockException, type IsAliveResponse, IsAliveResponseSchema, LinuxFileSystem, LinuxRemoteUser, ModelClient, type ModelClientConfig, ModelService, type ModelServiceConfig, Network, type Observation, ObservationSchema, type OssSetupResponse, OssSetupResponseSchema, PID_PREFIX, PID_SUFFIX, Process, type ReadFileRequest, ReadFileRequestSchema, type ReadFileResponse, ReadFileResponseSchema, ReasonPhrases, type ResetResult, RockEnv, type RockEnvConfig, type RockEnvInfo, RockEnvInfoSchema, RockException, RunMode, type RunModeType$1 as RunModeType, Sandbox, type SandboxConfig, SandboxConfigSchema, SandboxGroup, type SandboxGroupConfig, SandboxGroupConfigSchema, type SandboxResponse, SandboxResponseSchema, type RunModeType as SandboxRunModeType, type SandboxStatusResponse, SandboxStatusResponseSchema, SpeedupType, type StepResult, type UploadRequest, UploadRequestSchema, type UploadResponse, UploadResponseSchema, VERSION, type WriteFileRequest, WriteFileRequestSchema, type WriteFileResponse, WriteFileResponseSchema, arunWithRetry, createRockEnvInfo, createSandboxConfig, createSandboxGroupConfig, deprecated, deprecatedClass, extractNohupPid as extractNohupPidFromSandbox, fromRockException, getEnv, getReasonPhrase, getRequiredEnv, isBrowser, isClientError, isCommandError, isEnvSet, isError, isNode, isServerError, isSuccess, make, raiseForCode, retryAsync, rockEnvInfoToDict, sleep, withRetry, withTimeLogging };
|