ai-helper-agent 1.6.6 → 1.8.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-helper-agent",
3
- "version": "1.6.6",
3
+ "version": "1.8.0",
4
4
  "description": "AI Helper 代理服务 - 为 Chrome 扩展提供本地文件读写和系统命令执行能力",
5
5
  "type": "module",
6
6
  "main": "./src/server.js",
@@ -16,7 +16,7 @@
16
16
  "start": "node bin/agent.js start",
17
17
  "stop": "node bin/agent.js stop",
18
18
  "status": "node bin/agent.js status",
19
- "publish": "bash publish.sh"
19
+ "release": "bash publish.sh"
20
20
  },
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/sdk": "^1.29.0",
package/src/config.js CHANGED
@@ -8,6 +8,7 @@ const CONFIG_FILE = join(AGENT_DIR, 'config.json');
8
8
  const PAIRINGS_FILE = join(AGENT_DIR, 'pairings.json');
9
9
  const SKILLS_DIR = join(AGENT_DIR, 'skills');
10
10
  const WORKSPACE_DIR = join(AGENT_DIR, 'workspace');
11
+ const MEMORY_DIR = join(AGENT_DIR, 'memory');
11
12
 
12
13
  const DEFAULTS = {
13
14
  port: 18910,
@@ -44,8 +45,8 @@ function ensureAgentDir() {
44
45
  if (!existsSync(AGENT_DIR)) {
45
46
  mkdirSync(AGENT_DIR, { recursive: true });
46
47
  }
47
- // 确保 skills 和 workspace 子目录存在
48
- for (const dir of [SKILLS_DIR, WORKSPACE_DIR]) {
48
+ // 确保 skills、workspace 和 memory 子目录存在
49
+ for (const dir of [SKILLS_DIR, WORKSPACE_DIR, MEMORY_DIR]) {
49
50
  if (!existsSync(dir)) {
50
51
  mkdirSync(dir, { recursive: true });
51
52
  }
@@ -198,4 +199,4 @@ export async function savePairing(extensionId, token) {
198
199
  });
199
200
  }
200
201
 
201
- export { AGENT_DIR, CONFIG_FILE };
202
+ export { AGENT_DIR, CONFIG_FILE, MEMORY_DIR };
package/src/security.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { resolve, normalize, sep, isAbsolute, join, dirname } from 'path';
3
3
  import { realpathSync } from 'fs';
4
4
  import { homedir, platform } from 'os';
5
- import { loadConfig } from './config.js';
5
+ import { loadConfig, MEMORY_DIR } from './config.js';
6
6
 
7
7
  const isWin32 = platform() === 'win32';
8
8
 
@@ -60,6 +60,13 @@ function checkPath(pathStr) {
60
60
  return { allowed: false, reason: '路径无效' };
61
61
  }
62
62
 
63
+ // 展开 ~ 到用户主目录(扩展端无法知道 Agent 所在机器的 home 路径)
64
+ if (pathStr === '~') {
65
+ pathStr = homedir();
66
+ } else if (pathStr.startsWith('~/')) {
67
+ pathStr = join(homedir(), pathStr.slice(2));
68
+ }
69
+
63
70
  try {
64
71
  const config = loadConfig();
65
72
 
@@ -74,6 +81,12 @@ function checkPath(pathStr) {
74
81
  return { allowed: false, reason: '禁止访问代理系统文件' };
75
82
  }
76
83
 
84
+ // 0.5. 系统目录白名单:记忆存储目录(Agent 内部管理,可读写)
85
+ const memoryPrefix = normalize(join(MEMORY_DIR, sep));
86
+ if (normalized.startsWith(memoryPrefix) || normalized === normalize(MEMORY_DIR)) {
87
+ return { allowed: true, resolved: normalized };
88
+ }
89
+
77
90
  const allowedPaths = config.allowedPaths.length > 0 ? config.allowedPaths.map(p => normalizePathFormat(p)) : [normalizedWorkdir];
78
91
 
79
92
  // 先做前缀检查(快速路径,兼容 Windows/Unix)