@iamsamyiok/agents-chat 3.28.1 → 3.29.0
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/app/server.js +21 -0
- package/package.json +2 -2
package/app/server.js
CHANGED
|
@@ -8,6 +8,27 @@ const path = require('path');
|
|
|
8
8
|
const url = require('url');
|
|
9
9
|
const { spawn } = require('child_process');
|
|
10
10
|
|
|
11
|
+
// 单文件 exe 无控制台(--windows-hide-console)时 stdout 可能不可写:
|
|
12
|
+
// 把 console.* 重定向到数据目录 agents-chat.log(>2MB 滚动到 .1),出错有迹可循。
|
|
13
|
+
// 必须在任何 console 调用前执行;仅 standalone 形态且写入探测失败时启用。
|
|
14
|
+
(function setupHeadlessLogging() {
|
|
15
|
+
if (process.env.AGENTS_CHAT_STANDALONE !== '1') return;
|
|
16
|
+
let writable = true;
|
|
17
|
+
try { if (!process.stdout || typeof process.stdout.write !== 'function') writable = false; else process.stdout.write(''); }
|
|
18
|
+
catch { writable = false; }
|
|
19
|
+
if (writable) return;
|
|
20
|
+
try {
|
|
21
|
+
const dir = process.env.AGENTS_CHAT_DATA || path.join(path.dirname(process.execPath), '.data');
|
|
22
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
23
|
+
const logPath = path.join(dir, 'agents-chat.log');
|
|
24
|
+
try { if (fs.statSync(logPath).size > 2 * 1024 * 1024) fs.renameSync(logPath, logPath + '.1'); } catch { /* 新文件 */ }
|
|
25
|
+
const stream = fs.createWriteStream(logPath, { flags: 'a' });
|
|
26
|
+
const fmt = (args) => args.map(a => typeof a === 'string' ? a : (() => { try { return JSON.stringify(a); } catch { return String(a); } })()).join(' ') + '\n';
|
|
27
|
+
console.log = (...a) => { try { stream.write(fmt(a)); } catch { /* ignore */ } };
|
|
28
|
+
console.warn = console.error = console.log;
|
|
29
|
+
} catch { /* 日志系统自身失败:静默,服务照常 */ }
|
|
30
|
+
})();
|
|
31
|
+
|
|
11
32
|
// 首先加载 .env(根目录,行为开关配置)
|
|
12
33
|
const { loadEnv } = require('./lib/env');
|
|
13
34
|
const ROOT_DIR = path.join(__dirname, '..');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iamsamyiok/agents-chat",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "多智能体群聊工具 - 支持 OpenCode/Claude Code/Codex/pi 内核,微信风格聊天界面
|
|
3
|
+
"version": "3.29.0",
|
|
4
|
+
"description": "多智能体群聊工具 - 支持 OpenCode/Claude Code/Codex/pi 内核,微信风格聊天界面",
|
|
5
5
|
"main": "lib/start.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"agents-chat": "./bin/agents-chat.js"
|