@agentclientprotocol/claude-agent-acp 0.112.1-preview.1 → 0.112.1-preview.3

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.
Files changed (46) hide show
  1. package/README.md +1 -0
  2. package/dist/adapter-command.d.ts +56 -0
  3. package/dist/adapter-command.d.ts.map +1 -0
  4. package/dist/adapter-command.js +74 -0
  5. package/dist/claude-cli.d.ts +2 -0
  6. package/dist/claude-cli.d.ts.map +1 -1
  7. package/dist/claude-cli.js +5 -1
  8. package/dist/mcp-command.d.ts.map +1 -1
  9. package/dist/mcp-command.js +1 -14
  10. package/dist/plugin-command.d.ts +94 -0
  11. package/dist/plugin-command.d.ts.map +1 -0
  12. package/dist/plugin-command.js +633 -0
  13. package/dist/slash-commands.d.ts +1 -1
  14. package/dist/slash-commands.d.ts.map +1 -1
  15. package/dist/slash-commands.js +5 -12
  16. package/dist/usage-markdown.d.ts +4 -0
  17. package/dist/usage-markdown.d.ts.map +1 -1
  18. package/dist/usage-markdown.js +13 -0
  19. package/dist/v1/acp-agent.d.ts +16 -10
  20. package/dist/v1/acp-agent.d.ts.map +1 -1
  21. package/dist/v1/acp-agent.js +125 -77
  22. package/dist/v1/adapter-commands.d.ts +78 -0
  23. package/dist/v1/adapter-commands.d.ts.map +1 -0
  24. package/dist/v1/adapter-commands.js +124 -0
  25. package/dist/v1/remote-control.d.ts +10 -34
  26. package/dist/v1/remote-control.d.ts.map +1 -1
  27. package/dist/v1/remote-control.js +6 -26
  28. package/dist/v2/{remote-control.d.ts → adapter-commands.d.ts} +34 -17
  29. package/dist/v2/adapter-commands.d.ts.map +1 -0
  30. package/dist/v2/adapter-commands.js +121 -0
  31. package/dist/v2/agent.d.ts.map +1 -1
  32. package/dist/v2/agent.js +3 -2
  33. package/dist/v2/commands.d.ts +5 -4
  34. package/dist/v2/commands.d.ts.map +1 -1
  35. package/dist/v2/commands.js +4 -2
  36. package/dist/v2/session.d.ts +14 -8
  37. package/dist/v2/session.d.ts.map +1 -1
  38. package/dist/v2/session.js +68 -38
  39. package/dist/v2/subscription-guard.d.ts +2 -1
  40. package/dist/v2/subscription-guard.d.ts.map +1 -1
  41. package/dist/v2/tasks.d.ts +9 -2
  42. package/dist/v2/tasks.d.ts.map +1 -1
  43. package/dist/v2/tasks.js +80 -15
  44. package/package.json +1 -1
  45. package/dist/v2/remote-control.d.ts.map +0 -1
  46. package/dist/v2/remote-control.js +0 -97
@@ -0,0 +1,78 @@
1
+ import type { Query } from "@anthropic-ai/claude-agent-sdk";
2
+ import { type AdapterCommand, type AdapterCommandContext, adapterCommand } from "../adapter-command.js";
3
+ import type { RemoteControlCommand } from "../remote-control.js";
4
+ import type { TurnEvents } from "./turn-events.js";
5
+ /** What the commands need of their session and its agent. */
6
+ export interface AdapterCommandsHost {
7
+ /** The `RequestError` text for a session that has ended. */
8
+ readonly sessionEndedMessage: string;
9
+ /** This session's query. A rewind leaves a successor session with its own. */
10
+ query(): Query;
11
+ /** Claude Code's terminal-bound commands, which it does not offer. */
12
+ terminalCommands(): readonly string[] | undefined;
13
+ /** Whether Claude is working in the session (see `ClaudeAcpAgent.claudeIsWorking`). */
14
+ claudeIsWorking(): boolean;
15
+ /** Starts the reader of the session's query stream, if none runs yet. */
16
+ ensureConsumer(): void;
17
+ /** Sends `text` to the client as an agent message. */
18
+ reply(text: string): Promise<void>;
19
+ /** Whether the session is still the agent's current one and its query is open. */
20
+ alive(): boolean;
21
+ /** Why the prompt received as number `received` must not start: its session
22
+ * was closed, or a `session/cancel` came after the prompt. */
23
+ endedBeforeStart(received: number): "closed" | "cancelled" | undefined;
24
+ /** Records the `/remote-control` that was asked, so that a restart of the
25
+ * query keeps what the user chose last (see `RemoteControlAtStartup.commandRan`). */
26
+ commandRan(command: RemoteControlCommand): void;
27
+ context(): AdapterCommandContext;
28
+ }
29
+ export declare class AdapterCommands {
30
+ private readonly host;
31
+ /**
32
+ * What runs, from its request to its answer: an adapter command, or Remote
33
+ * Control starting with the query (see `connectAtStartup`). `abort` stops a
34
+ * command on `session/cancel` and teardown; the start of Remote Control has
35
+ * none, as it can't be stopped.
36
+ */
37
+ private running;
38
+ constructor(host: AdapterCommandsHost);
39
+ /** Whether something runs, so that the session is busy for idle compaction
40
+ * and rewind, and a command is refused. */
41
+ get busy(): boolean;
42
+ /** Settles when what runs has ended, failed or not. The prompts wait for it. */
43
+ get done(): Promise<void> | undefined;
44
+ /** Stops the command that runs, which then sends no reply. */
45
+ abort(): void;
46
+ /**
47
+ * Settles when the command that `abort` stops has ended, for a close to wait
48
+ * for. Not for the start of Remote Control: a cancel does not stop it, and a
49
+ * request that never answers would hold the close for the whole timeout.
50
+ */
51
+ abortedEnd(): Promise<void> | undefined;
52
+ /** The adapter command of `prompt`, or `null` for a prompt that goes to Claude Code. */
53
+ lookup(prompt: Parameters<typeof adapterCommand>[0]): Promise<AdapterCommand | null>;
54
+ /** Refuses a command that cannot start now: the session ended, a turn runs,
55
+ * or another command does. */
56
+ assertCanStart(command: AdapterCommand): void;
57
+ /**
58
+ * Starts the command, which the adapter answers without a model turn. The
59
+ * refusals of {@link assertCanStart} throw synchronously. A close or cancel
60
+ * that came before the command started ends the prompt `cancelled` when
61
+ * `events` is passed (a prompt), and throws when it is not (`steer`, which
62
+ * has no prompt to end). The promise settles once the command and its reply
63
+ * are done.
64
+ */
65
+ begin(command: AdapterCommand, received: number, events?: Pick<TurnEvents, "inserted" | "ended">): Promise<void>;
66
+ /**
67
+ * Runs `change`, Remote Control starting with the query, which answers into
68
+ * the session's output, with the session's prompts held back until it is
69
+ * done. Nothing awaits before the hold is set, so no prompt can start between
70
+ * the caller's checks and the hold. The query stream's reader starts first,
71
+ * as in {@link begin}. The hold has no `abort`: a `session/cancel` does not
72
+ * stop `change`, as Remote Control cannot be un-started.
73
+ */
74
+ hold(change: () => Promise<void>): Promise<void>;
75
+ private run;
76
+ private occupy;
77
+ }
78
+ //# sourceMappingURL=adapter-commands.d.ts.map
@@ -0,0 +1 @@
1
+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,GAAG,SAAS,CAEpC;IAED,8DAA8D;IAC9D,KAAK,IAAI,IAAI;IAIb;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS;IAIvC,wFAAwF;IACxF,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IASpF;mCAC+B;IAC/B,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAW7C;;;;;;;OAOG;IACH,KAAK,CACH,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC;IA6BhB;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAKlC,GAAG;YAKH,MAAM;CAQrB"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * The commands the adapter serves itself on the v1 core (`/remote-control` and
3
+ * `/plugin`, see `../adapter-command.ts`), and the session's slot that they
4
+ * share with Remote Control starting with the query.
5
+ *
6
+ * Their reply goes straight to the client, not through the turn queue, so it
7
+ * would land inside the output of a turn that is running. v1 therefore refuses
8
+ * a command while Claude works or another command runs, and holds the prompts
9
+ * that follow back until the reply is sent, as they would start a turn that the
10
+ * reply lands in. (v2 holds the command instead: `src/v2/adapter-commands.ts`.)
11
+ */
12
+ import { randomUUID } from "node:crypto";
13
+ import { RequestError } from "@agentclientprotocol/sdk/unstable";
14
+ import { adapterCommand, } from "../adapter-command.js";
15
+ export class AdapterCommands {
16
+ host;
17
+ /**
18
+ * What runs, from its request to its answer: an adapter command, or Remote
19
+ * Control starting with the query (see `connectAtStartup`). `abort` stops a
20
+ * command on `session/cancel` and teardown; the start of Remote Control has
21
+ * none, as it can't be stopped.
22
+ */
23
+ running;
24
+ constructor(host) {
25
+ this.host = host;
26
+ }
27
+ /** Whether something runs, so that the session is busy for idle compaction
28
+ * and rewind, and a command is refused. */
29
+ get busy() {
30
+ return this.running !== undefined;
31
+ }
32
+ /** Settles when what runs has ended, failed or not. The prompts wait for it. */
33
+ get done() {
34
+ return this.running?.done;
35
+ }
36
+ /** Stops the command that runs, which then sends no reply. */
37
+ abort() {
38
+ this.running?.abort?.abort();
39
+ }
40
+ /**
41
+ * Settles when the command that `abort` stops has ended, for a close to wait
42
+ * for. Not for the start of Remote Control: a cancel does not stop it, and a
43
+ * request that never answers would hold the close for the whole timeout.
44
+ */
45
+ abortedEnd() {
46
+ return this.running?.abort && this.running.done.catch(() => { });
47
+ }
48
+ /** The adapter command of `prompt`, or `null` for a prompt that goes to Claude Code. */
49
+ lookup(prompt) {
50
+ return adapterCommand(prompt, this.host.query(), this.host.terminalCommands(), this.host.context());
51
+ }
52
+ /** Refuses a command that cannot start now: the session ended, a turn runs,
53
+ * or another command does. */
54
+ assertCanStart(command) {
55
+ if (!this.host.alive())
56
+ throw RequestError.internalError(undefined, this.host.sessionEndedMessage);
57
+ // `claudeIsWorking` also covers a cycle that Claude Code started on its own,
58
+ // such as its follow-up after a background subagent finished.
59
+ if (this.host.claudeIsWorking()) {
60
+ throw RequestError.invalidRequest(undefined, command.busyMessage);
61
+ }
62
+ if (this.running)
63
+ throw RequestError.invalidRequest(undefined, command.inFlightMessage);
64
+ }
65
+ /**
66
+ * Starts the command, which the adapter answers without a model turn. The
67
+ * refusals of {@link assertCanStart} throw synchronously. A close or cancel
68
+ * that came before the command started ends the prompt `cancelled` when
69
+ * `events` is passed (a prompt), and throws when it is not (`steer`, which
70
+ * has no prompt to end). The promise settles once the command and its reply
71
+ * are done.
72
+ */
73
+ begin(command, received, events) {
74
+ const ended = this.host.endedBeforeStart(received);
75
+ if (ended) {
76
+ if (!events) {
77
+ throw ended === "closed"
78
+ ? RequestError.internalError(undefined, this.host.sessionEndedMessage)
79
+ : RequestError.requestCancelled(undefined, "The command was cancelled before it started.");
80
+ }
81
+ events.ended({ stopReason: "cancelled" });
82
+ return Promise.resolve();
83
+ }
84
+ this.assertCanStart(command);
85
+ if (command.remoteControl)
86
+ this.host.commandRan(command.remoteControl);
87
+ // Once Remote Control is on, other clients can start turns on their own.
88
+ // The reader starts after the session's setup response, so a command that
89
+ // comes before it answers without a turn and leaves the stream unread.
90
+ this.host.ensureConsumer();
91
+ events?.inserted(randomUUID());
92
+ // A command can take a network call or a minute-long `git clone`.
93
+ const abort = new AbortController();
94
+ const done = this.run(command, abort.signal);
95
+ return this.occupy({ done, abort }).then(() => events?.ended({ stopReason: abort.signal.aborted ? "cancelled" : "end_turn" }));
96
+ }
97
+ /**
98
+ * Runs `change`, Remote Control starting with the query, which answers into
99
+ * the session's output, with the session's prompts held back until it is
100
+ * done. Nothing awaits before the hold is set, so no prompt can start between
101
+ * the caller's checks and the hold. The query stream's reader starts first,
102
+ * as in {@link begin}. The hold has no `abort`: a `session/cancel` does not
103
+ * stop `change`, as Remote Control cannot be un-started.
104
+ */
105
+ hold(change) {
106
+ this.host.ensureConsumer();
107
+ return this.occupy({ done: change() });
108
+ }
109
+ async run(command, signal) {
110
+ const text = await command.run(signal);
111
+ if (!signal.aborted)
112
+ await this.host.reply(text);
113
+ }
114
+ async occupy(held) {
115
+ this.running = held;
116
+ try {
117
+ await held.done;
118
+ }
119
+ finally {
120
+ if (this.running === held)
121
+ this.running = undefined;
122
+ }
123
+ }
124
+ }
@@ -1,51 +1,27 @@
1
1
  /**
2
- * Remote Control on the v1 core, besides what both cores share
3
- * (`../remote-control.ts`): holding a session's prompts back while Remote
4
- * Control changes. The adapter's `/remote-control` answers without a model
5
- * turn, and Remote Control that starts with a query answers in a notice.
6
- * Neither answer goes through the turn queue, so the prompts that follow wait
7
- * for it: a prompt that started a turn meanwhile would have the answer land in
8
- * that turn.
2
+ * Remote Control at the start of a query on the v1 core, besides what both
3
+ * cores share (`../remote-control.ts`). It answers in a notice, which does not
4
+ * go through the turn queue, so it holds the session's prompts back in the
5
+ * `AdapterCommands` slot, as the adapter's `/remote-control` does.
9
6
  */
10
7
  import type { RemoteControlAtStartup, RemoteControlAtStartupSession } from "../remote-control.js";
11
8
  import type { SessionNotice } from "../session-notices.js";
12
- /** What holding prompts back needs of a v1 session. */
13
- export type PromptHoldingSession = {
14
- /**
15
- * The Remote Control change that is running, from its request to its
16
- * answer: a `/remote-control` command, or Remote Control starting with the
17
- * query. Prompts wait for it, and a `/remote-control` is refused meanwhile:
18
- * v1 refuses a command rather than hold it, as it does while Claude works.
19
- */
20
- remoteControlCommand?: Promise<void>;
21
- };
22
- /**
23
- * Runs `change`, a change of Remote Control that answers into the session's
24
- * output, and holds the session's prompts back until it is done. Nothing
25
- * awaits before the hold is set, so no prompt can start between the caller's
26
- * checks and the hold. `readStream` starts the reader of the query stream
27
- * first: once Remote Control is on, other clients can start turns or send
28
- * messages on their own, and something has to read the stream for those to
29
- * reach this client.
30
- */
31
- export declare function holdingPrompts(session: PromptHoldingSession, readStream: () => void, change: () => Promise<void>): Promise<void>;
9
+ import type { AdapterCommands } from "./adapter-commands.js";
32
10
  /** What starting Remote Control with a query needs of a v1 session and its agent. */
33
11
  export type StartupConnection = RemoteControlAtStartupSession & {
34
- /** Starts the reader of the session's query stream, if none runs yet. */
35
- readStream(): void;
36
12
  /** Sends `notice` to the client, as a transcript line to one without notices. */
37
13
  notice(notice: SessionNotice): Promise<void>;
38
14
  };
39
15
  /**
40
16
  * Starts Remote Control with the session's query when Claude Code asked for it
41
17
  * (see `RemoteControlAtStartup`), and holds the session's prompts back until
42
- * its notice is sent. A `/remote-control` command that runs meanwhile makes
43
- * the session busy too: Remote Control is that command's to decide. One that
44
- * comes while this runs is refused, as during another command. A query
18
+ * its notice is sent. An adapter command (`/remote-control`, `/plugin`) that
19
+ * runs meanwhile makes the session busy too, so this does not start then. One
20
+ * that comes while this runs is refused, as during another command. A query
45
21
  * that closed before the answer, as by a restart or a close, gets no notice:
46
22
  * it would report on Remote Control that ended with that query.
47
23
  */
48
- export declare function connectAtStartup(session: PromptHoldingSession & {
24
+ export declare function connectAtStartup(session: {
49
25
  remoteControlAtStartup?: RemoteControlAtStartup;
50
- }, connection: StartupConnection): Promise<void>;
26
+ }, commands: AdapterCommands, connection: StartupConnection): Promise<void>;
51
27
  //# sourceMappingURL=remote-control.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote-control.d.ts","sourceRoot":"","sources":["../../src/v1/remote-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,oBAAoB,EAC7B,UAAU,EAAE,MAAM,IAAI,EACtB,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC1B,OAAO,CAAC,IAAI,CAAC,CASf;AAED,qFAAqF;AACrF,MAAM,MAAM,iBAAiB,GAAG,6BAA6B,GAAG;IAC9D,yEAAyE;IACzE,UAAU,IAAI,IAAI,CAAC;IACnB,iFAAiF;IACjF,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,oBAAoB,GAAG;IAAE,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;CAAE,EACnF,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAqBf"}
1
+ {"version":3,"file":"remote-control.d.ts","sourceRoot":"","sources":["../../src/v1/remote-control.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qFAAqF;AACrF,MAAM,MAAM,iBAAiB,GAAG,6BAA6B,GAAG;IAC9D,iFAAiF;IACjF,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE;IAAE,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;CAAE,EAC5D,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiBf"}
@@ -1,41 +1,21 @@
1
- /**
2
- * Runs `change`, a change of Remote Control that answers into the session's
3
- * output, and holds the session's prompts back until it is done. Nothing
4
- * awaits before the hold is set, so no prompt can start between the caller's
5
- * checks and the hold. `readStream` starts the reader of the query stream
6
- * first: once Remote Control is on, other clients can start turns or send
7
- * messages on their own, and something has to read the stream for those to
8
- * reach this client.
9
- */
10
- export async function holdingPrompts(session, readStream, change) {
11
- readStream();
12
- const running = change();
13
- session.remoteControlCommand = running;
14
- try {
15
- await running;
16
- }
17
- finally {
18
- session.remoteControlCommand = undefined;
19
- }
20
- }
21
1
  /**
22
2
  * Starts Remote Control with the session's query when Claude Code asked for it
23
3
  * (see `RemoteControlAtStartup`), and holds the session's prompts back until
24
- * its notice is sent. A `/remote-control` command that runs meanwhile makes
25
- * the session busy too: Remote Control is that command's to decide. One that
26
- * comes while this runs is refused, as during another command. A query
4
+ * its notice is sent. An adapter command (`/remote-control`, `/plugin`) that
5
+ * runs meanwhile makes the session busy too, so this does not start then. One
6
+ * that comes while this runs is refused, as during another command. A query
27
7
  * that closed before the answer, as by a restart or a close, gets no notice:
28
8
  * it would report on Remote Control that ended with that query.
29
9
  */
30
- export async function connectAtStartup(session, connection) {
10
+ export async function connectAtStartup(session, commands, connection) {
31
11
  const notice = session.remoteControlAtStartup?.connect({
32
12
  ...connection,
33
- working: () => connection.working() || session.remoteControlCommand !== undefined,
13
+ working: () => connection.working() || commands.busy,
34
14
  });
35
15
  if (!notice)
36
16
  return;
37
17
  try {
38
- await holdingPrompts(session, () => connection.readStream(), async () => {
18
+ await commands.hold(async () => {
39
19
  const answer = await notice;
40
20
  if (connection.query())
41
21
  await connection.notice(answer);
@@ -1,9 +1,18 @@
1
1
  import type { Query, SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
2
+ import { mayBeAdapterCommand, type AdapterCommandContext } from "../adapter-command.js";
2
3
  import type { Logger } from "../logger.js";
3
- import { parseRemoteControlCommand, RemoteControlAtStartup } from "../remote-control.js";
4
+ import { RemoteControlAtStartup } from "../remote-control.js";
4
5
  import type { SessionNotice } from "../session-notices.js";
5
- /** What the command needs of its session. */
6
- export interface RemoteControlHost {
6
+ /** How {@link SessionAdapterCommands.run} handled a prompt. */
7
+ export type AdapterCommandOutcome =
8
+ /** The adapter does not serve the prompt, which goes to Claude Code. */
9
+ "not-served"
10
+ /** The command ran as its turn. */
11
+ | "ran"
12
+ /** A cancel or close answered the prompt before the command began. */
13
+ | "answered";
14
+ /** What the commands need of their session. */
15
+ export interface AdapterCommandsHost extends Pick<AdapterCommandContext, "cwd" | "env" | "remoteSession"> {
7
16
  readonly logger: Logger;
8
17
  readonly sessionId: string;
9
18
  query(): Query | undefined;
@@ -13,14 +22,17 @@ export interface RemoteControlHost {
13
22
  idle(): Promise<boolean>;
14
23
  /** Inserts the prompt `uuid` and opens its turn. */
15
24
  begin(uuid: string): void;
16
- /** Sends the reply `text`, as agent text of the message `messageId`, and ends the turn. */
17
- end(text: string, messageId: string): void;
25
+ /** Ends the turn, after the reply `text` as agent text of the message `messageId`, if any. */
26
+ end(reply: {
27
+ text: string;
28
+ messageId: string;
29
+ } | undefined): void;
18
30
  /** Whether a turn is open or a prompt waits in Claude Code's queue. */
19
31
  working(): boolean;
20
32
  /** Sends `notice` to the client. */
21
33
  notice(notice: SessionNotice): void;
22
34
  }
23
- export declare class SessionRemoteControl {
35
+ export declare class SessionAdapterCommands {
24
36
  private readonly host;
25
37
  /** The uuids of the prompts that this session sent, until Claude Code echoes them. */
26
38
  private readonly sent;
@@ -29,7 +41,7 @@ export declare class SessionRemoteControl {
29
41
  * at `initialize` (see `V2Session.setRemoteControlAtStartup`).
30
42
  */
31
43
  atStartup: RemoteControlAtStartup;
32
- constructor(host: RemoteControlHost);
44
+ constructor(host: AdapterCommandsHost);
33
45
  /**
34
46
  * Starts Remote Control after the setup response of a query that Claude
35
47
  * Code asked to start with it, and reports how it went in a notice (see
@@ -45,17 +57,22 @@ export declare class SessionRemoteControl {
45
57
  * that the user turned off there stays off (see
46
58
  * `RemoteControlAtStartup.restartedFrom`).
47
59
  */
48
- restartedFrom(previous: SessionRemoteControl): void;
49
- /** Whether `prompt` may be the adapter's command, which {@link run} then decides. */
50
- mayRun(prompt: Parameters<typeof parseRemoteControlCommand>[0]): boolean;
60
+ restartedFrom(previous: SessionAdapterCommands): void;
61
+ /** The running command's abort, while one runs. */
62
+ private abortCommand;
63
+ /** Whether `prompt` may be an adapter command, which {@link run} then decides. */
64
+ mayRun(prompt: Parameters<typeof mayBeAdapterCommand>[0]): boolean;
51
65
  /**
52
- * Runs `prompt` as the adapter's command, as its turn, once the session is
53
- * idle. Resolves `false` without running it when Claude Code serves the
54
- * command itself or the query has no Remote Control: the prompt then goes
55
- * to Claude Code. `stillPending` tells whether a cancel or close answered
56
- * the prompt meanwhile.
66
+ * Runs `prompt` as an adapter command, as its turn, once the session is
67
+ * idle. Resolves `"not-served"` without running it when the adapter does
68
+ * not serve it (Claude Code offers the command itself, or the session
69
+ * cannot run it): the prompt then goes to Claude Code. `stillPending`
70
+ * tells whether a cancel or close answered the prompt meanwhile, which
71
+ * resolves `"answered"` without running it.
57
72
  */
58
- run(prompt: Parameters<typeof parseRemoteControlCommand>[0], uuid: string, stillPending: () => boolean): Promise<boolean>;
73
+ run(prompt: Parameters<typeof mayBeAdapterCommand>[0], uuid: string, stillPending: () => boolean): Promise<AdapterCommandOutcome>;
74
+ /** Aborts the running command, which then sends no reply. A cancel or close calls it. */
75
+ abort(): void;
59
76
  /** The session sent the prompt `uuid` to Claude Code. */
60
77
  pushed(uuid: string): void;
61
78
  /**
@@ -65,4 +82,4 @@ export declare class SessionRemoteControl {
65
82
  */
66
83
  remoteMessage(message: SDKUserMessage): SDKUserMessage["message"]["content"] | undefined;
67
84
  }
68
- //# sourceMappingURL=remote-control.d.ts.map
85
+ //# sourceMappingURL=adapter-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-commands.d.ts","sourceRoot":"","sources":["../../src/v2/adapter-commands.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAEL,mBAAmB,EACnB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAwB,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,+DAA+D;AAC/D,MAAM,MAAM,qBAAqB;AAC/B,wEAAwE;AACtE,YAAY;AACd,mCAAmC;GACjC,KAAK;AACP,sEAAsE;GACpE,UAAU,CAAC;AAEf,+CAA+C;AAC/C,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,qBAAqB,EACrB,KAAK,GAAG,KAAK,GAAG,eAAe,CAChC;IACC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB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AAI,IAAI;IAIb,yDAAyD;IACzD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1B;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,SAAS;CAIzF"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * The commands the adapter serves itself on the v2 core (`/remote-control`
3
+ * and `/plugin`, see `adapter-command.ts`), and the messages that a person
4
+ * types in another client of the session over Remote Control.
5
+ *
6
+ * The commands, their listing, and their replies are shared with the v1 core.
7
+ * A command runs as a local command of its own turn, as v2 asks of one
8
+ * ("Local handling still uses the foreground lifecycle"): its prompt is
9
+ * inserted as a live-only `user_message`, the turn reports `running`, the
10
+ * reply goes out, and the turn ends `idle` with `end_turn`. It waits until no
11
+ * turn is open and no prompt waits in Claude Code's queue, and the prompts
12
+ * after it wait for it: v2 asks to hold a prompt rather than reject it while
13
+ * Claude works. A cancel or close aborts the running command: no reply goes
14
+ * out and the turn ends `cancelled`.
15
+ *
16
+ * Remote Control also starts with a query that Claude Code asked to start
17
+ * with it (`remoteControlAtStartup` in the settings, else the policy default or
18
+ * a rollout; see `startsWithRemoteControl`). That is no turn: it reports in a
19
+ * notice, as v1 does.
20
+ */
21
+ import { randomUUID } from "node:crypto";
22
+ import { adapterCommand, mayBeAdapterCommand, } from "../adapter-command.js";
23
+ import { isRemoteHumanMessage, RemoteControlAtStartup } from "../remote-control.js";
24
+ export class SessionAdapterCommands {
25
+ host;
26
+ /** The uuids of the prompts that this session sent, until Claude Code echoes them. */
27
+ sent = new Set();
28
+ /**
29
+ * Remote Control at the start of this query, which Claude Code can ask for
30
+ * at `initialize` (see `V2Session.setRemoteControlAtStartup`).
31
+ */
32
+ atStartup = new RemoteControlAtStartup(false);
33
+ constructor(host) {
34
+ this.host = host;
35
+ }
36
+ /**
37
+ * Starts Remote Control after the setup response of a query that Claude
38
+ * Code asked to start with it, and reports how it went in a notice (see
39
+ * `RemoteControlAtStartup`). It runs once per query, so a later resume of
40
+ * the live session starts nothing, while a restart of the query (see
41
+ * `restarts.ts`), whose new query asks again, starts it again, unless the
42
+ * user turned it off before (see {@link restartedFrom}). The session holds
43
+ * its prompts back until the notice is sent.
44
+ */
45
+ async connectAtStartup() {
46
+ const notice = this.atStartup.connect(this.host);
47
+ if (notice)
48
+ this.host.notice(await notice);
49
+ }
50
+ /**
51
+ * A restart replaced the query of `previous` with this one: Remote Control
52
+ * that the user turned off there stays off (see
53
+ * `RemoteControlAtStartup.restartedFrom`).
54
+ */
55
+ restartedFrom(previous) {
56
+ this.atStartup.restartedFrom(previous.atStartup);
57
+ }
58
+ /** The running command's abort, while one runs. */
59
+ abortCommand;
60
+ /** Whether `prompt` may be an adapter command, which {@link run} then decides. */
61
+ mayRun(prompt) {
62
+ return mayBeAdapterCommand(prompt);
63
+ }
64
+ /**
65
+ * Runs `prompt` as an adapter command, as its turn, once the session is
66
+ * idle. Resolves `"not-served"` without running it when the adapter does
67
+ * not serve it (Claude Code offers the command itself, or the session
68
+ * cannot run it): the prompt then goes to Claude Code. `stillPending`
69
+ * tells whether a cancel or close answered the prompt meanwhile, which
70
+ * resolves `"answered"` without running it.
71
+ */
72
+ async run(prompt, uuid, stillPending) {
73
+ const query = this.host.query();
74
+ if (!query)
75
+ return "not-served";
76
+ const command = await adapterCommand(prompt, query, this.host.terminalCommands(), {
77
+ cwd: this.host.cwd,
78
+ env: this.host.env,
79
+ remoteSession: this.host.remoteSession,
80
+ query: () => this.host.query(),
81
+ logError: (message) => this.host.logger.error(message),
82
+ });
83
+ if (!command)
84
+ return "not-served";
85
+ if (!(await this.host.idle()) || !stillPending())
86
+ return "answered";
87
+ this.host.begin(uuid);
88
+ // A restart of the query keeps what the user chose last.
89
+ if (command.remoteControl)
90
+ this.atStartup.commandRan(command.remoteControl);
91
+ // The turn is open across the command, so the session reads as busy.
92
+ const abort = new AbortController();
93
+ this.abortCommand = abort;
94
+ try {
95
+ const text = await command.run(abort.signal);
96
+ this.host.end(abort.signal.aborted ? undefined : { text, messageId: randomUUID() });
97
+ }
98
+ finally {
99
+ this.abortCommand = undefined;
100
+ }
101
+ return "ran";
102
+ }
103
+ /** Aborts the running command, which then sends no reply. A cancel or close calls it. */
104
+ abort() {
105
+ this.abortCommand?.abort();
106
+ }
107
+ /** The session sent the prompt `uuid` to Claude Code. */
108
+ pushed(uuid) {
109
+ this.sent.add(uuid);
110
+ }
111
+ /**
112
+ * The content of a prompt echo to show as a user message: one that a
113
+ * person typed in another client of the session. `undefined` for the
114
+ * echo of a prompt that this session sent, and for any other echo.
115
+ */
116
+ remoteMessage(message) {
117
+ if (message.uuid && this.sent.delete(message.uuid))
118
+ return undefined;
119
+ return isRemoteHumanMessage(message) ? message.message.content : undefined;
120
+ }
121
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAaxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA+E3C,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,EAAE,CAAC,QAAQ,CA+Cb"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAcxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA+E3C,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,EAAE,CAAC,QAAQ,CA+Cb"}
package/dist/v2/agent.js CHANGED
@@ -16,6 +16,7 @@ import { RequestError, } from "@agentclientprotocol/sdk/unstable";
16
16
  import * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
17
17
  import { deleteSession, getSessionMessages, listSessions, query, } from "@anthropic-ai/claude-agent-sdk";
18
18
  import packageJson from "../../package.json" with { type: "json" };
19
+ import { sessionAdapterOptions } from "../adapter-command.js";
19
20
  import { messageIdForGrouping } from "../sdk-to-acp.js";
20
21
  import { customAgents } from "../session-config-options.js";
21
22
  import { startsWithRemoteControl } from "../remote-control.js";
@@ -608,7 +609,7 @@ class V2Agent {
608
609
  persist: false,
609
610
  });
610
611
  try {
611
- return fields(probe.config, await listed(new SessionCommands(probe.query)));
612
+ return fields(probe.config, await listed(new SessionCommands(probe.query, sessionAdapterOptions(setup).remoteSession)));
612
613
  }
613
614
  finally {
614
615
  probe.query.close();
@@ -980,7 +981,7 @@ class V2Agent {
980
981
  ...(client?.additionalDirectories ?? []),
981
982
  ...(request.additionalDirectories ?? []),
982
983
  ];
983
- const session = new V2Session(sessionId, request.cwd, request.additionalDirectories ?? [], this, input, perTaskStopAffordance, additionalDirectories);
984
+ const session = new V2Session(sessionId, request.cwd, request.additionalDirectories ?? [], this, input, perTaskStopAffordance, additionalDirectories, sessionAdapterOptions(params));
984
985
  const elicitationOptions = session.elicitations.queryOptions();
985
986
  const subagent = subagentHooks((input) => session.tasks.subagentHook(input));
986
987
  // None for a query without `acp` servers. A resume cannot give a running
@@ -5,9 +5,9 @@
5
5
  * The list is built by the v1 core's `getAvailableSlashCommands`, so both
6
6
  * cores advertise the same commands: Claude Code's commands without the
7
7
  * unsupported and terminal-bound ones, MCP prompts as `mcp:<server>:<name>`,
8
- * the adapter's `/mcp`, and the adapter's `/remote-control` when the query
9
- * serves Remote Control and Claude Code offers no command of that name (see
10
- * `remote-control.ts`).
8
+ * the adapter's `/mcp`, the adapter's `/remote-control` when the query
9
+ * serves Remote Control, and `/plugin` unless the session is remote, each only
10
+ * when Claude Code offers no command of that name (see `adapter-command.ts`).
11
11
  *
12
12
  * `/mcp` is served as on v1 (`runMcpCommand`): Claude Code runs the command,
13
13
  * and the adapter's server list replaces Claude Code's text in the turn's
@@ -19,9 +19,10 @@ import type { Query, SDKSystemMessage, SlashCommand } from "@anthropic-ai/claude
19
19
  import { runMcpCommand, type McpCommand } from "../mcp-command.js";
20
20
  export declare class SessionCommands {
21
21
  private readonly query;
22
+ private readonly remoteSession;
22
23
  /** Claude Code's terminal-bound commands, from the turn's `system/init`. */
23
24
  private terminalCommands;
24
- constructor(query: Query);
25
+ constructor(query: Query, remoteSession?: boolean);
25
26
  /** The session's commands, in v2 form. */
26
27
  list(): Promise<v2.AvailableCommand[]>;
27
28
  /** The `available_commands_update` of Claude Code's `commands_changed` list. */
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/v2/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE5F,OAAO,EAAmB,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpF,qBAAa,eAAe;IAId,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,4EAA4E;IAC5E,OAAO,CAAC,gBAAgB,CAAuB;gBAElB,KAAK,EAAE,KAAK;IAEzC,0CAA0C;IACpC,IAAI,IAAI,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAI5C,gFA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AQ,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,aAAa;IAInD;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;IASxC,sEAAsE;IACtE,QAAQ,IAAI,SAAS,MAAM,EAAE,GAAG,SAAS;IAIzC,yDAAyD;IACzD,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,GAAG,SAAS;IAM5D;;;;OAIG;IACG,OAAO,CACX,KAAK,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,EAC1C,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAClC,OAAO,CAAC,MAAM,CAAC;IAKlB,OAAO,CAAC,MAAM;CAaf"}
@@ -3,10 +3,12 @@ import { parseMcpCommand, runMcpCommand } from "../mcp-command.js";
3
3
  import { v2AvailableCommands } from "./session-requests.js";
4
4
  export class SessionCommands {
5
5
  query;
6
+ remoteSession;
6
7
  /** Claude Code's terminal-bound commands, from the turn's `system/init`. */
7
8
  terminalCommands;
8
- constructor(query) {
9
+ constructor(query, remoteSession = false) {
9
10
  this.query = query;
11
+ this.remoteSession = remoteSession;
10
12
  }
11
13
  /** The session's commands, in v2 form. */
12
14
  async list() {
@@ -49,6 +51,6 @@ export class SessionCommands {
49
51
  return markdown ?? output;
50
52
  }
51
53
  render(commands) {
52
- return v2AvailableCommands(getAvailableSlashCommands(commands, this.terminalCommands, undefined, undefined, this.query));
54
+ return v2AvailableCommands(getAvailableSlashCommands(commands, this.terminalCommands, undefined, undefined, this.query, undefined, this.remoteSession));
53
55
  }
54
56
  }