Concepts
Conduit and Engine
Conduit wraps the Yella Engine. Every engine concept applies directly: events, runs, the run state machine, durable effects, retry and dead-letter queues, crash recovery, and event chaining.
What Conduit adds on top:
- Connectors: a standard interface for external systems (webhooks, APIs, message queues, cron)
- Enriched handler context:
ctx.connector(),ctx.auth(), andctx.effect()available in every process handler - HTTP server with dashboard: engine dashboard extended with connector status, auth config, and connector admin routes
- Auth surfaces: operator, ingress, and public route classification with opt-in middleware
If you haven’t read the engine docs, start with Engine Concepts: the rest of this page builds on that foundation.
Connectors
A connector is a bridge between an external system and Conduit’s event-driven runtime. defineConnector() creates a connector definition:
import { defineConnector } from '@yellatech/conduit'
const webhook = defineConnector({
name: 'webhook',
version: '1.0.0',
description: 'Receives inbound HTTP webhooks',
events: {
received: { description: 'Webhook payload received' },
},
config: {
secret: { required: false, secret: true, description: 'HMAC verification secret' },
},
setup(ctx) {
// ctx.routes is a Hono instance scoped to /connectors/webhook
ctx.routes.post('/inbound', async (c) => {
const body = await c.req.json()
ctx.emit('received', body)
return c.json({ ok: true })
})
return {
start() { ctx.status('healthy') },
stop() { ctx.status('stopped') },
}
},
})
The setup() function receives a ConnectorContext with:
| Property | Description |
|---|---|
emit(event, payload) | Emit an event into the engine (auto-prefixed with the connector name) |
status(status, info?) | Report connector health: 'healthy', 'degraded', 'errored', 'stopped' |
config | Resolved config values (defaults merged with DB overrides and code overrides) |
auth | Auth client for outbound API calls, or null if not configured |
routes | A Hono instance mounted at /connectors/:name for HTTP endpoints |
setup() returns a ConnectorRuntime with optional lifecycle hooks:
| Method | When it runs |
|---|---|
start() | After setup completes, establishes connections |
stop() | During graceful shutdown or reconnect |
methods | Named callable operations (see Connector Methods) |
Register a connector with your app:
const app = createConduit()
await app.connector(webhook, {
config: { secret: 'my-hmac-secret' },
})
Event Naming
Connector events arrive in the engine with a prefix: connectorName:eventName.
If a connector named github emits event push, your processes listen on github:push. If a connector named email emits inbound, processes listen on email:inbound.
Direct app.emit() calls are not prefixed: the event name is used as-is:
// Connector emit → engine sees 'webhook:received'
ctx.emit('received', body)
// Direct emit → engine sees 'order:created'
app.emit('order:created', { orderId: '123' })
CloudEvent Wrapping
All event payloads in Conduit are wrapped as CloudEvents before entering the engine. This applies to connector events, direct app.emit() calls, cron events, and chained events from process handlers.
The source field tracks origin:
- Connector events →
connector/{connectorName} - Direct emit →
app/emit - Process chains →
process/{processName} - Cron →
connector/cron(virtual connector)
The causationid extension links chained events back to the parent event that triggered them, enabling full causation tracking across the event graph.
Inside your handler, ctx.payload is the full CloudEvent object. Access the original data via ctx.payload.data.
Processes
app.process() is the primary way to register event handlers in Conduit:
app.process({
name: 'handle-webhook',
on: 'webhook:received',
retry: { maxRetries: 3, delay: 1000 },
run: async (ctx) => {
const payload = ctx.payload as { type: string; data: unknown }
// Durable effect: safe to retry
const result = await ctx.effect('process-payload', () => transformPayload(payload))
return { success: true, triggerEvent: 'webhook:processed', payload: result }
},
})
ProcessConfig options
| Option | Type | Description |
|---|---|---|
name | string | Unique process name |
on | string | Event to listen for |
schema | Schema<T> | Optional payload validation (Zod or any .parse() schema) |
retry | RetryPolicy | Optional retry policy (maxRetries, delay) |
concurrency | number | Max concurrent active runs for this process (omit for unlimited) |
emits | EmitOption[] | Declare which events this process may trigger |
run | ConduitHandler | The handler function |
ConduitHandlerContext
The handler receives a ConduitHandlerContext which extends the engine’s HandlerContext:
interface ConduitHandlerContext<T = unknown> extends HandlerContext<T> {
connector(name: string): ConnectorHandle
auth(name: string): AuthClient
decide(opts: DecideOptions): Promise<HandlerResult>
describeContext(): DescribeContextResult
}
In addition to the engine’s HandlerContext (which provides event, payload, runId, effect(key, fn), signal, context, etc.), Conduit adds:
| Method | Description |
|---|---|
ctx.connector(name) | Get a connector handle to call its methods |
ctx.auth(name) | Get an auth client for outbound API requests |
ctx.decide(opts) | LLM-powered decision routing via a connector that implements complete() |
ctx.describeContext() | Serializable snapshot of available connectors, skills, and emits |
Durable effects use the engine’s ctx.effect(key, fn): see Engine Concepts: Durable Effects.
Process chaining
Chain events by returning triggerEvent in the handler result:
app.process({
name: 'validate',
on: 'order:new',
run: async (ctx) => {
return { success: true, triggerEvent: 'order:validated', payload: ctx.payload }
},
})
See Engine Concepts: Event Chaining for correlation IDs and chain depth.
Connector Methods
Connectors can declare methods: named operations that processes can invoke. Methods support three implementation styles:
Custom function
const slack = defineConnector({
name: 'slack',
version: '1.0.0',
methods: {
sendMessage: {
description: 'Post a message to a Slack channel',
run: async (input, ctx) => {
const { channel, text } = input as { channel: string; text: string }
// call Slack API using ctx.auth
return { ok: true, ts: '1234567890.123456' }
},
},
},
setup() {
return {}
},
})
HTTP template
Methods can also be declared as HTTP request templates with {{ }} expressions for interpolation:
const api = defineConnector({
name: 'tickets',
version: '1.0.0',
methods: {
createTicket: {
description: 'Create a support ticket',
http: {
method: 'POST',
baseUrl: '{{ config.baseUrl }}',
path: '/api/tickets',
headers: { 'X-Project': '{{ config.projectId }}' },
body: { title: '{{ input.title }}', body: '{{ input.body }}' },
},
},
},
setup() {
return {}
},
})
Runtime methods
Methods can also be provided at runtime via the ConnectorRuntime:
setup(ctx) {
const client = createApiClient(ctx.config)
return {
methods: {
sendMessage: (input) => client.post('/messages', input),
},
}
}
Calling methods from processes
Access connector methods via ctx.connector():
app.process({
name: 'notify-slack',
on: 'alert:fired',
run: async (ctx) => {
const slack = ctx.connector('slack')
await slack.sendMessage({ channel: '#alerts', text: 'Fire!' })
return ctx.ok()
},
})
The handle exposes each declared method as a callable function. Input and output validation schemas are applied automatically when defined.
Server and Dashboard
app.listen(port) starts an HTTP server that composes the engine dashboard with Conduit extensions:
const app = createConduit({
engine: { store: { type: 'sqlite', path: './_db/conduit.db' } },
})
// Register connectors and processes...
const server = await app.listen(3000)
// Dashboard at http://localhost:3000
The server provides:
| Surface | Routes | Description |
|---|---|---|
| Dashboard | / | Engine dashboard extended with connector status panel |
| Engine API | /runs, /runs/:id/trace, /emit, … | Standard engine query and control routes |
| Conduit API | /api/connectors, /api/auth, /api/connectors/:name/config | Connector and auth management |
| Connector routes | /connectors/:name/* | HTTP endpoints registered by connectors via ctx.routes |
| Health | /livez, /readyz | Liveness and readiness probes |
Auth Surfaces
Conduit classifies all HTTP routes into three auth surfaces. Each surface can have its own middleware for authentication and authorization.
| Surface | What it protects | Typical middleware |
|---|---|---|
| Public | /livez, /readyz | None: open for health checks and load balancers |
| Ingress | /connectors/*, /hooks/* | HMAC verification, API key validation, IP allowlisting |
| Operator | Everything else: dashboard, engine API, conduit admin | Bearer token, session auth, basic auth |
Middleware is evaluated in registration order. The routing decision tree:
Auth is opt-in. With no middleware configured, everything is open: appropriate for local development.
const app = createConduit({
server: {
auth: {
operator: bearerAuth({ token: process.env.ADMIN_TOKEN! }),
ingress: async (c, next) => {
// verify webhook signatures, API keys, etc.
await next()
},
},
},
})
See Authentication for outbound auth configuration (API keys, OAuth2, basic auth) used by connectors for external API calls.
Event Flow
Putting it all together: the full lifecycle from external event to process completion:
The engine’s guarantees carry through: at-least-once delivery, durable effects for safely retrying side effects, lease-based crash recovery with SQLite storage, and correlation tracking across the full chain.