evolclaw-web 1.1.0 → 1.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evolclaw-web",
3
- "version": "1.1.0",
3
+ "version": "1.2.2",
4
4
  "description": "Web-based monitoring dashboard for EvolClaw",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "dist/"
11
11
  ],
12
12
  "scripts": {
13
- "build": "tsc && node -e \"try{require('child_process').execFileSync('chmod',['+x','dist/index.js'])}catch{}\" && node -e \"const fs=require('fs'),path=require('path');fs.cpSync('src/static','dist/static',{recursive:true});const f='dist/static/index.html',n=new Date(),ts=n.getFullYear()+'-'+String(n.getMonth()+1).padStart(2,'0')+'-'+String(n.getDate()).padStart(2,'0')+' '+String(n.getHours()).padStart(2,'0')+':'+String(n.getMinutes()).padStart(2,'0');fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace(/(\\<span class=\\\"build-ts\\\"[^>]*\\>)[^<]+(\\<\\/span\\>)/,'$1'+ts+'$2'))\"",
13
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc && node -e \"try{require('child_process').execFileSync('chmod',['+x','dist/index.js'])}catch{}\" && node -e \"const fs=require('fs'),path=require('path');fs.cpSync('src/static','dist/static',{recursive:true});const f='dist/static/index.html',n=new Date(),ts=n.getFullYear()+'-'+String(n.getMonth()+1).padStart(2,'0')+'-'+String(n.getDate()).padStart(2,'0')+' '+String(n.getHours()).padStart(2,'0')+':'+String(n.getMinutes()).padStart(2,'0');fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace(/(\\<span class=\\\"build-ts\\\"[^>]*\\>)[^<]+(\\<\\/span\\>)/,'$1'+ts+'$2'))\"",
14
14
  "dev": "node dev.mjs",
15
15
  "prepublishOnly": "npm run build"
16
16
  },
@@ -1,58 +0,0 @@
1
- /**
2
- * Control 数据源 — 通过 daemon IPC 的 menu.exec 代理拉取 menu.* 当前状态。
3
- *
4
- * snapshot: 一批 menu.list + menu.query(各 name 当前值)+ menu.options(列表类)。
5
- * subscribe: 1s 轮询 + JSON diff,仅变化时 push(IPC 无推送,与 aid.ts 同款)。
6
- *
7
- * 写操作(update/action)不走这里——浏览器经 WS `menu` 消息直发,requestId 配对响应。
8
- */
9
- import { resolvePaths } from '../paths.js';
10
- import { ipcQuery } from '../ipc-client.js';
11
- // 支持 query 当前值的 name
12
- const QUERY_NAMES = ['system', 'pwd', 'baseagent', 'model', 'effort',
13
- 'chatmode', 'permission', 'activity', 'dispatch', 'session'];
14
- // 列表类(options)
15
- const OPTIONS_NAMES = ['session', 'agent', 'trigger'];
16
- async function menuExec(payload) {
17
- const p = resolvePaths();
18
- const r = await ipcQuery(p.socket, { type: 'menu.exec', payload }, 5000);
19
- return r?.ok ? r.response : null;
20
- }
21
- async function buildSnapshot() {
22
- const [listResp, ...queryResps] = await Promise.all([
23
- menuExec({ type: 'menu.list', id: 'ctrl-list' }),
24
- ...QUERY_NAMES.map((name, i) => menuExec({ type: 'menu.query', id: `ctrl-q-${i}`, name })),
25
- ]);
26
- const optResps = await Promise.all(OPTIONS_NAMES.map((name, i) => menuExec({ type: 'menu.options', id: `ctrl-o-${i}`, name })));
27
- const daemonRunning = listResp !== null;
28
- const queries = {};
29
- QUERY_NAMES.forEach((name, i) => { queries[name] = queryResps[i]; });
30
- const options = {};
31
- OPTIONS_NAMES.forEach((name, i) => { options[name] = optResps[i]; });
32
- return { daemonRunning, list: listResp, queries, options };
33
- }
34
- export const controlSource = {
35
- kind: 'control',
36
- async snapshot() {
37
- return buildSnapshot();
38
- },
39
- subscribe(_params, push) {
40
- let lastJson = '';
41
- let stopped = false;
42
- const tick = async () => {
43
- if (stopped)
44
- return;
45
- try {
46
- const snap = await buildSnapshot();
47
- const json = JSON.stringify(snap);
48
- if (json !== lastJson) {
49
- lastJson = json;
50
- push(snap);
51
- }
52
- }
53
- catch { /* ignore transient IPC errors */ }
54
- };
55
- const timer = setInterval(tick, 1000);
56
- return () => { stopped = true; clearInterval(timer); };
57
- },
58
- };