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:

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:

PropertyDescription
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'
configResolved config values (defaults merged with DB overrides and code overrides)
authAuth client for outbound API calls, or null if not configured
routesA Hono instance mounted at /connectors/:name for HTTP endpoints

setup() returns a ConnectorRuntime with optional lifecycle hooks:

MethodWhen it runs
start()After setup completes, establishes connections
stop()During graceful shutdown or reconnect
methodsNamed 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.

flowchart LR W["Webhook POST /inbound"] --> C["webhook connector"] C -->|"ctx.emit('received', body)"| E["Engine event: webhook:received"] E --> P1["process: log-webhook"] E --> P2["process: forward-webhook"]

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.

flowchart LR subgraph Input R["Raw payload"] end subgraph "CloudEvent Envelope" ID["id: random UUID"] SRC["source: connector/slack"] TYP["type: message"] TIME["time: ISO timestamp"] DATA["data: raw payload"] CID["causationid: parent event ID"] end R --> DATA

The source field tracks origin:

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

OptionTypeDescription
namestringUnique process name
onstringEvent to listen for
schemaSchema<T>Optional payload validation (Zod or any .parse() schema)
retryRetryPolicyOptional retry policy (maxRetries, delay)
concurrencynumberMax concurrent active runs for this process (omit for unlimited)
emitsEmitOption[]Declare which events this process may trigger
runConduitHandlerThe 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:

MethodDescription
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:

SurfaceRoutesDescription
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/configConnector and auth management
Connector routes/connectors/:name/*HTTP endpoints registered by connectors via ctx.routes
Health/livez, /readyzLiveness 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.

flowchart TB subgraph public ["Public (open by default)"] L["/livez"] R["/readyz"] end subgraph ingress ["Ingress (webhook/connector routes)"] C["/connectors/:name/*"] H["/hooks/*"] end subgraph operator ["Operator (dashboard + admin)"] D["/ (dashboard)"] A1["/runs, /emit, ..."] A2["/api/connectors"] A3["/api/auth"] end
SurfaceWhat it protectsTypical middleware
Public/livez, /readyzNone: open for health checks and load balancers
Ingress/connectors/*, /hooks/*HMAC verification, API key validation, IP allowlisting
OperatorEverything else: dashboard, engine API, conduit adminBearer token, session auth, basic auth

Middleware is evaluated in registration order. The routing decision tree:

flowchart TD REQ["Incoming request"] --> PUB{"/livez or /readyz?"} PUB -->|yes| PM{"public middleware\nconfigured?"} PM -->|yes| PMA["Apply public middleware"] --> ROUTE["Route handler"] PM -->|no| ROUTE PUB -->|no| ING{"/connectors/* or\n/hooks/*?"} ING -->|yes| IM{"ingress middleware\nconfigured?"} IM -->|yes| IMA["Apply ingress middleware"] --> ROUTE IM -->|no| ROUTE ING -->|no| EXC{"In operatorExclude\nlist?"} EXC -->|yes| ROUTE EXC -->|no| OM{"operator middleware\nconfigured?"} OM -->|yes| OMA["Apply operator middleware"] --> ROUTE OM -->|no| ROUTE

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:

sequenceDiagram participant X as External System participant C as Connector participant E as Engine participant D as Dispatcher participant H as Process Handler X->>C: HTTP POST / WebSocket / Poll C->>E: ctx.emit('received', payload) Note over E: Creates run for 'connector:received' E->>D: Idle run queued D->>H: Claims run, executes handler H->>H: ctx.effect(), ctx.connector(), ctx.auth() H-->>D: ctx.ok(result, { emit: 'next:event' }) D->>E: Run completed, chain event emitted Note over E: Next process picks up 'next:event'

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.