Documentation
¶
Overview ¶
Package capability implements the edgeCore Capability Runtime for EAN 2.0. It defines the shared Agent / Capability / Discovery / Invoke / Event models and local runtime components (registry, dispatcher, discovery/event publishers).
Index ¶
- Constants
- Variables
- func CapabilityID(protocol, command string) string
- func DecodeBody[T any](body any) (T, error)
- func NewEventID() string
- func NewInvokeID() string
- func NewMessageID() string
- func NormalizeProtocolID(protocol string) string
- func NowMilli() int64
- func TopicEvent(agentID string) string
- func TopicEventDevice(agentID, deviceID string) string
- func TopicHeartbeat(agentID string) string
- func TopicInvoke(agentID string) string
- func TopicInvokeStatus(agentID string) string
- func TopicReply(agentID string) string
- func TopicState(agentID string) string
- func TopicStateDelta(agentID string) string
- func TopicStateGet(agentID string) string
- type Agent
- type AgentDescriptorBody
- type AgentEndpoint
- type AgentKind
- type AgentOfflineBody
- type AgentStatus
- type Bus
- type Capability
- type CapabilityCategory
- type CapabilityDescriptorBody
- type DiscoveryPublisher
- func (p *DiscoveryPublisher) HandleDiscoveryQuery(raw []byte) error
- func (p *DiscoveryPublisher) PublishAgentDescriptor() error
- func (p *DiscoveryPublisher) PublishCapabilityDescriptor() error
- func (p *DiscoveryPublisher) PublishHeartbeat() error
- func (p *DiscoveryPublisher) PublishOffline(reason string) error
- func (p *DiscoveryPublisher) PublishStartup() error
- type DiscoveryQuery
- type DiscoveryResponseBody
- type Dispatcher
- type ErrorCounter
- type Event
- type EventPublisher
- func (p *EventPublisher) Publish(evt Event) error
- func (p *EventPublisher) PublishBroadcast(evt Event) error
- func (p *EventPublisher) PublishCapabilityInvoked(capabilityID string, status InvokeStatus, metadata map[string]any) error
- func (p *EventPublisher) PublishDeviceOffline(deviceID string) error
- func (p *EventPublisher) PublishDeviceOnline(deviceID string) error
- func (p *EventPublisher) PublishPointChanged(deviceID, pointID string, value, previous any, metadata map[string]any) error
- type EventSeverity
- type Handler
- type HeartbeatBody
- type InvokeMetrics
- type InvokeMetricsSnapshot
- type InvokeOptions
- type InvokeRequest
- type InvokeResponse
- type InvokeResult
- type InvokeStatus
- type InvokeStatusQuery
- type Mapper
- type MemoryBus
- func (b *MemoryBus) IsConnected() bool
- func (b *MemoryBus) Publish(topic string, payload []byte, qos byte) error
- func (b *MemoryBus) Published() []PublishedMessage
- func (b *MemoryBus) SetConnected(v bool)
- func (b *MemoryBus) Subscribe(topic string, qos byte, handler func(topic string, payload []byte)) error
- type Message
- type MessageHeader
- type NoopBus
- type Permission
- type PublishedMessage
- type Registry
- func (r *Registry) AgentID() string
- func (r *Registry) Count() int
- func (r *Registry) Get(id string) (Capability, bool)
- func (r *Registry) GetAgent() Agent
- func (r *Registry) IDs() []string
- func (r *Registry) List() []Capability
- func (r *Registry) ListByCategory(category CapabilityCategory) []Capability
- func (r *Registry) Register(cap Capability) error
- func (r *Registry) RegisterAll(caps []Capability) error
- func (r *Registry) SetAgent(agent Agent)
- func (r *Registry) SetStatus(status AgentStatus)
- func (r *Registry) Snapshot() RegistrySnapshot
- func (r *Registry) Unregister(id string)
- type RegistrySnapshot
- type Runtime
- func (r *Runtime) Discovery() *DiscoveryPublisher
- func (r *Runtime) Dispatcher() *Dispatcher
- func (r *Runtime) Events() *EventPublisher
- func (r *Runtime) Invoke(ctx context.Context, req InvokeRequest) InvokeResponse
- func (r *Runtime) Metrics() InvokeMetricsSnapshot
- func (r *Runtime) OnConnected(ctx context.Context)
- func (r *Runtime) RegisterHandler(category CapabilityCategory, handler Handler)
- func (r *Runtime) Registry() *Registry
- func (r *Runtime) SetBus(bus Bus)
- func (r *Runtime) SetMapper(mapper Mapper)
- func (r *Runtime) Start(ctx context.Context) error
- func (r *Runtime) Stop()
- type RuntimeConfig
- type ShadowEventBridge
- type ShadowPointView
- type TransportType
- type V1Compat
- func (V1Compat) CmdDiscover(nodeID string) string
- func (V1Compat) CmdNodesRegister() string
- func (V1Compat) CmdResponse(nodeID, deviceID string) string
- func (V1Compat) CmdWrite(nodeID, deviceID string) string
- func (V1Compat) DataDevice(nodeID, deviceID string) string
- func (V1Compat) DataPoint(nodeID, deviceID, pointID string) string
- func (V1Compat) DeviceInfo(nodeID, deviceID string) string
- func (V1Compat) DeviceOffline(nodeID, deviceID string) string
- func (V1Compat) DeviceOnline(nodeID, deviceID string) string
- func (V1Compat) DevicesList(nodeID string) string
- func (V1Compat) DevicesReport() string
- func (V1Compat) EventsAlert() string
- func (V1Compat) EventsError() string
- func (V1Compat) EventsInfo() string
- func (V1Compat) Heartbeat(nodeID string) string
- func (V1Compat) NodeOffline(nodeID string) string
- func (V1Compat) NodeOnline(nodeID string) string
- func (V1Compat) NodeStatus(nodeID string) string
- func (V1Compat) NodesRegister() string
- func (V1Compat) NodesUnregister() string
- func (V1Compat) PointsDevice(nodeID, deviceID string) string
- func (V1Compat) PointsReport() string
Constants ¶
const ( TopicDiscoveryAgent = "$edgeos/discovery/agent" TopicDiscoveryAgentOffline = "$edgeos/discovery/agent/offline" TopicDiscoveryCapability = "$edgeos/discovery/capability" TopicDiscoveryService = "$edgeos/discovery/service" TopicDiscoveryQuery = "$edgeos/discovery/query" TopicDiscoveryResponse = "$edgeos/discovery/response" TopicEventBroadcast = "$edgeos/event/broadcast" TopicEventSubscribe = "$edgeos/event/subscribe" )
EAN 2.0 Topic / Subject templates ($edgeos/*). These use MQTT-style slash separators. The NATS bus adapter (edgos_nats.MqttTopicToNatsSubject) converts them to NATS-native dot-separated subjects before every Publish / Subscribe call. | EAN 2.0 Topic 模板使用 MQTT 斜杠形式。 | NATS 适配器会自动将其转换为点分隔的 NATS Subject。
const ( QoSDiscovery = byte(1) QoSInvoke = byte(1) QoSEvent = byte(1) QoSHeartbeat = byte(0) QoSQuery = byte(0) )
QoS defaults for EAN 2.0 topics.
const ( ProtocolVersion = "2.0" RuntimeVersion = "2.0.0" )
const ( MessageTypeAgentDescriptor = "agent_descriptor" MessageTypeAgentOffline = "agent_offline" MessageTypeCapabilityDescriptor = "capability_descriptor" MessageTypeDiscoveryQuery = "discovery_query" MessageTypeDiscoveryResponse = "discovery_response" MessageTypeInvokeCapability = "invoke_capability" MessageTypeInvokeResponse = "invoke_response" MessageTypeInvokeStatusQuery = "invoke_status_query" MessageTypeEvent = "event" MessageTypeHeartbeat = "agent_heartbeat" )
MessageType values used in EAN 2.0 envelopes.
Variables ¶
var KnownDriverProtocols = []string{
"modbus-tcp",
"modbus-rtu",
"modbus-rtu-over-tcp",
"bacnet-ip",
"s7",
"opc-ua",
"ethernet-ip",
"omron-fins",
"iec60870-5-104",
"knxnet-ip",
"snmp",
"dlt645",
"mitsubishi-slmp",
"profinet-io",
"ethercat",
}
KnownDriverProtocols lists edgeCore driver protocol ids used for auto-generation. Values use edgeCore driver registration names (hyphenated); they are normalized to Capability ID prefixes with underscores.
var V1 = V1Compat{}
V1 is the V1.0 compatibility topic namespace.
Functions ¶
func CapabilityID ¶
CapabilityID builds "{protocol}.{command}".
func DecodeBody ¶
func NormalizeProtocolID ¶
NormalizeProtocolID converts driver protocol names to Capability ID prefixes. Example: "modbus-tcp" → "modbus_tcp".
func TopicEvent ¶
TopicEvent returns $edgeos/event/{agentID}.
func TopicEventDevice ¶
TopicEventDevice returns $edgeos/event/{agentID}/{deviceID}.
func TopicHeartbeat ¶
TopicHeartbeat returns $edgeos/heartbeat/{agentID}.
func TopicInvoke ¶
TopicInvoke returns $edgeos/invoke/{agentID}.
func TopicInvokeStatus ¶
TopicInvokeStatus returns $edgeos/invoke/{agentID}/status.
func TopicReply ¶
TopicReply returns $edgeos/reply/{agentID}.
func TopicState ¶
TopicState returns $edgeos/state/{agentID}.
func TopicStateDelta ¶
TopicStateDelta returns $edgeos/state/{agentID}/delta.
func TopicStateGet ¶
TopicStateGet returns $edgeos/state/{agentID}/get.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
Kind AgentKind `json:"kind"`
Version string `json:"version"`
Status AgentStatus `json:"status"`
Transport TransportType `json:"transport"`
HeartbeatIntervalSec int `json:"heartbeat_interval_sec"`
Endpoint *AgentEndpoint `json:"endpoint,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Capabilities []Capability `json:"capabilities,omitempty"`
}
Agent is the EAN 2.0 unified Agent model.
type AgentDescriptorBody ¶
type AgentDescriptorBody struct {
Agent Agent `json:"agent"`
}
AgentDescriptorBody is published on discovery/agent.
type AgentEndpoint ¶
AgentEndpoint describes how peers reach the Agent.
type AgentOfflineBody ¶
type AgentOfflineBody struct {
AgentID string `json:"agent_id"`
Reason string `json:"reason,omitempty"`
}
AgentOfflineBody is published on discovery/agent/offline.
type AgentStatus ¶
type AgentStatus string
AgentStatus is the lifecycle status of an Agent.
const ( AgentStatusOnline AgentStatus = "online" AgentStatusOffline AgentStatus = "offline" AgentStatusDegraded AgentStatus = "degraded" AgentStatusError AgentStatus = "error" )
type Bus ¶
type Bus interface {
Publish(topic string, payload []byte, qos byte) error
Subscribe(topic string, qos byte, handler func(topic string, payload []byte)) error
IsConnected() bool
}
Bus is the minimal publish/subscribe transport used by Discovery / Event / Invoke publishers. MQTT and NATS northbound clients adapt to this interface.
type Capability ¶
type Capability struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
Description string `json:"description"`
Category CapabilityCategory `json:"category"`
InputSchema map[string]any `json:"input_schema,omitempty"`
OutputSchema map[string]any `json:"output_schema,omitempty"`
TimeoutSec int `json:"timeout_sec"`
Permission Permission `json:"permission"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Capability is the EAN 2.0 unified capability model.
func GenerateDefaultCapabilities ¶
func GenerateDefaultCapabilities(agentID string, protocols []string) []Capability
GenerateDefaultCapabilities builds the full default Capability set for edgeCore. Generates 63 capabilities (15 protocols x 4 ops + 3 system/AI). Used by northbound EAN Runtime for EdgeOS cross-system discovery.
func GenerateProtocolCapabilities ¶
func GenerateProtocolCapabilities(agentID, protocol string) []Capability
GenerateProtocolCapabilities auto-maps Driver commands to Capabilities for a single protocol, per EAN 2.0 auto-generation rules.
func GenerateSystemCapabilities ¶
func GenerateSystemCapabilities(agentID string) []Capability
GenerateSystemCapabilities returns built-in system/AI capabilities.
func GenerateUnifiedCapabilities ¶
func GenerateUnifiedCapabilities(agentID string) []Capability
GenerateUnifiedCapabilities builds a consolidated MCP tool set (7 tools). Replaces the 63 protocol-specific capabilities with 5 unified device operations plus 2 AI capabilities, reducing MCP tool count from 63 to 7. Used by MCP Runtime for LLM tool calling.
type CapabilityCategory ¶
type CapabilityCategory string
CapabilityCategory groups capabilities for dispatch routing.
const ( CategoryDevice CapabilityCategory = "device" CategoryAI CapabilityCategory = "ai" CategoryWorkflow CapabilityCategory = "workflow" CategorySystem CapabilityCategory = "system" )
type CapabilityDescriptorBody ¶
type CapabilityDescriptorBody struct {
Capabilities []Capability `json:"capabilities"`
}
CapabilityDescriptorBody is published on discovery/capability.
type DiscoveryPublisher ¶
type DiscoveryPublisher struct {
// contains filtered or unexported fields
}
DiscoveryPublisher publishes Agent / Capability descriptors and heartbeats.
func NewDiscoveryPublisher ¶
func NewDiscoveryPublisher(registry *Registry, bus Bus) *DiscoveryPublisher
NewDiscoveryPublisher creates a DiscoveryPublisher.
func (*DiscoveryPublisher) HandleDiscoveryQuery ¶
func (p *DiscoveryPublisher) HandleDiscoveryQuery(raw []byte) error
HandleDiscoveryQuery responds to EdgeOS discovery queries.
func (*DiscoveryPublisher) PublishAgentDescriptor ¶
func (p *DiscoveryPublisher) PublishAgentDescriptor() error
PublishAgentDescriptor publishes the Agent Descriptor to EdgeOS.
func (*DiscoveryPublisher) PublishCapabilityDescriptor ¶
func (p *DiscoveryPublisher) PublishCapabilityDescriptor() error
PublishCapabilityDescriptor publishes all local Capabilities.
func (*DiscoveryPublisher) PublishHeartbeat ¶
func (p *DiscoveryPublisher) PublishHeartbeat() error
PublishHeartbeat publishes one heartbeat tick.
func (*DiscoveryPublisher) PublishOffline ¶
func (p *DiscoveryPublisher) PublishOffline(reason string) error
PublishOffline publishes graceful offline notification.
func (*DiscoveryPublisher) PublishStartup ¶
func (p *DiscoveryPublisher) PublishStartup() error
PublishStartup performs the EAN startup discovery sequence.
type DiscoveryQuery ¶
type DiscoveryQuery struct {
QueryType string `json:"query_type"` // agent | capability | all
AgentID string `json:"agent_id,omitempty"`
CapabilityID string `json:"capability_id,omitempty"`
Category string `json:"category,omitempty"`
Keyword string `json:"keyword,omitempty"`
}
DiscoveryQuery is sent on discovery/query.
type DiscoveryResponseBody ¶
type DiscoveryResponseBody struct {
Agent *Agent `json:"agent,omitempty"`
Capabilities []Capability `json:"capabilities,omitempty"`
}
DiscoveryResponseBody is published on discovery/response.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is the unified Capability Invoke entry point.
func NewDispatcher ¶
func NewDispatcher(registry *Registry) *Dispatcher
NewDispatcher creates an Invoke Dispatcher bound to a registry.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(ctx context.Context, req InvokeRequest) InvokeResponse
Dispatch validates and executes an InvokeRequest.
func (*Dispatcher) GetStatus ¶
func (d *Dispatcher) GetStatus(invokeID string) (InvokeResponse, bool)
GetStatus returns the latest invoke record.
func (*Dispatcher) RegisterHandler ¶
func (d *Dispatcher) RegisterHandler(category CapabilityCategory, handler Handler)
RegisterHandler registers a category-level handler (device/ai/system/...).
func (*Dispatcher) SetMapper ¶
func (d *Dispatcher) SetMapper(mapper Mapper)
SetMapper installs the Capability → Driver execution mapper.
type ErrorCounter ¶
ErrorCounter tracks failure error code frequency.
type Event ¶
type Event struct {
EventID string `json:"event_id"`
EventType string `json:"event_type"`
AgentID string `json:"agent_id"`
DeviceID string `json:"device_id,omitempty"`
PointID string `json:"point_id,omitempty"`
Value any `json:"value,omitempty"`
PreviousValue any `json:"previous_value,omitempty"`
Timestamp int64 `json:"timestamp"`
Severity EventSeverity `json:"severity"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Event is the EAN 2.0 event model.
type EventPublisher ¶
type EventPublisher struct {
// contains filtered or unexported fields
}
EventPublisher publishes EAN 2.0 events to EdgeOS.
func NewEventPublisher ¶
func NewEventPublisher(agentID string, bus Bus) *EventPublisher
NewEventPublisher creates an EventPublisher for the given agent.
func (*EventPublisher) Publish ¶
func (p *EventPublisher) Publish(evt Event) error
Publish sends an Event on $edgeos/event/{agent_id} (and device topic when set).
func (*EventPublisher) PublishBroadcast ¶
func (p *EventPublisher) PublishBroadcast(evt Event) error
PublishBroadcast publishes to $edgeos/event/broadcast.
func (*EventPublisher) PublishCapabilityInvoked ¶
func (p *EventPublisher) PublishCapabilityInvoked(capabilityID string, status InvokeStatus, metadata map[string]any) error
PublishCapabilityInvoked emits capability.invoked after a successful/failed invoke.
func (*EventPublisher) PublishDeviceOffline ¶
func (p *EventPublisher) PublishDeviceOffline(deviceID string) error
PublishDeviceOffline emits device.offline.
func (*EventPublisher) PublishDeviceOnline ¶
func (p *EventPublisher) PublishDeviceOnline(deviceID string) error
PublishDeviceOnline emits device.online.
func (*EventPublisher) PublishPointChanged ¶
func (p *EventPublisher) PublishPointChanged(deviceID, pointID string, value, previous any, metadata map[string]any) error
PublishPointChanged emits "{point_id}.changed".
type EventSeverity ¶
type EventSeverity string
EventSeverity classifies event urgency.
const ( SeverityInfo EventSeverity = "info" SeverityWarning EventSeverity = "warning" SeverityError EventSeverity = "error" SeverityCritical EventSeverity = "critical" )
type Handler ¶
type Handler func(ctx context.Context, req InvokeRequest, cap Capability) (any, error)
Handler executes an Invoke for a registered Capability.
type HeartbeatBody ¶
type HeartbeatBody struct {
AgentID string `json:"agent_id"`
Status AgentStatus `json:"status"`
Timestamp int64 `json:"timestamp"`
Sequence int64 `json:"sequence"`
}
HeartbeatBody is published on heartbeat/{agent_id}.
type InvokeMetrics ¶
type InvokeMetrics struct {
TotalInvokes int64 `json:"total_invokes"`
SuccessCount int64 `json:"success_count"`
FailedCount int64 `json:"failed_count"`
TimeoutCount int64 `json:"timeout_count"`
RejectedCount int64 `json:"rejected_count"`
// 延迟统计(毫秒)| Latency statistics in milliseconds
TotalLatencyMs int64 `json:"total_latency_ms"`
MinLatencyMs int64 `json:"min_latency_ms"`
MaxLatencyMs int64 `json:"max_latency_ms"`
}
InvokeMetrics tracks EAN Invoke runtime statistics for monitoring. Thread-safe; designed for concurrent Invoke calls from HTTP/MCP/bus adapters.
type InvokeMetricsSnapshot ¶
type InvokeMetricsSnapshot struct {
TotalInvokes int64 `json:"total_invokes"`
SuccessCount int64 `json:"success_count"`
FailedCount int64 `json:"failed_count"`
TimeoutCount int64 `json:"timeout_count"`
RejectedCount int64 `json:"rejected_count"`
SuccessRate float64 `json:"success_rate"`
AvgLatencyMs float64 `json:"avg_latency_ms"`
P50LatencyMs int64 `json:"p50_latency_ms"`
P99LatencyMs int64 `json:"p99_latency_ms"`
MinLatencyMs int64 `json:"min_latency_ms"`
MaxLatencyMs int64 `json:"max_latency_ms"`
TopErrors []ErrorCounter `json:"top_errors,omitempty"`
}
InvokeMetricsSnapshot is a point-in-time copy of InvokeMetrics for API exposure.
type InvokeOptions ¶
type InvokeOptions struct {
TimeoutSec int `json:"timeout_sec,omitempty"`
Priority string `json:"priority,omitempty"`
Retry int `json:"retry,omitempty"`
Async bool `json:"async,omitempty"`
}
InvokeOptions controls Invoke execution.
type InvokeRequest ¶
type InvokeRequest struct {
InvokeID string `json:"invoke_id"`
Target string `json:"target"`
Capability string `json:"capability"`
Arguments map[string]any `json:"arguments,omitempty"`
Options InvokeOptions `json:"options,omitempty"`
}
InvokeRequest is the body of an invoke_capability message.
type InvokeResponse ¶
type InvokeResponse struct {
InvokeID string `json:"invoke_id"`
Status InvokeStatus `json:"status"`
Result InvokeResult `json:"result"`
LatencyMs int64 `json:"latency_ms,omitempty"`
}
InvokeResponse is the body of an invoke_response message.
type InvokeResult ¶
type InvokeResult struct {
Success bool `json:"success"`
Values any `json:"values,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
Error string `json:"error,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
InvokeResult is the successful or failed execution payload.
type InvokeStatus ¶
type InvokeStatus string
InvokeStatus is the Invoke state machine status.
const ( InvokeQueued InvokeStatus = "queued" InvokeRunning InvokeStatus = "running" InvokeCompleted InvokeStatus = "completed" InvokeFailed InvokeStatus = "failed" InvokeTimeout InvokeStatus = "timeout" InvokeRejected InvokeStatus = "rejected" )
type InvokeStatusQuery ¶
type InvokeStatusQuery struct {
InvokeID string `json:"invoke_id"`
}
InvokeStatusQuery requests async invoke status.
type Mapper ¶
type Mapper interface {
MapAndExecute(ctx context.Context, req InvokeRequest, cap Capability) (any, error)
}
Mapper maps a Capability Invoke to a lower-level driver/system command. Implementations live in internal/execution; this interface keeps the Capability Runtime decoupled from ScanEngine / Driver wiring.
type MemoryBus ¶
type MemoryBus struct {
// contains filtered or unexported fields
}
MemoryBus is an in-memory Bus for unit tests.
func (*MemoryBus) IsConnected ¶
func (*MemoryBus) Published ¶
func (b *MemoryBus) Published() []PublishedMessage
Published returns a copy of published messages.
func (*MemoryBus) SetConnected ¶
type Message ¶
type Message struct {
Header MessageHeader `json:"header"`
Body any `json:"body"`
}
Message is the standard EAN 2.0 envelope.
func NewEnvelope ¶
NewEnvelope builds a standard EAN 2.0 message.
func NewEnvelopeTo ¶
NewEnvelopeTo builds a directed EAN 2.0 message.
type MessageHeader ¶
type MessageHeader struct {
MessageID string `json:"message_id"`
Timestamp int64 `json:"timestamp"`
Source string `json:"source"`
Destination string `json:"destination,omitempty"`
MessageType string `json:"message_type"`
Version string `json:"version"`
CorrelationID string `json:"correlation_id,omitempty"`
RequestID string `json:"request_id,omitempty"`
}
MessageHeader is the common EAN 2.0 envelope header.
type NoopBus ¶
type NoopBus struct{}
NoopBus discards publishes and ignores subscriptions (useful for unit tests / offline).
func (NoopBus) IsConnected ¶
type Permission ¶
type Permission string
Permission is the Capability access mode.
const ( PermissionRead Permission = "read" PermissionWrite Permission = "write" PermissionReadWrite Permission = "readwrite" PermissionAdmin Permission = "admin" )
type PublishedMessage ¶
PublishedMessage records a publish for assertions.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the local Capability Registry (edgeCore Capability Runtime side).
func NewRegistry ¶
NewRegistry creates an empty registry for the given agent.
func (*Registry) Get ¶
func (r *Registry) Get(id string) (Capability, bool)
Get returns a capability by id.
func (*Registry) GetAgent ¶
GetAgent returns a copy of the current agent descriptor (without embedding all caps).
func (*Registry) List ¶
func (r *Registry) List() []Capability
List returns all registered capabilities.
func (*Registry) ListByCategory ¶
func (r *Registry) ListByCategory(category CapabilityCategory) []Capability
ListByCategory filters capabilities by category.
func (*Registry) Register ¶
func (r *Registry) Register(cap Capability) error
Register adds or replaces a capability.
func (*Registry) RegisterAll ¶
func (r *Registry) RegisterAll(caps []Capability) error
RegisterAll registers multiple capabilities.
func (*Registry) SetAgent ¶
SetAgent updates the agent descriptor fields (capabilities list is managed separately).
func (*Registry) SetStatus ¶
func (r *Registry) SetStatus(status AgentStatus)
SetStatus updates agent online status.
func (*Registry) Snapshot ¶
func (r *Registry) Snapshot() RegistrySnapshot
Snapshot builds a registry snapshot for discovery/index consumers.
func (*Registry) Unregister ¶
Unregister removes a capability by id.
type RegistrySnapshot ¶
type RegistrySnapshot struct {
AgentID string `json:"agent_id"`
LastSeen int64 `json:"last_seen"`
CapabilitiesCount int `json:"capabilities_count"`
Capabilities []string `json:"capabilities"`
Status string `json:"status"`
Version string `json:"version"`
}
RegistrySnapshot is the local/remote registry view.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is the edgeCore Capability Runtime entrypoint (EAN 2.0). EdgeOS acts as Coordination Platform; edgeCore exposes Capabilities via this runtime.
func NewRuntime ¶
func NewRuntime(cfg RuntimeConfig, bus Bus) (*Runtime, error)
NewRuntime builds a Capability Runtime with auto-generated Capabilities.
func (*Runtime) Discovery ¶
func (r *Runtime) Discovery() *DiscoveryPublisher
Discovery returns the Discovery Publisher.
func (*Runtime) Dispatcher ¶
func (r *Runtime) Dispatcher() *Dispatcher
Dispatcher returns the Invoke Dispatcher.
func (*Runtime) Events ¶
func (r *Runtime) Events() *EventPublisher
Events returns the Event Publisher.
func (*Runtime) Invoke ¶
func (r *Runtime) Invoke(ctx context.Context, req InvokeRequest) InvokeResponse
Invoke is a local (in-process) Capability Invoke entry — used by HTTP/SDK/MCP adapters.
func (*Runtime) Metrics ¶
func (r *Runtime) Metrics() InvokeMetricsSnapshot
Metrics returns a point-in-time snapshot of Invoke metrics for API exposure.
func (*Runtime) OnConnected ¶
OnConnected should be called when the northbound bus becomes connected.
func (*Runtime) RegisterHandler ¶
func (r *Runtime) RegisterHandler(category CapabilityCategory, handler Handler)
RegisterHandler registers a category handler on the dispatcher.
func (*Runtime) SetBus ¶
SetBus swaps the transport bus (e.g. when MQTT connects) and refreshes publishers.
type RuntimeConfig ¶
type RuntimeConfig struct {
AgentID string
AgentVersion string
Transport TransportType
HeartbeatIntervalSec int
Protocols []string // driver protocols to auto-register; empty = KnownDriverProtocols
Metadata map[string]any
Endpoint *AgentEndpoint
// Unified generates 7 consolidated capabilities instead of 63 protocol-specific ones.
// Used by MCP Runtime to reduce LLM tool count. Northbound EAN Runtime uses false (default).
Unified bool
}
RuntimeConfig configures the edgeCore Capability Runtime.
type ShadowEventBridge ¶
type ShadowEventBridge struct {
// contains filtered or unexported fields
}
ShadowEventBridge publishes EAN Events when Shadow point values change.
func NewShadowEventBridge ¶
func NewShadowEventBridge() *ShadowEventBridge
NewShadowEventBridge creates an empty bridge; attach publishers via AddPublisher.
func (*ShadowEventBridge) AddPublisher ¶
func (b *ShadowEventBridge) AddPublisher(pub *EventPublisher)
AddPublisher registers an EventPublisher (e.g. from MQTT/NATS Capability Runtime).
func (*ShadowEventBridge) HandleDelta ¶
func (b *ShadowEventBridge) HandleDelta(deviceID, channelID string, points map[string]ShadowPointView)
HandleDelta is the hot-path callback for ShadowCore subscribers. deviceID should be the physical device id (not shadow- prefixed).
func (*ShadowEventBridge) SetPublishers ¶
func (b *ShadowEventBridge) SetPublishers(pubs []*EventPublisher)
SetPublishers replaces the publisher list (used when runtimes reconnect).
type ShadowPointView ¶
ShadowPointView is a transport-neutral snapshot used by Shadow→Event bridging. Kept free of core/model imports so capability stays a leaf package.
type TransportType ¶
type TransportType string
TransportType is how the Agent is reachable.
const ( TransportMQTT TransportType = "mqtt" TransportNATS TransportType = "nats" TransportHTTP TransportType = "http" TransportSDK TransportType = "sdk" )
type V1Compat ¶
type V1Compat struct{}
V1Compat holds V1.0 edgeCore/* topic helpers retained as a compatibility layer. New development should prefer EAN 2.0 $edgeos/* topics above.