mindwire 0.1.29 → 0.1.30
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/{chunk-QPZMGVY7.js → chunk-RN7ERVJ2.js} +29 -10
- package/dist/chunk-RN7ERVJ2.js.map +1 -0
- package/dist/cli.js +13 -9
- package/dist/cli.js.map +1 -1
- package/dist/computer/connection-flow.d.ts +3 -0
- package/dist/computer/controller-handoff.d.ts +6 -0
- package/dist/computer/lifecycle.d.ts +4 -0
- package/dist/computer/relay-health.d.ts +11 -0
- package/dist/computer.d.ts +5 -2
- package/dist/{controller-MNMIJHH5.js → controller-DIJKMWWU.js} +156 -11
- package/dist/controller-DIJKMWWU.js.map +1 -0
- package/dist/controller-handoff-4GXF4ATR.js +71 -0
- package/dist/controller-handoff-4GXF4ATR.js.map +1 -0
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/package.json +7 -3
- package/dist/chunk-QPZMGVY7.js.map +0 -1
- package/dist/controller-MNMIJHH5.js.map +0 -1
|
@@ -79,7 +79,16 @@ function computerPairingURI(invitation) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// src/version.ts
|
|
82
|
-
var SDK_VERSION = "0.1.
|
|
82
|
+
var SDK_VERSION = "0.1.30" ;
|
|
83
|
+
function versionAtLeast(actual, desired) {
|
|
84
|
+
if (actual === desired) return true;
|
|
85
|
+
if (!actual || !/^\d+\.\d+\.\d+$/.test(actual) || !/^\d+\.\d+\.\d+$/.test(desired)) return false;
|
|
86
|
+
const a = actual.split(".").map(Number), b = desired.split(".").map(Number);
|
|
87
|
+
for (let i = 0; i < 3; i++) {
|
|
88
|
+
if (a[i] !== b[i]) return a[i] > b[i];
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
83
92
|
|
|
84
93
|
// src/daemon-binary.ts
|
|
85
94
|
function supported(platform, arch) {
|
|
@@ -1884,6 +1893,7 @@ async function acquireProcessLock(file, options = {}) {
|
|
|
1884
1893
|
}
|
|
1885
1894
|
|
|
1886
1895
|
// src/computer/lifecycle.ts
|
|
1896
|
+
var CONTROLLER_PROTOCOL = 2;
|
|
1887
1897
|
var defaultStateDirectory = () => path.join(homedir(), ".mindwire", "computer");
|
|
1888
1898
|
var defaultComputerConfig = () => ({ directory: homedir(), bind: "0.0.0.0", sshPort: 8791, websocketPort: 8792, relay: { kind: "cloudflare" } });
|
|
1889
1899
|
async function readJSON(file) {
|
|
@@ -1938,6 +1948,9 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
|
|
|
1938
1948
|
const configPath = path.join(directory, "computer-config.json");
|
|
1939
1949
|
const previous = await readJSON(configPath);
|
|
1940
1950
|
const config = { ...defaultComputerConfig(), ...previous, ...patch };
|
|
1951
|
+
const requestedAt = resume ? Date.now() : 0;
|
|
1952
|
+
if (resume) await writeJSON(path.join(directory, "computer-check.json"), { requestedAt });
|
|
1953
|
+
const compatible = (controller) => (controller?.protocol ?? 0) >= CONTROLLER_PROTOCOL && versionAtLeast(controller?.cliVersion, SDK_VERSION);
|
|
1941
1954
|
let launchedPID;
|
|
1942
1955
|
let launchFailure;
|
|
1943
1956
|
const waitUntilReady = async () => {
|
|
@@ -1951,7 +1964,7 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
|
|
|
1951
1964
|
continue;
|
|
1952
1965
|
}
|
|
1953
1966
|
if (controller?.error && !controller.recovering) throw new Error(controller.error);
|
|
1954
|
-
if (controller?.ready && await processStateAlive(controller)) return computerClient(directory);
|
|
1967
|
+
if (controller?.ready && compatible(controller) && (controller.checkedAt ?? 0) >= requestedAt && await processStateAlive(controller)) return computerClient(directory);
|
|
1955
1968
|
if (controller?.phase && controller.phase !== phase) {
|
|
1956
1969
|
phase = controller.phase;
|
|
1957
1970
|
onProgress?.(phase);
|
|
@@ -1965,14 +1978,14 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
|
|
|
1965
1978
|
throw new Error("Mindwire is running with different connection settings. Run mindwire stop when idle, then retry with the new settings.");
|
|
1966
1979
|
}
|
|
1967
1980
|
const controller = await readJSON(path.join(directory, "computer-controller.json"));
|
|
1968
|
-
if (await processStateAlive(controller)) return waitUntilReady();
|
|
1981
|
+
if (compatible(controller) && await processStateAlive(controller)) return waitUntilReady();
|
|
1969
1982
|
}
|
|
1970
1983
|
const lockPath = path.join(directory, "launch.lock");
|
|
1971
1984
|
const lock = await acquireProcessLock(lockPath, {
|
|
1972
1985
|
signal: options.signal,
|
|
1973
1986
|
onWait: async () => {
|
|
1974
1987
|
const controller = await readJSON(path.join(directory, "computer-controller.json"));
|
|
1975
|
-
if (await processStateAlive(controller)) {
|
|
1988
|
+
if (compatible(controller) && await processStateAlive(controller)) {
|
|
1976
1989
|
const saved = await readJSON(configPath);
|
|
1977
1990
|
if (Object.keys(patch).some((key) => JSON.stringify(patch[key]) !== JSON.stringify(saved?.[key]))) {
|
|
1978
1991
|
throw new Error("Another start used different connection settings. Stop Mindwire when idle before changing them.");
|
|
@@ -1996,9 +2009,15 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
|
|
|
1996
2009
|
throw new Error("Another start used different connection settings. Stop Mindwire when idle before changing them.");
|
|
1997
2010
|
}
|
|
1998
2011
|
const controller2 = await readJSON(path.join(directory, "computer-controller.json"));
|
|
1999
|
-
if (await processStateAlive(controller2)) return waitUntilReady();
|
|
2012
|
+
if (compatible(controller2) && await processStateAlive(controller2)) return waitUntilReady();
|
|
2013
|
+
}
|
|
2014
|
+
let controller = await readJSON(path.join(directory, "computer-controller.json"));
|
|
2015
|
+
if (existing && controller && !compatible(controller) && await processStateAlive(controller)) {
|
|
2016
|
+
onProgress?.("Refreshing the background connection service\u2026");
|
|
2017
|
+
const { handoffController } = await import('./controller-handoff-4GXF4ATR.js');
|
|
2018
|
+
await handoffController(directory, controller, config, await existing.computer.info());
|
|
2019
|
+
controller = void 0;
|
|
2000
2020
|
}
|
|
2001
|
-
const controller = await readJSON(path.join(directory, "computer-controller.json"));
|
|
2002
2021
|
if (await processStateAlive(controller)) {
|
|
2003
2022
|
if (controller?.error && !controller.recovering) throw new Error(controller.error);
|
|
2004
2023
|
} else {
|
|
@@ -2029,7 +2048,7 @@ async function ensureComputer(directory, cliPath, patch = {}, onProgress, option
|
|
|
2029
2048
|
}
|
|
2030
2049
|
}
|
|
2031
2050
|
async function superviseComputer(directory) {
|
|
2032
|
-
const controller = await import('./controller-
|
|
2051
|
+
const controller = await import('./controller-DIJKMWWU.js');
|
|
2033
2052
|
await controller.superviseComputer(directory);
|
|
2034
2053
|
}
|
|
2035
2054
|
async function stopComputer(directory, force = false) {
|
|
@@ -2053,6 +2072,6 @@ async function stopComputer(directory, force = false) {
|
|
|
2053
2072
|
throw new Error("Mindwire is still stopping. Check computer.log.");
|
|
2054
2073
|
}
|
|
2055
2074
|
|
|
2056
|
-
export { SDK_VERSION, acquireProcessLock, adoptProcess, computerClient, computerPairingQRData, computerPairingURI, currentProcessIdentity, defaultStateDirectory, directRoutes, ensureComputer, ensureDaemonBinary, ownChild, processIdentity, processStateAlive, readJSON, stopComputer, superviseComputer, writeJSON };
|
|
2057
|
-
//# sourceMappingURL=chunk-
|
|
2058
|
-
//# sourceMappingURL=chunk-
|
|
2075
|
+
export { CONTROLLER_PROTOCOL, SDK_VERSION, acquireProcessLock, adoptProcess, computerClient, computerPairingQRData, computerPairingURI, currentProcessIdentity, defaultStateDirectory, directRoutes, ensureComputer, ensureDaemonBinary, ownChild, processIdentity, processStateAlive, readJSON, stopComputer, superviseComputer, writeJSON };
|
|
2076
|
+
//# sourceMappingURL=chunk-RN7ERVJ2.js.map
|
|
2077
|
+
//# sourceMappingURL=chunk-RN7ERVJ2.js.map
|