jipairamen on X (v0.1.4212): a Chrome translation extension pointed at
magpie's gateway address got, for every request,
403 "magpie's Codex relay serves Codex on this computer only".
Cause: that answer is not the gateway's. When magpie quits with Codex
running, it leaves `magpie codex-relay` at the gateway's port for the
Codex threads still open (codexrelay, 4534561f6). The relay judged who
asks before what is asked: any request with an Origin was refused with
the line above, so an extension's /v1/chat/completions never reached the
"magpie isn't running ... Open magpie" answer (relayGone) that every
other non-Codex call gets, and the doc already promised. The message
read as a permission rule, not as "magpie is closed".
Now a path other than /backend-api/codex/* gets relayGone (503) from any
caller, Origin or not; it passes nothing on, so who asks doesn't matter.
On Codex's own path a page, an extension, a null frame or a rebound name
is still refused (403), with a message that says magpie isn't running
and to open it. No origin rule changed: the relay still forwards only
loopback, Origin-less Codex requests, and the running gateway's
corsGuard is untouched (an unlisted chrome-extension:// origin was
already served keyless there by design; a listed one needs a key).
Siblings: the relay's LeavePath answers only the next magpie (token);
its "forbidden" there is not seen by users. No other handler holds the
gateway's port while magpie is quit.
Tests: TestCodexRelayTellsExtensionToOpenMagpie (chrome-extension://,
moz-extension://, https page, null; four paths; with and without a
key: 503 relayGone, nothing sent to OpenAI) and
TestCodexRelayOnlyThisComputer (now with an extension origin and the
"Open magpie" text). With the old codex_relay.go both FAIL:
--- FAIL: TestCodexRelayOnlyThisComputer
--- FAIL: TestCodexRelayTellsExtensionToOpenMagpie
and pass with the change.
Real use: built magpie (nogui) on mote, ran `magpie codex-relay --addr
127.0.0.1:34871 --pids <sleep>` under a sandbox HOME and curled it as
the extension: POST /v1/chat/completions with Origin
chrome-extension://... -> 503 "magpie isn't running: ... Open magpie for
everything else."; POST /backend-api/codex/responses with that Origin
-> 403 with the new text.
Run on mote at a9c98d8de (base b754cb095): gofmt -l (nothing), go vet
./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...,
go build, GOOS=linux go build -tags nogui, GOOS=windows go build: all
rc 0; go test -tags nogui -timeout 45m ./...: 101 packages ok, no FAIL
(internal/gateway 1081s).
After rebasing onto dcb0f3dcd (gateway, provider and app.js changed
upstream), at e27f946cf: go vet ./..., GOOS=linux and GOOS=windows go vet,
go build rc 0; go test -tags nogui -timeout 45m ./internal/gateway
./internal/provider ./internal/gui ./internal/codexrelay: all ok
(gateway 1086s, provider 335s, gui 296s).
Rebased onto f1c9014cd (agent/wsl, gateway fallback, masking, provider;
none of this change's files) before the push; at abaa78247 only go
build, go vet of gateway and codexrelay, and their TestCodexRelay*,
TestLeave*, TestEnds* were run: ok. The full suite was not rerun there.
Not tried: the user's own extension in Chrome; magpie's Settings page
doesn't change.