Files
gnoma/internal/tool/sysinfo/sysinfo.go
T
vikingowl c4fde583f5 chore(lint): gofmt sweep + errcheck cleanups in router discovery
Apply gofmt -w across the codebase (struct field comment realignment
only — no semantic changes) and silence two errcheck warnings on
fmt.Sscanf / fmt.Fprintf return values in internal/router/discovery
with explicit `_, _ =` discards. Required so `make check` is green
before tagging v0.1.0.
2026-05-20 03:13:05 +02:00

53 lines
1.3 KiB
Go

package sysinfo
import (
"context"
"encoding/json"
"somegit.dev/Owlibou/gnoma/internal/tool"
"somegit.dev/Owlibou/gnoma/internal/tool/bash"
)
var paramSchema = json.RawMessage(`{
"type": "object",
"properties": {
"section": {
"type": "string",
"description": "Section to query: runtimes, packages, tools, hardware, all",
"enum": ["runtimes", "packages", "tools", "hardware", "all"]
}
}
}`)
// Tool provides queryable access to system inventory.
type Tool struct {
inventory *bash.SystemInventory
}
func New(inv *bash.SystemInventory) *Tool {
return &Tool{inventory: inv}
}
func (t *Tool) Name() string { return "system_info" }
func (t *Tool) Description() string {
return "Query system information: installed runtimes, packages, tools, hardware"
}
func (t *Tool) Parameters() json.RawMessage { return paramSchema }
func (t *Tool) IsReadOnly() bool { return true }
func (t *Tool) IsDestructive() bool { return false }
type sysInfoArgs struct {
Section string `json:"section,omitempty"`
}
func (t *Tool) Execute(_ context.Context, args json.RawMessage) (tool.Result, error) {
var a sysInfoArgs
if args != nil {
_ = json.Unmarshal(args, &a)
}
if a.Section == "" {
a.Section = "all"
}
return tool.Result{Output: t.inventory.QuerySection(a.Section)}, nil
}