// Launch echo agent as subprocess (from packaged JAR)
var params = AgentParameters.builder("java")
.arg("-jar")
.arg(jarPath)
.build();
var transport = new StdioAcpClientTransport(params);
AcpSyncClient client = AcpClient.sync(transport)
.sessionUpdateConsumer(notification -> {
if (notification.update() instanceof AgentMessageChunk msg) {
System.out.println(((TextContent) msg.content()).text());
}
})
.build();
client.initialize();
var session = client.newSession(new NewSessionRequest(".", List.of()));
client.prompt(new PromptRequest(
session.sessionId(),
List.of(new TextContent("Hello, Echo Agent!"))
));
// Output: Echo: Hello, Echo Agent!