Class UserMessage

All Implemented Interfaces:
PropertyChangeSource, Rebindable
Direct Known Subclasses:
AgiUserMessage, InputUserMessage, RagMessage

public class UserMessage extends AbstractMessage
Represents a conversation message originating from the end-user.

This class is the primary entry point for human intent within the Agi session. It extends AbstractMessage to provide user-specific identity resolution and ensures that all user-provided content is correctly typed and attributed to the host device.

Author:
anahata
  • Constructor Details

    • UserMessage

      public UserMessage(Agi agi)
      Constructs a new UserMessage.
      Parameters:
      agi - The parent agi session.
  • Method Details

    • getRole

      public Role getRole()
      Gets the role of the entity that created this message. This is implemented by subclasses to provide compile-time type safety.

      Returns the Role.USER constant for this message type.

      Specified by:
      getRole in class AbstractMessage
      Returns:
      The role of the message creator.
    • getFrom

      public String getFrom()
      Gets the identity of the sender of this message. For user messages, this is typically the user's name. For model messages, it's the model ID. For tool messages, it's the identity of the execution context.

      Returns the user's identity formatted as 'username@device'.

      Specified by:
      getFrom in class AbstractMessage
      Returns:
      The sender's identity.
    • getDevice

      public String getDevice()
      Gets the ID of the device where this message was created or processed. This could be a hostname, a JVM ID, or a cloud identifier.

      Returns the unique identifier of the host that originated this user message.

      Specified by:
      getDevice in class AbstractMessage
      Returns:
      The device ID.
    • addTextPart

      public final TextPart addTextPart(String text)
      Creates and adds a new text part to this message. Creates and adds a UserTextPart.
      Specified by:
      addTextPart in class AbstractMessage
      Parameters:
      text - The text content.
      Returns:
      The created text part.
    • addBlobPart

      public final BlobPart addBlobPart(String mimeType, byte[] data)
      Creates and adds a new binary data part to this message. Creates and adds a UserBlobPart.
      Specified by:
      addBlobPart in class AbstractMessage
      Parameters:
      mimeType - The MIME type.
      data - The binary data.
      Returns:
      The created blob part.
    • addBlobPart

      public final BlobPart addBlobPart(Path path) throws Exception
      Creates and adds a new binary data part from a local file path. Creates and adds a UserBlobPart from a file path.
      Specified by:
      addBlobPart in class AbstractMessage
      Parameters:
      path - The file path.
      Returns:
      The created blob part.
      Throws:
      Exception - if the file cannot be read.