public static class AcpClient.AsyncSpec
extends java.lang.Object
The builder supports configuration of:
| 限定符和类型 | 方法和说明 |
|---|---|
AcpAsyncClient |
build()
Creates an instance of
AcpAsyncClient with the provided configurations
or sensible defaults. |
AcpClient.AsyncSpec |
clientCapabilities(AcpSchema.ClientCapabilities clientCapabilities)
Sets the client capabilities that will be advertised to the agent during
initialization.
|
AcpClient.AsyncSpec |
createTerminalHandler(java.util.function.Function<AcpSchema.CreateTerminalRequest,reactor.core.publisher.Mono<AcpSchema.CreateTerminalResponse>> handler)
Adds a typed handler for terminal creation requests from the agent.
|
AcpClient.AsyncSpec |
killTerminalHandler(java.util.function.Function<AcpSchema.KillTerminalCommandRequest,reactor.core.publisher.Mono<AcpSchema.KillTerminalCommandResponse>> handler)
Adds a typed handler for terminal kill requests from the agent.
|
AcpClient.AsyncSpec |
notificationHandler(java.lang.String method,
AcpClientSession.NotificationHandler handler)
Adds a custom notification handler for a specific method.
|
AcpClient.AsyncSpec |
readTextFileHandler(java.util.function.Function<AcpSchema.ReadTextFileRequest,reactor.core.publisher.Mono<AcpSchema.ReadTextFileResponse>> handler)
Adds a typed handler for file system read requests from the agent.
|
AcpClient.AsyncSpec |
releaseTerminalHandler(java.util.function.Function<AcpSchema.ReleaseTerminalRequest,reactor.core.publisher.Mono<AcpSchema.ReleaseTerminalResponse>> handler)
Adds a typed handler for terminal release requests from the agent.
|
AcpClient.AsyncSpec |
requestHandler(java.lang.String method,
AcpClientSession.RequestHandler<?> handler)
Adds a custom request handler for a specific method.
|
AcpClient.AsyncSpec |
requestPermissionHandler(java.util.function.Function<AcpSchema.RequestPermissionRequest,reactor.core.publisher.Mono<AcpSchema.RequestPermissionResponse>> handler)
Adds a typed handler for permission requests from the agent.
|
AcpClient.AsyncSpec |
requestTimeout(java.time.Duration requestTimeout)
Sets the duration to wait for agent responses before timing out requests.
|
AcpClient.AsyncSpec |
sessionUpdateConsumer(java.util.function.Function<AcpSchema.SessionNotification,reactor.core.publisher.Mono<java.lang.Void>> sessionUpdateConsumer)
Adds a consumer to be notified when session update notifications are received
from the agent.
|
AcpClient.AsyncSpec |
terminalOutputHandler(java.util.function.Function<AcpSchema.TerminalOutputRequest,reactor.core.publisher.Mono<AcpSchema.TerminalOutputResponse>> handler)
Adds a typed handler for terminal output requests from the agent.
|
AcpClient.AsyncSpec |
waitForTerminalExitHandler(java.util.function.Function<AcpSchema.WaitForTerminalExitRequest,reactor.core.publisher.Mono<AcpSchema.WaitForTerminalExitResponse>> handler)
Adds a typed handler for wait-for-terminal-exit requests from the agent.
|
AcpClient.AsyncSpec |
writeTextFileHandler(java.util.function.Function<AcpSchema.WriteTextFileRequest,reactor.core.publisher.Mono<AcpSchema.WriteTextFileResponse>> handler)
Adds a typed handler for file system write requests from the agent.
|
public AcpClient.AsyncSpec requestTimeout(java.time.Duration requestTimeout)
requestTimeout - The duration to wait before timing out requests. Must not
be null.java.lang.IllegalArgumentException - if requestTimeout is nullpublic AcpClient.AsyncSpec clientCapabilities(AcpSchema.ClientCapabilities clientCapabilities)
clientCapabilities - The client capabilities configuration. Must not be
null.java.lang.IllegalArgumentException - if clientCapabilities is nullpublic AcpClient.AsyncSpec readTextFileHandler(java.util.function.Function<AcpSchema.ReadTextFileRequest,reactor.core.publisher.Mono<AcpSchema.ReadTextFileResponse>> handler)
Example usage:
.readTextFileHandler(req ->
Mono.fromCallable(() -> Files.readString(Path.of(req.path())))
.map(ReadTextFileResponse::new))
handler - The typed handler function that processes read requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec writeTextFileHandler(java.util.function.Function<AcpSchema.WriteTextFileRequest,reactor.core.publisher.Mono<AcpSchema.WriteTextFileResponse>> handler)
Example usage:
.writeTextFileHandler(req ->
Mono.fromRunnable(() -> Files.writeString(Path.of(req.path()), req.content()))
.then(Mono.just(new WriteTextFileResponse())))
handler - The typed handler function that processes write requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec requestPermissionHandler(java.util.function.Function<AcpSchema.RequestPermissionRequest,reactor.core.publisher.Mono<AcpSchema.RequestPermissionResponse>> handler)
Example usage:
.requestPermissionHandler(req ->
Mono.just(new RequestPermissionResponse(
new RequestPermissionOutcome("approve", null))))
handler - The typed handler function that processes permission requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec createTerminalHandler(java.util.function.Function<AcpSchema.CreateTerminalRequest,reactor.core.publisher.Mono<AcpSchema.CreateTerminalResponse>> handler)
Example usage:
.createTerminalHandler(req -> {
String terminalId = UUID.randomUUID().toString();
// Start process with req.command(), req.args(), req.cwd()
return Mono.just(new CreateTerminalResponse(terminalId));
})
handler - The typed handler function that processes terminal creation requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec terminalOutputHandler(java.util.function.Function<AcpSchema.TerminalOutputRequest,reactor.core.publisher.Mono<AcpSchema.TerminalOutputResponse>> handler)
Example usage:
.terminalOutputHandler(req -> {
String output = getTerminalOutput(req.terminalId());
return Mono.just(new TerminalOutputResponse(output, false, null));
})
handler - The typed handler function that processes terminal output requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec releaseTerminalHandler(java.util.function.Function<AcpSchema.ReleaseTerminalRequest,reactor.core.publisher.Mono<AcpSchema.ReleaseTerminalResponse>> handler)
Example usage:
.releaseTerminalHandler(req -> {
releaseTerminal(req.terminalId());
return Mono.just(new ReleaseTerminalResponse());
})
handler - The typed handler function that processes terminal release requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec waitForTerminalExitHandler(java.util.function.Function<AcpSchema.WaitForTerminalExitRequest,reactor.core.publisher.Mono<AcpSchema.WaitForTerminalExitResponse>> handler)
Example usage:
.waitForTerminalExitHandler(req -> {
int exitCode = waitForExit(req.terminalId());
return Mono.just(new WaitForTerminalExitResponse(exitCode, null));
})
handler - The typed handler function that processes wait-for-exit requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec killTerminalHandler(java.util.function.Function<AcpSchema.KillTerminalCommandRequest,reactor.core.publisher.Mono<AcpSchema.KillTerminalCommandResponse>> handler)
Example usage:
.killTerminalHandler(req -> {
killProcess(req.terminalId());
return Mono.just(new KillTerminalCommandResponse());
})
handler - The typed handler function that processes terminal kill requestsjava.lang.IllegalArgumentException - if handler is nullpublic AcpClient.AsyncSpec sessionUpdateConsumer(java.util.function.Function<AcpSchema.SessionNotification,reactor.core.publisher.Mono<java.lang.Void>> sessionUpdateConsumer)
sessionUpdateConsumer - A consumer that receives session update
notifications. Must not be null.java.lang.IllegalArgumentException - if sessionUpdateConsumer is nullpublic AcpClient.AsyncSpec requestHandler(java.lang.String method, AcpClientSession.RequestHandler<?> handler)
method - The method name (e.g., "custom/operation")handler - The handler function for this methodjava.lang.IllegalArgumentException - if method or handler is nullpublic AcpClient.AsyncSpec notificationHandler(java.lang.String method, AcpClientSession.NotificationHandler handler)
method - The method name (e.g., "custom/notification")handler - The handler function for this methodjava.lang.IllegalArgumentException - if method or handler is nullpublic AcpAsyncClient build()
AcpAsyncClient with the provided configurations
or sensible defaults.AcpAsyncClient