Files
devvm/testdata
w3cjandClaude Opus 5.5 62cdd16dd4 feat(agents): devvm agent login claude, Claude Code's login captured in the VM for every VM
Claude Code logs in from inside a VM, so this machine never needs it, and
devvm keeps one Claude Code login on the host for every VM with Claude
Code: the subscription's OAuth login, or a Claude Code token from claude
setup-token. The newest replaces the other. The VM holds placeholders
alone, so claude /login in a VM no longer leaves real tokens there.

- Capture: every VM's proxy captures at platform.claude.com and
  console.anthropic.com /v1/oauth/token (agentlogin.Endpoints), only for
  a VM whose image has Claude Code (netpolicy.Capturer). setup-token's
  code grant (expires_in, agentlogin.SetupToken) gives the claude secret
  (agentlogin.ClaudeToken, secrets.Token's checks) and the VM the
  secret's placeholder. Any other code grant goes in the store's
  .claude/.credentials.json (a File of kind agentlogin.ClaudeOAuth:
  claudeAiOauth accessToken, refreshToken, expiresAt ms, scopes); the
  VM's reply holds sk-ant-oat01-devvm-proxy-managed-oauth-<salt> and a
  managed refresh token, and the VM's own refresh is answered from the
  store. Refused: a new login without user:inference (Console), any
  login or refresh with org:create_api_key, an access token that isn't
  sk-ant-oat01- shaped.
- One login: saving the claude secret (captured or devvm secret set
  claude) removes the OAuth login, and an OAuth capture deletes the saved
  token, both under the claude logins folder's lock
  (agentlogin.LockFolder); a token that can't be deleted is a warning.
  CLAUDE_CODE_OAUTH_TOKEN in devvm's environment wins, as in Claude Code
  (secrets.ClaudeOf(store).Login). A launch gives the VM either
  CLAUDE_CODE_OAUTH_TOKEN or ~/.claude/.credentials.json (placeholder,
  managed refresh token, expiry 2099), never both. Both bindings
  (claude, claude-oauth) go into Authorization for api.anthropic.com
  while either login exists, and Store.Get gives each the login devvm
  keeps now, so a running VM survives the switch.
- Refresh: the host refreshes the OAuth login when due, JSON to
  platform.claude.com with Claude Code's client ID and the login's
  scopes, through the company proxy (proxy.RouteOf), under the file's
  lock; claude_refresh_failed says to log in again.
- devvm agent login claude [--setup-token]: claude auth login --claudeai
  or claude setup-token in the VM without CLAUDE_CODE_OAUTH_TOKEN, the
  code pasted back on this terminal (no forward); the VM is set up again
  once the store has a new login of the kind asked for
  (secrets.ClaudeOf(store).Sums); claude_env_token_wins when the
  environment's token wins. --device-code, --api-key and --stdin are
  usage errors with claude, --setup-token without it.
- Confirmed in Claude Code 2.1.317's linux-arm64 bundle (sha256 checked):
  TOKEN_URL platform.claude.com/v1/oauth/token, client ID
  9d1c250a-e61b-44d9-88ed-5944d1962f5e, the JSON code and refresh
  bodies, setup-token's expires_in 31536000 and user:inference scope,
  the claudeAiOauth fields, the anthropic-beta oauth-2025-04-20 header
  Claude Code sends itself, claude auth login's pasted code#state on
  stdin. The real claude auth login logged in in e2e against the fake.
- Messages: agent_login_claude_paste, claude_login_saved,
  claude_setup_token_saved, claude_env_token_wins,
  agent_login_claude_flag, agent_login_setup_token_alone,
  claude_refresh_failed, claude_no_login; no_claude_token,
  claude_token_invalid, claude_token_howto and not_setup_token point at
  devvm agent login claude.
- Tests: TestClaudeCapture, TestClaudeSetupToken, TestClaudeOAuthGet,
  TestCaptureRefuses' Claude cases (agentlogin); TestOneClaudeLogin,
  TestClaudeBindings, TestClaudeOAuthVMCopy (secrets); TestCapturer's
  Claude cases (netpolicy); agent_login.txtar's Claude section;
  network.txtar's bindings.
- e2e (network): the fake company proxy fakes Claude's token endpoint
  and Anthropic's API too; setup-token's request makes the claude secret;
  devvm agent login claude runs the real claude auth login, the store
  keeps the login, the claude secret goes, the VM holds placeholders and
  no token, the API gets the store's token for the VM's placeholder; a
  due login makes the host refresh through the company proxy (which
  fails there, as the host doesn't trust the run's CA).
- Docs: Claude Code login (using/coding-agents.md), first VM, the home
  page, README, commands, settings, safety/network.md, internals
  network.md, the design note's risk that this path is unofficial,
  Contributing's e2e, the proxy README; the CLI reference.

Security review (security-audit skill, an independent read):
- Fixed: a login granting org:create_api_key would let a VM make an API
  key through the binding and get it unread: refused, on refresh too.
- Fixed: a refresh could install a Console login when the store had
  none: the scope check applies to every new login.
- Fixed: any VM, without Claude Code, could replace the login or delete
  the token with a refresh grant: only a VM with Claude Code captures.
- Fixed: two captures at once could leave neither login: one lock.
- Fixed: a saved token that couldn't be deleted gave the VM a 502 for a
  saved login: a warning instead.
- Fixed: captured and refreshed access tokens are shape-checked.
- Accepted, documented: the bound login reaches every api.anthropic.com
  path its scopes allow (profile, sessions); any VM with Claude Code can
  replace the login; a token Claude Code mints in a VM for another use
  (install-github-app) becomes devvm's login.
- Unconfirmed: whether another Anthropic host also answers
  /v1/oauth/token (it would pass unguarded).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 20:18:20 -07:00
..
2026-10-24 09:50:15 -06:00