返回 DeepSeek-Reasonix
mcp_capability_view_app.go
根目录 / desktop / mcp_capability_view_app.go
1 package main
2
3 import "reasonix/internal/plugin"
4
5 // MCPCapabilityView is one row of the four-layer MCP capability matrix shown
6 // in the MCP panel: what this desktop declares and what live sessions
7 // negotiated.
8 type MCPCapabilityView struct {
9 ID string `json:"id"`
10 Layer string `json:"layer"`
11 State string `json:"state"`
12 Negotiated bool `json:"negotiated"`
13 Detail string `json:"detail"`
14 }
15
16 type MCPCapabilityMatrixView struct {
17 Views []MCPCapabilityView `json:"views"`
18 HostProfile string `json:"hostProfile"`
19 }
20
21 // MCPCapabilityMatrix returns the active tab's MCP capability matrix plus the
22 // host profile name for the status header.
23 func (a *App) MCPCapabilityMatrix() MCPCapabilityMatrixView {
24 tab, ctrl := a.activeTabAndCtrl()
25 if tab == nil || ctrl == nil {
26 return MCPCapabilityMatrixView{}
27 }
28 capabilityViews, ok := ctrl.(interface {
29 MCPCapabilityViews() []plugin.CapabilityView
30 })
31 if !ok {
32 return MCPCapabilityMatrixView{}
33 }
34 views := capabilityViews.MCPCapabilityViews()
35 plugin.SortCapabilityViews(views)
36 out := make([]MCPCapabilityView, 0, len(views))
37 profile := ""
38 for _, v := range views {
39 out = append(out, MCPCapabilityView{
40 ID: v.ID, Layer: v.Layer, State: v.State, Negotiated: v.Negotiated, Detail: v.Detail,
41 })
42 if v.ID == plugin.CapabilityIDCore {
43 if host := ctrl.Host(); host != nil {
44 profile = host.Profile().String()
45 }
46 }
47 }
48 return MCPCapabilityMatrixView{Views: out, HostProfile: profile}
49 }
50
50 lines GO