@sharedots/cli 0.1.3 → 0.1.5
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/bin/daemon-wrapper.js +19 -0
- package/bin/sharedots-daemon.exe +0 -0
- package/dist/index.js +131 -26
- package/package.json +5 -4
|
@@ -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
|
+
}
|
package/bin/sharedots-daemon.exe
CHANGED
|
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
|
-
|
|
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(
|
|
41083
|
-
|
|
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(
|
|
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),
|
|
@@ -43022,6 +43065,8 @@ init_esm_shims();
|
|
|
43022
43065
|
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
43023
43066
|
"help",
|
|
43024
43067
|
"h",
|
|
43068
|
+
"version",
|
|
43069
|
+
"v",
|
|
43025
43070
|
"yes",
|
|
43026
43071
|
"y",
|
|
43027
43072
|
"cluster",
|
|
@@ -43093,29 +43138,89 @@ function parseFlags(argv) {
|
|
|
43093
43138
|
|
|
43094
43139
|
// src/index.ts
|
|
43095
43140
|
var __dirname3 = dirname3(fileURLToPath3(import.meta.url));
|
|
43141
|
+
var CLI_VERSION = "0.1.5";
|
|
43142
|
+
function getCliVersion() {
|
|
43143
|
+
try {
|
|
43144
|
+
const pkgPath = resolve4(__dirname3, "../package.json");
|
|
43145
|
+
if (existsSync7(pkgPath)) {
|
|
43146
|
+
const pkg = JSON.parse(readFileSync6(pkgPath, "utf8"));
|
|
43147
|
+
if (pkg.version) return pkg.version;
|
|
43148
|
+
}
|
|
43149
|
+
} catch {
|
|
43150
|
+
}
|
|
43151
|
+
return CLI_VERSION;
|
|
43152
|
+
}
|
|
43096
43153
|
function printHelp() {
|
|
43097
|
-
|
|
43154
|
+
const v = getCliVersion();
|
|
43155
|
+
console.log(`
|
|
43156
|
+
\u26A1 SHAREDOTS CLI v${v} \u2014 Universal Distributed Compute Mesh
|
|
43157
|
+
Coordinate compute power across machines, edge devices, and cloud nodes.
|
|
43158
|
+
|
|
43159
|
+
USAGE:
|
|
43160
|
+
sharedots <command> [arguments] [flags]
|
|
43161
|
+
|
|
43162
|
+
CORE COMMANDS:
|
|
43163
|
+
sharedots up Interactive onboarding wizard (create room or join mesh)
|
|
43164
|
+
sharedots join <CODE|URL> Join a cluster room using an invite code or coordinator URL
|
|
43165
|
+
sharedots tui Launch the full interactive Terminal Dashboard & Cluster Monitor
|
|
43166
|
+
sharedots dashboard Open the web dashboard control bridge in your default browser
|
|
43167
|
+
|
|
43168
|
+
DISTRIBUTED COMPUTE & JOBS:
|
|
43169
|
+
sharedots run [script.py] Partition and execute a Python script across cluster workers
|
|
43170
|
+
sharedots job run Interactive job studio to launch presets (Monte Carlo, Matrix, etc.)
|
|
43171
|
+
sharedots job submit <spec> Submit a declarative JSON distributed job definition
|
|
43172
|
+
sharedots bench Run distributed compute & matrix performance benchmarks
|
|
43173
|
+
|
|
43174
|
+
WORKER NODE MANAGEMENT:
|
|
43175
|
+
sharedots worker start Launch the background worker daemon to contribute compute
|
|
43176
|
+
sharedots worker status Check daemon operational status, metrics, and active tasks
|
|
43177
|
+
sharedots worker logs Tail recent logs from the local worker daemon process
|
|
43178
|
+
sharedots worker stop Stop the active background worker daemon
|
|
43179
|
+
sharedots worker join <ROOM> Connect local daemon to a specific room with --token <SECRET>
|
|
43180
|
+
sharedots worker leave Unregister worker and disconnect from the current mesh room
|
|
43181
|
+
|
|
43182
|
+
CLUSTER & ROOMS:
|
|
43183
|
+
sharedots room create Create a new isolated compute room with an access token
|
|
43098
43184
|
|
|
43099
|
-
|
|
43100
|
-
|
|
43101
|
-
|
|
43102
|
-
|
|
43103
|
-
|
|
43104
|
-
|
|
43105
|
-
|
|
43106
|
-
|
|
43107
|
-
|
|
43108
|
-
|
|
43109
|
-
|
|
43110
|
-
|
|
43111
|
-
|
|
43112
|
-
|
|
43113
|
-
|
|
43185
|
+
GLOBAL FLAGS:
|
|
43186
|
+
--coordinator <url> Coordinator endpoint (default: https://sharedots.onrender.com)
|
|
43187
|
+
--room <room_id> Target room ID for jobs, worker, or dashboard
|
|
43188
|
+
--token <secret> Room authentication secret token
|
|
43189
|
+
--partitions <N> Number of parallel partitions/tasks for job execution
|
|
43190
|
+
--cpu-limit <N> Max CPU core allocation for worker daemon
|
|
43191
|
+
--memory-limit <MB> Max memory limit for worker daemon in MB
|
|
43192
|
+
--gpu Enable hardware GPU acceleration if available
|
|
43193
|
+
--foreground Run daemon or join process in foreground
|
|
43194
|
+
--json Format output as structured JSON
|
|
43195
|
+
-v, --version Print CLI version
|
|
43196
|
+
-h, --help Show this help reference
|
|
43197
|
+
|
|
43198
|
+
EXAMPLES:
|
|
43199
|
+
# Quick start interactive setup
|
|
43200
|
+
$ sharedots up
|
|
43201
|
+
|
|
43202
|
+
# Launch the interactive terminal UI
|
|
43203
|
+
$ sharedots tui
|
|
43204
|
+
|
|
43205
|
+
# Run a Python script partitioned across 4 workers
|
|
43206
|
+
$ sharedots run monte_carlo.py --partitions 4
|
|
43207
|
+
|
|
43208
|
+
# Open the web dashboard
|
|
43209
|
+
$ sharedots dashboard
|
|
43210
|
+
|
|
43211
|
+
# Start contributing idle compute in the background
|
|
43212
|
+
$ sharedots worker start --cpu-limit 8 --memory-limit 4096
|
|
43213
|
+
|
|
43214
|
+
Documentation & Repository: https://github.com/Rachit-Tiwari-7/SHAREDOTS
|
|
43114
43215
|
`);
|
|
43115
43216
|
}
|
|
43116
43217
|
async function main() {
|
|
43117
43218
|
const { positional, flags } = parseFlags(process.argv.slice(2));
|
|
43118
43219
|
const [group, sub, ...rest] = positional;
|
|
43220
|
+
if (flags.version || flags.v || group === "version") {
|
|
43221
|
+
console.log(`@sharedots/cli v${getCliVersion()}`);
|
|
43222
|
+
return;
|
|
43223
|
+
}
|
|
43119
43224
|
if (!group || flags.help || group === "help") {
|
|
43120
43225
|
printHelp();
|
|
43121
43226
|
return;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharedots/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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",
|
|
@@ -21,8 +22,8 @@
|
|
|
21
22
|
"typescript": "^5.7.2",
|
|
22
23
|
"vitest": "^2.1.8",
|
|
23
24
|
"@sharedots/protocol": "0.1.2",
|
|
24
|
-
"
|
|
25
|
-
"sharedots": "0.1.2"
|
|
25
|
+
"sharedots": "0.1.2",
|
|
26
|
+
"@sharedots/tui": "0.1.2"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"build": "tsup",
|