import { isPendingApproval } from "@usenaive-sdk/server";
const alice = naive.forUser("alice");
// 1. Agent attempts a gated action → pending, not executed
const res = await alice.cards.create({ name: "Ads", spendingLimitCents: 50000 });
if (isPendingApproval(res)) {
// res.approval_id — surface it to the human who can approve
}
// 2. A human approves → API replays the action
await alice.approvals.approve(res.approval_id);
// 3. Inspect the outcome
const a = await alice.approvals.get(res.approval_id); // status: "executed" + result