@botiverse/raft-computer 0.0.57 → 0.0.58
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 +607 -247
- package/dist/lib/index.js +62 -54
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5874,7 +5874,7 @@ var require_connect = __commonJS({
|
|
|
5874
5874
|
const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions);
|
|
5875
5875
|
timeout = timeout == null ? 1e4 : timeout;
|
|
5876
5876
|
allowH2 = allowH2 != null ? allowH2 : false;
|
|
5877
|
-
return function
|
|
5877
|
+
return function connect2({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) {
|
|
5878
5878
|
let socket;
|
|
5879
5879
|
if (protocol === "https:") {
|
|
5880
5880
|
if (!tls) {
|
|
@@ -11552,7 +11552,7 @@ var require_client = __commonJS({
|
|
|
11552
11552
|
tls,
|
|
11553
11553
|
strictContentLength,
|
|
11554
11554
|
maxCachedSessions,
|
|
11555
|
-
connect:
|
|
11555
|
+
connect: connect3,
|
|
11556
11556
|
maxRequestsPerClient,
|
|
11557
11557
|
localAddress,
|
|
11558
11558
|
maxResponseSize,
|
|
@@ -11609,7 +11609,7 @@ var require_client = __commonJS({
|
|
|
11609
11609
|
if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) {
|
|
11610
11610
|
throw new InvalidArgumentError2("bodyTimeout must be a positive integer or zero");
|
|
11611
11611
|
}
|
|
11612
|
-
if (
|
|
11612
|
+
if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") {
|
|
11613
11613
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
11614
11614
|
}
|
|
11615
11615
|
if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
|
|
@@ -11643,8 +11643,8 @@ var require_client = __commonJS({
|
|
|
11643
11643
|
throw new InvalidArgumentError2("pingInterval must be a positive integer, greater or equal to 0");
|
|
11644
11644
|
}
|
|
11645
11645
|
super();
|
|
11646
|
-
if (typeof
|
|
11647
|
-
|
|
11646
|
+
if (typeof connect3 !== "function") {
|
|
11647
|
+
connect3 = buildConnector({
|
|
11648
11648
|
...tls,
|
|
11649
11649
|
maxCachedSessions,
|
|
11650
11650
|
allowH2,
|
|
@@ -11652,14 +11652,14 @@ var require_client = __commonJS({
|
|
|
11652
11652
|
socketPath,
|
|
11653
11653
|
timeout: connectTimeout,
|
|
11654
11654
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
11655
|
-
...
|
|
11655
|
+
...connect3
|
|
11656
11656
|
});
|
|
11657
11657
|
} else if (socketPath != null) {
|
|
11658
|
-
const customConnect =
|
|
11659
|
-
|
|
11658
|
+
const customConnect = connect3;
|
|
11659
|
+
connect3 = (opts, callback) => customConnect({ ...opts, socketPath }, callback);
|
|
11660
11660
|
}
|
|
11661
11661
|
this[kUrl] = util.parseOrigin(url);
|
|
11662
|
-
this[kConnector] =
|
|
11662
|
+
this[kConnector] = connect3;
|
|
11663
11663
|
this[kPipelining] = pipelining != null ? pipelining : 1;
|
|
11664
11664
|
this[kMaxHeadersSize] = maxHeaderSize;
|
|
11665
11665
|
this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout;
|
|
@@ -11717,7 +11717,7 @@ var require_client = __commonJS({
|
|
|
11717
11717
|
);
|
|
11718
11718
|
}
|
|
11719
11719
|
[kConnect](cb) {
|
|
11720
|
-
|
|
11720
|
+
connect2(this);
|
|
11721
11721
|
this.once("connect", cb);
|
|
11722
11722
|
}
|
|
11723
11723
|
[kDispatch](opts, handler) {
|
|
@@ -11779,7 +11779,7 @@ var require_client = __commonJS({
|
|
|
11779
11779
|
assert(client[kSize] === 0);
|
|
11780
11780
|
}
|
|
11781
11781
|
}
|
|
11782
|
-
function
|
|
11782
|
+
function connect2(client) {
|
|
11783
11783
|
assert(!client[kConnecting]);
|
|
11784
11784
|
assert(!client[kHTTPContext]);
|
|
11785
11785
|
let { host, hostname, protocol, port } = client[kUrl];
|
|
@@ -11958,7 +11958,7 @@ var require_client = __commonJS({
|
|
|
11958
11958
|
return;
|
|
11959
11959
|
}
|
|
11960
11960
|
if (!client[kHTTPContext]) {
|
|
11961
|
-
|
|
11961
|
+
connect2(client);
|
|
11962
11962
|
return;
|
|
11963
11963
|
}
|
|
11964
11964
|
if (client[kHTTPContext].destroyed) {
|
|
@@ -12257,7 +12257,7 @@ var require_pool = __commonJS({
|
|
|
12257
12257
|
constructor(origin, {
|
|
12258
12258
|
connections,
|
|
12259
12259
|
factory = defaultFactory,
|
|
12260
|
-
connect,
|
|
12260
|
+
connect: connect2,
|
|
12261
12261
|
connectTimeout,
|
|
12262
12262
|
tls,
|
|
12263
12263
|
maxCachedSessions,
|
|
@@ -12274,24 +12274,24 @@ var require_pool = __commonJS({
|
|
|
12274
12274
|
if (typeof factory !== "function") {
|
|
12275
12275
|
throw new InvalidArgumentError2("factory must be a function.");
|
|
12276
12276
|
}
|
|
12277
|
-
if (
|
|
12277
|
+
if (connect2 != null && typeof connect2 !== "function" && typeof connect2 !== "object") {
|
|
12278
12278
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
12279
12279
|
}
|
|
12280
|
-
if (typeof
|
|
12281
|
-
|
|
12280
|
+
if (typeof connect2 !== "function") {
|
|
12281
|
+
connect2 = buildConnector({
|
|
12282
12282
|
...tls,
|
|
12283
12283
|
maxCachedSessions,
|
|
12284
12284
|
allowH2,
|
|
12285
12285
|
socketPath,
|
|
12286
12286
|
timeout: connectTimeout,
|
|
12287
12287
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
12288
|
-
...
|
|
12288
|
+
...connect2
|
|
12289
12289
|
});
|
|
12290
12290
|
}
|
|
12291
12291
|
super();
|
|
12292
12292
|
this[kConnections] = connections || null;
|
|
12293
12293
|
this[kUrl] = util.parseOrigin(origin);
|
|
12294
|
-
this[kOptions] = { ...util.deepClone(options), connect, allowH2, clientTtl, socketPath };
|
|
12294
|
+
this[kOptions] = { ...util.deepClone(options), connect: connect2, allowH2, clientTtl, socketPath };
|
|
12295
12295
|
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
|
12296
12296
|
this[kFactory] = factory;
|
|
12297
12297
|
this.on("connect", (origin2, targets) => {
|
|
@@ -12510,7 +12510,7 @@ var require_round_robin_pool = __commonJS({
|
|
|
12510
12510
|
constructor(origin, {
|
|
12511
12511
|
connections,
|
|
12512
12512
|
factory = defaultFactory,
|
|
12513
|
-
connect,
|
|
12513
|
+
connect: connect2,
|
|
12514
12514
|
connectTimeout,
|
|
12515
12515
|
tls,
|
|
12516
12516
|
maxCachedSessions,
|
|
@@ -12527,24 +12527,24 @@ var require_round_robin_pool = __commonJS({
|
|
|
12527
12527
|
if (typeof factory !== "function") {
|
|
12528
12528
|
throw new InvalidArgumentError2("factory must be a function.");
|
|
12529
12529
|
}
|
|
12530
|
-
if (
|
|
12530
|
+
if (connect2 != null && typeof connect2 !== "function" && typeof connect2 !== "object") {
|
|
12531
12531
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
12532
12532
|
}
|
|
12533
|
-
if (typeof
|
|
12534
|
-
|
|
12533
|
+
if (typeof connect2 !== "function") {
|
|
12534
|
+
connect2 = buildConnector({
|
|
12535
12535
|
...tls,
|
|
12536
12536
|
maxCachedSessions,
|
|
12537
12537
|
allowH2,
|
|
12538
12538
|
socketPath,
|
|
12539
12539
|
timeout: connectTimeout,
|
|
12540
12540
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
12541
|
-
...
|
|
12541
|
+
...connect2
|
|
12542
12542
|
});
|
|
12543
12543
|
}
|
|
12544
12544
|
super();
|
|
12545
12545
|
this[kConnections] = connections || null;
|
|
12546
12546
|
this[kUrl] = util.parseOrigin(origin);
|
|
12547
|
-
this[kOptions] = { ...util.deepClone(options), connect, allowH2, clientTtl, socketPath };
|
|
12547
|
+
this[kOptions] = { ...util.deepClone(options), connect: connect2, allowH2, clientTtl, socketPath };
|
|
12548
12548
|
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
|
12549
12549
|
this[kFactory] = factory;
|
|
12550
12550
|
this[kIndex] = -1;
|
|
@@ -12619,21 +12619,21 @@ var require_agent = __commonJS({
|
|
|
12619
12619
|
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
|
12620
12620
|
}
|
|
12621
12621
|
var Agent = class extends DispatcherBase {
|
|
12622
|
-
constructor({ factory = defaultFactory, maxOrigins = Infinity, connect, ...options } = {}) {
|
|
12622
|
+
constructor({ factory = defaultFactory, maxOrigins = Infinity, connect: connect2, ...options } = {}) {
|
|
12623
12623
|
if (typeof factory !== "function") {
|
|
12624
12624
|
throw new InvalidArgumentError2("factory must be a function.");
|
|
12625
12625
|
}
|
|
12626
|
-
if (
|
|
12626
|
+
if (connect2 != null && typeof connect2 !== "function" && typeof connect2 !== "object") {
|
|
12627
12627
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
12628
12628
|
}
|
|
12629
12629
|
if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) {
|
|
12630
12630
|
throw new InvalidArgumentError2("maxOrigins must be a number greater than 0");
|
|
12631
12631
|
}
|
|
12632
12632
|
super();
|
|
12633
|
-
if (
|
|
12634
|
-
|
|
12633
|
+
if (connect2 && typeof connect2 !== "function") {
|
|
12634
|
+
connect2 = { ...connect2 };
|
|
12635
12635
|
}
|
|
12636
|
-
this[kOptions] = { ...util.deepClone(options), maxOrigins, connect };
|
|
12636
|
+
this[kOptions] = { ...util.deepClone(options), maxOrigins, connect: connect2 };
|
|
12637
12637
|
this[kFactory] = factory;
|
|
12638
12638
|
this[kClients] = /* @__PURE__ */ new Map();
|
|
12639
12639
|
this[kOrigins] = /* @__PURE__ */ new Set();
|
|
@@ -13432,16 +13432,16 @@ var require_proxy_agent = __commonJS({
|
|
|
13432
13432
|
}
|
|
13433
13433
|
var Http1ProxyWrapper = class extends DispatcherBase {
|
|
13434
13434
|
#client;
|
|
13435
|
-
constructor(proxyUrl, { headers = {}, connect, factory }) {
|
|
13435
|
+
constructor(proxyUrl, { headers = {}, connect: connect2, factory }) {
|
|
13436
13436
|
if (!proxyUrl) {
|
|
13437
13437
|
throw new InvalidArgumentError2("Proxy URL is mandatory");
|
|
13438
13438
|
}
|
|
13439
13439
|
super();
|
|
13440
13440
|
this[kProxyHeaders] = headers;
|
|
13441
13441
|
if (factory) {
|
|
13442
|
-
this.#client = factory(proxyUrl, { connect });
|
|
13442
|
+
this.#client = factory(proxyUrl, { connect: connect2 });
|
|
13443
13443
|
} else {
|
|
13444
|
-
this.#client = new Client(proxyUrl, { connect });
|
|
13444
|
+
this.#client = new Client(proxyUrl, { connect: connect2 });
|
|
13445
13445
|
}
|
|
13446
13446
|
}
|
|
13447
13447
|
[kDispatch](opts, handler) {
|
|
@@ -13502,7 +13502,7 @@ var require_proxy_agent = __commonJS({
|
|
|
13502
13502
|
} else if (username && password) {
|
|
13503
13503
|
this[kProxyHeaders]["proxy-authorization"] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString("base64")}`;
|
|
13504
13504
|
}
|
|
13505
|
-
const
|
|
13505
|
+
const connect2 = buildConnector({ ...opts.proxyTls });
|
|
13506
13506
|
this[kConnectEndpoint] = buildConnector({ ...opts.requestTls });
|
|
13507
13507
|
const agentFactory = opts.factory || defaultAgentFactory;
|
|
13508
13508
|
const factory = (origin2, options) => {
|
|
@@ -13510,7 +13510,7 @@ var require_proxy_agent = __commonJS({
|
|
|
13510
13510
|
if (this[kProxy].protocol === "socks5:" || this[kProxy].protocol === "socks:") {
|
|
13511
13511
|
return new Socks5ProxyAgent(this[kProxy].uri, {
|
|
13512
13512
|
headers: this[kProxyHeaders],
|
|
13513
|
-
connect,
|
|
13513
|
+
connect: connect2,
|
|
13514
13514
|
factory: agentFactory,
|
|
13515
13515
|
username: opts.username || username,
|
|
13516
13516
|
password: opts.password || password,
|
|
@@ -13520,7 +13520,7 @@ var require_proxy_agent = __commonJS({
|
|
|
13520
13520
|
if (!this[kTunnelProxy] && protocol2 === "http:" && this[kProxy].protocol === "http:") {
|
|
13521
13521
|
return new Http1ProxyWrapper(this[kProxy].uri, {
|
|
13522
13522
|
headers: this[kProxyHeaders],
|
|
13523
|
-
connect,
|
|
13523
|
+
connect: connect2,
|
|
13524
13524
|
factory: agentFactory
|
|
13525
13525
|
});
|
|
13526
13526
|
}
|
|
@@ -13529,7 +13529,7 @@ var require_proxy_agent = __commonJS({
|
|
|
13529
13529
|
if (protocol === "socks5:" || protocol === "socks:") {
|
|
13530
13530
|
this[kClient] = null;
|
|
13531
13531
|
} else {
|
|
13532
|
-
this[kClient] = clientFactory(url, { connect });
|
|
13532
|
+
this[kClient] = clientFactory(url, { connect: connect2 });
|
|
13533
13533
|
}
|
|
13534
13534
|
this[kAgent] = new Agent({
|
|
13535
13535
|
...opts,
|
|
@@ -14139,7 +14139,7 @@ var require_h2c_client = __commonJS({
|
|
|
14139
14139
|
"h2c-client: Only h2c protocol is supported"
|
|
14140
14140
|
);
|
|
14141
14141
|
}
|
|
14142
|
-
const { connect, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
|
|
14142
|
+
const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {};
|
|
14143
14143
|
let defaultMaxConcurrentStreams = 100;
|
|
14144
14144
|
let defaultPipelining = 100;
|
|
14145
14145
|
if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) {
|
|
@@ -15328,10 +15328,10 @@ var require_api_connect = __commonJS({
|
|
|
15328
15328
|
}
|
|
15329
15329
|
}
|
|
15330
15330
|
};
|
|
15331
|
-
function
|
|
15331
|
+
function connect2(opts, callback) {
|
|
15332
15332
|
if (callback === void 0) {
|
|
15333
15333
|
return new Promise((resolve2, reject) => {
|
|
15334
|
-
|
|
15334
|
+
connect2.call(this, opts, (err, data) => {
|
|
15335
15335
|
return err ? reject(err) : resolve2(data);
|
|
15336
15336
|
});
|
|
15337
15337
|
});
|
|
@@ -15348,7 +15348,7 @@ var require_api_connect = __commonJS({
|
|
|
15348
15348
|
queueMicrotask(() => callback(err, { opaque }));
|
|
15349
15349
|
}
|
|
15350
15350
|
}
|
|
15351
|
-
module.exports =
|
|
15351
|
+
module.exports = connect2;
|
|
15352
15352
|
}
|
|
15353
15353
|
});
|
|
15354
15354
|
|
|
@@ -16617,8 +16617,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
16617
16617
|
"../../node_modules/.pnpm/undici@7.24.8/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
16618
16618
|
"use strict";
|
|
16619
16619
|
init_esm_shims();
|
|
16620
|
-
var { writeFile: writeFile12, readFile: readFile15, mkdir:
|
|
16621
|
-
var { dirname:
|
|
16620
|
+
var { writeFile: writeFile12, readFile: readFile15, mkdir: mkdir16 } = __require("fs/promises");
|
|
16621
|
+
var { dirname: dirname14, resolve: resolve2 } = __require("path");
|
|
16622
16622
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("timers");
|
|
16623
16623
|
var { InvalidArgumentError: InvalidArgumentError2, UndiciError } = require_errors();
|
|
16624
16624
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -16849,7 +16849,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
16849
16849
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
16850
16850
|
}
|
|
16851
16851
|
const resolvedPath = resolve2(path3);
|
|
16852
|
-
await
|
|
16852
|
+
await mkdir16(dirname14(resolvedPath), { recursive: true });
|
|
16853
16853
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
16854
16854
|
hash,
|
|
16855
16855
|
snapshot
|
|
@@ -29193,11 +29193,11 @@ var require_mtime_precision = __commonJS({
|
|
|
29193
29193
|
function probe(file, fs, callback) {
|
|
29194
29194
|
const cachedPrecision = fs[cacheSymbol];
|
|
29195
29195
|
if (cachedPrecision) {
|
|
29196
|
-
return fs.stat(file, (err,
|
|
29196
|
+
return fs.stat(file, (err, stat5) => {
|
|
29197
29197
|
if (err) {
|
|
29198
29198
|
return callback(err);
|
|
29199
29199
|
}
|
|
29200
|
-
callback(null,
|
|
29200
|
+
callback(null, stat5.mtime, cachedPrecision);
|
|
29201
29201
|
});
|
|
29202
29202
|
}
|
|
29203
29203
|
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
@@ -29205,13 +29205,13 @@ var require_mtime_precision = __commonJS({
|
|
|
29205
29205
|
if (err) {
|
|
29206
29206
|
return callback(err);
|
|
29207
29207
|
}
|
|
29208
|
-
fs.stat(file, (err2,
|
|
29208
|
+
fs.stat(file, (err2, stat5) => {
|
|
29209
29209
|
if (err2) {
|
|
29210
29210
|
return callback(err2);
|
|
29211
29211
|
}
|
|
29212
|
-
const precision =
|
|
29212
|
+
const precision = stat5.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
29213
29213
|
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
29214
|
-
callback(null,
|
|
29214
|
+
callback(null, stat5.mtime, precision);
|
|
29215
29215
|
});
|
|
29216
29216
|
});
|
|
29217
29217
|
}
|
|
@@ -29266,14 +29266,14 @@ var require_lockfile = __commonJS({
|
|
|
29266
29266
|
if (options.stale <= 0) {
|
|
29267
29267
|
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
29268
29268
|
}
|
|
29269
|
-
options.fs.stat(lockfilePath, (err2,
|
|
29269
|
+
options.fs.stat(lockfilePath, (err2, stat5) => {
|
|
29270
29270
|
if (err2) {
|
|
29271
29271
|
if (err2.code === "ENOENT") {
|
|
29272
29272
|
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
29273
29273
|
}
|
|
29274
29274
|
return callback(err2);
|
|
29275
29275
|
}
|
|
29276
|
-
if (!isLockStale(
|
|
29276
|
+
if (!isLockStale(stat5, options)) {
|
|
29277
29277
|
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
29278
29278
|
}
|
|
29279
29279
|
removeLock(file, options, (err3) => {
|
|
@@ -29285,8 +29285,8 @@ var require_lockfile = __commonJS({
|
|
|
29285
29285
|
});
|
|
29286
29286
|
});
|
|
29287
29287
|
}
|
|
29288
|
-
function isLockStale(
|
|
29289
|
-
return
|
|
29288
|
+
function isLockStale(stat5, options) {
|
|
29289
|
+
return stat5.mtime.getTime() < Date.now() - options.stale;
|
|
29290
29290
|
}
|
|
29291
29291
|
function removeLock(file, options, callback) {
|
|
29292
29292
|
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
@@ -29304,7 +29304,7 @@ var require_lockfile = __commonJS({
|
|
|
29304
29304
|
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
29305
29305
|
lock2.updateTimeout = setTimeout(() => {
|
|
29306
29306
|
lock2.updateTimeout = null;
|
|
29307
|
-
options.fs.stat(lock2.lockfilePath, (err,
|
|
29307
|
+
options.fs.stat(lock2.lockfilePath, (err, stat5) => {
|
|
29308
29308
|
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
29309
29309
|
if (err) {
|
|
29310
29310
|
if (err.code === "ENOENT" || isOverThreshold) {
|
|
@@ -29313,7 +29313,7 @@ var require_lockfile = __commonJS({
|
|
|
29313
29313
|
lock2.updateDelay = 1e3;
|
|
29314
29314
|
return updateLock(file, options);
|
|
29315
29315
|
}
|
|
29316
|
-
const isMtimeOurs = lock2.mtime.getTime() ===
|
|
29316
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat5.mtime.getTime();
|
|
29317
29317
|
if (!isMtimeOurs) {
|
|
29318
29318
|
return setLockAsCompromised(
|
|
29319
29319
|
file,
|
|
@@ -29438,11 +29438,11 @@ var require_lockfile = __commonJS({
|
|
|
29438
29438
|
if (err) {
|
|
29439
29439
|
return callback(err);
|
|
29440
29440
|
}
|
|
29441
|
-
options.fs.stat(getLockFile(file2, options), (err2,
|
|
29441
|
+
options.fs.stat(getLockFile(file2, options), (err2, stat5) => {
|
|
29442
29442
|
if (err2) {
|
|
29443
29443
|
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
29444
29444
|
}
|
|
29445
|
-
return callback(null, !isLockStale(
|
|
29445
|
+
return callback(null, !isLockStale(stat5, options));
|
|
29446
29446
|
});
|
|
29447
29447
|
});
|
|
29448
29448
|
}
|
|
@@ -30011,6 +30011,13 @@ function servicePidReadFallback(slockHome) {
|
|
|
30011
30011
|
function serviceLogPath(slockHome) {
|
|
30012
30012
|
return path2.join(serviceRunDir(slockHome), "service.log");
|
|
30013
30013
|
}
|
|
30014
|
+
function serviceSocketPath(slockHome) {
|
|
30015
|
+
return path2.join(computerDir(slockHome), "run", "service.sock");
|
|
30016
|
+
}
|
|
30017
|
+
function serviceWindowsPipeName(slockHome) {
|
|
30018
|
+
const hash = createHash("sha256").update(computerDir(slockHome)).digest("hex").slice(0, 16);
|
|
30019
|
+
return `\\\\.\\pipe\\slock-computer-${hash}`;
|
|
30020
|
+
}
|
|
30014
30021
|
function serviceVersionPath(slockHome) {
|
|
30015
30022
|
return path2.join(computerDir(slockHome), "service-version.json");
|
|
30016
30023
|
}
|
|
@@ -30505,8 +30512,8 @@ async function runAttach(opts) {
|
|
|
30505
30512
|
// src/setup.ts
|
|
30506
30513
|
init_esm_shims();
|
|
30507
30514
|
var import_undici3 = __toESM(require_undici(), 1);
|
|
30508
|
-
import { chmod as
|
|
30509
|
-
import { dirname as
|
|
30515
|
+
import { chmod as chmod6, mkdir as mkdir12, readFile as readFile11, rename as rename4, rm as rm3, writeFile as writeFile10 } from "fs/promises";
|
|
30516
|
+
import { dirname as dirname11 } from "path";
|
|
30510
30517
|
|
|
30511
30518
|
// src/lib/migration.ts
|
|
30512
30519
|
init_esm_shims();
|
|
@@ -31032,8 +31039,8 @@ function readComputerVersion(moduleUrl = import.meta.url) {
|
|
|
31032
31039
|
var COMPUTER_VERSION = readComputerVersion();
|
|
31033
31040
|
|
|
31034
31041
|
// src/service.ts
|
|
31035
|
-
import { mkdir as
|
|
31036
|
-
import { dirname as
|
|
31042
|
+
import { mkdir as mkdir11, readFile as readFile10, writeFile as writeFile9, open, rename as rename3 } from "fs/promises";
|
|
31043
|
+
import { dirname as dirname10, join as joinPath } from "path";
|
|
31037
31044
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
31038
31045
|
|
|
31039
31046
|
// src/cleanup.ts
|
|
@@ -32081,6 +32088,493 @@ async function resolveAndRunSeaUpgrade(opts) {
|
|
|
32081
32088
|
return { ...result, targetVersion };
|
|
32082
32089
|
}
|
|
32083
32090
|
|
|
32091
|
+
// src/internal/ipc-server.ts
|
|
32092
|
+
init_esm_shims();
|
|
32093
|
+
import { connect, createServer } from "net";
|
|
32094
|
+
import { chmod as chmod5, mkdir as mkdir10, stat as stat4, unlink as unlink5 } from "fs/promises";
|
|
32095
|
+
import { dirname as dirname9 } from "path";
|
|
32096
|
+
|
|
32097
|
+
// src/internal/ipc-codec.ts
|
|
32098
|
+
init_esm_shims();
|
|
32099
|
+
|
|
32100
|
+
// src/lib/types.ts
|
|
32101
|
+
init_esm_shims();
|
|
32102
|
+
var ServiceClientError = class extends Error {
|
|
32103
|
+
code;
|
|
32104
|
+
cause;
|
|
32105
|
+
constructor(code, message, cause) {
|
|
32106
|
+
super(message);
|
|
32107
|
+
this.name = "ServiceClientError";
|
|
32108
|
+
this.code = code;
|
|
32109
|
+
if (cause !== void 0) this.cause = cause;
|
|
32110
|
+
}
|
|
32111
|
+
};
|
|
32112
|
+
var StateReaderError = class extends Error {
|
|
32113
|
+
code;
|
|
32114
|
+
constructor(code, message) {
|
|
32115
|
+
super(message);
|
|
32116
|
+
this.name = "StateReaderError";
|
|
32117
|
+
this.code = code;
|
|
32118
|
+
}
|
|
32119
|
+
};
|
|
32120
|
+
|
|
32121
|
+
// src/internal/ipc-codec.ts
|
|
32122
|
+
var MAX_FRAME_BYTES = 1024 * 1024;
|
|
32123
|
+
function encodeFrame(payload) {
|
|
32124
|
+
const json = Buffer.from(JSON.stringify(payload), "utf8");
|
|
32125
|
+
if (json.length > MAX_FRAME_BYTES) {
|
|
32126
|
+
throw new ServiceClientError(
|
|
32127
|
+
"IPC_FRAME_TOO_LARGE",
|
|
32128
|
+
`outgoing frame ${json.length} bytes exceeds MAX_FRAME_BYTES ${MAX_FRAME_BYTES}`
|
|
32129
|
+
);
|
|
32130
|
+
}
|
|
32131
|
+
const header = Buffer.alloc(4);
|
|
32132
|
+
header.writeUInt32BE(json.length, 0);
|
|
32133
|
+
return Buffer.concat([header, json]);
|
|
32134
|
+
}
|
|
32135
|
+
var FrameDecoder = class {
|
|
32136
|
+
buffer = Buffer.alloc(0);
|
|
32137
|
+
push(chunk) {
|
|
32138
|
+
this.buffer = this.buffer.length === 0 ? chunk : Buffer.concat([this.buffer, chunk]);
|
|
32139
|
+
}
|
|
32140
|
+
drain() {
|
|
32141
|
+
const frames = [];
|
|
32142
|
+
while (this.buffer.length >= 4) {
|
|
32143
|
+
const length = this.buffer.readUInt32BE(0);
|
|
32144
|
+
if (length > MAX_FRAME_BYTES) {
|
|
32145
|
+
throw new ServiceClientError(
|
|
32146
|
+
"IPC_FRAME_TOO_LARGE",
|
|
32147
|
+
`incoming frame ${length} bytes exceeds MAX_FRAME_BYTES ${MAX_FRAME_BYTES}`
|
|
32148
|
+
);
|
|
32149
|
+
}
|
|
32150
|
+
if (this.buffer.length < 4 + length) break;
|
|
32151
|
+
const body = this.buffer.subarray(4, 4 + length);
|
|
32152
|
+
this.buffer = this.buffer.subarray(4 + length);
|
|
32153
|
+
let parsed;
|
|
32154
|
+
try {
|
|
32155
|
+
parsed = JSON.parse(body.toString("utf8"));
|
|
32156
|
+
} catch (cause) {
|
|
32157
|
+
throw new ServiceClientError("IPC_MALFORMED_FRAME", "frame body is not valid UTF-8 JSON", cause);
|
|
32158
|
+
}
|
|
32159
|
+
frames.push(parsed);
|
|
32160
|
+
}
|
|
32161
|
+
return frames;
|
|
32162
|
+
}
|
|
32163
|
+
};
|
|
32164
|
+
|
|
32165
|
+
// src/internal/ipc-server.ts
|
|
32166
|
+
var SUPPORTED_PROTOCOL_VERSIONS = [1];
|
|
32167
|
+
var SERVICE_VERSION = "0.0.0";
|
|
32168
|
+
function resolveTransportPath(installRoot) {
|
|
32169
|
+
return process.platform === "win32" ? serviceWindowsPipeName(installRoot) : serviceSocketPath(installRoot);
|
|
32170
|
+
}
|
|
32171
|
+
async function probeAndClearStaleSocket(socketPath) {
|
|
32172
|
+
if (process.platform === "win32") return;
|
|
32173
|
+
let isSocket = false;
|
|
32174
|
+
try {
|
|
32175
|
+
const stats = await stat4(socketPath);
|
|
32176
|
+
isSocket = stats.isSocket();
|
|
32177
|
+
} catch (err) {
|
|
32178
|
+
if (isErrnoException(err) && err.code === "ENOENT") return;
|
|
32179
|
+
return;
|
|
32180
|
+
}
|
|
32181
|
+
if (!isSocket) {
|
|
32182
|
+
return;
|
|
32183
|
+
}
|
|
32184
|
+
const outcome = await new Promise((resolve2) => {
|
|
32185
|
+
const probe = connect({ path: socketPath });
|
|
32186
|
+
const finalize = (o) => {
|
|
32187
|
+
probe.removeAllListeners();
|
|
32188
|
+
probe.destroy();
|
|
32189
|
+
resolve2(o);
|
|
32190
|
+
};
|
|
32191
|
+
const timer = setTimeout(() => finalize("indeterminate"), 500);
|
|
32192
|
+
probe.once("connect", () => {
|
|
32193
|
+
clearTimeout(timer);
|
|
32194
|
+
finalize("connected");
|
|
32195
|
+
});
|
|
32196
|
+
probe.once("error", (err) => {
|
|
32197
|
+
clearTimeout(timer);
|
|
32198
|
+
finalize(err.code === "ECONNREFUSED" ? "refused" : "indeterminate");
|
|
32199
|
+
});
|
|
32200
|
+
});
|
|
32201
|
+
if (outcome !== "refused") {
|
|
32202
|
+
return;
|
|
32203
|
+
}
|
|
32204
|
+
try {
|
|
32205
|
+
await unlink5(socketPath);
|
|
32206
|
+
} catch (err) {
|
|
32207
|
+
if (isErrnoException(err) && err.code === "ENOENT") return;
|
|
32208
|
+
throw err;
|
|
32209
|
+
}
|
|
32210
|
+
}
|
|
32211
|
+
function createIpcServer(options) {
|
|
32212
|
+
const { installRoot, handlers } = options;
|
|
32213
|
+
const transportPath = resolveTransportPath(installRoot);
|
|
32214
|
+
const connections = /* @__PURE__ */ new Set();
|
|
32215
|
+
let server = null;
|
|
32216
|
+
let closed = false;
|
|
32217
|
+
function dispatchFrame(conn, frame) {
|
|
32218
|
+
if (!isRecord(frame) || typeof frame.type !== "string") {
|
|
32219
|
+
writeError(conn, null, "IPC_MALFORMED_FRAME", "frame is missing required `type` field");
|
|
32220
|
+
conn.socket.destroy();
|
|
32221
|
+
return;
|
|
32222
|
+
}
|
|
32223
|
+
if (!conn.handshakeDone) {
|
|
32224
|
+
handleHello(conn, frame);
|
|
32225
|
+
return;
|
|
32226
|
+
}
|
|
32227
|
+
if (frame.type === "request") {
|
|
32228
|
+
void handleRequest(conn, frame);
|
|
32229
|
+
return;
|
|
32230
|
+
}
|
|
32231
|
+
if (frame.type === "ping") {
|
|
32232
|
+
conn.socket.write(encodeFrame({ type: "pong" }));
|
|
32233
|
+
return;
|
|
32234
|
+
}
|
|
32235
|
+
if (frame.type === "pong") {
|
|
32236
|
+
return;
|
|
32237
|
+
}
|
|
32238
|
+
}
|
|
32239
|
+
function handleHello(conn, frame) {
|
|
32240
|
+
if (frame.type !== "hello") {
|
|
32241
|
+
conn.socket.write(encodeFrame({
|
|
32242
|
+
type: "hello-reject",
|
|
32243
|
+
reason: "IPC_PROTOCOL_HANDSHAKE_FAILED",
|
|
32244
|
+
message: `expected hello, got \`${String(frame.type)}\``
|
|
32245
|
+
}));
|
|
32246
|
+
conn.socket.destroy();
|
|
32247
|
+
return;
|
|
32248
|
+
}
|
|
32249
|
+
const requested = Number(frame.protocolVersion);
|
|
32250
|
+
if (!SUPPORTED_PROTOCOL_VERSIONS.includes(requested)) {
|
|
32251
|
+
conn.socket.write(encodeFrame({
|
|
32252
|
+
type: "hello-reject",
|
|
32253
|
+
reason: "IPC_PROTOCOL_VERSION_UNSUPPORTED",
|
|
32254
|
+
supported: [...SUPPORTED_PROTOCOL_VERSIONS]
|
|
32255
|
+
}));
|
|
32256
|
+
conn.socket.destroy();
|
|
32257
|
+
return;
|
|
32258
|
+
}
|
|
32259
|
+
conn.handshakeDone = true;
|
|
32260
|
+
conn.socket.write(encodeFrame({
|
|
32261
|
+
type: "hello-ack",
|
|
32262
|
+
protocolVersion: requested,
|
|
32263
|
+
serviceVersion: SERVICE_VERSION
|
|
32264
|
+
}));
|
|
32265
|
+
}
|
|
32266
|
+
async function handleRequest(conn, frame) {
|
|
32267
|
+
const id = typeof frame.id === "string" ? frame.id : "";
|
|
32268
|
+
const method = typeof frame.method === "string" ? frame.method : "";
|
|
32269
|
+
if (id === "" || method === "") {
|
|
32270
|
+
writeError(conn, id || null, "IPC_MALFORMED_FRAME", "request missing `id` or `method`");
|
|
32271
|
+
return;
|
|
32272
|
+
}
|
|
32273
|
+
const handler = handlers[method];
|
|
32274
|
+
if (!handler) {
|
|
32275
|
+
writeError(conn, id, "IPC_MALFORMED_FRAME", `unknown method \`${method}\``);
|
|
32276
|
+
return;
|
|
32277
|
+
}
|
|
32278
|
+
try {
|
|
32279
|
+
const result = await handler(
|
|
32280
|
+
frame.params
|
|
32281
|
+
);
|
|
32282
|
+
if (conn.socket.destroyed) return;
|
|
32283
|
+
conn.socket.write(encodeFrame({ type: "response", id, result }));
|
|
32284
|
+
} catch (error) {
|
|
32285
|
+
if (conn.socket.destroyed) return;
|
|
32286
|
+
const { code, message } = normalizeHandlerError(error);
|
|
32287
|
+
writeError(conn, id, code, message);
|
|
32288
|
+
}
|
|
32289
|
+
}
|
|
32290
|
+
function writeError(conn, id, code, message) {
|
|
32291
|
+
if (conn.socket.destroyed) return;
|
|
32292
|
+
try {
|
|
32293
|
+
conn.socket.write(encodeFrame({
|
|
32294
|
+
type: "response",
|
|
32295
|
+
id: id ?? "",
|
|
32296
|
+
error: { code, message }
|
|
32297
|
+
}));
|
|
32298
|
+
} catch {
|
|
32299
|
+
}
|
|
32300
|
+
}
|
|
32301
|
+
function attachConnection(socket) {
|
|
32302
|
+
if (closed) {
|
|
32303
|
+
socket.destroy();
|
|
32304
|
+
return;
|
|
32305
|
+
}
|
|
32306
|
+
const conn = {
|
|
32307
|
+
socket,
|
|
32308
|
+
decoder: new FrameDecoder(),
|
|
32309
|
+
handshakeDone: false
|
|
32310
|
+
};
|
|
32311
|
+
connections.add(conn);
|
|
32312
|
+
socket.on("data", (chunk) => {
|
|
32313
|
+
try {
|
|
32314
|
+
conn.decoder.push(chunk);
|
|
32315
|
+
const frames = conn.decoder.drain();
|
|
32316
|
+
for (const frame of frames) dispatchFrame(conn, frame);
|
|
32317
|
+
} catch (error) {
|
|
32318
|
+
const { code, message } = normalizeHandlerError(error);
|
|
32319
|
+
writeError(conn, null, code, message);
|
|
32320
|
+
socket.destroy();
|
|
32321
|
+
}
|
|
32322
|
+
});
|
|
32323
|
+
socket.on("close", () => connections.delete(conn));
|
|
32324
|
+
socket.on("error", () => {
|
|
32325
|
+
});
|
|
32326
|
+
}
|
|
32327
|
+
return {
|
|
32328
|
+
async listen() {
|
|
32329
|
+
if (server) throw new Error("ipc-server: listen() called twice");
|
|
32330
|
+
if (process.platform !== "win32") {
|
|
32331
|
+
await mkdir10(dirname9(transportPath), { recursive: true });
|
|
32332
|
+
await probeAndClearStaleSocket(transportPath);
|
|
32333
|
+
}
|
|
32334
|
+
const s = createServer(attachConnection);
|
|
32335
|
+
server = s;
|
|
32336
|
+
await new Promise((resolve2, reject) => {
|
|
32337
|
+
const onError = (err) => {
|
|
32338
|
+
s.removeListener("error", onError);
|
|
32339
|
+
reject(err);
|
|
32340
|
+
};
|
|
32341
|
+
s.once("error", onError);
|
|
32342
|
+
s.listen(transportPath, () => {
|
|
32343
|
+
s.removeListener("error", onError);
|
|
32344
|
+
resolve2();
|
|
32345
|
+
});
|
|
32346
|
+
});
|
|
32347
|
+
if (process.platform !== "win32") {
|
|
32348
|
+
try {
|
|
32349
|
+
await chmod5(transportPath, 384);
|
|
32350
|
+
} catch {
|
|
32351
|
+
}
|
|
32352
|
+
}
|
|
32353
|
+
return transportPath;
|
|
32354
|
+
},
|
|
32355
|
+
broadcast(event) {
|
|
32356
|
+
if (closed) return;
|
|
32357
|
+
const payload = encodeFrame({ type: "event", kind: event.kind, payload: event.payload });
|
|
32358
|
+
for (const conn of connections) {
|
|
32359
|
+
if (!conn.handshakeDone || conn.socket.destroyed) continue;
|
|
32360
|
+
try {
|
|
32361
|
+
conn.socket.write(payload);
|
|
32362
|
+
} catch {
|
|
32363
|
+
}
|
|
32364
|
+
}
|
|
32365
|
+
},
|
|
32366
|
+
async close() {
|
|
32367
|
+
if (closed) return;
|
|
32368
|
+
closed = true;
|
|
32369
|
+
const s = server;
|
|
32370
|
+
server = null;
|
|
32371
|
+
for (const conn of connections) conn.socket.destroy();
|
|
32372
|
+
connections.clear();
|
|
32373
|
+
if (s) {
|
|
32374
|
+
await new Promise((resolve2) => {
|
|
32375
|
+
s.close(() => resolve2());
|
|
32376
|
+
});
|
|
32377
|
+
}
|
|
32378
|
+
}
|
|
32379
|
+
};
|
|
32380
|
+
}
|
|
32381
|
+
function normalizeHandlerError(error) {
|
|
32382
|
+
if (error instanceof ServiceClientError) {
|
|
32383
|
+
return { code: error.code, message: error.message };
|
|
32384
|
+
}
|
|
32385
|
+
const message = error instanceof Error ? error.message : "handler threw non-Error value";
|
|
32386
|
+
return { code: "IPC_MALFORMED_FRAME", message };
|
|
32387
|
+
}
|
|
32388
|
+
function isRecord(value) {
|
|
32389
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32390
|
+
}
|
|
32391
|
+
function isErrnoException(value) {
|
|
32392
|
+
return value instanceof Error && typeof value.code === "string";
|
|
32393
|
+
}
|
|
32394
|
+
|
|
32395
|
+
// src/lib/readers.ts
|
|
32396
|
+
init_esm_shims();
|
|
32397
|
+
|
|
32398
|
+
// src/status.ts
|
|
32399
|
+
init_esm_shims();
|
|
32400
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
32401
|
+
async function readUserSession(path3) {
|
|
32402
|
+
try {
|
|
32403
|
+
const parsed = JSON.parse(await readFile9(path3, "utf8"));
|
|
32404
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
32405
|
+
return { state: "present", session: parsed, error: null };
|
|
32406
|
+
}
|
|
32407
|
+
return { state: "invalid", session: null, error: "not a JSON object" };
|
|
32408
|
+
} catch (err) {
|
|
32409
|
+
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
|
|
32410
|
+
return { state: "missing", session: null, error: null };
|
|
32411
|
+
}
|
|
32412
|
+
return {
|
|
32413
|
+
state: "invalid",
|
|
32414
|
+
session: null,
|
|
32415
|
+
error: err instanceof Error ? err.message : String(err)
|
|
32416
|
+
};
|
|
32417
|
+
}
|
|
32418
|
+
}
|
|
32419
|
+
function str(v) {
|
|
32420
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
32421
|
+
}
|
|
32422
|
+
async function pidStatus(pidfile) {
|
|
32423
|
+
const pid = await readPidfileAt(pidfile);
|
|
32424
|
+
return pid !== null && isProcessAlive2(pid) ? { running: true, pid } : { running: false };
|
|
32425
|
+
}
|
|
32426
|
+
async function serviceState(slockHome) {
|
|
32427
|
+
const { pid } = await findLiveServicePidReadOnly(slockHome);
|
|
32428
|
+
return pid !== null ? { running: true, pid } : { running: false };
|
|
32429
|
+
}
|
|
32430
|
+
async function deriveHealth(slockHome, serverId, daemon) {
|
|
32431
|
+
if (!daemon.running) return "offline";
|
|
32432
|
+
if (await isDegraded(slockHome, serverId)) return "degraded";
|
|
32433
|
+
return "ok";
|
|
32434
|
+
}
|
|
32435
|
+
async function buildStatusReport(installRoot) {
|
|
32436
|
+
const sessionRead = await readUserSession(userSessionPath(installRoot));
|
|
32437
|
+
const session = sessionRead.session;
|
|
32438
|
+
const attachments = await listServerAttachments(installRoot);
|
|
32439
|
+
const service = {
|
|
32440
|
+
...await serviceState(installRoot),
|
|
32441
|
+
logPath: serviceLogPath(installRoot)
|
|
32442
|
+
};
|
|
32443
|
+
const servers = [];
|
|
32444
|
+
for (const a of attachments) {
|
|
32445
|
+
const daemon = await pidStatus(serverRunnerPidPath(installRoot, a.serverId));
|
|
32446
|
+
servers.push({
|
|
32447
|
+
serverId: a.serverId,
|
|
32448
|
+
serverSlug: a.serverSlug ?? null,
|
|
32449
|
+
serverMachineId: a.serverMachineId,
|
|
32450
|
+
serverUrl: a.serverUrl,
|
|
32451
|
+
attachedAt: a.attachedAt ?? null,
|
|
32452
|
+
serverRunnerLogPath: serverRunnerLogPath(installRoot, a.serverId),
|
|
32453
|
+
daemon,
|
|
32454
|
+
health: await deriveHealth(installRoot, a.serverId, daemon)
|
|
32455
|
+
});
|
|
32456
|
+
}
|
|
32457
|
+
const loggedIn = session?.kind === "user-session" && typeof session.accessToken === "string" && session.accessToken.length > 0;
|
|
32458
|
+
return {
|
|
32459
|
+
slockHome: installRoot,
|
|
32460
|
+
loggedIn,
|
|
32461
|
+
userId: session ? str(session.userId) : null,
|
|
32462
|
+
loginServerUrl: session ? str(session.serverUrl) : null,
|
|
32463
|
+
userSessionError: sessionRead.state === "invalid" ? sessionRead.error : null,
|
|
32464
|
+
service,
|
|
32465
|
+
servers
|
|
32466
|
+
};
|
|
32467
|
+
}
|
|
32468
|
+
function pad(s, n) {
|
|
32469
|
+
return s.length >= n ? s : s + " ".repeat(n - s.length);
|
|
32470
|
+
}
|
|
32471
|
+
async function runStatus(opts) {
|
|
32472
|
+
const report = await buildStatusReport(resolveSlockHome());
|
|
32473
|
+
if (opts.json) {
|
|
32474
|
+
info(JSON.stringify(report, null, 2));
|
|
32475
|
+
return;
|
|
32476
|
+
}
|
|
32477
|
+
info("");
|
|
32478
|
+
info(`SLOCK_HOME: ${report.slockHome}`);
|
|
32479
|
+
const loginDetail = report.userSessionError ? "no \u2014 user session file is invalid; re-run `slock-computer login`" : report.loggedIn ? `yes (user ${report.userId ?? "?"})` : "no \u2014 run `slock-computer login`";
|
|
32480
|
+
info(
|
|
32481
|
+
`Logged in: ${loginDetail}`
|
|
32482
|
+
);
|
|
32483
|
+
if (report.loginServerUrl) info(`Login server: ${report.loginServerUrl}`);
|
|
32484
|
+
info(
|
|
32485
|
+
`Service: ${report.service.running ? `running (pid ${report.service.pid})` : "stopped \u2014 run `slock-computer start`"}`
|
|
32486
|
+
);
|
|
32487
|
+
info(`Service log: ${report.service.logPath}`);
|
|
32488
|
+
info("");
|
|
32489
|
+
if (report.servers.length === 0) {
|
|
32490
|
+
info("Attachments: none \u2014 run `slock-computer attach /<serverSlug>` (e.g. `/myserver`).");
|
|
32491
|
+
} else {
|
|
32492
|
+
info("Attachments:");
|
|
32493
|
+
info(` ${pad("SERVER", 24)}${pad("HEALTH", 12)}${pad("DAEMON", 24)}${pad("MACHINE", 38)}URL`);
|
|
32494
|
+
for (const s of report.servers) {
|
|
32495
|
+
const dcol = s.daemon.running ? `running (pid ${s.daemon.pid})` : "stopped";
|
|
32496
|
+
info(
|
|
32497
|
+
` ${pad(formatServerSlugDisplay(s.serverSlug), 24)}${pad(s.health, 12)}${pad(dcol, 24)}${pad(s.serverMachineId, 38)}${s.serverUrl}`
|
|
32498
|
+
);
|
|
32499
|
+
info(` Server runner log: ${s.serverRunnerLogPath}`);
|
|
32500
|
+
}
|
|
32501
|
+
if (report.servers.some((s) => s.health === "degraded")) {
|
|
32502
|
+
info("");
|
|
32503
|
+
info(
|
|
32504
|
+
" Note: one or more servers are `degraded` (repeated crashes; auto-restart paused)."
|
|
32505
|
+
);
|
|
32506
|
+
info(
|
|
32507
|
+
" Run `slock-computer doctor /<serverSlug> --reset-health` (e.g. `/myserver`) after fixing the underlying issue."
|
|
32508
|
+
);
|
|
32509
|
+
}
|
|
32510
|
+
}
|
|
32511
|
+
info("");
|
|
32512
|
+
}
|
|
32513
|
+
|
|
32514
|
+
// src/lib/readers.ts
|
|
32515
|
+
async function readServiceStatus(installRoot) {
|
|
32516
|
+
return buildStatusReport(installRoot);
|
|
32517
|
+
}
|
|
32518
|
+
async function readRunnerStatus(installRoot, serverId) {
|
|
32519
|
+
const report = await buildStatusReport(installRoot);
|
|
32520
|
+
const server = report.servers.find((s) => s.serverId === serverId);
|
|
32521
|
+
if (!server) {
|
|
32522
|
+
throw new StateReaderError(
|
|
32523
|
+
"NOT_ATTACHED",
|
|
32524
|
+
`Server ${serverId} is not attached to this Computer.`
|
|
32525
|
+
);
|
|
32526
|
+
}
|
|
32527
|
+
const attachment = await readServerAttachment(installRoot, serverId);
|
|
32528
|
+
if (!attachment) {
|
|
32529
|
+
throw new StateReaderError(
|
|
32530
|
+
"INVALID_ATTACHMENT",
|
|
32531
|
+
`Attachment for server ${serverId} is missing or invalid.`
|
|
32532
|
+
);
|
|
32533
|
+
}
|
|
32534
|
+
const client = new RunnersClient(attachment.serverUrl, attachment.apiKey);
|
|
32535
|
+
const result = await client.list();
|
|
32536
|
+
if (result.status === "success") {
|
|
32537
|
+
return { status: "ok", server, whitelist: result.whitelist, runners: result.runners };
|
|
32538
|
+
}
|
|
32539
|
+
if (result.status === "unauthorized") {
|
|
32540
|
+
return { status: "unauthorized", server };
|
|
32541
|
+
}
|
|
32542
|
+
return { status: "error", server, code: result.code };
|
|
32543
|
+
}
|
|
32544
|
+
async function listRunners(installRoot, opts = {}) {
|
|
32545
|
+
const all = await listServerAttachments(installRoot);
|
|
32546
|
+
let subset = all;
|
|
32547
|
+
if (opts.serverId !== void 0) {
|
|
32548
|
+
const found = all.find((a) => a.serverId === opts.serverId);
|
|
32549
|
+
if (!found) {
|
|
32550
|
+
throw new StateReaderError(
|
|
32551
|
+
"NOT_ATTACHED",
|
|
32552
|
+
`Server ${opts.serverId} is not attached to this Computer.`
|
|
32553
|
+
);
|
|
32554
|
+
}
|
|
32555
|
+
subset = [found];
|
|
32556
|
+
}
|
|
32557
|
+
const servers = [];
|
|
32558
|
+
for (const a of subset) {
|
|
32559
|
+
const client = new RunnersClient(a.serverUrl, a.apiKey);
|
|
32560
|
+
const result = await client.list();
|
|
32561
|
+
const idCols = { serverId: a.serverId, serverSlug: a.serverSlug ?? null };
|
|
32562
|
+
if (result.status === "success") {
|
|
32563
|
+
servers.push({
|
|
32564
|
+
...idCols,
|
|
32565
|
+
status: "ok",
|
|
32566
|
+
whitelist: result.whitelist,
|
|
32567
|
+
runners: result.runners
|
|
32568
|
+
});
|
|
32569
|
+
} else if (result.status === "unauthorized") {
|
|
32570
|
+
servers.push({ ...idCols, status: "unauthorized" });
|
|
32571
|
+
} else {
|
|
32572
|
+
servers.push({ ...idCols, status: "error", code: result.code });
|
|
32573
|
+
}
|
|
32574
|
+
}
|
|
32575
|
+
return { servers };
|
|
32576
|
+
}
|
|
32577
|
+
|
|
32084
32578
|
// src/service.ts
|
|
32085
32579
|
var seaRequire = createRequire2(import.meta.url);
|
|
32086
32580
|
var cachedIsSea;
|
|
@@ -32102,7 +32596,7 @@ function buildResidentSpawn(mode, serverId, selfEntry = process.argv[1] ?? "", e
|
|
|
32102
32596
|
}
|
|
32103
32597
|
var PARENT_LOCK_HELD_ENV_VAR = "SLOCK_COMPUTER_PARENT_MUTATION_LOCK_HELD";
|
|
32104
32598
|
async function spawnDetachedService(slockHome) {
|
|
32105
|
-
await
|
|
32599
|
+
await mkdir11(serviceRunDir(slockHome), { recursive: true });
|
|
32106
32600
|
const supLogFd = await open(serviceLogPath(slockHome), "a");
|
|
32107
32601
|
const { command, args } = buildResidentSpawn("__service", null);
|
|
32108
32602
|
const child = spawn2(command, args, {
|
|
@@ -32131,7 +32625,7 @@ async function ensureSeaRuntimePackageDir() {
|
|
|
32131
32625
|
if (!isSeaBinary() || process.env.PI_PACKAGE_DIR) return;
|
|
32132
32626
|
try {
|
|
32133
32627
|
const dir = joinPath(resolveSlockHome(), "runtime-pkg");
|
|
32134
|
-
await
|
|
32628
|
+
await mkdir11(dir, { recursive: true });
|
|
32135
32629
|
await writeFile9(
|
|
32136
32630
|
joinPath(dir, "package.json"),
|
|
32137
32631
|
`${JSON.stringify({ name: "slock-computer-sea-runtime", version: COMPUTER_VERSION })}
|
|
@@ -32327,10 +32821,10 @@ async function runServiceStartupRecovery(slockHome) {
|
|
|
32327
32821
|
}
|
|
32328
32822
|
async function resolveServiceIdentity() {
|
|
32329
32823
|
const here = fileURLToPath2(import.meta.url);
|
|
32330
|
-
const installRoot =
|
|
32824
|
+
const installRoot = dirname10(dirname10(here));
|
|
32331
32825
|
let version = null;
|
|
32332
32826
|
try {
|
|
32333
|
-
const raw = await
|
|
32827
|
+
const raw = await readFile10(joinPath(installRoot, "package.json"), "utf8");
|
|
32334
32828
|
const parsed = JSON.parse(raw);
|
|
32335
32829
|
if (typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
32336
32830
|
version = parsed.version;
|
|
@@ -32363,9 +32857,38 @@ async function writeServiceVersionEvidence(slockHome) {
|
|
|
32363
32857
|
);
|
|
32364
32858
|
}
|
|
32365
32859
|
}
|
|
32860
|
+
async function startServiceIpcSeam(slockHome) {
|
|
32861
|
+
const handlers = {
|
|
32862
|
+
"service-status": async () => readServiceStatus(slockHome),
|
|
32863
|
+
"runner-status": async ({ serverId }) => {
|
|
32864
|
+
try {
|
|
32865
|
+
return await readRunnerStatus(slockHome, serverId);
|
|
32866
|
+
} catch (err) {
|
|
32867
|
+
if (err instanceof StateReaderError) {
|
|
32868
|
+
throw new ServiceClientError("IPC_MALFORMED_FRAME", `${err.code}: ${err.message}`);
|
|
32869
|
+
}
|
|
32870
|
+
throw err;
|
|
32871
|
+
}
|
|
32872
|
+
},
|
|
32873
|
+
"list-runners": async () => listRunners(slockHome)
|
|
32874
|
+
};
|
|
32875
|
+
const ipc = createIpcServer({ installRoot: slockHome, handlers });
|
|
32876
|
+
try {
|
|
32877
|
+
const transportPath = await ipc.listen();
|
|
32878
|
+
process.stderr.write(`Service: IPC seam listening at ${transportPath}
|
|
32879
|
+
`);
|
|
32880
|
+
} catch (err) {
|
|
32881
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
32882
|
+
process.stderr.write(
|
|
32883
|
+
`Service: IPC seam failed to bind (${msg}); continuing without typed-RPC surface.
|
|
32884
|
+
`
|
|
32885
|
+
);
|
|
32886
|
+
}
|
|
32887
|
+
return ipc;
|
|
32888
|
+
}
|
|
32366
32889
|
async function runService() {
|
|
32367
32890
|
const slockHome = resolveSlockHome();
|
|
32368
|
-
await
|
|
32891
|
+
await mkdir11(serviceRunDir(slockHome), { recursive: true });
|
|
32369
32892
|
await runServiceStartupRecovery(slockHome);
|
|
32370
32893
|
await writePidfileAt(servicePidPath(slockHome), process.pid);
|
|
32371
32894
|
await writeServiceVersionEvidence(slockHome);
|
|
@@ -32375,7 +32898,7 @@ async function runService() {
|
|
|
32375
32898
|
const spawnChild = async (serverId) => {
|
|
32376
32899
|
if (children.has(serverId)) return;
|
|
32377
32900
|
const logPath = serverRunnerLogPath(slockHome, serverId);
|
|
32378
|
-
await
|
|
32901
|
+
await mkdir11(dirname10(logPath), { recursive: true });
|
|
32379
32902
|
const logFd = await open(logPath, "a");
|
|
32380
32903
|
const { command, args } = buildResidentSpawn("__run", serverId);
|
|
32381
32904
|
const child = spawn2(command, args, {
|
|
@@ -32456,11 +32979,13 @@ async function runService() {
|
|
|
32456
32979
|
if (!wanted.has(id)) killChild(handle);
|
|
32457
32980
|
}
|
|
32458
32981
|
};
|
|
32982
|
+
const ipc = await startServiceIpcSeam(slockHome);
|
|
32459
32983
|
let shuttingDown = false;
|
|
32460
32984
|
const shutdown = () => {
|
|
32461
32985
|
if (shuttingDown) return;
|
|
32462
32986
|
shuttingDown = true;
|
|
32463
32987
|
for (const handle of children.values()) killChild(handle);
|
|
32988
|
+
void ipc.close();
|
|
32464
32989
|
void clearPidfileAt(servicePidPath(slockHome)).then(() => process.exit(0));
|
|
32465
32990
|
};
|
|
32466
32991
|
process.on("SIGTERM", shutdown);
|
|
@@ -32586,7 +33111,7 @@ async function runDetach(serverId, serverLabel = serverId) {
|
|
|
32586
33111
|
var USER_SESSION_EXPIRY_LEEWAY_MS = 3e4;
|
|
32587
33112
|
async function readUserSessionAuth(slockHome) {
|
|
32588
33113
|
try {
|
|
32589
|
-
const parsed = JSON.parse(await
|
|
33114
|
+
const parsed = JSON.parse(await readFile11(userSessionPath(slockHome), "utf8"));
|
|
32590
33115
|
return {
|
|
32591
33116
|
accessToken: typeof parsed.accessToken === "string" ? parsed.accessToken : "",
|
|
32592
33117
|
...typeof parsed.serverUrl === "string" ? { serverUrl: parsed.serverUrl } : {}
|
|
@@ -32597,7 +33122,7 @@ async function readUserSessionAuth(slockHome) {
|
|
|
32597
33122
|
}
|
|
32598
33123
|
async function hasValidUserSession(slockHome) {
|
|
32599
33124
|
try {
|
|
32600
|
-
const parsed = JSON.parse(await
|
|
33125
|
+
const parsed = JSON.parse(await readFile11(userSessionPath(slockHome), "utf8"));
|
|
32601
33126
|
return parsed.kind === "user-session" && typeof parsed.accessToken === "string" && parsed.accessToken.length > 0 && !isJwtExpired(parsed.accessToken);
|
|
32602
33127
|
} catch {
|
|
32603
33128
|
return false;
|
|
@@ -32617,7 +33142,7 @@ async function refreshUserSession(slockHome, serverUrl) {
|
|
|
32617
33142
|
const file = userSessionPath(slockHome);
|
|
32618
33143
|
let session;
|
|
32619
33144
|
try {
|
|
32620
|
-
session = JSON.parse(await
|
|
33145
|
+
session = JSON.parse(await readFile11(file, "utf8"));
|
|
32621
33146
|
} catch {
|
|
32622
33147
|
return false;
|
|
32623
33148
|
}
|
|
@@ -32636,7 +33161,7 @@ async function refreshUserSession(slockHome, serverUrl) {
|
|
|
32636
33161
|
if (res.status !== 200 || typeof body?.accessToken !== "string" || typeof body.refreshToken !== "string") {
|
|
32637
33162
|
return false;
|
|
32638
33163
|
}
|
|
32639
|
-
await
|
|
33164
|
+
await mkdir12(dirname11(file), { recursive: true });
|
|
32640
33165
|
await writeFile10(
|
|
32641
33166
|
tmpFile,
|
|
32642
33167
|
JSON.stringify(
|
|
@@ -32654,7 +33179,7 @@ async function refreshUserSession(slockHome, serverUrl) {
|
|
|
32654
33179
|
),
|
|
32655
33180
|
{ mode: 384 }
|
|
32656
33181
|
);
|
|
32657
|
-
await
|
|
33182
|
+
await chmod6(tmpFile, 384);
|
|
32658
33183
|
await rename4(tmpFile, file);
|
|
32659
33184
|
return true;
|
|
32660
33185
|
} catch {
|
|
@@ -32964,122 +33489,6 @@ async function runSetup(opts, deps = {}) {
|
|
|
32964
33489
|
});
|
|
32965
33490
|
}
|
|
32966
33491
|
|
|
32967
|
-
// src/status.ts
|
|
32968
|
-
init_esm_shims();
|
|
32969
|
-
import { readFile as readFile11 } from "fs/promises";
|
|
32970
|
-
async function readUserSession(path3) {
|
|
32971
|
-
try {
|
|
32972
|
-
const parsed = JSON.parse(await readFile11(path3, "utf8"));
|
|
32973
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
32974
|
-
return { state: "present", session: parsed, error: null };
|
|
32975
|
-
}
|
|
32976
|
-
return { state: "invalid", session: null, error: "not a JSON object" };
|
|
32977
|
-
} catch (err) {
|
|
32978
|
-
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
|
|
32979
|
-
return { state: "missing", session: null, error: null };
|
|
32980
|
-
}
|
|
32981
|
-
return {
|
|
32982
|
-
state: "invalid",
|
|
32983
|
-
session: null,
|
|
32984
|
-
error: err instanceof Error ? err.message : String(err)
|
|
32985
|
-
};
|
|
32986
|
-
}
|
|
32987
|
-
}
|
|
32988
|
-
function str(v) {
|
|
32989
|
-
return typeof v === "string" && v.length > 0 ? v : null;
|
|
32990
|
-
}
|
|
32991
|
-
async function pidStatus(pidfile) {
|
|
32992
|
-
const pid = await readPidfileAt(pidfile);
|
|
32993
|
-
return pid !== null && isProcessAlive2(pid) ? { running: true, pid } : { running: false };
|
|
32994
|
-
}
|
|
32995
|
-
async function serviceState(slockHome) {
|
|
32996
|
-
const { pid } = await findLiveServicePidReadOnly(slockHome);
|
|
32997
|
-
return pid !== null ? { running: true, pid } : { running: false };
|
|
32998
|
-
}
|
|
32999
|
-
async function deriveHealth(slockHome, serverId, daemon) {
|
|
33000
|
-
if (!daemon.running) return "offline";
|
|
33001
|
-
if (await isDegraded(slockHome, serverId)) return "degraded";
|
|
33002
|
-
return "ok";
|
|
33003
|
-
}
|
|
33004
|
-
async function buildStatusReport(installRoot) {
|
|
33005
|
-
const sessionRead = await readUserSession(userSessionPath(installRoot));
|
|
33006
|
-
const session = sessionRead.session;
|
|
33007
|
-
const attachments = await listServerAttachments(installRoot);
|
|
33008
|
-
const service = {
|
|
33009
|
-
...await serviceState(installRoot),
|
|
33010
|
-
logPath: serviceLogPath(installRoot)
|
|
33011
|
-
};
|
|
33012
|
-
const servers = [];
|
|
33013
|
-
for (const a of attachments) {
|
|
33014
|
-
const daemon = await pidStatus(serverRunnerPidPath(installRoot, a.serverId));
|
|
33015
|
-
servers.push({
|
|
33016
|
-
serverId: a.serverId,
|
|
33017
|
-
serverSlug: a.serverSlug ?? null,
|
|
33018
|
-
serverMachineId: a.serverMachineId,
|
|
33019
|
-
serverUrl: a.serverUrl,
|
|
33020
|
-
attachedAt: a.attachedAt ?? null,
|
|
33021
|
-
serverRunnerLogPath: serverRunnerLogPath(installRoot, a.serverId),
|
|
33022
|
-
daemon,
|
|
33023
|
-
health: await deriveHealth(installRoot, a.serverId, daemon)
|
|
33024
|
-
});
|
|
33025
|
-
}
|
|
33026
|
-
const loggedIn = session?.kind === "user-session" && typeof session.accessToken === "string" && session.accessToken.length > 0;
|
|
33027
|
-
return {
|
|
33028
|
-
slockHome: installRoot,
|
|
33029
|
-
loggedIn,
|
|
33030
|
-
userId: session ? str(session.userId) : null,
|
|
33031
|
-
loginServerUrl: session ? str(session.serverUrl) : null,
|
|
33032
|
-
userSessionError: sessionRead.state === "invalid" ? sessionRead.error : null,
|
|
33033
|
-
service,
|
|
33034
|
-
servers
|
|
33035
|
-
};
|
|
33036
|
-
}
|
|
33037
|
-
function pad(s, n) {
|
|
33038
|
-
return s.length >= n ? s : s + " ".repeat(n - s.length);
|
|
33039
|
-
}
|
|
33040
|
-
async function runStatus(opts) {
|
|
33041
|
-
const report = await buildStatusReport(resolveSlockHome());
|
|
33042
|
-
if (opts.json) {
|
|
33043
|
-
info(JSON.stringify(report, null, 2));
|
|
33044
|
-
return;
|
|
33045
|
-
}
|
|
33046
|
-
info("");
|
|
33047
|
-
info(`SLOCK_HOME: ${report.slockHome}`);
|
|
33048
|
-
const loginDetail = report.userSessionError ? "no \u2014 user session file is invalid; re-run `slock-computer login`" : report.loggedIn ? `yes (user ${report.userId ?? "?"})` : "no \u2014 run `slock-computer login`";
|
|
33049
|
-
info(
|
|
33050
|
-
`Logged in: ${loginDetail}`
|
|
33051
|
-
);
|
|
33052
|
-
if (report.loginServerUrl) info(`Login server: ${report.loginServerUrl}`);
|
|
33053
|
-
info(
|
|
33054
|
-
`Service: ${report.service.running ? `running (pid ${report.service.pid})` : "stopped \u2014 run `slock-computer start`"}`
|
|
33055
|
-
);
|
|
33056
|
-
info(`Service log: ${report.service.logPath}`);
|
|
33057
|
-
info("");
|
|
33058
|
-
if (report.servers.length === 0) {
|
|
33059
|
-
info("Attachments: none \u2014 run `slock-computer attach /<serverSlug>` (e.g. `/myserver`).");
|
|
33060
|
-
} else {
|
|
33061
|
-
info("Attachments:");
|
|
33062
|
-
info(` ${pad("SERVER", 24)}${pad("HEALTH", 12)}${pad("DAEMON", 24)}${pad("MACHINE", 38)}URL`);
|
|
33063
|
-
for (const s of report.servers) {
|
|
33064
|
-
const dcol = s.daemon.running ? `running (pid ${s.daemon.pid})` : "stopped";
|
|
33065
|
-
info(
|
|
33066
|
-
` ${pad(formatServerSlugDisplay(s.serverSlug), 24)}${pad(s.health, 12)}${pad(dcol, 24)}${pad(s.serverMachineId, 38)}${s.serverUrl}`
|
|
33067
|
-
);
|
|
33068
|
-
info(` Server runner log: ${s.serverRunnerLogPath}`);
|
|
33069
|
-
}
|
|
33070
|
-
if (report.servers.some((s) => s.health === "degraded")) {
|
|
33071
|
-
info("");
|
|
33072
|
-
info(
|
|
33073
|
-
" Note: one or more servers are `degraded` (repeated crashes; auto-restart paused)."
|
|
33074
|
-
);
|
|
33075
|
-
info(
|
|
33076
|
-
" Run `slock-computer doctor /<serverSlug> --reset-health` (e.g. `/myserver`) after fixing the underlying issue."
|
|
33077
|
-
);
|
|
33078
|
-
}
|
|
33079
|
-
}
|
|
33080
|
-
info("");
|
|
33081
|
-
}
|
|
33082
|
-
|
|
33083
33492
|
// src/runners.ts
|
|
33084
33493
|
init_esm_shims();
|
|
33085
33494
|
|
|
@@ -33143,55 +33552,6 @@ async function resolveTargetAttachment(opts) {
|
|
|
33143
33552
|
return a;
|
|
33144
33553
|
}
|
|
33145
33554
|
|
|
33146
|
-
// src/lib/readers.ts
|
|
33147
|
-
init_esm_shims();
|
|
33148
|
-
|
|
33149
|
-
// src/lib/types.ts
|
|
33150
|
-
init_esm_shims();
|
|
33151
|
-
var StateReaderError = class extends Error {
|
|
33152
|
-
code;
|
|
33153
|
-
constructor(code, message) {
|
|
33154
|
-
super(message);
|
|
33155
|
-
this.name = "StateReaderError";
|
|
33156
|
-
this.code = code;
|
|
33157
|
-
}
|
|
33158
|
-
};
|
|
33159
|
-
|
|
33160
|
-
// src/lib/readers.ts
|
|
33161
|
-
async function listRunners(installRoot, opts = {}) {
|
|
33162
|
-
const all = await listServerAttachments(installRoot);
|
|
33163
|
-
let subset = all;
|
|
33164
|
-
if (opts.serverId !== void 0) {
|
|
33165
|
-
const found = all.find((a) => a.serverId === opts.serverId);
|
|
33166
|
-
if (!found) {
|
|
33167
|
-
throw new StateReaderError(
|
|
33168
|
-
"NOT_ATTACHED",
|
|
33169
|
-
`Server ${opts.serverId} is not attached to this Computer.`
|
|
33170
|
-
);
|
|
33171
|
-
}
|
|
33172
|
-
subset = [found];
|
|
33173
|
-
}
|
|
33174
|
-
const servers = [];
|
|
33175
|
-
for (const a of subset) {
|
|
33176
|
-
const client = new RunnersClient(a.serverUrl, a.apiKey);
|
|
33177
|
-
const result = await client.list();
|
|
33178
|
-
const idCols = { serverId: a.serverId, serverSlug: a.serverSlug ?? null };
|
|
33179
|
-
if (result.status === "success") {
|
|
33180
|
-
servers.push({
|
|
33181
|
-
...idCols,
|
|
33182
|
-
status: "ok",
|
|
33183
|
-
whitelist: result.whitelist,
|
|
33184
|
-
runners: result.runners
|
|
33185
|
-
});
|
|
33186
|
-
} else if (result.status === "unauthorized") {
|
|
33187
|
-
servers.push({ ...idCols, status: "unauthorized" });
|
|
33188
|
-
} else {
|
|
33189
|
-
servers.push({ ...idCols, status: "error", code: result.code });
|
|
33190
|
-
}
|
|
33191
|
-
}
|
|
33192
|
-
return { servers };
|
|
33193
|
-
}
|
|
33194
|
-
|
|
33195
33555
|
// src/runners.ts
|
|
33196
33556
|
async function runRunnersList(opts) {
|
|
33197
33557
|
const serverId = await resolveTargetServerId({ server: opts.server });
|
|
@@ -33423,8 +33783,8 @@ init_esm_shims();
|
|
|
33423
33783
|
|
|
33424
33784
|
// src/serviceState.ts
|
|
33425
33785
|
init_esm_shims();
|
|
33426
|
-
import { mkdir as
|
|
33427
|
-
import { dirname as
|
|
33786
|
+
import { mkdir as mkdir13, readFile as readFile13, writeFile as writeFile11, appendFile as appendFile3 } from "fs/promises";
|
|
33787
|
+
import { dirname as dirname12 } from "path";
|
|
33428
33788
|
|
|
33429
33789
|
// src/lib/state.ts
|
|
33430
33790
|
init_esm_shims();
|
|
@@ -33459,7 +33819,7 @@ async function readServiceState(slockHome) {
|
|
|
33459
33819
|
}
|
|
33460
33820
|
async function writeServiceState(slockHome, file) {
|
|
33461
33821
|
const path3 = serviceStatePath(slockHome);
|
|
33462
|
-
await
|
|
33822
|
+
await mkdir13(dirname12(path3), { recursive: true });
|
|
33463
33823
|
await writeFile11(path3, JSON.stringify(file), { mode: 384 });
|
|
33464
33824
|
}
|
|
33465
33825
|
function isCrashEntry(value) {
|
|
@@ -33477,7 +33837,7 @@ async function emitServiceStateTransition(slockHome, fromState, toState, trigger
|
|
|
33477
33837
|
};
|
|
33478
33838
|
try {
|
|
33479
33839
|
const path3 = serviceLogPath(slockHome);
|
|
33480
|
-
await
|
|
33840
|
+
await mkdir13(dirname12(path3), { recursive: true });
|
|
33481
33841
|
await appendFile3(path3, JSON.stringify(entry) + "\n");
|
|
33482
33842
|
} catch {
|
|
33483
33843
|
}
|
|
@@ -33571,13 +33931,13 @@ async function runReset(opts) {
|
|
|
33571
33931
|
// src/concurrency.ts
|
|
33572
33932
|
init_esm_shims();
|
|
33573
33933
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
33574
|
-
import { mkdir as
|
|
33934
|
+
import { mkdir as mkdir14 } from "fs/promises";
|
|
33575
33935
|
import { join as join5 } from "path";
|
|
33576
33936
|
var STALE_LOCK_THRESHOLD_MS = 6e4;
|
|
33577
33937
|
async function withMutationLock(fn) {
|
|
33578
33938
|
const slockHome = resolveSlockHome();
|
|
33579
33939
|
const lockTarget = computerDir(slockHome);
|
|
33580
|
-
await
|
|
33940
|
+
await mkdir14(lockTarget, { recursive: true });
|
|
33581
33941
|
const lockfilePath = join5(lockTarget, ".lock");
|
|
33582
33942
|
let release = null;
|
|
33583
33943
|
try {
|
|
@@ -33618,11 +33978,11 @@ async function withMutationLock(fn) {
|
|
|
33618
33978
|
init_esm_shims();
|
|
33619
33979
|
import { readFile as readFile14, rm as rm4 } from "fs/promises";
|
|
33620
33980
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
33621
|
-
import { dirname as
|
|
33981
|
+
import { dirname as dirname13, join as join6 } from "path";
|
|
33622
33982
|
|
|
33623
33983
|
// src/upgradeLog.ts
|
|
33624
33984
|
init_esm_shims();
|
|
33625
|
-
import { chmod as
|
|
33985
|
+
import { chmod as chmod7, mkdir as mkdir15, open as open2 } from "fs/promises";
|
|
33626
33986
|
var FILE_MODE = 384;
|
|
33627
33987
|
function resolveUpgradeTrigger(raw) {
|
|
33628
33988
|
return raw === "web" || raw === "tray" ? raw : "cli";
|
|
@@ -33670,7 +34030,7 @@ function assertUpgradeLogEntry(entry) {
|
|
|
33670
34030
|
}
|
|
33671
34031
|
async function appendUpgradeLogEntry(slockHome, entry) {
|
|
33672
34032
|
assertUpgradeLogEntry(entry);
|
|
33673
|
-
await
|
|
34033
|
+
await mkdir15(computerDir(slockHome), { recursive: true });
|
|
33674
34034
|
const path3 = upgradeLogPath(slockHome);
|
|
33675
34035
|
const at = entry.at ?? formatUpgradeLogTimestamp();
|
|
33676
34036
|
const fullEntry = { ...entry, at };
|
|
@@ -33682,7 +34042,7 @@ async function appendUpgradeLogEntry(slockHome, entry) {
|
|
|
33682
34042
|
await handle.close();
|
|
33683
34043
|
}
|
|
33684
34044
|
if (process.platform !== "win32") {
|
|
33685
|
-
await
|
|
34045
|
+
await chmod7(path3, FILE_MODE);
|
|
33686
34046
|
}
|
|
33687
34047
|
}
|
|
33688
34048
|
|
|
@@ -33840,7 +34200,7 @@ async function runUpgradeCli(slockHome, opts, deps = {}) {
|
|
|
33840
34200
|
}
|
|
33841
34201
|
function defaultCurrentBinaryDir() {
|
|
33842
34202
|
const here = fileURLToPath3(import.meta.url);
|
|
33843
|
-
return
|
|
34203
|
+
return dirname13(dirname13(here));
|
|
33844
34204
|
}
|
|
33845
34205
|
async function defaultCurrentVersion() {
|
|
33846
34206
|
if (isSeaBinary()) return COMPUTER_VERSION;
|