Skip to content

feat(cli): add edgee relay MITM proxy rerouting inference through the gateway#123

Open
SachaMorard wants to merge 1 commit into
mainfrom
feat/capture-mitm
Open

feat(cli): add edgee relay MITM proxy rerouting inference through the gateway#123
SachaMorard wants to merge 1 commit into
mainfrom
feat/capture-mitm

Conversation

@SachaMorard

Copy link
Copy Markdown
Member

What

Adds edgee relay [agent] — a local MITM proxy that logs LLM API traffic and reroutes inference requests to the Edgee gateway, giving local visibility into traffic that otherwise goes straight to the gateway (and bypasses the machine).

How it works

  • Terminates TLS with a locally-generated CA (rcgen), intercepts via hudsucker.
  • Reroutes inference paths to the gateway, preserving query + injecting x-edgee-api-key / x-edgee-session-id / x-edgee-repo:
    • /v1/messages, /v1/responses, /v1/chat/completions → same path on gateway
    • /backend-api/codex/responses (Codex ChatGPT backend) → remapped to /v1/responses
  • Reroute is gated by host (LLM provider domains) so unrelated hosts are untouched.
  • Everything else passes through to its original upstream.

Usage

edgee relay claude                    # spawn claude + reroute through gateway
edgee relay codex                     # spawn codex (Rust) — CA trusted via CODEX_CA_CERTIFICATE
edgee relay claude --no-launch        # proxy-only (external clients, e.g. Claude Desktop)
edgee relay claude --log-output ~/relay.log   # opt-in logging to a file
edgee launch claude --relay           # delegates to `edgee relay claude`

Logging (opt-in via --log-output <file>)

  • Request + response, full bodies (no truncation), gzip/br/zstd decoded for readability.
  • Request↔response correlation ids (#N) so parallel/interleaved traffic stays readable.
  • Atomic per-block writes; the forwarded response is left byte-for-byte untouched.

CA trust

  • Launched agents: injected automatically — NODE_EXTRA_CA_CERTS (Node/Claude) and CODEX_CA_CERTIFICATE (Codex/Rust).
  • External clients (--no-launch): trust the printed CA in the OS store (per-OS step).

Notes

  • Gated behind the relay feature (in default). Build dep aws-lc-rs needs a C toolchain (+ NASM on Windows); can fall back to ring if needed.
  • Reuses launch's gateway/auth resolution (resolve_gateway_base_url, provider keys).

Tests

  • Unit tests: URI rewrite + header injection, base-path prefix, Codex backend remap, gateway-URL parsing.
  • Integration smoke (witness gateway): inference rerouted with auth injected + path remapped; non-inference passed through untouched.
  • cargo fmt/clippy/test clean (default + --features relay).

🤖 Generated with Claude Code

…gh the gateway

`edgee relay [agent]` runs a local MITM proxy that logs LLM API traffic and
transparently reroutes inference requests (/v1/messages, /v1/responses,
/v1/chat/completions, and Codex's /backend-api/codex/responses → /v1/responses)
to the Edgee gateway, injecting x-edgee-* auth. Works for launched agents
(claude/codex) and external clients (--no-launch, e.g. Claude Desktop).

- Reuse hudsucker (MITM) + rcgen (local CA), gated behind the `relay` feature.
- Per-agent CA trust via NODE_EXTRA_CA_CERTS (Node) and CODEX_CA_CERTIFICATE (Rust).
- Opt-in logging via --log-output <file> (request+response, full bodies, decoded,
  req↔response correlation ids).
- `edgee launch claude --relay` delegates to the relay.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@SachaMorard SachaMorard requested a review from a team as a code owner June 30, 2026 14:26
Comment thread crates/cli/Cargo.toml
Comment on lines +42 to +45
hudsucker = { version = "0.24", optional = true }
rcgen = { version = "0.14", optional = true }
http-body-util = { workspace = true, optional = true }
bytes = { workspace = true, optional = true }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Crates should be declared at the workspace-level then be used with workspace = true on subcrates

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