fix(agents-login): capture a full user:profile-scoped Claude credential#739
Merged
Conversation
`claude setup-token` mints an inferenceOnly token (scope user:inference only, no user:profile), so runner Claude sessions could not resolve the account profile and showed "Claude API" instead of the subscription. Switch the Claude capture from `setup-token` to the interactive "Claude account with subscription" (claudeai) login, which mints the full-scope credential (user:profile + user:inference + refresh) and writes ~/.claude/.credentials.json + ~/.claude.json (oauthAccount): - Launch bare `claude`; seed onboarding flags in ~/.claude.json (only when absent) and write a managed-settings.json with forceLoginMethod=claudeai via CLAUDE_CODE_MANAGED_SETTINGS_PATH so the subscription method is pre-selected. - Bounded Enter-through navigation past the theme/intro screens until the authorize URL appears (reuses the existing URL-parse + code-paste path). - Capture the verbatim credentials_json + extracted oauthAccount (account_json); post both to agents-api (oauth_token kept optional for back-compat). Completion now keys off the credentials file, not a stdout token. Validated live that the claudeai authorize URL carries user:profile. Pairs with the agents-repo change that injects credentials_json + account_json into runners. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…anch threshold The full-credential capture added branches in credentials.ts (extractClaudeOauthToken / findStringField / extractClaudeAccountJson) that dropped global branch coverage to 79.57% (threshold 80%). Add focused tests for: token extraction from a nested accessToken field and from invalid JSON, and account_json presence/absence based on whether ~/.claude.json carries oauthAccount. Branch coverage now 83.37%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Runner Claude sessions showed "Claude API" instead of the Claude subscription. The worker captured a
claude setup-tokentoken, which isinferenceOnly— scopeduser:inferenceonly, nouser:profile. Claude Code resolves its subscription/header label from the OAuth account profile (oauthAccount), which needsuser:profile; without it, it falls back to "Claude API". (Live runner confirmed:/api/oauth/profile→permission_error … any_of(user:profile, user:office).)Change
Switch Claude capture from
setup-tokento the interactive "Claude account with subscription" (claudeai) login, which mints the full-scope credential (user:profile+user:inference+ refresh) and writes both~/.claude/.credentials.jsonand~/.claude.json(oauthAccount):claude; seed onboarding flags in~/.claude.json(only when absent) and write amanaged-settings.jsonwithforceLoginMethod=claudeaiviaCLAUDE_CODE_MANAGED_SETTINGS_PATHso the subscription method is pre-selected.credentials_json+ extractedoauthAccount(account_json); post both to agents-api (oauth_tokenkept optional for back-compat). Completion now keys off the credentials file, not a stdout token.Validated live that the
claudeaiauthorize URL carries…user:profile user:inference user:sessions:claude_code…. Pairs with the agents-repo change (ExtraToast/agents#121) that injectscredentials_json+account_jsoninto runners.Tests
vitest run: 10 files / 94 tests pass;tsc --noEmitclean.🤖 Generated with Claude Code