Help us shape the future of Go! Take the 2026 Go Developer Survey

codexrelay

package
v0.1.2649 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package codexrelay keeps the Codex threads open when magpie quits working until magpie is opened again or they end.

Codex signed in to ChatGPT sends its turns to magpie's gateway while magpie fails it over (agent.EndCodexFailover). At quit magpie takes that base URL out of Codex's config, but a thread already open, in the Codex app above all, keeps the URL it started with, and every turn after went to a closed port: "503 Service Unavailable: Unknown error" through a system proxy, "Connection refused" without one, until magpie was opened again (idkatbro on X). So at quit, with Codex running, magpie starts a small process of its own (`magpie codex-relay`) that takes the port up once the gateway lets go of it and passes those turns on to the ChatGPT backend on Codex's own sign-in (gateway.CodexRelay). It ends once every Codex process it was started for has, and leaves when the next magpie starts (Leave), finishing the turns it is streaming first: no running turn is cut.

Index

Constants

View Source
const (
	LeavePath   = "/.magpie-codex-relay/leave"
	TokenHeader = "X-Magpie-Relay-Token"
)

LeavePath is where the next magpie tells the relay to leave; with TokenHeader holding the token the relay wrote in its state file.

View Source
const Command = "codex-relay"

Command is the magpie command a relay runs as.

Variables

This section is empty.

Functions

func Leave

func Leave()

Leave tells a relay serving at the gateway's port to let go of it, for the magpie starting to serve there. It returns once the relay has closed its listener (its streams go on finishing), or at once when there is none.

func Main

func Main(args []string, h http.Handler) error

Main is `magpie codex-relay --addr host:port --pids 1,2`, serving h.

func Run

func Run(ctx context.Context, addr string, pids []int, h http.Handler) error

Run serves h at addr until ctx ends, the next magpie tells it to leave, or none of pids runs and nothing is in flight; then it finishes the requests it has, for up to drainFor.

func Start

func Start(addr string, pids []int) error

Start runs a relay at addr for the Codex processes pids, apart from this process so it outlives it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL