Files
HomeAgent/internal/plugins/webui/handler_terminal.go
JianFeeeee 4e70b8d5d8 refactor(module): 核心仓 Go module 路径改为 github.com/JianFeeeee/HologramAgent
批 1,不含 SDK 仓与目录改名。

- go.mod 第 1 行 module 路径
- 366 个 .go 文件的完整前缀 github.com/JianFeeeee/HomeAgent 机械替换
  (857 处,仅完整前缀;展示名/注释里的 HomeAgent 字样留给批 5)
- 未改:third_party 目录名、SDK 自身 go.mod module、go.mod replace 目标、
  homed/waiter 可执行名、.hmap 后缀
2026-10-21 12:17:19 +08:00

44 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package webui
import (
"net/http"
sdk "github.com/JianFeeeee/HologramAgent/internal/sdk"
)
// 终端面:终端会话列表与命令历史接口。
//
// 职责边界(2026-10-20 调整):终端状态归 agentcli,内核**不**再维护终端语义
// (旧的 internal/agent/core/terminal_registry.go 已删除)。WebUI 在
// NewHandler 里订阅事件总线(EventTerminalOutput + EventToolCall)攒自己的视图,
// CLI 用同一份 internal/pluginview 实现,两个插件的解析口径一致。
//
// 为什么不塞进 KernelStatus:那是全量快照,前端每 3 秒轮询 /kernel,
// 把每终端最多 64KB 的输出缓冲背进去会让轮询成本爆炸。
// handleTerminals 返回终端会话快照(本插件从事件总线攒的视图)。
func (h *Handler) handleTerminals(w http.ResponseWriter, r *http.Request) {
if h.termView == nil {
writeJSON(w, http.StatusOK, map[string]interface{}{"terminals": []interface{}{}})
return
}
terms, _ := h.termView.Snapshot()
if terms == nil {
terms = []sdk.TerminalStatus{}
}
writeJSON(w, http.StatusOK, map[string]interface{}{"terminals": terms})
}
// handleCmdHistory 返回命令执行历史快照(本插件从事件总线攒的视图)。
func (h *Handler) handleCmdHistory(w http.ResponseWriter, r *http.Request) {
if h.termView == nil {
writeJSON(w, http.StatusOK, map[string]interface{}{"history": []interface{}{}})
return
}
_, cmds := h.termView.Snapshot()
if cmds == nil {
cmds = []sdk.CmdExecStatus{}
}
writeJSON(w, http.StatusOK, map[string]interface{}{"history": cmds})
}