import { VetoClient, VetoError, UnauthorizedError, RateLimitError } from '@useveto/node';
const veto = new VetoClient({ apiKey: 'veto_...' });
try {
const result = await veto.authorize('agent-uuid', 'file.write', { path: '/tmp/out.txt' });
} catch (err) {
if (err instanceof RateLimitError) {
// Wait the indicated time then retry
await sleep(err.retryAfterMs);
retry();
} else if (err instanceof UnauthorizedError) {
// API key is missing or invalid
console.error('Check your API key:', err.message);
} else if (err instanceof VetoError) {
// Any other Veto API error
console.error(`API error ${err.statusCode} [${err.code}]:`, err.message);
} else {
throw err;
}
}