Skip to content

Add managed bypass policy#3

Merged
jesse-merhi merged 2 commits into
mainfrom
jesse/managed-bypass-policy
May 12, 2026
Merged

Add managed bypass policy#3
jesse-merhi merged 2 commits into
mainfrom
jesse/managed-bypass-policy

Conversation

@jesse-merhi
Copy link
Copy Markdown
Member

@jesse-merhi jesse-merhi commented May 12, 2026

Summary

  • add a managed-mode bypassPolicy callback for intentional direct routes
  • apply that policy to node/http, websocket, and undici/fetch proxy decisions
  • cover direct bypass behavior in unit and proxy-lab e2e tests
  • stop committing generated dist/; prepack still builds it for the npm tarball

Verification

  • npx -y node@24 /opt/homebrew/bin/pnpm check
  • npx -y node@24 /opt/homebrew/bin/pnpm package:dry-run
  • git diff --check

Notes

OpenClaw needs this before it can depend on @openclaw/proxyline@0.1.1 for the Gateway loopback bypass without mutating NO_PROXY.

dist/ is now intentionally ignored and untracked. The package dry-run still lists the generated dist/*.js, dist/*.d.ts, and dist/*.d.ts.map files in openclaw-proxyline-0.1.1.tgz via the existing prepack build.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a managed-mode bypassPolicy callback that can intentionally route specific destinations directly (instead of through the configured managed proxy), and wires it into proxy decision-making across the runtime. This is intended to support cases like Gateway loopback bypass without mutating NO_PROXY.

Changes:

  • Introduces bypassPolicy types (ProxylineBypassPolicy, ProxylineBypassRequest) and exposes them in the public API.
  • Applies bypass decisions in managed resolver logic and updates the managed undici dispatcher implementation accordingly.
  • Adds unit + proxy-lab e2e coverage for direct bypass behavior.

Reviewed changes

Copilot reviewed 5 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/index.test.ts Adds a unit test asserting explain() returns a direct decision when bypass policy matches.
test/e2e.test.ts Adds an e2e test asserting node + undici traffic goes direct (no lab proxy events) when bypass policy matches.
src/types.ts Adds bypass policy option + request/policy types.
src/runtime.ts Implements bypass checks in the managed resolver; introduces a managed undici dispatcher to support bypass in undici.
src/index.ts Re-exports bypass policy types from the public entrypoint.
dist/types.d.ts Updates generated type declarations for new bypass policy types.
dist/types.d.ts.map Updates generated sourcemap for types.
dist/runtime.js Updates built runtime JS with bypass policy + managed undici dispatcher changes.
dist/runtime.d.ts.map Updates generated runtime d.ts sourcemap.
dist/index.d.ts Updates generated index d.ts exports.
dist/index.d.ts.map Updates generated index d.ts sourcemap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/runtime.ts
Comment on lines +355 to +356
const proxyUrl = url === undefined ? "" : this.#resolver.getProxyForUrl(url);
const dispatcher = proxyUrl === "" ? this.#directDispatcher : this.#proxyDispatcher(proxyUrl);
Comment thread src/runtime.ts
Comment on lines 305 to +310
getProxyForUrl: (url) => {
const protocol = new URL(url).protocol;
return isProxyableUrlProtocol(protocol) ? proxyUrl.href : "";
return isProxyableUrlProtocol(protocol) &&
!shouldBypassManagedProxy(bypassPolicy, url, "unknown")
? proxyUrl.href
: "";
@jesse-merhi jesse-merhi merged commit a1aa939 into main May 12, 2026
29 of 30 checks passed
@jesse-merhi jesse-merhi deleted the jesse/managed-bypass-policy branch May 12, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants