Class MessageSource

java.lang.Object
com.github.copilot.rpc.MessageSource

public final class MessageSource extends Object
The origin of a message sent to a Copilot session.

Set on MessageOptions.setSource(MessageSource) to distinguish user input, system context, and messages from identified agents. This does not configure the session's system prompt or change the message delivery mode.

See Also:
  • Field Details

    • USER

      public static final MessageSource USER
      Input originating from the user.
    • SYSTEM

      public static final MessageSource SYSTEM
      Application-generated system context.
  • Method Details

    • agent

      public static MessageSource agent(String id)
      Identifies a message from an agent.
      Parameters:
      id - the opaque agent identifier, preserved exactly after agent-
      Returns:
      the agent message source
      Throws:
      NullPointerException - if id is null
    • getValue

      public String getValue()
      Returns the JSON value for this message source.
      Returns:
      the string value used in JSON serialization
    • fromValue

      public static MessageSource fromValue(String value)
      Deserializes a JSON string into the corresponding message source.
      Parameters:
      value - the JSON string value
      Returns:
      the matching source, or null if value is null
      Throws:
      IllegalArgumentException - if the value does not match a known message source
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object