How npm/agent works
@npmcli/agent is a Node.js HTTP/HTTPS agent library. A client supplies an agent directly or asks getAgent to select, normalize, and reuse one; the agent then routes connections through direct sockets or an applicable proxy while providing DNS caching, keep-alives, and granular timeouts. The graph preserves proxy selection, DNS resolution, and error handling as distinct capabilities. Relationships follow the excerpts and README; there are no claims about unsampled integrations.
Main entry points: agents.js HTTP agent · index.js Agent selection · options.js Option normalization · proxy.js Proxy selection
Components 9
Agent selection
- Agent selection
lib/index.js - Option normalization
lib/options.js
Connection handling
- HTTP agent
lib/agents.js - Proxy selection
lib/proxy.js - Proxy agents
package.json - TCP/TLS sockets
lib/agents.js
Network support
- DNS cache
lib/dns.js - Network errors
lib/errors.js
Other components
- HTTP client
Connections 14
- HTTP client → Agent selection: requests agent
README.md - HTTP client → HTTP agent: supplies directly
README.md - Agent selection → Option normalization: normalizes options
lib/index.js - Agent selection → Proxy selection: selects proxy
lib/index.js - Agent selection → HTTP agent: creates or reuses
lib/index.js - Agent selection → DNS cache: exposes cache
lib/index.js - HTTP agent → Option normalization: normalizes options
lib/agents.js - HTTP agent → Proxy selection: selects proxy
lib/agents.js - HTTP agent → Proxy agents: connects through
lib/agents.js - HTTP agent → TCP/TLS sockets: opens sockets
lib/agents.js - HTTP agent → DNS cache: uses lookup
lib/agents.js - Option normalization → DNS cache: gets lookup options
lib/options.js - HTTP agent → Network errors: throws timeout errors
lib/agents.js - Proxy selection → Network errors: throws protocol error
lib/proxy.js