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.
package/dist/main.mjs CHANGED
@@ -3553,6 +3553,10 @@ ${perTurnSystemDynamic}` : deferredHint || perTurnSystemDynamic;
3553
3553
  });
3554
3554
 
3555
3555
  // src/config/live.ts
3556
+ var live_exports = {};
3557
+ __export(live_exports, {
3558
+ liveConfig: () => liveConfig
3559
+ });
3556
3560
  var LiveConfigClass, liveConfig;
3557
3561
  var init_live = __esm({
3558
3562
  "src/config/live.ts"() {
@@ -5067,6 +5071,76 @@ var init_extractPrompts = __esm({
5067
5071
  }
5068
5072
  });
5069
5073
 
5074
+ // src/memory/everos/ingest.ts
5075
+ function parseMeta(text) {
5076
+ const m2 = text.match(/^\[meta:\s*(.+?)\s*\((.+?)\)\s*@(\S+)\s*[^\]]*\]/);
5077
+ if (!m2) return null;
5078
+ return { senderName: m2[1].trim() };
5079
+ }
5080
+ async function readConfig() {
5081
+ const defaults = {
5082
+ url: "http://127.0.0.1:8100",
5083
+ appId: "default",
5084
+ agentName: "assistant",
5085
+ enabled: false
5086
+ };
5087
+ try {
5088
+ const { liveConfig: liveConfig2 } = await Promise.resolve().then(() => (init_live(), live_exports));
5089
+ const cfg = liveConfig2.all()?.everos;
5090
+ if (!cfg) return defaults;
5091
+ return {
5092
+ url: cfg.everosUrl || defaults.url,
5093
+ appId: cfg.userId || defaults.appId,
5094
+ agentName: cfg.agentName || cfg.userId || defaults.agentName,
5095
+ enabled: cfg.enabled === true
5096
+ };
5097
+ } catch {
5098
+ return defaults;
5099
+ }
5100
+ }
5101
+ async function pushConversation(messages, sessionId) {
5102
+ const cfg = await readConfig();
5103
+ if (!cfg.enabled) return;
5104
+ if (!messages.length) return;
5105
+ const payload = {
5106
+ session_id: `extract-${sessionId}`,
5107
+ app_id: cfg.appId,
5108
+ project_id: "default",
5109
+ messages: messages.map((m2) => {
5110
+ const text = typeof m2.content === "string" ? m2.content : "[content blocks]";
5111
+ const meta = m2.role === "user" ? parseMeta(text) : null;
5112
+ const senderName = meta?.senderName ?? (m2.role === "assistant" ? cfg.agentName : void 0) ?? m2.role;
5113
+ return {
5114
+ sender_id: cfg.appId,
5115
+ sender_name: senderName,
5116
+ role: m2.role === "toolResult" ? "tool" : m2.role,
5117
+ timestamp: Date.now(),
5118
+ content: text
5119
+ };
5120
+ })
5121
+ };
5122
+ console.log(`[everos-ingest] pushing ${payload.messages.length} messages to ${cfg.url} (appId=${cfg.appId})`);
5123
+ try {
5124
+ const resp = await fetch(`${cfg.url}/api/v1/memory/add`, {
5125
+ method: "POST",
5126
+ headers: { "Content-Type": "application/json" },
5127
+ body: JSON.stringify(payload),
5128
+ signal: AbortSignal.timeout(1e4)
5129
+ });
5130
+ if (resp.ok) {
5131
+ console.log(`[everos-ingest] \u2705 pushed ${payload.messages.length} messages`);
5132
+ } else {
5133
+ console.warn(`[everos-ingest] memory/add ${resp.status}`);
5134
+ }
5135
+ } catch {
5136
+ }
5137
+ }
5138
+ var init_ingest = __esm({
5139
+ "src/memory/everos/ingest.ts"() {
5140
+ "use strict";
5141
+ }
5142
+ });
5143
+
5070
5144
  // src/memory/memdir/extractMemories.ts
5071
5145
  var extractMemories_exports = {};
5072
5146
  __export(extractMemories_exports, {
@@ -5094,12 +5168,46 @@ function getMemoryTools() {
5094
5168
  const allDefs = registry.definitions();
5095
5169
  return allDefs.filter((d) => MEMORY_TOOL_NAMES.includes(d.function.name));
5096
5170
  }
5171
+ function getStatePath(workspace) {
5172
+ return path12.join(workspace, STATE_FILE);
5173
+ }
5174
+ function loadPersistedState(workspace) {
5175
+ try {
5176
+ const p2 = getStatePath(workspace);
5177
+ if (fs12.existsSync(p2)) {
5178
+ const data = JSON.parse(fs12.readFileSync(p2, "utf-8"));
5179
+ for (const [sid, idx] of Object.entries(data.indices ?? {})) {
5180
+ lastIndexMap.set(sid, idx);
5181
+ }
5182
+ for (const [sid, ts] of Object.entries(data.timestamps ?? {})) {
5183
+ lastExtractTimeMap.set(sid, ts);
5184
+ }
5185
+ console.log(`[memory] loaded extract state for ${Object.keys(data.indices ?? {}).length} session(s) from ${STATE_FILE}`);
5186
+ }
5187
+ } catch (e) {
5188
+ console.warn(`[memory] failed to load extract state: ${e?.message ?? e}`);
5189
+ }
5190
+ }
5191
+ function persistState(workspace) {
5192
+ try {
5193
+ const indices = {};
5194
+ const timestamps = {};
5195
+ for (const [sid, idx] of lastIndexMap.entries()) indices[sid] = idx;
5196
+ for (const [sid, ts] of lastExtractTimeMap.entries()) timestamps[sid] = ts;
5197
+ const data = JSON.stringify({ indices, timestamps }, null, 2);
5198
+ fs12.writeFileSync(getStatePath(workspace), data, "utf-8");
5199
+ } catch (e) {
5200
+ console.warn(`[memory] failed to persist extract state: ${e?.message ?? e}`);
5201
+ }
5202
+ }
5097
5203
  function createMemoryExtractor(workspace, enabled) {
5098
5204
  let inProgress = false;
5205
+ loadPersistedState(workspace);
5099
5206
  return {
5100
5207
  reset(sessionId) {
5101
5208
  lastIndexMap.delete(sessionId);
5102
5209
  lastExtractTimeMap.delete(sessionId);
5210
+ persistState(workspace);
5103
5211
  inProgress = false;
5104
5212
  },
5105
5213
  async execute(messages, provider, model, sessionId, disableThinking, intervalMinutes) {
@@ -5198,6 +5306,9 @@ ${conversationText}`
5198
5306
  }
5199
5307
  lastIndexMap.set(sessionId, messages.length - 1);
5200
5308
  lastExtractTimeMap.set(sessionId, Date.now());
5309
+ persistState(workspace);
5310
+ pushConversation(recentMessages2, sessionId).catch(() => {
5311
+ });
5201
5312
  const duration = Date.now() - startTime;
5202
5313
  console.log(
5203
5314
  `[memory] extractMemories finished in ${duration}ms \u2014 ${toolCount} tools used, ${result.length} chars`
@@ -5212,7 +5323,7 @@ ${conversationText}`
5212
5323
  }
5213
5324
  };
5214
5325
  }
5215
- var lastIndexMap, lastExtractTimeMap;
5326
+ var lastIndexMap, lastExtractTimeMap, STATE_FILE;
5216
5327
  var init_extractMemories = __esm({
5217
5328
  "src/memory/memdir/extractMemories.ts"() {
5218
5329
  "use strict";
@@ -5221,8 +5332,10 @@ var init_extractMemories = __esm({
5221
5332
  init_paths();
5222
5333
  init_memoryScan();
5223
5334
  init_extractPrompts();
5335
+ init_ingest();
5224
5336
  lastIndexMap = /* @__PURE__ */ new Map();
5225
5337
  lastExtractTimeMap = /* @__PURE__ */ new Map();
5338
+ STATE_FILE = ".extract-state.json";
5226
5339
  }
5227
5340
  });
5228
5341
 
@@ -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(args2, searchPath, signal) {
7238
7351
  return new Promise((resolve10) => {
7239
7352
  const fullArgs = [...args2, 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 (args2) => {
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 (args2.task_id) {
11244
- const file = path44.join(resultsDir, `${args2.task_id}.json`);
11357
+ const file = path45.join(resultsDir, `${args2.task_id}.json`);
11245
11358
  if (!fs42.existsSync(file)) {
11246
11359
  return { content: `\u4EFB\u52A1 ${args2.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",
@@ -11640,7 +11755,7 @@ __export(license_exports, {
11640
11755
  });
11641
11756
  import * as crypto6 from "node:crypto";
11642
11757
  import * as fs39 from "node:fs";
11643
- import * as path40 from "node:path";
11758
+ import * as path41 from "node:path";
11644
11759
  function loadLicense(stateDir, devMode) {
11645
11760
  if (_licenseChecked) return _cachedLicense;
11646
11761
  _licenseChecked = true;
@@ -11653,7 +11768,7 @@ function loadLicense(stateDir, devMode) {
11653
11768
  _cachedLicense = allActive;
11654
11769
  return allActive;
11655
11770
  }
11656
- const licensePath = path40.join(stateDir, "license.json");
11771
+ const licensePath = path41.join(stateDir, "license.json");
11657
11772
  if (!fs39.existsSync(licensePath)) {
11658
11773
  console.log("[license] No license.json found, running basic engine only");
11659
11774
  return null;
@@ -11709,7 +11824,7 @@ function isFeatureLicensed(featureId) {
11709
11824
  return f2?.active === true;
11710
11825
  }
11711
11826
  function getLicenseStatus(stateDir) {
11712
- const licensePath = path40.join(stateDir, "license.json");
11827
+ const licensePath = path41.join(stateDir, "license.json");
11713
11828
  if (!fs39.existsSync(licensePath)) {
11714
11829
  return { licensed: false, features: {} };
11715
11830
  }
@@ -11774,7 +11889,7 @@ __export(manager_exports, {
11774
11889
  McpManager: () => McpManager
11775
11890
  });
11776
11891
  import * as fs40 from "node:fs";
11777
- import * as path41 from "node:path";
11892
+ import * as path42 from "node:path";
11778
11893
  import { Client as Client3 } from "@modelcontextprotocol/sdk/client/index.js";
11779
11894
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
11780
11895
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
@@ -11807,9 +11922,9 @@ function convertInputSchema(inputSchema) {
11807
11922
  }
11808
11923
  function persistBinary(base64Data, mimeType, persistId) {
11809
11924
  const ext = mimeType?.split("/")[1] || "bin";
11810
- const dir = path41.join(process.env.ENGINE_STATE_DIR || ".engine", "mcp-blobs");
11925
+ const dir = path42.join(process.env.ENGINE_STATE_DIR || ".engine", "mcp-blobs");
11811
11926
  fs40.mkdirSync(dir, { recursive: true });
11812
- const filepath = path41.join(dir, `${persistId}.${ext}`);
11927
+ const filepath = path42.join(dir, `${persistId}.${ext}`);
11813
11928
  try {
11814
11929
  const buf = Buffer.from(base64Data, "base64");
11815
11930
  fs40.writeFileSync(filepath, buf);
@@ -12146,7 +12261,7 @@ __export(resources_exports, {
12146
12261
  registerMcpResourceTools: () => registerMcpResourceTools,
12147
12262
  unregisterMcpResourceTools: () => unregisterMcpResourceTools
12148
12263
  });
12149
- import * as path42 from "node:path";
12264
+ import * as path43 from "node:path";
12150
12265
  function registerMcpResourceTools(manager) {
12151
12266
  mcpManagerRef = manager;
12152
12267
  registry.register(listResourcesTool);
@@ -12164,7 +12279,7 @@ var init_resources = __esm({
12164
12279
  "use strict";
12165
12280
  init_registry();
12166
12281
  MAX_RESULT_CHARS2 = 1e5;
12167
- MEDIA_DIR = process.env.ENGINE_MEDIA_DIR || path42.join(process.env.ENGINE_STATE_DIR || ".engine", "media", "inbound");
12282
+ MEDIA_DIR = process.env.ENGINE_MEDIA_DIR || path43.join(process.env.ENGINE_STATE_DIR || ".engine", "media", "inbound");
12168
12283
  MCP_LIST_RESOURCES_TOOL = "mcp__list_resources";
12169
12284
  MCP_READ_RESOURCE_TOOL = "mcp__read_resource";
12170
12285
  mcpManagerRef = null;
@@ -12249,88 +12364,6 @@ ${lines.join("\n\n")}`;
12249
12364
  }
12250
12365
  });
12251
12366
 
12252
- // src/memory/everos-sync.ts
12253
- var everos_sync_exports = {};
12254
- __export(everos_sync_exports, {
12255
- createEverosSync: () => createEverosSync
12256
- });
12257
- function parseMeta(text) {
12258
- const m2 = text.match(/^\[meta:\s*(.+?)\s*\((.+?)\)\s*@(\S+)\s*[^\]]*\]/);
12259
- if (!m2) return null;
12260
- return { senderName: m2[1].trim(), senderId: m2[2].trim(), platform: m2[3].trim() };
12261
- }
12262
- function createEverosSync(cfg) {
12263
- const { enabled, url, appId, userId, agentName } = cfg;
12264
- async function push(event) {
12265
- if (!enabled) return;
12266
- if (!event.text.trim()) return;
12267
- return;
12268
- const meta = event.role === "user" ? parseMeta(event.text) : null;
12269
- const senderId = appId;
12270
- const senderName = meta?.senderName ?? (event.role === "assistant" ? agentName : void 0) ?? event.senderName ?? event.role;
12271
- console.log(`[everos-sync] role=${event.role} sender_id=${senderId} sender_name=${senderName} metaParsed=${!!meta} textLen=${event.text.length}`);
12272
- try {
12273
- const resp = await fetch(`${url}/api/v1/memory/add`, {
12274
- method: "POST",
12275
- headers: { "Content-Type": "application/json" },
12276
- body: JSON.stringify({
12277
- session_id: event.sessionId,
12278
- app_id: appId,
12279
- project_id: "default",
12280
- messages: [{
12281
- sender_id: senderId,
12282
- sender_name: senderName,
12283
- role: event.role,
12284
- timestamp: event.timestamp,
12285
- content: event.text
12286
- }]
12287
- }),
12288
- signal: AbortSignal.timeout(5e3)
12289
- });
12290
- if (!resp.ok) {
12291
- console.warn(`[everos-sync] memory/add ${resp.status}`);
12292
- }
12293
- } catch {
12294
- }
12295
- }
12296
- async function pushBatch(events) {
12297
- if (!enabled || events.length === 0) return;
12298
- try {
12299
- const resp = await fetch(`${url}/api/v1/memory/add`, {
12300
- method: "POST",
12301
- headers: { "Content-Type": "application/json" },
12302
- body: JSON.stringify({
12303
- session_id: events[0].sessionId,
12304
- app_id: appId,
12305
- project_id: "default",
12306
- messages: events.map((e) => {
12307
- const meta = e.role === "user" ? parseMeta(e.text) : null;
12308
- const name = meta?.senderName ?? (e.role === "assistant" ? agentName : void 0) ?? e.senderName ?? e.role;
12309
- return {
12310
- sender_id: appId,
12311
- sender_name: name,
12312
- role: e.role,
12313
- timestamp: e.timestamp,
12314
- content: e.text
12315
- };
12316
- })
12317
- }),
12318
- signal: AbortSignal.timeout(3e4)
12319
- });
12320
- if (!resp.ok) {
12321
- console.warn(`[everos-sync] batch add ${resp.status}`);
12322
- }
12323
- } catch {
12324
- }
12325
- }
12326
- return { push, pushBatch };
12327
- }
12328
- var init_everos_sync = __esm({
12329
- "src/memory/everos-sync.ts"() {
12330
- "use strict";
12331
- }
12332
- });
12333
-
12334
12367
  // src/cron/cron-plugin.ts
12335
12368
  var cron_plugin_exports = {};
12336
12369
  __export(cron_plugin_exports, {
@@ -12406,8 +12439,8 @@ var reply_blocklist_exports = {};
12406
12439
  __export(reply_blocklist_exports, {
12407
12440
  isUserBlocked: () => isUserBlocked
12408
12441
  });
12409
- import { readFileSync as readFileSync26, writeFileSync as writeFileSync15, existsSync as existsSync24 } from "node:fs";
12410
- import { join as join36 } from "node:path";
12442
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync16, existsSync as existsSync24 } from "node:fs";
12443
+ import { join as join38 } from "node:path";
12411
12444
  function ensureLoaded(workspace, configIds) {
12412
12445
  if (loaded) return;
12413
12446
  if (configIds?.length) {
@@ -12415,10 +12448,10 @@ function ensureLoaded(workspace, configIds) {
12415
12448
  if (!state.blockedUserIds.includes(id)) state.blockedUserIds.push(id);
12416
12449
  }
12417
12450
  }
12418
- const path44 = join36(workspace, ".reply-blocklist.json");
12451
+ const path45 = join38(workspace, ".reply-blocklist.json");
12419
12452
  try {
12420
- if (existsSync24(path44)) {
12421
- const raw = readFileSync26(path44, "utf-8");
12453
+ if (existsSync24(path45)) {
12454
+ const raw = readFileSync26(path45, "utf-8");
12422
12455
  const parsed = JSON.parse(raw);
12423
12456
  if (parsed.blockedUserIds) {
12424
12457
  for (const id of parsed.blockedUserIds) {
@@ -12434,9 +12467,9 @@ function ensureLoaded(workspace, configIds) {
12434
12467
  loaded = true;
12435
12468
  }
12436
12469
  function save(workspace) {
12437
- const path44 = join36(workspace, ".reply-blocklist.json");
12470
+ const path45 = join38(workspace, ".reply-blocklist.json");
12438
12471
  try {
12439
- writeFileSync15(path44, JSON.stringify(state, null, 2), "utf-8");
12472
+ writeFileSync16(path45, JSON.stringify(state, null, 2), "utf-8");
12440
12473
  } catch (err) {
12441
12474
  console.warn(`[reply-blocklist] Failed to save: ${err.message}`);
12442
12475
  }
@@ -13036,7 +13069,7 @@ var init_cognifold_intent_watcher = __esm({
13036
13069
  init_loader();
13037
13070
 
13038
13071
  // src/engine-startup.ts
13039
- import * as path43 from "node:path";
13072
+ import * as path44 from "node:path";
13040
13073
  import * as fs41 from "node:fs";
13041
13074
  import { fileURLToPath } from "node:url";
13042
13075
 
@@ -14380,11 +14413,11 @@ var DiscordAdapter = class _DiscordAdapter {
14380
14413
  /** 发送媒体附件(图片/文件/音频)— discord.js channel.send({ files }) */
14381
14414
  async sendFile(target, message, attachment) {
14382
14415
  const fs42 = await import("node:fs");
14383
- const path44 = await import("node:path");
14416
+ const path45 = await import("node:path");
14384
14417
  if (!fs42.existsSync(attachment.path)) {
14385
14418
  throw new Error(`File not found: ${attachment.path}`);
14386
14419
  }
14387
- const filename = attachment.filename || path44.basename(attachment.path);
14420
+ const filename = attachment.filename || path45.basename(attachment.path);
14388
14421
  const fileBuffer = fs42.readFileSync(attachment.path);
14389
14422
  const filePayload = {
14390
14423
  attachment: fileBuffer,
@@ -14826,11 +14859,11 @@ var FeishuAdapter = class _FeishuAdapter {
14826
14859
  /** 发送媒体附件(图片/文件) */
14827
14860
  async sendFile(target, message, attachment) {
14828
14861
  const fs42 = await import("node:fs");
14829
- const path44 = await import("node:path");
14862
+ const path45 = await import("node:path");
14830
14863
  if (!fs42.existsSync(attachment.path)) {
14831
14864
  throw new Error(`File not found: ${attachment.path}`);
14832
14865
  }
14833
- const filename = attachment.filename || path44.basename(attachment.path);
14866
+ const filename = attachment.filename || path45.basename(attachment.path);
14834
14867
  const fileBuffer = fs42.readFileSync(attachment.path);
14835
14868
  const receiveIdType = target.startsWith("ou_") ? "open_id" : "chat_id";
14836
14869
  const mimeType = attachment.mimeType || "application/octet-stream";
@@ -15662,7 +15695,7 @@ var WechatAdapter = class {
15662
15695
  this.config = config2;
15663
15696
  this.baseUrl = config2.baseUrl?.replace(/\/$/, "") || ILINK_BASE_URL;
15664
15697
  this.cdnBaseUrl = config2.cdnBaseUrl?.replace(/\/$/, "") || WEIXIN_CDN_BASE_URL;
15665
- this.stateDir = config2.stateDir || path4.join(os.homedir?.() || "/tmp", ".openclaw");
15698
+ this.stateDir = config2.stateDir || path4.join(os.homedir?.() || "/tmp", ".engine7");
15666
15699
  if (!fs5.existsSync(this.stateDir)) fs5.mkdirSync(this.stateDir, { recursive: true });
15667
15700
  }
15668
15701
  // --- ChannelAdapter interface ---
@@ -18911,8 +18944,8 @@ ${ep.episode || ep.summary}`,
18911
18944
  // src/handle-query.ts
18912
18945
  init_paths();
18913
18946
  import { readFileSync as readFileSync15, existsSync as existsSync12 } from "node:fs";
18914
- import { join as join20 } from "node:path";
18915
- import { resolve as resolve6 } from "node:path";
18947
+ import { join as join20, resolve as resolve6 } from "node:path";
18948
+ import * as path13 from "node:path";
18916
18949
  var contactMap = null;
18917
18950
  var externalChanWhitelist = null;
18918
18951
  function loadContactMap(workspace) {
@@ -18980,18 +19013,18 @@ function truncate(s2, maxLen) {
18980
19013
  }
18981
19014
  var externalChanRulesCache = null;
18982
19015
  function loadExternalChanRules(workspace) {
18983
- const path44 = join20(workspace, "prompts", "external-chan-rules.md");
18984
- if (externalChanRulesCache && externalChanRulesCache.path === path44) return externalChanRulesCache;
19016
+ const path45 = join20(workspace, "prompts", "external-chan-rules.md");
19017
+ if (externalChanRulesCache && externalChanRulesCache.path === path45) return externalChanRulesCache;
18985
19018
  let content = "";
18986
- if (existsSync12(path44)) {
19019
+ if (existsSync12(path45)) {
18987
19020
  try {
18988
- content = readFileSync15(path44, "utf-8").trim();
19021
+ content = readFileSync15(path45, "utf-8").trim();
18989
19022
  } catch (e) {
18990
19023
  console.warn(`[external-chan-rules] Failed to load: ${e}`);
18991
19024
  }
18992
19025
  }
18993
- externalChanRulesCache = { path: path44, content };
18994
- console.log(`[external-chan-rules] Loaded ${content.length} chars from ${path44}`);
19026
+ externalChanRulesCache = { path: path45, content };
19027
+ console.log(`[external-chan-rules] Loaded ${content.length} chars from ${path45}`);
18995
19028
  return externalChanRulesCache;
18996
19029
  }
18997
19030
  function getExternalChanRulesBlock(inboundMeta, workspace) {
@@ -19259,9 +19292,9 @@ ${text}` : text });
19259
19292
  }
19260
19293
  console.log(`[${sessionId}] >>> query start (${messages.length} msgs in history)`);
19261
19294
  try {
19262
- const { writeFileSync: writeFileSync17 } = await import("node:fs");
19263
- const { join: join39 } = await import("node:path");
19264
- const contextPath = join39(workspace, ".context-debug.txt");
19295
+ const { writeFileSync: writeFileSync18 } = await import("node:fs");
19296
+ const { join: join41 } = await import("node:path");
19297
+ const contextPath = join41(workspace, ".context-debug.txt");
19265
19298
  const lines = [
19266
19299
  "=== Context Debug ===",
19267
19300
  `Time: ${(/* @__PURE__ */ new Date()).toISOString()}`,
@@ -19314,7 +19347,7 @@ ${text}` : text });
19314
19347
  }
19315
19348
  }
19316
19349
  lines.push("", "=== End ===");
19317
- writeFileSync17(contextPath, lines.join("\n") + "\n\n", { encoding: "utf-8", flag: "a" });
19350
+ writeFileSync18(contextPath, lines.join("\n") + "\n\n", { encoding: "utf-8", flag: "a" });
19318
19351
  console.log(`[${sessionId}] Context snapshot \u2192 ${contextPath}`);
19319
19352
  } catch (err) {
19320
19353
  console.warn(`[${sessionId}] Context snapshot failed: ${err.message}`);
@@ -19646,7 +19679,7 @@ stack: ${err.stack ?? "(none)"}`);
19646
19679
  }
19647
19680
  } catch (err) {
19648
19681
  try {
19649
- (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}
19682
+ (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}
19650
19683
  stack: ${err.stack ?? "(none)"}
19651
19684
  `);
19652
19685
  } catch {
@@ -20344,16 +20377,16 @@ var MessageDispatcher = class {
20344
20377
  };
20345
20378
 
20346
20379
  // src/cli-startup.ts
20347
- import * as path13 from "node:path";
20380
+ import * as path14 from "node:path";
20348
20381
  import * as fs13 from "node:fs";
20349
20382
  import * as readline2 from "node:readline";
20350
20383
  function getDailyLogPath(stateDir) {
20351
20384
  const dateStr = (/* @__PURE__ */ new Date()).toLocaleDateString("sv-SE", { timeZone: "Asia/Shanghai" });
20352
- return path13.join(stateDir, "logs", `engine-${dateStr}.log`);
20385
+ return path14.join(stateDir, "logs", `engine-${dateStr}.log`);
20353
20386
  }
20354
20387
  function setupFileLogging(stateDir) {
20355
20388
  const LOG_PATH = getDailyLogPath(stateDir);
20356
- fs13.mkdirSync(path13.join(stateDir, "logs"), { recursive: true });
20389
+ fs13.mkdirSync(path14.join(stateDir, "logs"), { recursive: true });
20357
20390
  const logStream = fs13.createWriteStream(LOG_PATH, { flags: "a" });
20358
20391
  logStream.on("error", (err) => console.error(`[log] Write error: ${err.message}`));
20359
20392
  function ts() {
@@ -20445,7 +20478,7 @@ function startCliLoop(deps, cliConfig, channelManager, dispatcher) {
20445
20478
 
20446
20479
  // src/session/session-history.ts
20447
20480
  import fs14 from "node:fs";
20448
- import path14 from "node:path";
20481
+ import path15 from "node:path";
20449
20482
  var BEIJING_OFFSET_MS = 8 * 36e5;
20450
20483
  var INJECTED_CONTENT_PATTERNS = [
20451
20484
  /【定时心跳】/,
@@ -20497,10 +20530,10 @@ function scopeMainJsonlPaths(sessions) {
20497
20530
  let latestArchive = null;
20498
20531
  if (current) {
20499
20532
  try {
20500
- const dir = path14.dirname(current);
20501
- const base = path14.basename(current);
20533
+ const dir = path15.dirname(current);
20534
+ const base = path15.basename(current);
20502
20535
  const archives = fs14.readdirSync(dir).filter((f2) => f2.startsWith(base + ".archived.")).sort();
20503
- if (archives.length > 0) latestArchive = path14.join(dir, archives[archives.length - 1]);
20536
+ if (archives.length > 0) latestArchive = path15.join(dir, archives[archives.length - 1]);
20504
20537
  } catch {
20505
20538
  }
20506
20539
  }
@@ -20747,7 +20780,7 @@ ${basePrompt}`;
20747
20780
 
20748
20781
  // src/nudge/plugin.ts
20749
20782
  import fs17 from "node:fs";
20750
- import path17 from "node:path";
20783
+ import path18 from "node:path";
20751
20784
 
20752
20785
  // src/nudge/judge.ts
20753
20786
  function shouldNudge(task, taskState, cfg) {
@@ -20916,10 +20949,10 @@ function formatDuration2(ms) {
20916
20949
 
20917
20950
  // src/nudge/session-state-reader.ts
20918
20951
  import fs15 from "node:fs";
20919
- import path15 from "node:path";
20952
+ import path16 from "node:path";
20920
20953
  function parseSessionStateFull(workspace, sessionStateFile) {
20921
20954
  const stateFile = sessionStateFile || "SESSION-STATE.md";
20922
- const statePath = path15.isAbsolute(stateFile) ? stateFile : path15.join(workspace, stateFile);
20955
+ const statePath = path16.isAbsolute(stateFile) ? stateFile : path16.join(workspace, stateFile);
20923
20956
  let content;
20924
20957
  try {
20925
20958
  content = fs15.readFileSync(statePath, "utf-8");
@@ -20974,13 +21007,13 @@ function taskIdFromTitle(title) {
20974
21007
 
20975
21008
  // src/calendar/db.ts
20976
21009
  import { DatabaseSync } from "node:sqlite";
20977
- import * as path16 from "node:path";
21010
+ import * as path17 from "node:path";
20978
21011
  import * as fs16 from "node:fs";
20979
21012
  var TZ_OFFSET_MS = 8 * 60 * 60 * 1e3;
20980
21013
  function openDb(workspace) {
20981
- const dir = path16.join(workspace, ".calendar");
21014
+ const dir = path17.join(workspace, ".calendar");
20982
21015
  fs16.mkdirSync(dir, { recursive: true });
20983
- const dbPath = path16.join(dir, "calendar.db");
21016
+ const dbPath = path17.join(dir, "calendar.db");
20984
21017
  const db = new DatabaseSync(dbPath);
20985
21018
  db.exec("PRAGMA journal_mode=WAL");
20986
21019
  db.exec(`CREATE TABLE IF NOT EXISTS events (
@@ -21069,7 +21102,7 @@ var NudgePlugin = class {
21069
21102
  provider;
21070
21103
  model;
21071
21104
  loadPrompt(workspace, promptFile) {
21072
- const promptPath = promptFile ? path17.isAbsolute(promptFile) ? promptFile : path17.join(workspace, promptFile) : path17.join(workspace, "prompts", "nudge-prompt.md");
21105
+ const promptPath = promptFile ? path18.isAbsolute(promptFile) ? promptFile : path18.join(workspace, promptFile) : path18.join(workspace, "prompts", "nudge-prompt.md");
21073
21106
  try {
21074
21107
  const content = fs17.readFileSync(promptPath, "utf-8").trim();
21075
21108
  if (content) {
@@ -21218,8 +21251,8 @@ var NudgePlugin = class {
21218
21251
  if (!isWaiting) {
21219
21252
  return { outcome: { outcome: "success" } };
21220
21253
  }
21221
- const nudgeDir = path17.join(this.workspace, ".nudge");
21222
- const notifPath = path17.join(nudgeDir, "stop-hook-notifications.json");
21254
+ const nudgeDir = path18.join(this.workspace, ".nudge");
21255
+ const notifPath = path18.join(nudgeDir, "stop-hook-notifications.json");
21223
21256
  try {
21224
21257
  if (!fs17.existsSync(nudgeDir)) fs17.mkdirSync(nudgeDir, { recursive: true });
21225
21258
  let notifs = [];
@@ -21288,7 +21321,7 @@ var NudgePlugin = class {
21288
21321
  * 已 notified 的不会再触发,等 agent 回复 "<id> 过期了" 由 cleanup 删。
21289
21322
  */
21290
21323
  collectDueStopHookNotifications() {
21291
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21324
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21292
21325
  try {
21293
21326
  if (!fs17.existsSync(notifPath)) return null;
21294
21327
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
@@ -21327,7 +21360,7 @@ ${items}
21327
21360
  }
21328
21361
  /** 按 id 删除条目(stop-hook 实时清理用;正常删除路径,agent 回复即删) */
21329
21362
  removeNotificationsById(ids) {
21330
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21363
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21331
21364
  try {
21332
21365
  if (!fs17.existsSync(notifPath)) return;
21333
21366
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
@@ -21347,7 +21380,7 @@ ${items}
21347
21380
  }
21348
21381
  /** 投递成功后标记 notified(防重复触发);不删除——删除只走 agent 回复 "<id> 过期了" */
21349
21382
  markNotified(ids) {
21350
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21383
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21351
21384
  try {
21352
21385
  if (!fs17.existsSync(notifPath)) return;
21353
21386
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
@@ -21370,7 +21403,7 @@ ${items}
21370
21403
  */
21371
21404
  cleanupStaleNotificationsFromMessages(sessions) {
21372
21405
  try {
21373
- const notifPath = path17.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21406
+ const notifPath = path18.join(this.workspace, ".nudge", "stop-hook-notifications.json");
21374
21407
  if (!fs17.existsSync(notifPath)) return;
21375
21408
  const notifs = JSON.parse(fs17.readFileSync(notifPath, "utf-8"));
21376
21409
  if (notifs.length === 0) return;
@@ -21671,7 +21704,7 @@ ${items}
21671
21704
  // === state 持久化 ===
21672
21705
  loadState() {
21673
21706
  const stateFile = this.cfg.stateFile || "nudge-state.json";
21674
- const statePath = path17.isAbsolute(stateFile) ? stateFile : path17.join(this.workspace, stateFile);
21707
+ const statePath = path18.isAbsolute(stateFile) ? stateFile : path18.join(this.workspace, stateFile);
21675
21708
  try {
21676
21709
  const content = fs17.readFileSync(statePath, "utf-8");
21677
21710
  return JSON.parse(content);
@@ -21681,7 +21714,7 @@ ${items}
21681
21714
  }
21682
21715
  saveState(state2) {
21683
21716
  const stateFile = this.cfg.stateFile || "nudge-state.json";
21684
- const statePath = path17.isAbsolute(stateFile) ? stateFile : path17.join(this.workspace, stateFile);
21717
+ const statePath = path18.isAbsolute(stateFile) ? stateFile : path18.join(this.workspace, stateFile);
21685
21718
  fs17.writeFileSync(statePath, JSON.stringify(state2, null, 2), "utf-8");
21686
21719
  }
21687
21720
  newTaskState() {
@@ -21861,7 +21894,7 @@ ${items}
21861
21894
 
21862
21895
  // src/inner-voice/plugin.ts
21863
21896
  import fs21 from "node:fs";
21864
- import path21 from "node:path";
21897
+ import path22 from "node:path";
21865
21898
 
21866
21899
  // src/inner-voice/activity.ts
21867
21900
  function checkActivity(sessions, activeThresholdMs) {
@@ -21901,7 +21934,7 @@ function calcHintProb(min) {
21901
21934
 
21902
21935
  // src/inner-voice/emotional-state.ts
21903
21936
  import fs18 from "node:fs";
21904
- import path18 from "node:path";
21937
+ import path19 from "node:path";
21905
21938
  var NEUTRAL = 0.5;
21906
21939
  var DECAY_RATE = 0.17;
21907
21940
  var MAX_EVENTS = 20;
@@ -21952,7 +21985,7 @@ function initialState() {
21952
21985
  return { version: 1, mood: NEUTRAL, trend: "stable", updatedAt: nowIsoBj(), events: [] };
21953
21986
  }
21954
21987
  async function updateEmotionalState(workspace, sessions) {
21955
- const stateFile = path18.join(workspace, "inner-voice", "emotional-state.json");
21988
+ const stateFile = path19.join(workspace, "inner-voice", "emotional-state.json");
21956
21989
  const messages = readRecentMessages(sessions, RECENT_N);
21957
21990
  if (messages.length === 0) {
21958
21991
  console.log("[emotional-state] no messages");
@@ -21985,7 +22018,7 @@ async function updateEmotionalState(workspace, sessions) {
21985
22018
  function readRecentMessages(sessions, n) {
21986
22019
  const mainId = sessions.getSessionId("scope:main");
21987
22020
  if (!mainId) return [];
21988
- const file = path18.join(sessions.sessionsDir, `${mainId}.jsonl`);
22021
+ const file = path19.join(sessions.sessionsDir, `${mainId}.jsonl`);
21989
22022
  if (!fs18.existsSync(file)) return [];
21990
22023
  const lines = readLastNLines(file, n * 4 + 20);
21991
22024
  const entries = [];
@@ -22103,7 +22136,7 @@ function refreshHoursAgo(events) {
22103
22136
  }
22104
22137
  function appendMoodLog(workspace, state2, summary) {
22105
22138
  try {
22106
- const logPath = path18.join(workspace, "mood-history.log");
22139
+ const logPath = path19.join(workspace, "mood-history.log");
22107
22140
  const ts = formatBj(/* @__PURE__ */ new Date(), false);
22108
22141
  fs18.appendFileSync(logPath, `${ts} mood=${state2.mood.toFixed(2)} trend=${state2.trend} ${summary}
22109
22142
  `);
@@ -22120,7 +22153,7 @@ function loadJson(file) {
22120
22153
  }
22121
22154
  function saveJson(file, data) {
22122
22155
  try {
22123
- fs18.mkdirSync(path18.dirname(file), { recursive: true });
22156
+ fs18.mkdirSync(path19.dirname(file), { recursive: true });
22124
22157
  fs18.writeFileSync(file, JSON.stringify(data, null, 2));
22125
22158
  } catch (err) {
22126
22159
  console.warn(`[emotional-state] save failed: ${err.message}`);
@@ -22166,7 +22199,7 @@ function formatBj(d, withSec) {
22166
22199
 
22167
22200
  // src/inner-voice/topics-scorer.ts
22168
22201
  import fs19 from "node:fs";
22169
- import path19 from "node:path";
22202
+ import path20 from "node:path";
22170
22203
  var HALF_LIFE_DAYS = 3;
22171
22204
  var PROJECT_HALF_LIFE_DAYS = 1.5;
22172
22205
  var COOLDOWN_HOURS = 6;
@@ -22174,8 +22207,8 @@ var MAX_CHARS = 8e3;
22174
22207
  var SKIP_NAMES = /* @__PURE__ */ new Set(["MEMORY.md", "archive"]);
22175
22208
  var SKIP_DIRS = /* @__PURE__ */ new Set(["archive"]);
22176
22209
  function pickTopic(workspace, typeFilter, opts) {
22177
- const topicsDir = path19.join(workspace, "topics");
22178
- const usageFile = path19.join(workspace, "inner-voice", "topics-usage.json");
22210
+ const topicsDir = path20.join(workspace, "topics");
22211
+ const usageFile = path20.join(workspace, "inner-voice", "topics-usage.json");
22179
22212
  const files = scanTopics(topicsDir, typeFilter);
22180
22213
  if (files.length === 0) {
22181
22214
  console.log(`[topics-scorer] no topics found (type=${typeFilter})`);
@@ -22207,7 +22240,7 @@ function pickTopic(workspace, typeFilter, opts) {
22207
22240
  recency: Math.round(recency * 1e3) / 1e3,
22208
22241
  freq: Math.round(freq * 1e3) / 1e3,
22209
22242
  type: type2,
22210
- name: meta.name || path19.basename(relpath),
22243
+ name: meta.name || path20.basename(relpath),
22211
22244
  description: meta.description || "",
22212
22245
  mtime
22213
22246
  });
@@ -22265,14 +22298,14 @@ function scanTopics(topicsDir, typeFilter) {
22265
22298
  const out = [];
22266
22299
  const walk = (dir) => {
22267
22300
  for (const name of fs19.readdirSync(dir)) {
22268
- const full = path19.join(dir, name);
22301
+ const full = path20.join(dir, name);
22269
22302
  const stat4 = fs19.statSync(full);
22270
22303
  if (stat4.isDirectory()) {
22271
22304
  if (SKIP_DIRS.has(name)) continue;
22272
22305
  walk(full);
22273
22306
  } else {
22274
22307
  if (!name.endsWith(".md") || SKIP_NAMES.has(name)) continue;
22275
- const relpath = path19.relative(topicsDir, full).replace(/\\/g, "/");
22308
+ const relpath = path20.relative(topicsDir, full).replace(/\\/g, "/");
22276
22309
  if (typeFilter && !relpath.startsWith(typeFilter + "/") && !relpath.startsWith(typeFilter + "_")) continue;
22277
22310
  out.push({ relpath, fullpath: full });
22278
22311
  }
@@ -22317,7 +22350,7 @@ function loadJson2(file) {
22317
22350
  }
22318
22351
  function saveJson2(file, data) {
22319
22352
  try {
22320
- fs19.mkdirSync(path19.dirname(file), { recursive: true });
22353
+ fs19.mkdirSync(path20.dirname(file), { recursive: true });
22321
22354
  fs19.writeFileSync(file, JSON.stringify(data, null, 2));
22322
22355
  } catch (err) {
22323
22356
  console.warn(`[topics-scorer] usage save failed: ${err.message}`);
@@ -22326,21 +22359,21 @@ function saveJson2(file, data) {
22326
22359
 
22327
22360
  // src/inner-voice/memory-reader.ts
22328
22361
  import fs20 from "node:fs";
22329
- import path20 from "node:path";
22362
+ import path21 from "node:path";
22330
22363
  var US_HALF_LIFE_DAYS = 10;
22331
22364
  var US_MAX_LINES = 60;
22332
22365
  function readRecentMemory(workspace) {
22333
- const dir = path20.join(workspace, "memory");
22366
+ const dir = path21.join(workspace, "memory");
22334
22367
  const now = new Date(Date.now() + 8 * 36e5);
22335
22368
  const today = formatYmd(now);
22336
22369
  const yesterday = formatYmd(new Date(now.getTime() - 864e5));
22337
22370
  return {
22338
- today: readIfExists(path20.join(dir, `${today}.md`)),
22339
- yesterday: readIfExists(path20.join(dir, `${yesterday}.md`))
22371
+ today: readIfExists(path21.join(dir, `${today}.md`)),
22372
+ yesterday: readIfExists(path21.join(dir, `${yesterday}.md`))
22340
22373
  };
22341
22374
  }
22342
22375
  function sampleUs(workspace) {
22343
- const usFile = path20.join(workspace, "memory", "us.md");
22376
+ const usFile = path21.join(workspace, "memory", "us.md");
22344
22377
  let content;
22345
22378
  try {
22346
22379
  content = fs20.readFileSync(usFile, "utf-8");
@@ -22680,7 +22713,7 @@ var InnerVoicePlugin = class {
22680
22713
  }
22681
22714
  /** 读 workspace/prompts/my-inner-voice.md,不存在用 DEFAULT_PROMPT */
22682
22715
  loadPrompt(workspace) {
22683
- const promptPath = path21.join(workspace, "prompts", "my-inner-voice.md");
22716
+ const promptPath = path22.join(workspace, "prompts", "my-inner-voice.md");
22684
22717
  try {
22685
22718
  const content = fs21.readFileSync(promptPath, "utf-8").trim();
22686
22719
  if (content) {
@@ -22754,7 +22787,7 @@ var InnerVoicePlugin = class {
22754
22787
  console.warn(`[inner-voice] emotional-state failed: ${err.message}`);
22755
22788
  }
22756
22789
  try {
22757
- const content = fs21.readFileSync(path21.join(this.workspace, "SESSION-STATE.md"), "utf-8");
22790
+ const content = fs21.readFileSync(path22.join(this.workspace, "SESSION-STATE.md"), "utf-8");
22758
22791
  lines.push("\n--- SESSION-STATE\uFF08\u5C3E\u90E8\uFF09 ---");
22759
22792
  lines.push(content.slice(-2e3));
22760
22793
  } catch {
@@ -22865,7 +22898,7 @@ var InnerVoicePlugin = class {
22865
22898
  if (Math.random() >= activity.hintProb) {
22866
22899
  return { text: thought, hintTriggered: false, hintText: "" };
22867
22900
  }
22868
- const poolPath = path21.join(this.workspace, "inner-voice", "hints_pool.txt");
22901
+ const poolPath = path22.join(this.workspace, "inner-voice", "hints_pool.txt");
22869
22902
  let hint = "\u60F3\u4ED6\u5C31\u53D1\u6D88\u606F\u5427";
22870
22903
  try {
22871
22904
  const pool = fs21.readFileSync(poolPath, "utf-8").split("\n").map((s2) => s2.trim()).filter(Boolean);
@@ -22893,7 +22926,7 @@ var InnerVoicePlugin = class {
22893
22926
  try {
22894
22927
  const writer = sessions.getWriter(mainSessionId);
22895
22928
  const history = sessions.getHistory(mainSessionId);
22896
- const fullPath = path21.resolve(this.workspace, emoTopic.file);
22929
+ const fullPath = path22.resolve(this.workspace, emoTopic.file);
22897
22930
  const memories = [{
22898
22931
  path: fullPath,
22899
22932
  content: emoTopic.content,
@@ -22921,9 +22954,9 @@ var InnerVoicePlugin = class {
22921
22954
  /** 写 xiaoyi.log(格式对齐旧 memory_whisper.py,便于既有日志分析复用)。 */
22922
22955
  writeLog(status, delivered, activity, hintTriggered, hintText) {
22923
22956
  try {
22924
- const logDir = path21.join(this.workspace, "inner-voice");
22957
+ const logDir = path22.join(this.workspace, "inner-voice");
22925
22958
  fs21.mkdirSync(logDir, { recursive: true });
22926
- const logPath = path21.join(logDir, "xiaoyi.log");
22959
+ const logPath = path22.join(logDir, "xiaoyi.log");
22927
22960
  const ts = formatBeijingTs(/* @__PURE__ */ new Date());
22928
22961
  const hintStatus = hintTriggered ? `YES (${(hintText || "").trim()})` : "no";
22929
22962
  fs21.appendFileSync(
@@ -23462,7 +23495,7 @@ var PluginManager = class {
23462
23495
  // src/voice-chat/plugin.ts
23463
23496
  import { spawn as spawn4, exec } from "node:child_process";
23464
23497
  import net from "node:net";
23465
- import path22 from "node:path";
23498
+ import path23 from "node:path";
23466
23499
  import fs22 from "node:fs";
23467
23500
 
23468
23501
  // src/voice-chat/bridge.ts
@@ -23839,13 +23872,13 @@ var VoiceChatPlugin = class _VoiceChatPlugin {
23839
23872
  }
23840
23873
  getPythonDir() {
23841
23874
  const dir = import.meta.dirname;
23842
- const srcDir = path22.resolve(dir, "..", "src", "voice-chat", "python");
23843
- const localDir = path22.join(dir, "python");
23875
+ const srcDir = path23.resolve(dir, "..", "src", "voice-chat", "python");
23876
+ const localDir = path23.join(dir, "python");
23844
23877
  return fs22.existsSync(srcDir) ? srcDir : localDir;
23845
23878
  }
23846
23879
  startPython() {
23847
23880
  const pythonDir = this.getPythonDir();
23848
- const serverPy = path22.join(pythonDir, "server.py");
23881
+ const serverPy = path23.join(pythonDir, "server.py");
23849
23882
  const pythonBin = this.findPython();
23850
23883
  const args2 = [serverPy];
23851
23884
  if (this.config.pythonPort) args2.push("--port", String(this.config.pythonPort));
@@ -23930,7 +23963,7 @@ var VoiceChatPlugin = class _VoiceChatPlugin {
23930
23963
  init_BashTool();
23931
23964
  import { spawn as spawn5, exec as exec2 } from "node:child_process";
23932
23965
  import net2 from "node:net";
23933
- import path23 from "node:path";
23966
+ import path24 from "node:path";
23934
23967
  import fs23 from "node:fs";
23935
23968
 
23936
23969
  // src/memory/cognifold/config.ts
@@ -23969,11 +24002,11 @@ var CogniFoldClient = class {
23969
24002
  this.timeoutMs = timeoutMs;
23970
24003
  this.modelName = modelName;
23971
24004
  }
23972
- async req(path44, options = {}) {
24005
+ async req(path45, options = {}) {
23973
24006
  const ctrl = new AbortController();
23974
24007
  const timer = setTimeout(() => ctrl.abort(), this.timeoutMs);
23975
24008
  try {
23976
- const resp = await fetch(`${this.baseUrl}${path44}`, {
24009
+ const resp = await fetch(`${this.baseUrl}${path45}`, {
23977
24010
  ...options,
23978
24011
  signal: ctrl.signal,
23979
24012
  headers: {
@@ -24063,20 +24096,20 @@ var CogniFoldClient = class {
24063
24096
  });
24064
24097
  }
24065
24098
  /** 兼容老版命名 */
24066
- async recl(path44, options = {}) {
24067
- return this.req(path44, options);
24099
+ async recl(path45, options = {}) {
24100
+ return this.req(path45, options);
24068
24101
  }
24069
24102
  };
24070
24103
 
24071
24104
  // src/memory/cognifold/session-manager.ts
24072
24105
  import { readFile as readFile6, writeFile as writeFile5, mkdir as mkdir4 } from "node:fs/promises";
24073
- import { join as join23, dirname as dirname3 } from "node:path";
24106
+ import { join as join24, dirname as dirname3 } from "node:path";
24074
24107
  var CogniFoldSessionManager = class {
24075
24108
  constructor(workspacePath, config2, client) {
24076
24109
  this.workspacePath = workspacePath;
24077
24110
  this.config = config2;
24078
24111
  this.client = client;
24079
- this.sessionsDir = join23(workspacePath, ".cognifold", "sessions");
24112
+ this.sessionsDir = join24(workspacePath, ".cognifold", "sessions");
24080
24113
  }
24081
24114
  workspacePath;
24082
24115
  config;
@@ -24146,7 +24179,7 @@ var CogniFoldSessionManager = class {
24146
24179
  console.log(`[cognifold] Created new session for scope "${scope}": ${newSession.sessionId}`);
24147
24180
  }
24148
24181
  getFilePath(scope) {
24149
- return join23(this.sessionsDir, `${scope}.json`);
24182
+ return join24(this.sessionsDir, `${scope}.json`);
24150
24183
  }
24151
24184
  async writeFileSafe(filePath, data) {
24152
24185
  try {
@@ -24345,16 +24378,16 @@ var CogniFoldPlugin = class {
24345
24378
  const dir = import.meta.dirname;
24346
24379
  const candidates = [
24347
24380
  // 从 dist/ 往回找 src
24348
- path23.resolve(dir, "..", "src", "memory", "cognifold", "python"),
24349
- path23.resolve(dir, "..", "..", "src", "memory", "cognifold", "python"),
24350
- path23.resolve(dir, "..", "..", "..", "src", "memory", "cognifold", "python"),
24381
+ path24.resolve(dir, "..", "src", "memory", "cognifold", "python"),
24382
+ path24.resolve(dir, "..", "..", "src", "memory", "cognifold", "python"),
24383
+ path24.resolve(dir, "..", "..", "..", "src", "memory", "cognifold", "python"),
24351
24384
  // 从 src/memory/cognifold/ 找本地
24352
- path23.join(dir, "python"),
24385
+ path24.join(dir, "python"),
24353
24386
  // 从 dist/memory/cognifold/ 找本地
24354
- path23.resolve(dir, "python")
24387
+ path24.resolve(dir, "python")
24355
24388
  ];
24356
24389
  for (const candidate of candidates) {
24357
- if (fs23.existsSync(path23.join(candidate, "cognifold"))) {
24390
+ if (fs23.existsSync(path24.join(candidate, "cognifold"))) {
24358
24391
  return candidate;
24359
24392
  }
24360
24393
  }
@@ -24380,7 +24413,7 @@ var CogniFoldPlugin = class {
24380
24413
  const pythonBin = this.findPython();
24381
24414
  console.log(`[cognifold] Starting Python: ${pythonBin} ${args2.join(" ")}`);
24382
24415
  console.log(`[cognifold] Python dir: ${pythonDir}`);
24383
- if (!fs23.existsSync(path23.join(pythonDir, "cognifold"))) {
24416
+ if (!fs23.existsSync(path24.join(pythonDir, "cognifold"))) {
24384
24417
  console.error(`[cognifold] FATAL: Python module not found at ${pythonDir}/cognifold`);
24385
24418
  throw new Error(`cognifold: python module not found`);
24386
24419
  }
@@ -24391,7 +24424,7 @@ var CogniFoldPlugin = class {
24391
24424
  if (this.config.llm?.baseUrl) {
24392
24425
  childEnv["OPENAI_BASE_URL"] = this.config.llm.baseUrl;
24393
24426
  }
24394
- const envFile = path23.join(pythonDir, ".env");
24427
+ const envFile = path24.join(pythonDir, ".env");
24395
24428
  try {
24396
24429
  if (fs23.existsSync(envFile)) {
24397
24430
  const envContent = fs23.readFileSync(envFile, "utf-8");
@@ -24463,7 +24496,7 @@ var CogniFoldPlugin = class {
24463
24496
  init_BashTool();
24464
24497
  import { spawn as spawn6 } from "node:child_process";
24465
24498
  import net3 from "node:net";
24466
- import path24 from "node:path";
24499
+ import path25 from "node:path";
24467
24500
  import fs24 from "node:fs";
24468
24501
 
24469
24502
  // src/memory/everos/config.ts
@@ -24671,8 +24704,8 @@ var EverosPlugin = class {
24671
24704
  }, 3e5);
24672
24705
  }
24673
24706
  async startEveros() {
24674
- const pythonDir = path24.dirname(this.config.lancedbPath);
24675
- const configPath2 = path24.join(pythonDir, "config.toml");
24707
+ const pythonDir = path25.dirname(this.config.lancedbPath);
24708
+ const configPath2 = path25.join(pythonDir, "config.toml");
24676
24709
  await this.ensureFcntlCompat();
24677
24710
  const venvPython = this.findVenvPython();
24678
24711
  const everosBin = venvPython.replace(/python\.exe$/, "everos.exe");
@@ -24761,19 +24794,19 @@ var EverosPlugin = class {
24761
24794
  return child;
24762
24795
  }
24763
24796
  findVenvPython() {
24764
- const stateDir = process.env.OPENCLAW_STATE_DIR || path24.join(process.env.HOME || process.env.USERPROFILE || ".", ".openclaw");
24797
+ const stateDir = (process.env.ENGINE7_STATE_DIR ?? process.env.OPENCLAW_STATE_DIR) || path25.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
24765
24798
  if (process.platform === "win32") {
24766
- return path24.join(stateDir, "everos-venv", "Scripts", "python.exe");
24799
+ return path25.join(stateDir, "everos-venv", "Scripts", "python.exe");
24767
24800
  }
24768
- return path24.join(stateDir, "everos-venv", "bin", "python");
24801
+ return path25.join(stateDir, "everos-venv", "bin", "python");
24769
24802
  }
24770
24803
  /** 检测 venv 是否存在,不存在就自动创建 + 装 EverOS */
24771
24804
  async ensureVenv() {
24772
24805
  const venvPython = this.findVenvPython();
24773
24806
  if (fs24.existsSync(venvPython)) return;
24774
- const stateDir = process.env.OPENCLAW_STATE_DIR || path24.join(process.env.HOME || process.env.USERPROFILE || ".", ".openclaw");
24775
- const venvDir = path24.join(stateDir, "everos-venv");
24776
- const everosSrc = path24.join(stateDir, "workspace", "research", "EverOS");
24807
+ const stateDir = (process.env.ENGINE7_STATE_DIR ?? process.env.OPENCLAW_STATE_DIR) || path25.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
24808
+ const venvDir = path25.join(stateDir, "everos-venv");
24809
+ const everosSrc = path25.join(stateDir, "workspace", "research", "EverOS");
24777
24810
  console.log(`[everos] venv not found at ${venvDir}, auto-creating...`);
24778
24811
  console.log(`[everos] \u23F3 This may take a few minutes on first run...`);
24779
24812
  const pyCandidates = process.platform === "win32" ? ["python", "python3", "C:\\Python314\\python.exe", "C:\\Python313\\python.exe", "C:\\Python312\\python.exe"] : ["python3", "python"];
@@ -24795,8 +24828,8 @@ var EverosPlugin = class {
24795
24828
  console.log(`[everos] Creating venv with ${sysPython}...`);
24796
24829
  const { execSync: execSync3 } = await import("node:child_process");
24797
24830
  execSync3(`"${sysPython}" -m venv "${venvDir}"`, { stdio: "pipe", shell: true });
24798
- const pip = process.platform === "win32" ? path24.join(venvDir, "Scripts", "pip.exe") : path24.join(venvDir, "bin", "pip");
24799
- const everosReq = path24.join(this.getPythonDir(), "requirements.txt");
24831
+ const pip = process.platform === "win32" ? path25.join(venvDir, "Scripts", "pip.exe") : path25.join(venvDir, "bin", "pip");
24832
+ const everosReq = path25.join(this.getPythonDir(), "requirements.txt");
24800
24833
  if (fs24.existsSync(everosReq)) {
24801
24834
  console.log(`[everos] Installing from requirements.txt...`);
24802
24835
  execSync3(`"${pip}" install -r "${everosReq}" -q`, { stdio: "pipe", shell: true, timeout: 3e5 });
@@ -24813,12 +24846,12 @@ var EverosPlugin = class {
24813
24846
  getPythonDir() {
24814
24847
  const dir = import.meta.dirname;
24815
24848
  const candidates = [
24816
- path24.join(dir, "python"),
24817
- path24.resolve(dir, "..", "src", "memory", "everos", "python"),
24818
- path24.resolve(dir, "..", "..", "..", "src", "memory", "everos", "python")
24849
+ path25.join(dir, "python"),
24850
+ path25.resolve(dir, "..", "src", "memory", "everos", "python"),
24851
+ path25.resolve(dir, "..", "..", "..", "src", "memory", "everos", "python")
24819
24852
  ];
24820
24853
  for (const candidate of candidates) {
24821
- if (fs24.existsSync(path24.join(candidate, "agentic_server.py"))) {
24854
+ if (fs24.existsSync(path25.join(candidate, "agentic_server.py"))) {
24822
24855
  return candidate;
24823
24856
  }
24824
24857
  }
@@ -24827,11 +24860,11 @@ var EverosPlugin = class {
24827
24860
  async ensureFcntlCompat() {
24828
24861
  if (process.platform !== "win32") return;
24829
24862
  const venvPython = this.findVenvPython();
24830
- const venvDir = path24.dirname(path24.dirname(venvPython));
24831
- const sitePackages = path24.join(venvDir, "Lib", "site-packages");
24832
- const target = path24.join(sitePackages, "fcntl.py");
24863
+ const venvDir = path25.dirname(path25.dirname(venvPython));
24864
+ const sitePackages = path25.join(venvDir, "Lib", "site-packages");
24865
+ const target = path25.join(sitePackages, "fcntl.py");
24833
24866
  if (fs24.existsSync(target)) return;
24834
- const source = path24.join(this.getPythonDir(), "fcntl_compat.py");
24867
+ const source = path25.join(this.getPythonDir(), "fcntl_compat.py");
24835
24868
  if (fs24.existsSync(source)) {
24836
24869
  try {
24837
24870
  fs24.copyFileSync(source, target);
@@ -24881,7 +24914,7 @@ var EverosPlugin = class {
24881
24914
  init_task_manager();
24882
24915
 
24883
24916
  // src/skills/scanner.ts
24884
- import * as path25 from "node:path";
24917
+ import * as path26 from "node:path";
24885
24918
  import * as fs25 from "node:fs";
24886
24919
  function scanSkills(skillsDir) {
24887
24920
  if (!fs25.existsSync(skillsDir)) {
@@ -24892,7 +24925,7 @@ function scanSkills(skillsDir) {
24892
24925
  const skills = [];
24893
24926
  for (const entry of entries) {
24894
24927
  if (!entry.isDirectory()) continue;
24895
- const skillMdPath = path25.join(skillsDir, entry.name, "SKILL.md");
24928
+ const skillMdPath = path26.join(skillsDir, entry.name, "SKILL.md");
24896
24929
  if (!fs25.existsSync(skillMdPath)) continue;
24897
24930
  try {
24898
24931
  const content = fs25.readFileSync(skillMdPath, "utf-8");
@@ -24960,7 +24993,7 @@ function parseFrontmatter2(content) {
24960
24993
  // src/tools/SkillTool/SkillTool.ts
24961
24994
  init_registry();
24962
24995
  import * as fs26 from "node:fs";
24963
- import * as path26 from "node:path";
24996
+ import * as path27 from "node:path";
24964
24997
 
24965
24998
  // src/tools/SkillTool/constants.ts
24966
24999
  var SKILL_TOOL_NAME2 = "Skill";
@@ -25037,12 +25070,12 @@ Important:
25037
25070
  `;
25038
25071
  }
25039
25072
  function loadSkillContent(skillName) {
25040
- const skillMdPath = path26.join(skillsDirPath, skillName, "SKILL.md");
25073
+ const skillMdPath = path27.join(skillsDirPath, skillName, "SKILL.md");
25041
25074
  if (!fs26.existsSync(skillMdPath)) return null;
25042
25075
  const content = fs26.readFileSync(skillMdPath, "utf-8");
25043
25076
  const bodyMatch = content.match(/^---\s*\n[\s\S]*?\n---\s*\n([\s\S]*)/);
25044
25077
  const body = bodyMatch ? bodyMatch[1] : content;
25045
- const skillDir = path26.dirname(skillMdPath);
25078
+ const skillDir = path27.dirname(skillMdPath);
25046
25079
  const normalizedDir = process.platform === "win32" ? skillDir.replace(/\\/g, "/") : skillDir;
25047
25080
  let finalContent = `Base directory for this skill: ${normalizedDir}
25048
25081
 
@@ -25317,9 +25350,9 @@ Examples:
25317
25350
  init_registry();
25318
25351
  init_live();
25319
25352
  import fs27 from "node:fs";
25320
- import path27 from "node:path";
25353
+ import path28 from "node:path";
25321
25354
  function getHusbandFeishuId(workspace) {
25322
- const contactsPath = path27.join(workspace, "prompts", "contacts.md");
25355
+ const contactsPath = path28.join(workspace, "prompts", "contacts.md");
25323
25356
  try {
25324
25357
  const text = fs27.readFileSync(contactsPath, "utf-8");
25325
25358
  const m2 = text.match(/\|\s*翀哥\s*\|\s*(ou_[a-f0-9]+)\s*\|/);
@@ -25522,7 +25555,7 @@ Examples:
25522
25555
  init_live();
25523
25556
  init_registry();
25524
25557
  import * as fs28 from "node:fs";
25525
- import * as path28 from "node:path";
25558
+ import * as path29 from "node:path";
25526
25559
  var MIME_MAP = {
25527
25560
  ".jpg": "jpeg",
25528
25561
  ".jpeg": "jpeg",
@@ -25534,7 +25567,7 @@ var MIME_MAP = {
25534
25567
  function resolveLatestImage(specifiedPath, mediaDir) {
25535
25568
  if (specifiedPath && fs28.existsSync(specifiedPath)) return specifiedPath;
25536
25569
  if (!fs28.existsSync(mediaDir)) return null;
25537
- 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);
25570
+ 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);
25538
25571
  return files[0]?.p || null;
25539
25572
  }
25540
25573
  registry.register({
@@ -25558,13 +25591,13 @@ registry.register({
25558
25591
  if (!provider?.streamChat) {
25559
25592
  return { content: "Error: provider \u4E0D\u53EF\u7528\u3002", isError: true };
25560
25593
  }
25561
- const mediaDir = path28.join(ctx.stateDir, "media", "inbound");
25594
+ const mediaDir = path29.join(ctx.stateDir, "media", "inbound");
25562
25595
  const imagePath = resolveLatestImage(args2.image_path, mediaDir);
25563
25596
  if (!imagePath) {
25564
25597
  return { content: "Error: no image found. Provide image_path or ensure media/inbound has images.", isError: true };
25565
25598
  }
25566
25599
  const rawPrompt = args2.prompt?.trim() || "\u63CF\u8FF0\u8FD9\u5F20\u56FE\u7247\u7684\u5185\u5BB9";
25567
- const ext = path28.extname(imagePath).toLowerCase();
25600
+ const ext = path29.extname(imagePath).toLowerCase();
25568
25601
  const mime = MIME_MAP[ext] || "jpeg";
25569
25602
  const imgB64 = fs28.readFileSync(imagePath).toString("base64");
25570
25603
  const userMsg = {
@@ -25604,13 +25637,13 @@ init_registry();
25604
25637
  import { execFile } from "node:child_process";
25605
25638
  import { promisify } from "node:util";
25606
25639
  import * as fs29 from "node:fs";
25607
- import * as path29 from "node:path";
25640
+ import * as path30 from "node:path";
25608
25641
  import * as os3 from "node:os";
25609
25642
  var execFileAsync = promisify(execFile);
25610
- var VOICE_DIR = path29.join(os3.tmpdir(), "engine-voice");
25643
+ var VOICE_DIR = path30.join(os3.tmpdir(), "engine-voice");
25611
25644
  async function ttsCosyvoice(text, apiKey, model, voice, workspaceId) {
25612
25645
  fs29.mkdirSync(VOICE_DIR, { recursive: true });
25613
- const output = path29.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25646
+ const output = path30.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25614
25647
  const script = `
25615
25648
  import sys, json, wave, time, threading
25616
25649
  import dashscope
@@ -25675,7 +25708,7 @@ var GPTSOVITS_REF_TEXT = "\u6625\u7720\u4E0D\u89C9\u6653\uFF0C\u5904\u5904\u95FB
25675
25708
  var GPTSOVITS_REF_LANG = "zh";
25676
25709
  async function ttsGptsovits(text) {
25677
25710
  fs29.mkdirSync(VOICE_DIR, { recursive: true });
25678
- const output = path29.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25711
+ const output = path30.join(VOICE_DIR, `tts_${Date.now()}.wav`);
25679
25712
  const params = new URLSearchParams({
25680
25713
  text,
25681
25714
  text_language: "zh",
@@ -25692,7 +25725,7 @@ async function ttsGptsovits(text) {
25692
25725
  var EDGE_VOICE = "zh-CN-XiaoxiaoNeural";
25693
25726
  async function ttsEdge(text) {
25694
25727
  fs29.mkdirSync(VOICE_DIR, { recursive: true });
25695
- const output = path29.join(VOICE_DIR, `tts_${Date.now()}.mp3`);
25728
+ const output = path30.join(VOICE_DIR, `tts_${Date.now()}.mp3`);
25696
25729
  const script = `
25697
25730
  import asyncio, edge_tts, sys
25698
25731
  async def main():
@@ -25785,7 +25818,7 @@ registry.register({
25785
25818
  } catch (e) {
25786
25819
  return { content: `TTS failed: ${e.message}`, isError: true };
25787
25820
  }
25788
- const ext = path29.extname(audioPath).toLowerCase();
25821
+ const ext = path30.extname(audioPath).toLowerCase();
25789
25822
  const mimeMap = { ".mp3": "audio/mpeg", ".wav": "audio/wav", ".m4a": "audio/mp4", ".ogg": "audio/ogg" };
25790
25823
  const mimeType = mimeMap[ext] || "audio/mpeg";
25791
25824
  const sizeKB = fs29.statSync(audioPath).size / 1024;
@@ -25816,7 +25849,7 @@ registry.register({
25816
25849
  init_live();
25817
25850
  init_registry();
25818
25851
  import * as fs30 from "node:fs";
25819
- import * as path30 from "node:path";
25852
+ import * as path31 from "node:path";
25820
25853
  var FAL_KEY = "3b848fc6-bee5-46e5-8db7-ae81ac16dc28:2f1f15cf394db2d32c9bb9a4f23f3bee";
25821
25854
  var FAL_ENDPOINT = "https://fal.run/xai/grok-imagine-image/edit";
25822
25855
  var DEFAULT_RESOLUTION = "1k";
@@ -25932,7 +25965,7 @@ registry.register({
25932
25965
  const REFERENCES = getReferences(ctx);
25933
25966
  const refName = args2.reference || "default";
25934
25967
  const refEntry = REFERENCES.find((r) => r.name === refName) || REFERENCES[0];
25935
- const refPath = path30.join(ctx.workspace, refEntry.p);
25968
+ const refPath = path31.join(ctx.workspace, refEntry.p);
25936
25969
  if (!fs30.existsSync(refPath)) {
25937
25970
  return { content: `Error: reference image not found at ${refPath}`, isError: true };
25938
25971
  }
@@ -25951,10 +25984,10 @@ registry.register({
25951
25984
  } catch (err) {
25952
25985
  return { content: `Selfie generation failed: ${err.message}`, isError: true };
25953
25986
  }
25954
- const imagesDir = path30.join(ctx.workspace, "images");
25987
+ const imagesDir = path31.join(ctx.workspace, "images");
25955
25988
  if (!fs30.existsSync(imagesDir)) fs30.mkdirSync(imagesDir, { recursive: true });
25956
25989
  const filename = `selfie_${Date.now()}.jpg`;
25957
- const outputPath = path30.join(imagesDir, filename);
25990
+ const outputPath = path31.join(imagesDir, filename);
25958
25991
  fs30.writeFileSync(outputPath, imageBuffer);
25959
25992
  const mgr = ctx.channelManager;
25960
25993
  if (mgr) {
@@ -25966,11 +25999,11 @@ registry.register({
25966
25999
  mimeType: "image/jpeg"
25967
26000
  });
25968
26001
  } catch (err) {
25969
- return { content: `Selfie generated but send failed: ${err.message}. Image: ${path30.resolve(outputPath)}`, isError: false };
26002
+ return { content: `Selfie generated but send failed: ${err.message}. Image: ${path31.resolve(outputPath)}`, isError: false };
25970
26003
  }
25971
26004
  return { content: `Selfie sent! Mode: ${mode}, Provider: ${getProvider(ctx)}, Ref: ${refEntry.name}` };
25972
26005
  }
25973
- return { content: `Selfie generated! Mode: ${mode}, Ref: ${refEntry.name}. Image: ${path30.resolve(outputPath)}` };
26006
+ return { content: `Selfie generated! Mode: ${mode}, Ref: ${refEntry.name}. Image: ${path31.resolve(outputPath)}` };
25974
26007
  },
25975
26008
  isConcurrencySafe: () => false,
25976
26009
  interruptBehavior: () => "block",
@@ -26437,14 +26470,14 @@ init_planModeState();
26437
26470
 
26438
26471
  // src/utils/plans.ts
26439
26472
  import * as fs32 from "node:fs";
26440
- import * as path32 from "node:path";
26473
+ import * as path33 from "node:path";
26441
26474
  import * as crypto4 from "node:crypto";
26442
26475
  var MAX_SLUG_RETRIES = 10;
26443
26476
  function generateSlug() {
26444
26477
  return crypto4.randomBytes(4).toString("hex");
26445
26478
  }
26446
26479
  function getPlansDirectory(stateDir) {
26447
- const plansDir = path32.join(stateDir, "plans");
26480
+ const plansDir = path33.join(stateDir, "plans");
26448
26481
  fs32.mkdirSync(plansDir, { recursive: true });
26449
26482
  return plansDir;
26450
26483
  }
@@ -26455,7 +26488,7 @@ function getPlanSlug(sessionId, stateDir) {
26455
26488
  const plansDir = getPlansDirectory(stateDir);
26456
26489
  for (let i = 0; i < MAX_SLUG_RETRIES; i++) {
26457
26490
  slug = generateSlug();
26458
- const filePath = path32.join(plansDir, `${slug}.md`);
26491
+ const filePath = path33.join(plansDir, `${slug}.md`);
26459
26492
  if (!fs32.existsSync(filePath)) {
26460
26493
  break;
26461
26494
  }
@@ -26467,9 +26500,9 @@ function getPlanSlug(sessionId, stateDir) {
26467
26500
  function getPlanFilePath(sessionId, stateDir, agentId) {
26468
26501
  const slug = getPlanSlug(sessionId, stateDir);
26469
26502
  if (!agentId) {
26470
- return path32.join(getPlansDirectory(stateDir), `${slug}.md`);
26503
+ return path33.join(getPlansDirectory(stateDir), `${slug}.md`);
26471
26504
  }
26472
- return path32.join(getPlansDirectory(stateDir), `${slug}-agent-${agentId}.md`);
26505
+ return path33.join(getPlansDirectory(stateDir), `${slug}-agent-${agentId}.md`);
26473
26506
  }
26474
26507
  function getPlan(sessionId, stateDir, agentId) {
26475
26508
  const filePath = getPlanFilePath(sessionId, stateDir, agentId);
@@ -27684,9 +27717,10 @@ async function startEngine(config2, opts) {
27684
27717
  process.env.ENGINE_MEDIA_DIR = config2.mediaDir;
27685
27718
  process.env.ENGINE7_WORKSPACE = config2.workspace;
27686
27719
  process.env.OPENCLAW_WORKSPACE = config2.workspace;
27687
- fs41.mkdirSync(path43.join(config2.stateDir, "agents", "main", "memory"), { recursive: true });
27688
- fs41.mkdirSync(path43.join(config2.stateDir, "agents", "main", "sessions"), { recursive: true });
27689
- fs41.mkdirSync(path43.join(config2.stateDir, "logs"), { recursive: true });
27720
+ process.env.ENGINE7_STATE_DIR = config2.stateDir;
27721
+ fs41.mkdirSync(path44.join(config2.stateDir, "agents", "main", "memory"), { recursive: true });
27722
+ fs41.mkdirSync(path44.join(config2.stateDir, "agents", "main", "sessions"), { recursive: true });
27723
+ fs41.mkdirSync(path44.join(config2.stateDir, "logs"), { recursive: true });
27690
27724
  fs41.mkdirSync(config2.workspace, { recursive: true });
27691
27725
  fs41.mkdirSync(config2.mediaDir, { recursive: true });
27692
27726
  try {
@@ -27796,7 +27830,7 @@ async function startEngine(config2, opts) {
27796
27830
  const { initSessionMemory: initSessionMemory2 } = await Promise.resolve().then(() => (init_sessionMemory(), sessionMemory_exports));
27797
27831
  initSessionMemory2({
27798
27832
  workspace: config2.workspace,
27799
- stateDir: path43.join(config2.stateDir, "session-memory"),
27833
+ stateDir: path44.join(config2.stateDir, "session-memory"),
27800
27834
  provider,
27801
27835
  model: config2.provider.modelId || config2.model || "deepseek-v4-flash",
27802
27836
  features: config2.profile.features
@@ -27826,9 +27860,9 @@ async function startEngine(config2, opts) {
27826
27860
  if (config2.hooks) {
27827
27861
  loadHooksFromConfig({ hooks: config2.hooks });
27828
27862
  }
27829
- const hooksPath = path43.join(config2.workspace, ".hooks.json");
27863
+ const hooksPath = path44.join(config2.workspace, ".hooks.json");
27830
27864
  loadHooksFromFile(hooksPath);
27831
- const settingsHooksPath = path43.join(config2.stateDir, "settings.json");
27865
+ const settingsHooksPath = path44.join(config2.stateDir, "settings.json");
27832
27866
  loadHooksFromFile(settingsHooksPath);
27833
27867
  console.log(`[hooks] Loaded hooks configuration`);
27834
27868
  registerCallbackHook("PreCompact", {
@@ -27842,15 +27876,15 @@ async function startEngine(config2, opts) {
27842
27876
  const bjTime = new Date(now.getTime() + (bjOffset + now.getTimezoneOffset()) * 6e4);
27843
27877
  const dateStr = `${bjTime.getFullYear()}-${String(bjTime.getMonth() + 1).padStart(2, "0")}-${String(bjTime.getDate()).padStart(2, "0")}`;
27844
27878
  const timeStr = `${String(bjTime.getHours()).padStart(2, "0")}:${String(bjTime.getMinutes()).padStart(2, "0")}`;
27845
- const dailyDir = path43.join(workspace, "memory", "daily");
27846
- const dailyPath = path43.join(dailyDir, `${dateStr}.md`);
27879
+ const dailyDir = path44.join(workspace, "memory", "daily");
27880
+ const dailyPath = path44.join(dailyDir, `${dateStr}.md`);
27847
27881
  try {
27848
27882
  const fs42 = await import("node:fs");
27849
27883
  if (!fs42.existsSync(dailyDir)) {
27850
27884
  fs42.mkdirSync(dailyDir, { recursive: true });
27851
27885
  }
27852
- const sessionsDir = path43.join(config2.stateDir, "agents", "main", "sessions");
27853
- const sessionFile = path43.join(sessionsDir, `${sessionId}.jsonl`);
27886
+ const sessionsDir = path44.join(config2.stateDir, "agents", "main", "sessions");
27887
+ const sessionFile = path44.join(sessionsDir, `${sessionId}.jsonl`);
27854
27888
  const recentLines = [];
27855
27889
  if (fs42.existsSync(sessionFile)) {
27856
27890
  const content = fs42.readFileSync(sessionFile, "utf-8");
@@ -27903,7 +27937,7 @@ ${entry}`);
27903
27937
  if (!workspace) return { continue: true };
27904
27938
  try {
27905
27939
  const fs42 = await import("node:fs");
27906
- const bufferPath = path43.join(workspace, "memory", "working-buffer.md");
27940
+ const bufferPath = path44.join(workspace, "memory", "working-buffer.md");
27907
27941
  if (fs42.existsSync(bufferPath)) {
27908
27942
  const stat4 = fs42.statSync(bufferPath);
27909
27943
  const ageMs = Date.now() - stat4.mtimeMs;
@@ -27956,7 +27990,7 @@ ${content}`
27956
27990
  return `${hr}h ${remMin}m`;
27957
27991
  }
27958
27992
  if (config2.skills?.enabled !== false) {
27959
- const skillsDir = config2.skills?.path ? path43.isAbsolute(config2.skills.path) ? config2.skills.path : path43.resolve(config2.workspace, config2.skills.path) : path43.resolve(config2.workspace, "skills");
27993
+ const skillsDir = config2.skills?.path ? path44.isAbsolute(config2.skills.path) ? config2.skills.path : path44.resolve(config2.workspace, config2.skills.path) : path44.resolve(config2.workspace, "skills");
27960
27994
  const modelDef2 = config2.provider.models.find((m2) => m2.id === config2.model);
27961
27995
  const contextWindowTokens = modelDef2?.contextWindow;
27962
27996
  const skills = scanSkills(skillsDir);
@@ -27975,7 +28009,7 @@ ${content}`
27975
28009
  workspace: config2.workspace
27976
28010
  });
27977
28011
  const systemPrompt = [systemStable, systemDynamic].join("\n\n");
27978
- const promptDumpPath = path43.join(config2.workspace, ".system-prompt.txt");
28012
+ const promptDumpPath = path44.join(config2.workspace, ".system-prompt.txt");
27979
28013
  fs41.writeFileSync(promptDumpPath, systemPrompt);
27980
28014
  console.log(`System prompt: ${systemStable.length} chars stable + ${systemDynamic.length} chars dynamic \u2192 ${promptDumpPath}`);
27981
28015
  const modelDef = config2.provider.models.find((m2) => m2.id === config2.model);
@@ -28079,31 +28113,6 @@ ${content}`
28079
28113
  sessions.migrateOldSessions();
28080
28114
  sessions.startIdleCleanup();
28081
28115
  cleanupArchivedSessionTranscripts(sessions.sessionsDir);
28082
- const everosCfg = config2.everos;
28083
- if (everosCfg?.enabled) {
28084
- const { createEverosSync: createEverosSync2 } = await Promise.resolve().then(() => (init_everos_sync(), everos_sync_exports));
28085
- const everosSync = createEverosSync2({
28086
- enabled: true,
28087
- url: everosCfg.everosUrl || "http://127.0.0.1:8100",
28088
- appId: everosCfg.userId || "default",
28089
- userId: everosCfg.userId || "default",
28090
- agentName: everosCfg.agentName || everosCfg.userId || "assistant"
28091
- });
28092
- sessions.onWriterCreated = (writer, sessionId) => {
28093
- writer.onMessageWritten = (msg2) => {
28094
- console.log(`[everos-sync] onMessageWritten fired: role=${msg2.role} len=${msg2.text.length}`);
28095
- everosSync.push({
28096
- sessionId: writer.engineSessionId || sessionId,
28097
- role: msg2.role === "toolResult" ? "tool" : msg2.role,
28098
- text: msg2.text,
28099
- timestamp: new Date(msg2.timestamp).getTime()
28100
- }).catch((e) => console.warn(`[everos-sync] push error: ${e}`));
28101
- };
28102
- };
28103
- console.log(`[everos-sync] hook registered (appId=${everosCfg.userId})`);
28104
- } else {
28105
- console.log(`[everos-sync] SKIPPED \u2014 config.everos not enabled or missing`);
28106
- }
28107
28116
  const channelManager = new ChannelManager();
28108
28117
  const memoryRecallProvider = createMemorySideProvider(
28109
28118
  config2.topics?.recall,
@@ -29054,8 +29063,8 @@ Auto-routing disabled \u2014 all messages use this model.
29054
29063
  let writePath = configPath2;
29055
29064
  if (configPath2 && !fs41.existsSync(configPath2)) {
29056
29065
  const __pFile = fileURLToPath(import.meta.url);
29057
- const __pDir = path43.dirname(__pFile);
29058
- const altPath = path43.join(path43.resolve(__pDir, "../configs"), path43.basename(configPath2));
29066
+ const __pDir = path44.dirname(__pFile);
29067
+ const altPath = path44.join(path44.resolve(__pDir, "../configs"), path44.basename(configPath2));
29059
29068
  if (fs41.existsSync(altPath)) {
29060
29069
  console.warn(`[primary] Config not found at ${configPath2}, falling back to ${altPath}`);
29061
29070
  writePath = altPath;
@@ -29335,7 +29344,7 @@ Use full ref like \`/vision-model ${candidates[0].ref}\``);
29335
29344
  const ext = detected.split("/")[1] || "png";
29336
29345
  const resized = await maybeResizeAndDownsampleImageBuffer2(rawBuffer, rawBuffer.length, ext);
29337
29346
  const imageId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
29338
- const savedPath = path43.join(config2.mediaDir, `${imageId}.${ext}`);
29347
+ const savedPath = path44.join(config2.mediaDir, `${imageId}.${ext}`);
29339
29348
  fs41.writeFileSync(savedPath, resized.buffer);
29340
29349
  savedPaths.push(savedPath);
29341
29350
  console.log(`[vision] Saved: ${savedPath} (${resized.buffer.length}B)`);
@@ -29362,7 +29371,7 @@ ${pathStr}` }];
29362
29371
  }
29363
29372
  const nonImageAttachments = inbound.attachments?.filter((a) => !a.contentType.startsWith("image/"));
29364
29373
  if (nonImageAttachments && nonImageAttachments.length > 0) {
29365
- const outDir = path43.join(config2.mediaDir, sessionId);
29374
+ const outDir = path44.join(config2.mediaDir, sessionId);
29366
29375
  fs41.mkdirSync(outDir, { recursive: true });
29367
29376
  const resolved = [];
29368
29377
  for (const att of nonImageAttachments) {
@@ -29371,8 +29380,8 @@ ${pathStr}` }];
29371
29380
  const resp = await fetch(att.url);
29372
29381
  if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
29373
29382
  const buffer = Buffer.from(await resp.arrayBuffer());
29374
- const safeName2 = path43.basename(att.filename).replace(/[<>:"/\\|?*\x00-\x1f]/g, "_") || "attachment";
29375
- const savedPath = path43.join(outDir, safeName2);
29383
+ const safeName2 = path44.basename(att.filename).replace(/[<>:"/\\|?*\x00-\x1f]/g, "_") || "attachment";
29384
+ const savedPath = path44.join(outDir, safeName2);
29376
29385
  fs41.writeFileSync(savedPath, buffer);
29377
29386
  resolved.push(savedPath);
29378
29387
  console.log(`[file] Saved: ${savedPath} (${buffer.length}B)`);
@@ -29734,7 +29743,7 @@ ${pathStr}` }];
29734
29743
  console.warn("[cognifold] watcher: config.workspace \u672A\u914D\u7F6E\uFF0C\u8DF3\u8FC7 proactive \u5199\u5165");
29735
29744
  return;
29736
29745
  }
29737
- const pFile = path43.join(wsDir, ".cognifold-proactive.json");
29746
+ const pFile = path44.join(wsDir, ".cognifold-proactive.json");
29738
29747
  const cognifoldBaseUrl = config2.cognifold?.baseUrl || "http://127.0.0.1:9001";
29739
29748
  const cognifoldSessionId = cfSessionId;
29740
29749
  const rawSuggestions = data.suggestions || data.actions || (data.intent_id ? [data] : []);
@@ -29788,7 +29797,7 @@ ${pathStr}` }];
29788
29797
  console.error(`[cognifold] failed to save proactive: ${e.message}`);
29789
29798
  }
29790
29799
  if (enriched.length > 0) {
29791
- const promptFile = path43.join(config2.workspace, "prompts", "cognifold-proactive.md");
29800
+ const promptFile = path44.join(config2.workspace, "prompts", "cognifold-proactive.md");
29792
29801
  const promptText = fs41.existsSync(promptFile) ? fs41.readFileSync(promptFile, "utf-8") : "[CogniFold proactive] \u6709 " + enriched.length + " \u4E2A action \u5230\u671F\u4E86";
29793
29802
  const actionsJson = JSON.stringify(enriched, null, 2);
29794
29803
  const sessionId = cfSessionId;
@@ -29894,9 +29903,9 @@ async function doReloadConfig(config2, deps, provider) {
29894
29903
  let reloadConfigPath = savedConfigPath;
29895
29904
  if (!fs41.existsSync(reloadConfigPath)) {
29896
29905
  const __filename = fileURLToPath(import.meta.url);
29897
- const __dirname = path43.dirname(__filename);
29898
- const engineConfigsDir = path43.resolve(__dirname, "../configs");
29899
- const altPath = path43.join(engineConfigsDir, path43.basename(savedConfigPath));
29906
+ const __dirname = path44.dirname(__filename);
29907
+ const engineConfigsDir = path44.resolve(__dirname, "../configs");
29908
+ const altPath = path44.join(engineConfigsDir, path44.basename(savedConfigPath));
29900
29909
  if (fs41.existsSync(altPath)) {
29901
29910
  console.warn(`[reload] Config not found at ${reloadConfigPath}, falling back to ${altPath} (dev mode)`);
29902
29911
  reloadConfigPath = altPath;
@@ -29949,7 +29958,7 @@ async function doReloadConfig(config2, deps, provider) {
29949
29958
  } catch (err) {
29950
29959
  console.error(`[reload] Failed: ${err.message}`);
29951
29960
  try {
29952
- fs41.appendFileSync(path43.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD FAILED: ${err.message}
29961
+ fs41.appendFileSync(path44.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD FAILED: ${err.message}
29953
29962
  ${err.stack}
29954
29963
  `);
29955
29964
  } catch {
@@ -29961,17 +29970,17 @@ function startConfigWatcher(config2, deps, provider) {
29961
29970
  const raw = config2._configFilePath;
29962
29971
  let configPath2 = raw;
29963
29972
  if (!fs41.existsSync(configPath2)) {
29964
- configPath2 = path43.resolve(raw);
29973
+ configPath2 = path44.resolve(raw);
29965
29974
  }
29966
29975
  if (!fs41.existsSync(configPath2)) {
29967
29976
  const __filename2 = fileURLToPath(import.meta.url);
29968
- const __dirname22 = path43.dirname(__filename2);
29969
- configPath2 = path43.resolve(__dirname22, "..", raw);
29977
+ const __dirname22 = path44.dirname(__filename2);
29978
+ configPath2 = path44.resolve(__dirname22, "..", raw);
29970
29979
  }
29971
29980
  if (!fs41.existsSync(configPath2)) {
29972
29981
  console.warn(`[config-watch] config path invalid: ${configPath2}, watcher disabled`);
29973
29982
  try {
29974
- fs41.appendFileSync(path43.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] DISABLED: configPath=${configPath2}
29983
+ fs41.appendFileSync(path44.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] DISABLED: configPath=${configPath2}
29975
29984
  `);
29976
29985
  } catch {
29977
29986
  }
@@ -29983,13 +29992,13 @@ function startConfigWatcher(config2, deps, provider) {
29983
29992
  debounceTimer = setTimeout(async () => {
29984
29993
  console.log(`[config-watch] file changed (${eventType}), reloading...`);
29985
29994
  try {
29986
- fs41.appendFileSync(path43.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] CHANGE eventType=${eventType}, calling doReloadConfig
29995
+ fs41.appendFileSync(path44.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] CHANGE eventType=${eventType}, calling doReloadConfig
29987
29996
  `);
29988
29997
  } catch {
29989
29998
  }
29990
29999
  const result = await doReloadConfig(config2, deps, provider);
29991
30000
  try {
29992
- fs41.appendFileSync(path43.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD DONE: ok=${result.ok} changes=${result.changes.join(",")}
30001
+ fs41.appendFileSync(path44.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] RELOAD DONE: ok=${result.ok} changes=${result.changes.join(",")}
29993
30002
  `);
29994
30003
  } catch {
29995
30004
  }
@@ -29998,14 +30007,14 @@ function startConfigWatcher(config2, deps, provider) {
29998
30007
  watcher.on("error", (err) => {
29999
30008
  console.error(`[config-watch] error: ${err.message}`);
30000
30009
  try {
30001
- fs41.appendFileSync(path43.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] ERROR: ${err.message}
30010
+ fs41.appendFileSync(path44.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] ERROR: ${err.message}
30002
30011
  `);
30003
30012
  } catch {
30004
30013
  }
30005
30014
  });
30006
30015
  console.log(`[config-watch] watching ${configPath2}`);
30007
30016
  try {
30008
- fs41.appendFileSync(path43.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] STARTED watching=${configPath2}
30017
+ fs41.appendFileSync(path44.join(config2.stateDir, "logs", "engine-config-watch.log"), `[${(/* @__PURE__ */ new Date()).toISOString()}] STARTED watching=${configPath2}
30009
30018
  `);
30010
30019
  } catch {
30011
30020
  }
@@ -30015,9 +30024,9 @@ function startConfigWatcher(config2, deps, provider) {
30015
30024
  // src/main.ts
30016
30025
  import { readFileSync as readFileSync28 } from "node:fs";
30017
30026
  import { fileURLToPath as fileURLToPath2 } from "node:url";
30018
- import { dirname as dirname8, join as join38 } from "node:path";
30027
+ import { dirname as dirname8, join as join40 } from "node:path";
30019
30028
  var __dirname2 = dirname8(fileURLToPath2(import.meta.url));
30020
- var pkg = JSON.parse(readFileSync28(join38(__dirname2, "..", "package.json"), "utf-8"));
30029
+ var pkg = JSON.parse(readFileSync28(join40(__dirname2, "..", "package.json"), "utf-8"));
30021
30030
  var epipeSeen = false;
30022
30031
  process.on("uncaughtException", (err) => {
30023
30032
  const code = err?.code ?? "";