Commit d89a0df41f001f88ef0d050c892127a9a95259b5

Authored by Yi Bo
1 parent 931784d3

fix: critical path bugs - DATA_ROOT+system joins still resolving to old data/system/ path

Fixed 4 hidden bugs where path.join(DATA_ROOT, "system", ...) was used instead
of direct path.resolve to root-level system/:

- agent-chat.js: billing log scan (line 804) and agent list scan (line 909)
- company-service.js: TEMPLATES_DIR and GLOBAL_AGENTS_DIR constants
- heartbeat-service.js: system agents scan directory

These were missed because they used path.join with a variable (DATA_ROOT)
rather than the literal string "data/system" that sed caught.
server/routes/agent-chat.js
... ... @@ -801,7 +801,7 @@ router.get('/quota', (req, res) => {
801 801 }
802 802 };
803 803  
804   - readBilling(path.join(DATA_ROOT, 'system/agents/master/logs'));
  804 + readBilling(path.resolve(__dirname, '../../system/agents/master/logs'));
805 805 const compDir = path.join(DATA_ROOT, 'companies');
806 806 if (fs.existsSync(compDir)) {
807 807 const comps = fs.readdirSync(compDir, { withFileTypes: true });
... ... @@ -906,7 +906,7 @@ router.get('/list', (req, res) => {
906 906 }
907 907  
908 908 // 1. 扫描 System Agents (system/agents/)
909   - scanAgentDir(path.join(DATA_ROOT, 'system', 'agents'), 'system')
  909 + scanAgentDir(path.resolve(__dirname, '../../system/agents'), 'system')
910 910  
911 911 // 2. 扫描 Company Agents (data/companies/{companyId}/agents/)
912 912 const companiesDir = path.join(DATA_ROOT, 'companies')
... ...
server/services/company-service.js
... ... @@ -2,7 +2,7 @@
2 2 * CompanyService — 公司实例管理
3 3 *
4 4 * 数据目录: data/{companyId}/
5   - * 模板库: data/templates/
  5 + * 模板库: system/templates/
6 6 *
7 7 * 核心职责:
8 8 * 1. Company CRUD (create/get/list/shutdown)
... ... @@ -15,8 +15,8 @@ const path = require('path');
15 15  
16 16 const ROOT_DATA_DIR = path.resolve(__dirname, '../../data');
17 17 const DATA_DIR = path.join(ROOT_DATA_DIR, 'companies');
18   -const TEMPLATES_DIR = path.join(ROOT_DATA_DIR, 'system', 'templates');
19   -const GLOBAL_AGENTS_DIR = path.join(ROOT_DATA_DIR, 'system', 'agents');
  18 +const TEMPLATES_DIR = path.resolve(__dirname, '../../system/templates');
  19 +const GLOBAL_AGENTS_DIR = path.resolve(__dirname, '../../system/agents');
20 20  
21 21 // 模板骨架文件白名单 (复制这些,不复制 memory/workspace/conversations 等运行态数据)
22 22 const TEMPLATE_FILES = [
... ...
server/services/heartbeat-service.js
... ... @@ -27,7 +27,7 @@ class HeartbeatService {
27 27 const rootDir = path.resolve(__dirname, '../../data');
28 28  
29 29 // 1. 扫描系统级 Agents (system/agents/*)
30   - const sysAgentsDir = path.join(rootDir, 'system', 'agents');
  30 + const sysAgentsDir = path.resolve(__dirname, '../../system/agents');
31 31 if (fs.existsSync(sysAgentsDir)) {
32 32 const globals = fs.readdirSync(sysAgentsDir).filter(f => fs.lstatSync(path.join(sysAgentsDir, f)).isDirectory());
33 33 for (const ag of globals) {
... ...