AcpAsyncAgent agent = AcpAgent.async(transport)
// Returns Mono<InitializeResponse>
.initializeHandler(req ->
Mono.just(InitializeResponse.ok()))
// Returns Mono<NewSessionResponse>
.newSessionHandler(req ->
Mono.just(new NewSessionResponse(
UUID.randomUUID().toString(), null, null)))
// Returns Mono<PromptResponse>
.promptHandler((req, context) -> {
String text = req.text();
// sendMessage() returns Mono<Void> — must chain with then()
return context.sendMessage("Async Echo: " + text)
.then(Mono.just(PromptResponse.endTurn()));
})
.build();
// Start and block until transport closes
agent.start().block();
agent.awaitTermination().block();