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.
- package/package.json +1 -1
- package/src/server.js +12 -12
package/package.json
CHANGED
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 {
|
|
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
|
-
|
|
385
|
+
cmd = 'open';
|
|
386
|
+
args = [fileUrl];
|
|
387
|
+
spawnOpts = { detached: true, stdio: 'ignore' };
|
|
386
388
|
} else if (platform === 'win32') {
|
|
387
|
-
|
|
389
|
+
cmd = 'start';
|
|
390
|
+
args = ['""', `"${fileUrl}"`];
|
|
391
|
+
spawnOpts = { detached: true, stdio: 'ignore', shell: true, windowsHide: true };
|
|
388
392
|
} else {
|
|
389
|
-
|
|
393
|
+
cmd = 'xdg-open';
|
|
394
|
+
args = [fileUrl];
|
|
395
|
+
spawnOpts = { detached: true, stdio: 'ignore' };
|
|
390
396
|
}
|
|
391
397
|
|
|
392
|
-
|
|
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 });
|