engine7 7.1.138 → 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/README.md +3 -1
- package/dist/bg-worker.mjs +134 -128
- package/dist/cli.mjs +4908 -3448
- package/dist/cpu-router-worker.mjs +604 -8
- package/dist/device-connectors/reader +0 -0
- package/dist/engine-startup.mjs +9105 -6642
- package/dist/main.mjs +9082 -6618
- package/dist/optional-deps.json +78 -0
- package/dist/recall-worker.mjs +57 -53
- package/dist/sqlite-maintenance-worker.mjs +16 -18
- package/dist/topics-worker.mjs +56 -52
- package/dist/travel-activation-database.mjs +1077 -0
- package/dist/travel-authority.mjs +46 -25
- package/dist/travel-console.mjs +150 -83
- package/dist/travel-controller.mjs +244 -51
- package/dist/travel-data.mjs +972 -578
- package/dist/travel-gateway.mjs +1529 -745
- package/dist/travel-host.mjs +3970 -3068
- package/dist/travel-initial-baseline.mjs +5959 -0
- package/dist/travel-node-data.mjs +751 -324
- package/dist/travel-node.mjs +2489 -1541
- package/dist/travel-pairing.mjs +1570 -779
- package/dist/travel-resource.mjs +23 -16
- package/dist/travel-retire.mjs +52 -37
- package/dist/web-console.mjs +1972 -320
- package/package.json +13 -8
- package/scripts/verify-cpu-router-package.mjs +14 -1
- package/templates/config.template.json +14 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const require=(await import('node:module')).createRequire(import.meta.url)
|
|
2
2
|
|
|
3
3
|
// src/continuity/authority-main.ts
|
|
4
|
-
import { existsSync as existsSync2, readFileSync as
|
|
5
|
-
import { isAbsolute, join as
|
|
4
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
5
|
+
import { isAbsolute as isAbsolute2, join as join4, resolve as resolve3 } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
8
|
// src/continuity/authority.ts
|
|
9
9
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
10
10
|
import { createHash, createPublicKey, generateKeyPairSync, randomBytes, randomUUID, sign, verify } from "node:crypto";
|
|
11
|
-
import { existsSync, writeFileSync
|
|
11
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
12
12
|
import { join as join2 } from "node:path";
|
|
13
13
|
|
|
14
14
|
// src/continuity/publication-objects.ts
|
|
@@ -20,19 +20,15 @@ import {
|
|
|
20
20
|
fstatSync,
|
|
21
21
|
fsyncSync,
|
|
22
22
|
readSync,
|
|
23
|
-
writeSync,
|
|
24
23
|
lstatSync,
|
|
25
24
|
realpathSync,
|
|
26
|
-
mkdirSync
|
|
27
|
-
readFileSync,
|
|
28
|
-
writeFileSync,
|
|
29
|
-
linkSync,
|
|
30
|
-
unlinkSync
|
|
25
|
+
mkdirSync
|
|
31
26
|
} from "node:fs";
|
|
32
27
|
import { join, dirname, resolve } from "node:path";
|
|
33
28
|
var PUBLICATION_CHUNK_BYTES = 1024 * 1024;
|
|
34
29
|
var HASH = /^[a-f0-9]{64}$/;
|
|
35
30
|
var MAGIC = Buffer.from("E7P1");
|
|
31
|
+
var INLINE_BYTES = 64 * 1024;
|
|
36
32
|
var noFollow = constants.O_NOFOLLOW ?? 0;
|
|
37
33
|
function validateObjectRef(ref) {
|
|
38
34
|
if (!ref || !HASH.test(ref.sha256) || !Number.isSafeInteger(ref.bytes) || ref.bytes < 1 || ref.bytes > PUBLICATION_CHUNK_BYTES)
|
|
@@ -110,7 +106,7 @@ function preparePrivateDatabase(path2) {
|
|
|
110
106
|
|
|
111
107
|
// src/continuity/key-service-store.ts
|
|
112
108
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
113
|
-
import { constants as constants2, lstatSync as lstatSync2, mkdirSync as mkdirSync2, openSync as openSync2, closeSync as closeSync2, readFileSync
|
|
109
|
+
import { constants as constants2, lstatSync as lstatSync2, mkdirSync as mkdirSync2, openSync as openSync2, closeSync as closeSync2, readFileSync, writeSync, fstatSync as fstatSync2, fsyncSync as fsyncSync2, unlinkSync } from "node:fs";
|
|
114
110
|
function assertPrivateStat(stat, directory) {
|
|
115
111
|
if ((directory ? !stat.isDirectory() : !stat.isFile()) || process.platform !== "win32" && ((stat.mode & 63) !== 0 || stat.uid !== process.getuid?.()))
|
|
116
112
|
throw new Error("KEY_SERVICE_PRIVATE_PATH_REQUIRED");
|
|
@@ -122,7 +118,7 @@ function readPrivateFile(path2, maximumBytes = 65536) {
|
|
|
122
118
|
const stat = fstatSync2(fd);
|
|
123
119
|
assertPrivateStat(stat, false);
|
|
124
120
|
if (stat.size > maximumBytes) throw new Error("KEY_SERVICE_INVALID_FILE_SIZE");
|
|
125
|
-
return
|
|
121
|
+
return readFileSync(fd);
|
|
126
122
|
} finally {
|
|
127
123
|
closeSync2(fd);
|
|
128
124
|
}
|
|
@@ -191,7 +187,7 @@ var TravelAuthority = class {
|
|
|
191
187
|
if (present !== keyPresent) throw new Error("TRAVEL_AUTHORITY_RECOVERY_REQUIRED");
|
|
192
188
|
if (!keyPresent) {
|
|
193
189
|
const keys = generateKeyPairSync("ed25519");
|
|
194
|
-
|
|
190
|
+
writeFileSync(keyFile, keys.privateKey.export({ format: "pem", type: "pkcs8" }), { mode: 384, flag: "wx", flush: true });
|
|
195
191
|
}
|
|
196
192
|
this.signingKey = readPrivateFile(keyFile).toString();
|
|
197
193
|
this.publicKey = createPublicKey(this.signingKey).export({ format: "pem", type: "spki" }).toString();
|
|
@@ -212,6 +208,9 @@ var TravelAuthority = class {
|
|
|
212
208
|
CREATE TABLE IF NOT EXISTS recovery_branches(identity TEXT NOT NULL,common TEXT NOT NULL,local TEXT NOT NULL,
|
|
213
209
|
chain TEXT NOT NULL,PRIMARY KEY(identity,common,local));`);
|
|
214
210
|
this.db.exec("CREATE TABLE IF NOT EXISTS retirement_sources(identity TEXT PRIMARY KEY,body TEXT NOT NULL)");
|
|
211
|
+
if (!this.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='leased_seats'").get()) {
|
|
212
|
+
this.transaction(() => this.db.exec("CREATE TABLE leased_seats(identity TEXT PRIMARY KEY); INSERT INTO leased_seats SELECT identity FROM seats"));
|
|
213
|
+
}
|
|
215
214
|
if (this.db.prepare("PRAGMA quick_check").get()?.quick_check !== "ok") throw new Error("TRAVEL_AUTHORITY_CORRUPT");
|
|
216
215
|
this.transaction(() => {
|
|
217
216
|
this.db.exec("UPDATE seats SET epoch=epoch+1,active_node=NULL,active_boot=NULL,frozen=0 WHERE retired IS NULL");
|
|
@@ -276,7 +275,7 @@ var TravelAuthority = class {
|
|
|
276
275
|
}
|
|
277
276
|
/** Trusted pairing owner binds the first real H to an unused reservation.
|
|
278
277
|
* This does not grant a lease and never rewrites a used seat's history. */
|
|
279
|
-
bindInitialCheckpoint(principal, digest, buildManifestId) {
|
|
278
|
+
bindInitialCheckpoint(principal, digest, buildManifestId, previousDigest) {
|
|
280
279
|
if (!HASH2.test(digest) || digest === "0".repeat(64)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
281
280
|
id(buildManifestId);
|
|
282
281
|
const text = identityText(principal);
|
|
@@ -285,7 +284,9 @@ var TravelAuthority = class {
|
|
|
285
284
|
this.principal(principal);
|
|
286
285
|
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(text)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
287
286
|
if (row.checkpoint === digest) return;
|
|
288
|
-
if (
|
|
287
|
+
if (this.db.prepare("SELECT 1 FROM leased_seats WHERE identity=?").get(text)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
288
|
+
if (previousDigest !== void 0 && (!HASH2.test(previousDigest) || row.checkpoint !== previousDigest)) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
289
|
+
if (row.checkpoint !== "0".repeat(64) && previousDigest !== row.checkpoint) throw new Error("TRAVEL_INITIAL_BASELINE");
|
|
289
290
|
this.db.prepare("DELETE FROM checkpoints WHERE identity=?").run(text);
|
|
290
291
|
this.db.prepare("INSERT INTO checkpoints VALUES(?,?,NULL,1)").run(text, digest);
|
|
291
292
|
this.db.prepare("UPDATE seats SET checkpoint=? WHERE identity=?").run(digest, text);
|
|
@@ -356,6 +357,7 @@ var TravelAuthority = class {
|
|
|
356
357
|
if (row.active_node && ((this.deadlines.get(text) ?? 0) <= this.monotonicNow() || row.active_boot !== node.boot)) row.epoch++;
|
|
357
358
|
row.active_node = principal.nodeId;
|
|
358
359
|
row.active_boot = String(node.boot);
|
|
360
|
+
this.db.prepare("INSERT OR IGNORE INTO leased_seats VALUES(?)").run(text);
|
|
359
361
|
this.db.prepare("UPDATE seats SET epoch=?,active_node=?,active_boot=? WHERE identity=?").run(row.epoch, row.active_node, row.active_boot, text);
|
|
360
362
|
this.deadlines.set(text, this.monotonicNow() + this.leaseMs);
|
|
361
363
|
this.healthy.set(text + principal.nodeId, this.monotonicNow() + this.leaseMs);
|
|
@@ -646,7 +648,22 @@ var TravelAuthority = class {
|
|
|
646
648
|
// src/continuity/publication.ts
|
|
647
649
|
import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
648
650
|
import { createHash as createHash2 } from "node:crypto";
|
|
649
|
-
|
|
651
|
+
|
|
652
|
+
// src/continuity/inventory.ts
|
|
653
|
+
import { isAbsolute, join as join3, relative, resolve as resolve2, sep } from "node:path";
|
|
654
|
+
var STATE = new Set(`workspace agents auth configs cron media mem7 memory runtime session-memory steer tasks teams todos tools topics topics-history .everos .calendar calendar proactive skills prompts goals.json goal-events.jsonl SESSION-STATE.md install-identity.json license.json report-failures.jsonl report-state.json service-suggestions.json weixin cc-driver engines.json settings.json onboarding.json onboarding-tips.json remote-watchers.json plans telegram state`.split(" "));
|
|
655
|
+
var CORE_DIRECTORIES = new Set(`agents auth configs cron mem7 memory runtime session-memory steer tasks teams todos tools .everos .calendar calendar .proactive proactive skills prompts .nudge hooks inner-voice goals plans private scripts state .voice-chat .desktopBuddy body`.split(" "));
|
|
656
|
+
var CORE_OMITTED = new Set(`media images videos audio content content-library docs output outputs dogfood-output backup backups topics-history node_modules .venvs venv .venv asr .cache cache caches tmp temp .playwright-mcp lancedb`.split(" "));
|
|
657
|
+
function validateRelativePath(path2) {
|
|
658
|
+
if (typeof path2 !== "string" || !path2 || path2.length > 2048 || isAbsolute(path2)) throw new Error("INVALID_ARTIFACT_PATH");
|
|
659
|
+
for (const part of path2.split("/")) {
|
|
660
|
+
if (!part || part === "." || part === ".." || /[\x00-\x1f]/.test(part) || Buffer.byteLength(part) > 255 || process.platform === "win32" && (/[<>:"|?*\\]/.test(part) || /[. ]$/.test(part) || /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(part)))
|
|
661
|
+
throw new Error("INVALID_ARTIFACT_PATH");
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// src/continuity/publication.ts
|
|
666
|
+
var PUBLICATION_MANIFEST_BYTES = 32 * 1024 * 1024;
|
|
650
667
|
var PUBLICATION_COMMIT_BYTES = 24 * 1024 * 1024;
|
|
651
668
|
var ZERO = "0".repeat(64);
|
|
652
669
|
var HASH3 = /^[a-f0-9]{64}$/;
|
|
@@ -687,8 +704,12 @@ function normalizePublicationProfile(value) {
|
|
|
687
704
|
return Object.freeze(profile);
|
|
688
705
|
}
|
|
689
706
|
function validatePublicationPath(path2) {
|
|
690
|
-
if (typeof path2 !== "string" ||
|
|
707
|
+
if (typeof path2 !== "string" || path2.normalize("NFC") !== path2) throw new Error("PUBLICATION_INVALID_PATH");
|
|
708
|
+
try {
|
|
709
|
+
validateRelativePath(path2);
|
|
710
|
+
} catch {
|
|
691
711
|
throw new Error("PUBLICATION_INVALID_PATH");
|
|
712
|
+
}
|
|
692
713
|
}
|
|
693
714
|
function normalizePublication(value) {
|
|
694
715
|
if (!value || value.format !== "engine7-publication-v1" || !natural2(value.sequence) || !value.sequence || !HASH3.test(value.parentDigest) || !natural2(value.deletionWatermark) || !Array.isArray(value.databases) || !Array.isArray(value.trees)) throw new Error("PUBLICATION_INVALID_MANIFEST");
|
|
@@ -1027,20 +1048,20 @@ function createTravelAuthorityServer(options) {
|
|
|
1027
1048
|
|
|
1028
1049
|
// src/continuity/authority-main.ts
|
|
1029
1050
|
function path(value) {
|
|
1030
|
-
if (typeof value !== "string" || !
|
|
1031
|
-
return
|
|
1051
|
+
if (typeof value !== "string" || !isAbsolute2(value)) throw new Error("TRAVEL_CONTROL_ABSOLUTE_PATH_REQUIRED");
|
|
1052
|
+
return resolve3(value);
|
|
1032
1053
|
}
|
|
1033
1054
|
async function startTravelAuthorityService(config) {
|
|
1034
1055
|
if (!Number.isSafeInteger(config?.port) || config.port < 0 || config.port > 65535 || typeof config.host !== "string" || !config.host) throw new Error("TRAVEL_CONTROL_INVALID_LISTENER");
|
|
1035
1056
|
const directory = path(config.authorityDir);
|
|
1036
|
-
if (!existsSync2(
|
|
1057
|
+
if (!existsSync2(join4(directory, "authority.sqlite")) || !existsSync2(join4(directory, "authority-signing.pem"))) throw new Error("TRAVEL_CONTROL_REGISTRATION_REQUIRED");
|
|
1037
1058
|
const authority = new TravelAuthority({ directory, leaseMs: config.leaseMs });
|
|
1038
1059
|
let server, key, closing;
|
|
1039
1060
|
const close = () => closing ??= (async () => {
|
|
1040
1061
|
try {
|
|
1041
1062
|
if (server) {
|
|
1042
1063
|
server.closeAllConnections();
|
|
1043
|
-
await new Promise((
|
|
1064
|
+
await new Promise((resolve4) => server.close(() => resolve4()));
|
|
1044
1065
|
}
|
|
1045
1066
|
} finally {
|
|
1046
1067
|
authority.close();
|
|
@@ -1052,8 +1073,8 @@ async function startTravelAuthorityService(config) {
|
|
|
1052
1073
|
server = createTravelAuthorityServer({
|
|
1053
1074
|
authority,
|
|
1054
1075
|
key,
|
|
1055
|
-
cert:
|
|
1056
|
-
ca:
|
|
1076
|
+
cert: readFileSync2(path(config.tls?.certFile)),
|
|
1077
|
+
ca: readFileSync2(path(config.tls?.caFile)),
|
|
1057
1078
|
proxyFingerprints: config.proxyFingerprints,
|
|
1058
1079
|
allowedPeers: config.allowedPeers,
|
|
1059
1080
|
managementPeers: config.managementPeers,
|
|
@@ -1062,9 +1083,9 @@ async function startTravelAuthorityService(config) {
|
|
|
1062
1083
|
maximumInFlight: config.maximumInFlight,
|
|
1063
1084
|
requestTimeoutMs: config.requestTimeoutMs
|
|
1064
1085
|
});
|
|
1065
|
-
await new Promise((
|
|
1086
|
+
await new Promise((resolve4, reject) => {
|
|
1066
1087
|
server.once("error", reject);
|
|
1067
|
-
server.listen(config.port, config.host,
|
|
1088
|
+
server.listen(config.port, config.host, resolve4);
|
|
1068
1089
|
});
|
|
1069
1090
|
const status = () => ({ ready: true, port: server.address().port, authorityBootId: authority.authorityBootId });
|
|
1070
1091
|
return { server, authority, close, status };
|
|
@@ -1087,7 +1108,7 @@ async function runTravelAuthorityCli(args) {
|
|
|
1087
1108
|
process.once("SIGINT", stop);
|
|
1088
1109
|
return service.status();
|
|
1089
1110
|
}
|
|
1090
|
-
if (process.argv[1] &&
|
|
1111
|
+
if (process.argv[1] && resolve3(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
1091
1112
|
runTravelAuthorityCli(process.argv.slice(2)).then((result) => process.stdout.write(JSON.stringify(result) + "\n")).catch(() => {
|
|
1092
1113
|
process.stderr.write("TRAVEL_CONTROL_REFUSED\n");
|
|
1093
1114
|
process.exitCode = 1;
|