mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-06 17:27:31 +00:00
refactor(plugins): 按「内置插件判定标准」收敛内置清单 16 → 11
## 判定标准(写进 all.go 与 ARCHITECTURE) **只有必须使用内部 SDK 能力(公开 SDK 没有的接口面)的插件,才留在 编译期内置清单**;其余一律外置为 .hmap 插件,独立编译、独立发版。 依据是 internal/plugin/proc/capability.go 的 withheldCapabilities: 内部 SDK 的 TerminalAPI/TrackerAPI/StatusAPI/SupervisorAPI/AdapterAPI/ SelftestAPI/ToolAPI/Publish 等能力面,外部插件在类型层就不存在。 需要它们的插件外置后功能会**静默消失**(不报错),必须内置; 只要公开能力的插件,留在内核里是白付重编成本。 ## 内置 11 个(all.go 单一权威清单) cli webui TerminalAPI/Tracker/Status/Supervisor/Adapter agentcli EventPublish(终端输出走 Publish,公开 SDK 无此方法) healthcheck SelftestAPI pluginmgr failback 恢复链必需 seq ToolAPI remotedevice RegisterChannel clawhubadapter InjectInputSync cfgmgr skillmgr seemedia(保留) ## 外置 8 个(源码保留,.hmap 由 SDK 仓 example/ 提供) timer(此前)ai_image files cmd kbtree localuse mcp multimodal ## 同步修正 - kbtree 归位:它一直是编译期内置插件,却长期被 main.go 单独导入, 游离在 all.go 清单之外(文档盘点因此数错)。现移入 all.go, main.go 不再单独导入任何插件,并加注释禁止该做法。 - integration_test:外置插件的 7 个用例(cmd_run/terminal_*)加 requireExternalTool 跳过保护——用例保留(行为判据仍有价值), 在纯内置装配下 Skip,不造假失败。 - 全部文档同步 11 个的清单与判定标准(中英四份 + 两份 README)。 ## 已核实不做的事 - 保留的 11 个内置插件无一在代码里硬依赖被外置的插件: cli 对 terminal_* 是 ExecuteTool 按名动态调用(运行时依赖); healthcheck/seq 只在白名单与示例文本里出现;webui 只订阅事件。 - kernelmod/(内核模块)与 plugins/(插件)严格区分: kernelmod/multimodal 是内核装配模块,与外置的 multimodal 插件无关。 验证:go build ./... 全绿;go test ./internal/plugins/... 全绿; webui 新增 5 条命令历史渲染回归判据(TestCmdHistory*)全绿。
This commit is contained in:
@ -4987,50 +4987,106 @@ function renderTerminals() {
|
||||
}
|
||||
|
||||
function renderCmdHistory() {
|
||||
// 面板标题是「命令历史」,数据源必须是 cmd_run 的执行记录
|
||||
// (/api/v1/cmd/history → 内核 TerminalRegistry.CmdHistory)。
|
||||
//
|
||||
// ★ 旧实现渲染的是**终端列表**(state.terminals 里 running 的那些),
|
||||
// 而 loadCmdHistory() 拉回来的 state.cmdHistory **从未被读过** ——
|
||||
// 于是面板名叫「命令历史」,实际只显示运行中的终端:
|
||||
// · 已完成的命令(绝大多数)永远不出现,用户以为命令没执行;
|
||||
// · 终端的 uptime 被当成命令时长,语义也对不上。
|
||||
// 现在分两段:先列 cmd_run 历史(带退出码/输出),再列运行中的终端。
|
||||
var r = document.getElementById("cmd-list");
|
||||
var cnt = document.getElementById("cmd-count-badge");
|
||||
if (!r) return;
|
||||
|
||||
var history = state.cmdHistory || [];
|
||||
var running = (state.terminals || []).filter((t) => t.running);
|
||||
if (cnt) cnt.textContent = running.length;
|
||||
if (running.length === 0) {
|
||||
if (cnt) cnt.textContent = String(history.length + running.length);
|
||||
|
||||
if (history.length === 0 && running.length === 0) {
|
||||
r.innerHTML =
|
||||
'<p style="color:var(--text-muted);padding:8px;text-align:center;font-size:11px">' +
|
||||
__("暂无运行中的命令", "No running commands") +
|
||||
__("暂无命令记录", "No command history") +
|
||||
"</p>";
|
||||
return;
|
||||
}
|
||||
var html =
|
||||
'<table style="font-size:10px"><tr><th>' +
|
||||
__("命令", "Command") +
|
||||
"</th><th>" +
|
||||
__("状态", "Status") +
|
||||
"</th><th>" +
|
||||
__("运行时长", "Uptime") +
|
||||
"</th></tr>";
|
||||
running.forEach((t) => {
|
||||
var scr = (state.termScreens && state.termScreens[t.id]) || null;
|
||||
var out = scr ? scr.output : t.output || "";
|
||||
|
||||
var html = "";
|
||||
|
||||
if (history.length > 0) {
|
||||
html +=
|
||||
"<tr>" +
|
||||
'<td style="font-family:monospace;max-width:200px;overflow:hidden;text-overflow:ellipsis">' +
|
||||
escHtml(t.command || t.id || "") +
|
||||
"</td>" +
|
||||
'<td><span class="badge badge-green">' +
|
||||
__("运行中", "Running") +
|
||||
"</span></td>" +
|
||||
'<td style="color:var(--text-muted);white-space:nowrap">' +
|
||||
escHtml(t.uptime || "-") +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
if (out) {
|
||||
'<table style="font-size:10px"><tr><th>' +
|
||||
__("命令", "Command") +
|
||||
"</th><th>" +
|
||||
__("状态", "Status") +
|
||||
"</th><th>" +
|
||||
__("时间", "Time") +
|
||||
"</th></tr>";
|
||||
// 新的在上:内核按时间正序追加,用户最关心最近一条。
|
||||
history
|
||||
.slice()
|
||||
.reverse()
|
||||
.forEach((c) => {
|
||||
var ok = (c.status || "").toLowerCase() === "ok" || c.exit_code === 0;
|
||||
var badge = ok ? "badge-green" : "badge-red";
|
||||
var label = ok
|
||||
? __("成功", "OK")
|
||||
: __("失败", "Failed") + (c.exit_code ? " (" + c.exit_code + ")" : "");
|
||||
html +=
|
||||
"<tr>" +
|
||||
'<td style="font-family:monospace;max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">' +
|
||||
escHtml(c.command || "-") +
|
||||
"</td>" +
|
||||
'<td><span class="badge ' +
|
||||
badge +
|
||||
'">' +
|
||||
escHtml(label) +
|
||||
"</span></td>" +
|
||||
'<td style="color:var(--text-muted);white-space:nowrap">' +
|
||||
escHtml(c.time || "-") +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
// 输出按需展开:默认收起,避免长输出把面板撑爆。
|
||||
var out = (c.stdout || "") + (c.stderr ? "\n" + c.stderr : "");
|
||||
out = out.trim();
|
||||
if (out) {
|
||||
html +=
|
||||
'<tr><td colspan="3" style="padding:0 0 4px 0">' +
|
||||
'<pre style="margin:0;padding:4px 8px;max-height:120px;overflow:auto;background:var(--bg-input);border-radius:4px;font-size:10px;color:var(--text-secondary);white-space:pre-wrap">' +
|
||||
escHtml(out.substring(0, 2000)) +
|
||||
(out.length > 2000 ? "\n… (truncated)" : "") +
|
||||
"</pre></td></tr>";
|
||||
}
|
||||
});
|
||||
html += "</table>";
|
||||
}
|
||||
|
||||
if (running.length > 0) {
|
||||
html +=
|
||||
'<div style="margin-top:8px;font-size:10px;color:var(--text-muted)">' +
|
||||
__("运行中的终端", "Running terminals") +
|
||||
"</div>";
|
||||
html +=
|
||||
'<table style="font-size:10px"><tr><th>' +
|
||||
__("命令", "Command") +
|
||||
"</th><th>" +
|
||||
__("运行时长", "Uptime") +
|
||||
"</th></tr>";
|
||||
running.forEach((t) => {
|
||||
html +=
|
||||
"<tr>" +
|
||||
'<td colspan="3" style="padding:0"><pre style="margin:0;padding:4px 8px;max-height:120px;overflow:auto;background:var(--bg-input);border-radius:4px;font-size:10px;color:var(--text-secondary)">' +
|
||||
escHtml(out.substring(0, 2000)) +
|
||||
"</pre></td></tr>";
|
||||
}
|
||||
});
|
||||
html += "</table>";
|
||||
'<td style="font-family:monospace;max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">' +
|
||||
escHtml(t.command || t.id || "") +
|
||||
"</td>" +
|
||||
'<td style="color:var(--text-muted);white-space:nowrap">' +
|
||||
escHtml(t.uptime || "-") +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
});
|
||||
html += "</table>";
|
||||
}
|
||||
|
||||
r.innerHTML = html;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user