public class StdioAcpAgentTransport extends java.lang.Object implements AcpAgentTransport
This is the agent-side counterpart to StdioAcpClientTransport. While the client
spawns an agent process and connects to its stdin/stdout, the agent transport reads from
the process's System.in and writes to System.out.
Key features:
| 构造器和说明 |
|---|
StdioAcpAgentTransport()
Creates a new StdioAcpAgentTransport with the default JsonMapper using
System.in and System.out for communication.
|
StdioAcpAgentTransport(McpJsonMapper jsonMapper)
Creates a new StdioAcpAgentTransport with the specified JsonMapper using
System.in and System.out for communication.
|
StdioAcpAgentTransport(McpJsonMapper jsonMapper,
java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Creates a new StdioAcpAgentTransport with the specified JsonMapper and streams.
|
| 限定符和类型 | 方法和说明 |
|---|---|
reactor.core.publisher.Mono<java.lang.Void> |
awaitTermination()
Returns a Mono that completes when the transport terminates.
|
reactor.core.publisher.Mono<java.lang.Void> |
closeGracefully()
Closes the transport connection and releases any associated resources
asynchronously.
|
java.util.List<java.lang.Integer> |
protocolVersions()
Returns the list of protocol versions supported by this transport.
|
reactor.core.publisher.Mono<java.lang.Void> |
sendMessage(AcpSchema.JSONRPCMessage message)
Sends a message to the peer asynchronously.
|
void |
setExceptionHandler(java.util.function.Consumer<java.lang.Throwable> handler)
Sets the exception handler for exceptions raised on the transport layer.
|
reactor.core.publisher.Mono<java.lang.Void> |
start(java.util.function.Function<reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>> handler)
Used to register the incoming messages' handler and start listening for client
connections.
|
<T> T |
unmarshalFrom(java.lang.Object data,
TypeRef<T> typeRef)
Unmarshals the given data into an object of the specified type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic StdioAcpAgentTransport()
public StdioAcpAgentTransport(McpJsonMapper jsonMapper)
jsonMapper - The JsonMapper to use for JSON serialization/deserializationpublic StdioAcpAgentTransport(McpJsonMapper jsonMapper, java.io.InputStream inputStream, java.io.OutputStream outputStream)
jsonMapper - The JsonMapper to use for JSON serialization/deserializationinputStream - The input stream to read messages from (client → agent)outputStream - The output stream to write messages to (agent → client)public java.util.List<java.lang.Integer> protocolVersions()
AcpTransportprotocolVersions 在接口中 AcpTransportpublic reactor.core.publisher.Mono<java.lang.Void> start(java.util.function.Function<reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>> handler)
AcpAgentTransportstart 在接口中 AcpAgentTransporthandler - a transformer for incoming messagesMono that terminates upon successful agent setup. The successful
termination of the returned Mono simply means the agent can now receive
requests. An error can be retried according to the application requirements.public reactor.core.publisher.Mono<java.lang.Void> sendMessage(AcpSchema.JSONRPCMessage message)
AcpTransportThis method handles the transmission of messages to the peer in an asynchronous manner. Messages are sent in JSON-RPC format as specified by the ACP protocol.
sendMessage 在接口中 AcpTransportmessage - the AcpSchema.JSONRPCMessage to be sent to the peerMono that completes when the message has been sentpublic reactor.core.publisher.Mono<java.lang.Void> closeGracefully()
AcpTransportcloseGracefully 在接口中 AcpTransportMono that completes when the connection has been closed.public void setExceptionHandler(java.util.function.Consumer<java.lang.Throwable> handler)
AcpAgentTransportsetExceptionHandler 在接口中 AcpAgentTransporthandler - Allows reacting to transport level exceptions by the higher layerspublic reactor.core.publisher.Mono<java.lang.Void> awaitTermination()
AcpAgentTransportExample usage:
transport.start(handler).block();
transport.awaitTermination().block(); // Block until stdin closes
awaitTermination 在接口中 AcpAgentTransportMono that completes when the transport terminatespublic <T> T unmarshalFrom(java.lang.Object data,
TypeRef<T> typeRef)
AcpTransportunmarshalFrom 在接口中 AcpTransportT - the type of the object to unmarshaldata - the data to unmarshaltypeRef - the type reference for the object to unmarshal