@agentclientprotocol/claude-agent-acp 0.109.1-preview.3 → 0.109.1-preview.4
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.
|
@@ -48,8 +48,7 @@ export declare class AuthStatusReporter {
|
|
|
48
48
|
private probeRuns;
|
|
49
49
|
/** The latest-started probe run that published its read. */
|
|
50
50
|
private publishedRun;
|
|
51
|
-
|
|
52
|
-
private sentAcp?;
|
|
51
|
+
private acpStatus;
|
|
53
52
|
constructor(options: AuthStatusReporterOptions);
|
|
54
53
|
/**
|
|
55
54
|
* Stores `next` and pushes it to the client, as `_auth/status_update` and
|
|
@@ -65,7 +64,7 @@ export declare class AuthStatusReporter {
|
|
|
65
64
|
* reach here at all (see the epoch check in the probe and the guards at
|
|
66
65
|
* session create).
|
|
67
66
|
*/
|
|
68
|
-
set(next: AuthStatus | undefined): void;
|
|
67
|
+
set(next: AuthStatus | undefined, refused?: boolean): void;
|
|
69
68
|
/**
|
|
70
69
|
* The `auth/status` answer: the identity the connection holds, which is
|
|
71
70
|
* also what the last `auth/status_update` said.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-status-reporter.d.ts","sourceRoot":"","sources":["../src/auth-status-reporter.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,OAAO,EAEZ,KAAK,QAAQ,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EACf,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"auth-status-reporter.d.ts","sourceRoot":"","sources":["../src/auth-status-reporter.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,OAAO,EAEZ,KAAK,QAAQ,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EACf,KAAK,cAAc,EAOpB,MAAM,kBAAkB,CAAC;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K;IACtB,4DAA4D;IAC5D,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,SAAS,CAAuC;gBAE3B,OAAO,EAAE,yBAAyB;IAE/D;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,OAAO,UAAQ,GAAG,IAAI;IAyBxD;;;;;;;;;;;;;;;;OAgBG;IACG,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC;IAStC,+EAA+E;IAC/E,OAAO,IAAI,IAAI;IAIf;;;OAGG;IACH,WAAW,CACT,OAAO,EAAE,kBAAkB,EAC3B,gBAAgB,CAAC,EAAE,QAAQ,EAC3B,SAAS,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IAkB5B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IA2BpF;;;;mBAIe;IACf,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAcrE,4EAA4E;YAC9D,QAAQ;CAgGvB;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAc/C"}
|
|
@@ -9,8 +9,9 @@ import { execFile } from "node:child_process";
|
|
|
9
9
|
import { promisify } from "node:util";
|
|
10
10
|
import { RequestError } from "@agentclientprotocol/sdk/unstable";
|
|
11
11
|
import { filterEscalatingDefaultMode, resolveSettings, } from "@anthropic-ai/claude-agent-sdk";
|
|
12
|
-
import { AUTH_STATUS_PROBE_TIMEOUT_MS,
|
|
12
|
+
import { AUTH_STATUS_PROBE_TIMEOUT_MS, cliAuthIdentity, fromAccountInfo, mergeAuthStatus, parseCliAuthStatus, sameAuthStatus, toAcpAuthStatus, } from "./auth-status.js";
|
|
13
13
|
import { claudeCliPath } from "./claude-cli.js";
|
|
14
|
+
import { claudeAuthRefusal, isClaudeEnterprisePlan, shouldHideClaudeAuth, } from "./hide-claude-auth.js";
|
|
14
15
|
const execFileAsync = promisify(execFile);
|
|
15
16
|
export class AuthStatusReporter {
|
|
16
17
|
options;
|
|
@@ -40,8 +41,7 @@ export class AuthStatusReporter {
|
|
|
40
41
|
probeRuns = 0;
|
|
41
42
|
/** The latest-started probe run that published its read. */
|
|
42
43
|
publishedRun = 0;
|
|
43
|
-
|
|
44
|
-
sentAcp;
|
|
44
|
+
acpStatus = { state: "unknown" };
|
|
45
45
|
constructor(options) {
|
|
46
46
|
this.options = options;
|
|
47
47
|
}
|
|
@@ -59,28 +59,24 @@ export class AuthStatusReporter {
|
|
|
59
59
|
* reach here at all (see the epoch check in the probe and the guards at
|
|
60
60
|
* session create).
|
|
61
61
|
*/
|
|
62
|
-
set(next) {
|
|
62
|
+
set(next, refused = false) {
|
|
63
63
|
if (!next) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
if (sameAuthStatus(this.current, next)) {
|
|
67
|
-
|
|
66
|
+
if (!sameAuthStatus(this.current, next)) {
|
|
67
|
+
this.current = next;
|
|
68
|
+
// Older clients still get the actual identity, including one the guard refused.
|
|
69
|
+
void Promise.resolve()
|
|
70
|
+
.then(() => this.options.push(next))
|
|
71
|
+
.catch((error) => {
|
|
72
|
+
this.options.logger.error("Failed to send _auth/status_update:", error);
|
|
73
|
+
});
|
|
68
74
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// drop it silently — send unconditionally and never fail a caller on it.
|
|
72
|
-
void Promise.resolve()
|
|
73
|
-
.then(() => this.options.push(next))
|
|
74
|
-
.catch((error) => {
|
|
75
|
-
this.options.logger.error("Failed to send _auth/status_update:", error);
|
|
76
|
-
});
|
|
77
|
-
// Compared on its own payload: two identities can map to the same one.
|
|
78
|
-
const acp = toAcpAuthStatus(next);
|
|
79
|
-
const sent = JSON.stringify(acp);
|
|
80
|
-
if (sent === this.sentAcp) {
|
|
75
|
+
const acp = toAcpAuthStatus(next, refused);
|
|
76
|
+
if (JSON.stringify(acp) === JSON.stringify(this.acpStatus)) {
|
|
81
77
|
return;
|
|
82
78
|
}
|
|
83
|
-
this.
|
|
79
|
+
this.acpStatus = acp;
|
|
84
80
|
void Promise.resolve()
|
|
85
81
|
.then(() => this.options.pushAcp(acp))
|
|
86
82
|
.catch((error) => {
|
|
@@ -111,7 +107,7 @@ export class AuthStatusReporter {
|
|
|
111
107
|
else {
|
|
112
108
|
await this.probe();
|
|
113
109
|
}
|
|
114
|
-
return
|
|
110
|
+
return this.acpStatus;
|
|
115
111
|
}
|
|
116
112
|
/** A login or a logout: any probe already running read the world before it. */
|
|
117
113
|
changed() {
|
|
@@ -173,8 +169,8 @@ export class AuthStatusReporter {
|
|
|
173
169
|
return;
|
|
174
170
|
}
|
|
175
171
|
const fromSession = fromAccountInfo(account, apiKeyHelper);
|
|
176
|
-
if (fromSession) {
|
|
177
|
-
this.set(mergeAuthStatus(this.current, fromSession, "session"));
|
|
172
|
+
if (account && fromSession) {
|
|
173
|
+
this.set(mergeAuthStatus(this.current, fromSession, "session"), shouldHideClaudeAuth() && claudeAuthRefusal(account) !== undefined);
|
|
178
174
|
}
|
|
179
175
|
else if (!this.loggedUninformativeAccount) {
|
|
180
176
|
this.loggedUninformativeAccount = true;
|
|
@@ -251,20 +247,21 @@ export class AuthStatusReporter {
|
|
|
251
247
|
}
|
|
252
248
|
stdout = failed.stdout;
|
|
253
249
|
}
|
|
254
|
-
|
|
250
|
+
const cli = parseCliAuthStatus(stdout);
|
|
251
|
+
if (!cli) {
|
|
252
|
+
logger.error("claude auth status returned unparseable output");
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
let status = cliAuthIdentity(cli, apiKeyHelper);
|
|
255
256
|
if (!context && status?.kind === "api_key" && status.detail === "API key helper") {
|
|
256
257
|
try {
|
|
257
258
|
const resolved = await resolveSettings({ cwd: process.cwd() });
|
|
258
|
-
status =
|
|
259
|
+
status = cliAuthIdentity(cli, filterEscalatingDefaultMode(resolved).apiKeyHelper);
|
|
259
260
|
}
|
|
260
261
|
catch {
|
|
261
262
|
logger.error("Could not resolve auth source settings");
|
|
262
263
|
}
|
|
263
264
|
}
|
|
264
|
-
if (!status) {
|
|
265
|
-
logger.error("claude auth status returned unparseable output");
|
|
266
|
-
return undefined;
|
|
267
|
-
}
|
|
268
265
|
if (epoch !== this.epoch) {
|
|
269
266
|
// A login or logout landed while this probe was running; the newer
|
|
270
267
|
// state wins and this answer is discarded, never published.
|
|
@@ -282,7 +279,13 @@ export class AuthStatusReporter {
|
|
|
282
279
|
// same login (no organization, say). Keep those extra fields rather than
|
|
283
280
|
// regressing the payload; a different identity replaces it wholesale.
|
|
284
281
|
const merged = mergeAuthStatus(this.current, status, "cli");
|
|
285
|
-
|
|
282
|
+
// The CLI names the effective credential, not the SDK's accountInfo tokenSource.
|
|
283
|
+
// An OAuth setup token can carry a plan but, like an API key, is allowed.
|
|
284
|
+
const refused = shouldHideClaudeAuth() &&
|
|
285
|
+
status.kind === "account" &&
|
|
286
|
+
cli.authMethod !== "oauth_token" &&
|
|
287
|
+
!isClaudeEnterprisePlan(cli.subscriptionType);
|
|
288
|
+
this.set(merged, refused);
|
|
286
289
|
this.options.onProbe?.(status.kind);
|
|
287
290
|
return merged;
|
|
288
291
|
}
|
package/dist/auth-status.d.ts
CHANGED
|
@@ -98,10 +98,10 @@ export type AcpAuthStatus = Pick<AuthStatusResponse, "state" | "accounts">;
|
|
|
98
98
|
* `_meta.claudeCode` carries the `kind` and `plan`, and the `detail` again
|
|
99
99
|
* for clients that read it there.
|
|
100
100
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
101
|
+
* The legacy extension still reports a refused identity for display. ACP
|
|
102
|
+
* reports that sign-in is needed instead of listing it as an active account.
|
|
103
103
|
*/
|
|
104
|
-
export declare function toAcpAuthStatus(status: AuthStatus | undefined): AcpAuthStatus;
|
|
104
|
+
export declare function toAcpAuthStatus(status: AuthStatus | undefined, refused?: boolean): AcpAuthStatus;
|
|
105
105
|
/** Shape of `claude auth status --json`. Absent fields are omitted, not null,
|
|
106
106
|
* and the logged-out case exits 1 while still printing valid JSON. */
|
|
107
107
|
export type CliAuthStatus = {
|
|
@@ -139,10 +139,9 @@ export declare function accountInfoHasIdentitySignal(account: AccountInfo | unde
|
|
|
139
139
|
* it is populated. Returns `undefined` when the account carries no identity
|
|
140
140
|
* signal, so callers keep the status they already know. */
|
|
141
141
|
export declare function fromAccountInfo(account: AccountInfo | undefined, apiKeyHelper?: string): AuthStatus | undefined;
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
export declare function fromCliStatus(stdout: string, apiKeyHelper?: string): AuthStatus | undefined;
|
|
142
|
+
/** An unreadable `claude auth status --json` result is unknown, not signed out. */
|
|
143
|
+
export declare function parseCliAuthStatus(stdout: string): CliAuthStatus | undefined;
|
|
144
|
+
export declare function cliAuthIdentity(status: CliAuthStatus, apiKeyHelper?: string): AuthStatus;
|
|
146
145
|
/**
|
|
147
146
|
* Do two payloads describe the same login? Compared on the field that
|
|
148
147
|
* identifies each kind — the key source for `api_key`, the email for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-status.d.ts","sourceRoot":"","sources":["../src/auth-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE;uEACuE;AACvE,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;6CAC6C;AAC7C,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC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,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAyBF,wBAAgB,qBAAqB,IAAI,UAAU,CAElD;AAED;kFACkF;AAClF,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAc9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAOtF;AAED;;4DAE4D;AAC5D,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,YAAY,CAAC,EAAE,MAAM,GACpB,UAAU,GAAG,SAAS,CAYxB;AAED,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAe5E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,UAAU,CA0BxF;AAyED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAYlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,UAAU,GAAG,SAAS,EAChC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,KAAK,GAAG,SAAS,GACxB,UAAU,CAuBZ;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAgBhF"}
|
package/dist/auth-status.js
CHANGED
|
@@ -68,14 +68,14 @@ export function authStatusCapability() {
|
|
|
68
68
|
* `_meta.claudeCode` carries the `kind` and `plan`, and the `detail` again
|
|
69
69
|
* for clients that read it there.
|
|
70
70
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
71
|
+
* The legacy extension still reports a refused identity for display. ACP
|
|
72
|
+
* reports that sign-in is needed instead of listing it as an active account.
|
|
73
73
|
*/
|
|
74
|
-
export function toAcpAuthStatus(status) {
|
|
74
|
+
export function toAcpAuthStatus(status, refused = false) {
|
|
75
75
|
if (!status) {
|
|
76
76
|
return { state: "unknown" };
|
|
77
77
|
}
|
|
78
|
-
if (status.kind === "none") {
|
|
78
|
+
if (refused || status.kind === "none") {
|
|
79
79
|
return { state: "unauthenticated" };
|
|
80
80
|
}
|
|
81
81
|
const account = { label: status.label, active: true };
|
|
@@ -172,10 +172,8 @@ export function fromAccountInfo(account, apiKeyHelper) {
|
|
|
172
172
|
apiKeyHelper,
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
* report "not known" instead of guessing. */
|
|
178
|
-
export function fromCliStatus(stdout, apiKeyHelper) {
|
|
175
|
+
/** An unreadable `claude auth status --json` result is unknown, not signed out. */
|
|
176
|
+
export function parseCliAuthStatus(stdout) {
|
|
179
177
|
let parsed;
|
|
180
178
|
try {
|
|
181
179
|
parsed = JSON.parse(stdout);
|
|
@@ -190,6 +188,9 @@ export function fromCliStatus(stdout, apiKeyHelper) {
|
|
|
190
188
|
if (typeof status.loggedIn !== "boolean") {
|
|
191
189
|
return undefined;
|
|
192
190
|
}
|
|
191
|
+
return status;
|
|
192
|
+
}
|
|
193
|
+
export function cliAuthIdentity(status, apiKeyHelper) {
|
|
193
194
|
// `loggedIn` tracks the claude.ai login only. On a 3P backend (Bedrock,
|
|
194
195
|
// Vertex, …) it is false while the credentials live outside the agent, so the
|
|
195
196
|
// backend must decide the kind before the logged-out shortcut runs.
|
package/package.json
CHANGED