Tailrace
Integrations

tRPC

Procedure middleware for tRPC - check input and output at the tool boundary, throw TRPCError on block.

Enforce data policy on tRPC procedure input and result data. This is the tool boundary, not an OpenAI REST gateway.

Quickstart

import { createTailrace } from "@tailrace/core";
import { createTailraceMiddleware, withTrpc } from "@tailrace/trpc";
import { initTRPC } from "@trpc/server";

const t = initTRPC.create();

const governed = createTailraceMiddleware(createTailrace(), {
  agent: "api",
  name: ({ path }) => path,
});
export const procedure = t.procedure.use(governed);

// Fluent alternative
const tr = withTrpc(createTailrace());
export const procedure2 = t.procedure.use(tr.middleware({ agent: "api" }));

Peer: @trpc/server >=10. Non-streaming queries and mutations only in v0.1.

Boundaries covered

SurfaceTailrace boundaryDirection
Input{ kind: "tool", name, direction: "out" }Outbound
Output{ kind: "tool", name, direction: "in" }Inbound

Block → TRPCError (BAD_REQUEST) with a value-free message. Tokenize / mask rewrite input or result data in place.

Guides

Reference

On this page