@sharedots/cli 0.1.5 → 0.1.8
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/index.js +160 -13
- package/dist/node-worker.js +51 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4190,7 +4190,7 @@ var init_zod = __esm({
|
|
|
4190
4190
|
});
|
|
4191
4191
|
|
|
4192
4192
|
// ../protocol/dist/schemas.js
|
|
4193
|
-
var SUPPORTED_PROTOCOL_VERSIONS, MAX_CONTROL_FRAME_BYTES, ALL_RUNTIMES, ALL_STRATEGIES, RuntimeSchema, ExecutionStrategySchema, GpuRequirementSchema, WorkerStatusEnumSchema, MemorySpecSchema, GpuInfoSchema, WorkerLimitsSchema, WorkerCapabilitiesSchema, ResourceRequirementsSchema, ArtifactRefSchema, TaskSpecSchema, AggregationSpecSchema, JobSpecSchema, ErrorCodeSchema, MessageTypeSchema, MessageEnvelopeSchema, WorkerRegisterPayloadSchema, WorkerHeartbeatPayloadSchema, WorkerStatusPayloadSchema, JobSubmitPayloadSchema, JobAcceptedPayloadSchema, JobCancelPayloadSchema, JobCompletedPayloadSchema, JobFailedPayloadSchema, JobLogPayloadSchema, TaskManifestSchema, TaskAssignPayloadSchema, TaskStartedPayloadSchema, TaskProgressPayloadSchema, TaskCompletedPayloadSchema, TaskFailedPayloadSchema, ArtifactRequestPayloadSchema, ArtifactResponsePayloadSchema, ErrorPayloadSchema, AckPayloadSchema, PAYLOAD_SCHEMAS;
|
|
4193
|
+
var SUPPORTED_PROTOCOL_VERSIONS, MAX_CONTROL_FRAME_BYTES, ALL_RUNTIMES, ALL_STRATEGIES, RuntimeSchema, ExecutionStrategySchema, GpuRequirementSchema, WorkerStatusEnumSchema, MemorySpecSchema, GpuInfoSchema, WorkerLimitsSchema, WorkerCapabilitiesSchema, ResourceRequirementsSchema, ArtifactRefSchema, TaskSpecSchema, AggregationSpecSchema, SchedulingPolicySchema, JobSpecSchema, ErrorCodeSchema, MessageTypeSchema, MessageEnvelopeSchema, WorkerRegisterPayloadSchema, WorkerHeartbeatPayloadSchema, WorkerStatusPayloadSchema, JobSubmitPayloadSchema, JobAcceptedPayloadSchema, JobCancelPayloadSchema, JobCompletedPayloadSchema, JobFailedPayloadSchema, JobLogPayloadSchema, TaskManifestSchema, TaskAssignPayloadSchema, TaskStartedPayloadSchema, TaskProgressPayloadSchema, TaskCompletedPayloadSchema, TaskFailedPayloadSchema, TaskCancelPayloadSchema, TaskPullPayloadSchema, TaskYieldPayloadSchema, ArtifactRequestPayloadSchema, ArtifactResponsePayloadSchema, ErrorPayloadSchema, AckPayloadSchema, PAYLOAD_SCHEMAS;
|
|
4194
4194
|
var init_schemas = __esm({
|
|
4195
4195
|
"../protocol/dist/schemas.js"() {
|
|
4196
4196
|
"use strict";
|
|
@@ -4285,6 +4285,14 @@ var init_schemas = __esm({
|
|
|
4285
4285
|
outputFilename: external_exports.string().optional(),
|
|
4286
4286
|
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
4287
4287
|
});
|
|
4288
|
+
SchedulingPolicySchema = external_exports.object({
|
|
4289
|
+
algorithm: external_exports.enum(["guided", "fifo", "priority", "work-stealing"]).default("work-stealing"),
|
|
4290
|
+
chunkSize: external_exports.number().int().positive().optional(),
|
|
4291
|
+
minChunkSize: external_exports.number().int().positive().default(1),
|
|
4292
|
+
maxChunkSize: external_exports.number().int().positive().optional(),
|
|
4293
|
+
factor: external_exports.number().positive().default(2),
|
|
4294
|
+
leaseTimeoutSec: external_exports.number().int().positive().optional()
|
|
4295
|
+
});
|
|
4288
4296
|
JobSpecSchema = external_exports.object({
|
|
4289
4297
|
specVersion: external_exports.literal(1).default(1),
|
|
4290
4298
|
name: external_exports.string().min(1),
|
|
@@ -4294,6 +4302,7 @@ var init_schemas = __esm({
|
|
|
4294
4302
|
workers: external_exports.union([external_exports.literal("auto"), external_exports.number().int().positive()]).default("auto"),
|
|
4295
4303
|
partitions: external_exports.number().int().positive().optional()
|
|
4296
4304
|
}),
|
|
4305
|
+
scheduling: SchedulingPolicySchema.optional(),
|
|
4297
4306
|
resources: ResourceRequirementsSchema.default({
|
|
4298
4307
|
cpu: 1,
|
|
4299
4308
|
memory: "512MB",
|
|
@@ -4344,6 +4353,9 @@ var init_schemas = __esm({
|
|
|
4344
4353
|
"task.progress",
|
|
4345
4354
|
"task.completed",
|
|
4346
4355
|
"task.failed",
|
|
4356
|
+
"task.cancel",
|
|
4357
|
+
"task.pull",
|
|
4358
|
+
"task.yield",
|
|
4347
4359
|
"artifact.request",
|
|
4348
4360
|
"artifact.response",
|
|
4349
4361
|
"error",
|
|
@@ -4473,6 +4485,24 @@ var init_schemas = __esm({
|
|
|
4473
4485
|
message: external_exports.string(),
|
|
4474
4486
|
retryable: external_exports.boolean().default(true)
|
|
4475
4487
|
});
|
|
4488
|
+
TaskCancelPayloadSchema = external_exports.object({
|
|
4489
|
+
taskId: external_exports.string().min(1),
|
|
4490
|
+
jobId: external_exports.string().min(1).optional(),
|
|
4491
|
+
reason: external_exports.string().optional()
|
|
4492
|
+
});
|
|
4493
|
+
TaskPullPayloadSchema = external_exports.object({
|
|
4494
|
+
workerId: external_exports.string().min(1),
|
|
4495
|
+
roomId: external_exports.string().min(1),
|
|
4496
|
+
maxTasks: external_exports.number().int().positive().optional(),
|
|
4497
|
+
batchSize: external_exports.number().int().positive().optional(),
|
|
4498
|
+
currentLoad: external_exports.number().min(0).max(100).optional()
|
|
4499
|
+
});
|
|
4500
|
+
TaskYieldPayloadSchema = external_exports.object({
|
|
4501
|
+
workerId: external_exports.string().min(1),
|
|
4502
|
+
roomId: external_exports.string().min(1),
|
|
4503
|
+
taskId: external_exports.string().min(1),
|
|
4504
|
+
reason: external_exports.string().optional()
|
|
4505
|
+
});
|
|
4476
4506
|
ArtifactRequestPayloadSchema = external_exports.object({
|
|
4477
4507
|
artifactId: external_exports.string().min(1),
|
|
4478
4508
|
roomId: external_exports.string().min(1)
|
|
@@ -4510,6 +4540,9 @@ var init_schemas = __esm({
|
|
|
4510
4540
|
"task.progress": TaskProgressPayloadSchema,
|
|
4511
4541
|
"task.completed": TaskCompletedPayloadSchema,
|
|
4512
4542
|
"task.failed": TaskFailedPayloadSchema,
|
|
4543
|
+
"task.cancel": TaskCancelPayloadSchema,
|
|
4544
|
+
"task.pull": TaskPullPayloadSchema,
|
|
4545
|
+
"task.yield": TaskYieldPayloadSchema,
|
|
4513
4546
|
"artifact.request": ArtifactRequestPayloadSchema,
|
|
4514
4547
|
"artifact.response": ArtifactResponsePayloadSchema,
|
|
4515
4548
|
error: ErrorPayloadSchema,
|
|
@@ -39797,6 +39830,52 @@ var init_ClusterContext = __esm({
|
|
|
39797
39830
|
}
|
|
39798
39831
|
return nextList;
|
|
39799
39832
|
});
|
|
39833
|
+
try {
|
|
39834
|
+
const jobsRes = await fetch(`${coordinatorUrl}/api/jobs?roomId=${encodeURIComponent(roomId)}`);
|
|
39835
|
+
if (jobsRes.ok) {
|
|
39836
|
+
const jobsData = await jobsRes.json();
|
|
39837
|
+
const remoteJobs = jobsData.jobs || [];
|
|
39838
|
+
if (remoteJobs.length > 0) {
|
|
39839
|
+
setActiveJobs((prev) => {
|
|
39840
|
+
const merged = [...prev];
|
|
39841
|
+
for (const rj of remoteJobs) {
|
|
39842
|
+
const jId = String(rj.jobId || "");
|
|
39843
|
+
const spec = rj.spec || {};
|
|
39844
|
+
const name = String(spec.name || rj.name || `Job ${jId.slice(0, 8)}`);
|
|
39845
|
+
const status = String(rj.status || "queued");
|
|
39846
|
+
const rTasks = rj.tasks || [];
|
|
39847
|
+
const completedTasks = rTasks.filter((t) => t.status === "completed").length;
|
|
39848
|
+
const progressPercent = rTasks.length > 0 ? Math.round(completedTasks / rTasks.length * 100) : status === "completed" ? 100 : 0;
|
|
39849
|
+
const existingIdx = merged.findIndex((j) => j.jobId === jId);
|
|
39850
|
+
const jobObj = {
|
|
39851
|
+
jobId: jId,
|
|
39852
|
+
name,
|
|
39853
|
+
status,
|
|
39854
|
+
progressPercent,
|
|
39855
|
+
tasks: rTasks.map((t) => ({
|
|
39856
|
+
taskId: String(t.taskId || ""),
|
|
39857
|
+
jobId: jId,
|
|
39858
|
+
workerId: String(t.workerId || ""),
|
|
39859
|
+
workerHost: String(t.workerId || "worker"),
|
|
39860
|
+
workerIp: "mesh",
|
|
39861
|
+
percent: t.status === "completed" ? 100 : t.status === "running" ? 50 : 0,
|
|
39862
|
+
status: t.status || "pending"
|
|
39863
|
+
})),
|
|
39864
|
+
durationMs: rj.finishedAt && rj.startedAt ? Number(rj.finishedAt) - Number(rj.startedAt) : void 0,
|
|
39865
|
+
resultArtifactId: rj.resultArtifactId ? String(rj.resultArtifactId) : void 0
|
|
39866
|
+
};
|
|
39867
|
+
if (existingIdx >= 0) {
|
|
39868
|
+
merged[existingIdx] = { ...merged[existingIdx], ...jobObj };
|
|
39869
|
+
} else {
|
|
39870
|
+
merged.unshift(jobObj);
|
|
39871
|
+
}
|
|
39872
|
+
}
|
|
39873
|
+
return merged;
|
|
39874
|
+
});
|
|
39875
|
+
}
|
|
39876
|
+
}
|
|
39877
|
+
} catch {
|
|
39878
|
+
}
|
|
39800
39879
|
} catch {
|
|
39801
39880
|
}
|
|
39802
39881
|
}, [coordinatorUrl, roomId, addLog]);
|
|
@@ -40587,7 +40666,7 @@ var init_Footer = __esm({
|
|
|
40587
40666
|
const nodesTicker = overview.onlineNodes > 0 ? source_default.cyan(`${overview.onlineNodes} node${overview.onlineNodes > 1 ? "s" : ""} online`) : source_default.gray("0 nodes");
|
|
40588
40667
|
const runningJobs = activeJobs.filter((j) => j.status === "running").length;
|
|
40589
40668
|
const jobsTicker = runningJobs > 0 ? source_default.yellowBright(`${runningJobs} job active`) : source_default.dim("idle");
|
|
40590
|
-
return (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "row", justifyContent: "space-between", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [(0, import_jsx_runtime4.jsx)(Box_default, { children: (0, import_jsx_runtime4.jsxs)(Text, { color: "gray", children: [source_default.cyan("[1-5]"), " View ", source_default.dim("\u2502"), " ", source_default.cyan("[
|
|
40669
|
+
return (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "row", justifyContent: "space-between", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [(0, import_jsx_runtime4.jsx)(Box_default, { children: (0, import_jsx_runtime4.jsxs)(Text, { color: "gray", children: [source_default.cyan("[1-5]"), " View ", source_default.dim("\u2502"), " ", source_default.cyan("[w]"), " Web ", source_default.dim("\u2502"), " ", source_default.cyan("[?]"), " Help ", source_default.dim("\u2502"), " ", source_default.cyan("[r]"), " Refresh ", source_default.dim("\u2502"), " ", source_default.cyan("[q]"), " Exit"] }) }), (0, import_jsx_runtime4.jsx)(Box_default, { children: (0, import_jsx_runtime4.jsxs)(Text, { children: [daemonTicker, " ", source_default.dim("\u2502"), " ", nodesTicker, " ", source_default.dim("\u2502"), " ", jobsTicker] }) })] });
|
|
40591
40670
|
};
|
|
40592
40671
|
}
|
|
40593
40672
|
});
|
|
@@ -40967,7 +41046,7 @@ var init_HelpOverlay = __esm({
|
|
|
40967
41046
|
init_source();
|
|
40968
41047
|
await init_build2();
|
|
40969
41048
|
HelpOverlay = ({ onClose: _onClose }) => {
|
|
40970
|
-
return (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", borderStyle: "double", borderColor: "cyanBright", padding: 1, width: "100%", children: [(0, import_jsx_runtime8.jsx)(Box_default, { justifyContent: "center", marginBottom: 1, children: (0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "cyanBright", children: "SHAREDOTS TUI \u2014 KEYBOARD NAVIGATION & SHORTCUTS" }) }), (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "row", justifyContent: "space-between", children: [(0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", width: "48%", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "GLOBAL SHORTCUTS" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" 1..5 / F1..F5 "), " Switch View (Mesh / Daemon / Fleet / Jobs / Logs)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" Tab / S-Tab "), " Cycle tabs forward / backward"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" r "), " Force instant refresh of network and cluster"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" ? "), " Toggle this Help overlay"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" q / Ctrl+C "), " Open Graceful Shutdown dialog"] }), (0, import_jsx_runtime8.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "TAB 1: MESH ONBOARDING" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" h "), " Host new room (binds Tailscale/LAN IP & QR)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" j "), " Switch to Join Room form"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" p "), " Ping all detected Tailscale mesh peers"] })] })] }), (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", width: "48%", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "TAB 2: DAEMON SUPERVISOR & TUNER" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" s / x / R "), " Start / Stop / Restart daemon binary"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" d "), " Detach daemon to background"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" + / - or \u2190 / \u2192 "), " Adjust dedicated CPU cores"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" [ / ] "), " Adjust RAM ceiling in 512MB steps"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" g "), " Toggle CUDA / ROCm / Metal GPU"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" p / w / c "), " Toggle Python / WASM / Container"] }), (0, import_jsx_runtime8.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "TAB 4 & 5: JOBS & LOGS" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" 1..4 (in Jobs) "), " Select compute preset"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" Enter "), " Dispatch job across cluster"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" a / c / d / t "), " Filter log stream (All / Coord / Daemon / Tasks)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" l "), " Cycle log level (ALL / INFO / WARN / ERROR)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" / "), " Focus log search query"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" Space "), " Pause / Resume auto-scrolling"] })] })] })] }), (0, import_jsx_runtime8.jsx)(Box_default, { marginTop: 1, justifyContent: "center", children: (0, import_jsx_runtime8.jsxs)(Text, { color: "gray", children: ["Press ", source_default.cyanBright("[Esc]"), " or ", source_default.cyanBright("[?]"), " to return to dashboard"] }) })] });
|
|
41049
|
+
return (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", borderStyle: "double", borderColor: "cyanBright", padding: 1, width: "100%", children: [(0, import_jsx_runtime8.jsx)(Box_default, { justifyContent: "center", marginBottom: 1, children: (0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "cyanBright", children: "SHAREDOTS TUI \u2014 KEYBOARD NAVIGATION & SHORTCUTS" }) }), (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "row", justifyContent: "space-between", children: [(0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", width: "48%", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "GLOBAL SHORTCUTS" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" 1..5 / F1..F5 "), " Switch View (Mesh / Daemon / Fleet / Jobs / Logs)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" Tab / S-Tab "), " Cycle tabs forward / backward"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" w "), " Open Web Dashboard bridge in browser"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" r "), " Force instant refresh of network and cluster"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" ? "), " Toggle this Help overlay"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" q / Ctrl+C "), " Open Graceful Shutdown dialog"] }), (0, import_jsx_runtime8.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "TAB 1: MESH ONBOARDING" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" h "), " Host new room (binds Tailscale/LAN IP & QR)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" j "), " Switch to Join Room form"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" p "), " Ping all detected Tailscale mesh peers"] })] })] }), (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", width: "48%", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "TAB 2: DAEMON SUPERVISOR & TUNER" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" s / x / R "), " Start / Stop / Restart daemon binary"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" d "), " Detach daemon to background"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" + / - or \u2190 / \u2192 "), " Adjust dedicated CPU cores"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" [ / ] "), " Adjust RAM ceiling in 512MB steps"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" g "), " Toggle CUDA / ROCm / Metal GPU"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" p / w / c "), " Toggle Python / WASM / Container"] }), (0, import_jsx_runtime8.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime8.jsx)(Text, { bold: true, color: "white", children: "TAB 4 & 5: JOBS & LOGS" }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" 1..4 (in Jobs) "), " Select compute preset"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" Enter "), " Dispatch job across cluster"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" a / c / d / t "), " Filter log stream (All / Coord / Daemon / Tasks)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" l "), " Cycle log level (ALL / INFO / WARN / ERROR)"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" / "), " Focus log search query"] }), (0, import_jsx_runtime8.jsxs)(Text, { children: [source_default.cyan(" Space "), " Pause / Resume auto-scrolling"] })] })] })] }), (0, import_jsx_runtime8.jsx)(Box_default, { marginTop: 1, justifyContent: "center", children: (0, import_jsx_runtime8.jsxs)(Text, { color: "gray", children: ["Press ", source_default.cyanBright("[Esc]"), " or ", source_default.cyanBright("[?]"), " to return to dashboard"] }) })] });
|
|
40971
41050
|
};
|
|
40972
41051
|
}
|
|
40973
41052
|
});
|
|
@@ -41837,6 +41916,57 @@ var init_OnboardingView = __esm({
|
|
|
41837
41916
|
}
|
|
41838
41917
|
});
|
|
41839
41918
|
|
|
41919
|
+
// ../../apps/tui/dist/services/dashboard-bridge.js
|
|
41920
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
41921
|
+
function constructDashboardBridgeUrl(options) {
|
|
41922
|
+
const coordinator = (options.coordinatorUrl || "https://sharedots.onrender.com").replace(/\/$/, "");
|
|
41923
|
+
const roomId = options.roomId || "default-room";
|
|
41924
|
+
const token = options.roomToken || "sec_default";
|
|
41925
|
+
const port = options.port || "3000";
|
|
41926
|
+
const params = new URLSearchParams();
|
|
41927
|
+
params.set("room", roomId);
|
|
41928
|
+
params.set("token", token);
|
|
41929
|
+
params.set("coordinator", coordinator);
|
|
41930
|
+
const dashboardHost = (process.env.SHAREDOTS_DASHBOARD_URL || "https://sharedots.vercel.app").replace(/\/$/, "");
|
|
41931
|
+
const localUrl = `http://localhost:${port}/?${params.toString()}`;
|
|
41932
|
+
const hostedUrl = `${dashboardHost}/?${params.toString()}`;
|
|
41933
|
+
return { localUrl, hostedUrl };
|
|
41934
|
+
}
|
|
41935
|
+
async function openDashboardFromTui(options) {
|
|
41936
|
+
const { localUrl, hostedUrl } = constructDashboardBridgeUrl(options);
|
|
41937
|
+
const port = options.port || "3000";
|
|
41938
|
+
let isLocalRunning = false;
|
|
41939
|
+
try {
|
|
41940
|
+
const res = await fetch(`http://localhost:${port}`, { signal: AbortSignal.timeout(500) });
|
|
41941
|
+
if (res.ok || res.status < 500) {
|
|
41942
|
+
isLocalRunning = true;
|
|
41943
|
+
}
|
|
41944
|
+
} catch {
|
|
41945
|
+
isLocalRunning = false;
|
|
41946
|
+
}
|
|
41947
|
+
const targetUrl = isLocalRunning ? localUrl : hostedUrl;
|
|
41948
|
+
if (options.openBrowser !== false) {
|
|
41949
|
+
try {
|
|
41950
|
+
if (process.platform === "win32") {
|
|
41951
|
+
const winUrl = targetUrl.replace(/&/g, "^&");
|
|
41952
|
+
spawnSync2("cmd.exe", ["/c", "start", "", winUrl], { stdio: "ignore" });
|
|
41953
|
+
} else if (process.platform === "darwin") {
|
|
41954
|
+
spawnSync2("open", [targetUrl], { stdio: "ignore" });
|
|
41955
|
+
} else {
|
|
41956
|
+
spawnSync2("xdg-open", [targetUrl], { stdio: "ignore" });
|
|
41957
|
+
}
|
|
41958
|
+
} catch {
|
|
41959
|
+
}
|
|
41960
|
+
}
|
|
41961
|
+
return targetUrl;
|
|
41962
|
+
}
|
|
41963
|
+
var init_dashboard_bridge = __esm({
|
|
41964
|
+
"../../apps/tui/dist/services/dashboard-bridge.js"() {
|
|
41965
|
+
"use strict";
|
|
41966
|
+
init_esm_shims();
|
|
41967
|
+
}
|
|
41968
|
+
});
|
|
41969
|
+
|
|
41840
41970
|
// ../../apps/tui/dist/app.js
|
|
41841
41971
|
var import_jsx_runtime17, import_react33, MIN_COLUMNS, MIN_ROWS, AppContent, App2, app_default;
|
|
41842
41972
|
var init_app = __esm({
|
|
@@ -41860,13 +41990,14 @@ var init_app = __esm({
|
|
|
41860
41990
|
init_DaemonContext();
|
|
41861
41991
|
init_LogContext();
|
|
41862
41992
|
init_TailscaleContext();
|
|
41993
|
+
init_dashboard_bridge();
|
|
41863
41994
|
MIN_COLUMNS = 80;
|
|
41864
41995
|
MIN_ROWS = 24;
|
|
41865
41996
|
AppContent = ({ initialTab = 1, onExit: customExit }) => {
|
|
41866
41997
|
const { exit } = use_app_default();
|
|
41867
41998
|
const { stdout } = use_stdout_default();
|
|
41868
41999
|
const { refreshStatus } = useTailscale();
|
|
41869
|
-
const { refreshWorkers, isInputFocused } = useCluster();
|
|
42000
|
+
const { refreshWorkers, isInputFocused, roomId, roomToken, coordinatorUrl } = useCluster();
|
|
41870
42001
|
const { stopDaemon, detachDaemon, status: daemonStatus, pid: daemonPid } = useDaemon();
|
|
41871
42002
|
const { addLog } = useLogs();
|
|
41872
42003
|
const [activeTab, setActiveTab] = (0, import_react33.useState)(initialTab);
|
|
@@ -41973,6 +42104,16 @@ var init_app = __esm({
|
|
|
41973
42104
|
addLog({ source: "system", level: "INFO", message: "Instant metrics and peer refresh triggered" });
|
|
41974
42105
|
return;
|
|
41975
42106
|
}
|
|
42107
|
+
if (input === "w" || input === "W") {
|
|
42108
|
+
void openDashboardFromTui({
|
|
42109
|
+
coordinatorUrl: coordinatorUrl || "https://sharedots.onrender.com",
|
|
42110
|
+
roomId,
|
|
42111
|
+
roomToken
|
|
42112
|
+
}).then((url) => {
|
|
42113
|
+
addLog({ source: "system", level: "INFO", message: `Web Dashboard opened in browser: ${url}` });
|
|
42114
|
+
});
|
|
42115
|
+
return;
|
|
42116
|
+
}
|
|
41976
42117
|
if (activeTab === 4 && (input === "1" || input === "2" || input === "3" || input === "4")) {
|
|
41977
42118
|
return;
|
|
41978
42119
|
}
|
|
@@ -42069,7 +42210,7 @@ var init_dist6 = __esm({
|
|
|
42069
42210
|
init_esm_shims();
|
|
42070
42211
|
init_dist();
|
|
42071
42212
|
init_dist2();
|
|
42072
|
-
import { spawnSync as
|
|
42213
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
42073
42214
|
import { existsSync as existsSync7, readFileSync as readFileSync6, realpathSync, rmSync as rmSync3 } from "fs";
|
|
42074
42215
|
import { dirname as dirname3, join as join4, resolve as resolve4 } from "path";
|
|
42075
42216
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -42707,8 +42848,9 @@ function constructDashboardUrl(options) {
|
|
|
42707
42848
|
token,
|
|
42708
42849
|
coordinator
|
|
42709
42850
|
}).toString();
|
|
42851
|
+
const dashboardHost = (process.env.SHAREDOTS_DASHBOARD_URL || "https://sharedots.vercel.app").replace(/\/$/, "");
|
|
42710
42852
|
const localUrl = `http://localhost:${port}/?${qs}`;
|
|
42711
|
-
const hostedUrl =
|
|
42853
|
+
const hostedUrl = `${dashboardHost}/?${qs}`;
|
|
42712
42854
|
const effectiveUrl = options.hosted ? hostedUrl : localUrl;
|
|
42713
42855
|
return { localUrl, hostedUrl, effectiveUrl };
|
|
42714
42856
|
}
|
|
@@ -42734,7 +42876,7 @@ async function openDashboardBridge(options) {
|
|
|
42734
42876
|
} catch {
|
|
42735
42877
|
isLocalRunning = false;
|
|
42736
42878
|
}
|
|
42737
|
-
const targetUrl = isLocalRunning ? localUrl :
|
|
42879
|
+
const targetUrl = isLocalRunning ? localUrl : hostedUrl;
|
|
42738
42880
|
console.log(`
|
|
42739
42881
|
\x1B[1m\x1B[36m\u26A1 SHAREDOTS WEB DASHBOARD CONTROL BRIDGE\x1B[0m
|
|
42740
42882
|
`);
|
|
@@ -42743,11 +42885,16 @@ async function openDashboardBridge(options) {
|
|
|
42743
42885
|
console.log(` Coordinator: ${coordinator}`);
|
|
42744
42886
|
console.log(` Target URL: ${targetUrl}
|
|
42745
42887
|
`);
|
|
42746
|
-
if (!isLocalRunning
|
|
42747
|
-
|
|
42748
|
-
|
|
42749
|
-
console.log(`Hosted dashboard: \x1B[36m${hostedUrl}\x1B[0m
|
|
42888
|
+
if (!isLocalRunning) {
|
|
42889
|
+
if (options.hosted) {
|
|
42890
|
+
console.log(`\x1B[32m\u2714 Connecting to hosted cloud dashboard directly.\x1B[0m
|
|
42750
42891
|
`);
|
|
42892
|
+
} else {
|
|
42893
|
+
console.log(`\x1B[33mNotice: Local dashboard is not running on port ${port}.\x1B[0m`);
|
|
42894
|
+
console.log(`\x1B[32m\u2714 Automatically routing browser to hosted cloud dashboard.\x1B[0m`);
|
|
42895
|
+
console.log(`To run the dashboard locally instead: \x1B[36mpnpm dashboard:dev\x1B[0m
|
|
42896
|
+
`);
|
|
42897
|
+
}
|
|
42751
42898
|
}
|
|
42752
42899
|
if (options.openBrowser !== false) {
|
|
42753
42900
|
console.log(`Opening browser...`);
|
|
@@ -43138,7 +43285,7 @@ function parseFlags(argv) {
|
|
|
43138
43285
|
|
|
43139
43286
|
// src/index.ts
|
|
43140
43287
|
var __dirname3 = dirname3(fileURLToPath3(import.meta.url));
|
|
43141
|
-
var CLI_VERSION = "0.1.
|
|
43288
|
+
var CLI_VERSION = "0.1.8";
|
|
43142
43289
|
function getCliVersion() {
|
|
43143
43290
|
try {
|
|
43144
43291
|
const pkgPath = resolve4(__dirname3, "../package.json");
|
|
@@ -43566,7 +43713,7 @@ Join a worker with 1-command:`);
|
|
|
43566
43713
|
console.error(`Benchmark script not found at ${benchScript}`);
|
|
43567
43714
|
process.exit(1);
|
|
43568
43715
|
}
|
|
43569
|
-
const res =
|
|
43716
|
+
const res = spawnSync3(process.execPath, [benchScript, ...process.argv.slice(3)], {
|
|
43570
43717
|
stdio: "inherit"
|
|
43571
43718
|
});
|
|
43572
43719
|
process.exit(res.status ?? 0);
|
package/dist/node-worker.js
CHANGED
|
@@ -4787,6 +4787,14 @@ var AggregationSpecSchema = external_exports.object({
|
|
|
4787
4787
|
outputFilename: external_exports.string().optional(),
|
|
4788
4788
|
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
4789
4789
|
});
|
|
4790
|
+
var SchedulingPolicySchema = external_exports.object({
|
|
4791
|
+
algorithm: external_exports.enum(["guided", "fifo", "priority", "work-stealing"]).default("work-stealing"),
|
|
4792
|
+
chunkSize: external_exports.number().int().positive().optional(),
|
|
4793
|
+
minChunkSize: external_exports.number().int().positive().default(1),
|
|
4794
|
+
maxChunkSize: external_exports.number().int().positive().optional(),
|
|
4795
|
+
factor: external_exports.number().positive().default(2),
|
|
4796
|
+
leaseTimeoutSec: external_exports.number().int().positive().optional()
|
|
4797
|
+
});
|
|
4790
4798
|
var JobSpecSchema = external_exports.object({
|
|
4791
4799
|
specVersion: external_exports.literal(1).default(1),
|
|
4792
4800
|
name: external_exports.string().min(1),
|
|
@@ -4796,6 +4804,7 @@ var JobSpecSchema = external_exports.object({
|
|
|
4796
4804
|
workers: external_exports.union([external_exports.literal("auto"), external_exports.number().int().positive()]).default("auto"),
|
|
4797
4805
|
partitions: external_exports.number().int().positive().optional()
|
|
4798
4806
|
}),
|
|
4807
|
+
scheduling: SchedulingPolicySchema.optional(),
|
|
4799
4808
|
resources: ResourceRequirementsSchema.default({
|
|
4800
4809
|
cpu: 1,
|
|
4801
4810
|
memory: "512MB",
|
|
@@ -4846,6 +4855,9 @@ var MessageTypeSchema = external_exports.enum([
|
|
|
4846
4855
|
"task.progress",
|
|
4847
4856
|
"task.completed",
|
|
4848
4857
|
"task.failed",
|
|
4858
|
+
"task.cancel",
|
|
4859
|
+
"task.pull",
|
|
4860
|
+
"task.yield",
|
|
4849
4861
|
"artifact.request",
|
|
4850
4862
|
"artifact.response",
|
|
4851
4863
|
"error",
|
|
@@ -4975,6 +4987,24 @@ var TaskFailedPayloadSchema = external_exports.object({
|
|
|
4975
4987
|
message: external_exports.string(),
|
|
4976
4988
|
retryable: external_exports.boolean().default(true)
|
|
4977
4989
|
});
|
|
4990
|
+
var TaskCancelPayloadSchema = external_exports.object({
|
|
4991
|
+
taskId: external_exports.string().min(1),
|
|
4992
|
+
jobId: external_exports.string().min(1).optional(),
|
|
4993
|
+
reason: external_exports.string().optional()
|
|
4994
|
+
});
|
|
4995
|
+
var TaskPullPayloadSchema = external_exports.object({
|
|
4996
|
+
workerId: external_exports.string().min(1),
|
|
4997
|
+
roomId: external_exports.string().min(1),
|
|
4998
|
+
maxTasks: external_exports.number().int().positive().optional(),
|
|
4999
|
+
batchSize: external_exports.number().int().positive().optional(),
|
|
5000
|
+
currentLoad: external_exports.number().min(0).max(100).optional()
|
|
5001
|
+
});
|
|
5002
|
+
var TaskYieldPayloadSchema = external_exports.object({
|
|
5003
|
+
workerId: external_exports.string().min(1),
|
|
5004
|
+
roomId: external_exports.string().min(1),
|
|
5005
|
+
taskId: external_exports.string().min(1),
|
|
5006
|
+
reason: external_exports.string().optional()
|
|
5007
|
+
});
|
|
4978
5008
|
var ArtifactRequestPayloadSchema = external_exports.object({
|
|
4979
5009
|
artifactId: external_exports.string().min(1),
|
|
4980
5010
|
roomId: external_exports.string().min(1)
|
|
@@ -5012,6 +5042,9 @@ var PAYLOAD_SCHEMAS = {
|
|
|
5012
5042
|
"task.progress": TaskProgressPayloadSchema,
|
|
5013
5043
|
"task.completed": TaskCompletedPayloadSchema,
|
|
5014
5044
|
"task.failed": TaskFailedPayloadSchema,
|
|
5045
|
+
"task.cancel": TaskCancelPayloadSchema,
|
|
5046
|
+
"task.pull": TaskPullPayloadSchema,
|
|
5047
|
+
"task.yield": TaskYieldPayloadSchema,
|
|
5015
5048
|
"artifact.request": ArtifactRequestPayloadSchema,
|
|
5016
5049
|
"artifact.response": ArtifactResponsePayloadSchema,
|
|
5017
5050
|
error: ErrorPayloadSchema,
|
|
@@ -8216,6 +8249,23 @@ var NodeWorkerDaemon = class {
|
|
|
8216
8249
|
});
|
|
8217
8250
|
this.ws.send(encodeEnvelope(reg));
|
|
8218
8251
|
console.log(`[node-worker] Registered capabilities (${cpus.length} cores, ${Math.round(totalMem / 1024 ** 3)}GB RAM).`);
|
|
8252
|
+
this.pullNextTask();
|
|
8253
|
+
}
|
|
8254
|
+
pullNextTask(batchSize) {
|
|
8255
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
8256
|
+
try {
|
|
8257
|
+
const payload = {
|
|
8258
|
+
workerId: this.workerId,
|
|
8259
|
+
roomId: this.options.roomId
|
|
8260
|
+
};
|
|
8261
|
+
if (batchSize !== void 0) {
|
|
8262
|
+
payload.batchSize = batchSize;
|
|
8263
|
+
payload.maxTasks = batchSize;
|
|
8264
|
+
}
|
|
8265
|
+
const env = createEnvelope("task.pull", this.workerId, payload);
|
|
8266
|
+
this.ws.send(encodeEnvelope(env));
|
|
8267
|
+
} catch {
|
|
8268
|
+
}
|
|
8219
8269
|
}
|
|
8220
8270
|
startHeartbeat() {
|
|
8221
8271
|
const intervalSec = this.options.heartbeatIntervalSec || 5;
|
|
@@ -8341,6 +8391,7 @@ Execution error: ${err.message}`;
|
|
|
8341
8391
|
}
|
|
8342
8392
|
} finally {
|
|
8343
8393
|
this.activeTasks.delete(taskId);
|
|
8394
|
+
this.pullNextTask();
|
|
8344
8395
|
}
|
|
8345
8396
|
}
|
|
8346
8397
|
async downloadArtifact(artifactId, destPath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharedots/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"tsup": "^9.0.0",
|
|
22
22
|
"typescript": "^5.7.2",
|
|
23
23
|
"vitest": "^2.1.8",
|
|
24
|
-
"@sharedots/protocol": "0.1.
|
|
24
|
+
"@sharedots/protocol": "0.1.3",
|
|
25
25
|
"sharedots": "0.1.2",
|
|
26
26
|
"@sharedots/tui": "0.1.2"
|
|
27
27
|
},
|