embodiment

package
v0.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package embodiment defines the provider-neutral body subsystem contract.

It models perceptions, body capabilities, provider-neutral actions, and the routing loop without registering LLM tools or touching hardware-specific code.

Index

Constants

View Source
const (
	RouteReasonDelivered              = "delivered"
	RouteReasonInvalidAction          = "invalid_action"
	RouteReasonProviderDisabled       = "provider_disabled"
	RouteReasonCapabilityNotSupported = "capability_not_supported"
	RouteReasonNoDispatcher           = "no_dispatcher"
	RouteReasonDispatchFailed         = "dispatch_failed"
)
View Source
const (
	GateReasonOwnerVoice  = "owner_voice"
	GateReasonObservation = "observation"
	GateReasonExternal    = "external"
	GateReasonDebounce    = "debounce"
	GateReasonRateLimited = "rate_limited"
	GateReasonDisabled    = "disabled"
)
View Source
const (
	CognitionReasonTriggered = "triggered"
	CognitionReasonSkipped   = "skipped"
	CognitionReasonInFlight  = "in_flight"
)

Variables

This section is empty.

Functions

func BuildCognitionPrompt

func BuildCognitionPrompt(percept Percept, decision GateDecision) string

func BuildSystemPromptBlock

func BuildSystemPromptBlock(percept Percept, decision GateDecision) string

func LooksLikePerceptPayload

func LooksLikePerceptPayload(provider string, payload map[string]any, knownBody bool) bool

Types

type ActionDispatcher

type ActionDispatcher interface {
	Dispatch(context.Context, ProviderDescriptor, BodyAction) error
}

type ActionKind

type ActionKind string
const (
	ActionSpeak   ActionKind = "speak"
	ActionExpress ActionKind = "express"
	ActionMove    ActionKind = "move"
	ActionLED     ActionKind = "led"
)

type ActionRouter

type ActionRouter interface {
	RouteAll(context.Context, []BodyAction, ProviderDescriptor) []RouteResult
}

type BodyAction

type BodyAction struct {
	Kind    ActionKind
	Payload map[string]any
}

func ExtractBodyActions

func ExtractBodyActions(response string) ([]BodyAction, error)

func NormalizeBodyAction

func NormalizeBodyAction(action BodyAction) (BodyAction, error)

type Capability

type Capability string
const (
	CapabilityVision     Capability = "vision"
	CapabilityHearing    Capability = "hearing"
	CapabilitySpeech     Capability = "speech"
	CapabilityExpression Capability = "expression"
	CapabilityMotion     Capability = "motion"
	CapabilityLED        Capability = "led"
)

func RequiredCapability

func RequiredCapability(kind ActionKind) (Capability, bool)

type Cognition

type Cognition struct {
	// contains filtered or unexported fields
}

func NewCognition

func NewCognition(runtime AgentRuntime, cfg CognitionConfig) *Cognition

func (*Cognition) InFlight

func (c *Cognition) InFlight(provider, sessionID string) bool

func (*Cognition) Trigger

func (c *Cognition) Trigger(ctx context.Context, percept Percept, decision GateDecision) (CognitionResult, error)

type CognitionConfig

type CognitionConfig struct {
	DefaultSessionID string
	DefaultAgent     string
	WaitTimeout      time.Duration
	ActionRouter     ActionRouter
	ProviderResolver func(string) (ProviderDescriptor, bool)
}

type CognitionResult

type CognitionResult struct {
	Triggered bool   `json:"triggered"`
	RunID     string `json:"run_id,omitempty"`
	Reason    string `json:"reason,omitempty"`
}

type Gate

type Gate struct {
	// contains filtered or unexported fields
}

func NewGate

func NewGate(cfg GateConfig) *Gate

func (*Gate) Decide

func (g *Gate) Decide(percept Percept) GateDecision

type GateConfig

type GateConfig struct {
	MinTriggerInterval            time.Duration
	MaxTriggersPerHour            int
	TriggerObservations           bool
	TriggerObservationsByProvider map[string]bool
	Now                           func() time.Time
}

type GateDecision

type GateDecision struct {
	Trigger bool     `json:"trigger"`
	Mode    GateMode `json:"mode"`
	Reason  string   `json:"reason,omitempty"`
}

type GateMode

type GateMode string
const (
	GateModeDirective   GateMode = "directive"
	GateModeObservation GateMode = "observation"
)

type IngestResult

type IngestResult struct {
	Percept         Percept         `json:"percept"`
	Decision        GateDecision    `json:"decision"`
	CognitionResult CognitionResult `json:"cognition"`
}

type MCPToolCaller

type MCPToolCaller interface {
	CallTool(context.Context, string, string, map[string]any) (tool.Result, error)
}

type MCPTransport

type MCPTransport struct {
	// contains filtered or unexported fields
}

func NewMCPTransport

func NewMCPTransport(caller MCPToolCaller, logger zerolog.Logger) *MCPTransport

func (*MCPTransport) Dispatch

func (t *MCPTransport) Dispatch(ctx context.Context, provider ProviderDescriptor, action BodyAction) error

type Modality

type Modality string
const (
	ModalityVision Modality = "vision"
	ModalityAudio  Modality = "audio"
	ModalitySensor Modality = "sensor"
)

type NormalizeOptions

type NormalizeOptions struct {
	KnownBody bool
	Now       func() time.Time
}

type Options

type Options struct {
	Runtime          AgentRuntime
	DefaultSessionID string
	DefaultAgent     string
	Now              func() time.Time
	ActionDispatcher ActionDispatcher
}

type OwnerState

type OwnerState string
const (
	OwnerOwner    OwnerState = "owner"
	OwnerStranger OwnerState = "stranger"
	OwnerUnknown  OwnerState = "unknown"
	OwnerNone     OwnerState = "none"
)

type Percept

type Percept struct {
	ID            string
	Provider      string
	Modality      Modality
	Owner         OwnerState
	Summary       string
	Labels        []string
	MediaRef      string
	Trigger       string
	Salience      float64
	SessionID     string
	ThreadID      string
	IsSelfSensory bool
	CapturedAt    time.Time
	Raw           map[string]any
}

func NormalizePercept

func NormalizePercept(provider string, payload map[string]any, opts NormalizeOptions) (Percept, error)

type ProviderDescriptor

type ProviderDescriptor struct {
	Name         string
	Capabilities []Capability
	Enabled      bool
	Transport    Transport
	Endpoint     string
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() *Registry

func (*Registry) CapabilitiesOf

func (r *Registry) CapabilitiesOf(name string) []Capability

func (*Registry) Empty

func (r *Registry) Empty() bool

func (*Registry) Enabled

func (r *Registry) Enabled() []ProviderDescriptor

func (*Registry) Get

func (r *Registry) Get(name string) (ProviderDescriptor, bool)

func (*Registry) Register

func (r *Registry) Register(desc ProviderDescriptor) error

type RouteResult

type RouteResult struct {
	Action             BodyAction `json:"action"`
	Provider           string     `json:"provider,omitempty"`
	RequiredCapability Capability `json:"required_capability,omitempty"`
	Delivered          bool       `json:"delivered"`
	Dropped            bool       `json:"dropped"`
	Reason             string     `json:"reason,omitempty"`
	Error              string     `json:"error,omitempty"`
}

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(dispatcher ActionDispatcher, logger zerolog.Logger) *Router

func (*Router) Route

func (r *Router) Route(ctx context.Context, action BodyAction, provider ProviderDescriptor) RouteResult

func (*Router) RouteAll

func (r *Router) RouteAll(ctx context.Context, actions []BodyAction, provider ProviderDescriptor) []RouteResult

type Status

type Status struct {
	Enabled   bool
	Providers []ProviderDescriptor
}

type Subsystem

type Subsystem struct {
	// contains filtered or unexported fields
}

func New

func NewWithOptions

func NewWithOptions(cfg config.EmbodimentConfig, logger zerolog.Logger, opts Options) *Subsystem

func (*Subsystem) IngestPayload

func (s *Subsystem) IngestPayload(ctx context.Context, provider string, payload map[string]any) (IngestResult, error)

func (*Subsystem) IngestPercept

func (s *Subsystem) IngestPercept(ctx context.Context, percept Percept) (IngestResult, error)

func (*Subsystem) KnownProvider

func (s *Subsystem) KnownProvider(provider string) bool

func (*Subsystem) Start

func (s *Subsystem) Start(ctx context.Context) error

func (*Subsystem) Status

func (s *Subsystem) Status() Status

func (*Subsystem) Stop

func (s *Subsystem) Stop()

type Transport

type Transport string
const (
	TransportMCP     Transport = "mcp"
	TransportWebhook Transport = "webhook"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL