@agentclientprotocol/claude-agent-acp 0.104.0 → 0.104.1-preview.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,8 +94,8 @@ export declare class AuthStatusReporter {
94
94
  /**
95
95
  * Report the identity behind a session's `AccountInfo`.
96
96
  *
97
- * `AccountInfo` is richer than the CLI probe (it is what the live query
98
- * actually authenticates with). The v1 core calls it before the
97
+ * `AccountInfo` describes what the live query authenticates with, but lacks
98
+ * the CLI's plan tier. The v1 core calls it before the
99
99
  * `--hide-claude-auth` guard may refuse the session or the turn: that flag
100
100
  * blocks the *use* of a subscription, it does not make the state secret, and
101
101
  * a refusal is when the client most needs to know the account it was
@@ -139,8 +139,8 @@ export class AuthStatusReporter {
139
139
  /**
140
140
  * Report the identity behind a session's `AccountInfo`.
141
141
  *
142
- * `AccountInfo` is richer than the CLI probe (it is what the live query
143
- * actually authenticates with). The v1 core calls it before the
142
+ * `AccountInfo` describes what the live query authenticates with, but lacks
143
+ * the CLI's plan tier. The v1 core calls it before the
144
144
  * `--hide-claude-auth` guard may refuse the session or the turn: that flag
145
145
  * blocks the *use* of a subscription, it does not make the state secret, and
146
146
  * a refusal is when the client most needs to know the account it was
@@ -174,7 +174,7 @@ export class AuthStatusReporter {
174
174
  }
175
175
  const fromSession = fromAccountInfo(account, apiKeyHelper);
176
176
  if (fromSession) {
177
- this.set(fromSession);
177
+ this.set(mergeAuthStatus(this.current, fromSession, "session"));
178
178
  }
179
179
  else if (!this.loggedUninformativeAccount) {
180
180
  this.loggedUninformativeAccount = true;
@@ -281,7 +281,7 @@ export class AuthStatusReporter {
281
281
  // The CLI probe can be poorer than the session `AccountInfo` for the very
282
282
  // same login (no organization, say). Keep those extra fields rather than
283
283
  // regressing the payload; a different identity replaces it wholesale.
284
- const merged = mergeAuthStatus(this.current, status);
284
+ const merged = mergeAuthStatus(this.current, status, "cli");
285
285
  this.set(merged);
286
286
  this.options.onProbe?.(status.kind);
287
287
  return merged;
@@ -93,8 +93,10 @@ export type AcpAuthStatus = Pick<AuthStatusResponse, "state" | "accounts">;
93
93
  * - No identity read yet (`undefined`): `unknown`, no accounts.
94
94
  * - `kind: "none"`: `unauthenticated`, no accounts.
95
95
  * - Any other kind: `authenticated`, with the identity as the one account,
96
- * marked `active`. `_meta.claudeCode` carries the `kind`, `detail` and
97
- * `plan` that the account fields have no place for.
96
+ * marked `active`. The account has no field for `detail`, so its label
97
+ * carries it in parentheses, e.g. "Anthropic API key (ANTHROPIC_API_KEY)",
98
+ * for clients that show only the standard fields. `_meta.claudeCode`
99
+ * carries the `kind`, `detail` and `plan` on their own.
98
100
  *
99
101
  * `--hide-claude-auth` does not change the payload: it reports the login the
100
102
  * CLI holds, also when the subscription guard refuses to use it.
@@ -111,6 +113,8 @@ export type CliAuthStatus = {
111
113
  orgId?: string;
112
114
  orgName?: string;
113
115
  subscriptionType?: string;
116
+ /** CLI-only tier, e.g. "max_5x" or "max_20x"; not in SDK AccountInfo. */
117
+ planTier?: string;
114
118
  };
115
119
  export declare function notLoggedInAuthStatus(): AuthStatus;
116
120
  /** ACP-level gateway auth (`authenticate` with `gateway`/`gateway-bedrock`).
@@ -151,8 +155,10 @@ export declare function sameIdentity(a: AuthStatus, b: AuthStatus): boolean;
151
155
  * organization the CLI probe omits. So when the read describes the same
152
156
  * identity, its values win field by field but the fields it lacks are kept;
153
157
  * when it describes a different identity, it replaces the old one wholesale.
158
+ * Session reads lack the CLI's plan tier, so keep the label for the same plan.
159
+ * A CLI read always replaces the label, including when its tier is absent.
154
160
  */
155
- export declare function mergeAuthStatus(previous: AuthStatus | undefined, next: AuthStatus): AuthStatus;
161
+ export declare function mergeAuthStatus(previous: AuthStatus | undefined, next: AuthStatus, source: "cli" | "session"): AuthStatus;
156
162
  /**
157
163
  * Do two payloads carry the same information? Unlike {@link sameIdentity},
158
164
  * which asks "is this the same login", this compares every rendered field, so
@@ -1 +1 @@
1
- {"version":3,"file":"auth-status.d.ts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AU,CAuBZ;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAgBhF"}
@@ -63,8 +63,10 @@ export function authStatusCapability() {
63
63
  * - No identity read yet (`undefined`): `unknown`, no accounts.
64
64
  * - `kind: "none"`: `unauthenticated`, no accounts.
65
65
  * - Any other kind: `authenticated`, with the identity as the one account,
66
- * marked `active`. `_meta.claudeCode` carries the `kind`, `detail` and
67
- * `plan` that the account fields have no place for.
66
+ * marked `active`. The account has no field for `detail`, so its label
67
+ * carries it in parentheses, e.g. "Anthropic API key (ANTHROPIC_API_KEY)",
68
+ * for clients that show only the standard fields. `_meta.claudeCode`
69
+ * carries the `kind`, `detail` and `plan` on their own.
68
70
  *
69
71
  * `--hide-claude-auth` does not change the payload: it reports the login the
70
72
  * CLI holds, also when the subscription guard refuses to use it.
@@ -76,7 +78,8 @@ export function toAcpAuthStatus(status) {
76
78
  if (status.kind === "none") {
77
79
  return { state: "unauthenticated" };
78
80
  }
79
- const account = { label: status.label, active: true };
81
+ const label = status.detail ? `${status.label} (${status.detail})` : status.label;
82
+ const account = { label, active: true };
80
83
  if (status.account?.email)
81
84
  account.email = status.account.email;
82
85
  if (status.account?.organization)
@@ -203,6 +206,7 @@ export function fromCliStatus(stdout, apiKeyHelper) {
203
206
  return mapAuthFields({
204
207
  apiProvider: status.apiProvider,
205
208
  subscriptionType: status.subscriptionType,
209
+ planTier: status.planTier,
206
210
  apiKeySource: status.apiKeySource,
207
211
  email: status.email,
208
212
  organization: status.orgName,
@@ -253,19 +257,21 @@ function mapAuthFields(fields) {
253
257
  account.organization = organization;
254
258
  return {
255
259
  kind: "account",
256
- label: planLabel(subscriptionType),
260
+ label: planLabel(subscriptionType, fields.planTier),
257
261
  // No detail: the client falls back to `account.email` for line 2.
258
262
  account,
259
263
  };
260
264
  }
261
265
  return notLoggedInAuthStatus();
262
266
  }
263
- /** Names the plan with exactly one "Claude". A newer CLI already reports
264
- * "Claude Max", an older one reports "max", and both must read "Claude Max".
265
- * Each word is title-cased; a word that already carries capitals is kept. */
266
- function planLabel(plan) {
267
+ /** Names the plan with exactly one "Claude". Without a tier, "Claude Max"
268
+ * from a newer CLI and "max" from an older one both read "Claude Max".
269
+ * Each word is title-cased; a word that already carries capitals is kept.
270
+ * The CLI's max_20x tier identifies Ultra; other tiers keep the plan label. */
271
+ function planLabel(plan, planTier) {
267
272
  const titled = plan.replace(/\S+/g, (word) => word.charAt(0).toUpperCase() + word.slice(1));
268
- return /^claude(\s|$)/i.test(plan) ? titled : `Claude ${titled}`;
273
+ const label = /^claude(\s|$)/i.test(plan) ? titled : `Claude ${titled}`;
274
+ return label.toLowerCase() === "claude max" && planTier === "max_20x" ? "Claude Ultra" : label;
269
275
  }
270
276
  /**
271
277
  * Do two payloads describe the same login? Compared on the field that
@@ -291,8 +297,10 @@ export function sameIdentity(a, b) {
291
297
  * organization the CLI probe omits. So when the read describes the same
292
298
  * identity, its values win field by field but the fields it lacks are kept;
293
299
  * when it describes a different identity, it replaces the old one wholesale.
300
+ * Session reads lack the CLI's plan tier, so keep the label for the same plan.
301
+ * A CLI read always replaces the label, including when its tier is absent.
294
302
  */
295
- export function mergeAuthStatus(previous, next) {
303
+ export function mergeAuthStatus(previous, next, source) {
296
304
  if (!previous || !sameIdentity(previous, next)) {
297
305
  return next;
298
306
  }
@@ -303,6 +311,12 @@ export function mergeAuthStatus(previous, next) {
303
311
  if (previous.account || next.account) {
304
312
  merged.account = { ...previous.account, ...next.account };
305
313
  }
314
+ if (source === "session" &&
315
+ previous.account?.plan &&
316
+ next.account?.plan &&
317
+ planLabel(previous.account.plan).toLowerCase() === planLabel(next.account.plan).toLowerCase()) {
318
+ merged.label = previous.label;
319
+ }
306
320
  if (merged.vendor === undefined && previous.vendor !== undefined) {
307
321
  merged.vendor = previous.vendor;
308
322
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.104.0",
6
+ "version": "0.104.1-preview.2",
7
7
  "description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",