Documentation
¶
Index ¶
- func MustRegister(cmd Command)
- func MustRegisterHandler(name string, handler HandlerFunc)
- func Register(cmd Command) error
- func RegisterHandler(name string, handler HandlerFunc) error
- func Run(ctx context.Context, name string, input any) (any, error)
- type Command
- type Example
- type HandlerFunc
- type ListResponse
- type RESTBinding
- type Registry
- type SafetyLevel
- type SchemaRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegister ¶
func MustRegister(cmd Command)
MustRegister registers a command or panics on failure.
func MustRegisterHandler ¶
func MustRegisterHandler(name string, handler HandlerFunc)
MustRegisterHandler registers a handler or panics on failure.
func RegisterHandler ¶
func RegisterHandler(name string, handler HandlerFunc) error
RegisterHandler registers a handler for a command in the default registry.
Types ¶
type Command ¶
type Command struct {
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category,omitempty"`
Input *SchemaRef `json:"input,omitempty"`
Output *SchemaRef `json:"output,omitempty"`
REST *RESTBinding `json:"rest,omitempty"`
Examples []Example `json:"examples,omitempty"`
SafetyLevel SafetyLevel `json:"safety_level,omitempty"`
EmitsEvents []string `json:"emits_events,omitempty"`
Idempotent bool `json:"idempotent,omitempty"`
}
Command describes a kernel command with metadata for CLI/TUI/REST.
type Example ¶
type Example struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Command string `json:"command,omitempty"`
Input string `json:"input,omitempty"`
Output string `json:"output,omitempty"`
}
Example provides a usage example for OpenAPI and documentation.
type HandlerFunc ¶
HandlerFunc executes a command with the provided input.
type ListResponse ¶
ListResponse is the output schema for listing registered commands.
type RESTBinding ¶
type RESTBinding struct {
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
}
RESTBinding describes the REST endpoint mapping for a command.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores command metadata for CLI/TUI/REST surfaces.
func (*Registry) RegisterHandler ¶
func (r *Registry) RegisterHandler(name string, handler HandlerFunc) error
RegisterHandler associates a handler with a registered command.
type SafetyLevel ¶
type SafetyLevel string
SafetyLevel indicates the operational risk of a command.
const ( SafetySafe SafetyLevel = "safe" SafetyCaution SafetyLevel = "caution" SafetyDanger SafetyLevel = "danger" )
type SchemaRef ¶
type SchemaRef struct {
Name string `json:"name,omitempty"`
Ref string `json:"ref,omitempty"`
Description string `json:"description,omitempty"`
}
SchemaRef points to an input or output schema used by a command. Ref should be a stable identifier (e.g., a Go type name or JSON Schema ref).