Class ChannelMediaMetadata

java.lang.Object
io.agentscope.extensions.channel.common.ChannelMediaMetadata

public final class ChannelMediaMetadata extends Object
Metadata key contract for inbound media (image / audio / video / file) messages surfaced by channel inbound mappers.

Channel adapters deliberately do not decode provider media into content blocks: material identifiers (media_id / image_key / file_key / downloadCode) are not URLs and can only be exchanged for bytes through a token-authenticated download whose artifacts are short-lived. Deciding whether and when to fetch, where to buffer, and how to degrade is application policy. Mappers therefore surface a media event as a user Msg whose text content is a neutral marker and whose metadata carries the keys defined here, so the application can observe the event, download the material through its own path, or reply with guidance.

All values are strings. Keys absent on a given platform are omitted; readers must treat the metadata as a sparse map and never assume a key's presence.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Playback duration in milliseconds, as reported by the platform (Feishu and DingTalk both document the field in milliseconds for audio and video messages).
    static final String
    File name, when the platform reports one.
    static final String
    Container / format token (WeCom voice Format, DingTalk video videoType).
    static final String
    Primary provider material identifier (MediaId / image_key / file_key / downloadCode), verbatim.
    static final String
    Normalized media kind — one of image, audio, video, file.
    static final String
    Normalized media kind: audio (voice message).
    static final String
    Normalized media kind: generic file attachment.
    static final String
    Normalized media kind: image (photo / picture).
    static final String
    Normalized media kind: video, including video-bearing composite messages.
    static final String
    Original provider type token, verbatim (WeCom MsgType, Feishu message_type, DingTalk msgtype) — e.g.
    static final String
    Platform speech-to-text result for audio messages, when the platform provides one.
    static final String
    Secondary material identifier when the platform provides one (thumbnail / cover image / picture-specific download code).
    static final String
    Directly fetchable URL when the platform provides one alongside the material id (WeCom image PicUrl).
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    markerText(String kind, String fileName)
    Returns the neutral marker text used as the Msg text content of a mapped media message: "[image]", "[audio]", "[video]", or "[file: report.pdf]" when a file name is available.
    static void
    putIfPresent(Map<String,Object> metadata, String key, String value)
    Puts value under key only when value is neither null nor blank; a null/blank value is silently skipped.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • KIND_IMAGE

      public static final String KIND_IMAGE
      Normalized media kind: image (photo / picture).
      See Also:
    • KIND_AUDIO

      public static final String KIND_AUDIO
      Normalized media kind: audio (voice message).
      See Also:
    • KIND_VIDEO

      public static final String KIND_VIDEO
      Normalized media kind: video, including video-bearing composite messages.
      See Also:
    • KIND_FILE

      public static final String KIND_FILE
      Normalized media kind: generic file attachment.
      See Also:
    • KIND

      public static final String KIND
      Normalized media kind — one of image, audio, video, file.
      See Also:
    • PROVIDER_TYPE

      public static final String PROVIDER_TYPE
      Original provider type token, verbatim (WeCom MsgType, Feishu message_type, DingTalk msgtype) — e.g. voice, picture, media.
      See Also:
    • ID

      public static final String ID
      Primary provider material identifier (MediaId / image_key / file_key / downloadCode), verbatim.
      See Also:
    • SECONDARY_ID

      public static final String SECONDARY_ID
      Secondary material identifier when the platform provides one (thumbnail / cover image / picture-specific download code).
      See Also:
    • URL

      public static final String URL
      Directly fetchable URL when the platform provides one alongside the material id (WeCom image PicUrl).
      See Also:
    • FILE_NAME

      public static final String FILE_NAME
      File name, when the platform reports one.
      See Also:
    • FORMAT

      public static final String FORMAT
      Container / format token (WeCom voice Format, DingTalk video videoType).
      See Also:
    • DURATION_MS

      public static final String DURATION_MS
      Playback duration in milliseconds, as reported by the platform (Feishu and DingTalk both document the field in milliseconds for audio and video messages).
      See Also:
    • RECOGNITION

      public static final String RECOGNITION
      Platform speech-to-text result for audio messages, when the platform provides one.
      See Also:
  • Method Details

    • markerText

      public static String markerText(String kind, String fileName)
      Returns the neutral marker text used as the Msg text content of a mapped media message: "[image]", "[audio]", "[video]", or "[file: report.pdf]" when a file name is available. The marker keeps the event visible to text-only agents; applications are free to rewrite the text before dispatching.

      File names are provider-controlled input, so the embedded copy is sanitized — brackets, control characters and invisible formatting characters are removed, whitespace is collapsed and the copy is truncated — keeping the marker inert against crafted names; the raw name is preserved unmodified under FILE_NAME.

      Parameters:
      kind - normalized media kind, as in KIND
      fileName - optional file name; a sanitized copy is embedded when non-blank
      Throws:
      NullPointerException - if kind is null
    • putIfPresent

      public static void putIfPresent(Map<String,Object> metadata, String key, String value)
      Puts value under key only when value is neither null nor blank; a null/blank value is silently skipped. Channel payloads omit platform-optional fields; this keeps the metadata map sparse.
      Throws:
      NullPointerException - if metadata or key is null