msg.Fake's writers use cmp.Or in place of orDiscard, which only Fake
called, and LoopbackForward.Ports, which only its test called, is the
test's own listening helper.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
devvm agent login codex|opencode logs the agent in from inside this
folder's VM, so this machine never needs Codex or opencode, and devvm's
agent store keeps the login for every VM with the agent. It sits under
devvm agent beside import and save: it fills the store, as they do, and
a bare devvm login would read as a verb on the VM itself.
- Browser login (the default): the agent's own login runs in the VM on
this terminal (codex -c cli_auth_credentials_store="file" login;
opencode auth login --provider openai --method "ChatGPT Pro/Plus
(browser)"), and devvm forwards this machine's localhost:1455, and
1457 (Codex's fallback) when free, on 127.0.0.1 and ::1, to the same
ports on the VM's loopback, only while the login runs: closed when it
ends, fails or is interrupted (AddCleanup), and an interrupt also ends
the agent's login in the VM (its pid kept in ~/.cache/devvm-login.pid),
so its server doesn't linger for the VM's port forwarder. Port 1455
taken on this machine: refused, naming --device-code.
- --device-code: codex login --device-auth, or opencode's headless
ChatGPT login; nothing forwarded.
- --api-key [--provider anthropic|openai|openrouter] [--stdin]: the key
is asked for on this machine (msg.Question answered by --stdin) and
saved in the store, never in the VM: Codex's auth.json becomes
{auth_mode: apikey, OPENAI_API_KEY}, opencode's gets the provider's
{type: api, key} beside the others; the running VM gets its copy with
a placeholder and its proxy the binding at once.
- The proxy's capture (agentlogin's capturers) saves ChatGPT logins;
devvm then confirms what the store saved, with the account's email,
and fails when the login saved nothing new.
- opencode 1.19.5 has no Anthropic OAuth in its core (no Anthropic
plugin among its built-ins), so there's no pasted-code capturer:
Anthropic is an API key. opencode's OpenAI login listens on 1455 only;
Codex 0.166 on 1455, falling back to 1457.
- vmssh: SSH.ForwardLoopback (LoopbackForward: listeners in devvm's own
process, each connection its own ssh -W to the VM's 127.0.0.1, no
master; ErrPortTaken).
- agentlogin: KeyProviders, File.SetKey, File.ChatGPT.
- secrets: Store.SaveKey, LoginSum, ChatGPT (loginsDir shared with
Capture).
- vm: AgentLogin (agentlogin.go), LoginAgents.
- cli: agentlogin.go (--device-code, --api-key, --provider, --stdin,
--here/--parent); usage errors before anything runs.
- assets/guest/sync.sh: cli_auth_credentials_store = "file" first in
the VM's ~/.codex/config.toml on every launch.
- Messages: agent_login_* and agent_key_*; codex_no_key,
codex_no_chatgpt, codex_refresh_failed and opencode_refresh_failed
point at devvm agent login.
- Tests: agent_login.txtar (usage errors, no VM, no agent, device code
argv, browser forward and its end, the agent failing, a login saved
while it runs, port taken, interrupt, API keys, the VM's copy failing,
no terminal, an empty key), unit tests for the forward, SetKey,
ChatGPT, SaveKey, the confirmation and the argv; coverage baselines
raised.
- e2e (network): the real Codex's login in the VM against the run's
fake token endpoint, its callback opened through the forward, the
store's tokens and key, placeholders in the VM, the forward gone; an
interrupted login takes its forward away.
- Docs: Logging in with devvm agent login (using/coding-agents.md),
the Commands page, the questions table, Contributing's e2e, the cli
skill's tree, AGENTS.md; the CLI reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>