// Package wire converts internal domain objects into the public wire shapes // defined in pkg/client. It is the single serialization point: the HTTP // handler and the MCP adapter both go through it, so a capability looks the // same on every surface Hexis exposes. package wire import ( "github.com/kami/hexis/internal/domain" "github.com/kami/hexis/pkg/client" ) // Capability converts a domain capability into the public wire shape. // // Both `capability_id` and `id` are populated with the same value; see the // compatibility note on client.Capability for why the alias is retained. func Capability(c *domain.Capability) client.Capability { if c == nil { return client.Capability{} } targetTypes := c.TargetTypes if targetTypes == nil { targetTypes = []string{} } return client.Capability{ CapabilityID: c.ID, ID: c.ID, Name: c.Name, Description: c.Description, TargetTypes: targetTypes, TargetEntityID: c.TargetEntityID, Provider: c.Provider, Operation: c.Operation, Risk: c.Risk, ReadOnly: c.ReadOnly, ExpectedSideEffects: c.ExpectedSideEffects, RequiresConfirmation: c.RequiresConfirmation, Enabled: c.Enabled, TimeoutSeconds: c.TimeoutSeconds, Attributes: c.Attributes, CreatedAt: c.CreatedAt, UpdatedAt: c.UpdatedAt, Version: c.Version, } } // Capabilities converts a slice, never returning nil so the JSON encoding is // `[]` rather than `null`. func Capabilities(caps []*domain.Capability) []client.Capability { out := make([]client.Capability, 0, len(caps)) for _, c := range caps { out = append(out, Capability(c)) } return out }