Class StudioWebSocketClient

java.lang.Object
io.agentscope.core.studio.StudioWebSocketClient

public class StudioWebSocketClient extends Object
WebSocket client for real-time communication with AgentScope Studio.

This client uses Socket.IO to connect to Studio's /python namespace and receive user input events. It maintains a persistent connection with automatic reconnection support.

The client listens for "forwardUserInput" events from Studio, which are sent when a user provides input through the web interface. The input is then delivered to the waiting agent via a Mono.

  • Constructor Details

    • StudioWebSocketClient

      public StudioWebSocketClient(StudioConfig config)
      Creates a new Studio WebSocket client.
      Parameters:
      config - Configuration for Studio connection
  • Method Details

    • connect

      public reactor.core.publisher.Mono<Void> connect()
      Connects to Studio's WebSocket endpoint (/python namespace).

      This establishes a Socket.IO connection with authentication via run_id. The connection includes automatic reconnection with exponential backoff.

      Returns:
      A Mono that completes when the connection is established
    • waitForInput

      public reactor.core.publisher.Mono<StudioWebSocketClient.UserInputData> waitForInput(String requestId)
      Waits for user input matching the given request ID.

      This method is called after sending a requestUserInput HTTP request. It returns a Mono that will emit when the corresponding forwardUserInput event arrives via WebSocket.

      Parameters:
      requestId - The request ID to wait for (from StudioClient.requestUserInput)
      Returns:
      A Mono that emits the user input data when available
    • close

      public void close()
      Closes the WebSocket connection and releases resources.
    • isConnected

      public boolean isConnected()
      Checks if the WebSocket is currently connected.
      Returns:
      true if connected, false otherwise