engine7 7.1.143 → 7.1.144
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 +62 -9
- package/dist/cc-desktop.mjs +9 -0
- package/dist/cli.mjs +1960 -755
- package/dist/engine-startup.mjs +1001 -548
- package/dist/main.mjs +1001 -548
- package/dist/recall-worker.mjs +62 -9
- package/dist/topics-worker.mjs +132 -40
- package/dist/travel-gateway.mjs +186 -65
- package/dist/travel-host.mjs +600 -460
- package/dist/travel-node.mjs +29 -0
- package/dist/travel-oss-pull.mjs +389 -0
- package/dist/travel-oss-return.mjs +563 -0
- package/dist/travel-pairing.mjs +206 -85
- package/dist/web-console.mjs +448 -265
- package/package.json +1 -1
package/dist/travel-pairing.mjs
CHANGED
|
@@ -2499,15 +2499,15 @@ var init_context_time = __esm({
|
|
|
2499
2499
|
});
|
|
2500
2500
|
|
|
2501
2501
|
// src/mem7/core/state/knowledge-history.ts
|
|
2502
|
-
function knowledgeCutoff(db2, scope,
|
|
2503
|
-
if (
|
|
2504
|
-
if (
|
|
2502
|
+
function knowledgeCutoff(db2, scope, request4) {
|
|
2503
|
+
if (request4.knownAt === void 0 && request4.knownAtRevision === void 0) return void 0;
|
|
2504
|
+
if (request4.knownAt !== void 0 && request4.knownAtRevision !== void 0) throw new Error("AMBIGUOUS_KNOWLEDGE_TIME");
|
|
2505
2505
|
const id3 = scopeId(scope);
|
|
2506
|
-
const time =
|
|
2507
|
-
const checkpoint =
|
|
2506
|
+
const time = request4.knownAt === void 0 ? null : instant(request4.knownAt);
|
|
2507
|
+
const checkpoint = request4.knownAtRevision === void 0 ? void 0 : db2.prepare("SELECT history_id FROM memory_knowledge_checkpoints WHERE scope_id=? AND fact_revision=?").get(id3, request4.knownAtRevision);
|
|
2508
2508
|
const historyId = time ? Number(db2.prepare("SELECT COALESCE(MAX(history_id),0) history_id FROM memory_knowledge_history WHERE scope_id=? AND recorded_at<=?").get(id3, time).history_id) : Number(checkpoint?.history_id ?? 0);
|
|
2509
2509
|
const baseline = db2.prepare("SELECT history_id FROM memory_knowledge_history WHERE scope_id=? AND target_kind='coverage' ORDER BY history_id LIMIT 1").get(id3);
|
|
2510
|
-
return { historyId, time, complete: (!baseline || historyId >= baseline.history_id) && (
|
|
2510
|
+
return { historyId, time, complete: (!baseline || historyId >= baseline.history_id) && (request4.knownAtRevision === void 0 || request4.knownAtRevision === 0 || Boolean(checkpoint)) };
|
|
2511
2511
|
}
|
|
2512
2512
|
function journalEntityCutoff(db2, scope, revision) {
|
|
2513
2513
|
const row = db2.prepare("SELECT history_id FROM memory_entity_checkpoints WHERE scope_id=? AND entity_revision<=? ORDER BY entity_revision DESC LIMIT 1").get(scopeId(scope), revision);
|
|
@@ -7683,13 +7683,13 @@ CREATE TABLE memory_relationship_receipts (
|
|
|
7683
7683
|
JOIN memory_relationship_versions r ON r.scope_id=h.scope_id AND r.relationship_id=h.relationship_id AND r.semantic_version=h.semantic_version
|
|
7684
7684
|
JOIN fact_assertions a ON a.scope_id=r.scope_id AND a.assertion_id=r.assertion_id
|
|
7685
7685
|
WHERE h.scope_id=? AND h.perspective_entity_id=? AND h.subject_id=? AND h.object_id=?`);
|
|
7686
|
-
for (const
|
|
7687
|
-
const endpoints = [[
|
|
7688
|
-
if (
|
|
7686
|
+
for (const request4 of requests) {
|
|
7687
|
+
const endpoints = [[request4.subjectId, request4.objectId]];
|
|
7688
|
+
if (request4.direction === "symmetric") endpoints.push([request4.objectId, request4.subjectId]);
|
|
7689
7689
|
for (const [subject, object3] of endpoints) {
|
|
7690
|
-
for (const row of query.all(scopeId(scope),
|
|
7690
|
+
for (const row of query.all(scopeId(scope), request4.perspectiveEntityId, subject, object3)) {
|
|
7691
7691
|
const value = JSON.parse(row.value_json);
|
|
7692
|
-
if (value.contentKind ===
|
|
7692
|
+
if (value.contentKind === request4.contentKind && value.temporalScope === request4.temporalScope) ids.add(row.relationship_id);
|
|
7693
7693
|
}
|
|
7694
7694
|
}
|
|
7695
7695
|
}
|
|
@@ -10620,8 +10620,8 @@ CREATE TABLE IF NOT EXISTS cluster_members (
|
|
|
10620
10620
|
socialInterpretations;
|
|
10621
10621
|
relationshipCognition;
|
|
10622
10622
|
relationshipNotices;
|
|
10623
|
-
knowledgeCutoff(scope,
|
|
10624
|
-
return knowledgeCutoff(this.db, scope,
|
|
10623
|
+
knowledgeCutoff(scope, request4) {
|
|
10624
|
+
return knowledgeCutoff(this.db, scope, request4);
|
|
10625
10625
|
}
|
|
10626
10626
|
knowledgeSnapshot(scope, cutoff) {
|
|
10627
10627
|
return historicalRows(this.db, scope, "scope", cutoff)[0] ?? { entityRevision: 0, factRevision: 0, contextRevision: 0, sourceSeq: 0, interpretedSeq: 0 };
|
|
@@ -10854,6 +10854,35 @@ CREATE TABLE IF NOT EXISTS cluster_members (
|
|
|
10854
10854
|
};
|
|
10855
10855
|
}, scope, version);
|
|
10856
10856
|
}
|
|
10857
|
+
/** 1123 跨轮去重(md):entry id 由正文决定、所在文件由日期决定——日期判定跨轮漂移时新块落到
|
|
10858
|
+
* 另一个日期文件,appendMd 的原位替换只扫目标文件,旧块留成孤儿(妹妹 1122 重洗 44 处双份)。
|
|
10859
|
+
* 单遍扫 episodes:id 在本轮写入表里、但所在文件 ≠ 本轮目标日期的块删掉,entry_count 同步。
|
|
10860
|
+
* 不在本轮写入表里的条目不碰(别的来源/原生记忆)。 */
|
|
10861
|
+
purgeEpisodeEntries(ownerId, targetDateById) {
|
|
10862
|
+
if (!targetDateById.size) return 0;
|
|
10863
|
+
const dir = join12(this.root, "users", ownerId, "episodes");
|
|
10864
|
+
if (!existsSync5(dir)) return 0;
|
|
10865
|
+
let removed = 0;
|
|
10866
|
+
for (const name of readdirSync(dir)) {
|
|
10867
|
+
const fileDate = /^episode-(\d{4}-\d{2}-\d{2})\.md$/.exec(name)?.[1];
|
|
10868
|
+
if (!fileDate) continue;
|
|
10869
|
+
const file2 = join12(dir, name);
|
|
10870
|
+
let text2 = readFileSync8(file2, "utf8"), hit = false;
|
|
10871
|
+
for (const m of text2.matchAll(/<!-- entry:(\S+) -->/g)) {
|
|
10872
|
+
const target = targetDateById.get(m[1]);
|
|
10873
|
+
if (target === void 0 || target === fileDate) continue;
|
|
10874
|
+
text2 = text2.replace(new RegExp(`\\n*<!-- entry:${m[1]} -->[\\s\\S]*?<!-- /entry:${m[1]} -->`), "");
|
|
10875
|
+
removed++;
|
|
10876
|
+
hit = true;
|
|
10877
|
+
}
|
|
10878
|
+
if (!hit) continue;
|
|
10879
|
+
text2 = text2.replace(/entry_count: \d+/, `entry_count: ${(text2.match(/<!-- entry:/g) ?? []).length}`);
|
|
10880
|
+
const tmp = `${file2}.${process.pid}.tmp`;
|
|
10881
|
+
writeFileSync6(tmp, text2);
|
|
10882
|
+
renameSync3(tmp, file2);
|
|
10883
|
+
}
|
|
10884
|
+
return removed;
|
|
10885
|
+
}
|
|
10857
10886
|
appendAtomicFacts(ownerId, dateStr, entries, scope, version) {
|
|
10858
10887
|
const flat2 = [];
|
|
10859
10888
|
for (const e of entries) {
|
|
@@ -13238,6 +13267,52 @@ var init_session_map = __esm({
|
|
|
13238
13267
|
}
|
|
13239
13268
|
});
|
|
13240
13269
|
|
|
13270
|
+
// src/cc-driver/long-http.ts
|
|
13271
|
+
import { request as request3 } from "node:http";
|
|
13272
|
+
function longPostJson(url, body, headers = {}, signal) {
|
|
13273
|
+
const data = Buffer.from(JSON.stringify(body));
|
|
13274
|
+
return new Promise((resolve13, reject) => {
|
|
13275
|
+
const req = request3(url, { method: "POST", headers: { ...headers, "Content-Length": String(data.byteLength) } }, (res) => {
|
|
13276
|
+
const chunks = [];
|
|
13277
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
13278
|
+
res.on("error", reject);
|
|
13279
|
+
res.on("end", () => {
|
|
13280
|
+
cleanup();
|
|
13281
|
+
const text2 = Buffer.concat(chunks).toString("utf8");
|
|
13282
|
+
try {
|
|
13283
|
+
resolve13({ status: res.statusCode ?? 0, json: JSON.parse(text2) });
|
|
13284
|
+
} catch {
|
|
13285
|
+
reject(new Error(`\u5BF9\u7AEF\u8FD4\u56DE\u4E86\u975E JSON\uFF08HTTP ${res.statusCode}\uFF09\uFF1A${text2.slice(0, 200)}`));
|
|
13286
|
+
}
|
|
13287
|
+
});
|
|
13288
|
+
});
|
|
13289
|
+
req.on("error", (err) => {
|
|
13290
|
+
cleanup();
|
|
13291
|
+
reject(err);
|
|
13292
|
+
});
|
|
13293
|
+
const onAbort = () => {
|
|
13294
|
+
req.destroy();
|
|
13295
|
+
reject(signal.reason instanceof Error ? signal.reason : new Error("\u8BF7\u6C42\u5DF2\u53D6\u6D88"));
|
|
13296
|
+
};
|
|
13297
|
+
const cleanup = () => {
|
|
13298
|
+
signal?.removeEventListener("abort", onAbort);
|
|
13299
|
+
};
|
|
13300
|
+
if (signal) {
|
|
13301
|
+
if (signal.aborted) {
|
|
13302
|
+
onAbort();
|
|
13303
|
+
return;
|
|
13304
|
+
}
|
|
13305
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
13306
|
+
}
|
|
13307
|
+
req.end(data);
|
|
13308
|
+
});
|
|
13309
|
+
}
|
|
13310
|
+
var init_long_http = __esm({
|
|
13311
|
+
"src/cc-driver/long-http.ts"() {
|
|
13312
|
+
"use strict";
|
|
13313
|
+
}
|
|
13314
|
+
});
|
|
13315
|
+
|
|
13241
13316
|
// src/cc-driver/desktop.ts
|
|
13242
13317
|
import fs4 from "node:fs";
|
|
13243
13318
|
import os2 from "node:os";
|
|
@@ -13289,14 +13364,13 @@ async function findDesktopTargets(workDir, sessionId) {
|
|
|
13289
13364
|
return targets;
|
|
13290
13365
|
}
|
|
13291
13366
|
async function askDesktop(target, prompt, source, signal) {
|
|
13292
|
-
const
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
if (!response.ok) throw failure(result.error || `Desktop CC HTTP ${response.status}`, response.status);
|
|
13367
|
+
const { status, json: result } = await longPostJson(
|
|
13368
|
+
`http://127.0.0.1:${target.port}/ask`,
|
|
13369
|
+
{ prompt, source, sessionId: target.sessionId, instance: target.instance, workDir: target.workDir },
|
|
13370
|
+
{ authorization: `Bearer ${target.token}` },
|
|
13371
|
+
signal
|
|
13372
|
+
);
|
|
13373
|
+
if (status !== 200) throw failure(result?.error || `Desktop CC HTTP ${status}`, status);
|
|
13300
13374
|
if (result.sessionId !== target.sessionId || typeof result.text !== "string" || typeof result.isError !== "boolean") {
|
|
13301
13375
|
throw failure("Desktop CC returned an invalid result");
|
|
13302
13376
|
}
|
|
@@ -13306,6 +13380,7 @@ var registryDir, canonical2, failure, alive;
|
|
|
13306
13380
|
var init_desktop = __esm({
|
|
13307
13381
|
"src/cc-driver/desktop.ts"() {
|
|
13308
13382
|
"use strict";
|
|
13383
|
+
init_long_http();
|
|
13309
13384
|
registryDir = () => process.env.CC_DESKTOP_REGISTRY_DIR || path4.join(os2.homedir(), ".engine7", "cc-driver", "desktops");
|
|
13310
13385
|
canonical2 = (dir) => {
|
|
13311
13386
|
try {
|
|
@@ -13633,6 +13708,8 @@ var init_dep_downloader = __esm({
|
|
|
13633
13708
|
});
|
|
13634
13709
|
|
|
13635
13710
|
// src/cc-driver/driver.ts
|
|
13711
|
+
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync8 } from "node:fs";
|
|
13712
|
+
import { extname, join as join15 } from "node:path";
|
|
13636
13713
|
function requestError(message, status = 409) {
|
|
13637
13714
|
return Object.assign(new Error(message), { status });
|
|
13638
13715
|
}
|
|
@@ -14242,14 +14319,16 @@ ${acc.textSoFar.slice(-FINAL_CHUNK_CHARS)}` : ""));
|
|
|
14242
14319
|
return task;
|
|
14243
14320
|
}
|
|
14244
14321
|
};
|
|
14245
|
-
CcDriverHub = class {
|
|
14322
|
+
CcDriverHub = class _CcDriverHub {
|
|
14246
14323
|
map;
|
|
14247
14324
|
sessions = /* @__PURE__ */ new Map();
|
|
14248
14325
|
cfg;
|
|
14249
14326
|
cm;
|
|
14327
|
+
stateDir;
|
|
14250
14328
|
constructor(cfg, cm, stateDir, predecessor) {
|
|
14251
14329
|
this.cfg = cfg;
|
|
14252
14330
|
this.cm = cm;
|
|
14331
|
+
this.stateDir = stateDir;
|
|
14253
14332
|
this.map = new CcSessionMapStore(stateDir);
|
|
14254
14333
|
for (const b of cfg.bindings) {
|
|
14255
14334
|
this.sessions.set(bindingKey(b), new CcDriverSession(b, cm, this.map, predecessor));
|
|
@@ -14259,15 +14338,49 @@ ${acc.textSoFar.slice(-FINAL_CHUNK_CHARS)}` : ""));
|
|
|
14259
14338
|
matches(inbound) {
|
|
14260
14339
|
return findBinding(inbound, this.cfg) !== null;
|
|
14261
14340
|
}
|
|
14262
|
-
/**
|
|
14341
|
+
/** 落盘附件的体积上限:这条通道只收图/文档,不让大视频把 stateDir 撑爆 */
|
|
14342
|
+
static MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
|
|
14343
|
+
/**
|
|
14344
|
+
* 入站附件落盘(1123 翀哥:「我给你发图片你现在收不到」):CC 会话靠工具读文件——
|
|
14345
|
+
* 图片用 Read 工具直接看,文档走对应 skill。只做落盘+正文附路径,不改 CC 的输入协议。
|
|
14346
|
+
* 落在 <stateDir>/media/inbound(与 my-eyes 等同目录惯例);单个附件失败不影响其它附件和正文。
|
|
14347
|
+
*/
|
|
14348
|
+
async saveAttachments(inbound) {
|
|
14349
|
+
const lines = [];
|
|
14350
|
+
const dir = join15(this.stateDir, "media", "inbound");
|
|
14351
|
+
for (const [i, a] of (inbound.attachments ?? []).entries()) {
|
|
14352
|
+
const label = a.filename || `\u9644\u4EF6${i + 1}`;
|
|
14353
|
+
try {
|
|
14354
|
+
if (!a.loadBytes) throw new Error("\u9002\u914D\u5668\u672A\u63D0\u4F9B\u4E0B\u8F7D\u80FD\u529B");
|
|
14355
|
+
if (a.size > _CcDriverHub.MAX_ATTACHMENT_BYTES) throw new Error(`\u6587\u4EF6\u8FC7\u5927\uFF08${a.size} \u5B57\u8282\uFF09\uFF0C\u672A\u843D\u76D8`);
|
|
14356
|
+
const bytes2 = await a.loadBytes();
|
|
14357
|
+
const ext = extname(a.filename || "").toLowerCase().replace(/[^.a-z0-9]/g, "") || (a.contentType.startsWith("image/") ? "." + a.contentType.slice(6).replace("jpeg", "jpg") : "");
|
|
14358
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
14359
|
+
const tail = (inbound.messageId || "msg").replace(/\W/g, "").slice(-8);
|
|
14360
|
+
const file2 = join15(dir, `${stamp}-${tail}-${i + 1}${ext}`);
|
|
14361
|
+
mkdirSync9(dir, { recursive: true });
|
|
14362
|
+
writeFileSync8(file2, bytes2);
|
|
14363
|
+
const how = a.contentType.startsWith("image/") ? "\u56FE\u7247\u2014\u2014\u7528 Read \u5DE5\u5177\u6253\u5F00\u8FD9\u4E2A\u8DEF\u5F84\u5373\u53EF\u770B\u5230" : `\u6587\u4EF6\uFF08${a.contentType || "\u672A\u77E5\u7C7B\u578B"}\uFF09`;
|
|
14364
|
+
lines.push(`${i + 1}. ${label}\uFF0C${how}\uFF1A${file2}`);
|
|
14365
|
+
} catch (err) {
|
|
14366
|
+
lines.push(`${i + 1}. ${label} \u843D\u76D8\u5931\u8D25\uFF1A${err?.message || String(err)}`);
|
|
14367
|
+
}
|
|
14368
|
+
}
|
|
14369
|
+
return `\uFF08\u6536\u5230 ${lines.length} \u4E2A\u9644\u4EF6\uFF0C\u5DF2\u4FDD\u5B58\u5230\u672C\u673A\uFF1A
|
|
14370
|
+
${lines.join("\n")}\uFF09`;
|
|
14371
|
+
}
|
|
14372
|
+
/** 路由一条命中消息(调用方已 matches 过)。附件先落盘,路径随正文一起进会话(1123)。 */
|
|
14263
14373
|
route(inbound) {
|
|
14264
14374
|
const binding = findBinding(inbound, this.cfg);
|
|
14265
14375
|
if (!binding) return;
|
|
14266
14376
|
const session = this.sessions.get(bindingKey(binding));
|
|
14267
14377
|
if (!session) return;
|
|
14268
14378
|
if (inbound.attachments?.length) {
|
|
14269
|
-
void session.enqueue(`${inbound.content}
|
|
14270
|
-
|
|
14379
|
+
void this.saveAttachments(inbound).then((note) => session.enqueue(inbound.content.trim() ? `${inbound.content}
|
|
14380
|
+
|
|
14381
|
+
${note}` : note)).catch((err) => session.enqueue(`${inbound.content}
|
|
14382
|
+
|
|
14383
|
+
\uFF08\u9644\u4EF6\u5904\u7406\u5931\u8D25\uFF1A${err?.message || String(err)}\uFF09`));
|
|
14271
14384
|
return;
|
|
14272
14385
|
}
|
|
14273
14386
|
session.enqueue(inbound.content);
|
|
@@ -14330,6 +14443,7 @@ function registerCcHub(hub2, stateDir, port) {
|
|
|
14330
14443
|
var init_handoff = __esm({
|
|
14331
14444
|
"src/cc-driver/handoff.ts"() {
|
|
14332
14445
|
"use strict";
|
|
14446
|
+
init_long_http();
|
|
14333
14447
|
init_router();
|
|
14334
14448
|
}
|
|
14335
14449
|
});
|
|
@@ -15812,7 +15926,7 @@ __export(persistence_exports, {
|
|
|
15812
15926
|
normalizeToUtcIso: () => normalizeToUtcIso
|
|
15813
15927
|
});
|
|
15814
15928
|
import { DatabaseSync as DatabaseSync12 } from "node:sqlite";
|
|
15815
|
-
import { mkdirSync as
|
|
15929
|
+
import { mkdirSync as mkdirSync11 } from "node:fs";
|
|
15816
15930
|
import { basename as basename3, dirname as dirname7, resolve as resolve6 } from "node:path";
|
|
15817
15931
|
function rowToAction(r) {
|
|
15818
15932
|
return {
|
|
@@ -15950,7 +16064,7 @@ CREATE INDEX IF NOT EXISTS idx_proactive_decisions_created ON proactive_decision
|
|
|
15950
16064
|
checkRuntimeReplicationFile(dbPath, registration, Boolean(options.replication));
|
|
15951
16065
|
this.releaseRuntimeWriter = registration || options.replication ? registerRuntimeWriter(stateDir, "proactive") : void 0;
|
|
15952
16066
|
try {
|
|
15953
|
-
|
|
16067
|
+
mkdirSync11(dirname7(dbPath), { recursive: true });
|
|
15954
16068
|
this.db = new DatabaseSync12(dbPath);
|
|
15955
16069
|
} catch (error) {
|
|
15956
16070
|
this.releaseRuntimeWriter?.();
|
|
@@ -17503,17 +17617,17 @@ __export(paths_exports, {
|
|
|
17503
17617
|
isAutoMemPath: () => isAutoMemPath,
|
|
17504
17618
|
setMemoryDirOverride: () => setMemoryDirOverride
|
|
17505
17619
|
});
|
|
17506
|
-
import { join as
|
|
17620
|
+
import { join as join28, normalize as normalize5, sep as sep4, isAbsolute as isAbsolute4, resolve as resolve10 } from "node:path";
|
|
17507
17621
|
function setMemoryDirOverride(dir) {
|
|
17508
17622
|
_overrideMemoryDir = dir;
|
|
17509
17623
|
}
|
|
17510
17624
|
function getAutoMemPath(workspace) {
|
|
17511
|
-
const dir = _overrideMemoryDir ? isAbsolute4(_overrideMemoryDir) ? _overrideMemoryDir : resolve10(workspace, _overrideMemoryDir) :
|
|
17625
|
+
const dir = _overrideMemoryDir ? isAbsolute4(_overrideMemoryDir) ? _overrideMemoryDir : resolve10(workspace, _overrideMemoryDir) : join28(workspace, AUTO_MEM_DIRNAME);
|
|
17512
17626
|
const normalized = normalize5(dir);
|
|
17513
17627
|
return (normalized + sep4).normalize("NFC");
|
|
17514
17628
|
}
|
|
17515
17629
|
function getAutoMemEntrypoint(workspace) {
|
|
17516
|
-
return
|
|
17630
|
+
return join28(getAutoMemPath(workspace), ENTRYPOINT_NAME);
|
|
17517
17631
|
}
|
|
17518
17632
|
function isAutoMemPath(absolutePath, workspace) {
|
|
17519
17633
|
const normalizedPath = normalize5(absolutePath);
|
|
@@ -17704,7 +17818,7 @@ __export(memdir_exports, {
|
|
|
17704
17818
|
truncateEntrypointContent: () => truncateEntrypointContent
|
|
17705
17819
|
});
|
|
17706
17820
|
import { readFileSync as readFileSync15 } from "node:fs";
|
|
17707
|
-
import { join as
|
|
17821
|
+
import { join as join29 } from "node:path";
|
|
17708
17822
|
function truncateEntrypointContent(raw) {
|
|
17709
17823
|
const trimmed = raw.trim();
|
|
17710
17824
|
const contentLines = trimmed.split("\n");
|
|
@@ -17797,7 +17911,7 @@ function buildMemoryLines(displayName, memoryDir, extraGuidelines, skipIndex = f
|
|
|
17797
17911
|
}
|
|
17798
17912
|
function buildMemoryPrompt(params) {
|
|
17799
17913
|
const { displayName, memoryDir, extraGuidelines } = params;
|
|
17800
|
-
const entrypoint =
|
|
17914
|
+
const entrypoint = join29(memoryDir, ENTRYPOINT_NAME);
|
|
17801
17915
|
let entrypointContent = "";
|
|
17802
17916
|
try {
|
|
17803
17917
|
entrypointContent = readFileSync15(entrypoint, { encoding: "utf-8" });
|
|
@@ -18196,8 +18310,8 @@ var init_gateway_media = __esm({
|
|
|
18196
18310
|
});
|
|
18197
18311
|
|
|
18198
18312
|
// src/continuity/pairing-control.ts
|
|
18199
|
-
import { writeFileSync as
|
|
18200
|
-
import { join as
|
|
18313
|
+
import { writeFileSync as writeFileSync15, existsSync as existsSync15, rmSync as rmSync3 } from "node:fs";
|
|
18314
|
+
import { join as join32, resolve as resolve12 } from "node:path";
|
|
18201
18315
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
18202
18316
|
import { createServer as createServer4 } from "node:https";
|
|
18203
18317
|
import { timingSafeEqual, X509Certificate, createHash as createHash37 } from "node:crypto";
|
|
@@ -18456,22 +18570,22 @@ var TravelAuthority = class {
|
|
|
18456
18570
|
if (operation !== "CONTROL" && row.frozen) throw new Error("TRAVEL_HANDOFF_FROZEN");
|
|
18457
18571
|
if (operation !== "CONTROL" && permit.deletionWatermark !== Number(row.floor)) throw new Error("TRAVEL_DELETION_BARRIER");
|
|
18458
18572
|
}
|
|
18459
|
-
heartbeat(principal,
|
|
18573
|
+
heartbeat(principal, request4) {
|
|
18460
18574
|
return this.transaction(() => {
|
|
18461
18575
|
const node = this.principal(principal), text2 = identityText2(principal), seat = this.seat(principal);
|
|
18462
|
-
natural(
|
|
18463
|
-
if (
|
|
18464
|
-
if (
|
|
18576
|
+
natural(request4.sequence);
|
|
18577
|
+
if (request4.bootId !== node.boot) throw new Error("TRAVEL_BOOT_MISMATCH");
|
|
18578
|
+
if (request4.sequence <= Number(node.sequence)) throw new Error("TRAVEL_HEARTBEAT_REPLAY");
|
|
18465
18579
|
let permit;
|
|
18466
|
-
if (
|
|
18467
|
-
this.assertPermit(
|
|
18468
|
-
if (
|
|
18469
|
-
const floor =
|
|
18580
|
+
if (request4.permit) {
|
|
18581
|
+
this.assertPermit(request4.permit, "CONTROL");
|
|
18582
|
+
if (request4.permit.nodeId !== principal.nodeId || !same(identityText2(request4.permit), text2)) throw new Error("TRAVEL_AUTH_DENIED");
|
|
18583
|
+
const floor = request4.deletionWatermark ?? request4.permit.deletionWatermark;
|
|
18470
18584
|
if (floor !== Number(seat.floor)) throw new Error("TRAVEL_DELETION_BARRIER");
|
|
18471
18585
|
this.deadlines.set(text2, this.monotonicNow() + this.leaseMs);
|
|
18472
18586
|
permit = this.issue(principal, seat);
|
|
18473
18587
|
}
|
|
18474
|
-
this.db.prepare("UPDATE nodes SET sequence=? WHERE identity=? AND node_id=?").run(
|
|
18588
|
+
this.db.prepare("UPDATE nodes SET sequence=? WHERE identity=? AND node_id=?").run(request4.sequence, text2, principal.nodeId);
|
|
18475
18589
|
this.healthy.set(text2 + principal.nodeId, this.monotonicNow() + this.leaseMs);
|
|
18476
18590
|
return {
|
|
18477
18591
|
authorityBootId: this.authorityBootId,
|
|
@@ -18770,10 +18884,10 @@ function createKeyServiceServer(options) {
|
|
|
18770
18884
|
}
|
|
18771
18885
|
chunks.push(chunk);
|
|
18772
18886
|
}
|
|
18773
|
-
let
|
|
18887
|
+
let request4;
|
|
18774
18888
|
try {
|
|
18775
|
-
|
|
18776
|
-
validateKeyIdentity(
|
|
18889
|
+
request4 = JSON.parse(Buffer.concat(chunks).toString());
|
|
18890
|
+
validateKeyIdentity(request4?.identity);
|
|
18777
18891
|
} catch {
|
|
18778
18892
|
reply(400, "KEY_SERVICE_INVALID_REQUEST");
|
|
18779
18893
|
return;
|
|
@@ -18781,13 +18895,13 @@ function createKeyServiceServer(options) {
|
|
|
18781
18895
|
let result;
|
|
18782
18896
|
try {
|
|
18783
18897
|
const cert = socket.getPeerCertificate();
|
|
18784
|
-
result = store.readKey((cert.fingerprint256 ?? "").replaceAll(":", ""),
|
|
18898
|
+
result = store.readKey((cert.fingerprint256 ?? "").replaceAll(":", ""), request4.identity, request4.minimumDeletionWatermark);
|
|
18785
18899
|
} catch {
|
|
18786
18900
|
reply(403, "KEY_SERVICE_DENIED");
|
|
18787
18901
|
return;
|
|
18788
18902
|
}
|
|
18789
18903
|
try {
|
|
18790
|
-
res.end(JSON.stringify({ protocolVersion: 1, identity:
|
|
18904
|
+
res.end(JSON.stringify({ protocolVersion: 1, identity: request4.identity, deletionWatermark: result.deletionWatermark, key: result.key.toString("base64") }));
|
|
18791
18905
|
} finally {
|
|
18792
18906
|
result.key.fill(0);
|
|
18793
18907
|
}
|
|
@@ -20295,7 +20409,7 @@ import { HttpsProxyAgent } from "https-proxy-agent";
|
|
|
20295
20409
|
// src/memory/external-effect.ts
|
|
20296
20410
|
import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
|
|
20297
20411
|
import { createHash as createHash25 } from "node:crypto";
|
|
20298
|
-
import { join as
|
|
20412
|
+
import { join as join18 } from "node:path";
|
|
20299
20413
|
|
|
20300
20414
|
// src/memory/execution-guard.ts
|
|
20301
20415
|
init_db();
|
|
@@ -20305,7 +20419,7 @@ init_migrations();
|
|
|
20305
20419
|
init_context_time();
|
|
20306
20420
|
init_relationship_notice_check();
|
|
20307
20421
|
init_dependencies();
|
|
20308
|
-
import { join as
|
|
20422
|
+
import { join as join17 } from "node:path";
|
|
20309
20423
|
var MemoryExecutionBlockedError = class extends Error {
|
|
20310
20424
|
constructor(reason) {
|
|
20311
20425
|
super(`MEMORY_EXECUTION_BLOCKED: ${reason}`);
|
|
@@ -20318,7 +20432,7 @@ function checkMemoryExecution(stateDir, workspace, context, activeDispatchKey) {
|
|
|
20318
20432
|
let calendar;
|
|
20319
20433
|
try {
|
|
20320
20434
|
if (!stateDir || !context.scopeId || !Array.isArray(context.basisRefs)) return { ok: false, reason: "EXECUTION_CONTEXT_INVALID" };
|
|
20321
|
-
memory = new DatabaseSync11(
|
|
20435
|
+
memory = new DatabaseSync11(join17(stateDir, "mem7", "index", "mem7.db"), { readOnly: true });
|
|
20322
20436
|
memory.exec("PRAGMA query_only=ON; BEGIN");
|
|
20323
20437
|
const schema = readSchemaVersion(memory);
|
|
20324
20438
|
if (schema?.component !== "mem7" || schema.version !== MEM7_SCHEMA_VERSION) return { ok: false, reason: "MEMORY_SCHEMA_UNSUPPORTED" };
|
|
@@ -20333,7 +20447,7 @@ function checkMemoryExecution(stateDir, workspace, context, activeDispatchKey) {
|
|
|
20333
20447
|
if (!result.ok) return result;
|
|
20334
20448
|
}
|
|
20335
20449
|
if (context.calendarBinding) {
|
|
20336
|
-
calendar = new DatabaseSync11(
|
|
20450
|
+
calendar = new DatabaseSync11(join17(workspace, ".calendar", "calendar.db"), { readOnly: true });
|
|
20337
20451
|
calendar.exec("PRAGMA query_only=ON; BEGIN");
|
|
20338
20452
|
const binding = calendar.prepare(`SELECT b.*,e.status event_status,e.memory_version current_event_version FROM calendar_memory_bindings b
|
|
20339
20453
|
JOIN events e ON e.id=b.event_id WHERE b.event_id=?`).get(context.calendarBinding.eventId);
|
|
@@ -20351,7 +20465,7 @@ function checkMemoryExecution(stateDir, workspace, context, activeDispatchKey) {
|
|
|
20351
20465
|
if (!bound.ok) return bound;
|
|
20352
20466
|
}
|
|
20353
20467
|
if (context.actionVersions && Object.keys(context.actionVersions).length) {
|
|
20354
|
-
proactive = new DatabaseSync11(
|
|
20468
|
+
proactive = new DatabaseSync11(join17(workspace, ".proactive", "proactive.db"), { readOnly: true });
|
|
20355
20469
|
proactive.exec("PRAGMA query_only=ON; BEGIN");
|
|
20356
20470
|
for (const [id3, version] of Object.entries(context.actionVersions)) {
|
|
20357
20471
|
const action = proactive.prepare("SELECT * FROM actions WHERE id=?").get(id3);
|
|
@@ -20543,7 +20657,7 @@ async function guardedExternalEffect(run) {
|
|
|
20543
20657
|
assertMemoryExecution(stateDir, workspace, context);
|
|
20544
20658
|
return run();
|
|
20545
20659
|
}
|
|
20546
|
-
const persist = new Persistence2(
|
|
20660
|
+
const persist = new Persistence2(join18(workspace, ".proactive", "proactive.db"));
|
|
20547
20661
|
const key2 = "dispatch_" + createHash25("sha256").update(JSON.stringify([
|
|
20548
20662
|
context.scopeId,
|
|
20549
20663
|
Object.entries(versions).sort(([a], [b]) => a.localeCompare(b)),
|
|
@@ -25665,14 +25779,14 @@ import { HttpsProxyAgent as HttpsProxyAgent2 } from "https-proxy-agent";
|
|
|
25665
25779
|
|
|
25666
25780
|
// src/version.ts
|
|
25667
25781
|
import { readFileSync as readFileSync12 } from "node:fs";
|
|
25668
|
-
import { dirname as dirname10, join as
|
|
25782
|
+
import { dirname as dirname10, join as join22 } from "node:path";
|
|
25669
25783
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
25670
25784
|
var _loaded = null;
|
|
25671
25785
|
var _pkgDirOverride = null;
|
|
25672
25786
|
function candidates() {
|
|
25673
|
-
if (_pkgDirOverride !== null) return [
|
|
25787
|
+
if (_pkgDirOverride !== null) return [join22(_pkgDirOverride, "package.json")];
|
|
25674
25788
|
const here = dirname10(fileURLToPath2(import.meta.url));
|
|
25675
|
-
return [
|
|
25789
|
+
return [join22(here, "..", "package.json"), join22(here, "..", "..", "package.json")];
|
|
25676
25790
|
}
|
|
25677
25791
|
function readFromDisk() {
|
|
25678
25792
|
for (const p of candidates()) {
|
|
@@ -26321,8 +26435,11 @@ function fitProtectedTail(suffix, budget) {
|
|
|
26321
26435
|
function hasImage(m) {
|
|
26322
26436
|
return "role" in m && Array.isArray(m.content) && m.content.some((b) => b.type === "image_ref" || b.type === "image");
|
|
26323
26437
|
}
|
|
26438
|
+
function hasMedia(m) {
|
|
26439
|
+
return hasImage(m) || "role" in m && Array.isArray(m.content) && m.content.some((b) => b.type === "video");
|
|
26440
|
+
}
|
|
26324
26441
|
function unobservedImageIndex(messages) {
|
|
26325
|
-
return messages.findIndex((m) =>
|
|
26442
|
+
return messages.findIndex((m) => hasMedia(m) && !("role" in m && m.imageInput?.observed === true));
|
|
26326
26443
|
}
|
|
26327
26444
|
function splitProtectedImages(messages, budget) {
|
|
26328
26445
|
const index = unobservedImageIndex(messages);
|
|
@@ -29567,7 +29684,7 @@ init_dependencies();
|
|
|
29567
29684
|
init_basis_check();
|
|
29568
29685
|
init_relationship_notice_check();
|
|
29569
29686
|
init_scope();
|
|
29570
|
-
import { join as
|
|
29687
|
+
import { join as join26, resolve as resolve8 } from "node:path";
|
|
29571
29688
|
var contextIdentity = (context) => canonicalJson({
|
|
29572
29689
|
scopeId: context.scopeId,
|
|
29573
29690
|
basisRefs: context.basisRefs,
|
|
@@ -29622,7 +29739,7 @@ function readNotificationState(route, queueStateDir, open3, relationshipChecker)
|
|
|
29622
29739
|
let proactive;
|
|
29623
29740
|
let calendar;
|
|
29624
29741
|
try {
|
|
29625
|
-
memory = open3(
|
|
29742
|
+
memory = open3(join26(runtime.stateDir, "mem7", "index", "mem7.db"));
|
|
29626
29743
|
const scope = memory.prepare("SELECT * FROM memory_scopes WHERE scope_id=?").get(context.scopeId);
|
|
29627
29744
|
if (!scope) {
|
|
29628
29745
|
return { state: "blocked", reason: "MEMORY_NOTIFICATION_SCOPE_MISSING", redact: true };
|
|
@@ -29649,7 +29766,7 @@ function readNotificationState(route, queueStateDir, open3, relationshipChecker)
|
|
|
29649
29766
|
}
|
|
29650
29767
|
if (context.actionVersions && Object.keys(context.actionVersions).length) {
|
|
29651
29768
|
const ledgerDependencies = new MemoryDependencies(memory, (operation) => operation());
|
|
29652
|
-
proactive = open3(
|
|
29769
|
+
proactive = open3(join26(runtime.workspace, ".proactive", "proactive.db"));
|
|
29653
29770
|
for (const id3 of Object.keys(context.actionVersions)) {
|
|
29654
29771
|
const action = proactive.prepare("SELECT scope_id,intent_id FROM actions WHERE id=?").get(id3);
|
|
29655
29772
|
if (!action || action.scope_id !== context.scopeId) return { state: "blocked", reason: "MEMORY_NOTIFICATION_ACTION_MISMATCH", redact: true };
|
|
@@ -29703,7 +29820,7 @@ function readNotificationState(route, queueStateDir, open3, relationshipChecker)
|
|
|
29703
29820
|
}
|
|
29704
29821
|
if (route.hostDelivery) {
|
|
29705
29822
|
if (!proactive) {
|
|
29706
|
-
proactive = open3(
|
|
29823
|
+
proactive = open3(join26(runtime.workspace, ".proactive", "proactive.db"));
|
|
29707
29824
|
}
|
|
29708
29825
|
const receipt = proactive.prepare("SELECT * FROM proactive_host_deliveries WHERE delivery_key=?").get(route.hostDelivery.key);
|
|
29709
29826
|
if (!receipt || contextIdentity(JSON.parse(receipt.context_json)) !== contextIdentity(context)) {
|
|
@@ -29714,7 +29831,7 @@ function readNotificationState(route, queueStateDir, open3, relationshipChecker)
|
|
|
29714
29831
|
if (["blocked", "delivery_unknown"].includes(receipt.state)) return { state: receipt.state, reason: receipt.reason ?? receipt.state };
|
|
29715
29832
|
}
|
|
29716
29833
|
if (context.calendarBinding) {
|
|
29717
|
-
calendar = open3(
|
|
29834
|
+
calendar = open3(join26(runtime.workspace, ".calendar", "calendar.db"));
|
|
29718
29835
|
const binding = context.calendarBinding;
|
|
29719
29836
|
const rows = calendar.prepare("SELECT state,closure FROM calendar_dispatches WHERE scope_id=? AND event_id=? AND occurrence_id=?").all(context.scopeId, binding.eventId, binding.occurrenceId);
|
|
29720
29837
|
if (rows.some((row) => ["started", "delivery_unknown"].includes(row.state) && !row.closure)) {
|
|
@@ -30482,7 +30599,7 @@ var QueryEngine = class _QueryEngine {
|
|
|
30482
30599
|
this.compactConfig.systemOverheadTokens = overhead ?? this.compactConfig.systemOverheadTokens;
|
|
30483
30600
|
}
|
|
30484
30601
|
const activeSystemStable = perTurnSystemStable || this.resolveOpt(this.options.systemStable) || this.resolveOpt(this.options.systemPrompt);
|
|
30485
|
-
for (const m of messages) if ("role" in m &&
|
|
30602
|
+
for (const m of messages) if ("role" in m && hasMedia(m) && !m.imageInput) m.imageInput = { id: randomUUID17(), observed: hasImage(m) };
|
|
30486
30603
|
let currentMessages = [...messages];
|
|
30487
30604
|
const oldGatePattern = /^Tool "([^"]+)" is permanently unavailable in this channel\. Do NOT retry it or any other tool — answer the user directly in plain speech now\.$/;
|
|
30488
30605
|
const historicalGateTools = new Set(currentMessages.flatMap((m) => {
|
|
@@ -30873,9 +30990,13 @@ var QueryEngine = class _QueryEngine {
|
|
|
30873
30990
|
try {
|
|
30874
30991
|
wholeQueryAbort.signal.throwIfAborted();
|
|
30875
30992
|
const view = normalizeMessagesForAPI(currentMessages).map((m) => {
|
|
30876
|
-
if (!Array.isArray(m.content) || !m.imageInput?.observed ||
|
|
30877
|
-
const blocks = m.content.filter((b) =>
|
|
30878
|
-
|
|
30993
|
+
if (!Array.isArray(m.content) || !m.imageInput?.observed || !queryModelRef) return m;
|
|
30994
|
+
const blocks = m.content.filter((b) => {
|
|
30995
|
+
if (b.type === "image" || b.type === "image_ref") return !!queryInputs?.includes("image");
|
|
30996
|
+
if (b.type === "video") return !!queryInputs?.includes("video");
|
|
30997
|
+
return true;
|
|
30998
|
+
});
|
|
30999
|
+
return { ...m, content: blocks.length ? blocks : "[previous media omitted]" };
|
|
30879
31000
|
});
|
|
30880
31001
|
const apiMessages = await materializeImageMessages(view, this.options.imageAssets, wholeQueryAbort.signal);
|
|
30881
31002
|
wholeQueryAbort.signal.throwIfAborted();
|
|
@@ -31036,7 +31157,7 @@ ${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
|
|
|
31036
31157
|
}
|
|
31037
31158
|
});
|
|
31038
31159
|
if (!requestComplete || (toolCalls.length ? !validToolCalls : !textContent.trim()) || ["length", "max_tokens", "MAX_TOKENS", "incomplete", "content_filter"].includes(responseStopReason ?? "")) return;
|
|
31039
|
-
const inputs = currentMessages.filter((m) => "role" in m &&
|
|
31160
|
+
const inputs = currentMessages.filter((m) => "role" in m && hasMedia(m) && !m.imageInput?.observed);
|
|
31040
31161
|
if (!inputs.length) return;
|
|
31041
31162
|
return {
|
|
31042
31163
|
type: "image_observed",
|
|
@@ -34964,8 +35085,8 @@ import { randomUUID as randomUUID21 } from "node:crypto";
|
|
|
34964
35085
|
|
|
34965
35086
|
// src/continuity/gateway-channel.ts
|
|
34966
35087
|
init_gateway_media();
|
|
34967
|
-
import { mkdtempSync, writeFileSync as
|
|
34968
|
-
import { join as
|
|
35088
|
+
import { mkdtempSync, writeFileSync as writeFileSync14, rmSync as rmSync2, realpathSync as realpathSync5 } from "node:fs";
|
|
35089
|
+
import { join as join31 } from "node:path";
|
|
34969
35090
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
34970
35091
|
function splitChannelGatewayText(text2, channel) {
|
|
34971
35092
|
if (typeof text2 !== "string" || Buffer.byteLength(text2) > 1024 * 1024) throw new Error("TRAVEL_GATEWAY_REPLY_LIMIT");
|
|
@@ -35020,9 +35141,9 @@ async function deliverChannelGatewayEffect(adapter, effect, body, assertCurrent)
|
|
|
35020
35141
|
if (!media) await adapter.send(packet.target, packet.text, { replyTo: packet.replyTo });
|
|
35021
35142
|
else {
|
|
35022
35143
|
if (!adapter.sendFile) throw new Error("TRAVEL_GATEWAY_MEDIA_UNAVAILABLE");
|
|
35023
|
-
const directory2 = realpathSync5(mkdtempSync(
|
|
35144
|
+
const directory2 = realpathSync5(mkdtempSync(join31(tmpdir3(), "e7-gateway-media-"))), file2 = join31(directory2, packet.filename);
|
|
35024
35145
|
try {
|
|
35025
|
-
|
|
35146
|
+
writeFileSync14(file2, media.bytes, { mode: 384 });
|
|
35026
35147
|
await adapter.sendFile(packet.target, packet.text, { path: file2, filename: packet.filename, mimeType: packet.mimeType, voiceDurationSec: packet.voiceDurationSec });
|
|
35027
35148
|
} finally {
|
|
35028
35149
|
rmSync2(directory2, { recursive: true, force: true });
|
|
@@ -36177,9 +36298,9 @@ if (process.argv[1] && /[\\/](gateway-main\.ts|travel-gateway\.mjs)$/.test(proce
|
|
|
36177
36298
|
|
|
36178
36299
|
// src/continuity/pairing-control.ts
|
|
36179
36300
|
async function startPairingControl(config) {
|
|
36180
|
-
const directory2 = resolve12(config.directory), file2 =
|
|
36301
|
+
const directory2 = resolve12(config.directory), file2 = join32(directory2, "pairing.json"), read2 = (name) => readPrivateFile(join32(directory2, name), 65536);
|
|
36181
36302
|
const tls2 = { ca: read2("ca.pem"), cert: read2("server.pem"), key: read2("server.key") };
|
|
36182
|
-
const authority = new TravelAuthority({ directory:
|
|
36303
|
+
const authority = new TravelAuthority({ directory: join32(directory2, "authority") });
|
|
36183
36304
|
let binding;
|
|
36184
36305
|
try {
|
|
36185
36306
|
if (existsSync15(file2)) {
|
|
@@ -36189,12 +36310,12 @@ async function startPairingControl(config) {
|
|
|
36189
36310
|
} else {
|
|
36190
36311
|
const tokens = authority.provisionSeat(config.identity, { local: "LOCAL", cloud: "CLOUD" }, { checkpointDigest: "0".repeat(64), buildManifestId: config.buildManifestId });
|
|
36191
36312
|
binding = { identity: config.identity, buildManifestId: config.buildManifestId, keySha256: config.keySha256, tokens, local: authority.authenticate(tokens.local), cloud: authority.authenticate(tokens.cloud), publicKey: authority.publicKey, keyIdentity: { ...config.identity, keyId: "pair-" + config.identity.seatId, generation: 1 } };
|
|
36192
|
-
|
|
36313
|
+
writeFileSync15(file2, JSON.stringify(binding), { flag: "wx", mode: 384, flush: true });
|
|
36193
36314
|
}
|
|
36194
36315
|
} finally {
|
|
36195
36316
|
authority.close();
|
|
36196
36317
|
}
|
|
36197
|
-
const keys = new KeyServiceStore(
|
|
36318
|
+
const keys = new KeyServiceStore(join32(directory2, "keys"));
|
|
36198
36319
|
const key2 = read2("data.key");
|
|
36199
36320
|
try {
|
|
36200
36321
|
if (createHash37("sha256").update(key2).digest("hex") !== config.keySha256) throw new Error("TRAVEL_PAIRING_KEY");
|
|
@@ -36218,13 +36339,13 @@ async function startPairingControl(config) {
|
|
|
36218
36339
|
const fp = (name) => new X509Certificate(read2(name + ".pem")).fingerprint256.replaceAll(":", "").toLowerCase();
|
|
36219
36340
|
const peers = { [fp("local")]: binding.tokens.local, [fp("cloud")]: binding.tokens.cloud };
|
|
36220
36341
|
const managers = { [fp("manager")]: [binding.tokens.local, binding.tokens.cloud], [fp("local")]: [binding.tokens.local, binding.tokens.cloud], [fp("cloud")]: [binding.tokens.cloud, binding.tokens.local] };
|
|
36221
|
-
const tlsFiles = { caFile:
|
|
36222
|
-
const managerTls = { ...tlsFiles, certFile:
|
|
36342
|
+
const tlsFiles = { caFile: join32(directory2, "ca.pem"), certFile: join32(directory2, "server.pem"), keyFile: join32(directory2, "server.key") };
|
|
36343
|
+
const managerTls = { ...tlsFiles, certFile: join32(directory2, "manager.pem"), keyFile: join32(directory2, "manager.key") };
|
|
36223
36344
|
const gatewayConfig = {
|
|
36224
36345
|
identity: config.identity,
|
|
36225
|
-
authorityDir:
|
|
36226
|
-
gatewayDir:
|
|
36227
|
-
objectsDir:
|
|
36346
|
+
authorityDir: join32(directory2, "authority"),
|
|
36347
|
+
gatewayDir: join32(directory2, "gateway"),
|
|
36348
|
+
objectsDir: join32(directory2, "objects"),
|
|
36228
36349
|
tls: tlsFiles,
|
|
36229
36350
|
host: "127.0.0.1",
|
|
36230
36351
|
port: config.ports.gateway,
|
|
@@ -36232,12 +36353,12 @@ async function startPairingControl(config) {
|
|
|
36232
36353
|
control: { host: "127.0.0.1", port: config.ports.authority, tls: tlsFiles, allowedPeers: peers, managementPeers: managers, recoveryPeers: managers, retirementPeers: { [fp("manager")]: [binding.tokens.local] } },
|
|
36233
36354
|
allowedPeers: peers,
|
|
36234
36355
|
recoveryPeers: { [fp("manager")]: binding.tokens.local },
|
|
36235
|
-
platformStateDir:
|
|
36356
|
+
platformStateDir: join32(directory2, "platform"),
|
|
36236
36357
|
channels: config.channels,
|
|
36237
36358
|
feishu: { ...config.feishu, ingressEnabled: false },
|
|
36238
36359
|
ingressEnabled: false
|
|
36239
36360
|
};
|
|
36240
|
-
let ingress = existsSync15(
|
|
36361
|
+
let ingress = existsSync15(join32(directory2, "ingress-enabled.json"));
|
|
36241
36362
|
let gateway = await startTravelGateway({ ...gatewayConfig, ingressEnabled: ingress, feishu: { ...gatewayConfig.feishu, ingressEnabled: ingress && config.channels?.feishu?.enabled === true } });
|
|
36242
36363
|
let changing = false, closed = false;
|
|
36243
36364
|
const pairServer = createServer4({ ...tls2, minVersion: "TLSv1.3", requestCert: true, rejectUnauthorized: true }, async (req, res) => {
|
|
@@ -36266,12 +36387,12 @@ async function startPairingControl(config) {
|
|
|
36266
36387
|
if (input.action === "enable_ingress" && !ingress) {
|
|
36267
36388
|
await gateway.close();
|
|
36268
36389
|
gateway = await startTravelGateway({ ...gatewayConfig, ingressEnabled: true, feishu: { ...gatewayConfig.feishu, ingressEnabled: config.channels?.feishu?.enabled === true } });
|
|
36269
|
-
|
|
36390
|
+
writeFileSync15(join32(directory2, "ingress-enabled.json"), JSON.stringify({ identity: config.identity }), { mode: 384, flush: true });
|
|
36270
36391
|
ingress = true;
|
|
36271
36392
|
}
|
|
36272
36393
|
if (input.action === "disable_ingress" && ingress) {
|
|
36273
36394
|
if (gateway.authority.status(binding.local).activeNodeId !== null) throw new Error("TRAVEL_INITIAL_SOURCE_RUNNING");
|
|
36274
|
-
rmSync3(
|
|
36395
|
+
rmSync3(join32(directory2, "ingress-enabled.json"), { force: true });
|
|
36275
36396
|
await gateway.close();
|
|
36276
36397
|
gateway = await startTravelGateway(gatewayConfig);
|
|
36277
36398
|
ingress = false;
|