@botlearn-course/daemon 0.0.20-beta.6 → 0.0.20-beta.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.
@@ -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") {
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.7",
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": {