public class StdioAcpClientTransport extends java.lang.Object implements AcpClientTransport
This is a full-featured transport with:
| 构造器和说明 |
|---|
StdioAcpClientTransport(AgentParameters params)
Creates a new StdioAcpClientTransport with the specified parameters using the default JsonMapper.
|
StdioAcpClientTransport(AgentParameters params,
McpJsonMapper jsonMapper)
Creates a new StdioAcpClientTransport with the specified parameters and JsonMapper.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
awaitForExit()
Waits for the agent process to exit.
|
reactor.core.publisher.Mono<java.lang.Void> |
closeGracefully()
Gracefully closes the transport by destroying the process and disposing of the
schedulers.
|
reactor.core.publisher.Mono<java.lang.Void> |
connect(java.util.function.Function<reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>> handler)
Starts the agent process and initializes the message processing streams.
|
reactor.core.publisher.Sinks.Many<java.lang.String> |
getErrorSink() |
protected java.lang.ProcessBuilder |
getProcessBuilder()
Creates and returns a new ProcessBuilder instance.
|
protected void |
handleOutbound(java.util.function.Function<reactor.core.publisher.Flux<AcpSchema.JSONRPCMessage>,reactor.core.publisher.Flux<AcpSchema.JSONRPCMessage>> outboundConsumer) |
reactor.core.publisher.Mono<java.lang.Void> |
sendMessage(AcpSchema.JSONRPCMessage message)
Sends a message to the peer asynchronously.
|
void |
setStdErrorHandler(java.util.function.Consumer<java.lang.String> errorHandler)
Sets the handler for processing transport-level errors.
|
<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, waitsetExceptionHandlerclose, protocolVersionspublic StdioAcpClientTransport(AgentParameters params)
params - The parameters for configuring the agent processpublic StdioAcpClientTransport(AgentParameters params, McpJsonMapper jsonMapper)
params - The parameters for configuring the agent processjsonMapper - The JsonMapper to use for JSON serialization/deserializationpublic reactor.core.publisher.Mono<java.lang.Void> connect(java.util.function.Function<reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>,reactor.core.publisher.Mono<AcpSchema.JSONRPCMessage>> handler)
connect 在接口中 AcpClientTransporthandler - a transformer for incoming messagesMono that terminates upon successful client setup. It can mean
establishing a connection (which can be later disposed) but it doesn't have to,
depending on the transport type. The successful termination of the returned
Mono simply means the client can now be used. An error can be retried
according to the application requirements.java.lang.RuntimeException - if the process fails to start or if the process streams
are nullprotected java.lang.ProcessBuilder getProcessBuilder()
public void setStdErrorHandler(java.util.function.Consumer<java.lang.String> errorHandler)
The provided handler will be called when errors occur during transport operations, such as connection failures or protocol violations.
errorHandler - a consumer that processes error messagespublic void awaitForExit()
java.lang.RuntimeException - if the process is interrupted while waitingpublic 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 sentprotected void handleOutbound(java.util.function.Function<reactor.core.publisher.Flux<AcpSchema.JSONRPCMessage>,reactor.core.publisher.Flux<AcpSchema.JSONRPCMessage>> outboundConsumer)
public reactor.core.publisher.Mono<java.lang.Void> closeGracefully()
closeGracefully 在接口中 AcpTransportpublic reactor.core.publisher.Sinks.Many<java.lang.String> getErrorSink()
public <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