Tailrace
Reference

Encore

Reference for @tailrace/encore - tailraceEncore middleware and TailraceEncoreOptions.

@tailrace/encore returns Encore middleware(...) for OpenAI-compatible proxy endpoints. Prefer raw endpoints so request/response bodies and SSE are available via req.rawRequest / req.rawResponse.

Install

pnpm add @tailrace/core @tailrace/encore encore.dev

Peer dependency: encore.dev >=1.46 (bound against encore.dev@1.57.x middleware / HandlerResponse / MiddlewareRequest). Depends on @tailrace/core + @tailrace/http.

Exports

ExportDescription
tailraceEncoreReturns Encore middleware(...)
checkEncoreOpenAiBodyLower-level body check helper
TailraceEncoreOptionsOptions type
EncoreMiddlewareRequestMinimal request surface used by the adapter

Options

OptionDefaultNotes
mode"openai-compatible"Only mode in v0.1
agent"default"string or (req) => string
workflowId"default"string or (req) => string
onDecision-Audit callback

Typed Encore APIs that return structured chat payloads get the same check on request payload / HandlerResponse.payload when the body shape matches openai-compat. Streaming proxies should use api.raw.

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