SDK (TypeScript, Python)
For agents that do not use MCP, wrap a tool function directly. TypeScript:
import { Keeprun } from "@keeprun/sdk";
const kr = new Keeprun({ agentKey: process.env.KEEPRUN_AGENT_KEY });
const refund = kr.wrap(shopify.createRefund, {
tool: "shopify.create_refund",
riskClass: "refund",
amountPath: "amount",
});
const r = await refund({ order_id, amount });
// may return { keeprun: { status: "held", ref, note } }Python is the same shape:
from keeprun import Keeprun kr = Keeprun(agent_key=os.environ["KEEPRUN_AGENT_KEY"]) refund = kr.wrap(create_refund, tool="shopify.create_refund", risk_class="refund", amount_path="amount")
The SDK fails open by default if Keeprun is unreachable within a short budget, so it never blocks your agent on a network blip. A per-rule override can fail closed for payments and refunds.