themis-policy-anthropic
v0.2.1
Published
Gate Claude tool_use blocks through Themis
Downloads
214
Maintainers
Readme
themis-policy-anthropic
Gates Claude's tool_use blocks through a Themis policy engine. No Anthropic
SDK import: it accepts the public tool_use shape (type, id, name,
input) and returns the public tool_result shape (tool_use_id, content,
optional is_error). Any SDK that speaks those shapes works.
import Anthropic from '@anthropic-ai/sdk';
import { PolicyEngine, DefaultScopePolicy } from 'themis-policy';
import { gateToolHandlers } from 'themis-policy-anthropic';
const engine = new PolicyEngine();
engine.addPolicy(new DefaultScopePolicy());
const gated = gateToolHandlers({ send_invoice: sendInvoice }, { engine, requestor, tenant_id });
// run Claude's tool_use blocks through `gated`; a deny becomes an is_error tool_resultdeny → an error tool_result the model can read; redirect → the handler
receives the draft target; require_approval → an approval reference instead
of execution. One audit event per attempted call.
