@slock-ai/computer 0.0.20 → 0.0.21
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 +67 -20
- package/dist/lib/index.js +22 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30483,7 +30483,13 @@ async function readLocalOwners(installRoot) {
|
|
|
30483
30483
|
let raw;
|
|
30484
30484
|
try {
|
|
30485
30485
|
raw = await readFile3(ownerPath, "utf8");
|
|
30486
|
-
} catch {
|
|
30486
|
+
} catch (err) {
|
|
30487
|
+
if (err?.code === "ENOENT") {
|
|
30488
|
+
const fromDir = name.slice(MACHINE_DIR_PREFIX.length);
|
|
30489
|
+
if (FINGERPRINT_HEX_RE.test(fromDir)) {
|
|
30490
|
+
owners.push({ apiKeyFingerprint: fromDir, localPath: join(machinesDir, name) });
|
|
30491
|
+
}
|
|
30492
|
+
}
|
|
30487
30493
|
continue;
|
|
30488
30494
|
}
|
|
30489
30495
|
let parsed;
|
|
@@ -30964,6 +30970,22 @@ async function appendAdoptionLog(slockHome, line) {
|
|
|
30964
30970
|
// src/service.ts
|
|
30965
30971
|
init_esm_shims();
|
|
30966
30972
|
import { spawn as spawn2 } from "child_process";
|
|
30973
|
+
|
|
30974
|
+
// src/version.ts
|
|
30975
|
+
init_esm_shims();
|
|
30976
|
+
import { createRequire } from "module";
|
|
30977
|
+
function readComputerVersion(moduleUrl = import.meta.url) {
|
|
30978
|
+
try {
|
|
30979
|
+
const require2 = createRequire(moduleUrl);
|
|
30980
|
+
const pkg = require2("../package.json");
|
|
30981
|
+
return typeof pkg.version === "string" && pkg.version.length > 0 ? pkg.version : "0.0.0-dev";
|
|
30982
|
+
} catch {
|
|
30983
|
+
return "0.0.0-dev";
|
|
30984
|
+
}
|
|
30985
|
+
}
|
|
30986
|
+
var COMPUTER_VERSION = readComputerVersion();
|
|
30987
|
+
|
|
30988
|
+
// src/service.ts
|
|
30967
30989
|
import { mkdir as mkdir8, readFile as readFile7, writeFile as writeFile7, open, rename as rename2 } from "fs/promises";
|
|
30968
30990
|
import { dirname as dirname8, join as joinPath } from "path";
|
|
30969
30991
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -31774,7 +31796,41 @@ var defaultCoreFactory = async (creds) => {
|
|
|
31774
31796
|
}
|
|
31775
31797
|
throw err;
|
|
31776
31798
|
}
|
|
31777
|
-
|
|
31799
|
+
process.env.SLOCK_COMPUTER_VERSION = COMPUTER_VERSION;
|
|
31800
|
+
return new coreMod.DaemonCore({
|
|
31801
|
+
serverUrl: creds.serverUrl,
|
|
31802
|
+
apiKey: creds.apiKey,
|
|
31803
|
+
localTrace: true,
|
|
31804
|
+
// Managed-Computer remote control (server → WS → runner). This runner
|
|
31805
|
+
// is the service's in-process `__run` child, so:
|
|
31806
|
+
// restart → SIGTERM ourselves → runResident's shutdown does
|
|
31807
|
+
// core.stop() + exit 0 → classifyRunnerExit = graceful → the
|
|
31808
|
+
// service supervisor respawns this runner (effective restart).
|
|
31809
|
+
// upgrade → launch `slock-computer upgrade` out-of-band (detached)
|
|
31810
|
+
// so the §12 drain+swap+restart runs outside this event loop.
|
|
31811
|
+
onComputerControl: (action) => {
|
|
31812
|
+
if (action === "restart") {
|
|
31813
|
+
process.kill(process.pid, "SIGTERM");
|
|
31814
|
+
return;
|
|
31815
|
+
}
|
|
31816
|
+
try {
|
|
31817
|
+
const selfEntry = process.argv[1] ?? "";
|
|
31818
|
+
const child = spawn2(process.execPath, [...process.execArgv, selfEntry, "upgrade"], {
|
|
31819
|
+
detached: true,
|
|
31820
|
+
stdio: "ignore",
|
|
31821
|
+
windowsHide: true,
|
|
31822
|
+
// Attribute this upgrade to the web surface in upgrade.log — the
|
|
31823
|
+
// `upgrade` command reads SLOCK_UPGRADE_TRIGGER and defaults to
|
|
31824
|
+
// "cli" when unset.
|
|
31825
|
+
env: { ...process.env, SLOCK_UPGRADE_TRIGGER: "web" }
|
|
31826
|
+
});
|
|
31827
|
+
child.on("error", () => {
|
|
31828
|
+
});
|
|
31829
|
+
child.unref();
|
|
31830
|
+
} catch {
|
|
31831
|
+
}
|
|
31832
|
+
}
|
|
31833
|
+
});
|
|
31778
31834
|
};
|
|
31779
31835
|
function classifyRunnerExit(code, signal) {
|
|
31780
31836
|
if (code === EX_CONFIG_EXIT_CODE) return "config-error";
|
|
@@ -33243,7 +33299,7 @@ import { createHash as createHash3 } from "crypto";
|
|
|
33243
33299
|
init_esm_shims();
|
|
33244
33300
|
import { readFile as readFile13 } from "fs/promises";
|
|
33245
33301
|
import { spawn as spawn3 } from "child_process";
|
|
33246
|
-
import { createRequire } from "module";
|
|
33302
|
+
import { createRequire as createRequire2 } from "module";
|
|
33247
33303
|
import { join as join5 } from "path";
|
|
33248
33304
|
import { pathToFileURL } from "url";
|
|
33249
33305
|
var DAEMON_PACKAGE_NAME = "@slock-ai/daemon";
|
|
@@ -33412,7 +33468,7 @@ async function defaultReadInstalledDaemonVersion(currentBinaryDir) {
|
|
|
33412
33468
|
let searchPaths;
|
|
33413
33469
|
try {
|
|
33414
33470
|
const anchor = pathToFileURL(join5(currentBinaryDir, "package.json"));
|
|
33415
|
-
const req =
|
|
33471
|
+
const req = createRequire2(anchor);
|
|
33416
33472
|
searchPaths = req.resolve.paths(DAEMON_PACKAGE_NAME);
|
|
33417
33473
|
} catch {
|
|
33418
33474
|
return null;
|
|
@@ -34232,6 +34288,9 @@ async function locateStagedTarball(stagedPath) {
|
|
|
34232
34288
|
init_esm_shims();
|
|
34233
34289
|
import { chmod as chmod5, mkdir as mkdir14, open as open2 } from "fs/promises";
|
|
34234
34290
|
var FILE_MODE = 384;
|
|
34291
|
+
function resolveUpgradeTrigger(raw) {
|
|
34292
|
+
return raw === "web" || raw === "tray" ? raw : "cli";
|
|
34293
|
+
}
|
|
34235
34294
|
var UPGRADE_ERROR_CODES = [
|
|
34236
34295
|
"UPGRADE_DEPS_CHANGED",
|
|
34237
34296
|
"UPGRADE_NETWORK_FAILED",
|
|
@@ -34878,20 +34937,6 @@ async function defaultCurrentVersionLocal() {
|
|
|
34878
34937
|
);
|
|
34879
34938
|
}
|
|
34880
34939
|
|
|
34881
|
-
// src/version.ts
|
|
34882
|
-
init_esm_shims();
|
|
34883
|
-
import { createRequire as createRequire2 } from "module";
|
|
34884
|
-
function readComputerVersion(moduleUrl = import.meta.url) {
|
|
34885
|
-
try {
|
|
34886
|
-
const require2 = createRequire2(moduleUrl);
|
|
34887
|
-
const pkg = require2("../package.json");
|
|
34888
|
-
return typeof pkg.version === "string" && pkg.version.length > 0 ? pkg.version : "0.0.0-dev";
|
|
34889
|
-
} catch {
|
|
34890
|
-
return "0.0.0-dev";
|
|
34891
|
-
}
|
|
34892
|
-
}
|
|
34893
|
-
var COMPUTER_VERSION = readComputerVersion();
|
|
34894
|
-
|
|
34895
34940
|
// src/index.ts
|
|
34896
34941
|
function withCliExit(fn) {
|
|
34897
34942
|
return async (...args) => {
|
|
@@ -35019,6 +35064,7 @@ program2.command("upgrade").description(
|
|
|
35019
35064
|
drain = opts.drain;
|
|
35020
35065
|
}
|
|
35021
35066
|
const slockHome = resolveSlockHome();
|
|
35067
|
+
const trigger = resolveUpgradeTrigger(process.env.SLOCK_UPGRADE_TRIGGER);
|
|
35022
35068
|
try {
|
|
35023
35069
|
await withMutationLock(
|
|
35024
35070
|
() => runUpgradeCli(slockHome, {
|
|
@@ -35026,7 +35072,8 @@ program2.command("upgrade").description(
|
|
|
35026
35072
|
channel: opts.channel,
|
|
35027
35073
|
targetVersion: opts.targetVersion,
|
|
35028
35074
|
drain,
|
|
35029
|
-
force: opts.force
|
|
35075
|
+
force: opts.force,
|
|
35076
|
+
trigger
|
|
35030
35077
|
})
|
|
35031
35078
|
);
|
|
35032
35079
|
} catch (err) {
|
|
@@ -35038,7 +35085,7 @@ program2.command("upgrade").description(
|
|
|
35038
35085
|
fromBundle: { computerVersion: currentVersion },
|
|
35039
35086
|
toBundle: { computerVersion: currentVersion },
|
|
35040
35087
|
channel: channel2,
|
|
35041
|
-
trigger
|
|
35088
|
+
trigger,
|
|
35042
35089
|
outcome: "err",
|
|
35043
35090
|
errorCode: "UPGRADE_ALREADY_RUNNING"
|
|
35044
35091
|
}).catch(() => {
|
package/dist/lib/index.js
CHANGED
|
@@ -56,7 +56,13 @@ async function readLocalOwners(installRoot) {
|
|
|
56
56
|
let raw;
|
|
57
57
|
try {
|
|
58
58
|
raw = await readFile(ownerPath, "utf8");
|
|
59
|
-
} catch {
|
|
59
|
+
} catch (err) {
|
|
60
|
+
if (err?.code === "ENOENT") {
|
|
61
|
+
const fromDir = name.slice(MACHINE_DIR_PREFIX.length);
|
|
62
|
+
if (FINGERPRINT_HEX_RE.test(fromDir)) {
|
|
63
|
+
owners.push({ apiKeyFingerprint: fromDir, localPath: join(machinesDir, name) });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
60
66
|
continue;
|
|
61
67
|
}
|
|
62
68
|
let parsed;
|
|
@@ -422,6 +428,21 @@ import { setTimeout as delay } from "timers/promises";
|
|
|
422
428
|
|
|
423
429
|
// src/service.ts
|
|
424
430
|
import { spawn as spawn2 } from "child_process";
|
|
431
|
+
|
|
432
|
+
// src/version.ts
|
|
433
|
+
import { createRequire } from "module";
|
|
434
|
+
function readComputerVersion(moduleUrl = import.meta.url) {
|
|
435
|
+
try {
|
|
436
|
+
const require2 = createRequire(moduleUrl);
|
|
437
|
+
const pkg = require2("../package.json");
|
|
438
|
+
return typeof pkg.version === "string" && pkg.version.length > 0 ? pkg.version : "0.0.0-dev";
|
|
439
|
+
} catch {
|
|
440
|
+
return "0.0.0-dev";
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
var COMPUTER_VERSION = readComputerVersion();
|
|
444
|
+
|
|
445
|
+
// src/service.ts
|
|
425
446
|
import { mkdir as mkdir8, readFile as readFile7, writeFile as writeFile7, open, rename as rename2 } from "fs/promises";
|
|
426
447
|
import { dirname as dirname7, join as joinPath } from "path";
|
|
427
448
|
import { fileURLToPath } from "url";
|
package/package.json
CHANGED