engine7 7.1.140 → 7.1.141
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/bg-worker.mjs +1 -1
- package/dist/cli.mjs +1393 -1074
- package/dist/engine-startup.mjs +48 -23
- package/dist/main.mjs +48 -23
- package/dist/travel-activation-database.mjs +1077 -0
- package/dist/travel-authority.mjs +8 -2
- package/dist/travel-console.mjs +28 -16
- package/dist/travel-controller.mjs +14 -2
- package/dist/travel-data.mjs +351 -253
- package/dist/travel-gateway.mjs +24 -5
- package/dist/travel-host.mjs +1371 -1558
- package/dist/travel-initial-baseline.mjs +5959 -0
- package/dist/travel-node-data.mjs +146 -39
- package/dist/travel-node.mjs +1445 -1234
- package/dist/travel-pairing.mjs +26 -7
- package/dist/web-console.mjs +288 -71
- package/package.json +1 -1
package/dist/travel-gateway.mjs
CHANGED
|
@@ -11836,6 +11836,16 @@ function recoverCwd(file2) {
|
|
|
11836
11836
|
}
|
|
11837
11837
|
return null;
|
|
11838
11838
|
}
|
|
11839
|
+
function userText(content) {
|
|
11840
|
+
if (typeof content === "string") return content.trim() ? content : null;
|
|
11841
|
+
if (Array.isArray(content)) {
|
|
11842
|
+
const text2 = content.filter(
|
|
11843
|
+
(b) => !!b && typeof b === "object" && b.type === "text" && typeof b.text === "string"
|
|
11844
|
+
).map((b) => b.text).join(" ");
|
|
11845
|
+
return text2.trim() ? text2 : null;
|
|
11846
|
+
}
|
|
11847
|
+
return null;
|
|
11848
|
+
}
|
|
11839
11849
|
function firstUserText(file2) {
|
|
11840
11850
|
try {
|
|
11841
11851
|
const text2 = headBytes(file2, 65536).toString("utf-8");
|
|
@@ -11847,9 +11857,12 @@ function firstUserText(file2) {
|
|
|
11847
11857
|
} catch {
|
|
11848
11858
|
continue;
|
|
11849
11859
|
}
|
|
11850
|
-
if (entry.type === "user"
|
|
11851
|
-
const
|
|
11852
|
-
if (
|
|
11860
|
+
if (entry.type === "user") {
|
|
11861
|
+
const t = userText(entry.message?.content);
|
|
11862
|
+
if (t) {
|
|
11863
|
+
const s = t.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
|
11864
|
+
if (s) return s.length > 40 ? s.slice(0, 40) + "\u2026" : s;
|
|
11865
|
+
}
|
|
11853
11866
|
}
|
|
11854
11867
|
}
|
|
11855
11868
|
} catch {
|
|
@@ -17761,6 +17774,9 @@ var TravelAuthority = class {
|
|
|
17761
17774
|
CREATE TABLE IF NOT EXISTS recovery_branches(identity TEXT NOT NULL,common TEXT NOT NULL,local TEXT NOT NULL,
|
|
17762
17775
|
chain TEXT NOT NULL,PRIMARY KEY(identity,common,local));`);
|
|
17763
17776
|
this.db.exec("CREATE TABLE IF NOT EXISTS retirement_sources(identity TEXT PRIMARY KEY,body TEXT NOT NULL)");
|
|
17777
|
+
if (!this.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='leased_seats'").get()) {
|
|
17778
|
+
this.transaction(() => this.db.exec("CREATE TABLE leased_seats(identity TEXT PRIMARY KEY); INSERT INTO leased_seats SELECT identity FROM seats"));
|
|
17779
|
+
}
|
|
17764
17780
|
if (this.db.prepare("PRAGMA quick_check").get()?.quick_check !== "ok") throw new Error("TRAVEL_AUTHORITY_CORRUPT");
|
|
17765
17781
|
this.transaction(() => {
|
|
17766
17782
|
this.db.exec("UPDATE seats SET epoch=epoch+1,active_node=NULL,active_boot=NULL,frozen=0 WHERE retired IS NULL");
|
|
@@ -17825,7 +17841,7 @@ var TravelAuthority = class {
|
|
|
17825
17841
|
}
|
|
17826
17842
|
/** Trusted pairing owner binds the first real H to an unused reservation.
|
|
17827
17843
|
* This does not grant a lease and never rewrites a used seat's history. */
|
|
17828
|
-
bindInitialCheckpoint(principal, digest7, buildManifestId) {
|
|
17844
|
+
bindInitialCheckpoint(principal, digest7, buildManifestId, previousDigest) {
|
|
17829
17845
|
if (!HASH2.test(digest7) || digest7 === "0".repeat(64)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
17830
17846
|
id(buildManifestId);
|
|
17831
17847
|
const text2 = identityText(principal);
|
|
@@ -17834,7 +17850,9 @@ var TravelAuthority = class {
|
|
|
17834
17850
|
this.principal(principal);
|
|
17835
17851
|
if (!row || row.active_node !== null || row.active_boot !== null || row.frozen || row.retired !== null || row.floor !== 0 || row.build !== buildManifestId || this.db.prepare("SELECT 1 FROM handoffs WHERE identity=? LIMIT 1").get(text2)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
17836
17852
|
if (row.checkpoint === digest7) return;
|
|
17837
|
-
if (
|
|
17853
|
+
if (this.db.prepare("SELECT 1 FROM leased_seats WHERE identity=?").get(text2)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
17854
|
+
if (previousDigest !== void 0 && (!HASH2.test(previousDigest) || row.checkpoint !== previousDigest)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
17855
|
+
if (row.checkpoint !== "0".repeat(64) && previousDigest !== row.checkpoint) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
17838
17856
|
this.db.prepare("DELETE FROM checkpoints WHERE identity=?").run(text2);
|
|
17839
17857
|
this.db.prepare("INSERT INTO checkpoints VALUES(?,?,NULL,1)").run(text2, digest7);
|
|
17840
17858
|
this.db.prepare("UPDATE seats SET checkpoint=? WHERE identity=?").run(digest7, text2);
|
|
@@ -17905,6 +17923,7 @@ var TravelAuthority = class {
|
|
|
17905
17923
|
if (row.active_node && ((this.deadlines.get(text2) ?? 0) <= this.monotonicNow() || row.active_boot !== node.boot)) row.epoch++;
|
|
17906
17924
|
row.active_node = principal.nodeId;
|
|
17907
17925
|
row.active_boot = String(node.boot);
|
|
17926
|
+
this.db.prepare("INSERT OR IGNORE INTO leased_seats VALUES(?)").run(text2);
|
|
17908
17927
|
this.db.prepare("UPDATE seats SET epoch=?,active_node=?,active_boot=? WHERE identity=?").run(row.epoch, row.active_node, row.active_boot, text2);
|
|
17909
17928
|
this.deadlines.set(text2, this.monotonicNow() + this.leaseMs);
|
|
17910
17929
|
this.healthy.set(text2 + principal.nodeId, this.monotonicNow() + this.leaseMs);
|