Repository navigation
feat(sandbox): serve the egress broker and inject the gateway config - #209
Merged
Merged
Conversation
Every backend gains a resolveEgress hook: at start the provider serves the broker on the runtime socket (TCP at the NAT gateway for WSL, which also grows a socat stub on guest loopback 8788), writes an optional guest codev.json, and announces it via CODEV_CONFIG — merged between the guest's global and project configs, so no image respin is needed. Broker routes can now carry header overrides: the guest holds a placeholder credential and the broker swaps in the real gateway token host-side, so it never enters the sandbox. The desktop resolves egress from the hub auth file at each sandbox start (rotation needs no restart), builds the guest provider block with buildGatewayConfig pointed at the guest broker stub, and forwards upstream through Electron's net stack so host proxy/PAC/trust roots apply. e2e-vz now proves the chain live: a guest pty curls the broker and the host reads the response from the shared workspace. Verified: vz e2e health OK / path api OK / broker OK on the Node-24 image; sandbox suite 75 pass, desktop 76 pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4a: the two halves of sandbox LLM egress the in-app e2e scoped — nothing served
broker.sock, and the guest's seeded config pointed at the defaultopencode.aiprovider (chat died ongetaddrinfo EAI_AGAIN).Broker (
broker.ts)BrokerRoutegainsheadersoverrides, applied case-insensitively over the forwarded headers: the guest carries a placeholder credential and the broker swaps in the real gateway token host-side — the token never enters the sandbox and rotation is a host concern.SandboxEgresstype:{ routes, guestConfig?, fetchImpl? }.Providers — new
resolveEgress?: () => Promise<SandboxEgress | null>hook, resolved at every startruntime/broker.sockbefore boot (codev-vmm dials it per guest connection);guestConfiglands in the existing read-only config share as/codev-config/codev.json.0.0.0.0, ephemeral port) because the guest reaches the host at the NAT default gateway, and the boot script grows a socat stub bridging guest127.0.0.1:8788→$HOST_IP:<port>— so the guest-side broker address is identical on all three backends. Guest config is bind-mounted at/codev-config. (The WSL egress firewall remains the separate 4c item.)CODEV_CONFIG, which the server merges between global and project config — no image respin needed.Desktop (
src/main/sandbox/egress.ts, fork-only)Reads the hub auth file (
@codev/gatewayloadApiKey) at each sandbox start, builds the guest provider block withbuildGatewayConfigpointed athttp://127.0.0.1:8788/llm/v1, routes/llm/v1→ the user's gateway with the real bearer token injected, and forwards upstream through Electron'snetstack so host proxy/PAC/enterprise trust roots apply without entering the guest. No gateway login →null→ the sandbox boots with no egress at all, exactly as before.Verification
health: OK / path api: OK / broker: OK— the new e2e stage has a guest pty curlhttp://127.0.0.1:8788/probe/...through vsock → broker → host upstream and reads the response back out of the shared workspace./codev-configmount +CODEV_CONFIGenv + host-side config file + live TCP broker with credential swap, driven through the fake wsl.exe).CHANGELOG entry added; DIVERGENCES desktop-wiring row extended for the
@codev/gatewaydep.🤖 Generated with Claude Code