Cross-language
TypeScript SDK
Govern JavaScript / TypeScript agents with the same policy engine as Python. @antraft/guard is a thin client over the frozen governance contract — no policy logic is reimplemented, so the two languages can never drift.
Install
shell
npm install @antraft/guardRun the sidecar
shell
pip install "antraft[all]" "uvicorn[standard]"antraft serve --port 8000Guard your tool calls
agent.ts
import { GuardClient } from "@antraft/guard"; const guard = new GuardClient({ baseUrl: "http://localhost:8000", policy: { allow: ["search_web"], deny: ["delete_db"], rules: [ { trigger: "action:wire_transfer", checks: ["amount > 1000"], enforce: "pause" }, ], },}); // Option A — evaluate, then decide yourselfconst { decision, reason } = await guard.evaluate( { name: "wire_transfer", params: { amount: 5000 } },); // Option B — only run the side-effect if allowedawait guard.guarded( { name: "search_web", params: { q: "antraft" } }, async () => doSearch("antraft"),);Note
The Python service owns all policy logic and exposes it at
POST /guard/evaluate. The TS client just speaks that contract — one source of truth for governance across languages.Contract
types.ts
type Decision = "allow" | "deny" | "pause"; interface GuardAction { name: string; params?: Record<string, unknown>; id?: string }interface EvaluateResponse { decision: Decision; reason: string }Wrap every tool call your TS agent makes and your JavaScript agents inherit Antraft's policy enforcement, budgets, audit, and human-in-the-loop pause behavior.