@iamsamyiok/agents-chat 3.26.0 → 3.28.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/app/lib/store.js CHANGED
@@ -5,7 +5,11 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
  const safejson = require('./safejson');
7
7
 
8
- const ROOT = path.join(__dirname, '..', '..');
8
+ // 数据目录基准:单文件 exe(构建时 --define 注入 AGENTS_CHAT_STANDALONE=1)= exe 所在目录(便携,数据随身);
9
+ // 源码/npm 运行 = 项目根目录。AGENTS_CHAT_DATA 显式指定时优先。
10
+ let ROOT;
11
+ if (process.env.AGENTS_CHAT_STANDALONE === '1' && process.execPath) ROOT = path.dirname(process.execPath);
12
+ else ROOT = path.join(__dirname, '..', '..');
9
13
  const DATA_DIR = process.env.AGENTS_CHAT_DATA || path.join(ROOT, '.data');
10
14
  const CONFIG_PATH = path.join(DATA_DIR, 'config.json');
11
15
  const TASKS_PATH = path.join(DATA_DIR, 'tasks.json');
@@ -1024,11 +1024,19 @@ function renderUpdateInfo(data){
1024
1024
  if(document.getElementById('updateBar')) return;
1025
1025
  const bar=document.createElement('div');
1026
1026
  bar.id='updateBar'; bar.className='update-bar';
1027
+ if(data.standalone){
1028
+ // 单文件 exe:无 npm,引导去 GitHub Releases 下载覆盖
1029
+ bar.innerHTML='📦 发现新版本 <b>v'+esc(data.latestVersion)+'</b>(当前 v'+esc(data.version)+'):请到 GitHub Releases 下载最新版覆盖安装 <button id="updateOpen">打开放下载页</button>';
1030
+ document.body.prepend(bar);
1031
+ document.body.style.paddingTop='34px';
1032
+ $('#updateOpen').onclick=()=>window.open('https://github.com/iamsamyiok/agents-chat/releases/latest','_blank');
1033
+ return;
1034
+ }
1027
1035
  bar.innerHTML='📦 发现新版本 <b>v'+esc(data.latestVersion)+'</b>(当前 v'+esc(data.version)+'):终端运行 <code>agents-chat update</code> 一键升级,或执行 <code>'+esc(data.updateCommand)+'</code>'
1028
1036
  +' <button id="updateCopy">复制升级命令</button>';
1029
1037
  document.body.prepend(bar);
1030
1038
  document.body.style.paddingTop='34px';
1031
- $('#updateCopy').onclick=()=>copyText(data.updateCommand||('npm install -g @iamsamyiok/agents-chat@latest'));
1039
+ $('#updateCopy').onclick=()=>copyText(data.updateCommand||('npm install -g agents-chat-cli@latest'));
1032
1040
  }
1033
1041
  $('#trashEmpty').onclick=async()=>{ if(!confirm('确认清空垃圾桶?所有快照及其过程日志将被永久删除,不可恢复。'))return; const r=await post('/api/cards/trash/empty'); toast('已清空 '+r.cleared+' 项'); await loadCards(); };
1034
1042
 
@@ -3260,10 +3260,18 @@ function renderUpdateInfo(health) {
3260
3260
  const bar = document.createElement('div');
3261
3261
  bar.id = 'updateBar';
3262
3262
  bar.style.cssText = 'position:fixed;top:0;left:0;right:0;z-index:60;background:#fffbe6;border-bottom:1px solid #ffe58f;color:#614700;font-size:12.5px;padding:7px 14px;display:flex;align-items:center;gap:8px;flex-wrap:wrap';
3263
+ if (health.standalone) {
3264
+ // 单文件 exe:无 npm,引导去 GitHub Releases 下载覆盖
3265
+ bar.innerHTML = `📦 发现新版本 <b>v${esc(health.latestVersion)}</b>(当前 v${esc(health.version)}):请到 GitHub Releases 下载最新版覆盖安装 <button id="updateOpen" style="border:1px solid #d8b94a;background:#fff;border-radius:5px;padding:2px 10px;font-size:12px;cursor:pointer;color:#614700">打开放下载页</button>`;
3266
+ document.body.prepend(bar);
3267
+ document.body.style.paddingTop = '34px';
3268
+ document.getElementById('updateOpen').onclick = () => window.open('https://github.com/iamsamyiok/agents-chat/releases/latest', '_blank');
3269
+ return;
3270
+ }
3263
3271
  bar.innerHTML = `📦 发现新版本 <b>v${esc(health.latestVersion)}</b>(当前 v${esc(health.version)}):终端运行 <code>agents-chat update</code> 一键升级,或执行 <code>${esc(health.updateCommand)}</code> <button id="updateCopy" style="border:1px solid #d8b94a;background:#fff;border-radius:5px;padding:2px 10px;font-size:12px;cursor:pointer;color:#614700">复制升级命令</button>`;
3264
3272
  document.body.prepend(bar);
3265
3273
  document.body.style.paddingTop = '34px';
3266
- document.getElementById('updateCopy').onclick = () => copyText(health.updateCommand || 'npm install -g @iamsamyiok/agents-chat@latest');
3274
+ document.getElementById('updateCopy').onclick = () => copyText(health.updateCommand || 'npm install -g agents-chat-cli@latest');
3267
3275
  }
3268
3276
 
3269
3277
  function openHelp() {
package/app/server.js CHANGED
@@ -107,7 +107,20 @@ function readBody(req) {
107
107
  });
108
108
  }
109
109
 
110
+ // 单文件 exe(bun compile)构建时由 scripts/build-exe.js 生成,内嵌全部页面资源;
111
+ // npm/源码运行时该文件不存在 → 走磁盘,开发模式改页面即时生效
112
+ let EMBEDDED_ASSETS = null;
113
+ try { EMBEDDED_ASSETS = require('./lib/embedded-assets'); } catch { /* 开发模式 */ }
114
+ const IS_STANDALONE = process.env.AGENTS_CHAT_STANDALONE === '1' || !!process.versions.bun; // 单文件 exe 形态(构建期注入标识)
115
+ const RELEASES_URL = 'https://github.com/iamsamyiok/agents-chat/releases/latest';
116
+
110
117
  function serveStatic(res, filePath) {
118
+ const base = path.basename(filePath);
119
+ if (EMBEDDED_ASSETS && EMBEDDED_ASSETS[base] !== undefined) {
120
+ res.writeHead(200, { 'Content-Type': MIME[path.extname(filePath)] || 'text/html; charset=utf-8' });
121
+ res.end(EMBEDDED_ASSETS[base]);
122
+ return;
123
+ }
111
124
  fs.readFile(filePath, (err, data) => {
112
125
  if (err) {
113
126
  res.writeHead(404);
@@ -310,7 +323,8 @@ const server = http.createServer(async (req, res) => {
310
323
  version: APP_VERSION,
311
324
  latestVersion: upd ? upd.latest : '',
312
325
  updateAvailable: upd ? upd.updateAvailable : false,
313
- updateCommand: upd && upd.updateAvailable ? UPDATE_COMMAND : '',
326
+ updateCommand: upd && upd.updateAvailable && !IS_STANDALONE ? UPDATE_COMMAND : '',
327
+ standalone: IS_STANDALONE,
314
328
  runner: runner.kind,
315
329
  kernelLabel: runner.kernel ? runner.kernel.label : '',
316
330
  kernelCmd: runner.cmd || '',
@@ -985,7 +999,7 @@ const server = http.createServer(async (req, res) => {
985
999
  success: true, cards, running: cardRunner.isRunning(), maxParallel: cardRunner.maxP(), msgCounts: counts, config: CardStore.getConfig(),
986
1000
  followupIds: cardRunner.getFollowupIds(), runner: runnerInfo, corrupted: getCorruptedFiles(),
987
1001
  version: APP_VERSION, latestVersion: upd ? upd.latest : '', updateAvailable: upd ? upd.updateAvailable : false,
988
- updateCommand: upd && upd.updateAvailable ? UPDATE_COMMAND : ''
1002
+ updateCommand: upd && upd.updateAvailable && !IS_STANDALONE ? UPDATE_COMMAND : '', standalone: IS_STANDALONE
989
1003
  });
990
1004
  return;
991
1005
  }
@@ -1484,9 +1498,24 @@ server.listen(PORT, () => {
1484
1498
  if (upd && upd.updateAvailable) {
1485
1499
  console.log(`──────────────────────────────────────────────`);
1486
1500
  console.log(`📦 发现新版本 v${upd.latest}(当前 v${APP_VERSION})`);
1487
- console.log(` 命令行一键升级: agents-chat update`);
1488
- console.log(` 或手动执行: ${UPDATE_COMMAND}`);
1501
+ if (IS_STANDALONE) {
1502
+ console.log(` 单文件版:请到 GitHub Releases 下载最新版覆盖`);
1503
+ console.log(` ${RELEASES_URL}`);
1504
+ } else {
1505
+ console.log(` 命令行一键升级: agents-chat update`);
1506
+ console.log(` 或手动执行: ${UPDATE_COMMAND}`);
1507
+ }
1489
1508
  console.log(`──────────────────────────────────────────────`);
1490
1509
  }
1491
1510
  }).catch(() => { /* ignore */ });
1511
+ // 单文件 exe 直接双击运行:自动打开浏览器(AGENTS_CHAT_NO_OPEN=1 可关闭;npm 版由 CLI 开,避免重复)
1512
+ if (IS_STANDALONE && process.env.AGENTS_CHAT_NO_OPEN !== '1') {
1513
+ try {
1514
+ const { exec } = require('child_process');
1515
+ const url = `http://localhost:${PORT}`;
1516
+ const cmd = process.platform === 'win32' ? `start "" "${url}"`
1517
+ : process.platform === 'darwin' ? `open "${url}"` : `xdg-open "${url}"`;
1518
+ setTimeout(() => { try { exec(cmd, () => {}); } catch { /* ignore */ } }, 600);
1519
+ } catch { /* ignore */ }
1520
+ }
1492
1521
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iamsamyiok/agents-chat",
3
- "version": "3.26.0",
4
- "description": "多智能体群聊工具 - 支持 OpenCode/Claude Code/Codex/pi 内核,微信风格聊天界面",
3
+ "version": "3.28.1",
4
+ "description": "多智能体群聊工具 - 支持 OpenCode/Claude Code/Codex/pi 内核,微信风格聊天界面 (旧包名,推荐迁移: npm i -g agents-chat-cli)",
5
5
  "main": "lib/start.js",
6
6
  "bin": {
7
7
  "agents-chat": "./bin/agents-chat.js"
@@ -34,6 +34,7 @@
34
34
  "homepage": "https://github.com/iamsamyiok/agents-chat",
35
35
  "scripts": {
36
36
  "start": "node app/server.js",
37
- "test": "node --test \"test/*.test.js\""
37
+ "test": "node --test \"test/*.test.js\"",
38
+ "build:exe": "node scripts/build-exe.js"
38
39
  }
39
- }
40
+ }