Created At: 2026-11-19T01:59:48Z Completed At: 2026-11-19T01:59:49Z Command exited with code 0. Command output: const http = require('http'); const https = require('https'); // High-performance HTTP and HTTPS Keep-Alive Agents // Reuses TCP/TLS connections to avoid connection handshake delays on every request const httpAgent = new http.Agent({ keepAlive: true, keepAliveMsecs: 60000, maxSockets: 100, maxFreeSockets: 25, timeout: 60000 }); const httpsAgent = new https.Agent({ keepAlive: true, keepAliveMsecs: 60000, maxSockets: 100, maxFreeSockets: 25, timeout: 60000 }); /** * Returns the appropriate Keep-Alive agent based on the URL protocol. * @param {string|URL} targetUrl * @returns {http.Agent|https.Agent} */ function getAgent(targetUrl) { if (!targetUrl) return httpsAgent; const protocol = typeof targetUrl === 'string' ? (targetUrl.startsWith('http://') ? 'http:' : 'https:') : targetUrl.protocol; return protocol === 'http:' ? httpAgent : httpsAgent; } /** * Enhanced fetch wrapper that automatically applies keep-alive agents. * @param {string} url * @param {object} options * @returns {Promise} */ async function fetchWithAgent(url, options = {}) { const fetchFn = typeof fetch !== 'undefined' ? fetch : require('node-fetch'); const agent = getAgent(url); // node-fetch supports agent option return fetchFn(url, { agent, ...options }); } module.exports = { httpAgent, httpsAgent, getAgent, fetchWithAgent };