Tailrace
Reference

NestJS

Reference for @tailrace/nestjs - TailraceModule, TailraceMiddleware, and TailraceNestOptions.

@tailrace/nestjs provides TailraceModule.forRoot and TailraceMiddleware for NestJS. Primary CI target: Nest + Express adapter.

Install

pnpm add @tailrace/core @tailrace/nestjs @nestjs/common @nestjs/core reflect-metadata

Peer dependency: @nestjs/common >=10. Depends on @tailrace/core + @tailrace/http.

Exports

ExportDescription
TailraceModuleforRoot(options) Nest dynamic module
TailraceMiddlewareNest middleware implementing openai-compat
TailraceNestOptionsOptions type
TAILRACE_NEST_OPTIONSInjection token for module options

Options

OptionDefaultNotes
tailracerequiredTailrace instance
mode"openai-compatible"Only mode in v0.1
agent"default"(req) => string (Express Request)
workflowId"default"string or (req) => string
onDecision-Audit callback
forRoutes{*path}Paths for MiddlewareConsumer.forRoutes. Prefer v1/*path (Nest 11)

For Nest + Fastify, register @tailrace/fastify on the underlying Fastify instance.

Block shape

422 JSON { error: { type: "policy_violation", entity, rule } }. SSE: one data: error event then close (abort-equivalent only). Maps from PolicyViolationError.

See also

On this page