Configuration

ConduitOptions

import { createConduit } from '@yellatech/conduit'

const app = createConduit({
  engine: {
    /* EngineOptions: passed through to createEngine() */
    concurrency: 10,
    store: { type: 'sqlite', path: './app.db' },
  },
  db: './app.db',
  skills: ['./skills'],
  server: {
    auth: {
      operator: operatorMiddleware,
      ingress: hmacMiddleware,
    },
    operatorExclude: ['/auth'],
  },
})

Full type:

interface ConduitOptions {
  engine?: EngineOptions
  db?: string
  skills?: string[]
  server?: ConduitServerConfig
  onConnectorEvent?: (event: ConnectorEvent) => void
}

interface ConduitServerConfig {
  auth?: ConduitAuthHooks
  operatorExclude?: string[]
}

interface ConduitAuthHooks {
  operator?: MiddlewareHandler
  ingress?: MiddlewareHandler
  public?: MiddlewareHandler
}

Engine Options

The engine field is passed directly to createEngine(). Conduit strips the server option (it manages its own server) but forwards everything else: concurrency, store, hooks, maxPayloadBytes, maxChainDepth, etc.

See Engine Configuration for the full list.

Database

Conduit uses a SQLite database for auth config persistence, connector config, cron job state, and OAuth token caching. The path is resolved through a fallback chain:

flowchart TD A{"CONDUIT_DB_PATH\nenv var set?"} -->|yes| USE["Use CONDUIT_DB_PATH"] A -->|no| B{"options.db\nprovided?"} B -->|yes| USE2["Use options.db"] B -->|no| C{"Engine uses\nSQLite?"} C -->|yes| D{"Path is\n:memory:?"} D -->|no| USE3["Share engine's SQLite path"] D -->|yes| NULL["No database (in-memory only)"] C -->|no| NULL

When conduit and engine share the same database file, conduit tables (conduit_auth_configs, conduit_connector_status, conduit_cron_jobs, etc.) are created alongside engine tables in the same SQLite file. Migrations are tracked independently via _conduit_migrations.

// Explicit path
const app = createConduit({ db: './data/app.db' })

// Or via environment variable
// CONDUIT_DB_PATH=./data/app.db
const app = createConduit()

Server

app.listen(port, host) starts an HTTP server (defaults to 0.0.0.0:3000). Returns a ConduitServer with address and stop().

const server = await app.listen(8080)
console.log(`Listening on ${server.address.port}`)

The Hono app is accessible via app.hono for adding custom routes before calling listen().

Auth Surfaces

Conduit’s server has three auth surfaces, each protected by optional middleware:

SurfacePathsPurpose
public/livez, /readyzHealth checks, always accessible
ingress/connectors/*, /hooks/*Inbound webhooks from external services
operatorEverything elseDashboard, API routes, emit
const app = createConduit({
  server: {
    auth: {
      operator: bearerAuth({ token: process.env.ADMIN_TOKEN }),
      ingress: hmacVerify({ secret: process.env.WEBHOOK_SECRET }),
    },
    operatorExclude: ['/auth'],  // skip operator auth for these paths
  },
})

See Concepts for more detail on the security model.

Webhooks

Register webhook endpoints on the ingress surface:

app.webhook('/hooks/stripe', {
  eventType: 'stripe:event',  // static event name
})

// Dynamic event type from payload
app.webhook('/hooks/github', {
  eventType: (body) => `github:${body.action}`,
})

// With HMAC verification middleware
app.webhook('/hooks/stripe', {
  eventType: 'stripe:event',
  verify: stripeVerifyMiddleware,
})

Webhook routes are mounted as POST handlers. The request body is parsed as JSON and emitted as an event payload.

Cron Jobs

Register cron jobs that emit events on a schedule. Requires a database.

const app = createConduit({ db: './app.db' })

app.cron('daily-cleanup', '0 3 * * *', { timezone: 'America/New_York' })
app.cron('heartbeat', '*/5 * * * *', { payload: { source: 'cron' } })

app.process({
  name: 'cleanup',
  on: 'cron:daily-cleanup',
  run: async (ctx) => {
    // runs at 3am ET daily
    return { success: true }
  },
})

Cron events arrive as cron:{name}. Pause/resume state is persisted in the database across restarts.

app.pauseCron('heartbeat')    // stops firing, survives restart
app.resumeCron('heartbeat')   // resumes
app.getCronJobs()             // list all jobs with status and next run time

Cron lifecycle

stateDiagram-v2 [*] --> Registered : app.cron(name, pattern) Registered --> Running : start() (auto, on microtask) Running --> Firing : Pattern matches Firing --> Running : Event emitted, timer resets Running --> Paused : app.pauseCron(name) Paused --> Running : app.resumeCron(name) Running --> Stopped : app.stop() Paused --> Stopped : app.stop() state "DB State" as DB { [*] --> persisted persisted : pattern, timezone, payload persisted : paused flag persisted : last_fired_at }

On restart, cron jobs registered in code are reconciled with database state: orphaned DB rows (jobs no longer in code) are cleaned up, and pause state from the DB is respected for jobs that still exist.

Dashboard

Conduit extends the Engine dashboard with a connector status panel. The dashboard is served automatically from / when listen() is called. No additional configuration is needed.

Environment Variables

VariablePurpose
CONDUIT_DB_PATHPath to the SQLite database file
STATE_DB_PATHEngine-level database path (used if CONDUIT_DB_PATH is not set)

See also: Engine Configuration, Concepts, Auth.