@tailrace/core
v0.2.2
Published
Agent data governance core: detection, policy engine, vault, audit. Zero runtime deps; runs on Node, Cloudflare Workers, and Vercel Edge.
Downloads
976
Readme
@tailrace/core
Agent data governance for TypeScript. In-process detection of secrets and PII, reversible workflow-scoped tokenization, and per-agent data-flow policy enforced at the model, tool, and MCP boundaries. No proxy, no sidecar, no network call in the request hot path.
This package is the foundation of Tailrace. Every @tailrace/* integration
depends on it.
Packages
| Package | npm | What it is |
| ----------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| @tailrace/core | npm | Detection, policy engine, vault, audit. Zero runtime deps; runs on Node, Cloudflare Workers, and Vercel Edge. |
| @tailrace/adapter | npm | Shared integration helpers: wrapToolExecute, runGoverned. No host peers. |
| @tailrace/ai-sdk | npm | Vercel AI SDK middleware + tool wrapper. |
| @tailrace/cloudflare-agents | npm | Cloudflare Agents / AIChatAgent compose entry (identity, vault, AI SDK wraps). |
| @tailrace/openai-agents | npm | OpenAI Agents SDK function tool wrappers. |
| @tailrace/mcp | npm | MCP client transport wrapper. |
| @tailrace/hono | npm | Hono middleware (OpenAI-compatible passthrough). |
| @tailrace/cli | npm | tailrace binary: init, scan, install-hooks, hook. |
| @tailrace/recognizer-ner | npm | Optional Tier 1 ONNX NER recognizer (Node only). |
Quickstart
pnpm add @tailrace/core @tailrace/ai-sdk ai @ai-sdk/openaiimport { createTailrace } from "@tailrace/core";
import { withAiSdk } from "@tailrace/ai-sdk";
import { openai } from "@ai-sdk/openai";
const tailrace = withAiSdk(createTailrace()); // zero config: secrets blocked, common PII tokenized
const model = tailrace.model(openai("gpt-4o"));
// Use `model` anywhere you'd use the AI SDK model - sensitive values never leave the process.Also see @tailrace/mcp (withMcp / wrapTransport) and
@tailrace/hono (tailraceHono) for MCP transports and
OpenAI-compatible gateways.
Documentation
| Resource | Description | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | | Quickstart | Block a secret and tokenize email in five minutes | | Boundaries · Policy resolution · Detection tiers · Tokenization & the vault | The mental model, with diagrams | | Ship an agent | Clone, verify, deploy: model, tools, egress restore | | Govern MCP tool calls | Transport wrap + JSON-RPC block | | Block secrets in Claude Code | Hooks, scan, install-hooks | | Next.js · MCP · Hono · Claude Code | Integration pages |
Full docs: tailrace.dev
Install
pnpm add @tailrace/coreZero runtime dependencies. Runs on Node 20+, Cloudflare Workers, and Vercel Edge (WebCrypto only, no
node: imports).
Public API
createTailrace, definePolicy, defineRecognizer, definePatternRecognizer, memoryVault, kvVault, staticPolicy, the
error classes (TailraceError and subclasses), and all public types. Everything else is internal.
import { createTailrace, definePatternRecognizer, definePolicy } from "@tailrace/core";
const employeeId = definePatternRecognizer({
id: "employee-id",
entity: "employee_id",
tier: 0,
patterns: [{ source: String.raw`\bEMP-\d{5}\b`, confidence: 1 }],
});
const tailrace = createTailrace({
recognizers: [employeeId],
policy: definePolicy({
entities: { employee_id: "tokenize" },
defaults: { action: "allow" },
}),
});
const { output, decisions } = await tailrace.check("Assign EMP-01234", {
boundary: { kind: "model", provider: "openai/gpt-4o" },
identity: { agent: "default" },
workflowId: "session-1",
});Zero required config: createTailrace() without custom recognizers enforces the default policy (secret classes → block,
common structured PII → tokenize). Pass definePolicy(...) / staticPolicy(...) to customize.
Integrations (@tailrace/ai-sdk, @tailrace/mcp, @tailrace/hono, @tailrace/cli) construct a
Boundary / Identity, call check / restore, and translate PolicyViolationError into the
host failure mode. They contain zero policy logic.
