Documentation
¶
Overview ¶
Package setup routes one Codex home through a stage 2 edge and brain (codex-router setup), and undoes it. It edits the home's config.toml in marked blocks (plan M10) with the router provider and its token header (M9), stores the provider port and token in the home's state dir, and installs that home's service units through internal/service.
Index ¶
Constants ¶
const ConfigFile = "config.toml"
ConfigFile is Codex's config in a home.
const PluginEnvFile = "codex-router.env"
PluginEnvFile, in a Codex home, tells the codex-router plugin's scripts the binary and the state base setup used, as KEY=value lines. Codex runs plugin hooks with the env of whichever shell started the home's daemon, which may have neither on PATH or in XDG_STATE_HOME.
Variables ¶
This section is empty.
Functions ¶
func AddProvider ¶
AddProvider returns src with the router selected as model_provider and its provider table appended, both in marked blocks; blocks from an earlier setup are replaced. The rest of the file, comments included, stays byte for byte. It refuses a file that does not parse, sets model_provider itself, or already defines the router provider. The result is checked with a TOML parser: it must select the router and decode to the same settings as src otherwise.
func Diff ¶
Diff returns the line changes from a to b as hunks: a "@@ -i +j @@" header (1-based lines), then "-" and "+" lines. Token values are redacted. Setup only inserts and removes whole blocks, so a greedy resync is enough: it always yields a correct edit, and a minimal one for block edits.
func RemoveBlocks ¶
RemoveBlocks returns src without setup's marked blocks, and whether it had any. A block without its end marker is an error: the file was edited by hand and the block's extent is unknown.
Types ¶
type Options ¶
type Options struct {
Home home.Home
// HomePath is the home as the user gave it (home.Given), symlinks kept.
// The units get it as --home, so they resolve the same Home.Name.
HomePath string
// StateDir is the absolute state base, as $XDG_STATE_HOME; the units
// get it as --state-dir.
StateDir string
// Config is the codex-router config the units load; empty lets them
// use their default.
Config string
// Bin is the codex-router binary the units run.
Bin string
// DryRun prints what would change and writes nothing.
DryRun bool
// Undo removes the config blocks and the units; Purge also deletes the
// home's state dir.
Undo, Purge bool
// FollowSymlink allows editing a symlinked config.toml's target, where
// the token then lands (plan M9).
FollowSymlink bool
Service *service.Manager
Out io.Writer
// Now stamps backups; FreePort picks a port. Tests replace them.
Now func() time.Time
FreePort func() (int, error)
}
Options configure Run.