import { Naive } from "@usenaive-sdk/server";
const naive = new Naive({ apiKey: process.env.NAIVE_SECRET_KEY! });
// One tenant = one agent profile. Create the tenant_user, then use its id with forUser().
// (Pass "default" to act as the api key's own default agent profile.)
const alice = await naive.users.create({ external_id: "alice_db_uuid" });
// Provision a governed agent profile for that tenant (idempotent, async to fully verify).
const op = await naive.forUser(alice.id).provision("support", {
idempotencyKey: `op:${alice.id}`,
});
// Pull the agent profile's governed tools into your agent / Eve / LangGraph.
const tools = await op.tools();
// Absolute revoke — freeze the card, halt sends, tear down the runtime.
// await op.revoke();
// The flat resource API still works for the no-agent / single-capability case:
await naive.forUser(alice.id).cards.create({ spending_limit_cents: 25000 });