viveworker 0.7.0 → 0.8.0
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/README.md +33 -4
- package/package.json +7 -3
- package/scripts/lib/remote-pairing/README.md +164 -0
- package/scripts/lib/remote-pairing/_browser-bundle-entry.mjs +86 -0
- package/scripts/lib/remote-pairing/audit.mjs +122 -0
- package/scripts/lib/remote-pairing/bridge-relay-client.mjs +737 -0
- package/scripts/lib/remote-pairing/control.mjs +156 -0
- package/scripts/lib/remote-pairing/envelope.mjs +224 -0
- package/scripts/lib/remote-pairing/http-dispatch.mjs +530 -0
- package/scripts/lib/remote-pairing/keys-core.mjs +110 -0
- package/scripts/lib/remote-pairing/keys.mjs +181 -0
- package/scripts/lib/remote-pairing/noise.mjs +436 -0
- package/scripts/lib/remote-pairing/orchestrator.mjs +356 -0
- package/scripts/lib/remote-pairing/pairings.mjs +446 -0
- package/scripts/lib/remote-pairing/rpc.mjs +381 -0
- package/scripts/moltbook-scout-auto.sh +16 -8
- package/scripts/share-cli.mjs +14 -130
- package/scripts/viveworker-bridge.mjs +1324 -103
- package/scripts/viveworker.mjs +27 -6
- package/web/app.css +634 -9
- package/web/app.js +1731 -187
- package/web/i18n.js +187 -9
- package/web/index.html +32 -2
- package/web/remote-pairing/api-router.js +873 -0
- package/web/remote-pairing/keys.js +237 -0
- package/web/remote-pairing/pairing-state.js +313 -0
- package/web/remote-pairing/rpc-client.js +765 -0
- package/web/remote-pairing/transport.js +804 -0
- package/web/remote-pairing/wake.js +149 -0
- package/web/remote-pairing-test.html +400 -0
- package/web/remote-pairing.bundle.js +3 -0
- package/web/remote-pairing.bundle.js.LEGAL.txt +15 -0
- package/web/remote-pairing.bundle.js.map +7 -0
- package/web/sw.js +190 -20
package/scripts/viveworker.mjs
CHANGED
|
@@ -863,13 +863,16 @@ async function runStart(cliOptions) {
|
|
|
863
863
|
}
|
|
864
864
|
|
|
865
865
|
progress.update("cli.start.progress.bridge");
|
|
866
|
-
await
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
866
|
+
const alreadyHealthy = await waitForHealth(healthUrl, { attempts: 1, intervalMs: 0 });
|
|
867
|
+
if (!alreadyHealthy) {
|
|
868
|
+
await startDetachedBridge({
|
|
869
|
+
envFile,
|
|
870
|
+
logFile: resolvePath(cliOptions.logFile || defaultLogFile),
|
|
871
|
+
pidFile,
|
|
872
|
+
});
|
|
873
|
+
}
|
|
871
874
|
progress.update("cli.start.progress.health");
|
|
872
|
-
const healthy = await waitForHealth(healthUrl);
|
|
875
|
+
const healthy = alreadyHealthy || await waitForHealth(healthUrl);
|
|
873
876
|
const pairingReady = healthy && rotatedPairing.rotated
|
|
874
877
|
? await waitForExpectedPairing(config.NATIVE_APPROVAL_SERVER_PUBLIC_BASE_URL || "", rotatedPairing.pairingToken)
|
|
875
878
|
: true;
|
|
@@ -1691,6 +1694,11 @@ function buildLaunchAgentPlist({ label, nodePath, bridgeScript, envFile, logFile
|
|
|
1691
1694
|
}
|
|
1692
1695
|
|
|
1693
1696
|
async function startDetachedBridge({ envFile, logFile, pidFile }) {
|
|
1697
|
+
const existingPid = await maybeReadPid(pidFile);
|
|
1698
|
+
if (existingPid && isProcessRunning(existingPid)) {
|
|
1699
|
+
return { pid: existingPid, alreadyRunning: true };
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1694
1702
|
await fs.mkdir(path.dirname(logFile), { recursive: true });
|
|
1695
1703
|
const logHandle = await fs.open(logFile, "a");
|
|
1696
1704
|
const child = spawn(process.execPath, [bridgeScript, "--env-file", envFile], {
|
|
@@ -1700,6 +1708,7 @@ async function startDetachedBridge({ envFile, logFile, pidFile }) {
|
|
|
1700
1708
|
child.unref();
|
|
1701
1709
|
await logHandle.close();
|
|
1702
1710
|
await fs.writeFile(pidFile, `${child.pid}\n`, "utf8");
|
|
1711
|
+
return { pid: child.pid, alreadyRunning: false };
|
|
1703
1712
|
}
|
|
1704
1713
|
|
|
1705
1714
|
async function maybeReadPid(pidFile) {
|
|
@@ -1712,6 +1721,18 @@ async function maybeReadPid(pidFile) {
|
|
|
1712
1721
|
}
|
|
1713
1722
|
}
|
|
1714
1723
|
|
|
1724
|
+
function isProcessRunning(pid) {
|
|
1725
|
+
if (!Number.isFinite(pid) || pid <= 0) {
|
|
1726
|
+
return false;
|
|
1727
|
+
}
|
|
1728
|
+
try {
|
|
1729
|
+
process.kill(pid, 0);
|
|
1730
|
+
return true;
|
|
1731
|
+
} catch {
|
|
1732
|
+
return false;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1715
1736
|
async function maybeReadEnvFile(filePath) {
|
|
1716
1737
|
const output = {};
|
|
1717
1738
|
try {
|