public class AcpClientSession extends java.lang.Object implements AcpSession
The session manages:
This is the client-side session that sends requests to an agent (initialize, newSession, prompt, etc.) and handles incoming requests from the agent (readTextFile, writeTextFile, requestPermission, etc.)
| 限定符和类型 | 类和说明 |
|---|---|
static class |
AcpClientSession.AcpError
ACP-specific error wrapper for JSON-RPC errors.
|
static class |
AcpClientSession.MethodNotFoundError |
static interface |
AcpClientSession.NotificationHandler
Functional interface for handling incoming JSON-RPC notifications.
|
static interface |
AcpClientSession.RequestHandler<T>
Functional interface for handling incoming JSON-RPC requests.
|
| 构造器和说明 |
|---|
AcpClientSession(java.time.Duration requestTimeout,
AcpClientTransport transport,
java.util.Map<java.lang.String,AcpClientSession.RequestHandler<?>> requestHandlers,
java.util.Map<java.lang.String,AcpClientSession.NotificationHandler> notificationHandlers,
java.util.function.Function<? super reactor.core.publisher.Mono<java.lang.Void>,? extends org.reactivestreams.Publisher<java.lang.Void>> connectHook)
Creates a new AcpClientSession with the specified configuration and handlers.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
Closes the session immediately, potentially interrupting pending operations.
|
reactor.core.publisher.Mono<java.lang.Void> |
closeGracefully()
Closes the session gracefully, allowing pending operations to complete.
|
reactor.core.publisher.Mono<java.lang.Void> |
sendNotification(java.lang.String method,
java.lang.Object params)
Sends a JSON-RPC notification.
|
<T> reactor.core.publisher.Mono<T> |
sendRequest(java.lang.String method,
java.lang.Object requestParams,
TypeRef<T> typeRef)
Sends a JSON-RPC request and returns the response.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsendNotificationpublic AcpClientSession(java.time.Duration requestTimeout,
AcpClientTransport transport,
java.util.Map<java.lang.String,AcpClientSession.RequestHandler<?>> requestHandlers,
java.util.Map<java.lang.String,AcpClientSession.NotificationHandler> notificationHandlers,
java.util.function.Function<? super reactor.core.publisher.Mono<java.lang.Void>,? extends org.reactivestreams.Publisher<java.lang.Void>> connectHook)
requestTimeout - Duration to wait for responsestransport - Transport implementation for message exchangerequestHandlers - Map of method names to request handlersnotificationHandlers - Map of method names to notification handlersconnectHook - Hook that allows transforming the connection Publisher prior to
subscribingpublic <T> reactor.core.publisher.Mono<T> sendRequest(java.lang.String method,
java.lang.Object requestParams,
TypeRef<T> typeRef)
sendRequest 在接口中 AcpSessionT - The expected response typemethod - The method name to callrequestParams - The request parameterstypeRef - Type reference for response deserializationpublic reactor.core.publisher.Mono<java.lang.Void> sendNotification(java.lang.String method,
java.lang.Object params)
sendNotification 在接口中 AcpSessionmethod - The method name for the notificationparams - The notification parameterspublic reactor.core.publisher.Mono<java.lang.Void> closeGracefully()
closeGracefully 在接口中 AcpSessionpublic void close()
close 在接口中 AcpSession