engine7 7.1.136 → 7.1.137
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 +4 -1
- package/dist/cli.mjs +70 -9
- package/dist/engine-startup.mjs +120 -10
- package/dist/main.mjs +120 -10
- package/dist/recall-worker.mjs +4 -1
- package/dist/sqlite-maintenance-worker.mjs +4 -1
- package/dist/topics-worker.mjs +4 -1
- package/dist/travel-console.mjs +1 -0
- package/dist/travel-data.mjs +4 -1
- package/dist/travel-gateway.mjs +2 -1
- package/dist/travel-node-data.mjs +9 -3
- package/dist/travel-node.mjs +28 -3
- package/dist/travel-retire.mjs +1 -0
- package/dist/web-console.mjs +1137 -207
- package/package.json +2 -2
- package/templates/config.template.json +1 -1
package/dist/bg-worker.mjs
CHANGED
|
@@ -402,6 +402,8 @@ function assertControlPermissions(file) {
|
|
|
402
402
|
}
|
|
403
403
|
function assertStateDirUsable(stateDir2) {
|
|
404
404
|
if (typeof stateDir2 !== "string" || !stateDir2.trim()) throw new Error("RUNTIME_STATE_DIR_REQUIRED");
|
|
405
|
+
const initial = initialBaselineAdmission.getStore();
|
|
406
|
+
if (initial?.active && initial.roots.has(realpathSync(stateDir2))) return;
|
|
405
407
|
try {
|
|
406
408
|
lstatSync2(join2(stateDir2, ".travel-restored.json"));
|
|
407
409
|
throw new Error("TRAVEL_ACTIVATION_REQUIRED");
|
|
@@ -462,7 +464,7 @@ function registerRuntimeWriter(stateDir2, kind) {
|
|
|
462
464
|
}
|
|
463
465
|
return release;
|
|
464
466
|
}
|
|
465
|
-
var sqlite, bootId, releases, exitHookInstalled, recoveryWriterLocks;
|
|
467
|
+
var sqlite, bootId, releases, exitHookInstalled, recoveryWriterLocks, initialBaselineAdmission;
|
|
466
468
|
var init_runtime_lock = __esm({
|
|
467
469
|
"src/continuity/runtime-lock.ts"() {
|
|
468
470
|
"use strict";
|
|
@@ -471,6 +473,7 @@ var init_runtime_lock = __esm({
|
|
|
471
473
|
releases = /* @__PURE__ */ new Set();
|
|
472
474
|
exitHookInstalled = false;
|
|
473
475
|
recoveryWriterLocks = new AsyncLocalStorage();
|
|
476
|
+
initialBaselineAdmission = new AsyncLocalStorage();
|
|
474
477
|
}
|
|
475
478
|
});
|
|
476
479
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1590,6 +1590,8 @@ function assertControlPermissions(file2) {
|
|
|
1590
1590
|
}
|
|
1591
1591
|
function assertStateDirUsable(stateDir) {
|
|
1592
1592
|
if (typeof stateDir !== "string" || !stateDir.trim()) throw new Error("RUNTIME_STATE_DIR_REQUIRED");
|
|
1593
|
+
const initial = initialBaselineAdmission.getStore();
|
|
1594
|
+
if (initial?.active && initial.roots.has(realpathSync2(stateDir))) return;
|
|
1593
1595
|
try {
|
|
1594
1596
|
lstatSync3(join4(stateDir, ".travel-restored.json"));
|
|
1595
1597
|
throw new Error("TRAVEL_ACTIVATION_REQUIRED");
|
|
@@ -1722,7 +1724,25 @@ async function withCheckpointLock(stateDir, operation) {
|
|
|
1722
1724
|
db2.close();
|
|
1723
1725
|
}
|
|
1724
1726
|
}
|
|
1725
|
-
|
|
1727
|
+
async function withRecoveryWriterLocks(stateDirs, operation) {
|
|
1728
|
+
if (!Array.isArray(stateDirs) || stateDirs.length < 1 || stateDirs.length > 64) throw new Error("RECOVERY_WRITER_ROOTS");
|
|
1729
|
+
const roots = [...new Set(stateDirs.map((root) => realpathSync2(root)))].sort();
|
|
1730
|
+
const held = { roots: new Set(roots), active: false };
|
|
1731
|
+
let locked = () => recoveryWriterLocks.run(held, async () => {
|
|
1732
|
+
held.active = true;
|
|
1733
|
+
try {
|
|
1734
|
+
return await operation();
|
|
1735
|
+
} finally {
|
|
1736
|
+
held.active = false;
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
for (const root of [...roots].reverse()) {
|
|
1740
|
+
const next = locked;
|
|
1741
|
+
locked = () => withCheckpointLock(root, next);
|
|
1742
|
+
}
|
|
1743
|
+
return locked();
|
|
1744
|
+
}
|
|
1745
|
+
var sqlite, bootId, releases, checkpointHandles, exitHookInstalled, recoveryWriterLocks, initialBaselineAdmission;
|
|
1726
1746
|
var init_runtime_lock = __esm({
|
|
1727
1747
|
"src/continuity/runtime-lock.ts"() {
|
|
1728
1748
|
"use strict";
|
|
@@ -1732,6 +1752,7 @@ var init_runtime_lock = __esm({
|
|
|
1732
1752
|
checkpointHandles = /* @__PURE__ */ new Set();
|
|
1733
1753
|
exitHookInstalled = false;
|
|
1734
1754
|
recoveryWriterLocks = new AsyncLocalStorage2();
|
|
1755
|
+
initialBaselineAdmission = new AsyncLocalStorage2();
|
|
1735
1756
|
}
|
|
1736
1757
|
});
|
|
1737
1758
|
|
|
@@ -17855,7 +17876,7 @@ var init_context_window_policy = __esm({
|
|
|
17855
17876
|
"src/config/context-window-policy.ts"() {
|
|
17856
17877
|
"use strict";
|
|
17857
17878
|
DEFAULT_CONTEXT_WINDOW = 35e4;
|
|
17858
|
-
CONTEXT_WINDOW_MIGRATION_VERSION =
|
|
17879
|
+
CONTEXT_WINDOW_MIGRATION_VERSION = 2;
|
|
17859
17880
|
}
|
|
17860
17881
|
});
|
|
17861
17882
|
|
|
@@ -33658,13 +33679,13 @@ function startCcDriver(channelManager) {
|
|
|
33658
33679
|
console.warn(`[cc-driver] \u542F\u52A8\u8DF3\u8FC7\uFF1Aconfig \u65E0 stateDir\uFF08\u5F02\u5E38\u914D\u7F6E\uFF0Csession-map \u65E0\u5904\u843D\u76D8\uFF09`);
|
|
33659
33680
|
return;
|
|
33660
33681
|
}
|
|
33682
|
+
ccDriverRouter.setCm(channelManager);
|
|
33661
33683
|
const parsed = parseCcDriverConfig(cfg?.channels?.ccDriver);
|
|
33662
33684
|
if (!parsed.enabled) {
|
|
33663
33685
|
console.log(`[cc-driver] disabled (channels.ccDriver.enabled !== true \u6216\u65E0\u6709\u6548 binding)`);
|
|
33664
33686
|
return;
|
|
33665
33687
|
}
|
|
33666
33688
|
const hub2 = new CcDriverHub(parsed, channelManager, cfg.stateDir, stoppedWriters);
|
|
33667
|
-
ccDriverRouter.setCm(channelManager);
|
|
33668
33689
|
ccDriverRouter.setHub(hub2);
|
|
33669
33690
|
try {
|
|
33670
33691
|
unregisterHub = registerCcHub(hub2, cfg.stateDir, computeApiPort(cfg));
|
|
@@ -33714,10 +33735,39 @@ var init_cc_driver = __esm({
|
|
|
33714
33735
|
// src/cc-driver/router.ts
|
|
33715
33736
|
var router_exports = {};
|
|
33716
33737
|
__export(router_exports, {
|
|
33738
|
+
autoBindHit: () => autoBindHit,
|
|
33717
33739
|
ccDriverRouter: () => ccDriverRouter,
|
|
33718
33740
|
markBindSelect: () => markBindSelect
|
|
33719
33741
|
});
|
|
33720
33742
|
import { existsSync as existsSync25 } from "node:fs";
|
|
33743
|
+
function autoBindHit(inbound) {
|
|
33744
|
+
if (inbound.channel !== "feishu" || inbound.channelType !== "dm") return null;
|
|
33745
|
+
const owner = liveConfig.get("channels.feishu.ownerOpenId");
|
|
33746
|
+
const workDir = liveConfig.get("channels.ccDriver.autoBind.workDir");
|
|
33747
|
+
if (!owner || !workDir || inbound.from !== owner) return null;
|
|
33748
|
+
const cur = liveConfig.get("channels.ccDriver");
|
|
33749
|
+
if (cur?.enabled === false) return null;
|
|
33750
|
+
if ((cur?.bindings ?? []).length > 0) return null;
|
|
33751
|
+
return workDir;
|
|
33752
|
+
}
|
|
33753
|
+
async function doAutoBind(inbound, workDir) {
|
|
33754
|
+
if (!cmRef) return;
|
|
33755
|
+
const binding = {
|
|
33756
|
+
channel: inbound.channel,
|
|
33757
|
+
match: { type: "dm", chatId: inbound.channel_id, from: inbound.from },
|
|
33758
|
+
workDir
|
|
33759
|
+
};
|
|
33760
|
+
const cur = liveConfig.get("channels.ccDriver");
|
|
33761
|
+
const bindings = (cur?.bindings ?? []).filter((b) => !(b.channel === binding.channel && b.match.chatId === binding.match.chatId));
|
|
33762
|
+
bindings.push(binding);
|
|
33763
|
+
const { autoBind: _consumed, ...rest } = cur ?? {};
|
|
33764
|
+
const persisted = await liveConfig.set("channels.ccDriver", { ...rest, enabled: true, bindings }, { atomic: true });
|
|
33765
|
+
const { startCcDriver: startCcDriver2 } = await Promise.resolve().then(() => (init_cc_driver(), cc_driver_exports));
|
|
33766
|
+
startCcDriver2(cmRef);
|
|
33767
|
+
console.log(`[cc-driver] autoBind ${inbound.channel}:${inbound.channel_id} \u2192 ${workDir}\uFF08\u4E00\u6B21\u6027\uFF0C\u5DF2\u81EA\u5220\uFF1Bpersisted=${persisted}\uFF09`);
|
|
33768
|
+
await cmRef.send(inbound.channel, inbound.channel_id, persisted ? `\u2705 \u5DF2\u63A5\u5165 CC\uFF08${workDir}\uFF09\u2014\u2014\u518D\u8BF4\u4E00\u53E5\u8BDD\u5C31\u5F00\u59CB\u3002
|
|
33769
|
+
/cc-list \u770B\u4F1A\u8BDD\uFF0C/cc-switch \u6362\u7EBF\u3002` : `\u26A0\uFE0F \u5DF2\u63A5\u5165 CC\uFF0C\u4F46\u914D\u7F6E\u6CA1\u5199\u8FDB\u6587\u4EF6\uFF08\u91CD\u542F\u540E\u4F1A\u56DE\u5230\u672A\u7ED1\u5B9A\uFF09\u2014\u2014\u8BF7\u68C0\u67E5\u914D\u7F6E\u6587\u4EF6\u6743\u9650\u540E\u91CD\u8BD5\u3002`);
|
|
33770
|
+
}
|
|
33721
33771
|
function markBindSelect(channel, chatId) {
|
|
33722
33772
|
pendingBind.set(`${channel}:${chatId}`, Date.now());
|
|
33723
33773
|
while (pendingBind.size > 32) {
|
|
@@ -33753,7 +33803,7 @@ async function bindByNumber(inbound) {
|
|
|
33753
33803
|
const cur = liveConfig.get("channels.ccDriver");
|
|
33754
33804
|
const bindings = (cur?.bindings ?? []).filter((b) => !(b.channel === binding.channel && b.match.chatId === binding.match.chatId));
|
|
33755
33805
|
bindings.push(binding);
|
|
33756
|
-
liveConfig.set("channels.ccDriver", { enabled: true, bindings });
|
|
33806
|
+
liveConfig.set("channels.ccDriver", { ...cur ?? {}, enabled: true, bindings });
|
|
33757
33807
|
pendingBind.delete(`${inbound.channel}:${inbound.channel_id}`);
|
|
33758
33808
|
const { startCcDriver: startCcDriver2 } = await Promise.resolve().then(() => (init_cc_driver(), cc_driver_exports));
|
|
33759
33809
|
startCcDriver2(cmRef);
|
|
@@ -33786,6 +33836,7 @@ var init_router = __esm({
|
|
|
33786
33836
|
/** 未启用秒回 false,管线零开销 */
|
|
33787
33837
|
matches(inbound) {
|
|
33788
33838
|
if (hub && hub.matches(inbound)) return true;
|
|
33839
|
+
if (autoBindHit(inbound)) return true;
|
|
33789
33840
|
return peekBindNumber(inbound) !== null;
|
|
33790
33841
|
},
|
|
33791
33842
|
/** 永不抛——命中处理失败只打日志,消息吃掉(不回落 agent,避免同一句话两头跑) */
|
|
@@ -33795,7 +33846,12 @@ var init_router = __esm({
|
|
|
33795
33846
|
hub.route(inbound);
|
|
33796
33847
|
return;
|
|
33797
33848
|
}
|
|
33798
|
-
if (peekBindNumber(inbound) !== null)
|
|
33849
|
+
if (peekBindNumber(inbound) !== null) {
|
|
33850
|
+
await bindByNumber(inbound);
|
|
33851
|
+
return;
|
|
33852
|
+
}
|
|
33853
|
+
const autoWorkDir = autoBindHit(inbound);
|
|
33854
|
+
if (autoWorkDir) await doAutoBind(inbound, autoWorkDir);
|
|
33799
33855
|
} catch (err) {
|
|
33800
33856
|
console.error(`[cc-driver] route \u5931\u8D25\uFF08\u6D88\u606F\u5DF2\u5403\u6389\uFF09: ${err?.stack || err}`);
|
|
33801
33857
|
}
|
|
@@ -61156,20 +61212,25 @@ async function captureCheckpoint(options) {
|
|
|
61156
61212
|
const plain = join96(privatePlain.path, "plain"), objects = join96(stage, "objects");
|
|
61157
61213
|
await mkdir9(plain, { mode: 448 });
|
|
61158
61214
|
await mkdir9(objects, { mode: 448 });
|
|
61159
|
-
const manifest = await
|
|
61160
|
-
|
|
61215
|
+
const manifest = await withRecoveryWriterLocks([options.stateDir, workspace], async () => {
|
|
61216
|
+
let inventory = await collectInventory(options);
|
|
61161
61217
|
const { realpath: realpath4 } = await import("node:fs/promises");
|
|
61162
61218
|
const canonicalOutput = join96(await realpath4(dirname33(resolve36(options.output))), basename20(resolve36(options.output)));
|
|
61163
61219
|
if (Object.values(inventory.roots).some((root) => isWithin(root, canonicalOutput))) throw new Error("OVERLAPPING_PATHS");
|
|
61164
61220
|
const files = [], connections = [];
|
|
61165
61221
|
try {
|
|
61222
|
+
for (const entry of inventory.entries) if (entry.kind === "sqlite") {
|
|
61223
|
+
const db2 = new sqlite2.DatabaseSync(entry.source, { readOnly: true });
|
|
61224
|
+
connections.push({ db: db2, version: db2.prepare("PRAGMA data_version").get().data_version, file: entry.source });
|
|
61225
|
+
}
|
|
61226
|
+
inventory = await collectInventory(options);
|
|
61166
61227
|
for (const entry of inventory.entries) {
|
|
61167
61228
|
if (entry.kind === "directory" || entry.kind === "sidecar") continue;
|
|
61168
61229
|
const objectId = randomUUID33(), destination = join96(plain, objectId);
|
|
61169
61230
|
let fingerprint2;
|
|
61170
61231
|
if (entry.kind === "sqlite") {
|
|
61171
|
-
const db2 =
|
|
61172
|
-
|
|
61232
|
+
const db2 = connections.find((connection) => connection.file === entry.source)?.db;
|
|
61233
|
+
if (!db2) throw new Error("SOURCE_CHANGED");
|
|
61173
61234
|
const backup2 = sqlite2.backup;
|
|
61174
61235
|
if (!backup2) throw new Error("NODE_SQLITE_BACKUP_REQUIRED");
|
|
61175
61236
|
await backup2(db2, destination);
|