packages/sdk-java/client/README.md
The ACP Client SDK is a Java Software Development Kit for communicating with AI agents that support the Agent Client Protocol (ACP). It provides a standardized way to interact with AI agents that support the Agent Client Protocol, enabling features like session management, file system operations, terminal commands, and tool calls.
The ACP SDK implements the Agent Client Protocol, allowing client applications to communicate with AI agents. The SDK provides the following core features:
Add the following dependency to your pom.xml file:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>acp-sdk</artifactId>
<version>0.0.1-alpha</version>
</dependency>
Add the following to your build.gradle file:
implementation 'com.alibaba:acp-sdk:0.0.1-alpha'
The following is a simple example showing how to use the ACP SDK to create a client and establish a session:
@Test
public void testSession() throws AgentInitializeException, SessionNewException, IOException {
// Create an ACP client with a process transport
AcpClient acpClient = new AcpClient(
new ProcessTransport(new ProcessTransportOptions().setCommandArgs(new String[] {"qwen", "--acp", "-y"})));
try {
// Send a prompt to the agent
acpClient.sendPrompt(Collections.singletonList(new TextContent("你是谁")),
new AgentEventConsumer().setContentEventConsumer(new ContentEventSimpleConsumer() {
@Override
public void onAgentMessageChunkSessionUpdate(AgentMessageChunkSessionUpdate sessionUpdate) {
logger.info(sessionUpdate.toString());
}
@Override
public void onAvailableCommandsUpdateSessionUpdate(AvailableCommandsUpdateSessionUpdate sessionUpdate) {
logger.info(sessionUpdate.toString());
}
@Override
public void onCurrentModeUpdateSessionUpdate(CurrentModeUpdateSessionUpdate sessionUpdate) {
logger.info(sessionUpdate.toString());
}
@Override
public void onPlanSessionUpdate(PlanSessionUpdate sessionUpdate) {
logger.info(sessionUpdate.toString());
}
@Override
public void onToolCallUpdateSessionUpdate(ToolCallUpdateSessionUpdate sessionUpdate) {
logger.info(sessionUpdate.toString());
}
@Override
public void onToolCallSessionUpdate(ToolCallSessionUpdate sessionUpdate) {
logger.info(sessionUpdate.toString());
}
}));
} finally {
// Close the client when done
acpClient.close();
}
}
The SDK implements the Agent Client Protocol based on a comprehensive JSON schema that defines:
# Compile the project
mvn compile
# Run tests
mvn test
# Package the JAR
mvn package
# Install to local repository
mvn install
The project includes comprehensive unit tests covering:
Key dependencies include:
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
Contributions are welcome! Please submit issues and pull requests.
If you encounter any problems, please submit an issue report through GitHub Issues.