INNER CODE UNIT · JavaScript
sleep
nirholas/XActions · packages/xactions-edge/index.js:90
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;
}
}