Events
robot.events
Asynchronous event bus and event types.
Event = Any
module-attribute
__all__ = ['AnimationFinished', 'BlinkRequested', 'DisplayUpdated', 'EmotionChanged', 'EmotionName', 'Event', 'FaceDetected', 'IdleTimeout', 'InMemoryEventBus', 'LookRequested', 'PersonalityChanged', 'RobotError', 'RobotStarted', 'RobotStopped', 'ServoMoved', 'SpeechRecognized', 'StateChanged', 'WakeWordDetected']
module-attribute
AnimationFinished
dataclass
BlinkRequested
dataclass
Either eye or both. left and right may be False for a wink.
Source code in src/robot/events/events.py
left = True
class-attribute
instance-attribute
right = True
class-attribute
instance-attribute
speed = 1.0
class-attribute
instance-attribute
__init__(left=True, right=True, speed=1.0)
DisplayUpdated
dataclass
EmotionChanged
dataclass
Source code in src/robot/events/events.py
current
instance-attribute
intensity = 1.0
class-attribute
instance-attribute
previous
instance-attribute
__init__(previous, current, intensity=1.0)
EmotionName
Bases: str, Enum
High-level emotional states the face engine understands.
The minimum set requested by the project spec.
Source code in src/robot/events/events.py
ANGRY = 'angry'
class-attribute
instance-attribute
CURIOUS = 'curious'
class-attribute
instance-attribute
EMBARRASSED = 'embarrassed'
class-attribute
instance-attribute
EXCITED = 'excited'
class-attribute
instance-attribute
HAPPY = 'happy'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
SURPRISED = 'surprised'
class-attribute
instance-attribute
THINKING = 'thinking'
class-attribute
instance-attribute
FaceDetected
dataclass
Source code in src/robot/events/events.py
confidence = 1.0
class-attribute
instance-attribute
known = False
class-attribute
instance-attribute
size = 0.0
class-attribute
instance-attribute
x
instance-attribute
y
instance-attribute
__init__(x, y, confidence=1.0, size=0.0, known=False)
IdleTimeout
dataclass
InMemoryEventBus
An async pub/sub bus for in-process events with handler priority.
Critical handlers have their exceptions propagated; non-critical handlers have their exceptions logged and isolated.
Source code in src/robot/events/bus.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
__init__()
__repr__()
close()
async
publish(event)
async
Publish an event to all subscribers.
Source code in src/robot/events/bus.py
subscribe(event_type, handler)
Subscribe a non-critical handler for events of event_type.
Source code in src/robot/events/bus.py
subscribe_critical(event_type, handler)
Subscribe a critical handler for events of event_type.
Source code in src/robot/events/bus.py
unsubscribe(event_type, handler)
Unsubscribe a previously-registered handler.
Source code in src/robot/events/bus.py
LookRequested
dataclass
Request a glance in a direction (normalized -1..1).
Source code in src/robot/events/events.py
duration_s = 0.3
class-attribute
instance-attribute
x = 0.0
class-attribute
instance-attribute
y = 0.0
class-attribute
instance-attribute
__init__(x=0.0, y=0.0, duration_s=0.3)
PersonalityChanged
dataclass
RobotError
dataclass
Source code in src/robot/events/events.py
component = 'unknown'
class-attribute
instance-attribute
message
instance-attribute
recoverable = True
class-attribute
instance-attribute
__init__(message, component='unknown', recoverable=True)
RobotStarted
dataclass
Source code in src/robot/events/events.py
when = field(default_factory=lambda: datetime.now(tz=UTC))
class-attribute
instance-attribute
__init__(when=(lambda: datetime.now(tz=UTC))())
RobotStopped
dataclass
Source code in src/robot/events/events.py
reason = 'shutdown'
class-attribute
instance-attribute
when = field(default_factory=lambda: datetime.now(tz=UTC))
class-attribute
instance-attribute
__init__(when=(lambda: datetime.now(tz=UTC))(), reason='shutdown')
ServoMoved
dataclass
SpeechRecognized
dataclass
Source code in src/robot/events/events.py
confidence = 1.0
class-attribute
instance-attribute
language = 'en'
class-attribute
instance-attribute
text
instance-attribute
__init__(text, confidence=1.0, language='en')
StateChanged
dataclass
Event payloads
robot.events.events
All event payload types.
Events are immutable dataclasses. New payload types must be added here so subscribers and publishers share a single source of truth.
Event = Any
module-attribute
__all__ = ['AnimationFinished', 'BlinkRequested', 'BotReply', 'DisplayUpdated', 'EmotionChanged', 'EmotionName', 'Event', 'FaceDetected', 'GestureDetected', 'HumanFeedback', 'IdleTimeout', 'LLMTokenReceived', 'LookRequested', 'PersonalityChanged', 'RobotError', 'RobotStarted', 'RobotStopped', 'ServoMoved', 'SoundEffectPlayed', 'SpeechRecognized', 'StateChanged', 'WakeWordDetected']
module-attribute
AnimationFinished
dataclass
BlinkRequested
dataclass
Either eye or both. left and right may be False for a wink.
Source code in src/robot/events/events.py
left = True
class-attribute
instance-attribute
right = True
class-attribute
instance-attribute
speed = 1.0
class-attribute
instance-attribute
__init__(left=True, right=True, speed=1.0)
BotReply
dataclass
The full text reply the robot is speaking/returning.
Published after the LLM finishes generating a response (both streaming and one-shot paths). Subscribers can use this to display the reply as text (terminal, display, WebSocket clients) when TTS is unavailable.
Source code in src/robot/events/events.py
text
instance-attribute
user_text = ''
class-attribute
instance-attribute
__init__(text, user_text='')
DisplayUpdated
dataclass
EmotionChanged
dataclass
Source code in src/robot/events/events.py
current
instance-attribute
intensity = 1.0
class-attribute
instance-attribute
previous
instance-attribute
__init__(previous, current, intensity=1.0)
EmotionName
Bases: str, Enum
High-level emotional states the face engine understands.
The minimum set requested by the project spec.
Source code in src/robot/events/events.py
ANGRY = 'angry'
class-attribute
instance-attribute
CURIOUS = 'curious'
class-attribute
instance-attribute
EMBARRASSED = 'embarrassed'
class-attribute
instance-attribute
EXCITED = 'excited'
class-attribute
instance-attribute
HAPPY = 'happy'
class-attribute
instance-attribute
NEUTRAL = 'neutral'
class-attribute
instance-attribute
SAD = 'sad'
class-attribute
instance-attribute
SLEEPY = 'sleepy'
class-attribute
instance-attribute
SURPRISED = 'surprised'
class-attribute
instance-attribute
THINKING = 'thinking'
class-attribute
instance-attribute
FaceDetected
dataclass
Source code in src/robot/events/events.py
confidence = 1.0
class-attribute
instance-attribute
known = False
class-attribute
instance-attribute
size = 0.0
class-attribute
instance-attribute
x
instance-attribute
y
instance-attribute
__init__(x, y, confidence=1.0, size=0.0, known=False)
GestureDetected
dataclass
A human hand gesture was observed (e.g. a wave).
This is an observation, never an action. It updates the learning state encoder (gesture one-hot) but does not create a transition. Today the robot has no built-in vision gesture detector, so this event is produced by a synthetic injection channel (teaching API, CLI, constrained speech parser, or a test) rather than a CV model.
Source code in src/robot/events/events.py
confidence = 1.0
class-attribute
instance-attribute
gesture
instance-attribute
x = 0.5
class-attribute
instance-attribute
y = 0.5
class-attribute
instance-attribute
__init__(gesture, confidence=1.0, x=0.5, y=0.5)
HumanFeedback
dataclass
Explicit human feedback on a recent robot action.
A post-hoc signal: the human reacts to what the robot just did. It is an
observation that the :class:~robot.learning.feedback_service.FeedbackService
attributes to the most-recent eligible transition (by recency and, when
available, interaction_id). It never creates a transition by itself and
never invents a reward — the attribution target must already exist in the
recorder's working memory, else the feedback is dropped with a log line.
Attributes
polarity:
+1 for positive ("good"), -1 for negative ("no"/"wrong").
Other integers are tolerated but the reward path clamps magnitude.
magnitude:
Strength of the feedback, multiplied with polarity to form the
reward delta. Default 1.0.
source:
Origin of the feedback ("speech", "api", "cli" …) so the
dashboard can show how feedback was given.
interaction_id:
The teaching interaction the feedback belongs to, when known. Used to
preferentially attribute feedback to a transition from the same
interaction. None for ambient feedback.
transition_id:
The transition the feedback was attributed to. Filled in by the
:class:~robot.learning.feedback_service.FeedbackService at attribution
time; None until then.
text:
The raw human utterance that produced this feedback, for auditing.
Source code in src/robot/events/events.py
interaction_id = None
class-attribute
instance-attribute
magnitude = 1.0
class-attribute
instance-attribute
polarity
instance-attribute
source = 'speech'
class-attribute
instance-attribute
text = ''
class-attribute
instance-attribute
transition_id = None
class-attribute
instance-attribute
__init__(polarity, magnitude=1.0, source='speech', interaction_id=None, transition_id=None, text='')
IdleTimeout
dataclass
LLMTokenReceived
dataclass
A single token from a streaming LLM response.
Published for each token as the LLM generates its reply, enabling real-time face animation (thinking -> speaking).
Source code in src/robot/events/events.py
done = False
class-attribute
instance-attribute
token
instance-attribute
__init__(token, done=False)
LookRequested
dataclass
Request a glance in a direction (normalized -1..1).
Source code in src/robot/events/events.py
duration_s = 0.3
class-attribute
instance-attribute
x = 0.0
class-attribute
instance-attribute
y = 0.0
class-attribute
instance-attribute
__init__(x=0.0, y=0.0, duration_s=0.3)
PersonalityChanged
dataclass
RobotError
dataclass
Source code in src/robot/events/events.py
component = 'unknown'
class-attribute
instance-attribute
message
instance-attribute
recoverable = True
class-attribute
instance-attribute
__init__(message, component='unknown', recoverable=True)
RobotStarted
dataclass
Source code in src/robot/events/events.py
when = field(default_factory=lambda: datetime.now(tz=UTC))
class-attribute
instance-attribute
__init__(when=(lambda: datetime.now(tz=UTC))())
RobotState
Bases: str, Enum
Source code in src/robot/behavior/state_machine.py
BOOT = 'boot'
class-attribute
instance-attribute
CURIOUS = 'curious'
class-attribute
instance-attribute
ERROR = 'error'
class-attribute
instance-attribute
IDLE = 'idle'
class-attribute
instance-attribute
LISTENING = 'listening'
class-attribute
instance-attribute
SLEEPING = 'sleeping'
class-attribute
instance-attribute
SPEAKING = 'speaking'
class-attribute
instance-attribute
THINKING = 'thinking'
class-attribute
instance-attribute
RobotStopped
dataclass
Source code in src/robot/events/events.py
reason = 'shutdown'
class-attribute
instance-attribute
when = field(default_factory=lambda: datetime.now(tz=UTC))
class-attribute
instance-attribute
__init__(when=(lambda: datetime.now(tz=UTC))(), reason='shutdown')
ServoMoved
dataclass
SoundEffectPlayed
dataclass
A sound effect was sent to the configured audio output.