engine7 7.1.27 → 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.
@@ -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
 
@@ -5747,11 +5860,11 @@ async function readLastConsolidatedAt(memoryDir) {
5747
5860
  }
5748
5861
  }
5749
5862
  async function tryAcquireConsolidationLock(memoryDir) {
5750
- const path44 = lockPath(memoryDir);
5863
+ const path45 = lockPath(memoryDir);
5751
5864
  let mtimeMs;
5752
5865
  let holderPid;
5753
5866
  try {
5754
- const [s2, raw] = await Promise.all([stat3(path44), readFile5(path44, "utf8")]);
5867
+ const [s2, raw] = await Promise.all([stat3(path45), readFile5(path45, "utf8")]);
5755
5868
  mtimeMs = s2.mtimeMs;
5756
5869
  const parsed = parseInt(raw.trim(), 10);
5757
5870
  holderPid = Number.isFinite(parsed) ? parsed : void 0;
@@ -5764,10 +5877,10 @@ async function tryAcquireConsolidationLock(memoryDir) {
5764
5877
  }
5765
5878
  }
5766
5879
  await mkdir3(memoryDir, { recursive: true });
5767
- await writeFile4(path44, String(process.pid));
5880
+ await writeFile4(path45, String(process.pid));
5768
5881
  let verify2;
5769
5882
  try {
5770
- verify2 = await readFile5(path44, "utf8");
5883
+ verify2 = await readFile5(path45, "utf8");
5771
5884
  } catch {
5772
5885
  return null;
5773
5886
  }
@@ -5775,15 +5888,15 @@ async function tryAcquireConsolidationLock(memoryDir) {
5775
5888
  return mtimeMs ?? 0;
5776
5889
  }
5777
5890
  async function rollbackConsolidationLock(memoryDir, priorMtime) {
5778
- const path44 = lockPath(memoryDir);
5891
+ const path45 = lockPath(memoryDir);
5779
5892
  try {
5780
5893
  if (priorMtime === 0) {
5781
- await unlink(path44);
5894
+ await unlink(path45);
5782
5895
  return;
5783
5896
  }
5784
- await writeFile4(path44, "");
5897
+ await writeFile4(path45, "");
5785
5898
  const t = priorMtime / 1e3;
5786
- await utimes(path44, t, t);
5899
+ await utimes(path45, t, t);
5787
5900
  } catch (e) {
5788
5901
  console.log(`[autoDream] rollback failed: ${e.message} \u2014 next trigger delayed to minHours`);
5789
5902
  }
@@ -6116,15 +6229,15 @@ __export(TodoWriteTool_exports, {
6116
6229
  loadTodos: () => loadTodos
6117
6230
  });
6118
6231
  import fs31 from "node:fs";
6119
- import path31 from "node:path";
6232
+ import path32 from "node:path";
6120
6233
  function initTodoStore(stateDir) {
6121
- todosDir = path31.join(stateDir, "todos");
6234
+ todosDir = path32.join(stateDir, "todos");
6122
6235
  if (!fs31.existsSync(todosDir)) {
6123
6236
  fs31.mkdirSync(todosDir, { recursive: true });
6124
6237
  }
6125
6238
  }
6126
6239
  function todoFilePath(sessionId) {
6127
- return path31.join(todosDir, `${sessionId}.json`);
6240
+ return path32.join(todosDir, `${sessionId}.json`);
6128
6241
  }
6129
6242
  function loadTodos(sessionId) {
6130
6243
  if (!todosDir) return [];
@@ -6220,15 +6333,15 @@ __export(tasks_exports, {
6220
6333
  updateTask: () => updateTask
6221
6334
  });
6222
6335
  import * as fs33 from "node:fs";
6223
- import * as path33 from "node:path";
6336
+ import * as path34 from "node:path";
6224
6337
  function sanitizePathComponent2(input) {
6225
6338
  return input.replace(/[^a-zA-Z0-9_-]/g, "-");
6226
6339
  }
6227
6340
  function getTasksDir2(stateDir, listId) {
6228
- return path33.join(stateDir, "tasks", sanitizePathComponent2(listId));
6341
+ return path34.join(stateDir, "tasks", sanitizePathComponent2(listId));
6229
6342
  }
6230
6343
  function getTaskPath(stateDir, listId, taskId) {
6231
- return path33.join(getTasksDir2(stateDir, listId), `${sanitizePathComponent2(taskId)}.json`);
6344
+ return path34.join(getTasksDir2(stateDir, listId), `${sanitizePathComponent2(taskId)}.json`);
6232
6345
  }
6233
6346
  function ensureTasksDir2(stateDir, listId) {
6234
6347
  const dir = getTasksDir2(stateDir, listId);
@@ -6236,7 +6349,7 @@ function ensureTasksDir2(stateDir, listId) {
6236
6349
  return dir;
6237
6350
  }
6238
6351
  function getHighWaterMarkPath(stateDir, listId) {
6239
- return path33.join(getTasksDir2(stateDir, listId), HIGH_WATER_MARK_FILE);
6352
+ return path34.join(getTasksDir2(stateDir, listId), HIGH_WATER_MARK_FILE);
6240
6353
  }
6241
6354
  function readHighWaterMark(stateDir, listId) {
6242
6355
  try {
@@ -6442,7 +6555,7 @@ __export(read_exports, {
6442
6555
  readFileState: () => readFileState
6443
6556
  });
6444
6557
  import * as fs34 from "node:fs";
6445
- import * as path34 from "node:path";
6558
+ import * as path35 from "node:path";
6446
6559
  function isBlockedDevicePath(filePath) {
6447
6560
  if (BLOCKED_DEVICE_PATHS.has(filePath)) return true;
6448
6561
  if (filePath.startsWith("/proc/") && (filePath.endsWith("/fd/0") || filePath.endsWith("/fd/1") || filePath.endsWith("/fd/2"))) return true;
@@ -6621,7 +6734,7 @@ Usage:
6621
6734
  return { content: `\u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`, isError: true };
6622
6735
  }
6623
6736
  const stat4 = fs34.statSync(filePath);
6624
- const baseName = path34.basename(filePath).toUpperCase();
6737
+ const baseName = path35.basename(filePath).toUpperCase();
6625
6738
  if (BLOCKED_BASENAMES.has(baseName)) {
6626
6739
  return { content: `\u8BBE\u5907\u6587\u4EF6\u4E0D\u652F\u6301\u8BFB\u53D6: ${filePath}`, isError: true };
6627
6740
  }
@@ -6631,7 +6744,7 @@ Usage:
6631
6744
  if (stat4.isDirectory()) {
6632
6745
  const entries = fs34.readdirSync(filePath);
6633
6746
  const items = entries.map((e) => {
6634
- const full = path34.join(filePath, e);
6747
+ const full = path35.join(filePath, e);
6635
6748
  try {
6636
6749
  const s2 = fs34.statSync(full);
6637
6750
  return s2.isDirectory() ? `${e}/` : e;
@@ -6642,7 +6755,7 @@ Usage:
6642
6755
  return { content: `\u76EE\u5F55 (${entries.length} \u9879):
6643
6756
  ${items.join("\n")}` };
6644
6757
  }
6645
- const ext = path34.extname(filePath).toLowerCase();
6758
+ const ext = path35.extname(filePath).toLowerCase();
6646
6759
  if (BINARY_EXTENSIONS.has(ext)) {
6647
6760
  return { content: `\u4E8C\u8FDB\u5236\u6587\u4EF6\u4E0D\u652F\u6301\u8BFB\u53D6 (${ext}): ${filePath}`, isError: true };
6648
6761
  }
@@ -6691,7 +6804,7 @@ ${result}` : result };
6691
6804
  // src/tools/write.ts
6692
6805
  var write_exports = {};
6693
6806
  import * as fs35 from "node:fs";
6694
- import * as path35 from "node:path";
6807
+ import * as path36 from "node:path";
6695
6808
  function isBlockedPath(filePath) {
6696
6809
  return BLOCKED_PATTERNS.some((p2) => p2.test(filePath));
6697
6810
  }
@@ -6835,7 +6948,7 @@ Usage:
6835
6948
  }
6836
6949
  }
6837
6950
  }
6838
- const dir = path35.dirname(filePath);
6951
+ const dir = path36.dirname(filePath);
6839
6952
  try {
6840
6953
  fs35.mkdirSync(dir, { recursive: true });
6841
6954
  } catch (e) {
@@ -6871,7 +6984,7 @@ ${simpleDiff(oldContent, content)}`;
6871
6984
  // src/tools/edit.ts
6872
6985
  var edit_exports = {};
6873
6986
  import * as fs36 from "node:fs";
6874
- import * as path36 from "node:path";
6987
+ import * as path37 from "node:path";
6875
6988
  function normalizeQuotes(str) {
6876
6989
  return str.replaceAll(LEFT_SINGLE_CURLY, "'").replaceAll(RIGHT_SINGLE_CURLY, "'").replaceAll(LEFT_DOUBLE_CURLY, '"').replaceAll(RIGHT_DOUBLE_CURLY, '"');
6877
6990
  }
@@ -7034,7 +7147,7 @@ Usage:
7034
7147
  } catch (e) {
7035
7148
  if (e.code === "ENOENT") {
7036
7149
  if (oldString === "") {
7037
- const dir = path36.dirname(filePath);
7150
+ const dir = path37.dirname(filePath);
7038
7151
  fs36.mkdirSync(dir, { recursive: true });
7039
7152
  fs36.writeFileSync(filePath, newString, "utf-8");
7040
7153
  readFileState.set(filePath, { timestamp: fs36.statSync(filePath).mtimeMs });
@@ -7114,7 +7227,7 @@ ${diffView}`
7114
7227
  // src/tools/glob.ts
7115
7228
  var glob_exports = {};
7116
7229
  import * as fs37 from "node:fs";
7117
- import * as path37 from "node:path";
7230
+ import * as path38 from "node:path";
7118
7231
  function globMatch(pattern, filename) {
7119
7232
  const regexStr = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/\{\{GLOBSTAR\}\}/g, ".*");
7120
7233
  try {
@@ -7140,12 +7253,12 @@ function findFiles(dir, pattern, limit, baseDir) {
7140
7253
  }
7141
7254
  for (const entry of entries) {
7142
7255
  if (truncated) return;
7143
- const fullPath = path37.join(currentDir, entry.name);
7256
+ const fullPath = path38.join(currentDir, entry.name);
7144
7257
  if (entry.isDirectory()) {
7145
7258
  if (VCS_DIRS.has(entry.name)) continue;
7146
7259
  walk(fullPath);
7147
7260
  } else if (entry.isFile()) {
7148
- const relativePath = path37.relative(baseDir, fullPath).replace(/\\/g, "/");
7261
+ const relativePath = path38.relative(baseDir, fullPath).replace(/\\/g, "/");
7149
7262
  const patternsToTry = [pattern];
7150
7263
  if (pattern.startsWith("**/")) {
7151
7264
  patternsToTry.push(pattern.slice(3));
@@ -7172,7 +7285,7 @@ function findFiles(dir, pattern, limit, baseDir) {
7172
7285
  };
7173
7286
  }
7174
7287
  function toRelativePath(absolutePath, cwd) {
7175
- if (absolutePath.startsWith(cwd + path37.sep)) {
7288
+ if (absolutePath.startsWith(cwd + path38.sep)) {
7176
7289
  return absolutePath.slice(cwd.length + 1);
7177
7290
  }
7178
7291
  return absolutePath;
@@ -7233,7 +7346,7 @@ ${filenames.join("\n")}${truncatedNote}`
7233
7346
  // src/tools/grep.ts
7234
7347
  var grep_exports = {};
7235
7348
  import { execFile as execFile2 } from "node:child_process";
7236
- import * as path38 from "node:path";
7349
+ import * as path39 from "node:path";
7237
7350
  function ripGrep(args, searchPath, signal) {
7238
7351
  return new Promise((resolve10) => {
7239
7352
  const fullArgs = [...args, searchPath];
@@ -7265,7 +7378,7 @@ function applyHeadLimit(items, limit, offset = 0) {
7265
7378
  };
7266
7379
  }
7267
7380
  function toRelativePath2(absolutePath, cwd) {
7268
- if (absolutePath.startsWith(cwd + path38.sep)) {
7381
+ if (absolutePath.startsWith(cwd + path39.sep)) {
7269
7382
  return absolutePath.slice(cwd.length + 1);
7270
7383
  }
7271
7384
  if (absolutePath.startsWith(cwd)) {
@@ -9934,7 +10047,7 @@ var init_web_fetch = __esm({
9934
10047
 
9935
10048
  // src/cron/tasks.ts
9936
10049
  import fs38 from "node:fs";
9937
- import path39 from "node:path";
10050
+ import path40 from "node:path";
9938
10051
  import crypto5 from "node:crypto";
9939
10052
  function getStorageDir() {
9940
10053
  return storageDir;
@@ -9989,7 +10102,7 @@ function readTasksFromDisk() {
9989
10102
  }
9990
10103
  }
9991
10104
  async function writeTasksToDisk(tasks2) {
9992
- const lockPath2 = path39.join(storageDir, "tasks.json.lock");
10105
+ const lockPath2 = path40.join(storageDir, "tasks.json.lock");
9993
10106
  await withFileLock(lockPath2, () => {
9994
10107
  const store = {
9995
10108
  version: 1,
@@ -10001,7 +10114,7 @@ async function writeTasksToDisk(tasks2) {
10001
10114
  }
10002
10115
  function initTaskStore(dir) {
10003
10116
  storageDir = dir;
10004
- tasksFilePath = path39.join(dir, "tasks.json");
10117
+ tasksFilePath = path40.join(dir, "tasks.json");
10005
10118
  if (!fs38.existsSync(dir)) {
10006
10119
  fs38.mkdirSync(dir, { recursive: true });
10007
10120
  }
@@ -10915,9 +11028,9 @@ async function executeAndDeliver(task, now, deps) {
10915
11028
  let filePath = promptText.slice(1).trim();
10916
11029
  try {
10917
11030
  const fs42 = await import("fs");
10918
- const path44 = await import("path");
10919
- if (!path44.isAbsolute(filePath)) {
10920
- filePath = path44.join(deps.sessions["config"].stateDir, filePath);
11031
+ const path45 = await import("path");
11032
+ if (!path45.isAbsolute(filePath)) {
11033
+ filePath = path45.join(deps.sessions["config"].stateDir, filePath);
10921
11034
  }
10922
11035
  promptText = fs42.readFileSync(filePath, "utf-8");
10923
11036
  console.log(`[cron] Loaded prompt from ${filePath} (${promptText.length} chars)`);
@@ -10946,15 +11059,15 @@ async function executeAndDeliver(task, now, deps) {
10946
11059
  let finalResult = result;
10947
11060
  if (task.postProcess) {
10948
11061
  try {
10949
- const path44 = await import("path");
11062
+ const path45 = await import("path");
10950
11063
  const fs42 = await import("fs");
10951
11064
  let scriptPath = task.postProcess;
10952
- if (!path44.isAbsolute(scriptPath)) {
10953
- scriptPath = path44.join(deps.sessions["config"].stateDir, scriptPath);
11065
+ if (!path45.isAbsolute(scriptPath)) {
11066
+ scriptPath = path45.join(deps.sessions["config"].stateDir, scriptPath);
10954
11067
  }
10955
- const resultsDirTmp = path44.join(getStorageDir(), "results");
11068
+ const resultsDirTmp = path45.join(getStorageDir(), "results");
10956
11069
  fs42.mkdirSync(resultsDirTmp, { recursive: true });
10957
- const inputFile = path44.join(resultsDirTmp, `${task.id}.input.txt`);
11070
+ const inputFile = path45.join(resultsDirTmp, `${task.id}.input.txt`);
10958
11071
  fs42.writeFileSync(inputFile, result, "utf-8");
10959
11072
  const { execFile: execFile3 } = await import("child_process");
10960
11073
  await new Promise((resolve10) => {
@@ -10983,10 +11096,10 @@ async function executeAndDeliver(task, now, deps) {
10983
11096
  }
10984
11097
  try {
10985
11098
  const fs42 = await import("fs");
10986
- const path44 = await import("path");
10987
- const resultsDir = path44.join(getStorageDir(), "results");
11099
+ const path45 = await import("path");
11100
+ const resultsDir = path45.join(getStorageDir(), "results");
10988
11101
  fs42.mkdirSync(resultsDir, { recursive: true });
10989
- const resultFile = path44.join(resultsDir, `${task.id}.json`);
11102
+ const resultFile = path45.join(resultsDir, `${task.id}.json`);
10990
11103
  fs42.writeFileSync(resultFile, JSON.stringify({
10991
11104
  taskId: task.id,
10992
11105
  description: task.description,
@@ -11235,13 +11348,13 @@ function registerCronTools() {
11235
11348
  },
11236
11349
  handler: async (args) => {
11237
11350
  const fs42 = await import("fs");
11238
- const path44 = await import("path");
11239
- const resultsDir = path44.join(getStorageDir(), "results");
11351
+ const path45 = await import("path");
11352
+ const resultsDir = path45.join(getStorageDir(), "results");
11240
11353
  if (!fs42.existsSync(resultsDir)) {
11241
11354
  return { content: "\u6682\u65E0cron\u6267\u884C\u7ED3\u679C" };
11242
11355
  }
11243
11356
  if (args.task_id) {
11244
- const file = path44.join(resultsDir, `${args.task_id}.json`);
11357
+ const file = path45.join(resultsDir, `${args.task_id}.json`);
11245
11358
  if (!fs42.existsSync(file)) {
11246
11359
  return { content: `\u4EFB\u52A1 ${args.task_id} \u6682\u65E0\u6267\u884C\u7ED3\u679C`, isError: true };
11247
11360
  }
@@ -11257,7 +11370,7 @@ ${data.result}` };
11257
11370
  return { content: "\u6682\u65E0cron\u6267\u884C\u7ED3\u679C" };
11258
11371
  }
11259
11372
  const results = files.map((f2) => {
11260
- const data = JSON.parse(fs42.readFileSync(path44.join(resultsDir, f2), "utf-8"));
11373
+ const data = JSON.parse(fs42.readFileSync(path45.join(resultsDir, f2), "utf-8"));
11261
11374
  return `### ${data.description} (${data.taskId.slice(0, 8)})
11262
11375
  \u6267\u884C: ${data.executedAt} | \u7B2C${data.runCount}\u6B21
11263
11376
  ${data.result.slice(0, 500)}${data.result.length > 500 ? "..." : ""}`;
@@ -11311,6 +11424,7 @@ var init_tools = __esm({
11311
11424
 
11312
11425
  // src/tools/wechat/wx-query.ts
11313
11426
  var wx_query_exports = {};
11427
+ import { join as join34 } from "node:path";
11314
11428
  function getDescription() {
11315
11429
  return `\u67E5\u8BE2\u7FC0\u54E5\u7684\u5FAE\u4FE1\u6D88\u606F\uFF08\u7F13\u5B58\u89E3\u5BC6\u540E\u7684\u672C\u5730\u6570\u636E\u5E93\uFF09\u3002
11316
11430
 
@@ -11339,13 +11453,14 @@ function getDescription() {
11339
11453
  \u26A0\uFE0F \u9690\u79C1\u6CE8\u610F: \u79C1\u804A\u6D88\u606F\u4E0D\u66B4\u9732\u7ED9\u5176\u4ED6\u4EBA\uFF0C\u4EC5\u7528\u4E8E\u7FC0\u54E5\u81EA\u5DF1\u7684\u67E5\u8BE2\u3002
11340
11454
  \u5982\u679C\u67E5\u8BE2\u5230\u79C1\u804A\u5185\u5BB9\uFF0C\u4EC5\u544A\u77E5\u7FC0\u54E5\u672C\u4EBA\u3002`;
11341
11455
  }
11342
- var SCRIPT, PYTHON;
11456
+ var STATE_DIR, SCRIPT, PYTHON;
11343
11457
  var init_wx_query = __esm({
11344
11458
  "src/tools/wechat/wx-query.ts"() {
11345
11459
  "use strict";
11346
11460
  init_registry();
11347
11461
  init_live();
11348
- SCRIPT = "C:/Users/24045/.openclaw/engine/src/tools/wechat/wx_query.py";
11462
+ STATE_DIR = process.env.ENGINE7_STATE_DIR || process.env.OPENCLAW_STATE_DIR || join34(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
11463
+ SCRIPT = join34(STATE_DIR, "engine", "src", "tools", "wechat", "wx_query.py");
11349
11464
  PYTHON = "python3";
11350
11465
  registry.register({
11351
11466
  name: "wx_query",
@@ -11419,7 +11534,7 @@ __export(manager_exports, {
11419
11534
  McpManager: () => McpManager
11420
11535
  });
11421
11536
  import * as fs40 from "node:fs";
11422
- import * as path41 from "node:path";
11537
+ import * as path42 from "node:path";
11423
11538
  import { Client as Client3 } from "@modelcontextprotocol/sdk/client/index.js";
11424
11539
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
11425
11540
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
@@ -11452,9 +11567,9 @@ function convertInputSchema(inputSchema) {
11452
11567
  }
11453
11568
  function persistBinary(base64Data, mimeType, persistId) {
11454
11569
  const ext = mimeType?.split("/")[1] || "bin";
11455
- const dir = path41.join(process.env.ENGINE_STATE_DIR || ".engine", "mcp-blobs");
11570
+ const dir = path42.join(process.env.ENGINE_STATE_DIR || ".engine", "mcp-blobs");
11456
11571
  fs40.mkdirSync(dir, { recursive: true });
11457
- const filepath = path41.join(dir, `${persistId}.${ext}`);
11572
+ const filepath = path42.join(dir, `${persistId}.${ext}`);
11458
11573
  try {
11459
11574
  const buf = Buffer.from(base64Data, "base64");
11460
11575
  fs40.writeFileSync(filepath, buf);
@@ -11791,7 +11906,7 @@ __export(resources_exports, {
11791
11906
  registerMcpResourceTools: () => registerMcpResourceTools,
11792
11907
  unregisterMcpResourceTools: () => unregisterMcpResourceTools
11793
11908
  });
11794
- import * as path42 from "node:path";
11909
+ import * as path43 from "node:path";
11795
11910
  function registerMcpResourceTools(manager) {
11796
11911
  mcpManagerRef = manager;
11797
11912
  registry.register(listResourcesTool);
@@ -11809,7 +11924,7 @@ var init_resources = __esm({
11809
11924
  "use strict";
11810
11925
  init_registry();
11811
11926
  MAX_RESULT_CHARS2 = 1e5;
11812
- MEDIA_DIR = process.env.ENGINE_MEDIA_DIR || path42.join(process.env.ENGINE_STATE_DIR || ".engine", "media", "inbound");
11927
+ MEDIA_DIR = process.env.ENGINE_MEDIA_DIR || path43.join(process.env.ENGINE_STATE_DIR || ".engine", "media", "inbound");
11813
11928
  MCP_LIST_RESOURCES_TOOL = "mcp__list_resources";
11814
11929
  MCP_READ_RESOURCE_TOOL = "mcp__read_resource";
11815
11930
  mcpManagerRef = null;
@@ -11894,88 +12009,6 @@ ${lines.join("\n\n")}`;
11894
12009
  }
11895
12010
  });
11896
12011
 
11897
- // src/memory/everos-sync.ts
11898
- var everos_sync_exports = {};
11899
- __export(everos_sync_exports, {
11900
- createEverosSync: () => createEverosSync
11901
- });
11902
- function parseMeta(text) {
11903
- const m2 = text.match(/^\[meta:\s*(.+?)\s*\((.+?)\)\s*@(\S+)\s*[^\]]*\]/);
11904
- if (!m2) return null;
11905
- return { senderName: m2[1].trim(), senderId: m2[2].trim(), platform: m2[3].trim() };
11906
- }
11907
- function createEverosSync(cfg) {
11908
- const { enabled, url, appId, userId, agentName } = cfg;
11909
- async function push(event) {
11910
- if (!enabled) return;
11911
- if (!event.text.trim()) return;
11912
- return;
11913
- const meta = event.role === "user" ? parseMeta(event.text) : null;
11914
- const senderId = appId;
11915
- const senderName = meta?.senderName ?? (event.role === "assistant" ? agentName : void 0) ?? event.senderName ?? event.role;
11916
- console.log(`[everos-sync] role=${event.role} sender_id=${senderId} sender_name=${senderName} metaParsed=${!!meta} textLen=${event.text.length}`);
11917
- try {
11918
- const resp = await fetch(`${url}/api/v1/memory/add`, {
11919
- method: "POST",
11920
- headers: { "Content-Type": "application/json" },
11921
- body: JSON.stringify({
11922
- session_id: event.sessionId,
11923
- app_id: appId,
11924
- project_id: "default",
11925
- messages: [{
11926
- sender_id: senderId,
11927
- sender_name: senderName,
11928
- role: event.role,
11929
- timestamp: event.timestamp,
11930
- content: event.text
11931
- }]
11932
- }),
11933
- signal: AbortSignal.timeout(5e3)
11934
- });
11935
- if (!resp.ok) {
11936
- console.warn(`[everos-sync] memory/add ${resp.status}`);
11937
- }
11938
- } catch {
11939
- }
11940
- }
11941
- async function pushBatch(events) {
11942
- if (!enabled || events.length === 0) return;
11943
- try {
11944
- const resp = await fetch(`${url}/api/v1/memory/add`, {
11945
- method: "POST",
11946
- headers: { "Content-Type": "application/json" },
11947
- body: JSON.stringify({
11948
- session_id: events[0].sessionId,
11949
- app_id: appId,
11950
- project_id: "default",
11951
- messages: events.map((e) => {
11952
- const meta = e.role === "user" ? parseMeta(e.text) : null;
11953
- const name = meta?.senderName ?? (e.role === "assistant" ? agentName : void 0) ?? e.senderName ?? e.role;
11954
- return {
11955
- sender_id: appId,
11956
- sender_name: name,
11957
- role: e.role,
11958
- timestamp: e.timestamp,
11959
- content: e.text
11960
- };
11961
- })
11962
- }),
11963
- signal: AbortSignal.timeout(3e4)
11964
- });
11965
- if (!resp.ok) {
11966
- console.warn(`[everos-sync] batch add ${resp.status}`);
11967
- }
11968
- } catch {
11969
- }
11970
- }
11971
- return { push, pushBatch };
11972
- }
11973
- var init_everos_sync = __esm({
11974
- "src/memory/everos-sync.ts"() {
11975
- "use strict";
11976
- }
11977
- });
11978
-
11979
12012
  // src/cron/cron-plugin.ts
11980
12013
  var cron_plugin_exports = {};
11981
12014
  __export(cron_plugin_exports, {
@@ -12051,8 +12084,8 @@ var reply_blocklist_exports = {};
12051
12084
  __export(reply_blocklist_exports, {
12052
12085
  isUserBlocked: () => isUserBlocked
12053
12086
  });
12054
- import { readFileSync as readFileSync26, writeFileSync as writeFileSync15, existsSync as existsSync24 } from "node:fs";
12055
- import { join as join36 } from "node:path";
12087
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync16, existsSync as existsSync24 } from "node:fs";
12088
+ import { join as join38 } from "node:path";
12056
12089
  function ensureLoaded(workspace, configIds) {
12057
12090
  if (loaded) return;
12058
12091
  if (configIds?.length) {
@@ -12060,10 +12093,10 @@ function ensureLoaded(workspace, configIds) {
12060
12093
  if (!state.blockedUserIds.includes(id)) state.blockedUserIds.push(id);
12061
12094
  }
12062
12095
  }
12063
- const path44 = join36(workspace, ".reply-blocklist.json");
12096
+ const path45 = join38(workspace, ".reply-blocklist.json");
12064
12097
  try {
12065
- if (existsSync24(path44)) {
12066
- const raw = readFileSync26(path44, "utf-8");
12098
+ if (existsSync24(path45)) {
12099
+ const raw = readFileSync26(path45, "utf-8");
12067
12100
  const parsed = JSON.parse(raw);
12068
12101
  if (parsed.blockedUserIds) {
12069
12102
  for (const id of parsed.blockedUserIds) {
@@ -12079,9 +12112,9 @@ function ensureLoaded(workspace, configIds) {
12079
12112
  loaded = true;
12080
12113
  }
12081
12114
  function save(workspace) {
12082
- const path44 = join36(workspace, ".reply-blocklist.json");
12115
+ const path45 = join38(workspace, ".reply-blocklist.json");
12083
12116
  try {
12084
- writeFileSync15(path44, JSON.stringify(state, null, 2), "utf-8");
12117
+ writeFileSync16(path45, JSON.stringify(state, null, 2), "utf-8");
12085
12118
  } catch (err) {
12086
12119
  console.warn(`[reply-blocklist] Failed to save: ${err.message}`);
12087
12120
  }
@@ -12678,7 +12711,7 @@ var init_cognifold_intent_watcher = __esm({
12678
12711
  });
12679
12712
 
12680
12713
  // src/engine-startup.ts
12681
- import * as path43 from "node:path";
12714
+ import * as path44 from "node:path";
12682
12715
  import * as fs41 from "node:fs";
12683
12716
  import { fileURLToPath } from "node:url";
12684
12717
 
@@ -14022,11 +14055,11 @@ var DiscordAdapter = class _DiscordAdapter {
14022
14055
  /** 发送媒体附件(图片/文件/音频)— discord.js channel.send({ files }) */
14023
14056
  async sendFile(target, message, attachment) {
14024
14057
  const fs42 = await import("node:fs");
14025
- const path44 = await import("node:path");
14058
+ const path45 = await import("node:path");
14026
14059
  if (!fs42.existsSync(attachment.path)) {
14027
14060
  throw new Error(`File not found: ${attachment.path}`);
14028
14061
  }
14029
- const filename = attachment.filename || path44.basename(attachment.path);
14062
+ const filename = attachment.filename || path45.basename(attachment.path);
14030
14063
  const fileBuffer = fs42.readFileSync(attachment.path);
14031
14064
  const filePayload = {
14032
14065
  attachment: fileBuffer,
@@ -14468,11 +14501,11 @@ var FeishuAdapter = class _FeishuAdapter {
14468
14501
  /** 发送媒体附件(图片/文件) */
14469
14502
  async sendFile(target, message, attachment) {
14470
14503
  const fs42 = await import("node:fs");
14471
- const path44 = await import("node:path");
14504
+ const path45 = await import("node:path");
14472
14505
  if (!fs42.existsSync(attachment.path)) {
14473
14506
  throw new Error(`File not found: ${attachment.path}`);
14474
14507
  }
14475
- const filename = attachment.filename || path44.basename(attachment.path);
14508
+ const filename = attachment.filename || path45.basename(attachment.path);
14476
14509
  const fileBuffer = fs42.readFileSync(attachment.path);
14477
14510
  const receiveIdType = target.startsWith("ou_") ? "open_id" : "chat_id";
14478
14511
  const mimeType = attachment.mimeType || "application/octet-stream";
@@ -15304,7 +15337,7 @@ var WechatAdapter = class {
15304
15337
  this.config = config;
15305
15338
  this.baseUrl = config.baseUrl?.replace(/\/$/, "") || ILINK_BASE_URL;
15306
15339
  this.cdnBaseUrl = config.cdnBaseUrl?.replace(/\/$/, "") || WEIXIN_CDN_BASE_URL;
15307
- this.stateDir = config.stateDir || path4.join(os.homedir?.() || "/tmp", ".openclaw");
15340
+ this.stateDir = config.stateDir || path4.join(os.homedir?.() || "/tmp", ".engine7");
15308
15341
  if (!fs5.existsSync(this.stateDir)) fs5.mkdirSync(this.stateDir, { recursive: true });
15309
15342
  }
15310
15343
  // --- ChannelAdapter interface ---
@@ -18553,8 +18586,8 @@ ${ep.episode || ep.summary}`,
18553
18586
  // src/handle-query.ts
18554
18587
  init_paths();
18555
18588
  import { readFileSync as readFileSync15, existsSync as existsSync12 } from "node:fs";
18556
- import { join as join20 } from "node:path";
18557
- import { resolve as resolve6 } from "node:path";
18589
+ import { join as join20, resolve as resolve6 } from "node:path";
18590
+ import * as path13 from "node:path";
18558
18591
  var contactMap = null;
18559
18592
  var externalChanWhitelist = null;
18560
18593
  function loadContactMap(workspace) {
@@ -18622,18 +18655,18 @@ function truncate(s2, maxLen) {
18622
18655
  }
18623
18656
  var externalChanRulesCache = null;
18624
18657
  function loadExternalChanRules(workspace) {
18625
- const path44 = join20(workspace, "prompts", "external-chan-rules.md");
18626
- if (externalChanRulesCache && externalChanRulesCache.path === path44) return externalChanRulesCache;
18658
+ const path45 = join20(workspace, "prompts", "external-chan-rules.md");
18659
+ if (externalChanRulesCache && externalChanRulesCache.path === path45) return externalChanRulesCache;
18627
18660
  let content = "";
18628
- if (existsSync12(path44)) {
18661
+ if (existsSync12(path45)) {
18629
18662
  try {
18630
- content = readFileSync15(path44, "utf-8").trim();
18663
+ content = readFileSync15(path45, "utf-8").trim();
18631
18664
  } catch (e) {
18632
18665
  console.warn(`[external-chan-rules] Failed to load: ${e}`);
18633
18666
  }
18634
18667
  }
18635
- externalChanRulesCache = { path: path44, content };
18636
- console.log(`[external-chan-rules] Loaded ${content.length} chars from ${path44}`);
18668
+ externalChanRulesCache = { path: path45, content };
18669
+ console.log(`[external-chan-rules] Loaded ${content.length} chars from ${path45}`);
18637
18670
  return externalChanRulesCache;
18638
18671
  }
18639
18672
  function getExternalChanRulesBlock(inboundMeta, workspace) {
@@ -18901,9 +18934,9 @@ ${text}` : text });
18901
18934
  }
18902
18935
  console.log(`[${sessionId}] >>> query start (${messages.length} msgs in history)`);
18903
18936
  try {
18904
- const { writeFileSync: writeFileSync17 } = await import("node:fs");
18905
- const { join: join38 } = await import("node:path");
18906
- const contextPath = join38(workspace, ".context-debug.txt");
18937
+ const { writeFileSync: writeFileSync18 } = await import("node:fs");
18938
+ const { join: join40 } = await import("node:path");
18939
+ const contextPath = join40(workspace, ".context-debug.txt");
18907
18940
  const lines = [
18908
18941
  "=== Context Debug ===",
18909
18942
  `Time: ${(/* @__PURE__ */ new Date()).toISOString()}`,
@@ -18956,7 +18989,7 @@ ${text}` : text });
18956
18989
  }
18957
18990
  }
18958
18991
  lines.push("", "=== End ===");
18959
- writeFileSync17(contextPath, lines.join("\n") + "\n\n", { encoding: "utf-8", flag: "a" });
18992
+ writeFileSync18(contextPath, lines.join("\n") + "\n\n", { encoding: "utf-8", flag: "a" });
18960
18993
  console.log(`[${sessionId}] Context snapshot \u2192 ${contextPath}`);
18961
18994
  } catch (err) {
18962
18995
  console.warn(`[${sessionId}] Context snapshot failed: ${err.message}`);
@@ -19288,7 +19321,7 @@ stack: ${err.stack ?? "(none)"}`);
19288
19321
  }
19289
19322
  } catch (err) {
19290
19323
  try {
19291
- (await import("node:fs")).appendFileSync("C:\\Users\\24045\\.openclaw\\logs\\autoDream-debug.log", `[${(/* @__PURE__ */ new Date()).toISOString()}] [handle-query] autoDream trigger TRY-CATCH: ${err.message}
19324
+ (await import("node:fs")).appendFileSync(join20(process.env.ENGINE7_STATE_DIR || process.env.OPENCLAW_STATE_DIR || path13.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7"), "logs", "autoDream-debug.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] [handle-query] autoDream trigger TRY-CATCH: ${err.message}
19292
19325
  stack: ${err.stack ?? "(none)"}
19293
19326
  `);
19294
19327
  } catch {
@@ -19986,16 +20019,16 @@ var MessageDispatcher = class {
19986
20019
  };
19987
20020
 
19988
20021
  // src/cli-startup.ts
19989
- import * as path13 from "node:path";
20022
+ import * as path14 from "node:path";
19990
20023
  import * as fs13 from "node:fs";
19991
20024
  import * as readline2 from "node:readline";
19992
20025
  function getDailyLogPath(stateDir) {
19993
20026
  const dateStr = (/* @__PURE__ */ new Date()).toLocaleDateString("sv-SE", { timeZone: "Asia/Shanghai" });
19994
- return path13.join(stateDir, "logs", `engine-${dateStr}.log`);
20027
+ return path14.join(stateDir, "logs", `engine-${dateStr}.log`);
19995
20028
  }
19996
20029
  function setupFileLogging(stateDir) {
19997
20030
  const LOG_PATH = getDailyLogPath(stateDir);
19998
- fs13.mkdirSync(path13.join(stateDir, "logs"), { recursive: true });
20031
+ fs13.mkdirSync(path14.join(stateDir, "logs"), { recursive: true });
19999
20032
  const logStream = fs13.createWriteStream(LOG_PATH, { flags: "a" });
20000
20033
  logStream.on("error", (err) => console.error(`[log] Write error: ${err.message}`));
20001
20034
  function ts() {
@@ -20087,7 +20120,7 @@ function startCliLoop(deps, cliConfig, channelManager, dispatcher) {
20087
20120
 
20088
20121
  // src/session/session-history.ts
20089
20122
  import fs14 from "node:fs";
20090
- import path14 from "node:path";
20123
+ import path15 from "node:path";
20091
20124
  var BEIJING_OFFSET_MS = 8 * 36e5;
20092
20125
  var INJECTED_CONTENT_PATTERNS = [
20093
20126
  /【定时心跳】/,
@@ -20139,10 +20172,10 @@ function scopeMainJsonlPaths(sessions) {
20139
20172
  let latestArchive = null;
20140
20173
  if (current) {
20141
20174
  try {
20142
- const dir = path14.dirname(current);
20143
- const base = path14.basename(current);
20175
+ const dir = path15.dirname(current);
20176
+ const base = path15.basename(current);
20144
20177
  const archives = fs14.readdirSync(dir).filter((f2) => f2.startsWith(base + ".archived.")).sort();
20145
- if (archives.length > 0) latestArchive = path14.join(dir, archives[archives.length - 1]);
20178
+ if (archives.length > 0) latestArchive = path15.join(dir, archives[archives.length - 1]);
20146
20179
  } catch {
20147
20180
  }
20148
20181
  }
@@ -20389,7 +20422,7 @@ ${basePrompt}`;
20389
20422
 
20390
20423
  // src/nudge/plugin.ts
20391
20424
  import fs17 from "node:fs";
20392
- import path17 from "node:path";
20425
+ import path18 from "node:path";
20393
20426
 
20394
20427
  // src/nudge/judge.ts
20395
20428
  function shouldNudge(task, taskState, cfg) {
@@ -20558,10 +20591,10 @@ function formatDuration2(ms) {
20558
20591
 
20559
20592
  // src/nudge/session-state-reader.ts
20560
20593
  import fs15 from "node:fs";
20561
- import path15 from "node:path";
20594
+ import path16 from "node:path";
20562
20595
  function parseSessionStateFull(workspace, sessionStateFile) {
20563
20596
  const stateFile = sessionStateFile || "SESSION-STATE.md";
20564
- const statePath = path15.isAbsolute(stateFile) ? stateFile : path15.join(workspace, stateFile);
20597
+ const statePath = path16.isAbsolute(stateFile) ? stateFile : path16.join(workspace, stateFile);
20565
20598
  let content;
20566
20599
  try {
20567
20600
  content = fs15.readFileSync(statePath, "utf-8");
@@ -20616,13 +20649,13 @@ function taskIdFromTitle(title) {
20616
20649
 
20617
20650
  // src/calendar/db.ts
20618
20651
  import { DatabaseSync } from "node:sqlite";
20619
- import * as path16 from "node:path";
20652
+ import * as path17 from "node:path";
20620
20653
  import * as fs16 from "node:fs";
20621
20654
  var TZ_OFFSET_MS = 8 * 60 * 60 * 1e3;
20622
20655
  function openDb(workspace) {
20623
- const dir = path16.join(workspace, ".calendar");
20656
+ const dir = path17.join(workspace, ".calendar");
20624
20657
  fs16.mkdirSync(dir, { recursive: true });
20625
- const dbPath = path16.join(dir, "calendar.db");
20658
+ const dbPath = path17.join(dir, "calendar.db");
20626
20659
  const db = new DatabaseSync(dbPath);
20627
20660
  db.exec("PRAGMA journal_mode=WAL");
20628
20661
  db.exec(`CREATE TABLE IF NOT EXISTS events (
@@ -20711,7 +20744,7 @@ var NudgePlugin = class {
20711
20744
  provider;
20712
20745
  model;
20713
20746
  loadPrompt(workspace, promptFile) {
20714
- const promptPath = promptFile ? path17.isAbsolute(promptFile) ? promptFile : path17.join(workspace, promptFile) : path17.join(workspace, "prompts", "nudge-prompt.md");
20747
+ const promptPath = promptFile ? path18.isAbsolute(promptFile) ? promptFile : path18.join(workspace, promptFile) : path18.join(workspace, "prompts", "nudge-prompt.md");
20715
20748
  try {
20716
20749
  const content = fs17.readFileSync(promptPath, "utf-8").trim();
20717
20750
  if (content) {
@@ -20860,8 +20893,8 @@ var NudgePlugin = class {
20860
20893
  if (!isWaiting) {
20861
20894
  return { outcome: { outcome: "success" } };
20862
20895
  }
20863
- const nudgeDir = path17.join(this.workspace, ".nudge");
20864
- const notifPath = path17.join(nudgeDir, "stop-hook-notifications.json");
20896
+ const nudgeDir = path18.join(this.workspace, ".nudge");
20897
+ const notifPath = path18.join(nudgeDir, "stop-hook-notifications.json");
20865
20898
  try {
20866
20899
  if (!fs17.existsSync(nudgeDir)) fs17.mkdirSync(nudgeDir, { recursive: true });
20867
20900
  let notifs = [];
@@ -20930,7 +20963,7 @@ var NudgePlugin = class {
20930
20963
  * 已 notified 的不会再触发,等 agent 回复 "<id> 过期了" 由 cleanup 删。
20931
20964
  */
20932
20965
  collectDueStopHookNotifications() {
20933
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
20966
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
20934
20967
  try {
20935
20968
  if (!fs17.existsSync(notifPath)) return null;
20936
20969
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
@@ -20969,7 +21002,7 @@ ${items}
20969
21002
  }
20970
21003
  /** 按 id 删除条目(stop-hook 实时清理用;正常删除路径,agent 回复即删) */
20971
21004
  removeNotificationsById(ids) {
20972
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21005
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
20973
21006
  try {
20974
21007
  if (!fs17.existsSync(notifPath)) return;
20975
21008
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
@@ -20989,7 +21022,7 @@ ${items}
20989
21022
  }
20990
21023
  /** 投递成功后标记 notified(防重复触发);不删除——删除只走 agent 回复 "<id> 过期了" */
20991
21024
  markNotified(ids) {
20992
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21025
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
20993
21026
  try {
20994
21027
  if (!fs17.existsSync(notifPath)) return;
20995
21028
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
@@ -21012,7 +21045,7 @@ ${items}
21012
21045
  */
21013
21046
  cleanupStaleNotificationsFromMessages(sessions) {
21014
21047
  try {
21015
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21048
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21016
21049
  if (!fs17.existsSync(notifPath)) return;
21017
21050
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
21018
21051
  if (notifs.length === 0) return;
@@ -21313,7 +21346,7 @@ ${items}
21313
21346
  // === state 持久化 ===
21314
21347
  loadState() {
21315
21348
  const stateFile = this.cfg.stateFile || "nudge-state.json";
21316
- const statePath = path17.isAbsolute(stateFile) ? stateFile : path17.join(this.workspace, stateFile);
21349
+ const statePath = path18.isAbsolute(stateFile) ? stateFile : path18.join(this.workspace, stateFile);
21317
21350
  try {
21318
21351
  const content = fs17.readFileSync(statePath, "utf-8");
21319
21352
  return JSON.parse(content);
@@ -21323,7 +21356,7 @@ ${items}
21323
21356
  }
21324
21357
  saveState(state2) {
21325
21358
  const stateFile = this.cfg.stateFile || "nudge-state.json";
21326
- const statePath = path17.isAbsolute(stateFile) ? stateFile : path17.join(this.workspace, stateFile);
21359
+ const statePath = path18.isAbsolute(stateFile) ? stateFile : path18.join(this.workspace, stateFile);
21327
21360
  fs17.writeFileSync(statePath, JSON.stringify(state2, null, 2), "utf-8");
21328
21361
  }
21329
21362
  newTaskState() {
@@ -21503,7 +21536,7 @@ ${items}
21503
21536
 
21504
21537
  // src/inner-voice/plugin.ts
21505
21538
  import fs21 from "node:fs";
21506
- import path21 from "node:path";
21539
+ import path22 from "node:path";
21507
21540
 
21508
21541
  // src/inner-voice/activity.ts
21509
21542
  function checkActivity(sessions, activeThresholdMs) {
@@ -21543,7 +21576,7 @@ function calcHintProb(min) {
21543
21576
 
21544
21577
  // src/inner-voice/emotional-state.ts
21545
21578
  import fs18 from "node:fs";
21546
- import path18 from "node:path";
21579
+ import path19 from "node:path";
21547
21580
  var NEUTRAL = 0.5;
21548
21581
  var DECAY_RATE = 0.17;
21549
21582
  var MAX_EVENTS = 20;
@@ -21594,7 +21627,7 @@ function initialState() {
21594
21627
  return { version: 1, mood: NEUTRAL, trend: "stable", updatedAt: nowIsoBj(), events: [] };
21595
21628
  }
21596
21629
  async function updateEmotionalState(workspace, sessions) {
21597
- const stateFile = path18.join(workspace, "inner-voice", "emotional-state.json");
21630
+ const stateFile = path19.join(workspace, "inner-voice", "emotional-state.json");
21598
21631
  const messages = readRecentMessages(sessions, RECENT_N);
21599
21632
  if (messages.length === 0) {
21600
21633
  console.log("[emotional-state] no messages");
@@ -21627,7 +21660,7 @@ async function updateEmotionalState(workspace, sessions) {
21627
21660
  function readRecentMessages(sessions, n) {
21628
21661
  const mainId = sessions.getSessionId("scope:main");
21629
21662
  if (!mainId) return [];
21630
- const file = path18.join(sessions.sessionsDir, `${mainId}.jsonl`);
21663
+ const file = path19.join(sessions.sessionsDir, `${mainId}.jsonl`);
21631
21664
  if (!fs18.existsSync(file)) return [];
21632
21665
  const lines = readLastNLines(file, n * 4 + 20);
21633
21666
  const entries = [];
@@ -21745,7 +21778,7 @@ function refreshHoursAgo(events) {
21745
21778
  }
21746
21779
  function appendMoodLog(workspace, state2, summary) {
21747
21780
  try {
21748
- const logPath = path18.join(workspace, "mood-history.log");
21781
+ const logPath = path19.join(workspace, "mood-history.log");
21749
21782
  const ts = formatBj(/* @__PURE__ */ new Date(), false);
21750
21783
  fs18.appendFileSync(logPath, `${ts} mood=${state2.mood.toFixed(2)} trend=${state2.trend} ${summary}
21751
21784
  `);
@@ -21762,7 +21795,7 @@ function loadJson(file) {
21762
21795
  }
21763
21796
  function saveJson(file, data) {
21764
21797
  try {
21765
- fs18.mkdirSync(path18.dirname(file), { recursive: true });
21798
+ fs18.mkdirSync(path19.dirname(file), { recursive: true });
21766
21799
  fs18.writeFileSync(file, JSON.stringify(data, null, 2));
21767
21800
  } catch (err) {
21768
21801
  console.warn(`[emotional-state] save failed: ${err.message}`);
@@ -21808,7 +21841,7 @@ function formatBj(d, withSec) {
21808
21841
 
21809
21842
  // src/inner-voice/topics-scorer.ts
21810
21843
  import fs19 from "node:fs";
21811
- import path19 from "node:path";
21844
+ import path20 from "node:path";
21812
21845
  var HALF_LIFE_DAYS = 3;
21813
21846
  var PROJECT_HALF_LIFE_DAYS = 1.5;
21814
21847
  var COOLDOWN_HOURS = 6;
@@ -21816,8 +21849,8 @@ var MAX_CHARS = 8e3;
21816
21849
  var SKIP_NAMES = /* @__PURE__ */ new Set(["MEMORY.md", "archive"]);
21817
21850
  var SKIP_DIRS = /* @__PURE__ */ new Set(["archive"]);
21818
21851
  function pickTopic(workspace, typeFilter, opts) {
21819
- const topicsDir = path19.join(workspace, "topics");
21820
- const usageFile = path19.join(workspace, "inner-voice", "topics-usage.json");
21852
+ const topicsDir = path20.join(workspace, "topics");
21853
+ const usageFile = path20.join(workspace, "inner-voice", "topics-usage.json");
21821
21854
  const files = scanTopics(topicsDir, typeFilter);
21822
21855
  if (files.length === 0) {
21823
21856
  console.log(`[topics-scorer] no topics found (type=${typeFilter})`);
@@ -21849,7 +21882,7 @@ function pickTopic(workspace, typeFilter, opts) {
21849
21882
  recency: Math.round(recency * 1e3) / 1e3,
21850
21883
  freq: Math.round(freq * 1e3) / 1e3,
21851
21884
  type: type2,
21852
- name: meta.name || path19.basename(relpath),
21885
+ name: meta.name || path20.basename(relpath),
21853
21886
  description: meta.description || "",
21854
21887
  mtime
21855
21888
  });
@@ -21907,14 +21940,14 @@ function scanTopics(topicsDir, typeFilter) {
21907
21940
  const out = [];
21908
21941
  const walk = (dir) => {
21909
21942
  for (const name of fs19.readdirSync(dir)) {
21910
- const full = path19.join(dir, name);
21943
+ const full = path20.join(dir, name);
21911
21944
  const stat4 = fs19.statSync(full);
21912
21945
  if (stat4.isDirectory()) {
21913
21946
  if (SKIP_DIRS.has(name)) continue;
21914
21947
  walk(full);
21915
21948
  } else {
21916
21949
  if (!name.endsWith(".md") || SKIP_NAMES.has(name)) continue;
21917
- const relpath = path19.relative(topicsDir, full).replace(/\\/g, "/");
21950
+ const relpath = path20.relative(topicsDir, full).replace(/\\/g, "/");
21918
21951
  if (typeFilter && !relpath.startsWith(typeFilter + "/") && !relpath.startsWith(typeFilter + "_")) continue;
21919
21952
  out.push({ relpath, fullpath: full });
21920
21953
  }
@@ -21959,7 +21992,7 @@ function loadJson2(file) {
21959
21992
  }
21960
21993
  function saveJson2(file, data) {
21961
21994
  try {
21962
- fs19.mkdirSync(path19.dirname(file), { recursive: true });
21995
+ fs19.mkdirSync(path20.dirname(file), { recursive: true });
21963
21996
  fs19.writeFileSync(file, JSON.stringify(data, null, 2));
21964
21997
  } catch (err) {
21965
21998
  console.warn(`[topics-scorer] usage save failed: ${err.message}`);
@@ -21968,21 +22001,21 @@ function saveJson2(file, data) {
21968
22001
 
21969
22002
  // src/inner-voice/memory-reader.ts
21970
22003
  import fs20 from "node:fs";
21971
- import path20 from "node:path";
22004
+ import path21 from "node:path";
21972
22005
  var US_HALF_LIFE_DAYS = 10;
21973
22006
  var US_MAX_LINES = 60;
21974
22007
  function readRecentMemory(workspace) {
21975
- const dir = path20.join(workspace, "memory");
22008
+ const dir = path21.join(workspace, "memory");
21976
22009
  const now = new Date(Date.now() + 8 * 36e5);
21977
22010
  const today = formatYmd(now);
21978
22011
  const yesterday = formatYmd(new Date(now.getTime() - 864e5));
21979
22012
  return {
21980
- today: readIfExists(path20.join(dir, `${today}.md`)),
21981
- yesterday: readIfExists(path20.join(dir, `${yesterday}.md`))
22013
+ today: readIfExists(path21.join(dir, `${today}.md`)),
22014
+ yesterday: readIfExists(path21.join(dir, `${yesterday}.md`))
21982
22015
  };
21983
22016
  }
21984
22017
  function sampleUs(workspace) {
21985
- const usFile = path20.join(workspace, "memory", "us.md");
22018
+ const usFile = path21.join(workspace, "memory", "us.md");
21986
22019
  let content;
21987
22020
  try {
21988
22021
  content = fs20.readFileSync(usFile, "utf-8");
@@ -22322,7 +22355,7 @@ var InnerVoicePlugin = class {
22322
22355
  }
22323
22356
  /** 读 workspace/prompts/my-inner-voice.md,不存在用 DEFAULT_PROMPT */
22324
22357
  loadPrompt(workspace) {
22325
- const promptPath = path21.join(workspace, "prompts", "my-inner-voice.md");
22358
+ const promptPath = path22.join(workspace, "prompts", "my-inner-voice.md");
22326
22359
  try {
22327
22360
  const content = fs21.readFileSync(promptPath, "utf-8").trim();
22328
22361
  if (content) {
@@ -22396,7 +22429,7 @@ var InnerVoicePlugin = class {
22396
22429
  console.warn(`[inner-voice] emotional-state failed: ${err.message}`);
22397
22430
  }
22398
22431
  try {
22399
- const content = fs21.readFileSync(path21.join(this.workspace, "SESSION-STATE.md"), "utf-8");
22432
+ const content = fs21.readFileSync(path22.join(this.workspace, "SESSION-STATE.md"), "utf-8");
22400
22433
  lines.push("\n--- SESSION-STATE\uFF08\u5C3E\u90E8\uFF09 ---");
22401
22434
  lines.push(content.slice(-2e3));
22402
22435
  } catch {
@@ -22507,7 +22540,7 @@ var InnerVoicePlugin = class {
22507
22540
  if (Math.random() >= activity.hintProb) {
22508
22541
  return { text: thought, hintTriggered: false, hintText: "" };
22509
22542
  }
22510
- const poolPath = path21.join(this.workspace, "inner-voice", "hints_pool.txt");
22543
+ const poolPath = path22.join(this.workspace, "inner-voice", "hints_pool.txt");
22511
22544
  let hint = "\u60F3\u4ED6\u5C31\u53D1\u6D88\u606F\u5427";
22512
22545
  try {
22513
22546
  const pool = fs21.readFileSync(poolPath, "utf-8").split("\n").map((s2) => s2.trim()).filter(Boolean);
@@ -22535,7 +22568,7 @@ var InnerVoicePlugin = class {
22535
22568
  try {
22536
22569
  const writer = sessions.getWriter(mainSessionId);
22537
22570
  const history = sessions.getHistory(mainSessionId);
22538
- const fullPath = path21.resolve(this.workspace, emoTopic.file);
22571
+ const fullPath = path22.resolve(this.workspace, emoTopic.file);
22539
22572
  const memories = [{
22540
22573
  path: fullPath,
22541
22574
  content: emoTopic.content,
@@ -22563,9 +22596,9 @@ var InnerVoicePlugin = class {
22563
22596
  /** 写 xiaoyi.log(格式对齐旧 memory_whisper.py,便于既有日志分析复用)。 */
22564
22597
  writeLog(status, delivered, activity, hintTriggered, hintText) {
22565
22598
  try {
22566
- const logDir = path21.join(this.workspace, "inner-voice");
22599
+ const logDir = path22.join(this.workspace, "inner-voice");
22567
22600
  fs21.mkdirSync(logDir, { recursive: true });
22568
- const logPath = path21.join(logDir, "xiaoyi.log");
22601
+ const logPath = path22.join(logDir, "xiaoyi.log");
22569
22602
  const ts = formatBeijingTs(/* @__PURE__ */ new Date());
22570
22603
  const hintStatus = hintTriggered ? `YES (${(hintText || "").trim()})` : "no";
22571
22604
  fs21.appendFileSync(
@@ -23104,7 +23137,7 @@ var PluginManager = class {
23104
23137
  // src/voice-chat/plugin.ts
23105
23138
  import { spawn as spawn4, exec } from "node:child_process";
23106
23139
  import net from "node:net";
23107
- import path22 from "node:path";
23140
+ import path23 from "node:path";
23108
23141
  import fs22 from "node:fs";
23109
23142
 
23110
23143
  // src/voice-chat/bridge.ts
@@ -23481,13 +23514,13 @@ var VoiceChatPlugin = class _VoiceChatPlugin {
23481
23514
  }
23482
23515
  getPythonDir() {
23483
23516
  const dir = import.meta.dirname;
23484
- const srcDir = path22.resolve(dir, "..", "src", "voice-chat", "python");
23485
- const localDir = path22.join(dir, "python");
23517
+ const srcDir = path23.resolve(dir, "..", "src", "voice-chat", "python");
23518
+ const localDir = path23.join(dir, "python");
23486
23519
  return fs22.existsSync(srcDir) ? srcDir : localDir;
23487
23520
  }
23488
23521
  startPython() {
23489
23522
  const pythonDir = this.getPythonDir();
23490
- const serverPy = path22.join(pythonDir, "server.py");
23523
+ const serverPy = path23.join(pythonDir, "server.py");
23491
23524
  const pythonBin = this.findPython();
23492
23525
  const args = [serverPy];
23493
23526
  if (this.config.pythonPort) args.push("--port", String(this.config.pythonPort));
@@ -23572,7 +23605,7 @@ var VoiceChatPlugin = class _VoiceChatPlugin {
23572
23605
  init_BashTool();
23573
23606
  import { spawn as spawn5, exec as exec2 } from "node:child_process";
23574
23607
  import net2 from "node:net";
23575
- import path23 from "node:path";
23608
+ import path24 from "node:path";
23576
23609
  import fs23 from "node:fs";
23577
23610
 
23578
23611
  // src/memory/cognifold/config.ts
@@ -23611,11 +23644,11 @@ var CogniFoldClient = class {
23611
23644
  this.timeoutMs = timeoutMs;
23612
23645
  this.modelName = modelName;
23613
23646
  }
23614
- async req(path44, options = {}) {
23647
+ async req(path45, options = {}) {
23615
23648
  const ctrl = new AbortController();
23616
23649
  const timer = setTimeout(() => ctrl.abort(), this.timeoutMs);
23617
23650
  try {
23618
- const resp = await fetch(`${this.baseUrl}${path44}`, {
23651
+ const resp = await fetch(`${this.baseUrl}${path45}`, {
23619
23652
  ...options,
23620
23653
  signal: ctrl.signal,
23621
23654
  headers: {
@@ -23705,20 +23738,20 @@ var CogniFoldClient = class {
23705
23738
  });
23706
23739
  }
23707
23740
  /** 兼容老版命名 */
23708
- async recl(path44, options = {}) {
23709
- return this.req(path44, options);
23741
+ async recl(path45, options = {}) {
23742
+ return this.req(path45, options);
23710
23743
  }
23711
23744
  };
23712
23745
 
23713
23746
  // src/memory/cognifold/session-manager.ts
23714
23747
  import { readFile as readFile6, writeFile as writeFile5, mkdir as mkdir4 } from "node:fs/promises";
23715
- import { join as join23, dirname as dirname3 } from "node:path";
23748
+ import { join as join24, dirname as dirname3 } from "node:path";
23716
23749
  var CogniFoldSessionManager = class {
23717
23750
  constructor(workspacePath, config, client) {
23718
23751
  this.workspacePath = workspacePath;
23719
23752
  this.config = config;
23720
23753
  this.client = client;
23721
- this.sessionsDir = join23(workspacePath, ".cognifold", "sessions");
23754
+ this.sessionsDir = join24(workspacePath, ".cognifold", "sessions");
23722
23755
  }
23723
23756
  workspacePath;
23724
23757
  config;
@@ -23788,7 +23821,7 @@ var CogniFoldSessionManager = class {
23788
23821
  console.log(`[cognifold] Created new session for scope "${scope}": ${newSession.sessionId}`);
23789
23822
  }
23790
23823
  getFilePath(scope) {
23791
- return join23(this.sessionsDir, `${scope}.json`);
23824
+ return join24(this.sessionsDir, `${scope}.json`);
23792
23825
  }
23793
23826
  async writeFileSafe(filePath, data) {
23794
23827
  try {
@@ -23987,16 +24020,16 @@ var CogniFoldPlugin = class {
23987
24020
  const dir = import.meta.dirname;
23988
24021
  const candidates = [
23989
24022
  // 从 dist/ 往回找 src
23990
- path23.resolve(dir, "..", "src", "memory", "cognifold", "python"),
23991
- path23.resolve(dir, "..", "..", "src", "memory", "cognifold", "python"),
23992
- path23.resolve(dir, "..", "..", "..", "src", "memory", "cognifold", "python"),
24023
+ path24.resolve(dir, "..", "src", "memory", "cognifold", "python"),
24024
+ path24.resolve(dir, "..", "..", "src", "memory", "cognifold", "python"),
24025
+ path24.resolve(dir, "..", "..", "..", "src", "memory", "cognifold", "python"),
23993
24026
  // 从 src/memory/cognifold/ 找本地
23994
- path23.join(dir, "python"),
24027
+ path24.join(dir, "python"),
23995
24028
  // 从 dist/memory/cognifold/ 找本地
23996
- path23.resolve(dir, "python")
24029
+ path24.resolve(dir, "python")
23997
24030
  ];
23998
24031
  for (const candidate of candidates) {
23999
- if (fs23.existsSync(path23.join(candidate, "cognifold"))) {
24032
+ if (fs23.existsSync(path24.join(candidate, "cognifold"))) {
24000
24033
  return candidate;
24001
24034
  }
24002
24035
  }
@@ -24022,7 +24055,7 @@ var CogniFoldPlugin = class {
24022
24055
  const pythonBin = this.findPython();
24023
24056
  console.log(`[cognifold] Starting Python: ${pythonBin} ${args.join(" ")}`);
24024
24057
  console.log(`[cognifold] Python dir: ${pythonDir}`);
24025
- if (!fs23.existsSync(path23.join(pythonDir, "cognifold"))) {
24058
+ if (!fs23.existsSync(path24.join(pythonDir, "cognifold"))) {
24026
24059
  console.error(`[cognifold] FATAL: Python module not found at ${pythonDir}/cognifold`);
24027
24060
  throw new Error(`cognifold: python module not found`);
24028
24061
  }
@@ -24033,7 +24066,7 @@ var CogniFoldPlugin = class {
24033
24066
  if (this.config.llm?.baseUrl) {
24034
24067
  childEnv["OPENAI_BASE_URL"] = this.config.llm.baseUrl;
24035
24068
  }
24036
- const envFile = path23.join(pythonDir, ".env");
24069
+ const envFile = path24.join(pythonDir, ".env");
24037
24070
  try {
24038
24071
  if (fs23.existsSync(envFile)) {
24039
24072
  const envContent = fs23.readFileSync(envFile, "utf-8");
@@ -24105,7 +24138,7 @@ var CogniFoldPlugin = class {
24105
24138
  init_BashTool();
24106
24139
  import { spawn as spawn6 } from "node:child_process";
24107
24140
  import net3 from "node:net";
24108
- import path24 from "node:path";
24141
+ import path25 from "node:path";
24109
24142
  import fs24 from "node:fs";
24110
24143
 
24111
24144
  // src/memory/everos/config.ts
@@ -24313,8 +24346,8 @@ var EverosPlugin = class {
24313
24346
  }, 3e5);
24314
24347
  }
24315
24348
  async startEveros() {
24316
- const pythonDir = path24.dirname(this.config.lancedbPath);
24317
- const configPath = path24.join(pythonDir, "config.toml");
24349
+ const pythonDir = path25.dirname(this.config.lancedbPath);
24350
+ const configPath = path25.join(pythonDir, "config.toml");
24318
24351
  await this.ensureFcntlCompat();
24319
24352
  const venvPython = this.findVenvPython();
24320
24353
  const everosBin = venvPython.replace(/python\.exe$/, "everos.exe");
@@ -24403,19 +24436,19 @@ var EverosPlugin = class {
24403
24436
  return child;
24404
24437
  }
24405
24438
  findVenvPython() {
24406
- const stateDir = process.env.OPENCLAW_STATE_DIR || path24.join(process.env.HOME || process.env.USERPROFILE || ".", ".openclaw");
24439
+ const stateDir = (process.env.ENGINE7_STATE_DIR ?? process.env.OPENCLAW_STATE_DIR) || path25.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
24407
24440
  if (process.platform === "win32") {
24408
- return path24.join(stateDir, "everos-venv", "Scripts", "python.exe");
24441
+ return path25.join(stateDir, "everos-venv", "Scripts", "python.exe");
24409
24442
  }
24410
- return path24.join(stateDir, "everos-venv", "bin", "python");
24443
+ return path25.join(stateDir, "everos-venv", "bin", "python");
24411
24444
  }
24412
24445
  /** 检测 venv 是否存在,不存在就自动创建 + 装 EverOS */
24413
24446
  async ensureVenv() {
24414
24447
  const venvPython = this.findVenvPython();
24415
24448
  if (fs24.existsSync(venvPython)) return;
24416
- const stateDir = process.env.OPENCLAW_STATE_DIR || path24.join(process.env.HOME || process.env.USERPROFILE || ".", ".openclaw");
24417
- const venvDir = path24.join(stateDir, "everos-venv");
24418
- const everosSrc = path24.join(stateDir, "workspace", "research", "EverOS");
24449
+ const stateDir = (process.env.ENGINE7_STATE_DIR ?? process.env.OPENCLAW_STATE_DIR) || path25.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
24450
+ const venvDir = path25.join(stateDir, "everos-venv");
24451
+ const everosSrc = path25.join(stateDir, "workspace", "research", "EverOS");
24419
24452
  console.log(`[everos] venv not found at ${venvDir}, auto-creating...`);
24420
24453
  console.log(`[everos] \u23F3 This may take a few minutes on first run...`);
24421
24454
  const pyCandidates = process.platform === "win32" ? ["python", "python3", "C:\\Python314\\python.exe", "C:\\Python313\\python.exe", "C:\\Python312\\python.exe"] : ["python3", "python"];
@@ -24437,8 +24470,8 @@ var EverosPlugin = class {
24437
24470
  console.log(`[everos] Creating venv with ${sysPython}...`);
24438
24471
  const { execSync: execSync3 } = await import("node:child_process");
24439
24472
  execSync3(`"${sysPython}" -m venv "${venvDir}"`, { stdio: "pipe", shell: true });
24440
- const pip = process.platform === "win32" ? path24.join(venvDir, "Scripts", "pip.exe") : path24.join(venvDir, "bin", "pip");
24441
- const everosReq = path24.join(this.getPythonDir(), "requirements.txt");
24473
+ const pip = process.platform === "win32" ? path25.join(venvDir, "Scripts", "pip.exe") : path25.join(venvDir, "bin", "pip");
24474
+ const everosReq = path25.join(this.getPythonDir(), "requirements.txt");
24442
24475
  if (fs24.existsSync(everosReq)) {
24443
24476
  console.log(`[everos] Installing from requirements.txt...`);
24444
24477
  execSync3(`"${pip}" install -r "${everosReq}" -q`, { stdio: "pipe", shell: true, timeout: 3e5 });
@@ -24455,12 +24488,12 @@ var EverosPlugin = class {
24455
24488
  getPythonDir() {
24456
24489
  const dir = import.meta.dirname;
24457
24490
  const candidates = [
24458
- path24.join(dir, "python"),
24459
- path24.resolve(dir, "..", "src", "memory", "everos", "python"),
24460
- path24.resolve(dir, "..", "..", "..", "src", "memory", "everos", "python")
24491
+ path25.join(dir, "python"),
24492
+ path25.resolve(dir, "..", "src", "memory", "everos", "python"),
24493
+ path25.resolve(dir, "..", "..", "..", "src", "memory", "everos", "python")
24461
24494
  ];
24462
24495
  for (const candidate of candidates) {
24463
- if (fs24.existsSync(path24.join(candidate, "agentic_server.py"))) {
24496
+ if (fs24.existsSync(path25.join(candidate, "agentic_server.py"))) {
24464
24497
  return candidate;
24465
24498
  }
24466
24499
  }
@@ -24469,11 +24502,11 @@ var EverosPlugin = class {
24469
24502
  async ensureFcntlCompat() {
24470
24503
  if (process.platform !== "win32") return;
24471
24504
  const venvPython = this.findVenvPython();
24472
- const venvDir = path24.dirname(path24.dirname(venvPython));
24473
- const sitePackages = path24.join(venvDir, "Lib", "site-packages");
24474
- const target = path24.join(sitePackages, "fcntl.py");
24505
+ const venvDir = path25.dirname(path25.dirname(venvPython));
24506
+ const sitePackages = path25.join(venvDir, "Lib", "site-packages");
24507
+ const target = path25.join(sitePackages, "fcntl.py");
24475
24508
  if (fs24.existsSync(target)) return;
24476
- const source = path24.join(this.getPythonDir(), "fcntl_compat.py");
24509
+ const source = path25.join(this.getPythonDir(), "fcntl_compat.py");
24477
24510
  if (fs24.existsSync(source)) {
24478
24511
  try {
24479
24512
  fs24.copyFileSync(source, target);
@@ -24523,7 +24556,7 @@ var EverosPlugin = class {
24523
24556
  init_task_manager();
24524
24557
 
24525
24558
  // src/skills/scanner.ts
24526
- import * as path25 from "node:path";
24559
+ import * as path26 from "node:path";
24527
24560
  import * as fs25 from "node:fs";
24528
24561
  function scanSkills(skillsDir) {
24529
24562
  if (!fs25.existsSync(skillsDir)) {
@@ -24534,7 +24567,7 @@ function scanSkills(skillsDir) {
24534
24567
  const skills = [];
24535
24568
  for (const entry of entries) {
24536
24569
  if (!entry.isDirectory()) continue;
24537
- const skillMdPath = path25.join(skillsDir, entry.name, "SKILL.md");
24570
+ const skillMdPath = path26.join(skillsDir, entry.name, "SKILL.md");
24538
24571
  if (!fs25.existsSync(skillMdPath)) continue;
24539
24572
  try {
24540
24573
  const content = fs25.readFileSync(skillMdPath, "utf-8");
@@ -24602,7 +24635,7 @@ function parseFrontmatter2(content) {
24602
24635
  // src/tools/SkillTool/SkillTool.ts
24603
24636
  init_registry();
24604
24637
  import * as fs26 from "node:fs";
24605
- import * as path26 from "node:path";
24638
+ import * as path27 from "node:path";
24606
24639
 
24607
24640
  // src/tools/SkillTool/constants.ts
24608
24641
  var SKILL_TOOL_NAME2 = "Skill";
@@ -24679,12 +24712,12 @@ Important:
24679
24712
  `;
24680
24713
  }
24681
24714
  function loadSkillContent(skillName) {
24682
- const skillMdPath = path26.join(skillsDirPath, skillName, "SKILL.md");
24715
+ const skillMdPath = path27.join(skillsDirPath, skillName, "SKILL.md");
24683
24716
  if (!fs26.existsSync(skillMdPath)) return null;
24684
24717
  const content = fs26.readFileSync(skillMdPath, "utf-8");
24685
24718
  const bodyMatch = content.match(/^---\s*\n[\s\S]*?\n---\s*\n([\s\S]*)/);
24686
24719
  const body = bodyMatch ? bodyMatch[1] : content;
24687
- const skillDir = path26.dirname(skillMdPath);
24720
+ const skillDir = path27.dirname(skillMdPath);
24688
24721
  const normalizedDir = process.platform === "win32" ? skillDir.replace(/\\/g, "/") : skillDir;
24689
24722
  let finalContent = `Base directory for this skill: ${normalizedDir}
24690
24723
 
@@ -24959,9 +24992,9 @@ Examples:
24959
24992
  init_registry();
24960
24993
  init_live();
24961
24994
  import fs27 from "node:fs";
24962
- import path27 from "node:path";
24995
+ import path28 from "node:path";
24963
24996
  function getHusbandFeishuId(workspace) {
24964
- const contactsPath = path27.join(workspace, "prompts", "contacts.md");
24997
+ const contactsPath = path28.join(workspace, "prompts", "contacts.md");
24965
24998
  try {
24966
24999
  const text = fs27.readFileSync(contactsPath, "utf-8");
24967
25000
  const m2 = text.match(/\|\s*翀哥\s*\|\s*(ou_[a-f0-9]+)\s*\|/);
@@ -25164,7 +25197,7 @@ Examples:
25164
25197
  init_live();
25165
25198
  init_registry();
25166
25199
  import * as fs28 from "node:fs";
25167
- import * as path28 from "node:path";
25200
+ import * as path29 from "node:path";
25168
25201
  var MIME_MAP = {
25169
25202
  ".jpg": "jpeg",
25170
25203
  ".jpeg": "jpeg",
@@ -25176,7 +25209,7 @@ var MIME_MAP = {
25176
25209
  function resolveLatestImage(specifiedPath, mediaDir) {
25177
25210
  if (specifiedPath && fs28.existsSync(specifiedPath)) return specifiedPath;
25178
25211
  if (!fs28.existsSync(mediaDir)) return null;
25179
- const files = fs28.readdirSync(mediaDir).filter((f2) => /\.(jpg|jpeg|png|webp|gif|bmp)$/i.test(f2)).map((f2) => ({ name: f2, p: path28.join(mediaDir, f2), mtime: fs28.statSync(path28.join(mediaDir, f2)).mtimeMs })).sort((a, b2) => b2.mtime - a.mtime);
25212
+ const files = fs28.readdirSync(mediaDir).filter((f2) => /\.(jpg|jpeg|png|webp|gif|bmp)$/i.test(f2)).map((f2) => ({ name: f2, p: path29.join(mediaDir, f2), mtime: fs28.statSync(path29.join(mediaDir, f2)).mtimeMs })).sort((a, b2) => b2.mtime - a.mtime);
25180
25213
  return files[0]?.p || null;
25181
25214
  }
25182
25215
  registry.register({
@@ -25200,13 +25233,13 @@ registry.register({
25200
25233
  if (!provider?.streamChat) {
25201
25234
  return { content: "Error: provider \u4E0D\u53EF\u7528\u3002", isError: true };
25202
25235
  }
25203
- const mediaDir = path28.join(ctx.stateDir, "media", "inbound");
25236
+ const mediaDir = path29.join(ctx.stateDir, "media", "inbound");
25204
25237
  const imagePath = resolveLatestImage(args.image_path, mediaDir);
25205
25238
  if (!imagePath) {
25206
25239
  return { content: "Error: no image found. Provide image_path or ensure media/inbound has images.", isError: true };
25207
25240
  }
25208
25241
  const rawPrompt = args.prompt?.trim() || "\u63CF\u8FF0\u8FD9\u5F20\u56FE\u7247\u7684\u5185\u5BB9";
25209
- const ext = path28.extname(imagePath).toLowerCase();
25242
+ const ext = path29.extname(imagePath).toLowerCase();
25210
25243
  const mime = MIME_MAP[ext] || "jpeg";
25211
25244
  const imgB64 = fs28.readFileSync(imagePath).toString("base64");
25212
25245
  const userMsg = {
@@ -25246,13 +25279,13 @@ init_registry();
25246
25279
  import { execFile } from "node:child_process";
25247
25280
  import { promisify } from "node:util";
25248
25281
  import * as fs29 from "node:fs";
25249
- import * as path29 from "node:path";
25282
+ import * as path30 from "node:path";
25250
25283
  import * as os3 from "node:os";
25251
25284
  var execFileAsync = promisify(execFile);
25252
- var VOICE_DIR = path29.join(os3.tmpdir(), "engine-voice");
25285
+ var VOICE_DIR = path30.join(os3.tmpdir(), "engine-voice");
25253
25286
  async function ttsCosyvoice(text, apiKey, model, voice, workspaceId) {
25254
25287
  fs29.mkdirSync(VOICE_DIR, { recursive: true });
25255
- const output = path29.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25288
+ const output = path30.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25256
25289
  const script = `
25257
25290
  import sys, json, wave, time, threading
25258
25291
  import dashscope
@@ -25317,7 +25350,7 @@ var GPTSOVITS_REF_TEXT = "\u6625\u7720\u4E0D\u89C9\u6653\uFF0C\u5904\u5904\u95FB
25317
25350
  var GPTSOVITS_REF_LANG = "zh";
25318
25351
  async function ttsGptsovits(text) {
25319
25352
  fs29.mkdirSync(VOICE_DIR, { recursive: true });
25320
- const output = path29.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25353
+ const output = path30.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25321
25354
  const params = new URLSearchParams({
25322
25355
  text,
25323
25356
  text_language: "zh",
@@ -25334,7 +25367,7 @@ async function ttsGptsovits(text) {
25334
25367
  var EDGE_VOICE = "zh-CN-XiaoxiaoNeural";
25335
25368
  async function ttsEdge(text) {
25336
25369
  fs29.mkdirSync(VOICE_DIR, { recursive: true });
25337
- const output = path29.join(VOICE_DIR, `tts_${Date.now()}.mp3`);
25370
+ const output = path30.join(VOICE_DIR, `tts_${Date.now()}.mp3`);
25338
25371
  const script = `
25339
25372
  import asyncio, edge_tts, sys
25340
25373
  async def main():
@@ -25427,7 +25460,7 @@ registry.register({
25427
25460
  } catch (e) {
25428
25461
  return { content: `TTS failed: ${e.message}`, isError: true };
25429
25462
  }
25430
- const ext = path29.extname(audioPath).toLowerCase();
25463
+ const ext = path30.extname(audioPath).toLowerCase();
25431
25464
  const mimeMap = { ".mp3": "audio/mpeg", ".wav": "audio/wav", ".m4a": "audio/mp4", ".ogg": "audio/ogg" };
25432
25465
  const mimeType = mimeMap[ext] || "audio/mpeg";
25433
25466
  const sizeKB = fs29.statSync(audioPath).size / 1024;
@@ -25458,7 +25491,7 @@ registry.register({
25458
25491
  init_live();
25459
25492
  init_registry();
25460
25493
  import * as fs30 from "node:fs";
25461
- import * as path30 from "node:path";
25494
+ import * as path31 from "node:path";
25462
25495
  var FAL_KEY = "3b848fc6-bee5-46e5-8db7-ae81ac16dc28:2f1f15cf394db2d32c9bb9a4f23f3bee";
25463
25496
  var FAL_ENDPOINT = "https://fal.run/xai/grok-imagine-image/edit";
25464
25497
  var DEFAULT_RESOLUTION = "1k";
@@ -25574,7 +25607,7 @@ registry.register({
25574
25607
  const REFERENCES = getReferences(ctx);
25575
25608
  const refName = args.reference || "default";
25576
25609
  const refEntry = REFERENCES.find((r) => r.name === refName) || REFERENCES[0];
25577
- const refPath = path30.join(ctx.workspace, refEntry.p);
25610
+ const refPath = path31.join(ctx.workspace, refEntry.p);
25578
25611
  if (!fs30.existsSync(refPath)) {
25579
25612
  return { content: `Error: reference image not found at ${refPath}`, isError: true };
25580
25613
  }
@@ -25593,10 +25626,10 @@ registry.register({
25593
25626
  } catch (err) {
25594
25627
  return { content: `Selfie generation failed: ${err.message}`, isError: true };
25595
25628
  }
25596
- const imagesDir = path30.join(ctx.workspace, "images");
25629
+ const imagesDir = path31.join(ctx.workspace, "images");
25597
25630
  if (!fs30.existsSync(imagesDir)) fs30.mkdirSync(imagesDir, { recursive: true });
25598
25631
  const filename = `selfie_${Date.now()}.jpg`;
25599
- const outputPath = path30.join(imagesDir, filename);
25632
+ const outputPath = path31.join(imagesDir, filename);
25600
25633
  fs30.writeFileSync(outputPath, imageBuffer);
25601
25634
  const mgr = ctx.channelManager;
25602
25635
  if (mgr) {
@@ -25608,11 +25641,11 @@ registry.register({
25608
25641
  mimeType: "image/jpeg"
25609
25642
  });
25610
25643
  } catch (err) {
25611
- return { content: `Selfie generated but send failed: ${err.message}. Image: ${path30.resolve(outputPath)}`, isError: false };
25644
+ return { content: `Selfie generated but send failed: ${err.message}. Image: ${path31.resolve(outputPath)}`, isError: false };
25612
25645
  }
25613
25646
  return { content: `Selfie sent! Mode: ${mode}, Provider: ${getProvider(ctx)}, Ref: ${refEntry.name}` };
25614
25647
  }
25615
- return { content: `Selfie generated! Mode: ${mode}, Ref: ${refEntry.name}. Image: ${path30.resolve(outputPath)}` };
25648
+ return { content: `Selfie generated! Mode: ${mode}, Ref: ${refEntry.name}. Image: ${path31.resolve(outputPath)}` };
25616
25649
  },
25617
25650
  isConcurrencySafe: () => false,
25618
25651
  interruptBehavior: () => "block",
@@ -26079,14 +26112,14 @@ init_planModeState();
26079
26112
 
26080
26113
  // src/utils/plans.ts
26081
26114
  import * as fs32 from "node:fs";
26082
- import * as path32 from "node:path";
26115
+ import * as path33 from "node:path";
26083
26116
  import * as crypto4 from "node:crypto";
26084
26117
  var MAX_SLUG_RETRIES = 10;
26085
26118
  function generateSlug() {
26086
26119
  return crypto4.randomBytes(4).toString("hex");
26087
26120
  }
26088
26121
  function getPlansDirectory(stateDir) {
26089
- const plansDir = path32.join(stateDir, "plans");
26122
+ const plansDir = path33.join(stateDir, "plans");
26090
26123
  fs32.mkdirSync(plansDir, { recursive: true });
26091
26124
  return plansDir;
26092
26125
  }
@@ -26097,7 +26130,7 @@ function getPlanSlug(sessionId, stateDir) {
26097
26130
  const plansDir = getPlansDirectory(stateDir);
26098
26131
  for (let i = 0; i < MAX_SLUG_RETRIES; i++) {
26099
26132
  slug = generateSlug();
26100
- const filePath = path32.join(plansDir, `${slug}.md`);
26133
+ const filePath = path33.join(plansDir, `${slug}.md`);
26101
26134
  if (!fs32.existsSync(filePath)) {
26102
26135
  break;
26103
26136
  }
@@ -26109,9 +26142,9 @@ function getPlanSlug(sessionId, stateDir) {
26109
26142
  function getPlanFilePath(sessionId, stateDir, agentId) {
26110
26143
  const slug = getPlanSlug(sessionId, stateDir);
26111
26144
  if (!agentId) {
26112
- return path32.join(getPlansDirectory(stateDir), `${slug}.md`);
26145
+ return path33.join(getPlansDirectory(stateDir), `${slug}.md`);
26113
26146
  }
26114
- return path32.join(getPlansDirectory(stateDir), `${slug}-agent-${agentId}.md`);
26147
+ return path33.join(getPlansDirectory(stateDir), `${slug}-agent-${agentId}.md`);
26115
26148
  }
26116
26149
  function getPlan(sessionId, stateDir, agentId) {
26117
26150
  const filePath = getPlanFilePath(sessionId, stateDir, agentId);
@@ -26962,7 +26995,7 @@ async function setupFeatures(features, licensedFeatures) {
26962
26995
  // src/license/license.ts
26963
26996
  import * as crypto6 from "node:crypto";
26964
26997
  import * as fs39 from "node:fs";
26965
- import * as path40 from "node:path";
26998
+ import * as path41 from "node:path";
26966
26999
  var EMBEDDED_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
26967
27000
  MCowBQYDK2VwAyEAaKBEX+e8+D59qwtidazsu7WYDglApyvsVI3APwFoakA=
26968
27001
  -----END PUBLIC KEY-----`;
@@ -26993,7 +27026,7 @@ function loadLicense(stateDir, devMode) {
26993
27026
  _cachedLicense = allActive;
26994
27027
  return allActive;
26995
27028
  }
26996
- const licensePath = path40.join(stateDir, "license.json");
27029
+ const licensePath = path41.join(stateDir, "license.json");
26997
27030
  if (!fs39.existsSync(licensePath)) {
26998
27031
  console.log("[license] No license.json found, running basic engine only");
26999
27032
  return null;
@@ -27618,9 +27651,10 @@ async function startEngine(config, opts) {
27618
27651
  process.env.ENGINE_MEDIA_DIR = config.mediaDir;
27619
27652
  process.env.ENGINE7_WORKSPACE = config.workspace;
27620
27653
  process.env.OPENCLAW_WORKSPACE = config.workspace;
27621
- fs41.mkdirSync(path43.join(config.stateDir, "agents", "main", "memory"), { recursive: true });
27622
- fs41.mkdirSync(path43.join(config.stateDir, "agents", "main", "sessions"), { recursive: true });
27623
- fs41.mkdirSync(path43.join(config.stateDir, "logs"), { recursive: true });
27654
+ process.env.ENGINE7_STATE_DIR = config.stateDir;
27655
+ fs41.mkdirSync(path44.join(config.stateDir, "agents", "main", "memory"), { recursive: true });
27656
+ fs41.mkdirSync(path44.join(config.stateDir, "agents", "main", "sessions"), { recursive: true });
27657
+ fs41.mkdirSync(path44.join(config.stateDir, "logs"), { recursive: true });
27624
27658
  fs41.mkdirSync(config.workspace, { recursive: true });
27625
27659
  fs41.mkdirSync(config.mediaDir, { recursive: true });
27626
27660
  try {
@@ -27730,7 +27764,7 @@ async function startEngine(config, opts) {
27730
27764
  const { initSessionMemory: initSessionMemory2 } = await Promise.resolve().then(() => (init_sessionMemory(), sessionMemory_exports));
27731
27765
  initSessionMemory2({
27732
27766
  workspace: config.workspace,
27733
- stateDir: path43.join(config.stateDir, "session-memory"),
27767
+ stateDir: path44.join(config.stateDir, "session-memory"),
27734
27768
  provider,
27735
27769
  model: config.provider.modelId || config.model || "deepseek-v4-flash",
27736
27770
  features: config.profile.features
@@ -27760,9 +27794,9 @@ async function startEngine(config, opts) {
27760
27794
  if (config.hooks) {
27761
27795
  loadHooksFromConfig({ hooks: config.hooks });
27762
27796
  }
27763
- const hooksPath = path43.join(config.workspace, ".hooks.json");
27797
+ const hooksPath = path44.join(config.workspace, ".hooks.json");
27764
27798
  loadHooksFromFile(hooksPath);
27765
- const settingsHooksPath = path43.join(config.stateDir, "settings.json");
27799
+ const settingsHooksPath = path44.join(config.stateDir, "settings.json");
27766
27800
  loadHooksFromFile(settingsHooksPath);
27767
27801
  console.log(`[hooks] Loaded hooks configuration`);
27768
27802
  registerCallbackHook("PreCompact", {
@@ -27776,15 +27810,15 @@ async function startEngine(config, opts) {
27776
27810
  const bjTime = new Date(now.getTime() + (bjOffset + now.getTimezoneOffset()) * 6e4);
27777
27811
  const dateStr = `${bjTime.getFullYear()}-${String(bjTime.getMonth() + 1).padStart(2, "0")}-${String(bjTime.getDate()).padStart(2, "0")}`;
27778
27812
  const timeStr = `${String(bjTime.getHours()).padStart(2, "0")}:${String(bjTime.getMinutes()).padStart(2, "0")}`;
27779
- const dailyDir = path43.join(workspace, "memory", "daily");
27780
- const dailyPath = path43.join(dailyDir, `${dateStr}.md`);
27813
+ const dailyDir = path44.join(workspace, "memory", "daily");
27814
+ const dailyPath = path44.join(dailyDir, `${dateStr}.md`);
27781
27815
  try {
27782
27816
  const fs42 = await import("node:fs");
27783
27817
  if (!fs42.existsSync(dailyDir)) {
27784
27818
  fs42.mkdirSync(dailyDir, { recursive: true });
27785
27819
  }
27786
- const sessionsDir = path43.join(config.stateDir, "agents", "main", "sessions");
27787
- const sessionFile = path43.join(sessionsDir, `${sessionId}.jsonl`);
27820
+ const sessionsDir = path44.join(config.stateDir, "agents", "main", "sessions");
27821
+ const sessionFile = path44.join(sessionsDir, `${sessionId}.jsonl`);
27788
27822
  const recentLines = [];
27789
27823
  if (fs42.existsSync(sessionFile)) {
27790
27824
  const content = fs42.readFileSync(sessionFile, "utf-8");
@@ -27837,7 +27871,7 @@ ${entry}`);
27837
27871
  if (!workspace) return { continue: true };
27838
27872
  try {
27839
27873
  const fs42 = await import("node:fs");
27840
- const bufferPath = path43.join(workspace, "memory", "working-buffer.md");
27874
+ const bufferPath = path44.join(workspace, "memory", "working-buffer.md");
27841
27875
  if (fs42.existsSync(bufferPath)) {
27842
27876
  const stat4 = fs42.statSync(bufferPath);
27843
27877
  const ageMs = Date.now() - stat4.mtimeMs;
@@ -27890,7 +27924,7 @@ ${content}`
27890
27924
  return `${hr}h ${remMin}m`;
27891
27925
  }
27892
27926
  if (config.skills?.enabled !== false) {
27893
- const skillsDir = config.skills?.path ? path43.isAbsolute(config.skills.path) ? config.skills.path : path43.resolve(config.workspace, config.skills.path) : path43.resolve(config.workspace, "skills");
27927
+ const skillsDir = config.skills?.path ? path44.isAbsolute(config.skills.path) ? config.skills.path : path44.resolve(config.workspace, config.skills.path) : path44.resolve(config.workspace, "skills");
27894
27928
  const modelDef2 = config.provider.models.find((m2) => m2.id === config.model);
27895
27929
  const contextWindowTokens = modelDef2?.contextWindow;
27896
27930
  const skills = scanSkills(skillsDir);
@@ -27909,7 +27943,7 @@ ${content}`
27909
27943
  workspace: config.workspace
27910
27944
  });
27911
27945
  const systemPrompt = [systemStable, systemDynamic].join("\n\n");
27912
- const promptDumpPath = path43.join(config.workspace, ".system-prompt.txt");
27946
+ const promptDumpPath = path44.join(config.workspace, ".system-prompt.txt");
27913
27947
  fs41.writeFileSync(promptDumpPath, systemPrompt);
27914
27948
  console.log(`System prompt: ${systemStable.length} chars stable + ${systemDynamic.length} chars dynamic \u2192 ${promptDumpPath}`);
27915
27949
  const modelDef = config.provider.models.find((m2) => m2.id === config.model);
@@ -28013,31 +28047,6 @@ ${content}`
28013
28047
  sessions.migrateOldSessions();
28014
28048
  sessions.startIdleCleanup();
28015
28049
  cleanupArchivedSessionTranscripts(sessions.sessionsDir);
28016
- const everosCfg = config.everos;
28017
- if (everosCfg?.enabled) {
28018
- const { createEverosSync: createEverosSync2 } = await Promise.resolve().then(() => (init_everos_sync(), everos_sync_exports));
28019
- const everosSync = createEverosSync2({
28020
- enabled: true,
28021
- url: everosCfg.everosUrl || "http://127.0.0.1:8100",
28022
- appId: everosCfg.userId || "default",
28023
- userId: everosCfg.userId || "default",
28024
- agentName: everosCfg.agentName || everosCfg.userId || "assistant"
28025
- });
28026
- sessions.onWriterCreated = (writer, sessionId) => {
28027
- writer.onMessageWritten = (msg2) => {
28028
- console.log(`[everos-sync] onMessageWritten fired: role=${msg2.role} len=${msg2.text.length}`);
28029
- everosSync.push({
28030
- sessionId: writer.engineSessionId || sessionId,
28031
- role: msg2.role === "toolResult" ? "tool" : msg2.role,
28032
- text: msg2.text,
28033
- timestamp: new Date(msg2.timestamp).getTime()
28034
- }).catch((e) => console.warn(`[everos-sync] push error: ${e}`));
28035
- };
28036
- };
28037
- console.log(`[everos-sync] hook registered (appId=${everosCfg.userId})`);
28038
- } else {
28039
- console.log(`[everos-sync] SKIPPED \u2014 config.everos not enabled or missing`);
28040
- }
28041
28050
  const channelManager = new ChannelManager();
28042
28051
  const memoryRecallProvider = createMemorySideProvider(
28043
28052
  config.topics?.recall,
@@ -28988,8 +28997,8 @@ Auto-routing disabled \u2014 all messages use this model.
28988
28997
  let writePath = configPath;
28989
28998
  if (configPath && !fs41.existsSync(configPath)) {
28990
28999
  const __pFile = fileURLToPath(import.meta.url);
28991
- const __pDir = path43.dirname(__pFile);
28992
- const altPath = path43.join(path43.resolve(__pDir, "../configs"), path43.basename(configPath));
29000
+ const __pDir = path44.dirname(__pFile);
29001
+ const altPath = path44.join(path44.resolve(__pDir, "../configs"), path44.basename(configPath));
28993
29002
  if (fs41.existsSync(altPath)) {
28994
29003
  console.warn(`[primary] Config not found at ${configPath}, falling back to ${altPath}`);
28995
29004
  writePath = altPath;
@@ -29269,7 +29278,7 @@ Use full ref like \`/vision-model ${candidates[0].ref}\``);
29269
29278
  const ext = detected.split("/")[1] || "png";
29270
29279
  const resized = await maybeResizeAndDownsampleImageBuffer2(rawBuffer, rawBuffer.length, ext);
29271
29280
  const imageId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
29272
- const savedPath = path43.join(config.mediaDir, `${imageId}.${ext}`);
29281
+ const savedPath = path44.join(config.mediaDir, `${imageId}.${ext}`);
29273
29282
  fs41.writeFileSync(savedPath, resized.buffer);
29274
29283
  savedPaths.push(savedPath);
29275
29284
  console.log(`[vision] Saved: ${savedPath} (${resized.buffer.length}B)`);
@@ -29296,7 +29305,7 @@ ${pathStr}` }];
29296
29305
  }
29297
29306
  const nonImageAttachments = inbound.attachments?.filter((a) => !a.contentType.startsWith("image/"));
29298
29307
  if (nonImageAttachments && nonImageAttachments.length > 0) {
29299
- const outDir = path43.join(config.mediaDir, sessionId);
29308
+ const outDir = path44.join(config.mediaDir, sessionId);
29300
29309
  fs41.mkdirSync(outDir, { recursive: true });
29301
29310
  const resolved = [];
29302
29311
  for (const att of nonImageAttachments) {
@@ -29305,8 +29314,8 @@ ${pathStr}` }];
29305
29314
  const resp = await fetch(att.url);
29306
29315
  if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
29307
29316
  const buffer = Buffer.from(await resp.arrayBuffer());
29308
- const safeName2 = path43.basename(att.filename).replace(/[<>:"/\\|?*\x00-\x1f]/g, "_") || "attachment";
29309
- const savedPath = path43.join(outDir, safeName2);
29317
+ const safeName2 = path44.basename(att.filename).replace(/[<>:"/\\|?*\x00-\x1f]/g, "_") || "attachment";
29318
+ const savedPath = path44.join(outDir, safeName2);
29310
29319
  fs41.writeFileSync(savedPath, buffer);
29311
29320
  resolved.push(savedPath);
29312
29321
  console.log(`[file] Saved: ${savedPath} (${buffer.length}B)`);
@@ -29668,7 +29677,7 @@ ${pathStr}` }];
29668
29677
  console.warn("[cognifold] watcher: config.workspace \u672A\u914D\u7F6E\uFF0C\u8DF3\u8FC7 proactive \u5199\u5165");
29669
29678
  return;
29670
29679
  }
29671
- const pFile = path43.join(wsDir, ".cognifold-proactive.json");
29680
+ const pFile = path44.join(wsDir, ".cognifold-proactive.json");
29672
29681
  const cognifoldBaseUrl = config.cognifold?.baseUrl || "http://127.0.0.1:9001";
29673
29682
  const cognifoldSessionId = cfSessionId;
29674
29683
  const rawSuggestions = data.suggestions || data.actions || (data.intent_id ? [data] : []);
@@ -29722,7 +29731,7 @@ ${pathStr}` }];
29722
29731
  console.error(`[cognifold] failed to save proactive: ${e.message}`);
29723
29732
  }
29724
29733
  if (enriched.length > 0) {
29725
- const promptFile = path43.join(config.workspace, "prompts", "cognifold-proactive.md");
29734
+ const promptFile = path44.join(config.workspace, "prompts", "cognifold-proactive.md");
29726
29735
  const promptText = fs41.existsSync(promptFile) ? fs41.readFileSync(promptFile, "utf-8") : "[CogniFold proactive] \u6709 " + enriched.length + " \u4E2A action \u5230\u671F\u4E86";
29727
29736
  const actionsJson = JSON.stringify(enriched, null, 2);
29728
29737
  const sessionId = cfSessionId;
@@ -29828,9 +29837,9 @@ async function doReloadConfig(config, deps, provider) {
29828
29837
  let reloadConfigPath = savedConfigPath;
29829
29838
  if (!fs41.existsSync(reloadConfigPath)) {
29830
29839
  const __filename = fileURLToPath(import.meta.url);
29831
- const __dirname = path43.dirname(__filename);
29832
- const engineConfigsDir = path43.resolve(__dirname, "../configs");
29833
- const altPath = path43.join(engineConfigsDir, path43.basename(savedConfigPath));
29840
+ const __dirname = path44.dirname(__filename);
29841
+ const engineConfigsDir = path44.resolve(__dirname, "../configs");
29842
+ const altPath = path44.join(engineConfigsDir, path44.basename(savedConfigPath));
29834
29843
  if (fs41.existsSync(altPath)) {
29835
29844
  console.warn(`[reload] Config not found at ${reloadConfigPath}, falling back to ${altPath} (dev mode)`);
29836
29845
  reloadConfigPath = altPath;
@@ -29883,7 +29892,7 @@ async function doReloadConfig(config, deps, provider) {
29883
29892
  } catch (err) {
29884
29893
  console.error(`[reload] Failed: ${err.message}`);
29885
29894
  try {
29886
- fs41.appendFileSync(path43.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD FAILED: ${err.message}
29895
+ fs41.appendFileSync(path44.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD FAILED: ${err.message}
29887
29896
  ${err.stack}
29888
29897
  `);
29889
29898
  } catch {
@@ -29895,17 +29904,17 @@ function startConfigWatcher(config, deps, provider) {
29895
29904
  const raw = config._configFilePath;
29896
29905
  let configPath = raw;
29897
29906
  if (!fs41.existsSync(configPath)) {
29898
- configPath = path43.resolve(raw);
29907
+ configPath = path44.resolve(raw);
29899
29908
  }
29900
29909
  if (!fs41.existsSync(configPath)) {
29901
29910
  const __filename2 = fileURLToPath(import.meta.url);
29902
- const __dirname2 = path43.dirname(__filename2);
29903
- configPath = path43.resolve(__dirname2, "..", raw);
29911
+ const __dirname2 = path44.dirname(__filename2);
29912
+ configPath = path44.resolve(__dirname2, "..", raw);
29904
29913
  }
29905
29914
  if (!fs41.existsSync(configPath)) {
29906
29915
  console.warn(`[config-watch] config path invalid: ${configPath}, watcher disabled`);
29907
29916
  try {
29908
- fs41.appendFileSync(path43.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] DISABLED: configPath=${configPath}
29917
+ fs41.appendFileSync(path44.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] DISABLED: configPath=${configPath}
29909
29918
  `);
29910
29919
  } catch {
29911
29920
  }
@@ -29917,13 +29926,13 @@ function startConfigWatcher(config, deps, provider) {
29917
29926
  debounceTimer = setTimeout(async () => {
29918
29927
  console.log(`[config-watch] file changed (${eventType}), reloading...`);
29919
29928
  try {
29920
- fs41.appendFileSync(path43.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] CHANGE eventType=${eventType}, calling doReloadConfig
29929
+ fs41.appendFileSync(path44.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] CHANGE eventType=${eventType}, calling doReloadConfig
29921
29930
  `);
29922
29931
  } catch {
29923
29932
  }
29924
29933
  const result = await doReloadConfig(config, deps, provider);
29925
29934
  try {
29926
- fs41.appendFileSync(path43.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD DONE: ok=${result.ok} changes=${result.changes.join(",")}
29935
+ fs41.appendFileSync(path44.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD DONE: ok=${result.ok} changes=${result.changes.join(",")}
29927
29936
  `);
29928
29937
  } catch {
29929
29938
  }
@@ -29932,14 +29941,14 @@ function startConfigWatcher(config, deps, provider) {
29932
29941
  watcher.on("error", (err) => {
29933
29942
  console.error(`[config-watch] error: ${err.message}`);
29934
29943
  try {
29935
- fs41.appendFileSync(path43.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] ERROR: ${err.message}
29944
+ fs41.appendFileSync(path44.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] ERROR: ${err.message}
29936
29945
  `);
29937
29946
  } catch {
29938
29947
  }
29939
29948
  });
29940
29949
  console.log(`[config-watch] watching ${configPath}`);
29941
29950
  try {
29942
- fs41.appendFileSync(path43.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] STARTED watching=${configPath}
29951
+ fs41.appendFileSync(path44.join(config.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] STARTED watching=${configPath}
29943
29952
  `);
29944
29953
  } catch {
29945
29954
  }