API Reference
Functions
createConduit
function createConduit(options?: ConduitOptions): Conduit
Creates a Conduit instance. Initializes the engine, database, server app, and connector infrastructure. See Configuration for ConduitOptions.
defineConnector
function defineConnector(definition: ConnectorDefinition): ConnectorDefinition
function defineConnector(manifest: ConnectorManifest, setup: ConnectorDefinition['setup']): ConnectorDefinition
Identity function for type-checking connector definitions. Two-argument form separates the manifest (serializable metadata) from the setup function.
Core Interfaces
Conduit
The main API surface returned by createConduit().
Registration
on(event: string, handler: ConduitHandler): void
process<T = unknown>(config: ProcessConfig<T>): void
Connectors
connector(def: ConnectorDefinition, opts?: {
config?: Record<string, unknown>
auth?: string | OutboundAuth
}): Promise<void>
reconnect(connectorName: string): Promise<void>
auth(name: string): AuthClient
getConnectors(): ConnectorManifest[]
listConnectorStatuses(): ConnectorStatusRecord[]
getConnectorStatus(connectorName: string): ConnectorStatusRecord | null
getConnectorObservability(connectorName: string, query?: ConnectorObservabilityQuery): ConnectorObservabilityReport
subscribeConnectorEvents(listener: (event: ConnectorEvent) => void): () => void
invoke(connectorName: string, methodName: string, input?: unknown): Promise<unknown>
getAuditReport(): ConduitAuditReport
Events & Cron
emit(event: string, payload?: unknown, opts?: { idempotencyKey?: string }): Run[]
emitAndWait(event: string, payload?: unknown, opts?: {
idempotencyKey?: string
timeoutMs?: number
}): Promise<Run[]>
webhook(path: string, options: WebhookOptions): void
cron(name: string, pattern: string, options?: { timezone?: string; payload?: Record<string, unknown> }): void
getCronJobs(): CronJobInfo[]
pauseCron(name: string): boolean
resumeCron(name: string): boolean
Queries
getRun(id: string): Run | null
getRunning(): Run[]
getCompleted(): Run[] // deprecated: use getRunsPaginated
getErrored(): Run[]
getIdle(): Run[]
getChain(runId: string): Run[]
getProcesses(): ProcessDefinition[]
getEffects(runId: string): EffectRecord[]
getGraph(): EventGraph
countByState(state: ProcessState): number
getRunsByStatusPaginated(status: RunStatus, limit: number, offset: number, opts?: RunQueryOptions): { runs: Run[]; total: number }
getRunsPaginated(state: ProcessState | null, limit: number, offset: number, opts?: RunQueryOptions): { runs: Run[]; total: number }
getMetrics(): EngineMetrics
getObservability(query?: EngineObservabilityQuery): EngineObservabilityReport
subscribeEvents(listener: (event: EngineEvent) => void): () => void
retryRun(runId: string): Run
requeueDead(runId: string): Run
resume(runId: string, payload?: unknown): Run[]
Lifecycle
listen(port?: number, host?: string): Promise<ConduitServer>
drain(timeoutMs?: number): Promise<void>
stop(): Promise<void>
Properties
hono: Hono // underlying Hono app for custom routes
db: ConduitDb | null // database handle (null if no db configured)
ConduitOptions
interface ConduitOptions {
engine?: EngineOptions
db?: string
skills?: string[]
server?: ConduitServerConfig
onConnectorEvent?: (event: ConnectorEvent) => void
}
ConduitServerConfig
interface ConduitServerConfig {
auth?: ConduitAuthHooks
operatorExclude?: string[]
}
ConduitAuthHooks
interface ConduitAuthHooks {
operator?: MiddlewareHandler
ingress?: MiddlewareHandler
public?: MiddlewareHandler
}
Process Interfaces
ProcessConfig<T>
interface ProcessConfig<T = unknown> {
name: string
on: string
schema?: Schema<T>
retry?: RetryPolicy
concurrency?: number
emits?: EmitOption[]
run: ConduitHandler<T>
}
ConduitHandlerContext<T>
Extends the engine’s HandlerContext<T> with conduit-specific methods.
interface ConduitHandlerContext<T = unknown> extends HandlerContext<T> {
connector(name: string): ConnectorHandle
auth(name: string): AuthClient
decide(opts: DecideOptions): Promise<HandlerResult>
describeContext(): DescribeContextResult
}
connector(name): returns the connector’s handle with typed method accessorsauth(name): returns a named AuthClient from the databasedecide(opts): LLM-powered decision routing via a connector that implementscomplete()describeContext(): serializable snapshot of available connectors, skills, and emits
ConduitHandler<T>
type ConduitHandler<T = unknown> = (ctx: ConduitHandlerContext<T>) => Promise<HandlerResult> | HandlerResult
WebhookOptions
interface WebhookOptions {
verify?: MiddlewareHandler
eventType: string | ((body: any) => string)
}
Connector Interfaces
ConnectorDefinition
interface ConnectorDefinition {
name: string
version: string
description?: string
events?: Record<string, ConnectorEventDefinition>
methods?: Record<string, ConnectorMethodDefinition>
config?: Record<string, ConnectorConfigField>
setup?(ctx: ConnectorContext): ConnectorRuntime | Promise<ConnectorRuntime>
}
ConnectorManifest
Serializable subset of ConnectorDefinition: no functions, no setup.
interface ConnectorManifest {
name: string
version: string
description?: string
events?: Record<string, ConnectorEventDefinition>
methods?: Record<string, ConnectorMethodManifest>
config?: Record<string, ConnectorConfigField>
}
ConnectorContext
Passed to the connector’s setup function.
interface ConnectorContext {
emit(event: string, payload: unknown): void
status(status: ConnectorRuntimeStatus, info?: { message?: string | null }): void
config: Record<string, unknown>
auth: AuthClient | null
routes: Hono
}
ConnectorRuntime
Returned from setup(). Lifecycle hooks and method implementations.
interface ConnectorRuntime {
start?(): Promise<void> | void
stop?(): Promise<void> | void
methods?: Record<string, (input: unknown, ctx: ConnectorMethodContext) => Promise<unknown> | unknown>
}
ConnectorConfigField
interface ConnectorConfigField {
required?: boolean
secret?: boolean
description?: string
default?: unknown
}
ConnectorMethodDefinition
interface ConnectorMethodDefinition<TInput = unknown, TOutput = unknown> extends ConnectorMethodManifest {
validateInput?: Schema<TInput>
validateOutput?: Schema<TOutput>
http?: ConnectorHttpMethodDefinition
run?: (input: TInput, ctx: ConnectorMethodContext) => Promise<TOutput> | TOutput
}
ConnectorHandle
Returned by ctx.connector(name) in handlers. Contains the manifest plus callable methods.
interface ConnectorHandle extends Record<string, unknown> {
manifest: ConnectorManifest
}
Auth Interfaces
OutboundAuth
Discriminated union. See Authentication for usage.
type OutboundAuth =
| { type: 'none' }
| { type: 'api_key', key: string, headerName?: string, prefix?: string }
| { type: 'basic', username: string, password: string }
| { type: 'oauth2', clientId: string, clientSecret: string, tokenUrl: string, scopes?: string[], authMethod?: 'post_body' | 'basic_auth', cacheKey?: string }
| { type: 'custom', prepare(request: PreparedRequest, ctx: OutboundAuthPrepareContext): MaybePromise<PreparedRequest> }
AuthClient
interface AuthClient {
request(path: string, init?: RequestInit): Promise<Response>
readonly baseUrl: string
readonly authType: 'none' | 'api_key' | 'basic' | 'oauth2'
}
RequestClient
Lower-level client created by createRequestClient().
interface RequestClient {
readonly baseUrl?: string
request(path: string, init?: RequestInit): Promise<Response>
fetch(input: string | URL, init?: RequestInit): Promise<Response>
}
See also: Engine API Reference, Getting Started.