Broadcast Event
Design WebSocket event broadcasting for AI Developer Workflow observability.
Arguments
$ARGUMENTS: <event-type> [payload-description]
event-type: Type of event to broadcast (e.g., ToolUseBlock, StepComplete)
payload-description: Optional payload structure description
Event Types
| Event Type |
Source |
Payload |
TextBlock |
Agent output |
Text content |
ToolUseBlock |
Tool invocation |
Tool name, input |
ThinkingBlock |
Extended thinking |
Thinking content |
StepStart |
Workflow step |
Step name, timestamp |
StepEnd |
Workflow step |
Step name, status |
ADWComplete |
Workflow finish |
Final status, metrics |
Instructions
Step 1: Define Message Format
Standard ADW event structure:
{
"type": "adw_event",
"adw_id": "a1b2c3d4",
"step": "build",
"event_type": "ToolUseBlock",
"timestamp": "2026-01-01T14:30:00Z",
"summary": "Writing authentication middleware to src/auth.py",
"payload": {
"tool_name": "Write",
"file_path": "src/auth.py",
"content_preview": "class AuthMiddleware:..."
}
}
```text
### Step 2: Design Summarization Strategy
Use Haiku for fast, cheap summaries:
**Prompt Template:**
```text
Summarize this {event_type} in 15 words or less for a developer dashboard:
Tool: {tool_name}
Input: {tool_input_preview}
Summary:
```text
**Events to Summarize:**
- `ToolUseBlock`: Summarize tool action
- `TextBlock`: Summarize content (if long)
- `ThinkingBlock`: Summarize reasoning
**Events to Pass Through:**
- `StepStart`: Use fixed format
- `StepEnd`: Use fixed format
- `ADWComplete`: Use fixed format
### Step 3: Design WebSocket Server
Server specification:
```python
# adws/websocket_server.py
from fastapi import FastAPI, WebSocket
from typing import Dict, Set
import asyncio
app = FastAPI()
class ConnectionManager:
def __init__(self):
self.active_connections: Dict[str, Set[WebSocket]] = {}
async def connect(self, websocket: WebSocket, adw_id: str):
await websocket.accept()
if adw_id not in self.active_connections:
self.active_connections[adw_id] = set()
self.active_connections[adw_id].add(websocket)
async def broadcast(self, adw_id: str, message: dict):
if adw_id in self.active_connections:
for connection in self.active_connections[adw_id]:
await connection.send_json(message)
manager = ConnectionManager()
@app.websocket("/ws/{adw_id}")
async def websocket_endpoint(websocket: WebSocket, adw_id: str):
await manager.connect(websocket, adw_id)
try:
while True:
await websocket.receive_text() # Keep alive
except:
manager.active_connections[adw_id].discard(websocket)
```text
### Step 4: Design Client Subscription
Client subscription message:
```json
{
"action": "subscribe",
"filters": {
"adw_id": "a1b2c3d4",
"steps": ["build", "review"],
"event_types": ["ToolUseBlock", "StepEnd"]
}
}
```text
### Step 5: Design Resilience Patterns
**Reconnection Strategy:**
```javascript
class ResilientWebSocket {
constructor(url) {
this.url = url;
this.maxReconnectDelay = 30000;
this.reconnectAttempts = 0;
}
connect() {
this.ws = new WebSocket(this.url);
this.ws.onclose = () => {
const delay = Math.min(
1000 * Math.pow(2, this.reconnectAttempts),
this.maxReconnectDelay
);
setTimeout(() => this.connect(), delay);
this.reconnectAttempts++;
};
this.ws.onopen = () => {
this.reconnectAttempts = 0;
};
}
}
```text
**Heartbeat Mechanism:**
- Interval: 30 seconds
- Timeout: 90 seconds
- Message: `{"type": "ping"}`
## Output
```markdown
## Event Broadcasting Specification
**Event Type:** {event_type}
**ADW Context:** {adw_id}
### Message Format
```json
{message_structure}
```text
### Summarization
**Strategy:** {haiku/passthrough}
**Prompt:** {if haiku}
### Server Endpoint
**URL:** `ws://localhost:8000/ws/{adw_id}`
**Protocol:** WebSocket
### Client Subscription
```json
{subscription_message}
```text
### Resilience
| Pattern | Value |
| --- | --- |
| Reconnect Strategy | Exponential backoff |
| Max Delay | 30 seconds |
| Max Attempts | 10 |
| Heartbeat Interval | 30 seconds |
### Integration
Hook scripts broadcast via HTTP POST to server:
```python
import httpx
async def broadcast(event: dict):
async with httpx.AsyncClient() as client:
await client.post(
f"http://localhost:8000/broadcast/{event['adw_id']}",
json=event
)
```text
### Next Steps
1. Implement WebSocket server (`adws/websocket_server.py`)
2. Integrate with hooks (`/configure-hooks`)
3. Build swimlane UI (`swimlane-visualization` skill)
4. Add event persistence (optional database logging)
```text
## SDK Note
> **Implementation Note:** Full WebSocket integration requires production backend. This command provides the specification; implementation requires FastAPI/asyncio setup.
## Cross-References
- @websocket-architecture.md - WebSocket patterns
- @hook-event-patterns.md - Event types
- `event-broadcaster` agent - Broadcasting design
- `swimlane-visualization` skill - UI consumption
---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/melodic-software) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->
1---2name: broadcast-event3description: Design WebSocket event broadcasting for ADW observability. Use when streaming workflow events to external dashboards or monitoring systems. Use when this capability is needed.4---56# Broadcast Event78Design WebSocket event broadcasting for AI Developer Workflow observability.910## Arguments1112- `$ARGUMENTS`: `<event-type> [payload-description]`13 - `event-type`: Type of event to broadcast (e.g., `ToolUseBlock`, `StepComplete`)14 - `payload-description`: Optional payload structure description1516## Event Types1718| Event Type | Source | Payload |19| --- | --- | --- |20| `TextBlock` | Agent output | Text content |21| `ToolUseBlock` | Tool invocation | Tool name, input |22| `ThinkingBlock` | Extended thinking | Thinking content |23| `StepStart` | Workflow step | Step name, timestamp |24| `StepEnd` | Workflow step | Step name, status |25| `ADWComplete` | Workflow finish | Final status, metrics |2627## Instructions2829### Step 1: Define Message Format3031Standard ADW event structure:3233```json34{35 "type": "adw_event",36 "adw_id": "a1b2c3d4",37 "step": "build",38 "event_type": "ToolUseBlock",39 "timestamp": "2026-01-01T14:30:00Z",40 "summary": "Writing authentication middleware to src/auth.py",41 "payload": {42 "tool_name": "Write",43 "file_path": "src/auth.py",44 "content_preview": "class AuthMiddleware:..."45 }46}47```text4849### Step 2: Design Summarization Strategy5051Use Haiku for fast, cheap summaries:5253**Prompt Template:**5455```text56Summarize this {event_type} in 15 words or less for a developer dashboard:5758Tool: {tool_name}59Input: {tool_input_preview}6061Summary:62```text6364**Events to Summarize:**6566- `ToolUseBlock`: Summarize tool action67- `TextBlock`: Summarize content (if long)68- `ThinkingBlock`: Summarize reasoning6970**Events to Pass Through:**7172- `StepStart`: Use fixed format73- `StepEnd`: Use fixed format74- `ADWComplete`: Use fixed format7576### Step 3: Design WebSocket Server7778Server specification:7980```python81# adws/websocket_server.py82from fastapi import FastAPI, WebSocket83from typing import Dict, Set84import asyncio8586app = FastAPI()8788class ConnectionManager:89 def __init__(self):90 self.active_connections: Dict[str, Set[WebSocket]] = {}9192 async def connect(self, websocket: WebSocket, adw_id: str):93 await websocket.accept()94 if adw_id not in self.active_connections:95 self.active_connections[adw_id] = set()96 self.active_connections[adw_id].add(websocket)9798 async def broadcast(self, adw_id: str, message: dict):99 if adw_id in self.active_connections:100 for connection in self.active_connections[adw_id]:101 await connection.send_json(message)102103manager = ConnectionManager()104105@app.websocket("/ws/{adw_id}")106async def websocket_endpoint(websocket: WebSocket, adw_id: str):107 await manager.connect(websocket, adw_id)108 try:109 while True:110 await websocket.receive_text() # Keep alive111 except:112 manager.active_connections[adw_id].discard(websocket)113```text114115### Step 4: Design Client Subscription116117Client subscription message:118119```json120{121 "action": "subscribe",122 "filters": {123 "adw_id": "a1b2c3d4",124 "steps": ["build", "review"],125 "event_types": ["ToolUseBlock", "StepEnd"]126 }127}128```text129130### Step 5: Design Resilience Patterns131132**Reconnection Strategy:**133134```javascript135class ResilientWebSocket {136 constructor(url) {137 this.url = url;138 this.maxReconnectDelay = 30000;139 this.reconnectAttempts = 0;140 }141142 connect() {143 this.ws = new WebSocket(this.url);144145 this.ws.onclose = () => {146 const delay = Math.min(147 1000 * Math.pow(2, this.reconnectAttempts),148 this.maxReconnectDelay149 );150 setTimeout(() => this.connect(), delay);151 this.reconnectAttempts++;152 };153154 this.ws.onopen = () => {155 this.reconnectAttempts = 0;156 };157 }158}159```text160161**Heartbeat Mechanism:**162163- Interval: 30 seconds164- Timeout: 90 seconds165- Message: `{"type": "ping"}`166167## Output168169```markdown170## Event Broadcasting Specification171172**Event Type:** {event_type}173**ADW Context:** {adw_id}174175### Message Format176177```json178{message_structure}179```text180181### Summarization182183**Strategy:** {haiku/passthrough}184**Prompt:** {if haiku}185186### Server Endpoint187188**URL:** `ws://localhost:8000/ws/{adw_id}`189**Protocol:** WebSocket190191### Client Subscription192193```json194{subscription_message}195```text196197### Resilience198199| Pattern | Value |200| --- | --- |201| Reconnect Strategy | Exponential backoff |202| Max Delay | 30 seconds |203| Max Attempts | 10 |204| Heartbeat Interval | 30 seconds |205206### Integration207208Hook scripts broadcast via HTTP POST to server:209210```python211import httpx212213async def broadcast(event: dict):214 async with httpx.AsyncClient() as client:215 await client.post(216 f"http://localhost:8000/broadcast/{event['adw_id']}",217 json=event218 )219```text220221### Next Steps2222231. Implement WebSocket server (`adws/websocket_server.py`)2242. Integrate with hooks (`/configure-hooks`)2253. Build swimlane UI (`swimlane-visualization` skill)2264. Add event persistence (optional database logging)227228```text229230## SDK Note231232> **Implementation Note:** Full WebSocket integration requires production backend. This command provides the specification; implementation requires FastAPI/asyncio setup.233234## Cross-References235236- @websocket-architecture.md - WebSocket patterns237- @hook-event-patterns.md - Event types238- `event-broadcaster` agent - Broadcasting design239- `swimlane-visualization` skill - UI consumption240241---242> Converted and distributed by [TomeVault](https://tomevault.io/claim/melodic-software) — claim your Tome and manage your conversions.243<!-- tomevault:4.0:skill_md:2026-04-11 -->