engine7 7.1.28 → 7.1.29
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 +118 -112
- package/dist/main.mjs +118 -112
- package/package.json +58 -58
package/dist/engine-startup.mjs
CHANGED
|
@@ -3553,6 +3553,10 @@ var init_loader = __esm({
|
|
|
3553
3553
|
});
|
|
3554
3554
|
|
|
3555
3555
|
// src/config/live.ts
|
|
3556
|
+
var live_exports = {};
|
|
3557
|
+
__export(live_exports, {
|
|
3558
|
+
liveConfig: () => liveConfig
|
|
3559
|
+
});
|
|
3556
3560
|
var LiveConfigClass, liveConfig;
|
|
3557
3561
|
var init_live = __esm({
|
|
3558
3562
|
"src/config/live.ts"() {
|
|
@@ -5067,6 +5071,76 @@ var init_extractPrompts = __esm({
|
|
|
5067
5071
|
}
|
|
5068
5072
|
});
|
|
5069
5073
|
|
|
5074
|
+
// src/memory/everos/ingest.ts
|
|
5075
|
+
function parseMeta(text) {
|
|
5076
|
+
const m2 = text.match(/^\[meta:\s*(.+?)\s*\((.+?)\)\s*@(\S+)\s*[^\]]*\]/);
|
|
5077
|
+
if (!m2) return null;
|
|
5078
|
+
return { senderName: m2[1].trim() };
|
|
5079
|
+
}
|
|
5080
|
+
async function readConfig() {
|
|
5081
|
+
const defaults = {
|
|
5082
|
+
url: "http://127.0.0.1:8100",
|
|
5083
|
+
appId: "default",
|
|
5084
|
+
agentName: "assistant",
|
|
5085
|
+
enabled: false
|
|
5086
|
+
};
|
|
5087
|
+
try {
|
|
5088
|
+
const { liveConfig: liveConfig2 } = await Promise.resolve().then(() => (init_live(), live_exports));
|
|
5089
|
+
const cfg = liveConfig2.all()?.everos;
|
|
5090
|
+
if (!cfg) return defaults;
|
|
5091
|
+
return {
|
|
5092
|
+
url: cfg.everosUrl || defaults.url,
|
|
5093
|
+
appId: cfg.userId || defaults.appId,
|
|
5094
|
+
agentName: cfg.agentName || cfg.userId || defaults.agentName,
|
|
5095
|
+
enabled: cfg.enabled === true
|
|
5096
|
+
};
|
|
5097
|
+
} catch {
|
|
5098
|
+
return defaults;
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
async function pushConversation(messages, sessionId) {
|
|
5102
|
+
const cfg = await readConfig();
|
|
5103
|
+
if (!cfg.enabled) return;
|
|
5104
|
+
if (!messages.length) return;
|
|
5105
|
+
const payload = {
|
|
5106
|
+
session_id: `extract-${sessionId}`,
|
|
5107
|
+
app_id: cfg.appId,
|
|
5108
|
+
project_id: "default",
|
|
5109
|
+
messages: messages.map((m2) => {
|
|
5110
|
+
const text = typeof m2.content === "string" ? m2.content : "[content blocks]";
|
|
5111
|
+
const meta = m2.role === "user" ? parseMeta(text) : null;
|
|
5112
|
+
const senderName = meta?.senderName ?? (m2.role === "assistant" ? cfg.agentName : void 0) ?? m2.role;
|
|
5113
|
+
return {
|
|
5114
|
+
sender_id: cfg.appId,
|
|
5115
|
+
sender_name: senderName,
|
|
5116
|
+
role: m2.role === "toolResult" ? "tool" : m2.role,
|
|
5117
|
+
timestamp: Date.now(),
|
|
5118
|
+
content: text
|
|
5119
|
+
};
|
|
5120
|
+
})
|
|
5121
|
+
};
|
|
5122
|
+
console.log(`[everos-ingest] pushing ${payload.messages.length} messages to ${cfg.url} (appId=${cfg.appId})`);
|
|
5123
|
+
try {
|
|
5124
|
+
const resp = await fetch(`${cfg.url}/api/v1/memory/add`, {
|
|
5125
|
+
method: "POST",
|
|
5126
|
+
headers: { "Content-Type": "application/json" },
|
|
5127
|
+
body: JSON.stringify(payload),
|
|
5128
|
+
signal: AbortSignal.timeout(1e4)
|
|
5129
|
+
});
|
|
5130
|
+
if (resp.ok) {
|
|
5131
|
+
console.log(`[everos-ingest] \u2705 pushed ${payload.messages.length} messages`);
|
|
5132
|
+
} else {
|
|
5133
|
+
console.warn(`[everos-ingest] memory/add ${resp.status}`);
|
|
5134
|
+
}
|
|
5135
|
+
} catch {
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
var init_ingest = __esm({
|
|
5139
|
+
"src/memory/everos/ingest.ts"() {
|
|
5140
|
+
"use strict";
|
|
5141
|
+
}
|
|
5142
|
+
});
|
|
5143
|
+
|
|
5070
5144
|
// src/memory/memdir/extractMemories.ts
|
|
5071
5145
|
var extractMemories_exports = {};
|
|
5072
5146
|
__export(extractMemories_exports, {
|
|
@@ -5094,12 +5168,46 @@ function getMemoryTools() {
|
|
|
5094
5168
|
const allDefs = registry.definitions();
|
|
5095
5169
|
return allDefs.filter((d) => MEMORY_TOOL_NAMES.includes(d.function.name));
|
|
5096
5170
|
}
|
|
5171
|
+
function getStatePath(workspace) {
|
|
5172
|
+
return path12.join(workspace, STATE_FILE);
|
|
5173
|
+
}
|
|
5174
|
+
function loadPersistedState(workspace) {
|
|
5175
|
+
try {
|
|
5176
|
+
const p2 = getStatePath(workspace);
|
|
5177
|
+
if (fs12.existsSync(p2)) {
|
|
5178
|
+
const data = JSON.parse(fs12.readFileSync(p2, "utf-8"));
|
|
5179
|
+
for (const [sid, idx] of Object.entries(data.indices ?? {})) {
|
|
5180
|
+
lastIndexMap.set(sid, idx);
|
|
5181
|
+
}
|
|
5182
|
+
for (const [sid, ts] of Object.entries(data.timestamps ?? {})) {
|
|
5183
|
+
lastExtractTimeMap.set(sid, ts);
|
|
5184
|
+
}
|
|
5185
|
+
console.log(`[memory] loaded extract state for ${Object.keys(data.indices ?? {}).length} session(s) from ${STATE_FILE}`);
|
|
5186
|
+
}
|
|
5187
|
+
} catch (e) {
|
|
5188
|
+
console.warn(`[memory] failed to load extract state: ${e?.message ?? e}`);
|
|
5189
|
+
}
|
|
5190
|
+
}
|
|
5191
|
+
function persistState(workspace) {
|
|
5192
|
+
try {
|
|
5193
|
+
const indices = {};
|
|
5194
|
+
const timestamps = {};
|
|
5195
|
+
for (const [sid, idx] of lastIndexMap.entries()) indices[sid] = idx;
|
|
5196
|
+
for (const [sid, ts] of lastExtractTimeMap.entries()) timestamps[sid] = ts;
|
|
5197
|
+
const data = JSON.stringify({ indices, timestamps }, null, 2);
|
|
5198
|
+
fs12.writeFileSync(getStatePath(workspace), data, "utf-8");
|
|
5199
|
+
} catch (e) {
|
|
5200
|
+
console.warn(`[memory] failed to persist extract state: ${e?.message ?? e}`);
|
|
5201
|
+
}
|
|
5202
|
+
}
|
|
5097
5203
|
function createMemoryExtractor(workspace, enabled) {
|
|
5098
5204
|
let inProgress = false;
|
|
5205
|
+
loadPersistedState(workspace);
|
|
5099
5206
|
return {
|
|
5100
5207
|
reset(sessionId) {
|
|
5101
5208
|
lastIndexMap.delete(sessionId);
|
|
5102
5209
|
lastExtractTimeMap.delete(sessionId);
|
|
5210
|
+
persistState(workspace);
|
|
5103
5211
|
inProgress = false;
|
|
5104
5212
|
},
|
|
5105
5213
|
async execute(messages, provider, model, sessionId, disableThinking, intervalMinutes) {
|
|
@@ -5198,6 +5306,9 @@ ${conversationText}`
|
|
|
5198
5306
|
}
|
|
5199
5307
|
lastIndexMap.set(sessionId, messages.length - 1);
|
|
5200
5308
|
lastExtractTimeMap.set(sessionId, Date.now());
|
|
5309
|
+
persistState(workspace);
|
|
5310
|
+
pushConversation(recentMessages2, sessionId).catch(() => {
|
|
5311
|
+
});
|
|
5201
5312
|
const duration = Date.now() - startTime;
|
|
5202
5313
|
console.log(
|
|
5203
5314
|
`[memory] extractMemories finished in ${duration}ms \u2014 ${toolCount} tools used, ${result.length} chars`
|
|
@@ -5212,7 +5323,7 @@ ${conversationText}`
|
|
|
5212
5323
|
}
|
|
5213
5324
|
};
|
|
5214
5325
|
}
|
|
5215
|
-
var lastIndexMap, lastExtractTimeMap;
|
|
5326
|
+
var lastIndexMap, lastExtractTimeMap, STATE_FILE;
|
|
5216
5327
|
var init_extractMemories = __esm({
|
|
5217
5328
|
"src/memory/memdir/extractMemories.ts"() {
|
|
5218
5329
|
"use strict";
|
|
@@ -5221,8 +5332,10 @@ var init_extractMemories = __esm({
|
|
|
5221
5332
|
init_paths();
|
|
5222
5333
|
init_memoryScan();
|
|
5223
5334
|
init_extractPrompts();
|
|
5335
|
+
init_ingest();
|
|
5224
5336
|
lastIndexMap = /* @__PURE__ */ new Map();
|
|
5225
5337
|
lastExtractTimeMap = /* @__PURE__ */ new Map();
|
|
5338
|
+
STATE_FILE = ".extract-state.json";
|
|
5226
5339
|
}
|
|
5227
5340
|
});
|
|
5228
5341
|
|
|
@@ -11896,88 +12009,6 @@ ${lines.join("\n\n")}`;
|
|
|
11896
12009
|
}
|
|
11897
12010
|
});
|
|
11898
12011
|
|
|
11899
|
-
// src/memory/everos-sync.ts
|
|
11900
|
-
var everos_sync_exports = {};
|
|
11901
|
-
__export(everos_sync_exports, {
|
|
11902
|
-
createEverosSync: () => createEverosSync
|
|
11903
|
-
});
|
|
11904
|
-
function parseMeta(text) {
|
|
11905
|
-
const m2 = text.match(/^\[meta:\s*(.+?)\s*\((.+?)\)\s*@(\S+)\s*[^\]]*\]/);
|
|
11906
|
-
if (!m2) return null;
|
|
11907
|
-
return { senderName: m2[1].trim(), senderId: m2[2].trim(), platform: m2[3].trim() };
|
|
11908
|
-
}
|
|
11909
|
-
function createEverosSync(cfg) {
|
|
11910
|
-
const { enabled, url, appId, userId, agentName } = cfg;
|
|
11911
|
-
async function push(event) {
|
|
11912
|
-
if (!enabled) return;
|
|
11913
|
-
if (!event.text.trim()) return;
|
|
11914
|
-
return;
|
|
11915
|
-
const meta = event.role === "user" ? parseMeta(event.text) : null;
|
|
11916
|
-
const senderId = appId;
|
|
11917
|
-
const senderName = meta?.senderName ?? (event.role === "assistant" ? agentName : void 0) ?? event.senderName ?? event.role;
|
|
11918
|
-
console.log(`[everos-sync] role=${event.role} sender_id=${senderId} sender_name=${senderName} metaParsed=${!!meta} textLen=${event.text.length}`);
|
|
11919
|
-
try {
|
|
11920
|
-
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
11921
|
-
method: "POST",
|
|
11922
|
-
headers: { "Content-Type": "application/json" },
|
|
11923
|
-
body: JSON.stringify({
|
|
11924
|
-
session_id: event.sessionId,
|
|
11925
|
-
app_id: appId,
|
|
11926
|
-
project_id: "default",
|
|
11927
|
-
messages: [{
|
|
11928
|
-
sender_id: senderId,
|
|
11929
|
-
sender_name: senderName,
|
|
11930
|
-
role: event.role,
|
|
11931
|
-
timestamp: event.timestamp,
|
|
11932
|
-
content: event.text
|
|
11933
|
-
}]
|
|
11934
|
-
}),
|
|
11935
|
-
signal: AbortSignal.timeout(5e3)
|
|
11936
|
-
});
|
|
11937
|
-
if (!resp.ok) {
|
|
11938
|
-
console.warn(`[everos-sync] memory/add ${resp.status}`);
|
|
11939
|
-
}
|
|
11940
|
-
} catch {
|
|
11941
|
-
}
|
|
11942
|
-
}
|
|
11943
|
-
async function pushBatch(events) {
|
|
11944
|
-
if (!enabled || events.length === 0) return;
|
|
11945
|
-
try {
|
|
11946
|
-
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
11947
|
-
method: "POST",
|
|
11948
|
-
headers: { "Content-Type": "application/json" },
|
|
11949
|
-
body: JSON.stringify({
|
|
11950
|
-
session_id: events[0].sessionId,
|
|
11951
|
-
app_id: appId,
|
|
11952
|
-
project_id: "default",
|
|
11953
|
-
messages: events.map((e) => {
|
|
11954
|
-
const meta = e.role === "user" ? parseMeta(e.text) : null;
|
|
11955
|
-
const name = meta?.senderName ?? (e.role === "assistant" ? agentName : void 0) ?? e.senderName ?? e.role;
|
|
11956
|
-
return {
|
|
11957
|
-
sender_id: appId,
|
|
11958
|
-
sender_name: name,
|
|
11959
|
-
role: e.role,
|
|
11960
|
-
timestamp: e.timestamp,
|
|
11961
|
-
content: e.text
|
|
11962
|
-
};
|
|
11963
|
-
})
|
|
11964
|
-
}),
|
|
11965
|
-
signal: AbortSignal.timeout(3e4)
|
|
11966
|
-
});
|
|
11967
|
-
if (!resp.ok) {
|
|
11968
|
-
console.warn(`[everos-sync] batch add ${resp.status}`);
|
|
11969
|
-
}
|
|
11970
|
-
} catch {
|
|
11971
|
-
}
|
|
11972
|
-
}
|
|
11973
|
-
return { push, pushBatch };
|
|
11974
|
-
}
|
|
11975
|
-
var init_everos_sync = __esm({
|
|
11976
|
-
"src/memory/everos-sync.ts"() {
|
|
11977
|
-
"use strict";
|
|
11978
|
-
}
|
|
11979
|
-
});
|
|
11980
|
-
|
|
11981
12012
|
// src/cron/cron-plugin.ts
|
|
11982
12013
|
var cron_plugin_exports = {};
|
|
11983
12014
|
__export(cron_plugin_exports, {
|
|
@@ -12053,7 +12084,7 @@ var reply_blocklist_exports = {};
|
|
|
12053
12084
|
__export(reply_blocklist_exports, {
|
|
12054
12085
|
isUserBlocked: () => isUserBlocked
|
|
12055
12086
|
});
|
|
12056
|
-
import { readFileSync as readFileSync26, writeFileSync as
|
|
12087
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync16, existsSync as existsSync24 } from "node:fs";
|
|
12057
12088
|
import { join as join38 } from "node:path";
|
|
12058
12089
|
function ensureLoaded(workspace, configIds) {
|
|
12059
12090
|
if (loaded) return;
|
|
@@ -12083,7 +12114,7 @@ function ensureLoaded(workspace, configIds) {
|
|
|
12083
12114
|
function save(workspace) {
|
|
12084
12115
|
const path45 = join38(workspace, ".reply-blocklist.json");
|
|
12085
12116
|
try {
|
|
12086
|
-
|
|
12117
|
+
writeFileSync16(path45, JSON.stringify(state, null, 2), "utf-8");
|
|
12087
12118
|
} catch (err) {
|
|
12088
12119
|
console.warn(`[reply-blocklist] Failed to save: ${err.message}`);
|
|
12089
12120
|
}
|
|
@@ -18903,7 +18934,7 @@ ${text}` : text });
|
|
|
18903
18934
|
}
|
|
18904
18935
|
console.log(`[${sessionId}] >>> query start (${messages.length} msgs in history)`);
|
|
18905
18936
|
try {
|
|
18906
|
-
const { writeFileSync:
|
|
18937
|
+
const { writeFileSync: writeFileSync18 } = await import("node:fs");
|
|
18907
18938
|
const { join: join40 } = await import("node:path");
|
|
18908
18939
|
const contextPath = join40(workspace, ".context-debug.txt");
|
|
18909
18940
|
const lines = [
|
|
@@ -18958,7 +18989,7 @@ ${text}` : text });
|
|
|
18958
18989
|
}
|
|
18959
18990
|
}
|
|
18960
18991
|
lines.push("", "=== End ===");
|
|
18961
|
-
|
|
18992
|
+
writeFileSync18(contextPath, lines.join("\n") + "\n\n", { encoding: "utf-8", flag: "a" });
|
|
18962
18993
|
console.log(`[${sessionId}] Context snapshot \u2192 ${contextPath}`);
|
|
18963
18994
|
} catch (err) {
|
|
18964
18995
|
console.warn(`[${sessionId}] Context snapshot failed: ${err.message}`);
|
|
@@ -28016,31 +28047,6 @@ ${content}`
|
|
|
28016
28047
|
sessions.migrateOldSessions();
|
|
28017
28048
|
sessions.startIdleCleanup();
|
|
28018
28049
|
cleanupArchivedSessionTranscripts(sessions.sessionsDir);
|
|
28019
|
-
const everosCfg = config.everos;
|
|
28020
|
-
if (everosCfg?.enabled) {
|
|
28021
|
-
const { createEverosSync: createEverosSync2 } = await Promise.resolve().then(() => (init_everos_sync(), everos_sync_exports));
|
|
28022
|
-
const everosSync = createEverosSync2({
|
|
28023
|
-
enabled: true,
|
|
28024
|
-
url: everosCfg.everosUrl || "http://127.0.0.1:8100",
|
|
28025
|
-
appId: everosCfg.userId || "default",
|
|
28026
|
-
userId: everosCfg.userId || "default",
|
|
28027
|
-
agentName: everosCfg.agentName || everosCfg.userId || "assistant"
|
|
28028
|
-
});
|
|
28029
|
-
sessions.onWriterCreated = (writer, sessionId) => {
|
|
28030
|
-
writer.onMessageWritten = (msg2) => {
|
|
28031
|
-
console.log(`[everos-sync] onMessageWritten fired: role=${msg2.role} len=${msg2.text.length}`);
|
|
28032
|
-
everosSync.push({
|
|
28033
|
-
sessionId: writer.engineSessionId || sessionId,
|
|
28034
|
-
role: msg2.role === "toolResult" ? "tool" : msg2.role,
|
|
28035
|
-
text: msg2.text,
|
|
28036
|
-
timestamp: new Date(msg2.timestamp).getTime()
|
|
28037
|
-
}).catch((e) => console.warn(`[everos-sync] push error: ${e}`));
|
|
28038
|
-
};
|
|
28039
|
-
};
|
|
28040
|
-
console.log(`[everos-sync] hook registered (appId=${everosCfg.userId})`);
|
|
28041
|
-
} else {
|
|
28042
|
-
console.log(`[everos-sync] SKIPPED \u2014 config.everos not enabled or missing`);
|
|
28043
|
-
}
|
|
28044
28050
|
const channelManager = new ChannelManager();
|
|
28045
28051
|
const memoryRecallProvider = createMemorySideProvider(
|
|
28046
28052
|
config.topics?.recall,
|
package/dist/main.mjs
CHANGED
|
@@ -3553,6 +3553,10 @@ ${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
|
|
|
3553
3553
|
});
|
|
3554
3554
|
|
|
3555
3555
|
// src/config/live.ts
|
|
3556
|
+
var live_exports = {};
|
|
3557
|
+
__export(live_exports, {
|
|
3558
|
+
liveConfig: () => liveConfig
|
|
3559
|
+
});
|
|
3556
3560
|
var LiveConfigClass, liveConfig;
|
|
3557
3561
|
var init_live = __esm({
|
|
3558
3562
|
"src/config/live.ts"() {
|
|
@@ -5067,6 +5071,76 @@ var init_extractPrompts = __esm({
|
|
|
5067
5071
|
}
|
|
5068
5072
|
});
|
|
5069
5073
|
|
|
5074
|
+
// src/memory/everos/ingest.ts
|
|
5075
|
+
function parseMeta(text) {
|
|
5076
|
+
const m2 = text.match(/^\[meta:\s*(.+?)\s*\((.+?)\)\s*@(\S+)\s*[^\]]*\]/);
|
|
5077
|
+
if (!m2) return null;
|
|
5078
|
+
return { senderName: m2[1].trim() };
|
|
5079
|
+
}
|
|
5080
|
+
async function readConfig() {
|
|
5081
|
+
const defaults = {
|
|
5082
|
+
url: "http://127.0.0.1:8100",
|
|
5083
|
+
appId: "default",
|
|
5084
|
+
agentName: "assistant",
|
|
5085
|
+
enabled: false
|
|
5086
|
+
};
|
|
5087
|
+
try {
|
|
5088
|
+
const { liveConfig: liveConfig2 } = await Promise.resolve().then(() => (init_live(), live_exports));
|
|
5089
|
+
const cfg = liveConfig2.all()?.everos;
|
|
5090
|
+
if (!cfg) return defaults;
|
|
5091
|
+
return {
|
|
5092
|
+
url: cfg.everosUrl || defaults.url,
|
|
5093
|
+
appId: cfg.userId || defaults.appId,
|
|
5094
|
+
agentName: cfg.agentName || cfg.userId || defaults.agentName,
|
|
5095
|
+
enabled: cfg.enabled === true
|
|
5096
|
+
};
|
|
5097
|
+
} catch {
|
|
5098
|
+
return defaults;
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
async function pushConversation(messages, sessionId) {
|
|
5102
|
+
const cfg = await readConfig();
|
|
5103
|
+
if (!cfg.enabled) return;
|
|
5104
|
+
if (!messages.length) return;
|
|
5105
|
+
const payload = {
|
|
5106
|
+
session_id: `extract-${sessionId}`,
|
|
5107
|
+
app_id: cfg.appId,
|
|
5108
|
+
project_id: "default",
|
|
5109
|
+
messages: messages.map((m2) => {
|
|
5110
|
+
const text = typeof m2.content === "string" ? m2.content : "[content blocks]";
|
|
5111
|
+
const meta = m2.role === "user" ? parseMeta(text) : null;
|
|
5112
|
+
const senderName = meta?.senderName ?? (m2.role === "assistant" ? cfg.agentName : void 0) ?? m2.role;
|
|
5113
|
+
return {
|
|
5114
|
+
sender_id: cfg.appId,
|
|
5115
|
+
sender_name: senderName,
|
|
5116
|
+
role: m2.role === "toolResult" ? "tool" : m2.role,
|
|
5117
|
+
timestamp: Date.now(),
|
|
5118
|
+
content: text
|
|
5119
|
+
};
|
|
5120
|
+
})
|
|
5121
|
+
};
|
|
5122
|
+
console.log(`[everos-ingest] pushing ${payload.messages.length} messages to ${cfg.url} (appId=${cfg.appId})`);
|
|
5123
|
+
try {
|
|
5124
|
+
const resp = await fetch(`${cfg.url}/api/v1/memory/add`, {
|
|
5125
|
+
method: "POST",
|
|
5126
|
+
headers: { "Content-Type": "application/json" },
|
|
5127
|
+
body: JSON.stringify(payload),
|
|
5128
|
+
signal: AbortSignal.timeout(1e4)
|
|
5129
|
+
});
|
|
5130
|
+
if (resp.ok) {
|
|
5131
|
+
console.log(`[everos-ingest] \u2705 pushed ${payload.messages.length} messages`);
|
|
5132
|
+
} else {
|
|
5133
|
+
console.warn(`[everos-ingest] memory/add ${resp.status}`);
|
|
5134
|
+
}
|
|
5135
|
+
} catch {
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
var init_ingest = __esm({
|
|
5139
|
+
"src/memory/everos/ingest.ts"() {
|
|
5140
|
+
"use strict";
|
|
5141
|
+
}
|
|
5142
|
+
});
|
|
5143
|
+
|
|
5070
5144
|
// src/memory/memdir/extractMemories.ts
|
|
5071
5145
|
var extractMemories_exports = {};
|
|
5072
5146
|
__export(extractMemories_exports, {
|
|
@@ -5094,12 +5168,46 @@ function getMemoryTools() {
|
|
|
5094
5168
|
const allDefs = registry.definitions();
|
|
5095
5169
|
return allDefs.filter((d) => MEMORY_TOOL_NAMES.includes(d.function.name));
|
|
5096
5170
|
}
|
|
5171
|
+
function getStatePath(workspace) {
|
|
5172
|
+
return path12.join(workspace, STATE_FILE);
|
|
5173
|
+
}
|
|
5174
|
+
function loadPersistedState(workspace) {
|
|
5175
|
+
try {
|
|
5176
|
+
const p2 = getStatePath(workspace);
|
|
5177
|
+
if (fs12.existsSync(p2)) {
|
|
5178
|
+
const data = JSON.parse(fs12.readFileSync(p2, "utf-8"));
|
|
5179
|
+
for (const [sid, idx] of Object.entries(data.indices ?? {})) {
|
|
5180
|
+
lastIndexMap.set(sid, idx);
|
|
5181
|
+
}
|
|
5182
|
+
for (const [sid, ts] of Object.entries(data.timestamps ?? {})) {
|
|
5183
|
+
lastExtractTimeMap.set(sid, ts);
|
|
5184
|
+
}
|
|
5185
|
+
console.log(`[memory] loaded extract state for ${Object.keys(data.indices ?? {}).length} session(s) from ${STATE_FILE}`);
|
|
5186
|
+
}
|
|
5187
|
+
} catch (e) {
|
|
5188
|
+
console.warn(`[memory] failed to load extract state: ${e?.message ?? e}`);
|
|
5189
|
+
}
|
|
5190
|
+
}
|
|
5191
|
+
function persistState(workspace) {
|
|
5192
|
+
try {
|
|
5193
|
+
const indices = {};
|
|
5194
|
+
const timestamps = {};
|
|
5195
|
+
for (const [sid, idx] of lastIndexMap.entries()) indices[sid] = idx;
|
|
5196
|
+
for (const [sid, ts] of lastExtractTimeMap.entries()) timestamps[sid] = ts;
|
|
5197
|
+
const data = JSON.stringify({ indices, timestamps }, null, 2);
|
|
5198
|
+
fs12.writeFileSync(getStatePath(workspace), data, "utf-8");
|
|
5199
|
+
} catch (e) {
|
|
5200
|
+
console.warn(`[memory] failed to persist extract state: ${e?.message ?? e}`);
|
|
5201
|
+
}
|
|
5202
|
+
}
|
|
5097
5203
|
function createMemoryExtractor(workspace, enabled) {
|
|
5098
5204
|
let inProgress = false;
|
|
5205
|
+
loadPersistedState(workspace);
|
|
5099
5206
|
return {
|
|
5100
5207
|
reset(sessionId) {
|
|
5101
5208
|
lastIndexMap.delete(sessionId);
|
|
5102
5209
|
lastExtractTimeMap.delete(sessionId);
|
|
5210
|
+
persistState(workspace);
|
|
5103
5211
|
inProgress = false;
|
|
5104
5212
|
},
|
|
5105
5213
|
async execute(messages, provider, model, sessionId, disableThinking, intervalMinutes) {
|
|
@@ -5198,6 +5306,9 @@ ${conversationText}`
|
|
|
5198
5306
|
}
|
|
5199
5307
|
lastIndexMap.set(sessionId, messages.length - 1);
|
|
5200
5308
|
lastExtractTimeMap.set(sessionId, Date.now());
|
|
5309
|
+
persistState(workspace);
|
|
5310
|
+
pushConversation(recentMessages2, sessionId).catch(() => {
|
|
5311
|
+
});
|
|
5201
5312
|
const duration = Date.now() - startTime;
|
|
5202
5313
|
console.log(
|
|
5203
5314
|
`[memory] extractMemories finished in ${duration}ms \u2014 ${toolCount} tools used, ${result.length} chars`
|
|
@@ -5212,7 +5323,7 @@ ${conversationText}`
|
|
|
5212
5323
|
}
|
|
5213
5324
|
};
|
|
5214
5325
|
}
|
|
5215
|
-
var lastIndexMap, lastExtractTimeMap;
|
|
5326
|
+
var lastIndexMap, lastExtractTimeMap, STATE_FILE;
|
|
5216
5327
|
var init_extractMemories = __esm({
|
|
5217
5328
|
"src/memory/memdir/extractMemories.ts"() {
|
|
5218
5329
|
"use strict";
|
|
@@ -5221,8 +5332,10 @@ var init_extractMemories = __esm({
|
|
|
5221
5332
|
init_paths();
|
|
5222
5333
|
init_memoryScan();
|
|
5223
5334
|
init_extractPrompts();
|
|
5335
|
+
init_ingest();
|
|
5224
5336
|
lastIndexMap = /* @__PURE__ */ new Map();
|
|
5225
5337
|
lastExtractTimeMap = /* @__PURE__ */ new Map();
|
|
5338
|
+
STATE_FILE = ".extract-state.json";
|
|
5226
5339
|
}
|
|
5227
5340
|
});
|
|
5228
5341
|
|
|
@@ -12251,88 +12364,6 @@ ${lines.join("\n\n")}`;
|
|
|
12251
12364
|
}
|
|
12252
12365
|
});
|
|
12253
12366
|
|
|
12254
|
-
// src/memory/everos-sync.ts
|
|
12255
|
-
var everos_sync_exports = {};
|
|
12256
|
-
__export(everos_sync_exports, {
|
|
12257
|
-
createEverosSync: () => createEverosSync
|
|
12258
|
-
});
|
|
12259
|
-
function parseMeta(text) {
|
|
12260
|
-
const m2 = text.match(/^\[meta:\s*(.+?)\s*\((.+?)\)\s*@(\S+)\s*[^\]]*\]/);
|
|
12261
|
-
if (!m2) return null;
|
|
12262
|
-
return { senderName: m2[1].trim(), senderId: m2[2].trim(), platform: m2[3].trim() };
|
|
12263
|
-
}
|
|
12264
|
-
function createEverosSync(cfg) {
|
|
12265
|
-
const { enabled, url, appId, userId, agentName } = cfg;
|
|
12266
|
-
async function push(event) {
|
|
12267
|
-
if (!enabled) return;
|
|
12268
|
-
if (!event.text.trim()) return;
|
|
12269
|
-
return;
|
|
12270
|
-
const meta = event.role === "user" ? parseMeta(event.text) : null;
|
|
12271
|
-
const senderId = appId;
|
|
12272
|
-
const senderName = meta?.senderName ?? (event.role === "assistant" ? agentName : void 0) ?? event.senderName ?? event.role;
|
|
12273
|
-
console.log(`[everos-sync] role=${event.role} sender_id=${senderId} sender_name=${senderName} metaParsed=${!!meta} textLen=${event.text.length}`);
|
|
12274
|
-
try {
|
|
12275
|
-
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
12276
|
-
method: "POST",
|
|
12277
|
-
headers: { "Content-Type": "application/json" },
|
|
12278
|
-
body: JSON.stringify({
|
|
12279
|
-
session_id: event.sessionId,
|
|
12280
|
-
app_id: appId,
|
|
12281
|
-
project_id: "default",
|
|
12282
|
-
messages: [{
|
|
12283
|
-
sender_id: senderId,
|
|
12284
|
-
sender_name: senderName,
|
|
12285
|
-
role: event.role,
|
|
12286
|
-
timestamp: event.timestamp,
|
|
12287
|
-
content: event.text
|
|
12288
|
-
}]
|
|
12289
|
-
}),
|
|
12290
|
-
signal: AbortSignal.timeout(5e3)
|
|
12291
|
-
});
|
|
12292
|
-
if (!resp.ok) {
|
|
12293
|
-
console.warn(`[everos-sync] memory/add ${resp.status}`);
|
|
12294
|
-
}
|
|
12295
|
-
} catch {
|
|
12296
|
-
}
|
|
12297
|
-
}
|
|
12298
|
-
async function pushBatch(events) {
|
|
12299
|
-
if (!enabled || events.length === 0) return;
|
|
12300
|
-
try {
|
|
12301
|
-
const resp = await fetch(`${url}/api/v1/memory/add`, {
|
|
12302
|
-
method: "POST",
|
|
12303
|
-
headers: { "Content-Type": "application/json" },
|
|
12304
|
-
body: JSON.stringify({
|
|
12305
|
-
session_id: events[0].sessionId,
|
|
12306
|
-
app_id: appId,
|
|
12307
|
-
project_id: "default",
|
|
12308
|
-
messages: events.map((e) => {
|
|
12309
|
-
const meta = e.role === "user" ? parseMeta(e.text) : null;
|
|
12310
|
-
const name = meta?.senderName ?? (e.role === "assistant" ? agentName : void 0) ?? e.senderName ?? e.role;
|
|
12311
|
-
return {
|
|
12312
|
-
sender_id: appId,
|
|
12313
|
-
sender_name: name,
|
|
12314
|
-
role: e.role,
|
|
12315
|
-
timestamp: e.timestamp,
|
|
12316
|
-
content: e.text
|
|
12317
|
-
};
|
|
12318
|
-
})
|
|
12319
|
-
}),
|
|
12320
|
-
signal: AbortSignal.timeout(3e4)
|
|
12321
|
-
});
|
|
12322
|
-
if (!resp.ok) {
|
|
12323
|
-
console.warn(`[everos-sync] batch add ${resp.status}`);
|
|
12324
|
-
}
|
|
12325
|
-
} catch {
|
|
12326
|
-
}
|
|
12327
|
-
}
|
|
12328
|
-
return { push, pushBatch };
|
|
12329
|
-
}
|
|
12330
|
-
var init_everos_sync = __esm({
|
|
12331
|
-
"src/memory/everos-sync.ts"() {
|
|
12332
|
-
"use strict";
|
|
12333
|
-
}
|
|
12334
|
-
});
|
|
12335
|
-
|
|
12336
12367
|
// src/cron/cron-plugin.ts
|
|
12337
12368
|
var cron_plugin_exports = {};
|
|
12338
12369
|
__export(cron_plugin_exports, {
|
|
@@ -12408,7 +12439,7 @@ var reply_blocklist_exports = {};
|
|
|
12408
12439
|
__export(reply_blocklist_exports, {
|
|
12409
12440
|
isUserBlocked: () => isUserBlocked
|
|
12410
12441
|
});
|
|
12411
|
-
import { readFileSync as readFileSync26, writeFileSync as
|
|
12442
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync16, existsSync as existsSync24 } from "node:fs";
|
|
12412
12443
|
import { join as join38 } from "node:path";
|
|
12413
12444
|
function ensureLoaded(workspace, configIds) {
|
|
12414
12445
|
if (loaded) return;
|
|
@@ -12438,7 +12469,7 @@ function ensureLoaded(workspace, configIds) {
|
|
|
12438
12469
|
function save(workspace) {
|
|
12439
12470
|
const path45 = join38(workspace, ".reply-blocklist.json");
|
|
12440
12471
|
try {
|
|
12441
|
-
|
|
12472
|
+
writeFileSync16(path45, JSON.stringify(state, null, 2), "utf-8");
|
|
12442
12473
|
} catch (err) {
|
|
12443
12474
|
console.warn(`[reply-blocklist] Failed to save: ${err.message}`);
|
|
12444
12475
|
}
|
|
@@ -19261,7 +19292,7 @@ ${text}` : text });
|
|
|
19261
19292
|
}
|
|
19262
19293
|
console.log(`[${sessionId}] >>> query start (${messages.length} msgs in history)`);
|
|
19263
19294
|
try {
|
|
19264
|
-
const { writeFileSync:
|
|
19295
|
+
const { writeFileSync: writeFileSync18 } = await import("node:fs");
|
|
19265
19296
|
const { join: join41 } = await import("node:path");
|
|
19266
19297
|
const contextPath = join41(workspace, ".context-debug.txt");
|
|
19267
19298
|
const lines = [
|
|
@@ -19316,7 +19347,7 @@ ${text}` : text });
|
|
|
19316
19347
|
}
|
|
19317
19348
|
}
|
|
19318
19349
|
lines.push("", "=== End ===");
|
|
19319
|
-
|
|
19350
|
+
writeFileSync18(contextPath, lines.join("\n") + "\n\n", { encoding: "utf-8", flag: "a" });
|
|
19320
19351
|
console.log(`[${sessionId}] Context snapshot \u2192 ${contextPath}`);
|
|
19321
19352
|
} catch (err) {
|
|
19322
19353
|
console.warn(`[${sessionId}] Context snapshot failed: ${err.message}`);
|
|
@@ -28082,31 +28113,6 @@ ${content}`
|
|
|
28082
28113
|
sessions.migrateOldSessions();
|
|
28083
28114
|
sessions.startIdleCleanup();
|
|
28084
28115
|
cleanupArchivedSessionTranscripts(sessions.sessionsDir);
|
|
28085
|
-
const everosCfg = config2.everos;
|
|
28086
|
-
if (everosCfg?.enabled) {
|
|
28087
|
-
const { createEverosSync: createEverosSync2 } = await Promise.resolve().then(() => (init_everos_sync(), everos_sync_exports));
|
|
28088
|
-
const everosSync = createEverosSync2({
|
|
28089
|
-
enabled: true,
|
|
28090
|
-
url: everosCfg.everosUrl || "http://127.0.0.1:8100",
|
|
28091
|
-
appId: everosCfg.userId || "default",
|
|
28092
|
-
userId: everosCfg.userId || "default",
|
|
28093
|
-
agentName: everosCfg.agentName || everosCfg.userId || "assistant"
|
|
28094
|
-
});
|
|
28095
|
-
sessions.onWriterCreated = (writer, sessionId) => {
|
|
28096
|
-
writer.onMessageWritten = (msg2) => {
|
|
28097
|
-
console.log(`[everos-sync] onMessageWritten fired: role=${msg2.role} len=${msg2.text.length}`);
|
|
28098
|
-
everosSync.push({
|
|
28099
|
-
sessionId: writer.engineSessionId || sessionId,
|
|
28100
|
-
role: msg2.role === "toolResult" ? "tool" : msg2.role,
|
|
28101
|
-
text: msg2.text,
|
|
28102
|
-
timestamp: new Date(msg2.timestamp).getTime()
|
|
28103
|
-
}).catch((e) => console.warn(`[everos-sync] push error: ${e}`));
|
|
28104
|
-
};
|
|
28105
|
-
};
|
|
28106
|
-
console.log(`[everos-sync] hook registered (appId=${everosCfg.userId})`);
|
|
28107
|
-
} else {
|
|
28108
|
-
console.log(`[everos-sync] SKIPPED \u2014 config.everos not enabled or missing`);
|
|
28109
|
-
}
|
|
28110
28116
|
const channelManager = new ChannelManager();
|
|
28111
28117
|
const memoryRecallProvider = createMemorySideProvider(
|
|
28112
28118
|
config2.topics?.recall,
|
package/package.json
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "engine7",
|
|
3
|
-
"version": "7.1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Engine 7 — Self-hosted AI agent engine",
|
|
6
|
-
"main": "dist/main.mjs",
|
|
7
|
-
"bin": {
|
|
8
|
-
"engine7": "bin/engine7"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "node scripts/build.mjs",
|
|
12
|
-
"start": "node dist/main.mjs"
|
|
13
|
-
},
|
|
14
|
-
"engines": {
|
|
15
|
-
"node": ">=22"
|
|
16
|
-
},
|
|
17
|
-
"os": [
|
|
18
|
-
"win32",
|
|
19
|
-
"linux",
|
|
20
|
-
"darwin"
|
|
21
|
-
],
|
|
22
|
-
"cpu": [
|
|
23
|
-
"x64",
|
|
24
|
-
"arm64"
|
|
25
|
-
],
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/node": "^22.19.19",
|
|
28
|
-
"@types/turndown": "^5.0.6",
|
|
29
|
-
"tsx": "^4.22.3",
|
|
30
|
-
"typescript": "^6.0.0"
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@larksuiteoapi/node-sdk": "^1.66.1",
|
|
34
|
-
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
35
|
-
"chokidar": "^5.0.0",
|
|
36
|
-
"croner": "^10.0.1",
|
|
37
|
-
"discord.js": "^14.26.4",
|
|
38
|
-
"qrcode-terminal": "^0.12.0",
|
|
39
|
-
"sharp": "^0.34.5",
|
|
40
|
-
"sqlite-vec": "^0.1.9",
|
|
41
|
-
"turndown": "^7.2.4",
|
|
42
|
-
"typebox": "^1.1.38"
|
|
43
|
-
},
|
|
44
|
-
"optionalDependencies": {
|
|
45
|
-
"sqlite-vec-windows-x64": "^0.1.9",
|
|
46
|
-
"sqlite-vec-linux-x64": "^0.1.9",
|
|
47
|
-
"sqlite-vec-linux-arm64": "^0.1.9",
|
|
48
|
-
"sqlite-vec-darwin-x64": "^0.1.9",
|
|
49
|
-
"sqlite-vec-darwin-arm64": "^0.1.9"
|
|
50
|
-
},
|
|
51
|
-
"files": [
|
|
52
|
-
"dist/**/*.mjs",
|
|
53
|
-
"bin/**/*",
|
|
54
|
-
"templates/**/*",
|
|
55
|
-
"src/memory/everos/python/**/*",
|
|
56
|
-
"README.md"
|
|
57
|
-
]
|
|
58
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "engine7",
|
|
3
|
+
"version": "7.1.29",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Engine 7 — Self-hosted AI agent engine",
|
|
6
|
+
"main": "dist/main.mjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"engine7": "bin/engine7"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "node scripts/build.mjs",
|
|
12
|
+
"start": "node dist/main.mjs"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22"
|
|
16
|
+
},
|
|
17
|
+
"os": [
|
|
18
|
+
"win32",
|
|
19
|
+
"linux",
|
|
20
|
+
"darwin"
|
|
21
|
+
],
|
|
22
|
+
"cpu": [
|
|
23
|
+
"x64",
|
|
24
|
+
"arm64"
|
|
25
|
+
],
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.19.19",
|
|
28
|
+
"@types/turndown": "^5.0.6",
|
|
29
|
+
"tsx": "^4.22.3",
|
|
30
|
+
"typescript": "^6.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@larksuiteoapi/node-sdk": "^1.66.1",
|
|
34
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
35
|
+
"chokidar": "^5.0.0",
|
|
36
|
+
"croner": "^10.0.1",
|
|
37
|
+
"discord.js": "^14.26.4",
|
|
38
|
+
"qrcode-terminal": "^0.12.0",
|
|
39
|
+
"sharp": "^0.34.5",
|
|
40
|
+
"sqlite-vec": "^0.1.9",
|
|
41
|
+
"turndown": "^7.2.4",
|
|
42
|
+
"typebox": "^1.1.38"
|
|
43
|
+
},
|
|
44
|
+
"optionalDependencies": {
|
|
45
|
+
"sqlite-vec-windows-x64": "^0.1.9",
|
|
46
|
+
"sqlite-vec-linux-x64": "^0.1.9",
|
|
47
|
+
"sqlite-vec-linux-arm64": "^0.1.9",
|
|
48
|
+
"sqlite-vec-darwin-x64": "^0.1.9",
|
|
49
|
+
"sqlite-vec-darwin-arm64": "^0.1.9"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist/**/*.mjs",
|
|
53
|
+
"bin/**/*",
|
|
54
|
+
"templates/**/*",
|
|
55
|
+
"src/memory/everos/python/**/*",
|
|
56
|
+
"README.md"
|
|
57
|
+
]
|
|
58
|
+
}
|