evolclaw-web 1.0.1 → 1.1.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/dist/server.js +162 -3
- package/dist/sources/aid.js +1 -1
- package/dist/sources/cache.js +43 -0
- package/dist/sources/control.js +58 -0
- package/dist/sources/stats.js +348 -0
- package/dist/sources/system.js +51 -0
- package/dist/sources/triggers.js +54 -0
- package/dist/sources/types.js +1 -1
- package/dist/static/app.js +921 -17
- package/dist/static/index.html +95 -3
- package/dist/static/style.css +253 -1
- package/package.json +3 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System 数据源 — 纯进程级看板。
|
|
3
|
+
*
|
|
4
|
+
* snapshot: menu.list(探活)+ menu.query name=system(version/fastaunVersion/uptime/pid/node)。
|
|
5
|
+
* 另注入 ecwebVersion(ECWeb 进程自身 package.json 版本,由 server.ts 合并,不走 daemon IPC)。
|
|
6
|
+
* check / upgrade 结果不在快照里——由前端按钮触发 menu.action 后写入 state。
|
|
7
|
+
*
|
|
8
|
+
* subscribe: 3s 轮询 + JSON diff,仅变化时 push。
|
|
9
|
+
*/
|
|
10
|
+
import { resolvePaths } from '../paths.js';
|
|
11
|
+
import { ipcQuery } from '../ipc-client.js';
|
|
12
|
+
async function menuExec(payload) {
|
|
13
|
+
const p = resolvePaths();
|
|
14
|
+
const r = await ipcQuery(p.socket, { type: 'menu.exec', payload }, 5000);
|
|
15
|
+
return r?.ok ? r.response : null;
|
|
16
|
+
}
|
|
17
|
+
async function buildSnapshot() {
|
|
18
|
+
const [listResp, sysResp] = await Promise.all([
|
|
19
|
+
menuExec({ type: 'menu.list', id: 'sys-list' }),
|
|
20
|
+
menuExec({ type: 'menu.query', id: 'sys-q', name: 'system' }),
|
|
21
|
+
]);
|
|
22
|
+
const daemonRunning = listResp !== null;
|
|
23
|
+
// sysResp 形如 { type:'menu.response', id, name, data | error }
|
|
24
|
+
const system = sysResp?.data ?? null;
|
|
25
|
+
return { daemonRunning, system, upgrade: null, check: null };
|
|
26
|
+
}
|
|
27
|
+
export const systemSource = {
|
|
28
|
+
kind: 'system',
|
|
29
|
+
async snapshot() {
|
|
30
|
+
return buildSnapshot();
|
|
31
|
+
},
|
|
32
|
+
subscribe(_params, push) {
|
|
33
|
+
let lastJson = '';
|
|
34
|
+
let stopped = false;
|
|
35
|
+
const tick = async () => {
|
|
36
|
+
if (stopped)
|
|
37
|
+
return;
|
|
38
|
+
try {
|
|
39
|
+
const snap = await buildSnapshot();
|
|
40
|
+
const json = JSON.stringify(snap);
|
|
41
|
+
if (json !== lastJson) {
|
|
42
|
+
lastJson = json;
|
|
43
|
+
push(snap);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch { /* ignore transient IPC errors */ }
|
|
47
|
+
};
|
|
48
|
+
const timer = setInterval(tick, 3000);
|
|
49
|
+
return () => { stopped = true; clearInterval(timer); };
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triggers 数据源 — 按 agent 钻取触发器。
|
|
3
|
+
*
|
|
4
|
+
* snapshot:
|
|
5
|
+
* - agents: menu.options name=agent(agent 列表,同 Agents 页数据源)
|
|
6
|
+
* - triggers: 选中 agent 时 menu.options name=trigger(带 options=all),并带 agent 参数解析其 triggerManager
|
|
7
|
+
*
|
|
8
|
+
* subscribe: 2s 轮询 + JSON diff,仅变化时 push。
|
|
9
|
+
*/
|
|
10
|
+
import { resolvePaths } from '../paths.js';
|
|
11
|
+
import { ipcQuery } from '../ipc-client.js';
|
|
12
|
+
async function menuExec(payload) {
|
|
13
|
+
const p = resolvePaths();
|
|
14
|
+
const r = await ipcQuery(p.socket, { type: 'menu.exec', payload }, 5000);
|
|
15
|
+
return r?.ok ? r.response : null;
|
|
16
|
+
}
|
|
17
|
+
async function buildSnapshot(params) {
|
|
18
|
+
const agent = params?.agent ?? null;
|
|
19
|
+
const [agentsResp, triggersResp] = await Promise.all([
|
|
20
|
+
menuExec({ type: 'menu.options', id: 'tr-agents', name: 'agent' }),
|
|
21
|
+
agent
|
|
22
|
+
? menuExec({ type: 'menu.options', id: 'tr-list', name: 'trigger', args: { options: 'all' }, agent })
|
|
23
|
+
: Promise.resolve(null),
|
|
24
|
+
]);
|
|
25
|
+
// menu.options 响应形如 { type:'menu.response', id, name, data: MenuItem[] }
|
|
26
|
+
const agents = Array.isArray(agentsResp?.data) ? agentsResp.data : [];
|
|
27
|
+
const triggers = Array.isArray(triggersResp?.data) ? triggersResp.data : [];
|
|
28
|
+
return { agents, triggers, selectedAgent: agent };
|
|
29
|
+
}
|
|
30
|
+
export const triggersSource = {
|
|
31
|
+
kind: 'triggers',
|
|
32
|
+
async snapshot(params) {
|
|
33
|
+
return buildSnapshot(params ?? {});
|
|
34
|
+
},
|
|
35
|
+
subscribe(params, push) {
|
|
36
|
+
let lastJson = '';
|
|
37
|
+
let stopped = false;
|
|
38
|
+
const tick = async () => {
|
|
39
|
+
if (stopped)
|
|
40
|
+
return;
|
|
41
|
+
try {
|
|
42
|
+
const snap = await buildSnapshot(params);
|
|
43
|
+
const json = JSON.stringify(snap);
|
|
44
|
+
if (json !== lastJson) {
|
|
45
|
+
lastJson = json;
|
|
46
|
+
push(snap);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch { /* ignore transient IPC errors */ }
|
|
50
|
+
};
|
|
51
|
+
const timer = setInterval(tick, 2000);
|
|
52
|
+
return () => { stopped = true; clearInterval(timer); };
|
|
53
|
+
},
|
|
54
|
+
};
|