Files
magpie/internal/provider/codex_daemon.go
T
yetone 8b0132b3d2 codex: the Codex app sends again on every system as soon as magpie takes a used-up ChatGPT account over, and gets it back at the reset
Ethereal499 and Isdavexxx on X, MasterYi on Discord, #540. The Codex app greys
Send for every model, magpie's too, while the ChatGPT account it is signed in
to is used up. Its composer's gate (ChatGPT.app 26.1013) reads authMethod
"chatgpt" plus rate limit allowed=false, and it asks account/read only when its
app-server starts. ef37b6fb7 (v0.1.1381) could fail in practice:
- (a) The reopen was macOS-only, ran once per time out, only from the GUI
  process. A Windows or Linux user, a magpie without its window, or a second
  time out stayed greyed.
- Switch-back: the app stayed on magpie (authMethod null, no cloud tasks or
  Log out) after the reset. Nothing restarted it.
- (c) Detection lag: the account was read every 5 minutes.
- The notice sat on the Providers page, not on Codex's Agents row.

Now:
- The gateway process (`provider.KeepCodexAppOnItsProvider`, every 3s, on
  every OS) ends the Codex app's own app-server each time `Agent.AppOut`
  flips, both ways. The app starts another at once and reads account/read
  afresh. Its window, threads and drafts stay.
- It never ends an app-server while a Codex request is in flight through
  magpie or ended in the last 10s (`Server.CodexBusy`, Codex's requests only),
  or while a session under the Codex home has a turn open (`codexTurnOpen`).
- It ends only the app's own app-server. That one runs on stdio; one another
  program starts with `--listen` is left alone (Miyi Helper runs one on this
  Mac). It must also run on magpie's Codex home (`proc.EnvOf`: ps -E on macOS,
  /proc on Linux; Windows can't tell).
- The exit is clean (`proc.End`: SIGTERM, or TerminateProcess with code 0 on
  Windows). The app shows any other exit as a crash.
- A listing that fails is taken up again at the next look. One that outlives
  3 ends, or is denied, makes the row say to quit and reopen.
- The active account is read every minute while it is held or a window is at
  90% or more (`codexLookEvery`).
- Codex's Agents row says "On magpie until <reset> · ChatGPT allowance used
  up". Hovering it, or opening the row, says what is off until then (cloud
  tasks, the usage meter, Log out) and that it all comes back on its own. In
  en, zh, zh-TW, ja and de.
- Removed: gui's keepCodexAppSending/codexAppOut, provider's episode
  bookkeeping, and the Providers-page notice.

Not changed, by design:
- A Codex own model that no magpie account serves stays as it is: magpie
  can't serve that turn.
- Account discovery off and "Only switch Codex's sign-in" (login=chatgpt) are
  the user's own choices, and are left alone.

Full suite green at cff1a9686 (on origin/main 6ce0f14b9), below. At
4541b3e97 (rebased on 430e3050d, which touched gateway.go, app.js and
i18n.js beside this) ran: gofmt -l, go build ./..., go vet on darwin,
linux (-tags nogui ./...) and windows; go test -run Codex ./internal/provider
./internal/agent ok; GUI codex-app-out (22 ok) and codex-app-stale (20 ok),
chromium and webkit. Pushed rebased on b92cb2f59 (two more commits,
neither in these files), built, not rerun.

Run at this commit (cff1a9686, on origin/main 6ce0f14b9), with a private
GOCACHE (another session ran go clean -cache mid-run):
- gofmt -l: clean. go build ./...: ok.
- go vet: darwin (touched packages); GOOS=linux -tags nogui ./...;
  GOOS=windows (touched packages).
- go test -count=1 -timeout 45m: internal/proc, internal/provider,
  internal/agent, internal/gateway, internal/gui all ok, skipping four
  tests red on main without this change, each already filed:
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632, a synctest crash
  since 091153bf) and TestFetchAsksOneListOnceForTwoBasesOfIt,
  TestFetchUnionsProtocolListsWithoutChat, TestFetchAsksASharedBaseOnce
  (#3854, since 6eb510f78). All three of the latter fail the same at
  origin/main 6ce0f14b9 and at 353519f55 without this commit.
- GUI at cff1a9686, chromium and webkit, 231 cases ok: codex-app-out (5 languages, 980 and 440px),
  i18n-keys, gui-de/ja/zh-tw, codex-app-stale, codex-accounts-via,
  agent-stale-copies, agent-app-restart, agent-failover, agent-connect,
  agent-layout, agent-expand-steady, agent-connected-unfolded,
  agent-notice-lang and codex-signin-always.
- Windows box (cross-built test binaries): proc and provider's Codex app
  tests pass. TestEndExitsClean passes there and goes red with exit code 1.
- Broken by hand, each went red:
  - Codex-only busy: TestCodexBusy.
  - The 90% cadence: TestCodexLookEvery.
  - The retry after a failed listing: TestCodexAppServerUnknown.
  - The turn guard: TestCodexAppServerRestartedEachWay.
  - The --listen exclusion: TestCodexAppOwnServer.
  - Code 0 on Windows: TestEndExitsClean.
  - The row's notice: codex-app-out.test.cjs, 4 of 4.
- Real app: ChatGPT.app 26.1013 in a sandbox HOME/CODEX_HOME, with this
  build serving on 3492/3493. Codex was put on magpie as Sync does for a held
  account (model_provider = "magpie", codex.out in stash.json). OpenAI's usage
  reading to the app was never faked.
  - The first listing ran out at load ~200, so the timeout is now 30s. The
    next look ended the app-server, and the app started another 12s later.
    Its profile went from "Pro · Usage · Log out" to "magpie" with no reopen,
    and /api/state carried appOut.
  - Undoing it ended the app-server again, and the profile came back to Pro,
    Usage and Log out.
  - The owner's own ChatGPT app (its app-server on ~/.codex) was never
    touched.
- One webkit codex-app-out run at load 291 had one red subtest, name lost.
  It passed 3 of 3 alone and in two full webkit runs.

Not tried:
- The Windows Store app (not installed on the box), and a real Codex app
  on Linux.
- A real used-up account.
- A turn running in the real app while the switch happens (unit-tested
  only).
2026-10-27 15:57:41 +08:00

543 lines
18 KiB
Go

package provider
// Codex's background app-server. Codex CLI (0.156 on) can keep one running
// for its sessions to attach to — `codex app-server --managed-daemon`,
// started by the CLI and left running — and it reads the ChatGPT sign-in
// once, when it starts. So when magpie switches the account Codex is signed
// in to, a Codex session opened after that still runs on the account before
// until the daemon is restarted. magpie doesn't restart it on its own:
// that ends the sessions running on it. It says so instead, and restarts it
// when asked (RestartCodexDaemon).
//
// The daemon is told apart by --managed-daemon: the app-servers other apps
// run for themselves (the ChatGPT app's own codex, an editor's) are started
// without it, and they are none of magpie's business.
import (
"bytes"
"context"
"encoding/json"
"errors"
"os"
"os/exec"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
"sync"
"time"
"github.com/yetone/magpie/internal/proc"
)
// CodexDaemonRestart is the command that restarts Codex's app-server, for
// the user to run themselves.
const CodexDaemonRestart = "codex app-server daemon restart"
// listProcesses lists the processes that may be Codex's; a var so tests
// can fake it.
var listProcesses = func(ctx context.Context) ([]proc.Process, error) {
return proc.List(ctx, "codex")
}
// processCodexHome is the CODEX_HOME a process was started with, when it
// can be read (Linux, a process of the user's): "" is unset. A var so tests
// can fake it.
var processCodexHome = func(pid int) (home string, ok bool) {
if runtime.GOOS != "linux" {
return "", false
}
b, err := os.ReadFile("/proc/" + strconv.Itoa(pid) + "/environ")
if err != nil {
return "", false
}
for _, kv := range bytes.Split(b, []byte{0}) {
if v, found := bytes.CutPrefix(kv, []byte("CODEX_HOME=")); found {
return string(v), true
}
}
return "", true
}
// codexHome is the Codex home magpie signs Codex in through.
func codexHome() string { return filepath.Dir(codexAuthPath()) }
// isManagedDaemon reports whether a command line is Codex's managed
// app-server: `codex [-c k=v…] app-server --managed-daemon …`. Its helpers
// (`codex app-server daemon pid-update-loop`), other apps' app-servers and
// other programs given those words aren't.
func isManagedDaemon(args string) bool {
f := strings.Fields(args)
i := slices.Index(f, "app-server")
if i < 1 || !slices.ContainsFunc(f[:i], func(a string) bool {
base := strings.ToLower(a[strings.LastIndexAny(a, `/\`)+1:])
return base == "codex" || base == "codex.exe"
}) {
return false
}
return slices.ContainsFunc(f[i+1:], func(a string) bool {
return a == "--managed-daemon" || strings.HasPrefix(a, "--managed-daemon=")
})
}
// daemonPIDs are the ids Codex wrote down for the app-server it runs out of
// home: app-server-daemon/app-server.pid (daemon.pid before), a PidRecord
// ({"pid": …, …}) or a bare number.
func daemonPIDs(home string) []int {
var ids []int
for _, name := range []string{"app-server.pid", "daemon.pid"} {
b, err := os.ReadFile(filepath.Join(home, "app-server-daemon", name))
if err != nil {
continue
}
if id, ok := parsePIDFile(b); ok {
ids = append(ids, id)
}
}
return ids
}
func parsePIDFile(b []byte) (int, bool) {
b = bytes.TrimSpace(b)
if id, err := strconv.Atoi(string(b)); err == nil && id > 0 {
return id, true
}
var rec struct {
PID int `json:"pid"`
}
if json.Unmarshal(b, &rec) == nil && rec.PID > 0 {
return rec.PID, true
}
return 0, false
}
// findCodexDaemon picks, among the running processes, Codex's managed
// app-server for home: 0 when none runs. One started for another
// CODEX_HOME is left out where that can be read; where it can't, the one
// home's pid file names is taken, else the first.
func findCodexDaemon(ps []proc.Process, home string) int {
var ids []int
for _, p := range ps {
if !isManagedDaemon(p.Args) {
continue
}
if h, ok := processCodexHome(p.PID); ok && h != "" && filepath.Clean(h) != filepath.Clean(home) {
continue
}
ids = append(ids, p.PID)
}
if len(ids) == 0 {
return 0
}
for _, id := range daemonPIDs(home) {
if slices.Contains(ids, id) {
return id
}
}
return ids[0]
}
// codexDaemonLeft is the app-server that was running when Codex's account
// last changed, and the account it was started on: it stays on that one
// until it restarts.
type leftDaemon struct {
pid int
user string
}
var (
codexDaemonMu sync.Mutex
codexDaemonLeft leftDaemon
codexDaemonChecked time.Time
// codexAppLeft is the Codex desktop app's own app-server (ChatGPT.app's
// CodexCLI.app) that was running when Codex's account changed: it
// keeps the account it started on until the app is quit and opened
// again (codex-rs AuthManager reloads auth.json only for the same
// account), so the app goes on reading that account's limits, and
// stops sending in every thread once those are spent.
codexAppLeft leftDaemon
)
// codexDaemonRecheck is how long CodexDaemonStale trusts what it last saw.
const codexDaemonRecheck = 5 * time.Second
// noteCodexSwitch remembers, when Codex's account changes from one to
// another, the app-server left running on the one before.
func noteCodexSwitch(from, to string) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
ps, err := listProcesses(ctx)
known := err == nil
codexDaemonMu.Lock()
defer codexDaemonMu.Unlock()
codexDaemonChecked = time.Now()
if !known {
return
}
noteLeft(&codexDaemonLeft, findCodexDaemon(ps, codexHome()), from, to)
noteLeft(&codexAppLeft, findCodexApp(ps), from, to)
}
// noteLeft updates what is known of the app-server pid, running as Codex's
// account changes from one to another.
func noteLeft(left *leftDaemon, pid int, from, to string) {
switch {
case pid == 0:
*left = leftDaemon{}
case pid == left.pid:
// it is on the account it started with, whatever came between
if strings.EqualFold(to, left.user) {
*left = leftDaemon{}
}
default:
*left = leftDaemon{pid, from}
}
}
// CodexDaemonStale answers the account Codex's app-server is still signed
// in to when Codex has been switched to another since it started, "" when
// it isn't running or is on the account Codex is.
func CodexDaemonStale() string {
codexDaemonMu.Lock()
defer codexDaemonMu.Unlock()
recheckLeft()
return codexDaemonLeft.user
}
// CodexAppStale answers the account the Codex desktop app is still signed
// in to when Codex has been switched to another since the app opened, ""
// when it isn't open or is on the account Codex is. The app shows that
// account's limits, and once they are spent won't send in any thread,
// until it is quit and opened again.
func CodexAppStale() string {
codexDaemonMu.Lock()
defer codexDaemonMu.Unlock()
recheckLeft()
return codexAppLeft.user
}
// recheckLeft forgets an app-server left on an account before that has
// restarted, or stopped, since: a new one reads the sign-in afresh. What
// was known stays when the processes can't be listed. codexDaemonMu is
// held.
func recheckLeft() {
if codexDaemonLeft.pid == 0 && codexAppLeft.pid == 0 || time.Since(codexDaemonChecked) <= codexDaemonRecheck {
return
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ps, err := listProcesses(ctx)
cancel()
codexDaemonChecked = time.Now()
if err != nil {
return
}
if findCodexDaemon(ps, codexHome()) != codexDaemonLeft.pid {
codexDaemonLeft = leftDaemon{}
}
if findCodexApp(ps) != codexAppLeft.pid {
codexAppLeft = leftDaemon{}
}
}
// DismissCodexDaemon stops saying the app-server is on another account.
func DismissCodexDaemon() {
codexDaemonMu.Lock()
defer codexDaemonMu.Unlock()
codexDaemonLeft = leftDaemon{}
}
// DismissCodexApp stops saying the Codex app is on another account.
func DismissCodexApp() {
codexDaemonMu.Lock()
defer codexDaemonMu.Unlock()
codexAppLeft = leftDaemon{}
}
// findCodexApp picks, among the running processes, the app-server the
// Codex desktop app runs for itself: 0 when it isn't open. On macOS that
// is ChatGPT.app's (or Codex.app's) bundled codex, `…/CodexCLI.app/
// Contents/MacOS/codex [-c k=v…] app-server --analytics-default-enabled …`;
// on Windows the Store app's `…\WindowsApps\OpenAI.Codex_…\codex.exe
// app-server`. Not the managed daemon, nor an app-server's helpers or
// proxy, nor an editor's codex.
func findCodexApp(ps []proc.Process) int {
for _, p := range ps {
if isCodexAppServer(p.Args) {
return p.PID
}
}
return 0
}
// isCodexAppServer is findCodexApp's test of one command line.
func isCodexAppServer(args string) bool {
if isManagedDaemon(args) {
return false
}
// the program's own path: ps leaves a path's spaces unquoted, so
// "…/Codex Computer Use.app/Contents/MacOS/…" reads as one named Codex
exe, rest := splitExe(args)
if !strings.Contains(exe, ".app/Contents/") && !strings.Contains(exe, `\WindowsApps\OpenAI.`) {
return false
}
if base := strings.ToLower(exe[strings.LastIndexAny(exe, `/\`)+1:]); base != "codex" && base != "codex.exe" {
return false
}
f := strings.Fields(rest)
i := slices.Index(f, "app-server")
return i >= 0 && (i+1 >= len(f) || strings.HasPrefix(f[i+1], "-"))
}
// RestartCodexDaemon has Codex restart its app-server, which reads the
// sign-in again: `codex app-server daemon restart`, run with the codex CLI
// magpie finds and the Codex home it signs Codex in through. Codex 0.162's
// sessions attached to it reconnect to the new one, a turn running is let
// finish first (for up to a minute); an older Codex's are ended.
func RestartCodexDaemon(ctx context.Context) error {
codexRestarting.Lock()
defer codexRestarting.Unlock()
if err := restartCodexDaemon(ctx, codexHome()); err != nil {
return err
}
DismissCodexDaemon()
return nil
}
func restartCodexDaemon(ctx context.Context, home string) error {
cmd, err := codexDaemonCommand(ctx, home, "restart")
if err != nil {
return err
}
// run as its own responsible process: the daemon it leaves running
// works in the folder of every codex attached to it, and macOS would
// otherwise ask for ~/Desktop and the like in magpie's name
// (reformed9448 on Discord)
if out, err := proc.CombinedOutputOwn(ctx, cmd); err != nil {
if msg := lastLine(out); msg != "" {
return errors.New("codex app-server daemon restart: " + msg)
}
return errors.New("codex app-server daemon restart: " + err.Error())
}
return nil
}
// codexDaemonCommand is `codex app-server daemon <verb>`, with CODEX_HOME
// set to the home magpie switches, and nothing to read on stdin (Codex
// waits on a stdin left open).
func codexDaemonCommand(ctx context.Context, home, verb string) (*exec.Cmd, error) {
exe := codexExecutable()
if exe == "" {
return nil, errors.New("the codex CLI isn't installed, or magpie can't find it")
}
cmd := proc.CommandContext(ctx, exe, "app-server", "daemon", verb)
env := slices.DeleteFunc(codexDaemonEnv(os.Environ()), func(kv string) bool { return strings.HasPrefix(kv, "CODEX_HOME=") })
cmd.Env = append(env, "CODEX_HOME="+home)
cmd.Stdin = nil // os/exec reads it from the null device
return cmd, nil
}
// daemonProxyVars are the proxy variables Codex reads, as proc.ProxyVars
// names them for the login shell.
var daemonProxyVars = []string{"HTTP_PROXY", "http_proxy", "HTTPS_PROXY", "https_proxy", "ALL_PROXY", "all_proxy", "NO_PROXY", "no_proxy"}
// daemonLoginEnv and daemonLoginPath are the login shell's variables and
// PATH ("" for none); vars so tests can say.
var (
daemonLoginEnv = proc.LoginEnv
daemonLoginPath = func() string { return strings.Join(proc.LoginPath(), string(os.PathListSeparator)) }
)
// codexDaemonEnv is env with the PATH and proxy variables a terminal opened
// now has, from the login shell: the daemon outlives the restart and
// serves every codex started after it, so it runs as one started from a
// terminal would. magpie opened from the desktop has neither: on Linux,
// with the proxy set in .zshrc, the daemon magpie restarted after a
// ChatGPT sign-in reached chatgpt.com directly, and every codex after it
// stopped at "account/read failed: workspace routing discovery timed out"
// until the daemon was restarted from a terminal (guotianci6 on X, Codex
// 0.164). The proxy variables are taken as a set: when the login shell
// names any, magpie's own are dropped, so a NO_PROXY only magpie has
// doesn't ride along; when it names none, env's stay.
func codexDaemonEnv(env []string) []string {
if runtime.GOOS == "windows" {
return env // a terminal's environment is the registry's, as magpie's is
}
var login []string
for _, k := range daemonProxyVars {
if v := daemonLoginEnv(k); v != "" {
login = append(login, k+"="+v)
}
}
path := daemonLoginPath()
out := make([]string, 0, len(env)+len(login))
for _, kv := range env {
k, _, _ := strings.Cut(kv, "=")
if (len(login) > 0 && slices.Contains(daemonProxyVars, k)) || (path != "" && k == "PATH") {
continue
}
out = append(out, kv)
}
if path != "" {
out = append(out, "PATH="+path)
}
return append(out, login...)
}
// The daemon also builds Codex's model list once, as it starts, from
// config.toml and the catalog it names (codex-rs app-server's models
// manager): a codex session started after magpie wires Codex in, or takes
// it out, attaches to the daemon left running and shows the list from
// before — Codex's own models, or magpie's — until it restarts (luci on
// Discord, Codex 0.162). It runs per CODEX_HOME, not per terminal, and
// has no idle exit. Restarting it with no codex session attached ends
// nothing, so magpie does that itself (KeepCodexDaemonCurrent); with one
// attached, the Agents page offers it.
// A CodexDaemonCheck is what KeepCodexDaemonCurrent found and did.
type CodexDaemonCheck struct {
// Behind: a daemon runs that started before what it reads changed
Behind bool
// Since is when that daemon started
Since time.Time
// Attached is how many codex sessions may be on it, which magpie
// doesn't restart it under
Attached int
// Restarted: magpie restarted it, and new sessions get the new list
Restarted bool
Err error
}
// codexRestarting keeps one restart of the daemon at a time.
var codexRestarting sync.Mutex
// KeepCodexDaemonCurrent restarts the managed app-server of the Codex home
// home when it started before changed (when magpie last changed what Codex
// reads at start) and no codex session is attached to it. One that can't
// be found or timed, or a restart already under way, is left as it is.
func KeepCodexDaemonCurrent(ctx context.Context, home string, changed time.Time) CodexDaemonCheck {
var c CodexDaemonCheck
if changed.IsZero() || !pidFileBehind(home, changed) {
return c
}
ps, err := listProcesses(ctx)
if err != nil {
return c
}
pid := findCodexDaemon(ps, home)
if pid == 0 {
return c
}
since, ok := daemonStarted(home, pid)
// a second's slack: the pid file and the config are written by
// different programs, whose clocks round differently
if !ok || !since.Before(changed.Add(-time.Second)) {
return c
}
c.Behind, c.Since, c.Attached = true, since, codexClients(ps, home)
if c.Attached > 0 || !codexRestarting.TryLock() {
return c
}
defer codexRestarting.Unlock()
if c.Err = restartCodexDaemon(ctx, home); c.Err == nil {
c.Restarted = true
}
return c
}
// pidFileBehind reports whether a pid file of home's was written before
// changed: only a daemon one names can be found behind (daemonStarted), so
// with none the processes aren't listed at all. Listing them is a
// PowerShell run on Windows, which every look did every codexDaemonEvery
// for as long as magpie ran (#2341).
func pidFileBehind(home string, changed time.Time) bool {
for _, pid := range daemonPIDs(home) {
if since, ok := daemonStarted(home, pid); ok && since.Before(changed.Add(-time.Second)) {
return true
}
}
return false
}
// daemonStarted is when the daemon pid started: the time Codex wrote its
// pid file, which it does once, as the daemon comes up, on every OS. ok is
// false when no pid file of home's names pid.
func daemonStarted(home string, pid int) (time.Time, bool) {
for _, name := range []string{"app-server.pid", "daemon.pid"} {
p := filepath.Join(home, "app-server-daemon", name)
b, err := os.ReadFile(p)
if err != nil {
continue
}
if id, ok := parsePIDFile(b); !ok || id != pid {
continue
}
if st, err := os.Stat(p); err == nil {
return st.ModTime(), true
}
}
return time.Time{}, false
}
// codexClients counts the codex sessions that may be attached to home's
// daemon: codex run in a terminal (its TUI, exec, resume, an app-server
// proxy); not the daemon, its helpers and the commands that drive it, nor
// an app's or an editor's codex, which serve themselves. One started for
// another CODEX_HOME is left out where that can be read.
func codexClients(ps []proc.Process, home string) int {
n := 0
for _, p := range ps {
if !isCodexClient(p.Args) {
continue
}
if h, ok := processCodexHome(p.PID); ok && h != "" && filepath.Clean(h) != filepath.Clean(home) {
continue
}
n++
}
return n
}
// isCodexClient reports whether a command line is a codex session that
// may attach to the daemon.
func isCodexClient(args string) bool {
exe, rest := splitExe(args)
base := strings.ToLower(exe[strings.LastIndexAny(exe, `/\`)+1:])
if base != "codex" && base != "codex.exe" {
return false
}
// an app's (ChatGPT.app's CodexCLI.app) or an editor extension's; ps
// leaves a path's spaces unquoted, so "…/Codex Computer Use.app/
// Contents/MacOS/…" reads as a program named Codex: the whole line
// is looked at
if strings.Contains(args, ".app/Contents/") || strings.Contains(exe, "/extensions/") || strings.Contains(exe, `\extensions\`) {
return false
}
f := strings.Fields(rest)
if slices.Contains(f, "exec-server") || slices.Contains(f, "mcp-server") {
return false
}
if i := slices.Index(f, "app-server"); i >= 0 {
// the daemon, its helpers, `daemon restart` and other apps'
// app-servers serve; a proxy is a client of the daemon
return i+1 < len(f) && f[i+1] == "proxy"
}
return true
}
// splitExe parts a command line into the program and its arguments, the
// program quoted as Windows lists it (`"C:\Program Files\…\codex.exe" …`).
func splitExe(args string) (exe, rest string) {
args = strings.TrimSpace(args)
if q, ok := strings.CutPrefix(args, `"`); ok {
if exe, rest, ok = strings.Cut(q, `"`); ok {
return exe, rest
}
}
exe, rest, _ = strings.Cut(args, " ")
return exe, rest
}
// CodexHome is the Codex home magpie wires and signs Codex in through.
func CodexHome() string { return codexHome() }