gomcp/internal/application/tools/system_service.go
DmitrL-dev 694e32be26 refactor: rename identity to syntrex, add root orchestration and CI/CD
- Rename Go module: sentinel-community/gomcp -> syntrex/gomcp (50+ files)
- Rename npm package: sentinel-dashboard -> syntrex-dashboard
- Update Cargo.toml repository URL to syntrex/syntrex
- Update all doc references from DmitrL-dev/AISecurity to syntrex
- Add root Makefile (build-all, test-all, lint-all, clean-all)
- Add MIT LICENSE
- Add .editorconfig (Go/Rust/TS/C cross-language)
- Add .github/workflows/ci.yml (Go + Rust + Dashboard)
- Add dashboard next.config.ts and .env.example
- Clean ARCHITECTURE.md: remove brain/immune/strike/micro-swarm, fix 61->67 engines
2026-03-11 15:30:49 +10:00

94 lines
2.2 KiB
Go

package tools
import (
"context"
"fmt"
"runtime"
"time"
"github.com/syntrex/gomcp/internal/domain/memory"
)
// Version info set at build time via ldflags.
var (
Version = "2.0.0-dev"
GitCommit = "unknown"
BuildDate = "unknown"
)
// SystemService implements MCP tool logic for system operations.
type SystemService struct {
factStore memory.FactStore
startTime time.Time
}
// NewSystemService creates a new SystemService.
func NewSystemService(factStore memory.FactStore) *SystemService {
return &SystemService{
factStore: factStore,
startTime: time.Now(),
}
}
// HealthStatus holds the health check result.
type HealthStatus struct {
Status string `json:"status"`
Version string `json:"version"`
GoVersion string `json:"go_version"`
Uptime string `json:"uptime"`
OS string `json:"os"`
Arch string `json:"arch"`
}
// Health returns server health status.
func (s *SystemService) Health(_ context.Context) *HealthStatus {
return &HealthStatus{
Status: "healthy",
Version: Version,
GoVersion: runtime.Version(),
Uptime: time.Since(s.startTime).Round(time.Second).String(),
OS: runtime.GOOS,
Arch: runtime.GOARCH,
}
}
// VersionInfo holds version information.
type VersionInfo struct {
Version string `json:"version"`
GitCommit string `json:"git_commit"`
BuildDate string `json:"build_date"`
GoVersion string `json:"go_version"`
}
// GetVersion returns version information.
func (s *SystemService) GetVersion() *VersionInfo {
return &VersionInfo{
Version: Version,
GitCommit: GitCommit,
BuildDate: BuildDate,
GoVersion: runtime.Version(),
}
}
// DashboardData holds summary data for the system dashboard.
type DashboardData struct {
Health *HealthStatus `json:"health"`
FactStats *memory.FactStoreStats `json:"fact_stats,omitempty"`
}
// Dashboard returns a summary of all system metrics.
func (s *SystemService) Dashboard(ctx context.Context) (*DashboardData, error) {
data := &DashboardData{
Health: s.Health(ctx),
}
if s.factStore != nil {
stats, err := s.factStore.Stats(ctx)
if err != nil {
return nil, fmt.Errorf("get fact stats: %w", err)
}
data.FactStats = stats
}
return data, nil
}