@slock-ai/computer 0.0.20 → 0.0.22
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 +68 -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";
|
|
@@ -32390,6 +32446,7 @@ async function runSetup(opts, deps = {}) {
|
|
|
32390
32446
|
"Non-interactive setup requires --yes after you have confirmed the login/attach/start actions. Run `slock-computer login`, `slock-computer attach`, and `slock-computer start` separately for fully explicit automation."
|
|
32391
32447
|
);
|
|
32392
32448
|
}
|
|
32449
|
+
opts = { ...opts, serverSlug: normalizeServerSlug(opts.serverSlug) };
|
|
32393
32450
|
const label = formatServerSlugDisplay(opts.serverSlug);
|
|
32394
32451
|
info(`Setting up Slock Computer for ${label}\u2026`);
|
|
32395
32452
|
if (!await hasValidUserSession(slockHome)) {
|
|
@@ -33243,7 +33300,7 @@ import { createHash as createHash3 } from "crypto";
|
|
|
33243
33300
|
init_esm_shims();
|
|
33244
33301
|
import { readFile as readFile13 } from "fs/promises";
|
|
33245
33302
|
import { spawn as spawn3 } from "child_process";
|
|
33246
|
-
import { createRequire } from "module";
|
|
33303
|
+
import { createRequire as createRequire2 } from "module";
|
|
33247
33304
|
import { join as join5 } from "path";
|
|
33248
33305
|
import { pathToFileURL } from "url";
|
|
33249
33306
|
var DAEMON_PACKAGE_NAME = "@slock-ai/daemon";
|
|
@@ -33412,7 +33469,7 @@ async function defaultReadInstalledDaemonVersion(currentBinaryDir) {
|
|
|
33412
33469
|
let searchPaths;
|
|
33413
33470
|
try {
|
|
33414
33471
|
const anchor = pathToFileURL(join5(currentBinaryDir, "package.json"));
|
|
33415
|
-
const req =
|
|
33472
|
+
const req = createRequire2(anchor);
|
|
33416
33473
|
searchPaths = req.resolve.paths(DAEMON_PACKAGE_NAME);
|
|
33417
33474
|
} catch {
|
|
33418
33475
|
return null;
|
|
@@ -34232,6 +34289,9 @@ async function locateStagedTarball(stagedPath) {
|
|
|
34232
34289
|
init_esm_shims();
|
|
34233
34290
|
import { chmod as chmod5, mkdir as mkdir14, open as open2 } from "fs/promises";
|
|
34234
34291
|
var FILE_MODE = 384;
|
|
34292
|
+
function resolveUpgradeTrigger(raw) {
|
|
34293
|
+
return raw === "web" || raw === "tray" ? raw : "cli";
|
|
34294
|
+
}
|
|
34235
34295
|
var UPGRADE_ERROR_CODES = [
|
|
34236
34296
|
"UPGRADE_DEPS_CHANGED",
|
|
34237
34297
|
"UPGRADE_NETWORK_FAILED",
|
|
@@ -34878,20 +34938,6 @@ async function defaultCurrentVersionLocal() {
|
|
|
34878
34938
|
);
|
|
34879
34939
|
}
|
|
34880
34940
|
|
|
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
34941
|
// src/index.ts
|
|
34896
34942
|
function withCliExit(fn) {
|
|
34897
34943
|
return async (...args) => {
|
|
@@ -35019,6 +35065,7 @@ program2.command("upgrade").description(
|
|
|
35019
35065
|
drain = opts.drain;
|
|
35020
35066
|
}
|
|
35021
35067
|
const slockHome = resolveSlockHome();
|
|
35068
|
+
const trigger = resolveUpgradeTrigger(process.env.SLOCK_UPGRADE_TRIGGER);
|
|
35022
35069
|
try {
|
|
35023
35070
|
await withMutationLock(
|
|
35024
35071
|
() => runUpgradeCli(slockHome, {
|
|
@@ -35026,7 +35073,8 @@ program2.command("upgrade").description(
|
|
|
35026
35073
|
channel: opts.channel,
|
|
35027
35074
|
targetVersion: opts.targetVersion,
|
|
35028
35075
|
drain,
|
|
35029
|
-
force: opts.force
|
|
35076
|
+
force: opts.force,
|
|
35077
|
+
trigger
|
|
35030
35078
|
})
|
|
35031
35079
|
);
|
|
35032
35080
|
} catch (err) {
|
|
@@ -35038,7 +35086,7 @@ program2.command("upgrade").description(
|
|
|
35038
35086
|
fromBundle: { computerVersion: currentVersion },
|
|
35039
35087
|
toBundle: { computerVersion: currentVersion },
|
|
35040
35088
|
channel: channel2,
|
|
35041
|
-
trigger
|
|
35089
|
+
trigger,
|
|
35042
35090
|
outcome: "err",
|
|
35043
35091
|
errorCode: "UPGRADE_ALREADY_RUNNING"
|
|
35044
35092
|
}).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