.do
Execution

events

Event-driven architecture with on/send primitives for real-time workflows

events

Event-driven architecture primitives for building reactive systems with on (listeners) and send (publishers).

Overview

The events system enables decoupled, real-time communication between services, agents, and workflows through pub/sub patterns.

Parent Primitive: webhooks - Webhook management

SDK Object Mapping

This primitive maps directly to the on and send SDK objects - two of the 8 core platform objects:

import { on, send, every } from 'sdk.do'

// SEND - Publish events (send is one of 8 core SDK objects)
await send('order.created', {
  order: { id: '123', total: 99.99, userId: 'user-456' },
})

// ON - Listen for events (on is one of 8 core SDK objects)
on('order.created', async ({ order }) => {
  await sendConfirmationEmail(order)
  await updateInventory(order)
})

// EVERY - Workflow handlers (every is one of 8 core SDK objects)
every('daily at 9am', async () => {
  await send('report.generate', { type: 'daily-summary' })
})

// Pattern matching
on('order.*', async (event) => {
  console.log(`Order event: ${event.type}`)
})

Quick Example

import { on, send } from 'sdk.do'

// Listen for events
on('order.created', async ({ order }) => {
  await sendConfirmationEmail(order)
})

// Publish events
await send('order.created', {
  order: { id: '123', total: 99.99 },
})

Core Capabilities

  • Event Publishing - Send events with send() for decoupled communication
  • Event Listeners - React to events with on() handlers
  • Pattern Matching - Use wildcards (order.*) for flexible subscriptions
  • Event Sourcing - Store and replay events for audit trails
  • Integration Patterns - CQRS, Saga, and event bridge patterns

Access Methods

SDK

TypeScript/JavaScript library for event-driven programming

on('order.created', async ({ order }) => {
  await processOrder(order)
})

SDK Documentation

CLI

Command-line tool for publishing and debugging events

do event send order.created --data '{"orderId":"123","total":99.99}'

CLI Documentation

API

REST/RPC endpoints for event publishing

curl -X POST https://api.do/v1/events/send -d '{"type":"order.created","data":{...}}'

API Documentation

MCP

Model Context Protocol for AI-triggered events

Send an order.created event with orderId 123 and total $99.99

MCP Documentation

Parent Primitive

Sibling Primitives

  • on - Event handlers (SDK object mapping)
  • send - Event emission (SDK object mapping)
  • every - Workflow handlers (SDK object mapping)
  • workflows - Multi-step orchestration
  • functions - Event handler functions