Files
deepseek-harness/packages/util/http-proxy/src/index.ts
T
Yichen Jiang 8470ddef1d refactor(http-proxy): converge the proxy API on four functions
The package exported six functions, four of them shaped by one SDK's
transport each: a dispatcher factory, a `node:http` agent factory, a
proxy-URL lookup, and a policy accessor. Review asked whether the call
sites could converge instead of the package growing an export per SDK.

They could, and each removal took a whole shape with it:

- The OTLP exporter moves to the SDK's `fetch` delegate, retiring
  `createNodeHttpAgent`. Its Node-version floor goes too: `proxyEnv` on
  an `http.Agent` needs 22.21 or 24.5, inside the engines range, so
  telemetry was direct on 22.19, 22.20, and 24.0-24.4. The cost is
  `compression`, a Node-transport option; the plugin now refuses it,
  `keepAlive`, and `httpAgentOptions` at load instead of ignoring them.
- `web-fetch-http` builds its own address-pinning agent under an
  annotated `proxy-exempt:` exemption, retiring `createDispatcher`.
  Pinning is per-request state a process-wide dispatcher cannot hold.
- E2B reads `route.proxy`, retiring `proxyUrlFor`.

What remains is `installProxyFromEnvironment`, `proxyRouteFor`,
`proxyEnvironmentForChild`, and `clearedProxyEnv` — one per way a caller
can need the policy. Installation absorbs resolution and diagnostic
reporting, which no caller needed apart.

`proxyRouteFor` also closes a defect the old accessor made expressible:
`web-fetch-http` read the policy to decide whether to pin, then read it
again to build a transport, so an unmount between the two returned a
direct, unpinned agent for a URL the first read had cleared as proxied.
A route carries the answer and the transport that answer assumed.

Every egress spec now installs through `installProxyFromEnvironment`, so
no test asserts a policy object a real launch could not produce.
2026-09-01 21:15:04 +08:00

24 lines
971 B
TypeScript

/**
* Outbound HTTP proxy support for DeepSeek Harness.
*
* Node's built-in `fetch` ignores `HTTP_PROXY` and friends, so every harness request would connect
* directly no matter what the user exported. The launcher resolves one policy from the launch
* environment and installs it as undici's global dispatcher, which is what `fetch` resolves — so
* LLM adapters, web search, MCP over HTTP, and telemetry are covered without touching their code.
*
* This is a library, not a plugin: transport policy has one answer per process, so there is nothing
* for a composition to mount, swap, or scope.
*
* Four functions, one per way a caller needs the policy — install it, ask how to send one request,
* build a child's environment, and strip the ambient one for a replay.
* @module @deepseek-ai/dsh-http-proxy
*/
export {
clearedProxyEnv,
installProxyFromEnvironment,
proxyEnvironmentForChild,
proxyRouteFor,
type ProxyRoute,
} from './install.ts'