@agentclientprotocol/claude-agent-acp 0.109.1-preview.1 → 0.109.1-preview.10
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.
- package/README.md +10 -5
- package/dist/acp-subagents.d.ts +39 -0
- package/dist/acp-subagents.d.ts.map +1 -1
- package/dist/acp-subagents.js +47 -0
- package/dist/auth-status-reporter.d.ts +2 -3
- package/dist/auth-status-reporter.d.ts.map +1 -1
- package/dist/auth-status-reporter.js +32 -29
- package/dist/auth-status.d.ts +6 -7
- package/dist/auth-status.d.ts.map +1 -1
- package/dist/auth-status.js +9 -8
- package/dist/client-system-prompt.d.ts +6 -4
- package/dist/client-system-prompt.d.ts.map +1 -1
- package/dist/client-system-prompt.js +7 -2
- package/dist/context-compaction.d.ts.map +1 -1
- package/dist/context-compaction.js +4 -3
- package/dist/native-subagents.d.ts +102 -7
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +208 -17
- package/dist/plans.d.ts +4 -4
- package/dist/providers.d.ts +34 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +37 -1
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/subagent-replay.d.ts +49 -33
- package/dist/subagent-replay.d.ts.map +1 -1
- package/dist/subagent-replay.js +49 -52
- package/dist/tool-calls/renderer.d.ts +0 -9
- package/dist/tool-calls/renderer.d.ts.map +1 -1
- package/dist/tool-calls/renderer.js +1 -19
- package/dist/tool-calls/reporters/interaction.d.ts +9 -0
- package/dist/tool-calls/reporters/interaction.d.ts.map +1 -1
- package/dist/tool-calls/reporters/interaction.js +23 -1
- package/dist/tool-calls/reporters/search.d.ts +7 -3
- package/dist/tool-calls/reporters/search.d.ts.map +1 -1
- package/dist/tool-calls/reporters/search.js +9 -4
- package/dist/v1/acp-agent.d.ts +35 -19
- package/dist/v1/acp-agent.d.ts.map +1 -1
- package/dist/v1/acp-agent.js +123 -67
- package/dist/v1/client-connection.d.ts +4 -2
- package/dist/v1/client-connection.d.ts.map +1 -1
- package/dist/v1/client-connection.js +6 -2
- package/dist/v1/session-fingerprint.d.ts.map +1 -1
- package/dist/v1/session-fingerprint.js +1 -2
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +53 -19
- package/dist/v2/auth.d.ts +6 -5
- package/dist/v2/auth.d.ts.map +1 -1
- package/dist/v2/auth.js +2 -2
- package/dist/v2/permissions.d.ts +1 -1
- package/dist/v2/permissions.js +1 -1
- package/dist/v2/replay-hold.d.ts +15 -5
- package/dist/v2/replay-hold.d.ts.map +1 -1
- package/dist/v2/replay-hold.js +21 -7
- package/dist/v2/reports.d.ts +4 -0
- package/dist/v2/reports.d.ts.map +1 -1
- package/dist/v2/reports.js +10 -1
- package/dist/v2/session-requests.js +3 -1
- package/dist/v2/session-update.js +3 -3
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +2 -0
- package/dist/v2/subagent-replay.d.ts +20 -18
- package/dist/v2/subagent-replay.d.ts.map +1 -1
- package/dist/v2/subagent-replay.js +16 -31
- package/dist/v2/tasks.d.ts +55 -6
- package/dist/v2/tasks.d.ts.map +1 -1
- package/dist/v2/tasks.js +147 -19
- package/dist/v2/tool-call.d.ts.map +1 -1
- package/dist/v2/tool-call.js +23 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -58,11 +58,11 @@ npm run build:binary
|
|
|
58
58
|
npm run smoke:binary # add `-- --full` to drive a real session; needs a Claude login
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
###
|
|
61
|
+
### ACP v2 (Preview)
|
|
62
62
|
|
|
63
|
-
The adapter also serves
|
|
64
|
-
a client that asks for protocol version 2 or later in `initialize` gets v2, and every other
|
|
65
|
-
gets v1.
|
|
63
|
+
The adapter also serves [ACP v2](https://agentclientprotocol.com/protocol/v2/overview), which is in
|
|
64
|
+
Preview: a client that asks for protocol version 2 or later in `initialize` gets v2, and every other
|
|
65
|
+
client gets v1. v2 is not frozen yet, and this surface changes with it.
|
|
66
66
|
|
|
67
67
|
`CLAUDE_AGENT_ACP_PROTOCOL` limits the adapter to one version. With `v1`, a client that asks
|
|
68
68
|
for v2 is negotiated down to v1. With `v2`, the adapter rejects the `initialize` of a v1 client.
|
|
@@ -75,9 +75,14 @@ with replay, which `replay_complete` ends, `session/close`, `session/prompt`, `s
|
|
|
75
75
|
compaction, display terminals for commands, permission requests, elicitation, providers, auth, and
|
|
76
76
|
[subagents](docs/subagent-sessions.md). Steering is v1 only for now.
|
|
77
77
|
|
|
78
|
+
On v2, the `command` of a stdio MCP server must be an absolute path, such as `/usr/local/bin/npx`.
|
|
79
|
+
`session/new`, `session/resume` and `session/fork` fail with `-32602` for a relative one, such as
|
|
80
|
+
`npx`. A v1 client can still send one.
|
|
81
|
+
|
|
78
82
|
`session/prompt` takes an `idempotencyKey`: a prompt that a client sends again with the same key
|
|
79
83
|
is inserted once, and the retry gets the first `messageId`. The key is known for as long as Claude
|
|
80
|
-
Code stores the message, also after a restart.
|
|
84
|
+
Code stores the message, also after a restart. A prompt that Claude Code does not store, such as a
|
|
85
|
+
local command, keeps its key until `session/close` or the end of the connection.
|
|
81
86
|
|
|
82
87
|
The adapter announces a session cursor (`cursor_update`) before each user message that follows
|
|
83
88
|
another entry of the conversation, live and in a replay. `session/fork` with its `cursorId` copies
|
package/dist/acp-subagents.d.ts
CHANGED
|
@@ -18,6 +18,45 @@ export type SubagentForm = "rfd" | "air";
|
|
|
18
18
|
* of an unknown session. `method` completes "the client cannot … it".
|
|
19
19
|
*/
|
|
20
20
|
export declare function restrictedChild(sessionId: string, method: string): RequestError;
|
|
21
|
+
/**
|
|
22
|
+
* The child sessions that the sessions of one connection announced with
|
|
23
|
+
* `subagent_update`, while they run or in the replay of a `session/load` or
|
|
24
|
+
* `session/resume`. The client knows such a session, so a request that names
|
|
25
|
+
* it fails as {@link restrictedChild} says, and not as a request of an unknown
|
|
26
|
+
* session.
|
|
27
|
+
*
|
|
28
|
+
* A child is known from its announcement until the client ends its root
|
|
29
|
+
* session ({@link rootClosed}): with `session/close`, or a request that closes
|
|
30
|
+
* the session too, such as `session/delete`. Nothing else removes it: after a
|
|
31
|
+
* conversation reset (`/clear`), a restart of the root's query or the end of
|
|
32
|
+
* the root's Claude Code process, the client still holds the child.
|
|
33
|
+
*
|
|
34
|
+
* AIR's draft announces a child with `subagent_spawned` and keeps its own
|
|
35
|
+
* rules, so its children are never known here.
|
|
36
|
+
*/
|
|
37
|
+
export declare class AnnouncedChildren {
|
|
38
|
+
/** The root session of each announced child session, by the child's id. */
|
|
39
|
+
private readonly rootByChild;
|
|
40
|
+
/**
|
|
41
|
+
* Takes a session update that goes to the client. A `subagent_update`
|
|
42
|
+
* announces the child session it names, or reports on one that is known
|
|
43
|
+
* already. The update's own session is the child's parent, which can be a
|
|
44
|
+
* child itself: its root is the child's too.
|
|
45
|
+
*/
|
|
46
|
+
sending(notification: {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
update: {
|
|
49
|
+
sessionUpdate: string;
|
|
50
|
+
sessionId?: unknown;
|
|
51
|
+
};
|
|
52
|
+
}): void;
|
|
53
|
+
/** Whether `sessionId` is a child session that the client knows. */
|
|
54
|
+
has(sessionId: string): boolean;
|
|
55
|
+
/** The root session of the child session `sessionId`, when the client knows it. */
|
|
56
|
+
rootOf(sessionId: string): string | undefined;
|
|
57
|
+
/** The client ended the session `rootSessionId`, and can no longer name its children. */
|
|
58
|
+
rootClosed(rootSessionId: string): void;
|
|
59
|
+
}
|
|
21
60
|
/** The form of native subagent sessions that the client gets, or none. */
|
|
22
61
|
export declare function subagentForm(capabilities?: ClientCapabilities | null): SubagentForm | undefined;
|
|
23
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-subagents.d.ts","sourceRoot":"","sources":["../src/acp-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAm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C;IACpB,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,CAAC,QAAQ,CAAC,GAC7B,qBAAqB,GACrB,mBAAmB,GACnB,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,GAAG;IACzE,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,mBAAmB,GAAG;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACnC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CASzF;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,sBAAsB,GACnC,mBAAmB,CAErB"}
|
package/dist/acp-subagents.js
CHANGED
|
@@ -9,6 +9,53 @@ export { AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY } from "./air-extension.js";
|
|
|
9
9
|
export function restrictedChild(sessionId, method) {
|
|
10
10
|
return RequestError.invalidParams({ sessionId }, `${sessionId} is a subagent session: the client cannot ${method} it. Its parent session runs it.`);
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The child sessions that the sessions of one connection announced with
|
|
14
|
+
* `subagent_update`, while they run or in the replay of a `session/load` or
|
|
15
|
+
* `session/resume`. The client knows such a session, so a request that names
|
|
16
|
+
* it fails as {@link restrictedChild} says, and not as a request of an unknown
|
|
17
|
+
* session.
|
|
18
|
+
*
|
|
19
|
+
* A child is known from its announcement until the client ends its root
|
|
20
|
+
* session ({@link rootClosed}): with `session/close`, or a request that closes
|
|
21
|
+
* the session too, such as `session/delete`. Nothing else removes it: after a
|
|
22
|
+
* conversation reset (`/clear`), a restart of the root's query or the end of
|
|
23
|
+
* the root's Claude Code process, the client still holds the child.
|
|
24
|
+
*
|
|
25
|
+
* AIR's draft announces a child with `subagent_spawned` and keeps its own
|
|
26
|
+
* rules, so its children are never known here.
|
|
27
|
+
*/
|
|
28
|
+
export class AnnouncedChildren {
|
|
29
|
+
/** The root session of each announced child session, by the child's id. */
|
|
30
|
+
rootByChild = new Map();
|
|
31
|
+
/**
|
|
32
|
+
* Takes a session update that goes to the client. A `subagent_update`
|
|
33
|
+
* announces the child session it names, or reports on one that is known
|
|
34
|
+
* already. The update's own session is the child's parent, which can be a
|
|
35
|
+
* child itself: its root is the child's too.
|
|
36
|
+
*/
|
|
37
|
+
sending(notification) {
|
|
38
|
+
const { sessionId: parent, update } = notification;
|
|
39
|
+
if (update.sessionUpdate !== "subagent_update" || typeof update.sessionId !== "string")
|
|
40
|
+
return;
|
|
41
|
+
this.rootByChild.set(update.sessionId, this.rootByChild.get(parent) ?? parent);
|
|
42
|
+
}
|
|
43
|
+
/** Whether `sessionId` is a child session that the client knows. */
|
|
44
|
+
has(sessionId) {
|
|
45
|
+
return this.rootByChild.has(sessionId);
|
|
46
|
+
}
|
|
47
|
+
/** The root session of the child session `sessionId`, when the client knows it. */
|
|
48
|
+
rootOf(sessionId) {
|
|
49
|
+
return this.rootByChild.get(sessionId);
|
|
50
|
+
}
|
|
51
|
+
/** The client ended the session `rootSessionId`, and can no longer name its children. */
|
|
52
|
+
rootClosed(rootSessionId) {
|
|
53
|
+
for (const [child, root] of this.rootByChild) {
|
|
54
|
+
if (root === rootSessionId)
|
|
55
|
+
this.rootByChild.delete(child);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
12
59
|
/** The form of native subagent sessions that the client gets, or none. */
|
|
13
60
|
export function subagentForm(capabilities) {
|
|
14
61
|
if (!clientSupportsSubagents(capabilities))
|
|
@@ -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;AAO1B,OAAO,KAAK,EAAE,eAAe,EA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C,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;AAErF,MAAM,MAAM,iBAAiB,GAAG;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E,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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The client-provided system prompt of the
|
|
2
|
+
* The client-provided system prompt of the `systemPrompt` field on
|
|
3
3
|
* `session/new`, `session/load`, `session/resume`, and `session/fork`.
|
|
4
4
|
*
|
|
5
5
|
* - `append` keeps the Claude Code preset and adds the text after it, the
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* The CLI records the system prompt of a conversation on its first request
|
|
12
12
|
* and reuses it on resume, so a different `systemPrompt` on a later
|
|
13
|
-
* `session/resume` takes effect at the next compaction.
|
|
13
|
+
* `session/resume` takes effect at the next compaction. ACP allows this
|
|
14
14
|
* deferral.
|
|
15
15
|
*/
|
|
16
16
|
import type { Options } from "@anthropic-ai/claude-agent-sdk";
|
|
@@ -28,8 +28,10 @@ export type ClientSystemPrompt = {
|
|
|
28
28
|
/**
|
|
29
29
|
* The mode and text of a `systemPrompt`, or `undefined` when the request has
|
|
30
30
|
* none. Throws `invalid_params` for a mode other than `append` and `override`
|
|
31
|
-
* and for a content block other than text:
|
|
32
|
-
* session, for a prompt the agent cannot apply.
|
|
31
|
+
* and for a content block other than text: ACP requires an error, and no
|
|
32
|
+
* session, for a prompt the agent cannot apply. Also for an empty `content`
|
|
33
|
+
* list, which a client must not send: the v2 schema rejects it before this
|
|
34
|
+
* runs, and a v1 client gets the same answer.
|
|
33
35
|
*/
|
|
34
36
|
export declare function clientSystemPrompt(systemPrompt: SystemPrompt | null | undefined): ClientSystemPrompt | undefined;
|
|
35
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-system-prompt.d.ts","sourceRoot":"","sources":["../src/client-system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,mCAAmC,CAAC;AAE3C,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB;;;;CAEuB,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E
|
|
1
|
+
{"version":3,"file":"client-system-prompt.d.ts","sourceRoot":"","sources":["../src/client-system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,mCAAmC,CAAC;AAE3C,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB;;;;CAEuB,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAC5C,kBAAkB,GAAG,SAAS,CA0BhC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,kBAAkB,EAC1B,kBAAkB,EAAE,MAAM,GAAG,SAAS,GACrC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAMtC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,kBAAkB,GAAG,SAAS,EAC5C,UAAU,EAAE,OAAO,EACnB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAetC"}
|
|
@@ -6,8 +6,10 @@ export const SYSTEM_PROMPT_CAPABILITY = {
|
|
|
6
6
|
/**
|
|
7
7
|
* The mode and text of a `systemPrompt`, or `undefined` when the request has
|
|
8
8
|
* none. Throws `invalid_params` for a mode other than `append` and `override`
|
|
9
|
-
* and for a content block other than text:
|
|
10
|
-
* session, for a prompt the agent cannot apply.
|
|
9
|
+
* and for a content block other than text: ACP requires an error, and no
|
|
10
|
+
* session, for a prompt the agent cannot apply. Also for an empty `content`
|
|
11
|
+
* list, which a client must not send: the v2 schema rejects it before this
|
|
12
|
+
* runs, and a v1 client gets the same answer.
|
|
11
13
|
*/
|
|
12
14
|
export function clientSystemPrompt(systemPrompt) {
|
|
13
15
|
if (systemPrompt == null)
|
|
@@ -16,6 +18,9 @@ export function clientSystemPrompt(systemPrompt) {
|
|
|
16
18
|
if (mode !== "append" && mode !== "override") {
|
|
17
19
|
throw RequestError.invalidParams({ systemPrompt: { mode } }, `Unsupported systemPrompt mode: ${mode}`);
|
|
18
20
|
}
|
|
21
|
+
if (content.length === 0) {
|
|
22
|
+
throw RequestError.invalidParams({ systemPrompt: { content } }, "systemPrompt content is empty. Send at least one text block, or leave systemPrompt out.");
|
|
23
|
+
}
|
|
19
24
|
const text = [];
|
|
20
25
|
for (const block of content) {
|
|
21
26
|
if (block.type !== "text") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-compaction.d.ts","sourceRoot":"","sources":["../src/context-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EACL,yBAAyB,EAG1B,MAAM,8BAA8B,CAAC;AAItC,KAAK,gBAAgB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAG/C;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,mBAAmB,CAAC;AAevE,KAAK,UAAU,GAAG,CAAC,YAAY,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvE,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC;gCAC4B;IAC5B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD,0FAA0F;IAC1F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAgB,+BAA+B,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,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;IACH,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAW/C,KAAK,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBhD;;;;;;;;;;OAUG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBzE;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO;IAerC,MAAM,CACV,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,GAAE,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAM,EACzD,cAAc,UAAQ,GACrB,OAAO,CAAC,IAAI,CAAC;IAyDhB;2EACuE;IACvE,OAAO,CAAC,IAAI;IAaZ,OAAO,CAAC,IAAI;YAIE,WAAW;CAO1B;AAoBD,+FAA+F;AAC/F,wBAAgB,qCAAqC,CACnD,eAAe,EAAE;IACf,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,EACD,EAAE,cAAsB,EAAE,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5D,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAW5C"}
|
|
@@ -311,9 +311,10 @@ export class ContextCompactionLifecycle {
|
|
|
311
311
|
status: terminalStatus,
|
|
312
312
|
...(summary !== undefined ? { summary: [{ type: "text", text: summary }] } : {}),
|
|
313
313
|
...(terminalStatus === "failed" && metadata.error ? { error: metadata.error } : {}),
|
|
314
|
-
// `_meta` is
|
|
315
|
-
//
|
|
316
|
-
//
|
|
314
|
+
// A `_meta` that is sent replaces the facts a client holds (the
|
|
315
|
+
// whole `_meta` on v1, its `jetbrains` key on v2): seed it with the
|
|
316
|
+
// first terminal, then only re-send it when the boundary adds facts,
|
|
317
|
+
// so a status-only duplicate can't wipe the token counts.
|
|
317
318
|
// The standard `error` field carries the error, so `_meta` does not.
|
|
318
319
|
// Only AIR gets the compaction facts.
|
|
319
320
|
...(this.airClient && (firstTerminal || hasMetadata)
|