@myassis/gateway 1.0.17 → 1.0.19

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/dist/cli.js CHANGED
@@ -37,8 +37,16 @@ CORS 管理命令:
37
37
  其他:
38
38
  --version, -v 显示版本号
39
39
  --help, -h 显示本帮助信息
40
+ --verbose 显示运行时详细日志
40
41
  `);
41
42
  process.exit(0);
42
43
  }
44
+ // 静默模式:非启动服务类命令(install/uninstall/status/start/stop/restart/update)
45
+ // 默认静默日志,除非传 --verbose
46
+ const quietCommands = ['install', 'uninstall', 'status', 'start', 'stop', 'restart', 'update'];
47
+ const command = args.find(a => !a.startsWith('-'));
48
+ if (command && quietCommands.includes(command) && !args.includes('--verbose')) {
49
+ process.env.LOG_LEVEL = 'error';
50
+ }
43
51
  // 需要加载模块的命令,导入主程序
44
52
  import('./main.js');
@@ -9,16 +9,10 @@ export const SERVICE_NAME = 'myassis-gateway';
9
9
  export const SERVICE_DISPLAY_NAME = '我的助手 Desktop Gateway Service';
10
10
  // ─── 平台无关工具 ────────────────────────────────────────────
11
11
  function getServiceScript() {
12
- // pkg 环境
13
- const execDir = path.dirname(process.execPath);
14
- const pkgScript = path.join(execDir, 'gateway', 'dist', 'index.js');
15
- if (fs.existsSync(pkgScript))
16
- return pkgScript;
17
- // 开发模式
18
- const devScript = path.join(process.cwd(), 'dist', 'index.js');
19
- if (fs.existsSync(devScript))
20
- return devScript;
21
- return pkgScript;
12
+ // npm install -g 后,用当前模块位置定位包目录
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const pkgRoot = path.resolve(path.dirname(__filename), '..', '..');
15
+ return path.join(pkgRoot, 'dist', 'index.js');
22
16
  }
23
17
  function getNodeExec() {
24
18
  return process.execPath;
@@ -122,15 +116,16 @@ async function stopServiceWindows() {
122
116
  async function queryServiceLinux() {
123
117
  try {
124
118
  const { stdout } = await execAsync(`systemctl is-active ${SERVICE_NAME}`, { timeout: 5000 });
125
- const running = stdout.trim() === 'active';
126
- return { installed: true, running };
119
+ const status = stdout.trim();
120
+ return { installed: true, running: status === 'active' };
127
121
  }
128
122
  catch (err) {
129
- const code = err.code;
130
- if (code === 4)
123
+ // exit code 3 = 未找到服务(未安装)
124
+ if (err.code === 3)
131
125
  return { installed: false, running: false };
132
- const msg = err.stdout?.toString() || '';
133
- if (msg.trim() === 'inactive' || msg.trim() === 'failed') {
126
+ // exit code 0 inactive
127
+ const msg = (err.stdout?.toString() || '').trim();
128
+ if (msg === 'inactive' || msg === 'failed') {
134
129
  return { installed: true, running: false };
135
130
  }
136
131
  return { installed: false, running: false };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myassis/gateway",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "我的助手 Gateway Service - 本地 AI 网关服务,支持认证、WebSocket 实时通信和任务调度",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -13,8 +13,7 @@
13
13
  "scripts",
14
14
  "README.md",
15
15
  "LICENSE",
16
- "migrations",
17
- "dist/.env"
16
+ "migrations"
18
17
  ],
19
18
  "exports": {
20
19
  ".": {