@botiverse/raft-computer 0.0.57 → 0.0.59
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 +1486 -745
- package/dist/lib/index.d.ts +9 -5
- package/dist/lib/index.js +73 -78
- package/package.json +2 -2
package/dist/lib/index.d.ts
CHANGED
|
@@ -608,12 +608,16 @@ declare function listRunners(installRoot: string, opts?: {
|
|
|
608
608
|
|
|
609
609
|
type UpgradeTrigger = "cli" | "web" | "tray";
|
|
610
610
|
/**
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
611
|
+
* Closed-set of upgrade-failure codes. Adding / renaming / deleting any value
|
|
612
|
+
* requires an RFC bump (locked discipline). This constant array is the runtime
|
|
613
|
+
* source of truth for the `assertUpgradeLogEntry` membership check; the type
|
|
614
|
+
* alias below mirrors it.
|
|
615
|
+
*
|
|
616
|
+
* `UPGRADE_DEPS_CHANGED` / `UPGRADE_RESTART_FAILED` were carried over from the
|
|
617
|
+
* retired npm-pack upgrade path and never emitted on the SEA-only path; they
|
|
618
|
+
* are removed (no released consumer existed — Computer is unreleased).
|
|
615
619
|
*/
|
|
616
|
-
declare const UPGRADE_ERROR_CODES: readonly ["
|
|
620
|
+
declare const UPGRADE_ERROR_CODES: readonly ["UPGRADE_NETWORK_FAILED", "UPGRADE_INTEGRITY_FAILED", "UPGRADE_SWAP_FAILED", "UPGRADE_NO_TARGET", "UPGRADE_ALREADY_RUNNING"];
|
|
617
621
|
type UpgradeErrorCode = (typeof UPGRADE_ERROR_CODES)[number];
|
|
618
622
|
interface UpgradeBundle {
|
|
619
623
|
computerVersion: string;
|
package/dist/lib/index.js
CHANGED
|
@@ -320,8 +320,8 @@ var RunnersClient = class {
|
|
|
320
320
|
};
|
|
321
321
|
|
|
322
322
|
// src/setup.ts
|
|
323
|
-
import { chmod as
|
|
324
|
-
import { dirname as
|
|
323
|
+
import { chmod as chmod6, mkdir as mkdir13, readFile as readFile12, rename as rename4, rm as rm3, writeFile as writeFile11 } from "fs/promises";
|
|
324
|
+
import { dirname as dirname11 } from "path";
|
|
325
325
|
import { fetch as fetch4 } from "undici";
|
|
326
326
|
|
|
327
327
|
// src/serverState.ts
|
|
@@ -358,9 +358,6 @@ function serverDir(slockHome, serverId) {
|
|
|
358
358
|
function serverAttachmentPath(slockHome, serverId) {
|
|
359
359
|
return path.join(serverDir(slockHome, serverId), "runner.state.json");
|
|
360
360
|
}
|
|
361
|
-
function legacyServerAttachmentPath(slockHome, serverId) {
|
|
362
|
-
return path.join(serverDir(slockHome, serverId), "attachment.json");
|
|
363
|
-
}
|
|
364
361
|
function serverRunnerPidPath(slockHome, serverId) {
|
|
365
362
|
return path.join(serverDir(slockHome, serverId), "server-runner.pid");
|
|
366
363
|
}
|
|
@@ -376,18 +373,8 @@ function serviceRunDir(slockHome) {
|
|
|
376
373
|
function servicePidPath(slockHome) {
|
|
377
374
|
return path.join(serviceRunDir(slockHome), "service.pid");
|
|
378
375
|
}
|
|
379
|
-
function legacyServicePidPath(slockHome) {
|
|
380
|
-
return path.join(computerDir(slockHome), "service.pid");
|
|
381
|
-
}
|
|
382
|
-
function legacySupervisorPidPath(slockHome) {
|
|
383
|
-
return path.join(computerDir(slockHome), "supervisor.pid");
|
|
384
|
-
}
|
|
385
376
|
function servicePidReadFallback(slockHome) {
|
|
386
|
-
return [
|
|
387
|
-
servicePidPath(slockHome),
|
|
388
|
-
legacyServicePidPath(slockHome),
|
|
389
|
-
legacySupervisorPidPath(slockHome)
|
|
390
|
-
];
|
|
377
|
+
return [servicePidPath(slockHome)];
|
|
391
378
|
}
|
|
392
379
|
function serviceLogPath(slockHome) {
|
|
393
380
|
return path.join(serviceRunDir(slockHome), "service.log");
|
|
@@ -423,14 +410,7 @@ async function readAttachmentAt(path2) {
|
|
|
423
410
|
}
|
|
424
411
|
async function readServerAttachment(slockHome, serverId) {
|
|
425
412
|
if (!isValidServerId(serverId)) return null;
|
|
426
|
-
|
|
427
|
-
const legacy = await readAttachmentAt(legacyServerAttachmentPath(slockHome, serverId));
|
|
428
|
-
if (!current) return legacy;
|
|
429
|
-
if (!legacy) return current;
|
|
430
|
-
if (legacy.adoptedFromLegacy === true && current.adoptedFromLegacy !== true && legacy.serverMachineId !== current.serverMachineId) {
|
|
431
|
-
return legacy;
|
|
432
|
-
}
|
|
433
|
-
return current;
|
|
413
|
+
return readAttachmentAt(serverAttachmentPath(slockHome, serverId));
|
|
434
414
|
}
|
|
435
415
|
async function listAttachedServerIds(slockHome) {
|
|
436
416
|
let entries;
|
|
@@ -490,8 +470,8 @@ function readComputerVersion(moduleUrl = import.meta.url) {
|
|
|
490
470
|
var COMPUTER_VERSION = readComputerVersion();
|
|
491
471
|
|
|
492
472
|
// src/service.ts
|
|
493
|
-
import { mkdir as
|
|
494
|
-
import { dirname as
|
|
473
|
+
import { mkdir as mkdir12, readFile as readFile11, writeFile as writeFile10, open, rename as rename3 } from "fs/promises";
|
|
474
|
+
import { dirname as dirname10, join as joinPath } from "path";
|
|
495
475
|
import { fileURLToPath } from "url";
|
|
496
476
|
|
|
497
477
|
// src/cleanup.ts
|
|
@@ -599,60 +579,19 @@ import { join as join4 } from "path";
|
|
|
599
579
|
import { readFile as readFile7, writeFile as writeFile7, mkdir as mkdir8 } from "fs/promises";
|
|
600
580
|
import { dirname as dirname7 } from "path";
|
|
601
581
|
|
|
602
|
-
// src/
|
|
603
|
-
|
|
582
|
+
// src/internal/ipc-server.ts
|
|
583
|
+
import { connect, createServer } from "net";
|
|
584
|
+
import { chmod as chmod5, mkdir as mkdir10, stat as stat4, unlink as unlink5 } from "fs/promises";
|
|
585
|
+
import { dirname as dirname8 } from "path";
|
|
604
586
|
|
|
605
|
-
// src/
|
|
606
|
-
var
|
|
607
|
-
"empty-intersection",
|
|
608
|
-
"explicit-zero",
|
|
609
|
-
"eof",
|
|
610
|
-
"non-tty",
|
|
611
|
-
"server-unavailable"
|
|
612
|
-
];
|
|
613
|
-
async function pickMigrationCandidateFromInput(candidates, read, write) {
|
|
614
|
-
write(
|
|
615
|
-
"Migration: detected legacy daemon(s) on this Computer that match the target server.\n"
|
|
616
|
-
);
|
|
617
|
-
candidates.forEach((c, i) => {
|
|
618
|
-
const host = c.hostname ? ` (${c.hostname})` : "";
|
|
619
|
-
const seen = c.lastSeenAt ? ` last seen ${c.lastSeenAt}` : "";
|
|
620
|
-
write(` ${i + 1}. ${c.machineName}${host}${seen}
|
|
621
|
-
`);
|
|
622
|
-
write(` local: ${c.localPath}
|
|
623
|
-
`);
|
|
624
|
-
});
|
|
625
|
-
write(" 0. Fresh attach (skip migration)\n");
|
|
626
|
-
write(" m. Migrate from a different on-disk path\n");
|
|
627
|
-
while (true) {
|
|
628
|
-
write("Choose [1]: ");
|
|
629
|
-
const { line, eof } = await read();
|
|
630
|
-
if (eof) return { kind: "fresh" };
|
|
631
|
-
const trimmed = line.trim();
|
|
632
|
-
const norm = trimmed.toLowerCase();
|
|
633
|
-
if (norm === "m") {
|
|
634
|
-
write("Path to legacy machine dir or owner.json: ");
|
|
635
|
-
const { line: pathLine } = await read();
|
|
636
|
-
return { kind: "manual", path: pathLine.trim() };
|
|
637
|
-
}
|
|
638
|
-
if (norm.length === 0) return { kind: "candidate", index: 0 };
|
|
639
|
-
if (norm === "0") return { kind: "fresh" };
|
|
640
|
-
const n = Number.parseInt(norm, 10);
|
|
641
|
-
if (Number.isFinite(n) && String(n) === norm && n >= 1 && n <= candidates.length) {
|
|
642
|
-
return { kind: "candidate", index: n - 1 };
|
|
643
|
-
}
|
|
644
|
-
write(
|
|
645
|
-
`Invalid selection "${trimmed}". Enter 1..${candidates.length}, 0, or m.
|
|
646
|
-
`
|
|
647
|
-
);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
587
|
+
// src/internal/ipc-codec.ts
|
|
588
|
+
var MAX_FRAME_BYTES = 1024 * 1024;
|
|
650
589
|
|
|
651
590
|
// src/status.ts
|
|
652
|
-
import { readFile as
|
|
591
|
+
import { readFile as readFile9 } from "fs/promises";
|
|
653
592
|
async function readUserSession(path2) {
|
|
654
593
|
try {
|
|
655
|
-
const parsed = JSON.parse(await
|
|
594
|
+
const parsed = JSON.parse(await readFile9(path2, "utf8"));
|
|
656
595
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
657
596
|
return { state: "present", session: parsed, error: null };
|
|
658
597
|
}
|
|
@@ -782,6 +721,10 @@ async function listRunners(installRoot, opts = {}) {
|
|
|
782
721
|
return { servers };
|
|
783
722
|
}
|
|
784
723
|
|
|
724
|
+
// src/serviceState.ts
|
|
725
|
+
import { mkdir as mkdir11, readFile as readFile10, writeFile as writeFile9, appendFile as appendFile3 } from "fs/promises";
|
|
726
|
+
import { dirname as dirname9 } from "path";
|
|
727
|
+
|
|
785
728
|
// src/lib/state.ts
|
|
786
729
|
var RUNNER_STATE_VALUES = [
|
|
787
730
|
"starting",
|
|
@@ -804,14 +747,66 @@ function isServiceState(value) {
|
|
|
804
747
|
return typeof value === "string" && SERVICE_STATE_VALUES.includes(value);
|
|
805
748
|
}
|
|
806
749
|
|
|
750
|
+
// src/lib/ipc-client.ts
|
|
751
|
+
import { connect as connect2 } from "net";
|
|
752
|
+
import { randomUUID } from "crypto";
|
|
753
|
+
|
|
754
|
+
// src/service.ts
|
|
755
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
756
|
+
var seaRequire = createRequire2(import.meta.url);
|
|
757
|
+
|
|
758
|
+
// src/setup.ts
|
|
759
|
+
var MIGRATION_FRESH_TRIGGERS = [
|
|
760
|
+
"empty-intersection",
|
|
761
|
+
"explicit-zero",
|
|
762
|
+
"eof",
|
|
763
|
+
"non-tty",
|
|
764
|
+
"server-unavailable"
|
|
765
|
+
];
|
|
766
|
+
async function pickMigrationCandidateFromInput(candidates, read, write) {
|
|
767
|
+
write(
|
|
768
|
+
"Migration: detected legacy daemon(s) on this Computer that match the target server.\n"
|
|
769
|
+
);
|
|
770
|
+
candidates.forEach((c, i) => {
|
|
771
|
+
const host = c.hostname ? ` (${c.hostname})` : "";
|
|
772
|
+
const seen = c.lastSeenAt ? ` last seen ${c.lastSeenAt}` : "";
|
|
773
|
+
write(` ${i + 1}. ${c.machineName}${host}${seen}
|
|
774
|
+
`);
|
|
775
|
+
write(` local: ${c.localPath}
|
|
776
|
+
`);
|
|
777
|
+
});
|
|
778
|
+
write(" 0. Fresh attach (skip migration)\n");
|
|
779
|
+
write(" m. Migrate from a different on-disk path\n");
|
|
780
|
+
while (true) {
|
|
781
|
+
write("Choose [1]: ");
|
|
782
|
+
const { line, eof } = await read();
|
|
783
|
+
if (eof) return { kind: "fresh" };
|
|
784
|
+
const trimmed = line.trim();
|
|
785
|
+
const norm = trimmed.toLowerCase();
|
|
786
|
+
if (norm === "m") {
|
|
787
|
+
write("Path to legacy machine dir or owner.json: ");
|
|
788
|
+
const { line: pathLine } = await read();
|
|
789
|
+
return { kind: "manual", path: pathLine.trim() };
|
|
790
|
+
}
|
|
791
|
+
if (norm.length === 0) return { kind: "candidate", index: 0 };
|
|
792
|
+
if (norm === "0") return { kind: "fresh" };
|
|
793
|
+
const n = Number.parseInt(norm, 10);
|
|
794
|
+
if (Number.isFinite(n) && String(n) === norm && n >= 1 && n <= candidates.length) {
|
|
795
|
+
return { kind: "candidate", index: n - 1 };
|
|
796
|
+
}
|
|
797
|
+
write(
|
|
798
|
+
`Invalid selection "${trimmed}". Enter 1..${candidates.length}, 0, or m.
|
|
799
|
+
`
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
807
804
|
// src/upgradeLog.ts
|
|
808
|
-
import { chmod as
|
|
805
|
+
import { chmod as chmod7, mkdir as mkdir14, open as open2 } from "fs/promises";
|
|
809
806
|
var UPGRADE_ERROR_CODES = [
|
|
810
|
-
"UPGRADE_DEPS_CHANGED",
|
|
811
807
|
"UPGRADE_NETWORK_FAILED",
|
|
812
808
|
"UPGRADE_INTEGRITY_FAILED",
|
|
813
809
|
"UPGRADE_SWAP_FAILED",
|
|
814
|
-
"UPGRADE_RESTART_FAILED",
|
|
815
810
|
"UPGRADE_NO_TARGET",
|
|
816
811
|
"UPGRADE_ALREADY_RUNNING"
|
|
817
812
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botiverse/raft-computer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"description": "Canonical Raft Computer — standalone human/local-machine control-plane CLI (login + attach). Provides raft-computer plus the legacy slock-computer alias; distinct from the agent-facing @botiverse/raft CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"commander": "^12.1.0",
|
|
32
32
|
"proper-lockfile": "^4.1.2",
|
|
33
33
|
"undici": "^7.24.7",
|
|
34
|
-
"@botiverse/raft-daemon": "0.
|
|
34
|
+
"@botiverse/raft-daemon": "0.62.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^25.5.0",
|