ai-helper-agent 1.3.0 → 1.3.2

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/bin/agent.js CHANGED
@@ -210,7 +210,8 @@ if (command === 'start') {
210
210
  detached: true,
211
211
  stdio: 'ignore',
212
212
  cwd: process.cwd(),
213
- env: { ...process.env }
213
+ env: { ...process.env },
214
+ windowsHide: true
214
215
  });
215
216
 
216
217
  // 监听 spawn 错误
@@ -344,7 +345,8 @@ if (command === 'start') {
344
345
  detached: true,
345
346
  stdio: 'ignore',
346
347
  cwd: process.cwd(),
347
- env: { ...process.env }
348
+ env: { ...process.env },
349
+ windowsHide: true
348
350
  });
349
351
 
350
352
  let spawnFailed = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-helper-agent",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "AI Helper 本地代理服务 - 为 Chrome 扩展提供本地文件读写和系统命令执行能力",
5
5
  "type": "module",
6
6
  "main": "./src/server.js",
package/src/executor.js CHANGED
@@ -65,7 +65,8 @@ function executeCommand(command, cwd, wsClient, onComplete, collectOutput = fals
65
65
  const proc = spawn('sh', ['-c', command], {
66
66
  cwd: workdir,
67
67
  env: buildSafeEnv(),
68
- stdio: ['pipe', 'pipe', 'pipe']
68
+ stdio: ['ignore', 'pipe', 'pipe'],
69
+ windowsHide: true
69
70
  });
70
71
 
71
72
  const wsClients = new Set();
package/src/search.js CHANGED
@@ -13,7 +13,7 @@ let rgAvailable = null;
13
13
  */
14
14
  function checkFdAvailable() {
15
15
  return new Promise((resolve) => {
16
- const proc = spawn('fd', ['--version'], { stdio: 'ignore' });
16
+ const proc = spawn('fd', ['--version'], { stdio: 'ignore', windowsHide: true });
17
17
  const timeout = setTimeout(() => { proc.kill(); resolve(false); }, 5000);
18
18
  proc.on('close', (code) => { clearTimeout(timeout); resolve(code === 0); });
19
19
  proc.on('error', () => { clearTimeout(timeout); resolve(false); });
@@ -25,7 +25,7 @@ function checkFdAvailable() {
25
25
  */
26
26
  function checkRgAvailable() {
27
27
  return new Promise((resolve) => {
28
- const proc = spawn('rg', ['--version'], { stdio: 'ignore' });
28
+ const proc = spawn('rg', ['--version'], { stdio: 'ignore', windowsHide: true });
29
29
  const timeout = setTimeout(() => { proc.kill(); resolve(false); }, 5000);
30
30
  proc.on('close', (code) => { clearTimeout(timeout); resolve(code === 0); });
31
31
  proc.on('error', () => { clearTimeout(timeout); resolve(false); });
@@ -89,7 +89,7 @@ function searchWithFd(rootPath, filePattern, recursive, maxResults) {
89
89
  if (!recursive) args.push('--max-depth', '1');
90
90
  args.push(rootPath);
91
91
 
92
- const proc = spawn('fd', args, { stdio: ['ignore', 'pipe', 'pipe'] });
92
+ const proc = spawn('fd', args, { stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
93
93
  const stdout = [];
94
94
  const stderr = [];
95
95
  let timedOut = false;
@@ -218,7 +218,7 @@ function searchContentWithRg(rootPath, pattern, filePattern, maxResults, context
218
218
  }
219
219
  args.push(pattern, rootPath);
220
220
 
221
- const proc = spawn('rg', args, { stdio: ['ignore', 'pipe', 'pipe'] });
221
+ const proc = spawn('rg', args, { stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
222
222
  const stdout = [];
223
223
  let timedOut = false;
224
224
 
package/src/server.js CHANGED
@@ -2,7 +2,8 @@
2
2
  import http from 'http';
3
3
  import { WebSocketServer } from 'ws';
4
4
  import { readFileSync, writeFileSync, readdirSync, statSync, unlinkSync, rmdirSync, existsSync, chmodSync } from 'fs';
5
- import { join } from 'path';
5
+ import { join, dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
6
7
  import { homedir } from 'os';
7
8
  import os from 'os';
8
9
  import { loadConfig } from './config.js';
@@ -12,6 +13,9 @@ import { executeCommand, executeCommandSync, addWsClient, killProcess, getRunnin
12
13
  import { setConsoleOutput, logAuth, logFs, logExec, logSecurity, logSystem, logError, queryLogs, getLogDates } from './logger.js';
13
14
  import { initSearchTools, getSearchToolsAvailable, searchFiles, searchContent } from './search.js';
14
15
 
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+ const AGENT_VERSION = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')).version;
18
+
15
19
  const MAX_BODY_SIZE = 10 * 1024 * 1024; // 10MB
16
20
  const MAX_SEARCH_RESULTS = 5000; // 单次搜索最大结果数
17
21
  const MAX_LOG_QUERY_LIMIT = 1000; // 日志查询最大条数
@@ -145,7 +149,7 @@ export function startServer() {
145
149
  if (req.method === 'GET' && pathname === '/api/status') {
146
150
  return jsonResponse(res, 200, {
147
151
  success: true,
148
- version: '1.0.0',
152
+ version: AGENT_VERSION,
149
153
  running: true,
150
154
  ...PLATFORM_INFO,
151
155
  searchTools: getSearchToolsAvailable()
@@ -179,7 +183,7 @@ export function startServer() {
179
183
  if (req.method === 'GET' && pathname === '/api/status/detail') {
180
184
  return jsonResponse(res, 200, {
181
185
  success: true,
182
- version: '1.0.0',
186
+ version: AGENT_VERSION,
183
187
  pairCode: getCurrentPairCode(),
184
188
  pairCodeTTL: config.pairCodeTTL,
185
189
  workdir: config.workdir,