public static class AcpAgent.SyncAgentBuilder
extends java.lang.Object
This builder accepts synchronous handler interfaces that return plain values instead of Mono. Internally, handlers are converted to async handlers using the MCP SDK pattern (Mono.fromCallable + boundedElastic scheduler).
Example usage:
AcpSyncAgent agent = AcpAgent.sync(transport)
.initializeHandler(req -> new InitializeResponse(1, capabilities, List.of()))
.newSessionHandler(req -> new NewSessionResponse(sessionId, null, null))
.promptHandler((req, updater) -> {
updater.sendUpdate(sessionId, thought); // blocks, void return
updater.sendUpdate(sessionId, message); // blocks, void return
return new PromptResponse(StopReason.END_TURN); // plain return
})
.build();
| 限定符和类型 | 方法和说明 |
|---|---|
AcpAgent.SyncAgentBuilder |
authenticateHandler(AcpAgent.SyncAuthenticateHandler handler)
Sets the synchronous handler for authenticate requests.
|
AcpSyncAgent |
build()
Builds the synchronous ACP agent.
|
AcpAgent.SyncAgentBuilder |
cancelHandler(AcpAgent.SyncCancelHandler handler)
Sets the synchronous handler for cancel notifications.
|
AcpAgent.SyncAgentBuilder |
initializeHandler(AcpAgent.SyncInitializeHandler handler)
Sets the synchronous handler for initialize requests.
|
AcpAgent.SyncAgentBuilder |
loadSessionHandler(AcpAgent.SyncLoadSessionHandler handler)
Sets the synchronous handler for load session requests.
|
AcpAgent.SyncAgentBuilder |
newSessionHandler(AcpAgent.SyncNewSessionHandler handler)
Sets the synchronous handler for new session requests.
|
AcpAgent.SyncAgentBuilder |
promptHandler(AcpAgent.SyncPromptHandler handler)
Sets the synchronous handler for prompt requests.
|
AcpAgent.SyncAgentBuilder |
requestTimeout(java.time.Duration timeout)
Sets the timeout for requests sent to the client.
|
AcpAgent.SyncAgentBuilder |
setSessionModeHandler(AcpAgent.SyncSetSessionModeHandler handler)
Sets the synchronous handler for set session mode requests.
|
AcpAgent.SyncAgentBuilder |
setSessionModelHandler(AcpAgent.SyncSetSessionModelHandler handler)
Sets the synchronous handler for set session model requests.
|
public AcpAgent.SyncAgentBuilder requestTimeout(java.time.Duration timeout)
timeout - The request timeout durationpublic AcpAgent.SyncAgentBuilder initializeHandler(AcpAgent.SyncInitializeHandler handler)
handler - The sync initialize handler (returns plain value)public AcpAgent.SyncAgentBuilder authenticateHandler(AcpAgent.SyncAuthenticateHandler handler)
handler - The sync authenticate handler (returns plain value)public AcpAgent.SyncAgentBuilder newSessionHandler(AcpAgent.SyncNewSessionHandler handler)
handler - The sync new session handler (returns plain value)public AcpAgent.SyncAgentBuilder loadSessionHandler(AcpAgent.SyncLoadSessionHandler handler)
handler - The sync load session handler (returns plain value)public AcpAgent.SyncAgentBuilder promptHandler(AcpAgent.SyncPromptHandler handler)
handler - The sync prompt handler (returns plain value, receives SyncPromptContext)public AcpAgent.SyncAgentBuilder setSessionModeHandler(AcpAgent.SyncSetSessionModeHandler handler)
handler - The sync set session mode handler (returns plain value)public AcpAgent.SyncAgentBuilder setSessionModelHandler(AcpAgent.SyncSetSessionModelHandler handler)
handler - The sync set session model handler (returns plain value)public AcpAgent.SyncAgentBuilder cancelHandler(AcpAgent.SyncCancelHandler handler)
handler - The sync cancel handler (returns void)public AcpSyncAgent build()