INNER CODE UNIT · JavaScript

RATE_LIMIT_HINT

nirholas/XActions · packages/xactions-edge/index.js:88

const RATE_LIMIT_HINT = /rate.?limit|\b429\b/i;

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

/**
 * A priced tool reports its terms as the error text, because MCP has no status
 * code to carry a 402. Recognise that body and hand back the parsed terms.
 * @param {string} message
 * @returns {object|null}
 */
function parsePaymentRequired(message) {
  if (!message.includes('x402Version')) return null;
  try {
    const payload = JSON.parse(message);
    return payload?.x402Version ? payload : null;
  } catch {
    return null;
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…