function createMiddleware<TCtxIn>(): CreateMiddlewareBuilder<TCtxIn>;Defined in: packages/workflow-core/src/middleware/create-middleware.ts:46
Build a middleware that extends the workflow ctx. Type-level accumulation makes the extension visible to downstream middleware and the handler.
const traced = createMiddleware().server(async ({ ctx, next }) => { const trace = startTrace(ctx.runId) try { return await next({ context: { trace } }) } finally { trace.end() } })
For middleware that should compose on top of an already-extended ctx, type the generic explicitly:
createMiddleware<{ user: User }>().server(async ({ ctx, next }) => { // ctx.user is typed })
TCtxIn = unknown
CreateMiddlewareBuilder<TCtxIn>