mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-13 04:03:30 +00:00
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.
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { clearedProxyEnv, installProxyFromEnvironment } from '@deepseek-ai/dsh-http-proxy'
|
|
import { workerSpawnEnv } from '../src/host.ts'
|
|
|
|
/** A proxy URL carrying credentials, the shape that must never reach model-authored code. */
|
|
const CREDENTIALED_PROXY = 'http://alice:s3cret@proxy.example:8080'
|
|
|
|
/** The launch environment of a user whose proxy needs a password. */
|
|
const CREDENTIALED = {
|
|
get: (name: string) => (name === 'HTTP_PROXY' || name === 'HTTPS_PROXY' ? { value: CREDENTIALED_PROXY } : undefined),
|
|
}
|
|
|
|
describe('workflow worker egress', () => {
|
|
it('hands the worker no proxy configuration, credentialed or not', async () => {
|
|
const dispose = await installProxyFromEnvironment(CREDENTIALED, () => undefined)
|
|
try {
|
|
const env = workerSpawnEnv()
|
|
// The worker executes the model-authored script body, so a proxy URL that may carry
|
|
// `user:password` must not be readable from its environment.
|
|
for (const name of Object.keys(clearedProxyEnv())) expect(env).not.toHaveProperty(name)
|
|
expect(env).not.toHaveProperty('NODE_USE_ENV_PROXY')
|
|
expect(JSON.stringify(env)).not.toContain('s3cret')
|
|
} finally {
|
|
await dispose()
|
|
}
|
|
})
|
|
|
|
it('still carries the platform temp path the worker needs on Windows', () => {
|
|
expect(workerSpawnEnv('win32')).toHaveProperty('TMP')
|
|
})
|
|
})
|