Class StudioClient
This client handles HTTP requests to Studio's REST API endpoints using OkHttp. It provides methods for registering runs, pushing messages, and requesting user input. All operations are reactive and return Mono types for integration with Project Reactor.
The client includes automatic retry logic for failed requests (configurable via StudioConfig).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>pushMessage(io.agentscope.core.message.Msg msg) Pushes a message to Studio for visualization.reactor.core.publisher.Mono<Void>Registers a new run with Studio.reactor.core.publisher.Mono<String>requestUserInput(String agentId, String agentName, Object structuredSchema) Requests user input from Studio web interface.voidshutdown()Shuts down the HTTP client and releases resources.
-
Constructor Details
-
StudioClient
Creates a new Studio HTTP client.- Parameters:
config- Configuration for Studio connection
-
-
Method Details
-
registerRun
Registers a new run with Studio.This must be called before sending any messages. It notifies Studio that a new agent application is starting up.
POST /trpc/registerRun
- Returns:
- A Mono that completes when registration succeeds
-
pushMessage
Pushes a message to Studio for visualization.This method is typically called automatically by StudioMessageHook after an agent produces a response. It includes retry logic for robustness.
POST /trpc/pushMessage
- Parameters:
msg- The message to push- Returns:
- A Mono that completes when the message is successfully pushed
-
requestUserInput
public reactor.core.publisher.Mono<String> requestUserInput(String agentId, String agentName, Object structuredSchema) Requests user input from Studio web interface.This sends a request to Studio, which displays an input form to the user in the web UI. The actual input will be received via WebSocket (see StudioWebSocketClient).
POST /trpc/requestUserInput
- Parameters:
agentId- ID of the agent requesting inputagentName- Name of the agent requesting inputstructuredSchema- Optional JSON schema for structured input- Returns:
- A Mono containing the request ID (used to match WebSocket response)
-
shutdown
public void shutdown()Shuts down the HTTP client and releases resources.
-