import { LynxPolicyError } from "@lynxops/sdk";
const refund = lynx.firewallTool(
"refund.create",
async ({ amount }: { amount: number }) => {
return { refunded: amount };
},
{
riskLevel: "HIGH",
sideEffect: true,
failureMode: "FAIL_CLOSED",
beforeCall: ({ input }) => {
if (input.amount > 100) {
return {
action: "BLOCK",
policyId: "refund-limit",
reason: "승인된 환불 한도를 초과했습니다",
severity: "HIGH",
};
}
return {
action: "ALLOW",
policyId: "refund-limit",
};
},
},
);
try {
await lynx.run("SupportAgent", () => refund({ amount: 500 }));
} catch (error) {
if (error instanceof LynxPolicyError) {
console.log(error.action, error.policyId, error.reason);
}
}