rl-rock 1.2.5 → 1.2.7
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 +25 -30
- package/dist/index.d.ts +25 -30
- package/dist/index.js +374 -224
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +377 -225
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -16
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import path, { join, resolve, basename } from 'path';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
import { existsSync, mkdirSync, readFileSync, statSync, mkdtempSync, rmSync
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, statSync, mkdtempSync, rmSync } from 'fs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import axios
|
|
5
|
+
import axios from 'axios';
|
|
6
6
|
import https from 'https';
|
|
7
7
|
import { objectToCamel as objectToCamel$1, objectToSnake as objectToSnake$1 } from 'ts-case-convert';
|
|
8
|
-
import { tmpdir } from 'os';
|
|
9
8
|
import winston from 'winston';
|
|
9
|
+
import { tmpdir, homedir } from 'os';
|
|
10
10
|
import { randomUUID } from 'crypto';
|
|
11
|
+
import { readFile, appendFile } from 'fs/promises';
|
|
11
12
|
|
|
12
13
|
// node_modules/.pnpm/tsup@8.5.1_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
|
|
13
14
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
@@ -174,14 +175,6 @@ var RunMode = {
|
|
|
174
175
|
NORMAL: "normal",
|
|
175
176
|
NOHUP: "nohup"
|
|
176
177
|
};
|
|
177
|
-
var Constants = class {
|
|
178
|
-
static BASE_URL_PRODUCT = "";
|
|
179
|
-
static BASE_URL_ALIYUN = "";
|
|
180
|
-
static BASE_URL_INNER = "";
|
|
181
|
-
static BASE_URL_PRE = "";
|
|
182
|
-
static BASE_URL_LOCAL = "";
|
|
183
|
-
static REQUEST_TIMEOUT_SECONDS = 180;
|
|
184
|
-
};
|
|
185
178
|
var PID_PREFIX = "__ROCK_PID_START__";
|
|
186
179
|
var PID_SUFFIX = "__ROCK_PID_END__";
|
|
187
180
|
|
|
@@ -259,6 +252,10 @@ var objectToCamel = objectToCamel$1;
|
|
|
259
252
|
var objectToSnake = objectToSnake$1;
|
|
260
253
|
|
|
261
254
|
// src/utils/http.ts
|
|
255
|
+
var sharedHttpsAgent = new https.Agent({
|
|
256
|
+
rejectUnauthorized: true,
|
|
257
|
+
keepAlive: true
|
|
258
|
+
});
|
|
262
259
|
var HttpUtils = class {
|
|
263
260
|
static defaultTimeout = 3e5;
|
|
264
261
|
// 5 minutes
|
|
@@ -273,9 +270,7 @@ var HttpUtils = class {
|
|
|
273
270
|
"Content-Type": "application/json",
|
|
274
271
|
...config?.headers
|
|
275
272
|
},
|
|
276
|
-
httpsAgent:
|
|
277
|
-
rejectUnauthorized: true
|
|
278
|
-
})
|
|
273
|
+
httpsAgent: sharedHttpsAgent
|
|
279
274
|
});
|
|
280
275
|
}
|
|
281
276
|
/**
|
|
@@ -304,9 +299,6 @@ var HttpUtils = class {
|
|
|
304
299
|
}
|
|
305
300
|
return httpResponse;
|
|
306
301
|
} catch (error) {
|
|
307
|
-
if (error instanceof AxiosError) {
|
|
308
|
-
throw new Error(`Failed to POST ${url}: ${error.message}`);
|
|
309
|
-
}
|
|
310
302
|
throw error;
|
|
311
303
|
}
|
|
312
304
|
}
|
|
@@ -331,9 +323,6 @@ var HttpUtils = class {
|
|
|
331
323
|
}
|
|
332
324
|
return httpResponse;
|
|
333
325
|
} catch (error) {
|
|
334
|
-
if (error instanceof AxiosError) {
|
|
335
|
-
throw new Error(`Failed to GET ${url}: ${error.message}`);
|
|
336
|
-
}
|
|
337
326
|
throw error;
|
|
338
327
|
}
|
|
339
328
|
}
|
|
@@ -413,9 +402,6 @@ var HttpUtils = class {
|
|
|
413
402
|
}
|
|
414
403
|
return httpResponse;
|
|
415
404
|
} catch (error) {
|
|
416
|
-
if (error instanceof AxiosError) {
|
|
417
|
-
throw new Error(`Failed to POST multipart ${url}: ${error.message}`);
|
|
418
|
-
}
|
|
419
405
|
throw error;
|
|
420
406
|
}
|
|
421
407
|
}
|
|
@@ -499,43 +485,12 @@ function withRetry(fn, options = {}) {
|
|
|
499
485
|
});
|
|
500
486
|
}
|
|
501
487
|
|
|
502
|
-
// src/utils/deprecated.ts
|
|
503
|
-
function deprecated(reason = "") {
|
|
504
|
-
return function(target, propertyKey, descriptor) {
|
|
505
|
-
const originalMethod = descriptor.value;
|
|
506
|
-
descriptor.value = function(...args) {
|
|
507
|
-
console.warn(
|
|
508
|
-
`${String(propertyKey)} is deprecated. ${reason}`
|
|
509
|
-
);
|
|
510
|
-
return originalMethod.apply(this, args);
|
|
511
|
-
};
|
|
512
|
-
return descriptor;
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
function deprecatedClass(reason = "") {
|
|
516
|
-
return function(constructor) {
|
|
517
|
-
return class extends constructor {
|
|
518
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
519
|
-
constructor(...args) {
|
|
520
|
-
console.warn(`${constructor.name} is deprecated. ${reason}`);
|
|
521
|
-
super(...args);
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
488
|
// src/utils/system.ts
|
|
528
489
|
function isNode() {
|
|
529
490
|
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
530
491
|
}
|
|
531
|
-
function isBrowser() {
|
|
532
|
-
return typeof globalThis !== "undefined" && "window" in globalThis && typeof globalThis.window !== "undefined";
|
|
533
|
-
}
|
|
534
492
|
function getEnv(key, defaultValue) {
|
|
535
|
-
|
|
536
|
-
return process.env[key] ?? defaultValue;
|
|
537
|
-
}
|
|
538
|
-
return defaultValue;
|
|
493
|
+
return process.env[key] ?? defaultValue;
|
|
539
494
|
}
|
|
540
495
|
function getRequiredEnv(key) {
|
|
541
496
|
const value = getEnv(key);
|
|
@@ -545,10 +500,7 @@ function getRequiredEnv(key) {
|
|
|
545
500
|
return value;
|
|
546
501
|
}
|
|
547
502
|
function isEnvSet(key) {
|
|
548
|
-
|
|
549
|
-
return key in process.env;
|
|
550
|
-
}
|
|
551
|
-
return false;
|
|
503
|
+
return key in process.env;
|
|
552
504
|
}
|
|
553
505
|
var envVars = {
|
|
554
506
|
// Logging
|
|
@@ -561,25 +513,117 @@ var envVars = {
|
|
|
561
513
|
get ROCK_LOGGING_LEVEL() {
|
|
562
514
|
return getEnv("ROCK_LOGGING_LEVEL", "INFO");
|
|
563
515
|
},
|
|
516
|
+
// Service
|
|
517
|
+
get ROCK_SERVICE_STATUS_DIR() {
|
|
518
|
+
return getEnv("ROCK_SERVICE_STATUS_DIR", "/data/service_status");
|
|
519
|
+
},
|
|
520
|
+
get ROCK_SCHEDULER_STATUS_DIR() {
|
|
521
|
+
return getEnv("ROCK_SCHEDULER_STATUS_DIR", "/data/scheduler_status");
|
|
522
|
+
},
|
|
523
|
+
// Config
|
|
524
|
+
get ROCK_CONFIG() {
|
|
525
|
+
return getEnv("ROCK_CONFIG");
|
|
526
|
+
},
|
|
527
|
+
get ROCK_CONFIG_DIR_NAME() {
|
|
528
|
+
return getEnv("ROCK_CONFIG_DIR_NAME", "rock-conf");
|
|
529
|
+
},
|
|
564
530
|
// Base URLs
|
|
565
531
|
get ROCK_BASE_URL() {
|
|
566
532
|
return getEnv("ROCK_BASE_URL", "http://localhost:8080");
|
|
567
533
|
},
|
|
534
|
+
get ROCK_WORKER_ROCKLET_PORT() {
|
|
535
|
+
const val = getEnv("ROCK_WORKER_ROCKLET_PORT");
|
|
536
|
+
return val ? parseInt(val, 10) : void 0;
|
|
537
|
+
},
|
|
568
538
|
get ROCK_SANDBOX_STARTUP_TIMEOUT_SECONDS() {
|
|
569
539
|
return parseInt(getEnv("ROCK_SANDBOX_STARTUP_TIMEOUT_SECONDS", "180"), 10);
|
|
570
540
|
},
|
|
541
|
+
get ROCK_CODE_SANDBOX_BASE_URL() {
|
|
542
|
+
return getEnv("ROCK_CODE_SANDBOX_BASE_URL", "");
|
|
543
|
+
},
|
|
571
544
|
// EnvHub
|
|
572
545
|
get ROCK_ENVHUB_BASE_URL() {
|
|
573
546
|
return getEnv("ROCK_ENVHUB_BASE_URL", "http://localhost:8081");
|
|
574
547
|
},
|
|
548
|
+
get ROCK_ENVHUB_DEFAULT_DOCKER_IMAGE() {
|
|
549
|
+
return getEnv("ROCK_ENVHUB_DEFAULT_DOCKER_IMAGE", "python:3.11");
|
|
550
|
+
},
|
|
551
|
+
get ROCK_ENVHUB_DB_URL() {
|
|
552
|
+
return getEnv(
|
|
553
|
+
"ROCK_ENVHUB_DB_URL",
|
|
554
|
+
`sqlite:///${join(homedir(), ".rock", "rock_envs.db")}`
|
|
555
|
+
);
|
|
556
|
+
},
|
|
557
|
+
// Auto clear
|
|
558
|
+
get ROCK_DEFAULT_AUTO_CLEAR_TIME_MINUTES() {
|
|
559
|
+
return parseInt(getEnv("ROCK_DEFAULT_AUTO_CLEAR_TIME_MINUTES", "360"), 10);
|
|
560
|
+
},
|
|
561
|
+
// Ray
|
|
562
|
+
get ROCK_RAY_NAMESPACE() {
|
|
563
|
+
return getEnv("ROCK_RAY_NAMESPACE", "xrl-sandbox");
|
|
564
|
+
},
|
|
565
|
+
get ROCK_SANDBOX_EXPIRE_TIME_KEY() {
|
|
566
|
+
return getEnv("ROCK_SANDBOX_EXPIRE_TIME_KEY", "expire_time");
|
|
567
|
+
},
|
|
568
|
+
get ROCK_SANDBOX_AUTO_CLEAR_TIME_KEY() {
|
|
569
|
+
return getEnv("ROCK_SANDBOX_AUTO_CLEAR_TIME_KEY", "auto_clear_time");
|
|
570
|
+
},
|
|
571
|
+
// Timezone
|
|
572
|
+
get ROCK_TIME_ZONE() {
|
|
573
|
+
return getEnv("ROCK_TIME_ZONE", "Asia/Shanghai");
|
|
574
|
+
},
|
|
575
|
+
// OSS
|
|
576
|
+
get ROCK_OSS_ENABLE() {
|
|
577
|
+
return getEnv("ROCK_OSS_ENABLE", "false")?.toLowerCase() === "true";
|
|
578
|
+
},
|
|
579
|
+
get ROCK_OSS_BUCKET_ENDPOINT() {
|
|
580
|
+
return getEnv("ROCK_OSS_BUCKET_ENDPOINT");
|
|
581
|
+
},
|
|
582
|
+
get ROCK_OSS_BUCKET_NAME() {
|
|
583
|
+
return getEnv("ROCK_OSS_BUCKET_NAME");
|
|
584
|
+
},
|
|
585
|
+
get ROCK_OSS_BUCKET_REGION() {
|
|
586
|
+
return getEnv("ROCK_OSS_BUCKET_REGION");
|
|
587
|
+
},
|
|
575
588
|
// Pip
|
|
576
589
|
get ROCK_PIP_INDEX_URL() {
|
|
577
|
-
return getEnv("ROCK_PIP_INDEX_URL", "https://
|
|
590
|
+
return getEnv("ROCK_PIP_INDEX_URL", "https://pypi.org/simple/");
|
|
591
|
+
},
|
|
592
|
+
// Monitor
|
|
593
|
+
get ROCK_MONITOR_ENABLE() {
|
|
594
|
+
return getEnv("ROCK_MONITOR_ENABLE", "false")?.toLowerCase() === "true";
|
|
595
|
+
},
|
|
596
|
+
// Project
|
|
597
|
+
get ROCK_PROJECT_ROOT() {
|
|
598
|
+
return getEnv("ROCK_PROJECT_ROOT", process.cwd());
|
|
599
|
+
},
|
|
600
|
+
get ROCK_WORKER_ENV_TYPE() {
|
|
601
|
+
return getEnv("ROCK_WORKER_ENV_TYPE", "local");
|
|
602
|
+
},
|
|
603
|
+
get ROCK_PYTHON_ENV_PATH() {
|
|
604
|
+
return getEnv("ROCK_PYTHON_ENV_PATH", process.cwd());
|
|
605
|
+
},
|
|
606
|
+
// Admin
|
|
607
|
+
get ROCK_ADMIN_ENV() {
|
|
608
|
+
return getEnv("ROCK_ADMIN_ENV", "dev");
|
|
609
|
+
},
|
|
610
|
+
get ROCK_ADMIN_ROLE() {
|
|
611
|
+
return getEnv("ROCK_ADMIN_ROLE", "write");
|
|
612
|
+
},
|
|
613
|
+
// CLI
|
|
614
|
+
get ROCK_CLI_LOAD_PATHS() {
|
|
615
|
+
return getEnv("ROCK_CLI_LOAD_PATHS", "");
|
|
616
|
+
},
|
|
617
|
+
get ROCK_CLI_DEFAULT_CONFIG_PATH() {
|
|
618
|
+
return getEnv("ROCK_CLI_DEFAULT_CONFIG_PATH", join(homedir(), ".rock", "config.ini"));
|
|
578
619
|
},
|
|
579
620
|
// Model Service
|
|
580
621
|
get ROCK_MODEL_SERVICE_DATA_DIR() {
|
|
581
622
|
return getEnv("ROCK_MODEL_SERVICE_DATA_DIR", "/data/logs");
|
|
582
623
|
},
|
|
624
|
+
get ROCK_MODEL_SERVICE_TRAJ_APPEND_MODE() {
|
|
625
|
+
return getEnv("ROCK_MODEL_SERVICE_TRAJ_APPEND_MODE", "false")?.toLowerCase() === "true";
|
|
626
|
+
},
|
|
583
627
|
// RuntimeEnv
|
|
584
628
|
get ROCK_RTENV_PYTHON_V31114_INSTALL_CMD() {
|
|
585
629
|
return getEnv(
|
|
@@ -608,11 +652,167 @@ var envVars = {
|
|
|
608
652
|
return [];
|
|
609
653
|
}
|
|
610
654
|
},
|
|
655
|
+
get ROCK_AGENT_IFLOW_CLI_INSTALL_CMD() {
|
|
656
|
+
return getEnv("ROCK_AGENT_IFLOW_CLI_INSTALL_CMD", "npm i -g @iflow-ai/iflow-cli@latest");
|
|
657
|
+
},
|
|
611
658
|
get ROCK_MODEL_SERVICE_INSTALL_CMD() {
|
|
612
659
|
return getEnv("ROCK_MODEL_SERVICE_INSTALL_CMD", "pip install rl_rock[model-service]");
|
|
613
|
-
}
|
|
660
|
+
},
|
|
661
|
+
// Doccuum
|
|
662
|
+
get ROCK_DOCUUM_INSTALL_URL() {
|
|
663
|
+
return getEnv(
|
|
664
|
+
"ROCK_DOCUUM_INSTALL_URL",
|
|
665
|
+
"https://raw.githubusercontent.com/stepchowfun/docuum/main/install.sh"
|
|
666
|
+
);
|
|
667
|
+
},
|
|
668
|
+
// ========== Sandbox Defaults ==========
|
|
669
|
+
// Sandbox configuration defaults - allow users to override via environment variables
|
|
670
|
+
get ROCK_DEFAULT_IMAGE() {
|
|
671
|
+
return getEnv("ROCK_DEFAULT_IMAGE", "python:3.11");
|
|
672
|
+
},
|
|
673
|
+
get ROCK_DEFAULT_MEMORY() {
|
|
674
|
+
return getEnv("ROCK_DEFAULT_MEMORY", "8g");
|
|
675
|
+
},
|
|
676
|
+
get ROCK_DEFAULT_CPUS() {
|
|
677
|
+
return parseFloat(getEnv("ROCK_DEFAULT_CPUS", "2"));
|
|
678
|
+
},
|
|
679
|
+
get ROCK_DEFAULT_CLUSTER() {
|
|
680
|
+
return getEnv("ROCK_DEFAULT_CLUSTER", "zb");
|
|
681
|
+
},
|
|
682
|
+
get ROCK_DEFAULT_AUTO_CLEAR_SECONDS() {
|
|
683
|
+
return parseInt(getEnv("ROCK_DEFAULT_AUTO_CLEAR_SECONDS", "300"), 10);
|
|
684
|
+
},
|
|
685
|
+
// ========== SandboxGroup Defaults ==========
|
|
686
|
+
get ROCK_DEFAULT_GROUP_SIZE() {
|
|
687
|
+
return parseInt(getEnv("ROCK_DEFAULT_GROUP_SIZE", "2"), 10);
|
|
688
|
+
},
|
|
689
|
+
get ROCK_DEFAULT_START_CONCURRENCY() {
|
|
690
|
+
return parseInt(getEnv("ROCK_DEFAULT_START_CONCURRENCY", "2"), 10);
|
|
691
|
+
},
|
|
692
|
+
get ROCK_DEFAULT_START_RETRY_TIMES() {
|
|
693
|
+
return parseInt(getEnv("ROCK_DEFAULT_START_RETRY_TIMES", "3"), 10);
|
|
694
|
+
},
|
|
695
|
+
// ========== Client Timeouts (in seconds) ==========
|
|
696
|
+
get ROCK_DEFAULT_ARUN_TIMEOUT() {
|
|
697
|
+
return parseInt(getEnv("ROCK_DEFAULT_ARUN_TIMEOUT", "300"), 10);
|
|
698
|
+
},
|
|
699
|
+
get ROCK_DEFAULT_NOHUP_WAIT_TIMEOUT() {
|
|
700
|
+
return parseInt(getEnv("ROCK_DEFAULT_NOHUP_WAIT_TIMEOUT", "300"), 10);
|
|
701
|
+
},
|
|
702
|
+
get ROCK_DEFAULT_NOHUP_WAIT_INTERVAL() {
|
|
703
|
+
return parseInt(getEnv("ROCK_DEFAULT_NOHUP_WAIT_INTERVAL", "10"), 10);
|
|
704
|
+
},
|
|
705
|
+
get ROCK_DEFAULT_STATUS_CHECK_INTERVAL() {
|
|
706
|
+
return parseInt(getEnv("ROCK_DEFAULT_STATUS_CHECK_INTERVAL", "3"), 10);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
var levels = {
|
|
710
|
+
error: 0,
|
|
711
|
+
warn: 1,
|
|
712
|
+
info: 2,
|
|
713
|
+
http: 3,
|
|
714
|
+
debug: 4
|
|
715
|
+
};
|
|
716
|
+
var colors = {
|
|
717
|
+
error: "red",
|
|
718
|
+
warn: "yellow",
|
|
719
|
+
info: "green",
|
|
720
|
+
http: "magenta",
|
|
721
|
+
debug: "cyan"
|
|
722
|
+
};
|
|
723
|
+
winston.addColors(colors);
|
|
724
|
+
var consoleFormat = winston.format.combine(
|
|
725
|
+
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss.SSS" }),
|
|
726
|
+
winston.format.colorize({ all: true }),
|
|
727
|
+
winston.format.printf((info) => {
|
|
728
|
+
const { timestamp, level, message, ...meta } = info;
|
|
729
|
+
const metaStr = Object.keys(meta).length ? JSON.stringify(meta) : "";
|
|
730
|
+
return `${timestamp} ${level}: ${message} ${metaStr}`;
|
|
731
|
+
})
|
|
732
|
+
);
|
|
733
|
+
var fileFormat = winston.format.combine(
|
|
734
|
+
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss.SSS" }),
|
|
735
|
+
winston.format.json()
|
|
736
|
+
);
|
|
737
|
+
function getLogLevel() {
|
|
738
|
+
const level = envVars.ROCK_LOGGING_LEVEL.toLowerCase();
|
|
739
|
+
if (level in levels) {
|
|
740
|
+
return level;
|
|
741
|
+
}
|
|
742
|
+
return "info";
|
|
743
|
+
}
|
|
744
|
+
var loggerContainer = new winston.Container();
|
|
745
|
+
function initLogger(name = "rock", fileName) {
|
|
746
|
+
if (loggerContainer.has(name)) {
|
|
747
|
+
return loggerContainer.get(name);
|
|
748
|
+
}
|
|
749
|
+
const transports = [];
|
|
750
|
+
const logLevel = getLogLevel();
|
|
751
|
+
const logPath = envVars.ROCK_LOGGING_PATH;
|
|
752
|
+
const logFileName = envVars.ROCK_LOGGING_FILE_NAME;
|
|
753
|
+
if (logPath) {
|
|
754
|
+
if (!existsSync(logPath)) {
|
|
755
|
+
mkdirSync(logPath, { recursive: true });
|
|
756
|
+
}
|
|
757
|
+
transports.push(
|
|
758
|
+
new winston.transports.File({
|
|
759
|
+
filename: join(logPath, logFileName),
|
|
760
|
+
format: fileFormat,
|
|
761
|
+
level: logLevel
|
|
762
|
+
})
|
|
763
|
+
);
|
|
764
|
+
} else {
|
|
765
|
+
transports.push(
|
|
766
|
+
new winston.transports.Console({
|
|
767
|
+
format: consoleFormat,
|
|
768
|
+
level: logLevel
|
|
769
|
+
})
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
const logger13 = loggerContainer.add(name, {
|
|
773
|
+
levels,
|
|
774
|
+
defaultMeta: { service: name },
|
|
775
|
+
transports
|
|
776
|
+
});
|
|
777
|
+
return logger13;
|
|
778
|
+
}
|
|
779
|
+
initLogger("rock");
|
|
614
780
|
|
|
615
|
-
// src/
|
|
781
|
+
// src/utils/deprecated.ts
|
|
782
|
+
var warnedKeys = /* @__PURE__ */ new Set();
|
|
783
|
+
function getLogger() {
|
|
784
|
+
return initLogger("rock.deprecated");
|
|
785
|
+
}
|
|
786
|
+
function warnOnce(key, message) {
|
|
787
|
+
if (warnedKeys.has(key)) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
getLogger().warn(message);
|
|
791
|
+
warnedKeys.add(key);
|
|
792
|
+
}
|
|
793
|
+
function deprecated(reason = "") {
|
|
794
|
+
return function(target, propertyKey, descriptor) {
|
|
795
|
+
const originalMethod = descriptor.value;
|
|
796
|
+
const key = String(propertyKey);
|
|
797
|
+
descriptor.value = function(...args) {
|
|
798
|
+
warnOnce(key, `${key} is deprecated. ${reason}`);
|
|
799
|
+
return originalMethod.apply(this, args);
|
|
800
|
+
};
|
|
801
|
+
return descriptor;
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function deprecatedClass(reason = "") {
|
|
805
|
+
return function(constructor) {
|
|
806
|
+
const key = constructor.name;
|
|
807
|
+
return class extends constructor {
|
|
808
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
809
|
+
constructor(...args) {
|
|
810
|
+
warnOnce(key, `${key} is deprecated. ${reason}`);
|
|
811
|
+
super(...args);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
};
|
|
815
|
+
}
|
|
616
816
|
var EnvHubClientConfigSchema = z.object({
|
|
617
817
|
baseUrl: z.string().default(envVars.ROCK_ENVHUB_BASE_URL)
|
|
618
818
|
});
|
|
@@ -741,104 +941,51 @@ var EnvHubClient = class {
|
|
|
741
941
|
}
|
|
742
942
|
}
|
|
743
943
|
};
|
|
744
|
-
var levels = {
|
|
745
|
-
error: 0,
|
|
746
|
-
warn: 1,
|
|
747
|
-
info: 2,
|
|
748
|
-
http: 3,
|
|
749
|
-
debug: 4
|
|
750
|
-
};
|
|
751
|
-
var colors = {
|
|
752
|
-
error: "red",
|
|
753
|
-
warn: "yellow",
|
|
754
|
-
info: "green",
|
|
755
|
-
http: "magenta",
|
|
756
|
-
debug: "cyan"
|
|
757
|
-
};
|
|
758
|
-
winston.addColors(colors);
|
|
759
|
-
var consoleFormat = winston.format.combine(
|
|
760
|
-
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss.SSS" }),
|
|
761
|
-
winston.format.colorize({ all: true }),
|
|
762
|
-
winston.format.printf((info) => {
|
|
763
|
-
const { timestamp, level, message, ...meta } = info;
|
|
764
|
-
const metaStr = Object.keys(meta).length ? JSON.stringify(meta) : "";
|
|
765
|
-
return `${timestamp} ${level}: ${message} ${metaStr}`;
|
|
766
|
-
})
|
|
767
|
-
);
|
|
768
|
-
var fileFormat = winston.format.combine(
|
|
769
|
-
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss.SSS" }),
|
|
770
|
-
winston.format.json()
|
|
771
|
-
);
|
|
772
|
-
function getLogLevel() {
|
|
773
|
-
const level = envVars.ROCK_LOGGING_LEVEL.toLowerCase();
|
|
774
|
-
if (level in levels) {
|
|
775
|
-
return level;
|
|
776
|
-
}
|
|
777
|
-
return "info";
|
|
778
|
-
}
|
|
779
|
-
var loggerCache = /* @__PURE__ */ new Map();
|
|
780
|
-
function initLogger(name = "rock", fileName) {
|
|
781
|
-
if (loggerCache.has(name)) {
|
|
782
|
-
return loggerCache.get(name);
|
|
783
|
-
}
|
|
784
|
-
const transports = [];
|
|
785
|
-
const logLevel = getLogLevel();
|
|
786
|
-
const logPath = envVars.ROCK_LOGGING_PATH;
|
|
787
|
-
const logFileName = envVars.ROCK_LOGGING_FILE_NAME;
|
|
788
|
-
if (logPath) {
|
|
789
|
-
if (!existsSync(logPath)) {
|
|
790
|
-
mkdirSync(logPath, { recursive: true });
|
|
791
|
-
}
|
|
792
|
-
transports.push(
|
|
793
|
-
new winston.transports.File({
|
|
794
|
-
filename: join(logPath, logFileName),
|
|
795
|
-
format: fileFormat,
|
|
796
|
-
level: logLevel
|
|
797
|
-
})
|
|
798
|
-
);
|
|
799
|
-
} else {
|
|
800
|
-
transports.push(
|
|
801
|
-
new winston.transports.Console({
|
|
802
|
-
format: consoleFormat,
|
|
803
|
-
level: logLevel
|
|
804
|
-
})
|
|
805
|
-
);
|
|
806
|
-
}
|
|
807
|
-
const logger13 = winston.createLogger({
|
|
808
|
-
levels,
|
|
809
|
-
defaultMeta: { service: name },
|
|
810
|
-
transports
|
|
811
|
-
});
|
|
812
|
-
loggerCache.set(name, logger13);
|
|
813
|
-
return logger13;
|
|
814
|
-
}
|
|
815
|
-
initLogger("rock");
|
|
816
944
|
|
|
817
945
|
// src/envs/rock_env.ts
|
|
818
946
|
var logger = initLogger("rock.envs");
|
|
819
|
-
var RockEnv = class {
|
|
947
|
+
var RockEnv = class _RockEnv {
|
|
820
948
|
envId;
|
|
821
949
|
sandboxId = null;
|
|
822
950
|
isClosed = false;
|
|
823
|
-
client;
|
|
824
951
|
constructor(config) {
|
|
825
952
|
this.envId = config.envId;
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Create and initialize a RockEnv instance
|
|
956
|
+
*
|
|
957
|
+
* @param config - Environment configuration
|
|
958
|
+
* @returns Initialized RockEnv instance
|
|
959
|
+
*/
|
|
960
|
+
static async create(config) {
|
|
961
|
+
const env = new _RockEnv(config);
|
|
831
962
|
try {
|
|
832
|
-
|
|
963
|
+
await env.initializeEnvironment();
|
|
833
964
|
} catch (e) {
|
|
834
965
|
throw new Error(`Failed to initialize environment: ${e}`);
|
|
835
966
|
}
|
|
967
|
+
return env;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Get the sandbox ID
|
|
971
|
+
*/
|
|
972
|
+
getSandboxId() {
|
|
973
|
+
return this.sandboxId;
|
|
836
974
|
}
|
|
837
975
|
/**
|
|
838
976
|
* Initialize environment instance
|
|
839
977
|
*/
|
|
840
|
-
initializeEnvironment() {
|
|
978
|
+
async initializeEnvironment() {
|
|
841
979
|
logger.debug(`Initializing environment: ${this.envId}`);
|
|
980
|
+
const response = await HttpUtils.post(
|
|
981
|
+
`${envVars.ROCK_BASE_URL}/apis/v1/envs/gem/make`,
|
|
982
|
+
{ "Content-Type": "application/json" },
|
|
983
|
+
{ envId: this.envId }
|
|
984
|
+
);
|
|
985
|
+
this.sandboxId = response.result?.sandboxId ?? null;
|
|
986
|
+
if (!this.sandboxId) {
|
|
987
|
+
throw new Error("Failed to get environment instance ID");
|
|
988
|
+
}
|
|
842
989
|
}
|
|
843
990
|
/**
|
|
844
991
|
* Execute an action step
|
|
@@ -848,19 +995,12 @@ var RockEnv = class {
|
|
|
848
995
|
*/
|
|
849
996
|
async step(action) {
|
|
850
997
|
this.ensureNotClosed();
|
|
851
|
-
const
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
"/apis/v1/envs/gem/step",
|
|
858
|
-
params
|
|
859
|
-
);
|
|
860
|
-
return this.parseStepResult(response.data);
|
|
861
|
-
} catch (e) {
|
|
862
|
-
throw new Error(`Failed to execute step with action ${action}: ${e}`);
|
|
863
|
-
}
|
|
998
|
+
const response = await HttpUtils.post(
|
|
999
|
+
`${envVars.ROCK_BASE_URL}/apis/v1/envs/gem/step`,
|
|
1000
|
+
{ "Content-Type": "application/json" },
|
|
1001
|
+
{ sandboxId: this.sandboxId, action }
|
|
1002
|
+
);
|
|
1003
|
+
return this.parseStepResult(response.result);
|
|
864
1004
|
}
|
|
865
1005
|
/**
|
|
866
1006
|
* Reset environment to initial state
|
|
@@ -870,19 +1010,16 @@ var RockEnv = class {
|
|
|
870
1010
|
*/
|
|
871
1011
|
async reset(seed) {
|
|
872
1012
|
this.ensureNotClosed();
|
|
873
|
-
const params = {
|
|
1013
|
+
const params = { sandboxId: this.sandboxId };
|
|
874
1014
|
if (seed !== void 0) {
|
|
875
1015
|
params.seed = seed;
|
|
876
1016
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
} catch (e) {
|
|
884
|
-
throw new Error(`Failed to reset environment: ${e}`);
|
|
885
|
-
}
|
|
1017
|
+
const response = await HttpUtils.post(
|
|
1018
|
+
`${envVars.ROCK_BASE_URL}/apis/v1/envs/gem/reset`,
|
|
1019
|
+
{ "Content-Type": "application/json" },
|
|
1020
|
+
params
|
|
1021
|
+
);
|
|
1022
|
+
return this.parseResetResult(response.result);
|
|
886
1023
|
}
|
|
887
1024
|
/**
|
|
888
1025
|
* Close environment and clean up resources
|
|
@@ -892,9 +1029,11 @@ var RockEnv = class {
|
|
|
892
1029
|
return;
|
|
893
1030
|
}
|
|
894
1031
|
try {
|
|
895
|
-
await
|
|
896
|
-
|
|
897
|
-
|
|
1032
|
+
await HttpUtils.post(
|
|
1033
|
+
`${envVars.ROCK_BASE_URL}/apis/v1/envs/gem/close`,
|
|
1034
|
+
{ "Content-Type": "application/json" },
|
|
1035
|
+
{ sandboxId: this.sandboxId }
|
|
1036
|
+
);
|
|
898
1037
|
} catch (e) {
|
|
899
1038
|
throw new Error(`Failed to close environment: ${e}`);
|
|
900
1039
|
} finally {
|
|
@@ -906,6 +1045,9 @@ var RockEnv = class {
|
|
|
906
1045
|
* Parse step result from API response
|
|
907
1046
|
*/
|
|
908
1047
|
parseStepResult(data) {
|
|
1048
|
+
if (!data) {
|
|
1049
|
+
throw new Error("Invalid step result: no data");
|
|
1050
|
+
}
|
|
909
1051
|
return [
|
|
910
1052
|
data.observation,
|
|
911
1053
|
data.reward,
|
|
@@ -918,6 +1060,9 @@ var RockEnv = class {
|
|
|
918
1060
|
* Parse reset result from API response
|
|
919
1061
|
*/
|
|
920
1062
|
parseResetResult(data) {
|
|
1063
|
+
if (!data) {
|
|
1064
|
+
throw new Error("Invalid reset result: no data");
|
|
1065
|
+
}
|
|
921
1066
|
return [data.observation, data.info];
|
|
922
1067
|
}
|
|
923
1068
|
/**
|
|
@@ -931,30 +1076,30 @@ var RockEnv = class {
|
|
|
931
1076
|
};
|
|
932
1077
|
|
|
933
1078
|
// src/envs/registration.ts
|
|
934
|
-
function make(envId, options) {
|
|
935
|
-
return
|
|
1079
|
+
async function make(envId, options) {
|
|
1080
|
+
return RockEnv.create({ envId, ...options });
|
|
936
1081
|
}
|
|
937
1082
|
var BaseConfigSchema = z.object({
|
|
938
|
-
baseUrl: z.string().default(envVars.ROCK_BASE_URL),
|
|
1083
|
+
baseUrl: z.string().default(() => envVars.ROCK_BASE_URL),
|
|
939
1084
|
xrlAuthorization: z.string().optional(),
|
|
940
1085
|
extraHeaders: z.record(z.string()).default({})
|
|
941
1086
|
});
|
|
942
1087
|
var SandboxConfigSchema = BaseConfigSchema.extend({
|
|
943
|
-
image: z.string().default(
|
|
944
|
-
autoClearSeconds: z.number().default(
|
|
1088
|
+
image: z.string().default(() => envVars.ROCK_DEFAULT_IMAGE),
|
|
1089
|
+
autoClearSeconds: z.number().default(() => envVars.ROCK_DEFAULT_AUTO_CLEAR_SECONDS),
|
|
945
1090
|
routeKey: z.string().optional(),
|
|
946
|
-
startupTimeout: z.number().default(envVars.ROCK_SANDBOX_STARTUP_TIMEOUT_SECONDS),
|
|
947
|
-
memory: z.string().default(
|
|
948
|
-
cpus: z.number().default(
|
|
1091
|
+
startupTimeout: z.number().default(() => envVars.ROCK_SANDBOX_STARTUP_TIMEOUT_SECONDS),
|
|
1092
|
+
memory: z.string().default(() => envVars.ROCK_DEFAULT_MEMORY),
|
|
1093
|
+
cpus: z.number().default(() => envVars.ROCK_DEFAULT_CPUS),
|
|
949
1094
|
userId: z.string().optional(),
|
|
950
1095
|
experimentId: z.string().optional(),
|
|
951
|
-
cluster: z.string().default(
|
|
1096
|
+
cluster: z.string().default(() => envVars.ROCK_DEFAULT_CLUSTER),
|
|
952
1097
|
namespace: z.string().optional()
|
|
953
1098
|
});
|
|
954
1099
|
var SandboxGroupConfigSchema = SandboxConfigSchema.extend({
|
|
955
|
-
size: z.number().default(
|
|
956
|
-
startConcurrency: z.number().default(
|
|
957
|
-
startRetryTimes: z.number().default(
|
|
1100
|
+
size: z.number().default(() => envVars.ROCK_DEFAULT_GROUP_SIZE),
|
|
1101
|
+
startConcurrency: z.number().default(() => envVars.ROCK_DEFAULT_START_CONCURRENCY),
|
|
1102
|
+
startRetryTimes: z.number().default(() => envVars.ROCK_DEFAULT_START_RETRY_TIMES)
|
|
958
1103
|
});
|
|
959
1104
|
function createSandboxConfig(config) {
|
|
960
1105
|
return SandboxConfigSchema.parse(config ?? {});
|
|
@@ -1027,14 +1172,6 @@ var Deploy = class {
|
|
|
1027
1172
|
}
|
|
1028
1173
|
};
|
|
1029
1174
|
|
|
1030
|
-
// src/sandbox/types.ts
|
|
1031
|
-
var SpeedupType = /* @__PURE__ */ ((SpeedupType2) => {
|
|
1032
|
-
SpeedupType2["APT"] = "apt";
|
|
1033
|
-
SpeedupType2["PIP"] = "pip";
|
|
1034
|
-
SpeedupType2["GITHUB"] = "github";
|
|
1035
|
-
return SpeedupType2;
|
|
1036
|
-
})(SpeedupType || {});
|
|
1037
|
-
|
|
1038
1175
|
// src/utils/shell.ts
|
|
1039
1176
|
function shellQuote(str) {
|
|
1040
1177
|
if (str === "") {
|
|
@@ -1297,6 +1434,12 @@ var LinuxFileSystem = class extends FileSystem {
|
|
|
1297
1434
|
|
|
1298
1435
|
// src/sandbox/network.ts
|
|
1299
1436
|
var logger4 = initLogger("rock.sandbox.network");
|
|
1437
|
+
var SpeedupType = /* @__PURE__ */ ((SpeedupType2) => {
|
|
1438
|
+
SpeedupType2["APT"] = "apt";
|
|
1439
|
+
SpeedupType2["PIP"] = "pip";
|
|
1440
|
+
SpeedupType2["GITHUB"] = "github";
|
|
1441
|
+
return SpeedupType2;
|
|
1442
|
+
})(SpeedupType || {});
|
|
1300
1443
|
var Network = class {
|
|
1301
1444
|
sandbox;
|
|
1302
1445
|
constructor(sandbox) {
|
|
@@ -1936,13 +2079,6 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1936
2079
|
} = options;
|
|
1937
2080
|
const sessionName = session ?? "default";
|
|
1938
2081
|
if (mode === "normal") {
|
|
1939
|
-
try {
|
|
1940
|
-
await this.createSession({ session: sessionName, startupSource: [], envEnable: false });
|
|
1941
|
-
} catch (e) {
|
|
1942
|
-
if (String(e).includes("already exists")) ; else {
|
|
1943
|
-
throw e;
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
2082
|
return this.runInSession({ command: cmd, session: sessionName, timeout });
|
|
1947
2083
|
}
|
|
1948
2084
|
return this.arunWithNohup(cmd, options);
|
|
@@ -1982,13 +2118,12 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
1982
2118
|
outputFile
|
|
1983
2119
|
} = options;
|
|
1984
2120
|
const timestamp = Date.now();
|
|
1985
|
-
|
|
1986
|
-
|
|
2121
|
+
let tmpSession;
|
|
2122
|
+
if (session === void 0 || session === null) {
|
|
2123
|
+
tmpSession = `bash-${timestamp}`;
|
|
1987
2124
|
await this.createSession({ session: tmpSession, startupSource: [], envEnable: false });
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
throw e;
|
|
1991
|
-
}
|
|
2125
|
+
} else {
|
|
2126
|
+
tmpSession = session;
|
|
1992
2127
|
}
|
|
1993
2128
|
const tmpFile = outputFile ?? `/tmp/tmp_${timestamp}.out`;
|
|
1994
2129
|
const nohupCommand = `nohup ${cmd} < /dev/null > ${tmpFile} 2>&1 & echo __ROCK_PID_START__$!__ROCK_PID_END__;disown`;
|
|
@@ -2091,11 +2226,13 @@ var Sandbox = class extends AbstractSandbox {
|
|
|
2091
2226
|
const url = `${this.url}/upload`;
|
|
2092
2227
|
const headers = this.buildHeaders();
|
|
2093
2228
|
try {
|
|
2094
|
-
const fs = await import('fs');
|
|
2095
|
-
|
|
2229
|
+
const fs = await import('fs/promises');
|
|
2230
|
+
try {
|
|
2231
|
+
await fs.access(sourcePath);
|
|
2232
|
+
} catch {
|
|
2096
2233
|
return { success: false, message: `File not found: ${sourcePath}` };
|
|
2097
2234
|
}
|
|
2098
|
-
const fileBuffer = fs.
|
|
2235
|
+
const fileBuffer = await fs.readFile(sourcePath);
|
|
2099
2236
|
const fileName = sourcePath.split("/").pop() ?? "file";
|
|
2100
2237
|
const response = await HttpUtils.postMultipart(
|
|
2101
2238
|
url,
|
|
@@ -2203,7 +2340,7 @@ var ModelClient = class {
|
|
|
2203
2340
|
const content = this.constructResponse(lastResponse, index);
|
|
2204
2341
|
const lastResponseLine = await this.readLastResponseLine();
|
|
2205
2342
|
if (lastResponseLine === null) {
|
|
2206
|
-
this.appendResponse(content);
|
|
2343
|
+
await this.appendResponse(content);
|
|
2207
2344
|
return;
|
|
2208
2345
|
}
|
|
2209
2346
|
const { meta } = this.parseResponseLine(lastResponseLine);
|
|
@@ -2215,7 +2352,7 @@ var ModelClient = class {
|
|
|
2215
2352
|
logger9.debug(`response index ${index} already exists, skip`);
|
|
2216
2353
|
return;
|
|
2217
2354
|
}
|
|
2218
|
-
this.appendResponse(content);
|
|
2355
|
+
await this.appendResponse(content);
|
|
2219
2356
|
}
|
|
2220
2357
|
/**
|
|
2221
2358
|
* Pop request from log file
|
|
@@ -2247,8 +2384,13 @@ var ModelClient = class {
|
|
|
2247
2384
|
logger9.debug(`Last request is not the index ${index} we want, waiting...`);
|
|
2248
2385
|
await sleep(1e3);
|
|
2249
2386
|
} catch (e) {
|
|
2250
|
-
if (e instanceof Error
|
|
2251
|
-
|
|
2387
|
+
if (e instanceof Error) {
|
|
2388
|
+
if (e.message.includes("aborted")) {
|
|
2389
|
+
throw e;
|
|
2390
|
+
}
|
|
2391
|
+
if (e.message.includes("Invalid request line format")) {
|
|
2392
|
+
throw e;
|
|
2393
|
+
}
|
|
2252
2394
|
}
|
|
2253
2395
|
logger9.debug(`Error reading request: ${e}, waiting...`);
|
|
2254
2396
|
await sleep(1e3);
|
|
@@ -2276,7 +2418,7 @@ var ModelClient = class {
|
|
|
2276
2418
|
await sleep(1e3);
|
|
2277
2419
|
continue;
|
|
2278
2420
|
}
|
|
2279
|
-
const content =
|
|
2421
|
+
const content = await readFile(this.logFile, "utf-8");
|
|
2280
2422
|
const lines = content.split("\n").filter((l) => l.trim());
|
|
2281
2423
|
if (lines.length === 0) {
|
|
2282
2424
|
logger9.debug(`Log file ${this.logFile} is empty, waiting for the first request...`);
|
|
@@ -2290,21 +2432,31 @@ var ModelClient = class {
|
|
|
2290
2432
|
if (lineContent.includes(SESSION_END_MARKER)) {
|
|
2291
2433
|
return { requestJson: SESSION_END_MARKER, meta: {} };
|
|
2292
2434
|
}
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2435
|
+
try {
|
|
2436
|
+
const parts = lineContent.split(REQUEST_END_MARKER);
|
|
2437
|
+
const metaJson = parts[1] ?? "";
|
|
2438
|
+
const requestJson = parts[0]?.split(REQUEST_START_MARKER)[1] ?? "";
|
|
2439
|
+
const meta = JSON.parse(metaJson);
|
|
2440
|
+
return { requestJson, meta };
|
|
2441
|
+
} catch (e) {
|
|
2442
|
+
logger9.error(`Failed to parse request line: ${lineContent}, error: ${e}`);
|
|
2443
|
+
throw new Error(`Invalid request line format: ${e}`);
|
|
2444
|
+
}
|
|
2298
2445
|
}
|
|
2299
2446
|
parseResponseLine(lineContent) {
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2447
|
+
try {
|
|
2448
|
+
const parts = lineContent.split(RESPONSE_END_MARKER);
|
|
2449
|
+
const metaJson = parts[1] ?? "";
|
|
2450
|
+
const responseJson = parts[0]?.split(RESPONSE_START_MARKER)[1] ?? "";
|
|
2451
|
+
const meta = JSON.parse(metaJson);
|
|
2452
|
+
return { responseJson, meta };
|
|
2453
|
+
} catch (e) {
|
|
2454
|
+
logger9.error(`Failed to parse response line: ${lineContent}, error: ${e}`);
|
|
2455
|
+
throw new Error(`Invalid response line format: ${e}`);
|
|
2456
|
+
}
|
|
2305
2457
|
}
|
|
2306
2458
|
async readLastRequestLine() {
|
|
2307
|
-
const content =
|
|
2459
|
+
const content = await readFile(this.logFile, "utf-8");
|
|
2308
2460
|
const lines = content.split("\n").filter((l) => l.trim());
|
|
2309
2461
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
2310
2462
|
const line = lines[i];
|
|
@@ -2315,7 +2467,7 @@ var ModelClient = class {
|
|
|
2315
2467
|
throw new Error(`No request found in log file ${this.logFile}`);
|
|
2316
2468
|
}
|
|
2317
2469
|
async readLastResponseLine() {
|
|
2318
|
-
const content =
|
|
2470
|
+
const content = await readFile(this.logFile, "utf-8");
|
|
2319
2471
|
const lines = content.split("\n").filter((l) => l.trim());
|
|
2320
2472
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
2321
2473
|
const line = lines[i];
|
|
@@ -2325,8 +2477,8 @@ var ModelClient = class {
|
|
|
2325
2477
|
}
|
|
2326
2478
|
return null;
|
|
2327
2479
|
}
|
|
2328
|
-
appendResponse(content) {
|
|
2329
|
-
|
|
2480
|
+
async appendResponse(content) {
|
|
2481
|
+
await appendFile(this.logFile, content);
|
|
2330
2482
|
}
|
|
2331
2483
|
constructResponse(lastResponse, index) {
|
|
2332
2484
|
const meta = {
|
|
@@ -3039,6 +3191,6 @@ function getVersion() {
|
|
|
3039
3191
|
}
|
|
3040
3192
|
var VERSION = getVersion();
|
|
3041
3193
|
|
|
3042
|
-
export { Agent, AgentBashCommandSchema, AgentConfigSchema, BadRequestRockError, BashActionSchema, ChmodRequestSchema, ChmodResponseSchema, ChownRequestSchema, ChownResponseSchema, CloseResponseSchema, CloseSessionRequestSchema, CloseSessionResponseSchema, Codes, CommandResponseSchema, CommandRockError, CommandSchema,
|
|
3194
|
+
export { Agent, AgentBashCommandSchema, AgentConfigSchema, BadRequestRockError, BashActionSchema, ChmodRequestSchema, ChmodResponseSchema, ChownRequestSchema, ChownResponseSchema, CloseResponseSchema, CloseSessionRequestSchema, CloseSessionResponseSchema, Codes, CommandResponseSchema, CommandRockError, CommandSchema, CreateBashSessionRequestSchema, CreateSessionResponseSchema, DefaultAgent, DefaultAgentConfigSchema, Deploy, EnvHubClient, EnvHubClientConfigSchema, EnvHubError, ExecuteBashSessionResponseSchema, HttpUtils, InternalServerRockError, InvalidParameterRockException, IsAliveResponseSchema, LinuxFileSystem, LinuxRemoteUser, ModelClient, ModelService, ModelServiceConfigSchema, NODE_DEFAULT_VERSION, Network, NodeRuntimeEnv, NodeRuntimeEnvConfigSchema, ObservationSchema, OssSetupResponseSchema, PID_PREFIX, PID_SUFFIX, Process, PythonRuntimeEnv, PythonRuntimeEnvConfigSchema, ReadFileRequestSchema, ReadFileResponseSchema, ReasonPhrases, RockAgentConfigSchema, RockEnv, RockEnvInfoSchema, RockException, RunMode, RuntimeEnv, RuntimeEnvConfigSchema, Sandbox, SandboxConfigSchema, SandboxGroup, SandboxGroupConfigSchema, SandboxResponseSchema, SandboxStatusResponseSchema, SpeedupType, UploadRequestSchema, UploadResponseSchema, VERSION, WriteFileRequestSchema, WriteFileResponseSchema, arunWithRetry, createRockEnvInfo, createRuntimeEnvId, createSandboxConfig, createSandboxGroupConfig, deprecated, deprecatedClass, extractNohupPid as extractNohupPidFromSandbox, fromRockException, getDefaultPipIndexUrl, getEnv, getReasonPhrase, getRequiredEnv, isClientError, isCommandError, isEnvSet, isError, isNode, isServerError, isSuccess, make, raiseForCode, retryAsync, sleep, withRetry, withTimeLogging };
|
|
3043
3195
|
//# sourceMappingURL=index.mjs.map
|
|
3044
3196
|
//# sourceMappingURL=index.mjs.map
|