mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-11-09 19:02:05 +00:00
fix: report setup-token logins as logged in (#1376)
Fixes #1295 With a `claude setup-token` login (`CLAUDE_CODE_OAUTH_TOKEN`), `claude auth status --json` only returns `{"loggedIn": true, "authMethod": "oauth_token", "apiProvider": "firstParty"}`. `fromCliStatus()` handed that to `mapAuthFields()`, which has no plan or key fields to go on and fell back to "Not logged in". Clients then showed a working session as logged out. This maps that exact state to `kind: "account"` with the label suggested in the issue ("Claude subscription", detail "OAuth token"). Everything else still goes through `mapAuthFields()`. Added a case to `auth-status.test.ts` that fails without the change. `npm run check`, `npm run build` and `npm run test:run` pass.
This commit is contained in:
@@ -210,6 +210,15 @@ export function fromCliStatus(stdout: string, apiKeyHelper?: string): AuthStatus
|
||||
if (!externalBackend && !status.loggedIn && !status.apiKeySource) {
|
||||
return notLoggedInAuthStatus();
|
||||
}
|
||||
if (
|
||||
status.loggedIn &&
|
||||
status.authMethod === "oauth_token" &&
|
||||
status.apiProvider === "firstParty" &&
|
||||
!status.apiKeySource &&
|
||||
!status.subscriptionType
|
||||
) {
|
||||
return { kind: "account", label: "Claude subscription", detail: "OAuth token" };
|
||||
}
|
||||
return mapAuthFields({
|
||||
apiProvider: status.apiProvider,
|
||||
subscriptionType: status.subscriptionType,
|
||||
|
||||
@@ -306,6 +306,14 @@ describe("auth status mappers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("maps a setup-token CLI login without profile fields to an account", () => {
|
||||
expect(
|
||||
fromCliStatus(
|
||||
JSON.stringify({ loggedIn: true, authMethod: "oauth_token", apiProvider: "firstParty" }),
|
||||
),
|
||||
).toEqual({ kind: "account", label: "Claude subscription", detail: "OAuth token" });
|
||||
});
|
||||
|
||||
it("lets a third-party backend outrank the logged-out flag", () => {
|
||||
// `loggedIn` tracks the claude.ai login only; on Bedrock the credentials
|
||||
// are external and the agent is authenticated all the same.
|
||||
|
||||
Reference in New Issue
Block a user