From 91c25fa5363e72d5feb5259aba5e81843132be5b Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Tue, 15 Sep 2026 14:29:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(cli):=20/runtime=20=E6=8E=A5=E4=B8=8A?= =?UTF-8?q?=EF=BC=88runtime=20=E6=9C=AC=E5=B0=B1=E7=BB=8F=20KernelStatus?= =?UTF-8?q?=20=E5=AF=B9=E5=86=85=E9=83=A8=E6=8F=92=E4=BB=B6=E5=BC=80?= =?UTF-8?q?=E6=94=BE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 纠正上一轮的判断:runtime 不是“SDK 未暴露”。s.Status().GetKernelStatus() 里的 Scheduler / Residents / Channels / InputChannels 就是 WebUI /runtime 的数据源,内部插件同样拿得到——CLI 只是漏接了这条命令。 - CLI 插件新增 /runtime,输出与 GET /api/v1/runtime 同口径。 - waiter 侧 /runtime 在 local(发 CLI 插件)与 remote(走 REST)两条路都接上,/help 补齐。 --- cmd/waiter/builtin.go | 10 ++++++++++ internal/plugins/cli/plugin.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/cmd/waiter/builtin.go b/cmd/waiter/builtin.go index a11c035..0ff9acc 100644 --- a/cmd/waiter/builtin.go +++ b/cmd/waiter/builtin.go @@ -46,6 +46,7 @@ Server commands (local 与 remote 行为一致): /adapters list loaded Lua adapters /adapters remove remove a Lua adapter /network network status + LLM endpoints + /runtime scheduler / residents / channel topology /agents list agents /chat send to agent @@ -329,6 +330,15 @@ Any other text is sent to the agent directly.`) } return true + case cmd == "/runtime": + if rc := state.RemoteConn(); rc != nil { + d, _ := rc.DoAPI("GET", "/api/v1/runtime", "") + printJSON(out, d) + } else { + state.Send("/runtime") + } + return true + case cmd == "/network": if rc := state.RemoteConn(); rc != nil { d, _ := rc.DoAPI("GET", "/api/v1/network", "") diff --git a/internal/plugins/cli/plugin.go b/internal/plugins/cli/plugin.go index c5e61d6..68ac47f 100644 --- a/internal/plugins/cli/plugin.go +++ b/internal/plugins/cli/plugin.go @@ -315,6 +315,8 @@ func (p *Plugin) handleBuiltin(conn net.Conn, line string, s *sdk.PluginSDK) boo p.cmdAdapters(conn, parts, s) case "/network": p.cmdNetwork(conn, s) + case "/runtime": + p.cmdRuntime(conn, s) default: return false } @@ -351,6 +353,7 @@ func (p *Plugin) cmdHelp(conn net.Conn) { /adapters 列出已加载的 Lua 适配器 /adapters remove 卸载适配器 /network 网络状态与 LLM 端点 + /runtime 调度器/驻留子/通道拓扑快照 /agents 当前 Agent 信息 其他文本直接发送给 Agent 处理。`, @@ -823,6 +826,34 @@ func (p *Plugin) cmdAdapters(conn net.Conn, parts []string, s *sdk.PluginSDK) { writeJSONContent(conn, map[string]interface{}{"adapters": ad.List()}) } +// ======== /runtime ======== + +// cmdRuntime 与 WebUI 的 GET /api/v1/runtime 同口径。 +// +// 数据来自 SDK 已经对内部插件开放的 KernelStatus(s.Status().GetKernelStatus()), +// 不是 WebUI 专属:Scheduler / Residents / Channels / InputChannels 都在里面。 +// 之前 CLI 没接这一条,是漏接,不是没开放。 +func (p *Plugin) cmdRuntime(conn net.Conn, s *sdk.PluginSDK) { + st := s.Status() + if st == nil { + writeLine(conn, map[string]interface{}{"type": "error", "error": "status provider not available"}) + return + } + ks := st.GetKernelStatus() + if ks == nil { + writeLine(conn, map[string]interface{}{"type": "error", "error": "kernel status not available"}) + return + } + writeJSONContent(conn, map[string]interface{}{ + "uptime": ks.Uptime, + "agent_id": ks.AgentID, + "scheduler": ks.Scheduler, + "residents": ks.Residents, + "channels": ks.Channels, + "input_channels": ks.InputChannels, + }) +} + // ======== /network ======== // cmdNetwork 与 WebUI 的 GET /api/v1/network 同口径:网络状态 + LLM 端点。