ai-helper-agent 1.5.0 → 1.5.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.js +12 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-helper-agent",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "AI Helper 代理服务 - 为 Chrome 扩展提供本地文件读写和系统命令执行能力",
5
5
  "type": "module",
6
6
  "main": "./src/server.js",
package/src/server.js CHANGED
@@ -5,7 +5,7 @@ import { readFileSync, writeFileSync, readdirSync, statSync, unlinkSync, rmdirSy
5
5
  import { join, dirname } from 'path';
6
6
  import { fileURLToPath } from 'url';
7
7
  import { homedir } from 'os';
8
- import { exec } from 'child_process';
8
+ import { spawn } from 'child_process';
9
9
  import os from 'os';
10
10
  import { loadConfig } from './config.js';
11
11
  import { verifyToken, getCurrentPairCode, startPairCodeRotation, stopPairCodeRotation, handlePairRequest } from './auth.js';
@@ -379,23 +379,23 @@ export function startServer() {
379
379
  }
380
380
 
381
381
  const fileUrl = `file://${check.resolved}`;
382
- let openCmd;
383
382
  const platform = os.platform();
383
+ let cmd, args, spawnOpts;
384
384
  if (platform === 'darwin') {
385
- openCmd = `open "${fileUrl}"`;
385
+ cmd = 'open';
386
+ args = [fileUrl];
387
+ spawnOpts = { detached: true, stdio: 'ignore' };
386
388
  } else if (platform === 'win32') {
387
- openCmd = `start "" "${fileUrl}"`;
389
+ cmd = 'start';
390
+ args = ['""', `"${fileUrl}"`];
391
+ spawnOpts = { detached: true, stdio: 'ignore', shell: true, windowsHide: true };
388
392
  } else {
389
- openCmd = `xdg-open "${fileUrl}"`;
393
+ cmd = 'xdg-open';
394
+ args = [fileUrl];
395
+ spawnOpts = { detached: true, stdio: 'ignore' };
390
396
  }
391
397
 
392
- exec(openCmd, (err) => {
393
- if (err) {
394
- logError('browser_open', { path: check.resolved, error: err.message });
395
- // exec 是异步回调,这里无法直接在回调中响应
396
- // 但实际上如果能执行命令,浏览器大概率会成功打开
397
- }
398
- });
398
+ spawn(cmd, args, spawnOpts).unref();
399
399
 
400
400
  logFs('browser_open', { path: check.resolved, platform });
401
401
  return jsonResponse(res, 200, { success: true, path: check.resolved, platform });