cli/cmd/lthn-desktop/main.go
Snider 091c725036 feat(lthn-desktop): integrate Snider/Mining as native plugin
Add Mining module as a native Go plugin for lthn-desktop:

- Add github.com/Snider/Mining dependency (v0.0.9)
- Create MiningBridge that wraps the Mining service for Wails
- Implement module.GinModule interface for API route registration
- Register mining module with the Core module registry
- Provide Wails-bound methods for frontend: ListMiners, GetMinerStats,
  StartMiner, StopMiner, GetAvailableMiners, InstallMiner, UninstallMiner
- Update mining.itw3.json with native module configuration

The mining module provides:
- XMRig and TTMiner support
- Mining pool management
- Real-time hashrate monitoring
- Miner installation/uninstallation
- Mining profiles

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:17:14 +00:00

82 lines
2.4 KiB
Go

package main
import (
"embed"
"io/fs"
"log"
core "github.com/Snider/Core"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/services/notifications"
)
//go:embed all:frontend/dist/frontend/browser
var assets embed.FS
// Default MCP port for the embedded server
const mcpPort = 9877
func main() {
// Create the Core runtime with plugin support
rt, err := core.NewRuntime()
if err != nil {
log.Fatal(err)
}
// Create the notifications service for native system notifications
notifier := notifications.New()
// Wire the notifier to the display service for native notifications
rt.Display.SetNotifier(notifier)
// Create the MCP bridge for Claude Code integration
// This provides WebView access, console capture, window control, and process management
mcpBridge := NewMCPBridge(mcpPort, rt.Display)
// Create the Mining bridge for native miner management
miningBridge := NewMiningBridge()
// Register the mining module with the module registry
if err := rt.Module.Registry().RegisterGinModule(miningBridge.ModuleConfig(), miningBridge); err != nil {
log.Printf("Warning: failed to register mining module: %v", err)
}
// Collect all services including plugins
// Display service registered separately so Wails calls its Startup() for tray/window
services := []application.Service{
application.NewService(rt.Runtime),
application.NewService(rt.Display),
application.NewService(notifier), // Native notifications
application.NewService(rt.Docs),
application.NewService(rt.Config),
application.NewService(rt.I18n),
application.NewService(rt.Help),
application.NewService(rt.Crypt),
application.NewService(rt.IDE),
application.NewService(rt.Module),
application.NewService(rt.Workspace),
application.NewService(mcpBridge), // MCP Bridge for Claude Code
application.NewService(miningBridge), // Mining Bridge for native miner management
}
services = append(services, rt.PluginServices()...)
// Strip the embed path prefix so files are served from root
staticAssets, err := fs.Sub(assets, "frontend/dist/frontend/browser")
if err != nil {
log.Fatal(err)
}
app := application.New(application.Options{
Services: services,
Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(staticAssets),
},
})
log.Printf("Starting Core GUI with MCP server on port %d", mcpPort)
err = app.Run()
if err != nil {
log.Fatal(err)
}
}