import { Inviolet } from "@inviolet/sdk"
import Anthropic from "@anthropic-ai/sdk"
const inviolet = new Inviolet({ apiKey: process.env.INVIOLET_API_KEY! })
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY! })
// Before every tool call, ask Inviolet whether to allow it.
const decision = await inviolet.intent.evaluate({
userId: "user_2pX9...",
toolCall: { name: "lookup_customer", arguments: { id: "12345" } },
dataSourceId: "salesforce_prod",
})
if (decision.outcome !== "allowed") {
throw new Error(`call_blocked: ${decision.outcome}`)
}
// Proceed with the original Anthropic call.
const message = await anthropic.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Look up customer 12345." }],
})