@botlearn-course/daemon 0.0.3 → 0.0.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.
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  export declare function acquireSessionSupervisorLock(runtimeSessionId: string, lockRoot?: string): (() => void) | null;
3
3
  export declare function runSandboxSupervisor(argv: string[]): Promise<number>;
4
+ export declare function isMainModule(entry?: string): boolean;
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { execFileSync, spawn } from "node:child_process";
3
- import { chmodSync, chownSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
3
+ import { chmodSync, chownSync, existsSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync, } from "node:fs";
4
4
  import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
5
6
  const MAX_BOOTSTRAP_BYTES = 64 * 1024;
6
7
  const CONTROL_USER = "botlearn-control";
7
8
  const RUNTIME_USER = "user";
@@ -164,7 +165,17 @@ export async function runSandboxSupervisor(argv) {
164
165
  releaseLock?.();
165
166
  }
166
167
  }
167
- if (process.argv[1]?.endsWith("sandbox-supervisor.js")) {
168
+ export function isMainModule(entry = process.argv[1]) {
169
+ if (!entry)
170
+ return false;
171
+ try {
172
+ return realpathSync(entry) === fileURLToPath(import.meta.url);
173
+ }
174
+ catch {
175
+ return false;
176
+ }
177
+ }
178
+ if (isMainModule()) {
168
179
  runSandboxSupervisor(process.argv.slice(2))
169
180
  .then((code) => {
170
181
  process.exitCode = code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botlearn-course/daemon",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
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": {