xiaohongshu
xiaohongshu
event-flow
Add new events to Bob The Skull's event-driven architecture. Use when creating new events, event publishers, event handlers, or extending the event system with new event types.
Full skill instructions
Adds new events to Bob The Skull's event-driven architecture, ensuring all publishers and subscribers are properly connected.
Bob The Skull uses a central EventBus for all inter-component communication:
Component A → publish(Event) → EventBus → deliver → Component B.on_event()
No direct method calls between components! Everything goes through events.
from dataclasses import dataclass, field
from datetime import datetime
from typing import Dict, Any, Optional
@dataclass
class YourEvent:
"""Published when [describe condition that triggers event]"""
param1: type # Description
param2: type # Description
optional_data: Optional[Dict[str, Any]] = None
timestamp: datetime = field(default_factory=datetime.now)
State Change Events:
@dataclass
class ComponentStateChangedEvent:
"""Component changed state"""
component: str
old_state: str
new_state: str
timestamp: datetime = field(default_factory=datetime.now)
Detection Events:
@dataclass
class ThingDetectedEvent:
"""Thing was detected"""
confidence: float
location: tuple
detector_id: str
data: Dict[str, Any]
timestamp: datetime = field(default_factory=datetime.now)
Request/Response Events:
@dataclass
class ProcessRequestEvent:
"""Request to process something"""
request_id: str
input_data: Any
timestamp: datetime = field(default_factory=datetime.now)
@dataclass
class ProcessResponseEvent:
"""Response to process request"""
request_id: str
result: Any
success: bool
timestamp: datetime = field(default_factory=datetime.now)
In component code:
from events import YourEvent
class YourComponent:
def __init__(self, event_bus):
self.event_bus = event_bus
def do_something(self):
# When condition occurs, publish event
event = YourEvent(
param1=value1,
param2=value2
)
self.event_bus.publish(event)
logger.info(f"Published YourEvent: {event}")
In component code:
from events import YourEvent
class YourComponent:
def __init__(self, event_bus):
self.event_bus = event_bus
# Subscribe to event during initialization
self.event_bus.subscribe(YourEvent, self.on_your_event)
def on_your_event(self, event: YourEvent):
"""Handle YourEvent"""
logger.info(f"Received YourEvent: {event}")
# Process event
self.do_something_with(event.param1, event.param2)
State machine is a special subscriber that coordinates system behavior:
# In state_machine/state_machine.py
def _setup_event_handlers(self):
"""Subscribe to events"""
self.event_bus.subscribe(YourEvent, self.on_your_event)
def on_your_event(self, event: YourEvent):
"""Handle YourEvent in state machine"""
logger.info(f"State machine received: {event}")
# Check current state
if self.current_state == State.WAITING:
# Transition to new state
self._transition_to(State.PROCESSING)
# Trigger actions
self._handle_processing(event)
When adding a new event:
events.pyevent_bus.publish(YourEvent(...))event_bus.subscribe(YourEvent, self.on_event)def on_your_event(self, event: YourEvent):Find where event is published:
grep -r "YourEvent(" .
Find where event is subscribed:
grep -r "subscribe.*YourEvent" .
Find event handlers:
grep -r "def on_your_event" .
*DetectedEvent, *ClearedEvent*RecognizedEvent, *DetectedEvent*ResponseEvent, *ToolCallEvent*StatusEvent, *ErrorEventBob uses two event bus implementations:
LocalEventBus - In-process pub/sub
from local_event_bus import LocalEventBus
event_bus = LocalEventBus()
MQTTEventBus - Distributed pub/sub
from mqtt_event_bus import MQTTEventBus
event_bus = MQTTEventBus(broker="192.168.1.44")
Both implement the same interface:
publish(event) - Send eventsubscribe(event_type, handler) - Register handlerunsubscribe(event_type, handler) - Remove handlerCore events in events.py:
WakeWordDetectedEvent - Wake word heardSpeechRecognizedEvent - Speech transcribedLLMResponseReadyEvent - LLM response availableLLMToolCallEvent - LLM wants to call toolTTSStartedEvent / TTSCompletedEvent - TTS lifecycleFaceDetectedEvent / FaceIdentifiedEvent - Vision eventsMotionDetectedEvent / MotionClearedEvent - Motion eventsStateChangedEvent - State machine transitionsEvent Names:
ThingDetected, not DetectThingEvent: FaceDetectedEventDetected, not DetectHandler Names:
on_: on_face_detectedon_speech_recognizedFaceDetectedEvent → on_face_detectedEnable event logging:
# In LocalEventBus or MQTTEventBus
logger.setLevel(logging.DEBUG)
Trace event flow:
# In event_bus.py
def publish(self, event):
logger.debug(f"Publishing: {type(event).__name__} to {len(self.subscribers.get(type(event), []))} subscribers")
# ... publish logic
Check subscriptions:
# In component
logger.info(f"Subscribed to: {[t.__name__ for t in self.event_bus.subscribers.keys()]}")
field(default_factory=datetime.now)xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience