engine7 7.1.21 → 7.1.22
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/engine-startup.mjs +110 -2
- package/dist/main.mjs +110 -2
- package/package.json +1 -1
package/dist/engine-startup.mjs
CHANGED
|
@@ -11876,6 +11876,74 @@ ${lines.join("\n\n")}`;
|
|
|
11876
11876
|
}
|
|
11877
11877
|
});
|
|
11878
11878
|
|
|
11879
|
+
// src/memory/everos-sync.ts
|
|
11880
|
+
var everos_sync_exports = {};
|
|
11881
|
+
__export(everos_sync_exports, {
|
|
11882
|
+
createEverosSync: () => createEverosSync
|
|
11883
|
+
});
|
|
11884
|
+
function createEverosSync(cfg) {
|
|
11885
|
+
const { enabled, url, appId, userId } = cfg;
|
|
11886
|
+
async function push(event) {
|
|
11887
|
+
if (!enabled) return;
|
|
11888
|
+
if (!event.text.trim()) return;
|
|
11889
|
+
try {
|
|
11890
|
+
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
11891
|
+
method: "POST",
|
|
11892
|
+
headers: { "Content-Type": "application/json" },
|
|
11893
|
+
body: JSON.stringify({
|
|
11894
|
+
session_id: event.sessionId,
|
|
11895
|
+
app_id: appId,
|
|
11896
|
+
project_id: "default",
|
|
11897
|
+
messages: [{
|
|
11898
|
+
sender_id: event.role === "user" ? "user" : appId,
|
|
11899
|
+
sender_name: event.senderName || event.role,
|
|
11900
|
+
role: event.role,
|
|
11901
|
+
timestamp: event.timestamp,
|
|
11902
|
+
content: event.text
|
|
11903
|
+
}]
|
|
11904
|
+
}),
|
|
11905
|
+
signal: AbortSignal.timeout(5e3)
|
|
11906
|
+
});
|
|
11907
|
+
if (!resp.ok) {
|
|
11908
|
+
console.warn(`[everos-sync] memory/add ${resp.status}`);
|
|
11909
|
+
}
|
|
11910
|
+
} catch {
|
|
11911
|
+
}
|
|
11912
|
+
}
|
|
11913
|
+
async function pushBatch(events) {
|
|
11914
|
+
if (!enabled || events.length === 0) return;
|
|
11915
|
+
try {
|
|
11916
|
+
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
11917
|
+
method: "POST",
|
|
11918
|
+
headers: { "Content-Type": "application/json" },
|
|
11919
|
+
body: JSON.stringify({
|
|
11920
|
+
session_id: events[0].sessionId,
|
|
11921
|
+
app_id: appId,
|
|
11922
|
+
project_id: "default",
|
|
11923
|
+
messages: events.map((e) => ({
|
|
11924
|
+
sender_id: e.role === "user" ? "user" : appId,
|
|
11925
|
+
sender_name: e.senderName || e.role,
|
|
11926
|
+
role: e.role,
|
|
11927
|
+
timestamp: e.timestamp,
|
|
11928
|
+
content: e.text
|
|
11929
|
+
}))
|
|
11930
|
+
}),
|
|
11931
|
+
signal: AbortSignal.timeout(3e4)
|
|
11932
|
+
});
|
|
11933
|
+
if (!resp.ok) {
|
|
11934
|
+
console.warn(`[everos-sync] batch add ${resp.status}`);
|
|
11935
|
+
}
|
|
11936
|
+
} catch {
|
|
11937
|
+
}
|
|
11938
|
+
}
|
|
11939
|
+
return { push, pushBatch };
|
|
11940
|
+
}
|
|
11941
|
+
var init_everos_sync = __esm({
|
|
11942
|
+
"src/memory/everos-sync.ts"() {
|
|
11943
|
+
"use strict";
|
|
11944
|
+
}
|
|
11945
|
+
});
|
|
11946
|
+
|
|
11879
11947
|
// src/cron/cron-plugin.ts
|
|
11880
11948
|
var cron_plugin_exports = {};
|
|
11881
11949
|
__export(cron_plugin_exports, {
|
|
@@ -16365,6 +16433,8 @@ var SessionWriter = class {
|
|
|
16365
16433
|
lastId = null;
|
|
16366
16434
|
stream = null;
|
|
16367
16435
|
lineCount = 0;
|
|
16436
|
+
/** 消息写入 hook(由外部注入,如 EverOS sync) */
|
|
16437
|
+
onMessageWritten = null;
|
|
16368
16438
|
/**
|
|
16369
16439
|
* @param sessionsDir sessions 目录
|
|
16370
16440
|
* @param sessionId 可选,传入则续写已有文件;不传则新建
|
|
@@ -16762,6 +16832,19 @@ var SessionWriter = class {
|
|
|
16762
16832
|
const lineId = obj.id || obj.uuid;
|
|
16763
16833
|
if (lineId) this.lastId = lineId;
|
|
16764
16834
|
this.stream.write(JSON.stringify(obj) + "\n");
|
|
16835
|
+
if (obj.type === "message" && this.onMessageWritten && obj.message?.role && obj.message?.content) {
|
|
16836
|
+
const role = obj.message.role;
|
|
16837
|
+
let text = "";
|
|
16838
|
+
const content = obj.message.content;
|
|
16839
|
+
if (typeof content === "string") {
|
|
16840
|
+
text = content;
|
|
16841
|
+
} else if (Array.isArray(content)) {
|
|
16842
|
+
text = content.filter((b2) => b2.type === "text" && b2.text).map((b2) => b2.text).join("\n");
|
|
16843
|
+
}
|
|
16844
|
+
if (text.trim()) {
|
|
16845
|
+
this.onMessageWritten({ role, text, timestamp: obj.timestamp || (/* @__PURE__ */ new Date()).toISOString() });
|
|
16846
|
+
}
|
|
16847
|
+
}
|
|
16765
16848
|
}
|
|
16766
16849
|
};
|
|
16767
16850
|
function cleanupArchivedSessionTranscripts(sessionsDir, olderThanMs = 30 * 24 * 60 * 60 * 1e3) {
|
|
@@ -17205,6 +17288,8 @@ var SessionManager = class {
|
|
|
17205
17288
|
sessionsDir;
|
|
17206
17289
|
indexPath;
|
|
17207
17290
|
platformMapPath;
|
|
17291
|
+
/** 外部 hook:每次创建新 writer 时回调(如 EverOS sync 注入 onMessageWritten) */
|
|
17292
|
+
onWriterCreated = null;
|
|
17208
17293
|
histories = /* @__PURE__ */ new Map();
|
|
17209
17294
|
restoredRecallPaths = /* @__PURE__ */ new Map();
|
|
17210
17295
|
writers = /* @__PURE__ */ new Map();
|
|
@@ -17319,6 +17404,7 @@ var SessionManager = class {
|
|
|
17319
17404
|
this.index.set(sessionId, { file: writer.path, updatedAt: Date.now() });
|
|
17320
17405
|
this.saveIndex();
|
|
17321
17406
|
this.writers.set(sessionId, writer);
|
|
17407
|
+
this.onWriterCreated?.(writer, sessionId);
|
|
17322
17408
|
console.log(`[session] ${existing ? "Resumed" : "New"}: ${sessionId} \u2192 ${path7.basename(writer.path)}`);
|
|
17323
17409
|
}
|
|
17324
17410
|
return writer;
|
|
@@ -17966,8 +18052,8 @@ ${skillsListing}`);
|
|
|
17966
18052
|
parts.push(getEnvInfoSection(options.workspace));
|
|
17967
18053
|
const now = /* @__PURE__ */ new Date();
|
|
17968
18054
|
const dateStr = now.toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" });
|
|
17969
|
-
const
|
|
17970
|
-
const contextParts = [`\u5F53\u524D\u65F6\u95F4: ${dateStr}`, `\
|
|
18055
|
+
const osPlatform = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : process.platform;
|
|
18056
|
+
const contextParts = [`\u5F53\u524D\u65F6\u95F4: ${dateStr}`, `\u7CFB\u7EDF: ${osPlatform} (${process.platform})`];
|
|
17971
18057
|
const meta = options.inboundMeta;
|
|
17972
18058
|
if (meta) {
|
|
17973
18059
|
contextParts.push(`\u6765\u6E90: ${meta.channel}`);
|
|
@@ -27472,6 +27558,28 @@ ${content}`
|
|
|
27472
27558
|
sessions.migrateOldSessions();
|
|
27473
27559
|
sessions.startIdleCleanup();
|
|
27474
27560
|
cleanupArchivedSessionTranscripts(sessions.sessionsDir);
|
|
27561
|
+
const everosCfg = config.everos;
|
|
27562
|
+
if (everosCfg?.enabled) {
|
|
27563
|
+
const { createEverosSync: createEverosSync2 } = await Promise.resolve().then(() => (init_everos_sync(), everos_sync_exports));
|
|
27564
|
+
const everosSync = createEverosSync2({
|
|
27565
|
+
enabled: true,
|
|
27566
|
+
url: everosCfg.everosUrl || "http://127.0.0.1:8100",
|
|
27567
|
+
appId: everosCfg.userId || "default",
|
|
27568
|
+
userId: everosCfg.userId || "default"
|
|
27569
|
+
});
|
|
27570
|
+
sessions.onWriterCreated = (writer, sessionId) => {
|
|
27571
|
+
writer.onMessageWritten = (msg2) => {
|
|
27572
|
+
everosSync.push({
|
|
27573
|
+
sessionId: writer.engineSessionId || sessionId,
|
|
27574
|
+
role: msg2.role === "toolResult" ? "tool" : msg2.role,
|
|
27575
|
+
text: msg2.text,
|
|
27576
|
+
timestamp: new Date(msg2.timestamp).getTime()
|
|
27577
|
+
}).catch(() => {
|
|
27578
|
+
});
|
|
27579
|
+
};
|
|
27580
|
+
};
|
|
27581
|
+
console.log(`[everos-sync] hook registered (appId=${everosCfg.userId})`);
|
|
27582
|
+
}
|
|
27475
27583
|
const channelManager = new ChannelManager();
|
|
27476
27584
|
const memoryRecallProvider = createMemorySideProvider(
|
|
27477
27585
|
config.topics?.recall,
|
package/dist/main.mjs
CHANGED
|
@@ -12231,6 +12231,74 @@ ${lines.join("\n\n")}`;
|
|
|
12231
12231
|
}
|
|
12232
12232
|
});
|
|
12233
12233
|
|
|
12234
|
+
// src/memory/everos-sync.ts
|
|
12235
|
+
var everos_sync_exports = {};
|
|
12236
|
+
__export(everos_sync_exports, {
|
|
12237
|
+
createEverosSync: () => createEverosSync
|
|
12238
|
+
});
|
|
12239
|
+
function createEverosSync(cfg) {
|
|
12240
|
+
const { enabled, url, appId, userId } = cfg;
|
|
12241
|
+
async function push(event) {
|
|
12242
|
+
if (!enabled) return;
|
|
12243
|
+
if (!event.text.trim()) return;
|
|
12244
|
+
try {
|
|
12245
|
+
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
12246
|
+
method: "POST",
|
|
12247
|
+
headers: { "Content-Type": "application/json" },
|
|
12248
|
+
body: JSON.stringify({
|
|
12249
|
+
session_id: event.sessionId,
|
|
12250
|
+
app_id: appId,
|
|
12251
|
+
project_id: "default",
|
|
12252
|
+
messages: [{
|
|
12253
|
+
sender_id: event.role === "user" ? "user" : appId,
|
|
12254
|
+
sender_name: event.senderName || event.role,
|
|
12255
|
+
role: event.role,
|
|
12256
|
+
timestamp: event.timestamp,
|
|
12257
|
+
content: event.text
|
|
12258
|
+
}]
|
|
12259
|
+
}),
|
|
12260
|
+
signal: AbortSignal.timeout(5e3)
|
|
12261
|
+
});
|
|
12262
|
+
if (!resp.ok) {
|
|
12263
|
+
console.warn(`[everos-sync] memory/add ${resp.status}`);
|
|
12264
|
+
}
|
|
12265
|
+
} catch {
|
|
12266
|
+
}
|
|
12267
|
+
}
|
|
12268
|
+
async function pushBatch(events) {
|
|
12269
|
+
if (!enabled || events.length === 0) return;
|
|
12270
|
+
try {
|
|
12271
|
+
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
12272
|
+
method: "POST",
|
|
12273
|
+
headers: { "Content-Type": "application/json" },
|
|
12274
|
+
body: JSON.stringify({
|
|
12275
|
+
session_id: events[0].sessionId,
|
|
12276
|
+
app_id: appId,
|
|
12277
|
+
project_id: "default",
|
|
12278
|
+
messages: events.map((e) => ({
|
|
12279
|
+
sender_id: e.role === "user" ? "user" : appId,
|
|
12280
|
+
sender_name: e.senderName || e.role,
|
|
12281
|
+
role: e.role,
|
|
12282
|
+
timestamp: e.timestamp,
|
|
12283
|
+
content: e.text
|
|
12284
|
+
}))
|
|
12285
|
+
}),
|
|
12286
|
+
signal: AbortSignal.timeout(3e4)
|
|
12287
|
+
});
|
|
12288
|
+
if (!resp.ok) {
|
|
12289
|
+
console.warn(`[everos-sync] batch add ${resp.status}`);
|
|
12290
|
+
}
|
|
12291
|
+
} catch {
|
|
12292
|
+
}
|
|
12293
|
+
}
|
|
12294
|
+
return { push, pushBatch };
|
|
12295
|
+
}
|
|
12296
|
+
var init_everos_sync = __esm({
|
|
12297
|
+
"src/memory/everos-sync.ts"() {
|
|
12298
|
+
"use strict";
|
|
12299
|
+
}
|
|
12300
|
+
});
|
|
12301
|
+
|
|
12234
12302
|
// src/cron/cron-plugin.ts
|
|
12235
12303
|
var cron_plugin_exports = {};
|
|
12236
12304
|
__export(cron_plugin_exports, {
|
|
@@ -16723,6 +16791,8 @@ var SessionWriter = class {
|
|
|
16723
16791
|
lastId = null;
|
|
16724
16792
|
stream = null;
|
|
16725
16793
|
lineCount = 0;
|
|
16794
|
+
/** 消息写入 hook(由外部注入,如 EverOS sync) */
|
|
16795
|
+
onMessageWritten = null;
|
|
16726
16796
|
/**
|
|
16727
16797
|
* @param sessionsDir sessions 目录
|
|
16728
16798
|
* @param sessionId 可选,传入则续写已有文件;不传则新建
|
|
@@ -17120,6 +17190,19 @@ var SessionWriter = class {
|
|
|
17120
17190
|
const lineId = obj.id || obj.uuid;
|
|
17121
17191
|
if (lineId) this.lastId = lineId;
|
|
17122
17192
|
this.stream.write(JSON.stringify(obj) + "\n");
|
|
17193
|
+
if (obj.type === "message" && this.onMessageWritten && obj.message?.role && obj.message?.content) {
|
|
17194
|
+
const role = obj.message.role;
|
|
17195
|
+
let text = "";
|
|
17196
|
+
const content = obj.message.content;
|
|
17197
|
+
if (typeof content === "string") {
|
|
17198
|
+
text = content;
|
|
17199
|
+
} else if (Array.isArray(content)) {
|
|
17200
|
+
text = content.filter((b2) => b2.type === "text" && b2.text).map((b2) => b2.text).join("\n");
|
|
17201
|
+
}
|
|
17202
|
+
if (text.trim()) {
|
|
17203
|
+
this.onMessageWritten({ role, text, timestamp: obj.timestamp || (/* @__PURE__ */ new Date()).toISOString() });
|
|
17204
|
+
}
|
|
17205
|
+
}
|
|
17123
17206
|
}
|
|
17124
17207
|
};
|
|
17125
17208
|
function cleanupArchivedSessionTranscripts(sessionsDir, olderThanMs = 30 * 24 * 60 * 60 * 1e3) {
|
|
@@ -17563,6 +17646,8 @@ var SessionManager = class {
|
|
|
17563
17646
|
sessionsDir;
|
|
17564
17647
|
indexPath;
|
|
17565
17648
|
platformMapPath;
|
|
17649
|
+
/** 外部 hook:每次创建新 writer 时回调(如 EverOS sync 注入 onMessageWritten) */
|
|
17650
|
+
onWriterCreated = null;
|
|
17566
17651
|
histories = /* @__PURE__ */ new Map();
|
|
17567
17652
|
restoredRecallPaths = /* @__PURE__ */ new Map();
|
|
17568
17653
|
writers = /* @__PURE__ */ new Map();
|
|
@@ -17677,6 +17762,7 @@ var SessionManager = class {
|
|
|
17677
17762
|
this.index.set(sessionId, { file: writer.path, updatedAt: Date.now() });
|
|
17678
17763
|
this.saveIndex();
|
|
17679
17764
|
this.writers.set(sessionId, writer);
|
|
17765
|
+
this.onWriterCreated?.(writer, sessionId);
|
|
17680
17766
|
console.log(`[session] ${existing ? "Resumed" : "New"}: ${sessionId} \u2192 ${path7.basename(writer.path)}`);
|
|
17681
17767
|
}
|
|
17682
17768
|
return writer;
|
|
@@ -18324,8 +18410,8 @@ ${skillsListing}`);
|
|
|
18324
18410
|
parts.push(getEnvInfoSection(options.workspace));
|
|
18325
18411
|
const now = /* @__PURE__ */ new Date();
|
|
18326
18412
|
const dateStr = now.toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" });
|
|
18327
|
-
const
|
|
18328
|
-
const contextParts = [`\u5F53\u524D\u65F6\u95F4: ${dateStr}`, `\
|
|
18413
|
+
const osPlatform = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : process.platform;
|
|
18414
|
+
const contextParts = [`\u5F53\u524D\u65F6\u95F4: ${dateStr}`, `\u7CFB\u7EDF: ${osPlatform} (${process.platform})`];
|
|
18329
18415
|
const meta = options.inboundMeta;
|
|
18330
18416
|
if (meta) {
|
|
18331
18417
|
contextParts.push(`\u6765\u6E90: ${meta.channel}`);
|
|
@@ -27538,6 +27624,28 @@ ${content}`
|
|
|
27538
27624
|
sessions.migrateOldSessions();
|
|
27539
27625
|
sessions.startIdleCleanup();
|
|
27540
27626
|
cleanupArchivedSessionTranscripts(sessions.sessionsDir);
|
|
27627
|
+
const everosCfg = config2.everos;
|
|
27628
|
+
if (everosCfg?.enabled) {
|
|
27629
|
+
const { createEverosSync: createEverosSync2 } = await Promise.resolve().then(() => (init_everos_sync(), everos_sync_exports));
|
|
27630
|
+
const everosSync = createEverosSync2({
|
|
27631
|
+
enabled: true,
|
|
27632
|
+
url: everosCfg.everosUrl || "http://127.0.0.1:8100",
|
|
27633
|
+
appId: everosCfg.userId || "default",
|
|
27634
|
+
userId: everosCfg.userId || "default"
|
|
27635
|
+
});
|
|
27636
|
+
sessions.onWriterCreated = (writer, sessionId) => {
|
|
27637
|
+
writer.onMessageWritten = (msg2) => {
|
|
27638
|
+
everosSync.push({
|
|
27639
|
+
sessionId: writer.engineSessionId || sessionId,
|
|
27640
|
+
role: msg2.role === "toolResult" ? "tool" : msg2.role,
|
|
27641
|
+
text: msg2.text,
|
|
27642
|
+
timestamp: new Date(msg2.timestamp).getTime()
|
|
27643
|
+
}).catch(() => {
|
|
27644
|
+
});
|
|
27645
|
+
};
|
|
27646
|
+
};
|
|
27647
|
+
console.log(`[everos-sync] hook registered (appId=${everosCfg.userId})`);
|
|
27648
|
+
}
|
|
27541
27649
|
const channelManager = new ChannelManager();
|
|
27542
27650
|
const memoryRecallProvider = createMemorySideProvider(
|
|
27543
27651
|
config2.topics?.recall,
|