@sharedots/cli 0.1.3 → 0.1.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.
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const isWin = process.platform === "win32";
9
+ const nativeExe = join(__dirname, isWin ? "sharedots-daemon.exe" : "sharedots-daemon");
10
+
11
+ if (existsSync(nativeExe)) {
12
+ const child = spawn(nativeExe, process.argv.slice(2), { stdio: "inherit" });
13
+ child.on("exit", (code) => process.exit(code ?? 0));
14
+ } else {
15
+ // Graceful fallback to pure Node.js worker
16
+ const nodeWorker = join(__dirname, "..", "dist", "node-worker.js");
17
+ const child = spawn(process.execPath, [nodeWorker, ...process.argv.slice(2)], { stdio: "inherit" });
18
+ child.on("exit", (code) => process.exit(code ?? 0));
19
+ }
File without changes
package/dist/index.js CHANGED
@@ -40117,7 +40117,16 @@ function resolveDaemonBinary2() {
40117
40117
  const isWin = process.platform === "win32";
40118
40118
  const exe = isWin ? "sharedots-daemon.exe" : "sharedots-daemon";
40119
40119
  const cwd2 = process.cwd();
40120
+ const home = getSharedotsHome();
40121
+ const appDataNpm = process.env.APPDATA ? path2.join(process.env.APPDATA, "npm", exe) : null;
40120
40122
  const candidates = [
40123
+ path2.join(__dirname, "..", "bin", exe),
40124
+ path2.join(__dirname, "bin", exe),
40125
+ path2.join(home, "bin", exe),
40126
+ ...appDataNpm ? [appDataNpm] : [],
40127
+ path2.resolve(__dirname, "../../../packages/cli/bin", exe),
40128
+ path2.resolve(__dirname, "../../packages/cli/bin", exe),
40129
+ path2.join(cwd2, "packages", "cli", "bin", exe),
40121
40130
  path2.join(cwd2, "target", "release", exe),
40122
40131
  path2.join(cwd2, "target", "debug", exe),
40123
40132
  path2.join(cwd2, "..", "target", "release", exe),
@@ -40131,6 +40140,23 @@ function resolveDaemonBinary2() {
40131
40140
  }
40132
40141
  return exe;
40133
40142
  }
40143
+ function resolveNodeWorkerScript2() {
40144
+ const candidates = [
40145
+ path2.resolve(__dirname, "node-worker.js"),
40146
+ path2.resolve(__dirname, "..", "dist", "node-worker.js"),
40147
+ path2.resolve(__dirname, "../../../packages/cli/dist/node-worker.js"),
40148
+ path2.resolve(__dirname, "../../packages/cli/dist/node-worker.js"),
40149
+ path2.resolve(__dirname, "../../../packages/cli/src/node-worker.ts"),
40150
+ path2.resolve(__dirname, "../../packages/cli/src/node-worker.ts"),
40151
+ path2.join(process.cwd(), "packages", "cli", "dist", "node-worker.js"),
40152
+ path2.join(process.cwd(), "packages", "cli", "src", "node-worker.ts")
40153
+ ];
40154
+ for (const c of candidates) {
40155
+ if (existsSync5(c))
40156
+ return path2.resolve(c);
40157
+ }
40158
+ return null;
40159
+ }
40134
40160
  function buildDaemonArgs(opts) {
40135
40161
  const home = getSharedotsHome();
40136
40162
  const stateDir = opts.stateDir || path2.join(home, "state");
@@ -40263,9 +40289,17 @@ var init_daemon_process = __esm({
40263
40289
  this.status = "SPAWNING";
40264
40290
  this.lastError = null;
40265
40291
  this.notifyStatus();
40266
- const bin = resolveDaemonBinary2();
40292
+ let bin = resolveDaemonBinary2();
40293
+ let args = buildDaemonArgs(options);
40294
+ if (!existsSync5(bin)) {
40295
+ const nodeWorker = resolveNodeWorkerScript2();
40296
+ if (nodeWorker) {
40297
+ this.emitLog(`[supervisor] Native daemon binary not found, launching embedded Node worker: ${nodeWorker}`);
40298
+ bin = process.execPath;
40299
+ args = [nodeWorker, ...args];
40300
+ }
40301
+ }
40267
40302
  this.binaryPath = bin;
40268
- const args = buildDaemonArgs(options);
40269
40303
  try {
40270
40304
  this.emitLog(`[supervisor] Spawning daemon binary: ${bin}`);
40271
40305
  this.emitLog(`[supervisor] Args: ${args.join(" ")}`);
@@ -41071,16 +41105,19 @@ var init_DaemonTunerView = __esm({
41071
41105
  const { status, pid, workerId, startedAt, lastError, cpuCores, maxCpuCores, ramLimitMb, maxRamMb, gpuEnabled, runtimes, startDaemon, stopDaemon, restartDaemon, detachDaemon, setCpuCores, setRamLimitMb, toggleGpu, toggleRuntime, serializedArgsString } = useDaemon();
41072
41106
  const { roomId, roomToken, coordinatorUrl } = useCluster();
41073
41107
  const [actionMessage, setActionMessage] = (0, import_react28.useState)(null);
41074
- const getEffectiveRoomConfig = () => ({
41075
- coordinator: coordinatorUrl || "https://sharedots.onrender.com",
41076
- roomId: roomId || "room-mesh-alpha",
41077
- token: roomToken || "token-secret-alpha"
41078
- });
41079
41108
  const handleStart = async () => {
41080
41109
  try {
41081
41110
  setActionMessage("Starting daemon...");
41082
- await startDaemon(getEffectiveRoomConfig());
41083
- setActionMessage("Daemon process launched successfully.");
41111
+ await startDaemon({
41112
+ coordinator: coordinatorUrl || "https://sharedots.onrender.com",
41113
+ roomId: roomId || "room-mesh-alpha",
41114
+ token: roomToken || "token-secret-alpha"
41115
+ });
41116
+ if (!roomId) {
41117
+ setActionMessage("Started in standalone mode. Note: Create or join a room on Tab 1 to join the mesh.");
41118
+ } else {
41119
+ setActionMessage("Daemon process launched successfully.");
41120
+ }
41084
41121
  } catch (err) {
41085
41122
  setActionMessage(`Start failed: ${err instanceof Error ? err.message : String(err)}`);
41086
41123
  }
@@ -41097,7 +41134,11 @@ var init_DaemonTunerView = __esm({
41097
41134
  const handleRestart = async () => {
41098
41135
  try {
41099
41136
  setActionMessage("Restarting daemon...");
41100
- await restartDaemon(getEffectiveRoomConfig());
41137
+ await restartDaemon({
41138
+ coordinator: coordinatorUrl || "https://sharedots.onrender.com",
41139
+ roomId: roomId || "room-mesh-alpha",
41140
+ token: roomToken || "token-secret-alpha"
41141
+ });
41101
41142
  setActionMessage("Daemon restarted.");
41102
41143
  } catch (err) {
41103
41144
  setActionMessage(`Restart failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -42082,10 +42123,12 @@ function resolveDaemonBinary() {
42082
42123
  }
42083
42124
  const exe = process.platform === "win32" ? "sharedots-daemon.exe" : "sharedots-daemon";
42084
42125
  const repoRoot = resolve2(__dirname2, "../../..");
42126
+ const appDataNpm = process.env.APPDATA ? join2(process.env.APPDATA, "npm", exe) : null;
42085
42127
  const candidates = [
42086
42128
  join2(__dirname2, "..", "bin", exe),
42087
42129
  join2(__dirname2, "bin", exe),
42088
42130
  join2(getHomeDir(), "bin", exe),
42131
+ ...appDataNpm ? [appDataNpm] : [],
42089
42132
  join2(repoRoot, "target", "release", exe),
42090
42133
  join2(repoRoot, "target", "debug", exe),
42091
42134
  join2(process.cwd(), "target", "release", exe),
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@sharedots/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": {
8
- "sharedots": "./dist/index.js"
8
+ "sharedots": "./dist/index.js",
9
+ "sharedots-daemon": "./bin/sharedots-daemon.exe"
9
10
  },
10
11
  "files": [
11
12
  "dist",