feat: report the auth detail as the account's description (#1591)

Stacked on the SDK 2.6.0 update (`acp-sdk-2.6.0`). Merge that first.

`auth/status` and `auth/status_update` carried the detail of an account,
such as the key source or the gateway host, in parentheses in its label:
`Anthropic API key (ANTHROPIC_API_KEY)`. SDK 2.6.0 adds
`AuthAccount.description` for it, so the account is now `label:
"Anthropic API key"` with `description: "ANTHROPIC_API_KEY"`.

`_meta.claudeCode.detail` still carries the detail for clients that read
it there. A client that shows only `label` no longer shows the detail.

The mapping is shared, so v1 and v2 both change.
`docs/air-extensions.md` is updated.
This commit is contained in:
Ben Brandt
2026-11-10 23:34:49 +01:00
committed by GitHub
parent 9fca22a03b
commit f6d6429187
3 changed files with 12 additions and 10 deletions

View File

@@ -228,7 +228,7 @@ The adapter keeps them where they are.
## Auth source display
The connection-scoped `_auth/status_update` continues to report agent-owned authentication, not client-owned `providers/set` routing. The adapter also reports the same identity through the ACP `auth/status` method and `auth/status_update` notification (advertised as `auth.status`), with `kind`, `detail` and `plan` under the account's `_meta.claudeCode`. The account's `label` also carries a `detail` in parentheses, e.g. `Anthropic API key (ANTHROPIC_API_KEY)`. Each notification is sent when its own payload changed. `auth/status` answers with the identity last reported and starts a new read, whose change arrives as a notification. When the active key source is `apiKeyHelper`, the adapter reads the effective helper command through SDK `resolveSettings` / the session's `SettingsManager`, including programmatic settings overrides.
The connection-scoped `_auth/status_update` continues to report agent-owned authentication, not client-owned `providers/set` routing. The adapter also reports the same identity through the ACP `auth/status` method and `auth/status_update` notification (advertised as `auth.status`), with `kind`, `detail` and `plan` under the account's `_meta.claudeCode`. The account's `description` carries the `detail` too, e.g. `label: "Anthropic API key"` with `description: "ANTHROPIC_API_KEY"`. Each notification is sent when its own payload changed. `auth/status` answers with the identity last reported and starts a new read, whose change arrives as a notification. When the active key source is `apiKeyHelper`, the adapter reads the effective helper command through SDK `resolveSettings` / the session's `SettingsManager`, including programmatic settings overrides.
A command containing the whole word `central` and the word sequence `proxy start` is displayed as:

View File

@@ -104,10 +104,10 @@ export type AcpAuthStatus = Pick<AuthStatusResponse, "state" | "accounts">;
* - No identity read yet (`undefined`): `unknown`, no accounts.
* - `kind: "none"`: `unauthenticated`, no accounts.
* - Any other kind: `authenticated`, with the identity as the one account,
* marked `active`. The account has no field for `detail`, so its label
* carries it in parentheses, e.g. "Anthropic API key (ANTHROPIC_API_KEY)",
* for clients that show only the standard fields. `_meta.claudeCode`
* carries the `kind`, `detail` and `plan` on their own.
* marked `active`. `detail` is the account's `description`, e.g. label
* "Anthropic API key" with description "ANTHROPIC_API_KEY".
* `_meta.claudeCode` carries the `kind` and `plan`, and the `detail` again
* for clients that read it there.
*
* `--hide-claude-auth` does not change the payload: it reports the login the
* CLI holds, also when the subscription guard refuses to use it.
@@ -119,8 +119,8 @@ export function toAcpAuthStatus(status: AuthStatus | undefined): AcpAuthStatus {
if (status.kind === "none") {
return { state: "unauthenticated" };
}
const label = status.detail ? `${status.label} (${status.detail})` : status.label;
const account: AuthAccount = { label, active: true };
const account: AuthAccount = { label: status.label, active: true };
if (status.detail) account.description = status.detail;
if (status.account?.email) account.email = status.account.email;
if (status.account?.organization) account.organization = status.account.organization;
account._meta = {

View File

@@ -220,7 +220,8 @@ describe("auth status mappers", () => {
state: "authenticated",
accounts: [
{
label: "Anthropic API key (env)",
label: "Anthropic API key",
description: "env",
active: true,
_meta: { claudeCode: { kind: "api_key", detail: "env" } },
},
@@ -842,7 +843,8 @@ describe("auth status over ACP", () => {
state: "authenticated",
accounts: [
{
label: "Custom model gateway (gw.example.com)",
label: "Custom model gateway",
description: "gw.example.com",
active: true,
_meta: { claudeCode: { kind: "gateway", detail: "gw.example.com" } },
},
@@ -860,7 +862,7 @@ describe("auth status over ACP", () => {
agent.setAuthStatus({ kind: "api_key", label: "Anthropic API key", detail: "env" });
expect(await agent.authStatusResponse()).toMatchObject({
state: "authenticated",
accounts: [{ label: "Anthropic API key (env)" }],
accounts: [{ label: "Anthropic API key", description: "env" }],
});
});