- Replace provider dashboard with full chat UI (history, model selection, image attachments) - Add chat settings/history/image queue/tool-call metadata persistence - Add core://settings and core://store route handling in display package - Add progressive assistant rendering, collapsible thinking/tool-call blocks - Add markdown/code rendering with copy actions and lightbox image preview - Add app mode detection (pkg/display/mode.go) - Add chat backend coverage (pkg/display/chat_test.go) - Add chat.service.ts frontend service - AX sweep across pkg/mcp tools and pkg/window/webview/systray/notification Co-Authored-By: Virgil <virgil@lethean.io>
74 lines
2.4 KiB
Go
74 lines
2.4 KiB
Go
// pkg/mcp/tools_environment.go
|
|
package mcp
|
|
|
|
import (
|
|
"context"
|
|
|
|
"dappco.re/go/core/gui/pkg/environment"
|
|
coreerr "forge.lthn.ai/core/go-log"
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
// --- theme_get ---
|
|
|
|
type ThemeGetInput struct{}
|
|
type ThemeGetOutput struct {
|
|
Theme environment.ThemeInfo `json:"theme"`
|
|
}
|
|
|
|
func (s *Subsystem) themeGet(_ context.Context, _ *mcp.CallToolRequest, _ ThemeGetInput) (*mcp.CallToolResult, ThemeGetOutput, error) {
|
|
result, _, err := s.core.QUERY(environment.QueryTheme{})
|
|
if err != nil {
|
|
return nil, ThemeGetOutput{}, err
|
|
}
|
|
theme, ok := result.(environment.ThemeInfo)
|
|
if !ok {
|
|
return nil, ThemeGetOutput{}, coreerr.E("mcp.themeGet", "unexpected result type", nil)
|
|
}
|
|
return nil, ThemeGetOutput{Theme: theme}, nil
|
|
}
|
|
|
|
// --- theme_system ---
|
|
|
|
type ThemeSystemInput struct{}
|
|
type ThemeSystemOutput struct {
|
|
Info environment.EnvironmentInfo `json:"info"`
|
|
}
|
|
|
|
func (s *Subsystem) themeSystem(_ context.Context, _ *mcp.CallToolRequest, _ ThemeSystemInput) (*mcp.CallToolResult, ThemeSystemOutput, error) {
|
|
result, _, err := s.core.QUERY(environment.QueryInfo{})
|
|
if err != nil {
|
|
return nil, ThemeSystemOutput{}, err
|
|
}
|
|
info, ok := result.(environment.EnvironmentInfo)
|
|
if !ok {
|
|
return nil, ThemeSystemOutput{}, coreerr.E("mcp.themeSystem", "unexpected result type", nil)
|
|
}
|
|
return nil, ThemeSystemOutput{Info: info}, nil
|
|
}
|
|
|
|
// --- theme_set ---
|
|
|
|
type ThemeSetInput struct {
|
|
Theme string `json:"theme"`
|
|
}
|
|
type ThemeSetOutput struct {
|
|
Success bool `json:"success"`
|
|
}
|
|
|
|
func (s *Subsystem) themeSet(_ context.Context, _ *mcp.CallToolRequest, input ThemeSetInput) (*mcp.CallToolResult, ThemeSetOutput, error) {
|
|
_, _, err := s.core.PERFORM(environment.TaskSetTheme{Theme: input.Theme})
|
|
if err != nil {
|
|
return nil, ThemeSetOutput{}, err
|
|
}
|
|
return nil, ThemeSetOutput{Success: true}, nil
|
|
}
|
|
|
|
// --- Registration ---
|
|
|
|
func (s *Subsystem) registerEnvironmentTools(server *mcp.Server) {
|
|
mcp.AddTool(server, &mcp.Tool{Name: "theme_get", Description: "Get the current application theme"}, s.themeGet)
|
|
mcp.AddTool(server, &mcp.Tool{Name: "theme_set", Description: "Override the application theme to light, dark, or system"}, s.themeSet)
|
|
mcp.AddTool(server, &mcp.Tool{Name: "theme_system", Description: "Get system environment and theme information"}, s.themeSystem)
|
|
mcp.AddTool(server, &mcp.Tool{Name: "theme_set", Description: "Set the application theme override"}, s.themeSet)
|
|
}
|