Event bus for agent coordination.
Agents and processes subscribe to topics and receive messages when events occur. Workshop auto-publishes lifecycle events; you can also publish custom events.
Auto-published events
{:agent, :ask_complete, agent_name, result}
{:agent, :cast_complete, agent_name, result}
{:agent, :error, agent_name, reason}
{:agent, :created, agent_name}
{:agent, :dismissed, agent_name}
{:agent, :reset, agent_name}
{:store, :put, key}
{:store, :delete, key}
{:store, :clear}Usage from IEx
# Subscribe the current process
AgentWorkshop.PubSub.subscribe(:agent_events)
# Publish a custom event
AgentWorkshop.PubSub.broadcast(:deploy_ready, %{sha: "abc123"})
# Receive (in IEx or a GenServer)
receive do
{:workshop_event, topic, event} -> IO.inspect(event)
endUsage in agents
Agents don't subscribe directly (they're CLI subprocesses). Instead, use periodic tasks (#9) or the work board (#16) for reactive patterns. PubSub is primarily for BEAM processes: LiveView dashboards, custom GenServers, telemetry handlers.
Summary
Functions
Broadcast an event to all subscribers of the :all topic
and to subscribers of the event's specific topic.
Broadcast an event to a specific topic.
Subscribe the calling process to a topic.
Unsubscribe the calling process from a topic.
Functions
@spec broadcast(term()) :: :ok
Broadcast an event to all subscribers of the :all topic
and to subscribers of the event's specific topic.
Events are tuples like {:agent, :ask_complete, name, result}.
The first element is used as the specific topic.
Broadcast an event to a specific topic.
@spec subscribe(term()) :: :ok
Subscribe the calling process to a topic.
The process will receive {:workshop_event, topic, event} messages.
@spec unsubscribe(term()) :: :ok
Unsubscribe the calling process from a topic.