Class RemoteEventCodec

java.lang.Object
io.agentscope.harness.agent.subagent.protocol.RemoteEventCodec

public final class RemoteEventCodec extends Object
Bidirectional mapping between internal AgentEvents and stable RemoteAgentEvent wire DTOs.
  • Method Details

    • fromAgentEvent

      public static Optional<RemoteAgentEvent> fromAgentEvent(io.agentscope.core.event.AgentEvent event)
      Maps an internal agent event to a protocol DTO (without seq/taskId — those are assigned by the server event bus).

      Every event also carries its full serialization in RemoteAgentEvent.getPayload(), so a client can restore the original instance instead of the lossy flat fields. Event types without a dedicated wire type are forwarded as RemoteEventType.AGENT_EVENT and are only visible at detail=verbose.

    • toAgentEvent

      public static Optional<io.agentscope.core.event.AgentEvent> toAgentEvent(RemoteAgentEvent remote)
      Maps a protocol DTO back to an internal AgentEvent. Unknown or incomplete types are dropped. When the DTO carries a taskId, it is copied onto AgentEvent.METADATA_TASK_ID.

      A payload is preferred over the flat fields: it restores the original event with its ids, timestamps and metadata intact, and is the only way to recover events sent as RemoteEventType.AGENT_EVENT. Servers too old to send one still decode through the per-type mapping below.

    • matchesDetail

      public static boolean matchesDetail(RemoteEventType type, String detail)
      Whether this event type should be emitted for the given detail level.
      Parameters:
      type - event type
      detail - see RemoteStreamDetail
    • matchesDetail

      public static boolean matchesDetail(RemoteAgentEvent event, String detail)
      Detail check for a whole DTO; equivalent to matchesDetail(RemoteEventType, String).