@sudocode-ai/claude-code-acp 0.13.1 → 0.13.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.
- package/README.md +1 -1
- package/dist/acp-agent.d.ts +21 -10
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +55 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ This tool implements an ACP agent by using the official [Claude Agent SDK](https
|
|
|
10
10
|
- Images
|
|
11
11
|
- Tool calls (with permission requests)
|
|
12
12
|
- Following
|
|
13
|
-
- Edit
|
|
13
|
+
- Edit reviewddddd
|
|
14
14
|
- TODO lists
|
|
15
15
|
- Interactive (and background) terminals
|
|
16
16
|
- Custom [Slash commands](https://docs.anthropic.com/en/docs/claude-code/slash-commands)
|
package/dist/acp-agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, AgentSideConnection, AuthenticateRequest, CancelNotification, ClientCapabilities, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, SessionNotification, SetSessionModelRequest, SetSessionModelResponse, SetSessionModeRequest, SetSessionModeResponse, TerminalHandle, TerminalOutputResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { Agent, AgentSideConnection, AuthenticateRequest, CancelNotification, ClientCapabilities, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, ResumeSessionRequest, ResumeSessionResponse, SessionNotification, SetSessionModelRequest, SetSessionModelResponse, SetSessionModeRequest, SetSessionModeResponse, TerminalHandle, TerminalOutputResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { SettingsManager } from "./settings.js";
|
|
3
3
|
import { CanUseTool, Options, PermissionMode, Query, SDKPartialAssistantMessage, SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
4
4
|
import { Pushable } from "./utils.js";
|
|
@@ -125,16 +125,9 @@ export declare class ClaudeAcpAgent implements Agent {
|
|
|
125
125
|
*/
|
|
126
126
|
loadSession(params: LoadSessionRequest): Promise<LoadSessionResponse>;
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
128
|
+
* Resume an existing session. This delegates to loadSession for enhanced functionality.
|
|
129
129
|
*/
|
|
130
|
-
unstable_resumeSession(params:
|
|
131
|
-
sessionId: string;
|
|
132
|
-
_meta?: {
|
|
133
|
-
cwd?: string;
|
|
134
|
-
mcpServers?: any[];
|
|
135
|
-
[key: string]: unknown;
|
|
136
|
-
} | null;
|
|
137
|
-
}): Promise<LoadSessionResponse>;
|
|
130
|
+
unstable_resumeSession(params: ResumeSessionRequest): Promise<ResumeSessionResponse>;
|
|
138
131
|
authenticate(_params: AuthenticateRequest): Promise<void>;
|
|
139
132
|
prompt(params: PromptRequest): Promise<PromptResponse>;
|
|
140
133
|
cancel(params: CancelNotification): Promise<void>;
|
|
@@ -142,9 +135,27 @@ export declare class ClaudeAcpAgent implements Agent {
|
|
|
142
135
|
* Handle extension methods from the client.
|
|
143
136
|
*
|
|
144
137
|
* Currently supports:
|
|
138
|
+
* - `_session/inject`: Inject a message into an active session mid-execution
|
|
145
139
|
* - `_session/flush`: Flush a session to disk for fork-with-flush support
|
|
146
140
|
*/
|
|
147
141
|
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
142
|
+
/**
|
|
143
|
+
* Inject a message into an active session.
|
|
144
|
+
*
|
|
145
|
+
* This allows sending additional user input while a prompt() call is actively
|
|
146
|
+
* processing. The injected message will be queued and processed by the agent
|
|
147
|
+
* as part of the current conversation turn.
|
|
148
|
+
*
|
|
149
|
+
* Use cases:
|
|
150
|
+
* - Providing clarification while the agent is working
|
|
151
|
+
* - Adding context mid-execution
|
|
152
|
+
* - Sending corrections before a tool completes
|
|
153
|
+
*
|
|
154
|
+
* @param params.sessionId - The session to inject the message into
|
|
155
|
+
* @param params.message - Either a string or an array of ContentBlocks (same format as prompt)
|
|
156
|
+
* @returns Success status and any error message
|
|
157
|
+
*/
|
|
158
|
+
private handleSessionInject;
|
|
148
159
|
/**
|
|
149
160
|
* Flush a session to disk by aborting its query subprocess.
|
|
150
161
|
*
|
package/dist/acp-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAEnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,oBAAoB,EACpB,qBAAqB,EAErB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,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,cAAc,CA6EpE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,gBAAgB,EAAE,GAAG,wBAAwB,EAAE,EACvF,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,GACb,mBAAmB,EAAE,CAqKvB;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,GACb,mBAAmB,EAAE,CAgCvB;AAED,wBAAgB,MAAM,SAMrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -331,16 +331,17 @@ export class ClaudeAcpAgent {
|
|
|
331
331
|
return response;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
|
-
*
|
|
334
|
+
* Resume an existing session. This delegates to loadSession for enhanced functionality.
|
|
335
335
|
*/
|
|
336
336
|
async unstable_resumeSession(params) {
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
cwd: meta?.cwd ?? process.cwd(),
|
|
341
|
-
mcpServers: meta?.mcpServers ?? [],
|
|
337
|
+
const response = await this.createSession({
|
|
338
|
+
cwd: params.cwd,
|
|
339
|
+
mcpServers: params.mcpServers ?? [],
|
|
342
340
|
_meta: params._meta,
|
|
341
|
+
}, {
|
|
342
|
+
resume: params.sessionId,
|
|
343
343
|
});
|
|
344
|
+
return response;
|
|
344
345
|
}
|
|
345
346
|
async authenticate(_params) {
|
|
346
347
|
throw new Error("Method not implemented.");
|
|
@@ -477,14 +478,62 @@ export class ClaudeAcpAgent {
|
|
|
477
478
|
* Handle extension methods from the client.
|
|
478
479
|
*
|
|
479
480
|
* Currently supports:
|
|
481
|
+
* - `_session/inject`: Inject a message into an active session mid-execution
|
|
480
482
|
* - `_session/flush`: Flush a session to disk for fork-with-flush support
|
|
481
483
|
*/
|
|
482
484
|
async extMethod(method, params) {
|
|
485
|
+
if (method === "_session/inject") {
|
|
486
|
+
return this.handleSessionInject(params);
|
|
487
|
+
}
|
|
483
488
|
if (method === "_session/flush") {
|
|
484
489
|
return this.handleSessionFlush(params);
|
|
485
490
|
}
|
|
486
491
|
throw RequestError.methodNotFound(method);
|
|
487
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* Inject a message into an active session.
|
|
495
|
+
*
|
|
496
|
+
* This allows sending additional user input while a prompt() call is actively
|
|
497
|
+
* processing. The injected message will be queued and processed by the agent
|
|
498
|
+
* as part of the current conversation turn.
|
|
499
|
+
*
|
|
500
|
+
* Use cases:
|
|
501
|
+
* - Providing clarification while the agent is working
|
|
502
|
+
* - Adding context mid-execution
|
|
503
|
+
* - Sending corrections before a tool completes
|
|
504
|
+
*
|
|
505
|
+
* @param params.sessionId - The session to inject the message into
|
|
506
|
+
* @param params.message - Either a string or an array of ContentBlocks (same format as prompt)
|
|
507
|
+
* @returns Success status and any error message
|
|
508
|
+
*/
|
|
509
|
+
handleSessionInject(params) {
|
|
510
|
+
const { sessionId, message } = params;
|
|
511
|
+
const session = this.sessions[sessionId];
|
|
512
|
+
if (!session) {
|
|
513
|
+
return { success: false, error: `Session ${sessionId} not found` };
|
|
514
|
+
}
|
|
515
|
+
if (session.cancelled) {
|
|
516
|
+
return { success: false, error: `Session ${sessionId} is cancelled` };
|
|
517
|
+
}
|
|
518
|
+
try {
|
|
519
|
+
// Convert string to ContentBlock array if needed
|
|
520
|
+
const prompt = typeof message === "string" ? [{ type: "text", text: message }] : message;
|
|
521
|
+
// Create a PromptRequest-like object to reuse promptToClaude
|
|
522
|
+
const promptRequest = {
|
|
523
|
+
sessionId,
|
|
524
|
+
prompt,
|
|
525
|
+
};
|
|
526
|
+
// Convert to SDK format and push to the session's input queue
|
|
527
|
+
const sdkMessage = promptToClaude(promptRequest);
|
|
528
|
+
session.input.push(sdkMessage);
|
|
529
|
+
this.logger.log(`[claude-code-acp] Injected message into session ${sessionId}`);
|
|
530
|
+
return { success: true };
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
this.logger.error(`[claude-code-acp] Failed to inject message into session ${sessionId}:`, error);
|
|
534
|
+
return { success: false, error: String(error) };
|
|
535
|
+
}
|
|
536
|
+
}
|
|
488
537
|
/**
|
|
489
538
|
* Flush a session to disk by aborting its query subprocess.
|
|
490
539
|
*
|
|
@@ -797,8 +846,6 @@ export class ClaudeAcpAgent {
|
|
|
797
846
|
const extraArgs = { ...userProvidedOptions?.extraArgs };
|
|
798
847
|
if (creationOpts?.resume === undefined || creationOpts?.forkSession) {
|
|
799
848
|
// Set our own session id if not resuming an existing session.
|
|
800
|
-
// Note: For forked sessions (resume + fork), Claude CLI assigns its own session ID
|
|
801
|
-
// which means chain forking (fork of a fork) is not currently supported.
|
|
802
849
|
extraArgs["session-id"] = sessionId;
|
|
803
850
|
}
|
|
804
851
|
// Configure thinking tokens from environment variable
|
package/package.json
CHANGED