@ricsam/r5d-worker 0.0.152 → 0.0.153

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/mjs/main.mjs CHANGED
@@ -7,7 +7,7 @@ import { startManagerRpc } from "./runtime/releases/rpc-main.mjs";
7
7
  import { ManagerRpcConfig } from "./runtime/releases/rpc-protocol.mjs";
8
8
  const args = process.argv.slice(2);
9
9
  if (args.includes("--version")) {
10
- console.log(`r5d-worker ${true ? "0.0.152" : "development"}`);
10
+ console.log(`r5d-worker ${true ? "0.0.153" : "development"}`);
11
11
  } else if (!args.length || args.includes("--help")) {
12
12
  console.log(
13
13
  "Usage: r5d-worker start --label <label> [--root <dir>] [--base-url <url>] [--token <worker-token>]\n r5d-worker executor /absolute/private/config.json\n r5d-worker manager /absolute/private/config.json\n\nRun independently supervised durable runtime services. Provision configuration with r5dinfra."
@@ -15,7 +15,7 @@ if (args.includes("--version")) {
15
15
  } else if (args[0] === "start") {
16
16
  const runtime = await startPersonalWorker(
17
17
  parsePersonalWorkerOptions(args.slice(1)),
18
- true ? "0.0.152" : "development"
18
+ true ? "0.0.153" : "development"
19
19
  );
20
20
  console.log(`Worker connected: ${runtime.resourceId}`);
21
21
  let closing = false;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.152",
3
+ "version": "0.0.153",
4
4
  "type": "module"
5
5
  }
@@ -6,6 +6,16 @@ function packageMain(moduleUrl) {
6
6
  const module = fileURLToPath(moduleUrl);
7
7
  return path.join(path.dirname(module), path.extname(module) === ".cjs" ? "main.cjs" : "main.mjs");
8
8
  }
9
+ function internalMain(moduleUrl) {
10
+ return path.join(path.dirname(fileURLToPath(moduleUrl)), "..", "internal-r5dctl.cjs");
11
+ }
12
+ async function inspectInternal(candidate) {
13
+ const entrypoint = await fs.realpath(candidate);
14
+ const stat = await fs.lstat(entrypoint);
15
+ if (!stat.isFile() || stat.nlink !== 1 || stat.mode & 2 || ![0, process.getuid?.()].includes(stat.uid))
16
+ throw new Error("Untrusted internal r5dctl entrypoint");
17
+ return entrypoint;
18
+ }
9
19
  async function inspectPackage(candidate) {
10
20
  const entrypoint = await fs.realpath(candidate);
11
21
  const entrypointStat = await fs.lstat(entrypoint);
@@ -39,13 +49,19 @@ async function resolvePersonalCliEntrypoint(explicit, workerVersion, dependencie
39
49
  source = "explicit";
40
50
  candidate = explicit;
41
51
  } else {
52
+ const bundled = dependencies.bundled ?? internalMain(import.meta.url);
42
53
  try {
43
- const resolvePackage = dependencies.resolvePackage ?? ((specifier) => import.meta.resolve(specifier));
44
- candidate = packageMain(resolvePackage(`${PACKAGE_NAME}/cli`));
45
- source = "bundled";
46
- } catch {
47
- source = "path";
48
- candidate = (dependencies.which ?? Bun.which)("r5dctl");
54
+ return { entrypoint: await inspectInternal(bundled), version: workerVersion, source: "bundled" };
55
+ } catch (error) {
56
+ if (error.code !== "ENOENT" || workerVersion !== "development") throw error;
57
+ try {
58
+ const resolvePackage = dependencies.resolvePackage ?? ((specifier) => import.meta.resolve(specifier));
59
+ candidate = packageMain(resolvePackage(`${PACKAGE_NAME}/cli`));
60
+ source = "bundled";
61
+ } catch {
62
+ source = "path";
63
+ candidate = (dependencies.which ?? Bun.which)("r5dctl");
64
+ }
49
65
  }
50
66
  }
51
67
  if (!candidate) throw new Error("Install @ricsam/r5dctl before starting this worker");
@@ -105,7 +105,7 @@ async function openPersonalWorkerRuntime(options) {
105
105
  let cliDirectory;
106
106
  if (options.cliEntrypoint) {
107
107
  const cli = await fs.realpath(options.cliEntrypoint), executable = await fs.realpath(process.execPath), stat = await fs.lstat(cli);
108
- if (!stat.isFile() || stat.mode & 18 || ![0, process.getuid?.()].includes(stat.uid))
108
+ if (!stat.isFile() || stat.nlink !== 1 || stat.mode & 2 || ![0, process.getuid?.()].includes(stat.uid))
109
109
  throw new Error("Untrusted installed r5dctl entrypoint");
110
110
  cliDirectory = path.join(root, "bin");
111
111
  privateDirectory(cliDirectory);
@@ -1,4 +1,5 @@
1
1
  type ResolutionDependencies = {
2
+ bundled?: string;
2
3
  resolvePackage?: (specifier: string) => string;
3
4
  which?: (command: string) => string | null;
4
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.152",
3
+ "version": "0.0.153",
4
4
  "type": "module",
5
5
  "main": "./dist/mjs/main.mjs",
6
6
  "module": "./dist/mjs/main.mjs",
@@ -21,8 +21,7 @@
21
21
  "r5d-worker": "dist/mjs/main.mjs"
22
22
  },
23
23
  "dependencies": {
24
- "@ricsam/r5d-api": "^0.0.152",
25
- "@ricsam/r5dctl": "0.0.152",
24
+ "@ricsam/r5d-api": "^0.0.153",
26
25
  "node-pty": "1.1.0",
27
26
  "zod": "^4.1.13",
28
27
  "picomatch": "^4.0.3"