rl-rock 1.2.2 → 1.2.4
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 +33 -11
- package/dist/index.d.ts +33 -11
- package/dist/index.js +77 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
package/dist/index.d.mts
CHANGED
|
@@ -268,6 +268,9 @@ declare const SandboxStatusResponseSchema: z.ZodObject<{
|
|
|
268
268
|
cpus: z.ZodOptional<z.ZodNumber>;
|
|
269
269
|
memory: z.ZodOptional<z.ZodString>;
|
|
270
270
|
state: z.ZodOptional<z.ZodUnknown>;
|
|
271
|
+
cluster: z.ZodOptional<z.ZodString>;
|
|
272
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
273
|
+
eagleeyeTraceid: z.ZodOptional<z.ZodString>;
|
|
271
274
|
}, "strip", z.ZodTypeAny, {
|
|
272
275
|
isAlive: boolean;
|
|
273
276
|
status?: Record<string, unknown> | undefined;
|
|
@@ -284,6 +287,9 @@ declare const SandboxStatusResponseSchema: z.ZodObject<{
|
|
|
284
287
|
cpus?: number | undefined;
|
|
285
288
|
memory?: string | undefined;
|
|
286
289
|
state?: unknown;
|
|
290
|
+
cluster?: string | undefined;
|
|
291
|
+
requestId?: string | undefined;
|
|
292
|
+
eagleeyeTraceid?: string | undefined;
|
|
287
293
|
}, {
|
|
288
294
|
status?: Record<string, unknown> | undefined;
|
|
289
295
|
isAlive?: boolean | undefined;
|
|
@@ -300,6 +306,9 @@ declare const SandboxStatusResponseSchema: z.ZodObject<{
|
|
|
300
306
|
cpus?: number | undefined;
|
|
301
307
|
memory?: string | undefined;
|
|
302
308
|
state?: unknown;
|
|
309
|
+
cluster?: string | undefined;
|
|
310
|
+
requestId?: string | undefined;
|
|
311
|
+
eagleeyeTraceid?: string | undefined;
|
|
303
312
|
}>;
|
|
304
313
|
type SandboxStatusResponse = z.infer<typeof SandboxStatusResponseSchema>;
|
|
305
314
|
/**
|
|
@@ -546,6 +555,15 @@ declare function raiseForCode(code: Codes | null | undefined, message: string):
|
|
|
546
555
|
*/
|
|
547
556
|
declare function fromRockException(e: RockException): SandboxResponse;
|
|
548
557
|
|
|
558
|
+
/**
|
|
559
|
+
* HTTP response with headers
|
|
560
|
+
*/
|
|
561
|
+
interface HttpResponse<T = unknown> {
|
|
562
|
+
status: string;
|
|
563
|
+
result?: T;
|
|
564
|
+
error?: string;
|
|
565
|
+
headers: Record<string, string>;
|
|
566
|
+
}
|
|
549
567
|
/**
|
|
550
568
|
* HTTP utilities class
|
|
551
569
|
*/
|
|
@@ -561,12 +579,16 @@ declare class HttpUtils {
|
|
|
561
579
|
* Automatically converts request body from camelCase to snake_case
|
|
562
580
|
* Automatically converts response from snake_case to camelCase
|
|
563
581
|
*/
|
|
564
|
-
static post<T = unknown>(url: string, headers: Record<string, string>, data: Record<string, unknown>, readTimeout?: number): Promise<T
|
|
582
|
+
static post<T = unknown>(url: string, headers: Record<string, string>, data: Record<string, unknown>, readTimeout?: number): Promise<HttpResponse<T>>;
|
|
565
583
|
/**
|
|
566
584
|
* Send GET request
|
|
567
585
|
* Automatically converts response from snake_case to camelCase
|
|
568
586
|
*/
|
|
569
|
-
static get<T = unknown>(url: string, headers: Record<string, string>): Promise<T
|
|
587
|
+
static get<T = unknown>(url: string, headers: Record<string, string>): Promise<HttpResponse<T>>;
|
|
588
|
+
/**
|
|
589
|
+
* Extract headers from axios response
|
|
590
|
+
*/
|
|
591
|
+
private static extractHeaders;
|
|
570
592
|
/**
|
|
571
593
|
* Convert camelCase key to snake_case
|
|
572
594
|
*/
|
|
@@ -576,7 +598,7 @@ declare class HttpUtils {
|
|
|
576
598
|
* Automatically converts form data keys to snake_case
|
|
577
599
|
* Automatically converts response from snake_case to camelCase
|
|
578
600
|
*/
|
|
579
|
-
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
|
|
601
|
+
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<HttpResponse<T>>;
|
|
580
602
|
/**
|
|
581
603
|
* Guess MIME type from filename
|
|
582
604
|
*/
|
|
@@ -870,11 +892,11 @@ declare const SandboxConfigSchema: z.ZodObject<{
|
|
|
870
892
|
image: string;
|
|
871
893
|
cpus: number;
|
|
872
894
|
memory: string;
|
|
895
|
+
cluster: string;
|
|
873
896
|
baseUrl: string;
|
|
874
897
|
extraHeaders: Record<string, string>;
|
|
875
898
|
autoClearSeconds: number;
|
|
876
899
|
startupTimeout: number;
|
|
877
|
-
cluster: string;
|
|
878
900
|
userId?: string | undefined;
|
|
879
901
|
experimentId?: string | undefined;
|
|
880
902
|
namespace?: string | undefined;
|
|
@@ -887,13 +909,13 @@ declare const SandboxConfigSchema: z.ZodObject<{
|
|
|
887
909
|
namespace?: string | undefined;
|
|
888
910
|
cpus?: number | undefined;
|
|
889
911
|
memory?: string | undefined;
|
|
912
|
+
cluster?: string | undefined;
|
|
890
913
|
baseUrl?: string | undefined;
|
|
891
914
|
xrlAuthorization?: string | undefined;
|
|
892
915
|
extraHeaders?: Record<string, string> | undefined;
|
|
893
916
|
autoClearSeconds?: number | undefined;
|
|
894
917
|
routeKey?: string | undefined;
|
|
895
918
|
startupTimeout?: number | undefined;
|
|
896
|
-
cluster?: string | undefined;
|
|
897
919
|
}>;
|
|
898
920
|
type SandboxConfig = z.infer<typeof SandboxConfigSchema>;
|
|
899
921
|
/**
|
|
@@ -922,11 +944,11 @@ declare const SandboxGroupConfigSchema: z.ZodObject<{
|
|
|
922
944
|
image: string;
|
|
923
945
|
cpus: number;
|
|
924
946
|
memory: string;
|
|
947
|
+
cluster: string;
|
|
925
948
|
baseUrl: string;
|
|
926
949
|
extraHeaders: Record<string, string>;
|
|
927
950
|
autoClearSeconds: number;
|
|
928
951
|
startupTimeout: number;
|
|
929
|
-
cluster: string;
|
|
930
952
|
size: number;
|
|
931
953
|
startConcurrency: number;
|
|
932
954
|
startRetryTimes: number;
|
|
@@ -942,13 +964,13 @@ declare const SandboxGroupConfigSchema: z.ZodObject<{
|
|
|
942
964
|
namespace?: string | undefined;
|
|
943
965
|
cpus?: number | undefined;
|
|
944
966
|
memory?: string | undefined;
|
|
967
|
+
cluster?: string | undefined;
|
|
945
968
|
baseUrl?: string | undefined;
|
|
946
969
|
xrlAuthorization?: string | undefined;
|
|
947
970
|
extraHeaders?: Record<string, string> | undefined;
|
|
948
971
|
autoClearSeconds?: number | undefined;
|
|
949
972
|
routeKey?: string | undefined;
|
|
950
973
|
startupTimeout?: number | undefined;
|
|
951
|
-
cluster?: string | undefined;
|
|
952
974
|
size?: number | undefined;
|
|
953
975
|
startConcurrency?: number | undefined;
|
|
954
976
|
startRetryTimes?: number | undefined;
|
|
@@ -1136,8 +1158,8 @@ declare abstract class AbstractSandbox {
|
|
|
1136
1158
|
abstract isAlive(): Promise<IsAliveResponse>;
|
|
1137
1159
|
abstract createSession(request: CreateBashSessionRequest): Promise<CreateSessionResponse>;
|
|
1138
1160
|
abstract execute(command: Command): Promise<CommandResponse>;
|
|
1139
|
-
abstract
|
|
1140
|
-
abstract
|
|
1161
|
+
abstract readFile(request: ReadFileRequest): Promise<ReadFileResponse>;
|
|
1162
|
+
abstract writeFile(request: WriteFileRequest): Promise<WriteFileResponse>;
|
|
1141
1163
|
abstract upload(request: UploadRequest): Promise<UploadResponse>;
|
|
1142
1164
|
abstract closeSession(request: CloseSessionRequest): Promise<CloseSessionResponse>;
|
|
1143
1165
|
abstract close(): Promise<void>;
|
|
@@ -1192,8 +1214,8 @@ declare class Sandbox extends AbstractSandbox {
|
|
|
1192
1214
|
private runInSession;
|
|
1193
1215
|
private arunWithNohup;
|
|
1194
1216
|
private waitForProcessCompletion;
|
|
1195
|
-
|
|
1196
|
-
|
|
1217
|
+
writeFile(request: WriteFileRequest): Promise<WriteFileResponse>;
|
|
1218
|
+
readFile(request: ReadFileRequest): Promise<ReadFileResponse>;
|
|
1197
1219
|
upload(request: UploadRequest): Promise<UploadResponse>;
|
|
1198
1220
|
uploadByPath(sourcePath: string, targetPath: string): Promise<UploadResponse>;
|
|
1199
1221
|
close(): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -268,6 +268,9 @@ declare const SandboxStatusResponseSchema: z.ZodObject<{
|
|
|
268
268
|
cpus: z.ZodOptional<z.ZodNumber>;
|
|
269
269
|
memory: z.ZodOptional<z.ZodString>;
|
|
270
270
|
state: z.ZodOptional<z.ZodUnknown>;
|
|
271
|
+
cluster: z.ZodOptional<z.ZodString>;
|
|
272
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
273
|
+
eagleeyeTraceid: z.ZodOptional<z.ZodString>;
|
|
271
274
|
}, "strip", z.ZodTypeAny, {
|
|
272
275
|
isAlive: boolean;
|
|
273
276
|
status?: Record<string, unknown> | undefined;
|
|
@@ -284,6 +287,9 @@ declare const SandboxStatusResponseSchema: z.ZodObject<{
|
|
|
284
287
|
cpus?: number | undefined;
|
|
285
288
|
memory?: string | undefined;
|
|
286
289
|
state?: unknown;
|
|
290
|
+
cluster?: string | undefined;
|
|
291
|
+
requestId?: string | undefined;
|
|
292
|
+
eagleeyeTraceid?: string | undefined;
|
|
287
293
|
}, {
|
|
288
294
|
status?: Record<string, unknown> | undefined;
|
|
289
295
|
isAlive?: boolean | undefined;
|
|
@@ -300,6 +306,9 @@ declare const SandboxStatusResponseSchema: z.ZodObject<{
|
|
|
300
306
|
cpus?: number | undefined;
|
|
301
307
|
memory?: string | undefined;
|
|
302
308
|
state?: unknown;
|
|
309
|
+
cluster?: string | undefined;
|
|
310
|
+
requestId?: string | undefined;
|
|
311
|
+
eagleeyeTraceid?: string | undefined;
|
|
303
312
|
}>;
|
|
304
313
|
type SandboxStatusResponse = z.infer<typeof SandboxStatusResponseSchema>;
|
|
305
314
|
/**
|
|
@@ -546,6 +555,15 @@ declare function raiseForCode(code: Codes | null | undefined, message: string):
|
|
|
546
555
|
*/
|
|
547
556
|
declare function fromRockException(e: RockException): SandboxResponse;
|
|
548
557
|
|
|
558
|
+
/**
|
|
559
|
+
* HTTP response with headers
|
|
560
|
+
*/
|
|
561
|
+
interface HttpResponse<T = unknown> {
|
|
562
|
+
status: string;
|
|
563
|
+
result?: T;
|
|
564
|
+
error?: string;
|
|
565
|
+
headers: Record<string, string>;
|
|
566
|
+
}
|
|
549
567
|
/**
|
|
550
568
|
* HTTP utilities class
|
|
551
569
|
*/
|
|
@@ -561,12 +579,16 @@ declare class HttpUtils {
|
|
|
561
579
|
* Automatically converts request body from camelCase to snake_case
|
|
562
580
|
* Automatically converts response from snake_case to camelCase
|
|
563
581
|
*/
|
|
564
|
-
static post<T = unknown>(url: string, headers: Record<string, string>, data: Record<string, unknown>, readTimeout?: number): Promise<T
|
|
582
|
+
static post<T = unknown>(url: string, headers: Record<string, string>, data: Record<string, unknown>, readTimeout?: number): Promise<HttpResponse<T>>;
|
|
565
583
|
/**
|
|
566
584
|
* Send GET request
|
|
567
585
|
* Automatically converts response from snake_case to camelCase
|
|
568
586
|
*/
|
|
569
|
-
static get<T = unknown>(url: string, headers: Record<string, string>): Promise<T
|
|
587
|
+
static get<T = unknown>(url: string, headers: Record<string, string>): Promise<HttpResponse<T>>;
|
|
588
|
+
/**
|
|
589
|
+
* Extract headers from axios response
|
|
590
|
+
*/
|
|
591
|
+
private static extractHeaders;
|
|
570
592
|
/**
|
|
571
593
|
* Convert camelCase key to snake_case
|
|
572
594
|
*/
|
|
@@ -576,7 +598,7 @@ declare class HttpUtils {
|
|
|
576
598
|
* Automatically converts form data keys to snake_case
|
|
577
599
|
* Automatically converts response from snake_case to camelCase
|
|
578
600
|
*/
|
|
579
|
-
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
|
|
601
|
+
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<HttpResponse<T>>;
|
|
580
602
|
/**
|
|
581
603
|
* Guess MIME type from filename
|
|
582
604
|
*/
|
|
@@ -870,11 +892,11 @@ declare const SandboxConfigSchema: z.ZodObject<{
|
|
|
870
892
|
image: string;
|
|
871
893
|
cpus: number;
|
|
872
894
|
memory: string;
|
|
895
|
+
cluster: string;
|
|
873
896
|
baseUrl: string;
|
|
874
897
|
extraHeaders: Record<string, string>;
|
|
875
898
|
autoClearSeconds: number;
|
|
876
899
|
startupTimeout: number;
|
|
877
|
-
cluster: string;
|
|
878
900
|
userId?: string | undefined;
|
|
879
901
|
experimentId?: string | undefined;
|
|
880
902
|
namespace?: string | undefined;
|
|
@@ -887,13 +909,13 @@ declare const SandboxConfigSchema: z.ZodObject<{
|
|
|
887
909
|
namespace?: string | undefined;
|
|
888
910
|
cpus?: number | undefined;
|
|
889
911
|
memory?: string | undefined;
|
|
912
|
+
cluster?: string | undefined;
|
|
890
913
|
baseUrl?: string | undefined;
|
|
891
914
|
xrlAuthorization?: string | undefined;
|
|
892
915
|
extraHeaders?: Record<string, string> | undefined;
|
|
893
916
|
autoClearSeconds?: number | undefined;
|
|
894
917
|
routeKey?: string | undefined;
|
|
895
918
|
startupTimeout?: number | undefined;
|
|
896
|
-
cluster?: string | undefined;
|
|
897
919
|
}>;
|
|
898
920
|
type SandboxConfig = z.infer<typeof SandboxConfigSchema>;
|
|
899
921
|
/**
|
|
@@ -922,11 +944,11 @@ declare const SandboxGroupConfigSchema: z.ZodObject<{
|
|
|
922
944
|
image: string;
|
|
923
945
|
cpus: number;
|
|
924
946
|
memory: string;
|
|
947
|
+
cluster: string;
|
|
925
948
|
baseUrl: string;
|
|
926
949
|
extraHeaders: Record<string, string>;
|
|
927
950
|
autoClearSeconds: number;
|
|
928
951
|
startupTimeout: number;
|
|
929
|
-
cluster: string;
|
|
930
952
|
size: number;
|
|
931
953
|
startConcurrency: number;
|
|
932
954
|
startRetryTimes: number;
|
|
@@ -942,13 +964,13 @@ declare const SandboxGroupConfigSchema: z.ZodObject<{
|
|
|
942
964
|
namespace?: string | undefined;
|
|
943
965
|
cpus?: number | undefined;
|
|
944
966
|
memory?: string | undefined;
|
|
967
|
+
cluster?: string | undefined;
|
|
945
968
|
baseUrl?: string | undefined;
|
|
946
969
|
xrlAuthorization?: string | undefined;
|
|
947
970
|
extraHeaders?: Record<string, string> | undefined;
|
|
948
971
|
autoClearSeconds?: number | undefined;
|
|
949
972
|
routeKey?: string | undefined;
|
|
950
973
|
startupTimeout?: number | undefined;
|
|
951
|
-
cluster?: string | undefined;
|
|
952
974
|
size?: number | undefined;
|
|
953
975
|
startConcurrency?: number | undefined;
|
|
954
976
|
startRetryTimes?: number | undefined;
|
|
@@ -1136,8 +1158,8 @@ declare abstract class AbstractSandbox {
|
|
|
1136
1158
|
abstract isAlive(): Promise<IsAliveResponse>;
|
|
1137
1159
|
abstract createSession(request: CreateBashSessionRequest): Promise<CreateSessionResponse>;
|
|
1138
1160
|
abstract execute(command: Command): Promise<CommandResponse>;
|
|
1139
|
-
abstract
|
|
1140
|
-
abstract
|
|
1161
|
+
abstract readFile(request: ReadFileRequest): Promise<ReadFileResponse>;
|
|
1162
|
+
abstract writeFile(request: WriteFileRequest): Promise<WriteFileResponse>;
|
|
1141
1163
|
abstract upload(request: UploadRequest): Promise<UploadResponse>;
|
|
1142
1164
|
abstract closeSession(request: CloseSessionRequest): Promise<CloseSessionResponse>;
|
|
1143
1165
|
abstract close(): Promise<void>;
|
|
@@ -1192,8 +1214,8 @@ declare class Sandbox extends AbstractSandbox {
|
|
|
1192
1214
|
private runInSession;
|
|
1193
1215
|
private arunWithNohup;
|
|
1194
1216
|
private waitForProcessCompletion;
|
|
1195
|
-
|
|
1196
|
-
|
|
1217
|
+
writeFile(request: WriteFileRequest): Promise<WriteFileResponse>;
|
|
1218
|
+
readFile(request: ReadFileRequest): Promise<ReadFileResponse>;
|
|
1197
1219
|
upload(request: UploadRequest): Promise<UploadResponse>;
|
|
1198
1220
|
uploadByPath(sourcePath: string, targetPath: string): Promise<UploadResponse>;
|
|
1199
1221
|
close(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -118,7 +118,11 @@ var SandboxStatusResponseSchema = zod.z.object({
|
|
|
118
118
|
namespace: zod.z.string().optional(),
|
|
119
119
|
cpus: zod.z.number().optional(),
|
|
120
120
|
memory: zod.z.string().optional(),
|
|
121
|
-
state: zod.z.unknown().optional()
|
|
121
|
+
state: zod.z.unknown().optional(),
|
|
122
|
+
// Response headers info
|
|
123
|
+
cluster: zod.z.string().optional(),
|
|
124
|
+
requestId: zod.z.string().optional(),
|
|
125
|
+
eagleeyeTraceid: zod.z.string().optional()
|
|
122
126
|
});
|
|
123
127
|
var CommandResponseSchema = zod.z.object({
|
|
124
128
|
stdout: zod.z.string().default(""),
|
|
@@ -290,7 +294,18 @@ var HttpUtils = class {
|
|
|
290
294
|
const snakeData = objectToSnake(data);
|
|
291
295
|
try {
|
|
292
296
|
const response = await client.post(url, snakeData);
|
|
293
|
-
|
|
297
|
+
const camelData = objectToCamel(response.data);
|
|
298
|
+
const httpResponse = {
|
|
299
|
+
status: camelData.status ?? "Success",
|
|
300
|
+
headers: this.extractHeaders(response)
|
|
301
|
+
};
|
|
302
|
+
if (camelData.result !== void 0) {
|
|
303
|
+
httpResponse.result = camelData.result;
|
|
304
|
+
}
|
|
305
|
+
if (camelData.error !== void 0) {
|
|
306
|
+
httpResponse.error = camelData.error;
|
|
307
|
+
}
|
|
308
|
+
return httpResponse;
|
|
294
309
|
} catch (error) {
|
|
295
310
|
if (error instanceof axios3.AxiosError) {
|
|
296
311
|
throw new Error(`Failed to POST ${url}: ${error.message}`);
|
|
@@ -306,7 +321,18 @@ var HttpUtils = class {
|
|
|
306
321
|
const client = this.createClient({ headers });
|
|
307
322
|
try {
|
|
308
323
|
const response = await client.get(url);
|
|
309
|
-
|
|
324
|
+
const camelData = objectToCamel(response.data);
|
|
325
|
+
const httpResponse = {
|
|
326
|
+
status: camelData.status ?? "Success",
|
|
327
|
+
headers: this.extractHeaders(response)
|
|
328
|
+
};
|
|
329
|
+
if (camelData.result !== void 0) {
|
|
330
|
+
httpResponse.result = camelData.result;
|
|
331
|
+
}
|
|
332
|
+
if (camelData.error !== void 0) {
|
|
333
|
+
httpResponse.error = camelData.error;
|
|
334
|
+
}
|
|
335
|
+
return httpResponse;
|
|
310
336
|
} catch (error) {
|
|
311
337
|
if (error instanceof axios3.AxiosError) {
|
|
312
338
|
throw new Error(`Failed to GET ${url}: ${error.message}`);
|
|
@@ -314,6 +340,20 @@ var HttpUtils = class {
|
|
|
314
340
|
throw error;
|
|
315
341
|
}
|
|
316
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Extract headers from axios response
|
|
345
|
+
*/
|
|
346
|
+
static extractHeaders(response) {
|
|
347
|
+
const headers = {};
|
|
348
|
+
for (const [key, value] of Object.entries(response.headers)) {
|
|
349
|
+
if (typeof value === "string") {
|
|
350
|
+
headers[key.toLowerCase()] = value;
|
|
351
|
+
} else if (Array.isArray(value)) {
|
|
352
|
+
headers[key.toLowerCase()] = value.join(", ");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return headers;
|
|
356
|
+
}
|
|
317
357
|
/**
|
|
318
358
|
* Convert camelCase key to snake_case
|
|
319
359
|
*/
|
|
@@ -360,7 +400,18 @@ var HttpUtils = class {
|
|
|
360
400
|
});
|
|
361
401
|
try {
|
|
362
402
|
const response = await client.post(url, formData);
|
|
363
|
-
|
|
403
|
+
const camelData = objectToCamel(response.data);
|
|
404
|
+
const httpResponse = {
|
|
405
|
+
status: camelData.status ?? "Success",
|
|
406
|
+
headers: this.extractHeaders(response)
|
|
407
|
+
};
|
|
408
|
+
if (camelData.result !== void 0) {
|
|
409
|
+
httpResponse.result = camelData.result;
|
|
410
|
+
}
|
|
411
|
+
if (camelData.error !== void 0) {
|
|
412
|
+
httpResponse.error = camelData.error;
|
|
413
|
+
}
|
|
414
|
+
return httpResponse;
|
|
364
415
|
} catch (error) {
|
|
365
416
|
if (error instanceof axios3.AxiosError) {
|
|
366
417
|
throw new Error(`Failed to POST multipart ${url}: ${error.message}`);
|
|
@@ -571,7 +622,7 @@ var EnvHubClient = class {
|
|
|
571
622
|
this.headers,
|
|
572
623
|
payload
|
|
573
624
|
);
|
|
574
|
-
return createRockEnvInfo(response);
|
|
625
|
+
return createRockEnvInfo(response.result);
|
|
575
626
|
} catch (e) {
|
|
576
627
|
throw new EnvHubError(`Failed to register environment: ${e}`);
|
|
577
628
|
}
|
|
@@ -588,7 +639,7 @@ var EnvHubClient = class {
|
|
|
588
639
|
this.headers,
|
|
589
640
|
payload
|
|
590
641
|
);
|
|
591
|
-
return createRockEnvInfo(response);
|
|
642
|
+
return createRockEnvInfo(response.result);
|
|
592
643
|
} catch (e) {
|
|
593
644
|
throw new EnvHubError(`Failed to get environment ${envName}: ${e}`);
|
|
594
645
|
}
|
|
@@ -608,7 +659,7 @@ var EnvHubClient = class {
|
|
|
608
659
|
this.headers,
|
|
609
660
|
payload
|
|
610
661
|
);
|
|
611
|
-
const envsData = response.envs ?? [];
|
|
662
|
+
const envsData = response.result?.envs ?? [];
|
|
612
663
|
return envsData.map((envData) => createRockEnvInfo(envData));
|
|
613
664
|
} catch (e) {
|
|
614
665
|
throw new EnvHubError(`Failed to list environments: ${e}`);
|
|
@@ -641,7 +692,7 @@ var EnvHubClient = class {
|
|
|
641
692
|
url,
|
|
642
693
|
this.headers
|
|
643
694
|
);
|
|
644
|
-
return response;
|
|
695
|
+
return response.result ?? {};
|
|
645
696
|
} catch (e) {
|
|
646
697
|
throw new EnvHubError(`Failed to health check: ${e}`);
|
|
647
698
|
}
|
|
@@ -1090,7 +1141,7 @@ var Process = class {
|
|
|
1090
1141
|
const scriptPath = `/tmp/${name}`;
|
|
1091
1142
|
try {
|
|
1092
1143
|
logger5.info(`[${sandboxId}] Uploading script to ${scriptPath}`);
|
|
1093
|
-
const writeResult = await this.sandbox.
|
|
1144
|
+
const writeResult = await this.sandbox.writeFile({
|
|
1094
1145
|
content: scriptContent,
|
|
1095
1146
|
path: scriptPath
|
|
1096
1147
|
});
|
|
@@ -1430,9 +1481,14 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1430
1481
|
const headers = this.buildHeaders();
|
|
1431
1482
|
const response = await HttpUtils.get(url, headers);
|
|
1432
1483
|
if (response.status !== "Success") {
|
|
1433
|
-
|
|
1484
|
+
const errorDetail = response.error ? `, error=${response.error}` : "";
|
|
1485
|
+
throw new Error(`Failed to get status: status=${response.status}${errorDetail}, result=${JSON.stringify(response.result)}`);
|
|
1434
1486
|
}
|
|
1435
|
-
|
|
1487
|
+
const result = response.result;
|
|
1488
|
+
result.cluster = response.headers["x-rock-gateway-target-cluster"] || this.config.cluster || "N/A";
|
|
1489
|
+
result.requestId = response.headers["x-request-id"] || response.headers["request-id"] || "N/A";
|
|
1490
|
+
result.eagleeyeTraceid = response.headers["eagleeye-traceid"] || "N/A";
|
|
1491
|
+
return result;
|
|
1436
1492
|
}
|
|
1437
1493
|
// Command execution
|
|
1438
1494
|
async execute(command) {
|
|
@@ -1452,7 +1508,8 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1452
1508
|
data
|
|
1453
1509
|
);
|
|
1454
1510
|
if (response.status !== "Success") {
|
|
1455
|
-
|
|
1511
|
+
const errorDetail = response.error ? `, error=${response.error}` : "";
|
|
1512
|
+
throw new Error(`Failed to execute command: status=${response.status}${errorDetail}, result=${JSON.stringify(response.result)}`);
|
|
1456
1513
|
}
|
|
1457
1514
|
return response.result;
|
|
1458
1515
|
} catch (e) {
|
|
@@ -1474,7 +1531,8 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1474
1531
|
data
|
|
1475
1532
|
);
|
|
1476
1533
|
if (response.status !== "Success") {
|
|
1477
|
-
|
|
1534
|
+
const errorDetail = response.error ? `, error=${response.error}` : "";
|
|
1535
|
+
throw new Error(`Failed to create session: status=${response.status}${errorDetail}, result=${JSON.stringify(response.result)}`);
|
|
1478
1536
|
}
|
|
1479
1537
|
return response.result;
|
|
1480
1538
|
} catch (e) {
|
|
@@ -1495,7 +1553,8 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1495
1553
|
data
|
|
1496
1554
|
);
|
|
1497
1555
|
if (response.status !== "Success") {
|
|
1498
|
-
|
|
1556
|
+
const errorDetail = response.error ? `, error=${response.error}` : "";
|
|
1557
|
+
throw new Error(`Failed to close session: status=${response.status}${errorDetail}, result=${JSON.stringify(response.result)}`);
|
|
1499
1558
|
}
|
|
1500
1559
|
return response.result ?? { sessionType: "bash" };
|
|
1501
1560
|
} catch (e) {
|
|
@@ -1541,7 +1600,8 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1541
1600
|
timeoutMs
|
|
1542
1601
|
);
|
|
1543
1602
|
if (response.status !== "Success") {
|
|
1544
|
-
|
|
1603
|
+
const errorDetail = response.error ? `, error=${response.error}` : "";
|
|
1604
|
+
throw new Error(`Failed to run in session: status=${response.status}${errorDetail}, result=${JSON.stringify(response.result)}`);
|
|
1545
1605
|
}
|
|
1546
1606
|
return response.result;
|
|
1547
1607
|
} catch (e) {
|
|
@@ -1629,7 +1689,7 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1629
1689
|
return false;
|
|
1630
1690
|
}
|
|
1631
1691
|
// File operations
|
|
1632
|
-
async
|
|
1692
|
+
async writeFile(request) {
|
|
1633
1693
|
const url = `${this.url}/write_file`;
|
|
1634
1694
|
const headers = this.buildHeaders();
|
|
1635
1695
|
const data = {
|
|
@@ -1643,7 +1703,7 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1643
1703
|
}
|
|
1644
1704
|
return { success: true, message: `Successfully write content to file ${request.path}` };
|
|
1645
1705
|
}
|
|
1646
|
-
async
|
|
1706
|
+
async readFile(request) {
|
|
1647
1707
|
const url = `${this.url}/read_file`;
|
|
1648
1708
|
const headers = this.buildHeaders();
|
|
1649
1709
|
const data = {
|