@botlearn-course/daemon 0.0.20-beta.6 → 0.0.20-beta.8

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.
@@ -6,11 +6,23 @@ import { promisify } from "node:util";
6
6
  const execFileAsync = promisify(execFile);
7
7
  const RUNTIME_LAUNCHER = "/opt/botlearn/bin/botlearn-runtime-launcher";
8
8
  const RUNTIME_CGROUP_ROOT = "/sys/fs/cgroup/botlearn-runtime";
9
+ const RUNTIME_CGROUP_UNAVAILABLE = "/run/botlearn-runtime-cgroup-unavailable";
9
10
  const proofs = new WeakSet();
10
11
  const sleep = (milliseconds) => new Promise((resolve) => {
11
12
  setTimeout(resolve, milliseconds);
12
13
  });
13
14
  async function setDirectCgroupsFrozen(frozen) {
15
+ try {
16
+ accessSync(RUNTIME_CGROUP_UNAVAILABLE, fsConstants.F_OK);
17
+ await execFileAsync(RUNTIME_LAUNCHER, [frozen ? "--freeze-all" : "--thaw-all"], {
18
+ timeout: 10_000,
19
+ });
20
+ return;
21
+ }
22
+ catch (error) {
23
+ if (error.code !== "ENOENT")
24
+ throw error;
25
+ }
14
26
  let entries;
15
27
  try {
16
28
  entries = await readdir(RUNTIME_CGROUP_ROOT, { withFileTypes: true });
@@ -59,7 +71,15 @@ export async function thawRuntimeWriters() {
59
71
  export function assertWorkspaceWriterFreezeSupported() {
60
72
  const mode = process.env.BOTLEARN_RUNTIME_LAUNCH_MODE;
61
73
  if (mode === "direct-uid") {
62
- accessSync(RUNTIME_CGROUP_ROOT, fsConstants.R_OK | fsConstants.W_OK);
74
+ try {
75
+ accessSync(RUNTIME_CGROUP_UNAVAILABLE, fsConstants.F_OK);
76
+ accessSync(RUNTIME_LAUNCHER, fsConstants.X_OK);
77
+ }
78
+ catch (error) {
79
+ if (error.code !== "ENOENT")
80
+ throw error;
81
+ accessSync(RUNTIME_CGROUP_ROOT, fsConstants.R_OK | fsConstants.W_OK);
82
+ }
63
83
  return;
64
84
  }
65
85
  if (mode === "sudo") {
@@ -3,7 +3,9 @@ export declare const WORKSPACE_IMAGE_LOGICAL_BYTES: number;
3
3
  interface MountInfoEntry {
4
4
  target: string;
5
5
  filesystemType: string;
6
+ source: string;
6
7
  mountOptions: Set<string>;
8
+ superOptions: Set<string>;
7
9
  }
8
10
  export declare function parseWorkspaceMountInfo(text: string): MountInfoEntry[];
9
11
  export declare function nasWorkspaceEnabled(env?: NodeJS.ProcessEnv): boolean;
@@ -20,7 +20,9 @@ export function parseWorkspaceMountInfo(text) {
20
20
  return {
21
21
  target: decodeMountInfoPath(fields[4]),
22
22
  filesystemType: filesystem[0],
23
+ source: decodeMountInfoPath(filesystem[1]),
23
24
  mountOptions: new Set(fields[5].split(",")),
25
+ superOptions: new Set(filesystem[2].split(",")),
24
26
  };
25
27
  });
26
28
  }
@@ -84,8 +86,11 @@ export function assertWorkspaceFilesystem(workspaceRoot, env = process.env, moun
84
86
  return;
85
87
  const mount = parseWorkspaceMountInfo(mountInfo ?? readFileSync("/proc/self/mountinfo", "utf8"))
86
88
  .find((candidate) => candidate.target === workspaceRoot);
89
+ const validFilesystem = mount?.filesystemType === "ext4" || (mount?.filesystemType === "fuse.ext4"
90
+ && mount.source === "/mnt/botlearn-workspace-store/workspace.ext4"
91
+ && mount.superOptions.has("allow_other"));
87
92
  if (!mount
88
- || mount.filesystemType !== "ext4"
93
+ || !validFilesystem
89
94
  || !mount.mountOptions.has("rw")
90
95
  || !mount.mountOptions.has("nodev")
91
96
  || !mount.mountOptions.has("nosuid")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botlearn-course/daemon",
3
- "version": "0.0.20-beta.6",
3
+ "version": "0.0.20-beta.8",
4
4
  "description": "Lightweight BotLearn Course daemon: run course tasks on your own machine with your own agent runtime (BYOA).",
5
5
  "type": "module",
6
6
  "bin": {