@yeaft/webchat-agent 0.1.224 → 0.1.226

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.
@@ -1,46 +0,0 @@
1
- // 加载 .env 文件
2
- const fs = require('fs');
3
- const path = require('path');
4
-
5
- function loadEnv() {
6
- const agentDir = path.join(__dirname, '..');
7
- const envPath = path.join(agentDir, '.env');
8
- const env = { NODE_ENV: 'production' };
9
-
10
- if (fs.existsSync(envPath)) {
11
- const content = fs.readFileSync(envPath, 'utf-8');
12
- for (const line of content.split('\n')) {
13
- const match = line.match(/^\s*([^#][^=]*)\s*=\s*(.*)$/);
14
- if (match) {
15
- const key = match[1].trim();
16
- let value = match[2].trim();
17
- // 移除引号
18
- value = value.replace(/^["']|["']$/g, '');
19
- env[key] = value;
20
- }
21
- }
22
- }
23
- return env;
24
- }
25
-
26
- module.exports = {
27
- apps: [{
28
- name: 'claude-agent',
29
- script: 'cli.js',
30
- cwd: path.join(__dirname, '..'),
31
- // 从 .env 文件加载环境变量
32
- env: loadEnv(),
33
- // 自动重启配置
34
- autorestart: true,
35
- watch: false,
36
- max_restarts: 10,
37
- restart_delay: 5000,
38
- // 日志配置
39
- log_date_format: 'YYYY-MM-DD HH:mm:ss',
40
- error_file: 'logs/error.log',
41
- out_file: 'logs/out.log',
42
- merge_logs: true,
43
- // 内存超限自动重启
44
- max_memory_restart: '500M',
45
- }]
46
- };
@@ -1,59 +0,0 @@
1
- # Claude Agent PM2 托管启动脚本
2
- # 用法: .\pm2-start.ps1
3
-
4
- $ErrorActionPreference = "Stop"
5
- $AgentDir = Split-Path -Parent $MyInvocation.MyCommand.Path
6
-
7
- # 切换到 agent 目录
8
- Set-Location $AgentDir
9
-
10
- # 检查 pm2 是否安装
11
- $pm2Path = Get-Command pm2 -ErrorAction SilentlyContinue
12
- if (-not $pm2Path) {
13
- Write-Host "Installing pm2 globally..." -ForegroundColor Yellow
14
- npm install -g pm2
15
- # Windows 上需要安装 pm2-windows-startup
16
- npm install -g pm2-windows-startup
17
- }
18
-
19
- # 安装依赖 (每次都检查确保完整)
20
- Write-Host "Checking dependencies..." -ForegroundColor Yellow
21
- npm install --silent
22
- if ($LASTEXITCODE -ne 0) {
23
- Write-Host "Failed to install dependencies!" -ForegroundColor Red
24
- exit 1
25
- }
26
-
27
- # 检查 .env 文件
28
- if (-not (Test-Path ".env")) {
29
- Write-Host "No .env file found. Creating from .env.example..." -ForegroundColor Yellow
30
- if (Test-Path ".env.example") {
31
- Copy-Item ".env.example" ".env"
32
- Write-Host "Please edit .env with your configuration, then run this script again." -ForegroundColor Red
33
- exit 1
34
- } else {
35
- Write-Host "No .env.example found!" -ForegroundColor Red
36
- exit 1
37
- }
38
- }
39
-
40
- # 启动 pm2
41
- Write-Host ""
42
- Write-Host "Starting Claude Agent with pm2..." -ForegroundColor Green
43
- pm2 start ecosystem.config.cjs
44
-
45
- Write-Host ""
46
- Write-Host "Agent started!" -ForegroundColor Green
47
- Write-Host ""
48
- Write-Host "Management commands:" -ForegroundColor Cyan
49
- Write-Host " pm2 status - Check status"
50
- Write-Host " pm2 logs claude-agent - View logs (follow mode)"
51
- Write-Host " pm2 logs claude-agent --lines 100 - View last 100 lines"
52
- Write-Host " pm2 stop claude-agent - Stop agent"
53
- Write-Host " pm2 restart claude-agent - Restart agent"
54
- Write-Host " pm2 delete claude-agent - Remove from pm2"
55
- Write-Host ""
56
- Write-Host "To enable startup on Windows boot:" -ForegroundColor Yellow
57
- Write-Host " 1. pm2 save"
58
- Write-Host " 2. pm2-startup install"
59
- Write-Host ""
@@ -1,36 +0,0 @@
1
- # 启动 Claude Agent (pm2 托管) + 托盘图标
2
- $AgentDir = Split-Path -Parent $MyInvocation.MyCommand.Path
3
- Set-Location $AgentDir
4
-
5
- # 检查 pm2
6
- $pm2 = Get-Command pm2 -ErrorAction SilentlyContinue
7
- if (-not $pm2) {
8
- Write-Host "Installing pm2..." -ForegroundColor Yellow
9
- npm install -g pm2
10
- }
11
-
12
- # 检查并安装 pm2-logrotate
13
- $logrotateInstalled = pm2 list 2>$null | Select-String "pm2-logrotate"
14
- if (-not $logrotateInstalled) {
15
- Write-Host "Installing pm2-logrotate..." -ForegroundColor Yellow
16
- pm2 install pm2-logrotate
17
- # 配置 logrotate
18
- pm2 set pm2-logrotate:max_size 10M
19
- pm2 set pm2-logrotate:retain 7
20
- pm2 set pm2-logrotate:compress true
21
- Write-Host "pm2-logrotate configured (max 10MB, keep 7 files)" -ForegroundColor Cyan
22
- }
23
-
24
- # 先停止已有进程,确保干净启动
25
- Write-Host "Checking existing processes..." -ForegroundColor Gray
26
- pm2 delete claude-agent 2>$null | Out-Null
27
-
28
- # 启动 agent
29
- Write-Host "Starting Claude Agent..." -ForegroundColor Green
30
- pm2 start ecosystem.config.cjs
31
-
32
- # 启动托盘(隐藏窗口)
33
- Write-Host "Starting tray icon..." -ForegroundColor Green
34
- Start-Process powershell -ArgumentList "-WindowStyle Hidden -File `"$AgentDir\agent-tray.ps1`"" -WindowStyle Hidden
35
-
36
- Write-Host "Done! Check the system tray." -ForegroundColor Green