engine7 7.1.140 → 7.1.142

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.
@@ -208,6 +208,9 @@ var TravelAuthority = class {
208
208
  CREATE TABLE IF NOT EXISTS recovery_branches(identity TEXT NOT NULL,common TEXT NOT NULL,local TEXT NOT NULL,
209
209
  chain TEXT NOT NULL,PRIMARY KEY(identity,common,local));`);
210
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
+ }
211
214
  if (this.db.prepare("PRAGMA quick_check").get()?.quick_check !== "ok") throw new Error("TRAVEL_AUTHORITY_CORRUPT");
212
215
  this.transaction(() => {
213
216
  this.db.exec("UPDATE seats SET epoch=epoch+1,active_node=NULL,active_boot=NULL,frozen=0 WHERE retired IS NULL");
@@ -272,7 +275,7 @@ var TravelAuthority = class {
272
275
  }
273
276
  /** Trusted pairing owner binds the first real H to an unused reservation.
274
277
  * This does not grant a lease and never rewrites a used seat's history. */
275
- bindInitialCheckpoint(principal, digest, buildManifestId) {
278
+ bindInitialCheckpoint(principal, digest, buildManifestId, previousDigest) {
276
279
  if (!HASH2.test(digest) || digest === "0".repeat(64)) throw new Error("TRAVEL_INITIAL_BASELINE");
277
280
  id(buildManifestId);
278
281
  const text = identityText(principal);
@@ -281,7 +284,9 @@ var TravelAuthority = class {
281
284
  this.principal(principal);
282
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");
283
286
  if (row.checkpoint === digest) return;
284
- if (row.checkpoint !== "0".repeat(64)) throw new Error("TRAVEL_INITIAL_BASELINE");
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");
285
290
  this.db.prepare("DELETE FROM checkpoints WHERE identity=?").run(text);
286
291
  this.db.prepare("INSERT INTO checkpoints VALUES(?,?,NULL,1)").run(text, digest);
287
292
  this.db.prepare("UPDATE seats SET checkpoint=? WHERE identity=?").run(digest, text);
@@ -352,6 +357,7 @@ var TravelAuthority = class {
352
357
  if (row.active_node && ((this.deadlines.get(text) ?? 0) <= this.monotonicNow() || row.active_boot !== node.boot)) row.epoch++;
353
358
  row.active_node = principal.nodeId;
354
359
  row.active_boot = String(node.boot);
360
+ this.db.prepare("INSERT OR IGNORE INTO leased_seats VALUES(?)").run(text);
355
361
  this.db.prepare("UPDATE seats SET epoch=?,active_node=?,active_boot=? WHERE identity=?").run(row.epoch, row.active_node, row.active_boot, text);
356
362
  this.deadlines.set(text, this.monotonicNow() + this.leaseMs);
357
363
  this.healthy.set(text + principal.nodeId, this.monotonicNow() + this.leaseMs);
@@ -646,7 +652,7 @@ import { createHash as createHash2 } from "node:crypto";
646
652
  // src/continuity/inventory.ts
647
653
  import { isAbsolute, join as join3, relative, resolve as resolve2, sep } from "node:path";
648
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(" "));
649
- 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(" "));
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 topics .nudge hooks inner-voice goals plans private scripts state .voice-chat .desktopBuddy body`.split(" "));
650
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(" "));
651
657
  function validateRelativePath(path2) {
652
658
  if (typeof path2 !== "string" || !path2 || path2.length > 2048 || isAbsolute(path2)) throw new Error("INVALID_ARTIFACT_PATH");
@@ -562,7 +562,11 @@ var TravelController = class {
562
562
  if (!target) throw new Error("TRAVEL_CONTROLLER_IDENTITY");
563
563
  if (job.state === "REQUESTED") {
564
564
  const status = await control.status(target.principal);
565
- if (!status.activeNodeId || status.expired) throw new Error("TRAVEL_CONTROLLER_SOURCE_OFFLINE");
565
+ if (!status.activeNodeId || status.expired) {
566
+ this.db.prepare("UPDATE jobs SET state='ABORTED' WHERE id=?").run(job.id);
567
+ if (status.activeNodeId) await this.options.nodes[status.activeNodeId]?.stop();
568
+ return;
569
+ }
566
570
  if (status.activeNodeId === job.target) {
567
571
  this.db.prepare("UPDATE jobs SET state='DONE' WHERE id=?").run(job.id);
568
572
  return;
@@ -964,7 +968,7 @@ import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
964
968
 
965
969
  // src/continuity/inventory.ts
966
970
  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(" "));
967
- 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(" "));
971
+ 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 topics .nudge hooks inner-voice goals plans private scripts state .voice-chat .desktopBuddy body`.split(" "));
968
972
  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(" "));
969
973
 
970
974
  // src/continuity/publication.ts
@@ -1206,9 +1210,17 @@ var BODY_LIMIT = PUBLICATION_MANIFEST_BYTES + 65536;
1206
1210
  // src/continuity/recovery-archive-transfer.ts
1207
1211
  import { gzipSync, gunzipSync, createGunzip, brotliCompressSync, brotliDecompressSync, createBrotliCompress, createBrotliDecompress, constants as constants3 } from "node:zlib";
1208
1212
 
1209
- // src/continuity/recovery-archive.ts
1213
+ // src/continuity/native-database-snapshot.ts
1210
1214
  import { DatabaseSync as DatabaseSync5, backup } from "node:sqlite";
1211
1215
 
1216
+ // src/continuity/native-file-copy.ts
1217
+ import { execFile } from "node:child_process";
1218
+ import { promisify } from "node:util";
1219
+ var exec = promisify(execFile);
1220
+
1221
+ // src/continuity/recovery-archive.ts
1222
+ import { DatabaseSync as DatabaseSync6 } from "node:sqlite";
1223
+
1212
1224
  // src/continuity/crypto.ts
1213
1225
  var MAGIC2 = Buffer.from("E7OBJ001");
1214
1226
  var HEADER_SIZE = MAGIC2.length + 12;
@@ -1305,7 +1317,7 @@ if (process.argv[1] && /[\\/](controller-main\.ts|travel-controller\.mjs)$/.test
1305
1317
  }
1306
1318
 
1307
1319
  // src/continuity/console-manager.ts
1308
- import { DatabaseSync as DatabaseSync6 } from "node:sqlite";
1320
+ import { DatabaseSync as DatabaseSync7 } from "node:sqlite";
1309
1321
  import { join as join4 } from "node:path";
1310
1322
  import { randomUUID as randomUUID3 } from "node:crypto";
1311
1323
  var travelConsoleActions = ["status", "auto_on", "auto_off", "sync", "to_cloud", "to_local", "recover", "finish"];
@@ -1320,7 +1332,7 @@ var TravelConsoleManager = class {
1320
1332
  preparePrivateDirectory(options.directory);
1321
1333
  const file = join4(options.directory, "console.sqlite");
1322
1334
  preparePrivateDatabase(file);
1323
- this.db = new DatabaseSync6(file);
1335
+ this.db = new DatabaseSync7(file);
1324
1336
  try {
1325
1337
  this.db.exec("PRAGMA synchronous=FULL;CREATE TABLE IF NOT EXISTS binding(value TEXT NOT NULL)");
1326
1338
  const binding = JSON.stringify([options.identity, values.map((n) => [n.principal.nodeId, n.principal.role]).sort()]), prior = this.db.prepare("SELECT value FROM binding").all();
@@ -1596,7 +1608,7 @@ function createTravelConsoleServer(options) {
1596
1608
 
1597
1609
  // src/continuity/console-retirement.ts
1598
1610
  import { existsSync as existsSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync3, renameSync, realpathSync as realpathSync5, unlinkSync as unlinkSync2 } from "node:fs";
1599
- import { DatabaseSync as DatabaseSync10 } from "node:sqlite";
1611
+ import { DatabaseSync as DatabaseSync11 } from "node:sqlite";
1600
1612
  import { dirname as dirname5, join as join9, isAbsolute as isAbsolute6, resolve as resolve7 } from "node:path";
1601
1613
  import { createHash as createHash7, randomUUID as randomUUID5 } from "node:crypto";
1602
1614
 
@@ -1604,8 +1616,8 @@ import { createHash as createHash7, randomUUID as randomUUID5 } from "node:crypt
1604
1616
  import { readFileSync as readFileSync6, existsSync as existsSync3 } from "node:fs";
1605
1617
  import { isAbsolute as isAbsolute5, resolve as resolve6 } from "node:path";
1606
1618
  import { fileURLToPath as fileURLToPath2 } from "node:url";
1607
- import { execFile } from "node:child_process";
1608
- import { promisify } from "node:util";
1619
+ import { execFile as execFile2 } from "node:child_process";
1620
+ import { promisify as promisify2 } from "node:util";
1609
1621
  import { createHash as createHash6 } from "node:crypto";
1610
1622
 
1611
1623
  // src/continuity/user-seat-resource.ts
@@ -1668,7 +1680,7 @@ var UserSeatResource = class {
1668
1680
  };
1669
1681
 
1670
1682
  // src/continuity/retirement.ts
1671
- import { DatabaseSync as DatabaseSync7 } from "node:sqlite";
1683
+ import { DatabaseSync as DatabaseSync8 } from "node:sqlite";
1672
1684
  import { createHash as createHash2 } from "node:crypto";
1673
1685
  import { existsSync } from "node:fs";
1674
1686
  import { accessSync, constants as constants4, lstatSync as lstatSync3, readdirSync, readFileSync as readFileSync3, readlinkSync, realpathSync as realpathSync2, rmSync } from "node:fs";
@@ -1735,7 +1747,7 @@ var TravelRetirement = class {
1735
1747
  preparePrivateDirectory(options.directory);
1736
1748
  const ownerFile = join5(options.directory, "owner.sqlite");
1737
1749
  preparePrivateDatabase(ownerFile);
1738
- this.owner = new DatabaseSync7(ownerFile);
1750
+ this.owner = new DatabaseSync8(ownerFile);
1739
1751
  try {
1740
1752
  this.owner.exec("CREATE TABLE IF NOT EXISTS owner(id INTEGER);BEGIN IMMEDIATE");
1741
1753
  } catch (error) {
@@ -1744,7 +1756,7 @@ var TravelRetirement = class {
1744
1756
  }
1745
1757
  const file = join5(options.directory, "retirement.sqlite");
1746
1758
  preparePrivateDatabase(file);
1747
- this.db = new DatabaseSync7(file);
1759
+ this.db = new DatabaseSync8(file);
1748
1760
  try {
1749
1761
  this.db.exec("PRAGMA synchronous=FULL;CREATE TABLE IF NOT EXISTS job(id TEXT PRIMARY KEY,binding TEXT NOT NULL,state TEXT NOT NULL,stopped INTEGER NOT NULL DEFAULT 0);CREATE TABLE IF NOT EXISTS resources(id TEXT PRIMARY KEY,inventory TEXT,state TEXT NOT NULL)");
1750
1762
  const binding = JSON.stringify([identity(options.identity), options.resources.map((resource) => [resource.id, resource.path ?? null]).sort(), options.accountOwnerRequestedKeyDestruction === true]);
@@ -1839,7 +1851,7 @@ var TravelRetirement = class {
1839
1851
 
1840
1852
  // src/continuity/local-exit.ts
1841
1853
  import { cpSync, existsSync as existsSync2, mkdirSync as mkdirSync5, readFileSync as readFileSync5, readdirSync as readdirSync3, realpathSync as realpathSync4, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
1842
- import { DatabaseSync as DatabaseSync9 } from "node:sqlite";
1854
+ import { DatabaseSync as DatabaseSync10 } from "node:sqlite";
1843
1855
  import { isAbsolute as isAbsolute4, join as join8, dirname as dirname4, resolve as resolve5 } from "node:path";
1844
1856
  import { createHash as createHash5, verify as verify2 } from "node:crypto";
1845
1857
 
@@ -1942,7 +1954,7 @@ async function withCheckpointLock(stateDir, operation) {
1942
1954
  }
1943
1955
 
1944
1956
  // src/continuity/local-dedupe.ts
1945
- import { DatabaseSync as DatabaseSync8 } from "node:sqlite";
1957
+ import { DatabaseSync as DatabaseSync9 } from "node:sqlite";
1946
1958
  import { createHash as createHash3 } from "node:crypto";
1947
1959
  import { dirname as dirname3 } from "node:path";
1948
1960
  var sha2 = (value) => createHash3("sha256").update(value).digest("hex");
@@ -1953,7 +1965,7 @@ var PlatformReceiptStore = class {
1953
1965
  if (!namespace || namespace.length > 1024) throw new Error("PLATFORM_RECEIPT_IDENTITY");
1954
1966
  preparePrivateDirectory(dirname3(file));
1955
1967
  preparePrivateDatabase(file);
1956
- this.db = new DatabaseSync8(file);
1968
+ this.db = new DatabaseSync9(file);
1957
1969
  try {
1958
1970
  this.db.exec("PRAGMA synchronous=FULL;CREATE TABLE IF NOT EXISTS binding(namespace TEXT NOT NULL);CREATE TABLE IF NOT EXISTS inputs(id TEXT PRIMARY KEY,state TEXT NOT NULL);CREATE TABLE IF NOT EXISTS effects(id TEXT PRIMARY KEY,body TEXT NOT NULL);CREATE TABLE IF NOT EXISTS imports(digest TEXT PRIMARY KEY,identity TEXT NOT NULL)");
1959
1971
  const binding = this.db.prepare("SELECT namespace FROM binding").all();
@@ -2083,7 +2095,7 @@ function detachReplication(directory) {
2083
2095
  }
2084
2096
  if (!entry.isFile()) throw new Error("TRAVEL_EXIT_PATH");
2085
2097
  if (!/\.(?:db|sqlite)$/.test(entry.name)) continue;
2086
- const db = new DatabaseSync9(file);
2098
+ const db = new DatabaseSync10(file);
2087
2099
  try {
2088
2100
  if (!db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='e7_replication_control'").get()) continue;
2089
2101
  db.exec("BEGIN IMMEDIATE");
@@ -2154,7 +2166,7 @@ async function createOrdinaryLocalRecovery(options) {
2154
2166
  }
2155
2167
 
2156
2168
  // src/continuity/retirement-main.ts
2157
- var command = promisify(execFile);
2169
+ var command = promisify2(execFile2);
2158
2170
  var sha4 = (value) => createHash6("sha256").update(value).digest("hex");
2159
2171
  var path2 = (value) => {
2160
2172
  if (typeof value !== "string" || !isAbsolute5(value) || resolve6(value) !== value) throw new Error("TRAVEL_RETIREMENT_PATH");
@@ -2277,7 +2289,7 @@ function createTravelConsoleRetirement(options) {
2277
2289
  const prepared = pending();
2278
2290
  return existsSync4(config.localRecoveryReceiptFile) || prepared ? { jobId: config.jobId, state: recovery === "ready" ? "LOCAL_READY" : prepared?.state ?? "RECOVERY_REQUIRED", recovery } : void 0;
2279
2291
  }
2280
- const db = new DatabaseSync10(file, { readOnly: true });
2292
+ const db = new DatabaseSync11(file, { readOnly: true });
2281
2293
  try {
2282
2294
  const row = db.prepare("SELECT id,state,stopped FROM job").get();
2283
2295
  if (!row || row.id !== config.jobId) throw new Error("TRAVEL_CONSOLE_CONFIG");
@@ -344,7 +344,11 @@ var TravelController = class {
344
344
  if (!target) throw new Error("TRAVEL_CONTROLLER_IDENTITY");
345
345
  if (job.state === "REQUESTED") {
346
346
  const status = await control.status(target.principal);
347
- if (!status.activeNodeId || status.expired) throw new Error("TRAVEL_CONTROLLER_SOURCE_OFFLINE");
347
+ if (!status.activeNodeId || status.expired) {
348
+ this.db.prepare("UPDATE jobs SET state='ABORTED' WHERE id=?").run(job.id);
349
+ if (status.activeNodeId) await this.options.nodes[status.activeNodeId]?.stop();
350
+ return;
351
+ }
348
352
  if (status.activeNodeId === job.target) {
349
353
  this.db.prepare("UPDATE jobs SET state='DONE' WHERE id=?").run(job.id);
350
354
  return;
@@ -748,7 +752,7 @@ import { createHash } from "node:crypto";
748
752
  // src/continuity/inventory.ts
749
753
  import { isAbsolute, join as join3, relative, resolve as resolve2, sep } from "node:path";
750
754
  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(" "));
751
- 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(" "));
755
+ 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 topics .nudge hooks inner-voice goals plans private scripts state .voice-chat .desktopBuddy body`.split(" "));
752
756
  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(" "));
753
757
  function validateRelativePath(path2) {
754
758
  if (typeof path2 !== "string" || !path2 || path2.length > 2048 || isAbsolute(path2)) throw new Error("INVALID_ARTIFACT_PATH");
@@ -1290,7 +1294,7 @@ function createTravelNodeSupervisorServer(options) {
1290
1294
  } catch (error) {
1291
1295
  const code = error instanceof Error && nodeSupervisorErrors.has(error.message) ? error.message : "TRAVEL_NODE_REFUSED";
1292
1296
  const reason = error instanceof Error ? /^(?:TRAVEL|RECOVERY|RUNTIME|PUBLICATION|REPLICATION|KEY_SERVICE)_[A-Z_]+/.exec(error.message)?.[0] : void 0;
1293
- if (slot === "operation" || slot === "stop") process.stderr.write("[travel-node] " + (reason ?? code) + "\n");
1297
+ if (slot === "operation" || slot === "stop") process.stderr.write("[travel-node] " + (reason ?? code) + " | original: " + (error?.stack ?? String(error)) + "\n");
1294
1298
  reply(code === "TRAVEL_AUTH_DENIED" ? 403 : 409, { error: code });
1295
1299
  } finally {
1296
1300
  clearTimeout(timer);
@@ -1587,9 +1591,17 @@ import { Agent as Agent4, createServer as createServer3, request as request4 } f
1587
1591
  import { gzipSync, gunzipSync, createGunzip, brotliCompressSync, brotliDecompressSync, createBrotliCompress, createBrotliDecompress, constants as constants3 } from "node:zlib";
1588
1592
  import { pipeline as pipelineAsync } from "node:stream/promises";
1589
1593
 
1590
- // src/continuity/recovery-archive.ts
1594
+ // src/continuity/native-database-snapshot.ts
1591
1595
  import { DatabaseSync as DatabaseSync5, backup } from "node:sqlite";
1592
1596
 
1597
+ // src/continuity/native-file-copy.ts
1598
+ import { execFile } from "node:child_process";
1599
+ import { promisify } from "node:util";
1600
+ var exec = promisify(execFile);
1601
+
1602
+ // src/continuity/recovery-archive.ts
1603
+ import { DatabaseSync as DatabaseSync6 } from "node:sqlite";
1604
+
1593
1605
  // src/continuity/crypto.ts
1594
1606
  var MAGIC2 = Buffer.from("E7OBJ001");
1595
1607
  var HEADER_SIZE = MAGIC2.length + 12;