Member Junction
    Preparing search index...

    Utility class for parsing and formatting special content in conversation messages Handles @{...} syntax for mentions, forms, and other structured content

    All content uses the @{...} wrapper with a _mode field to distinguish types. If _mode is omitted, defaults to "mention" for backward compatibility.

    const tokens = ConversationUtility.ParseSpecialContent(message);
    const plainText = ConversationUtility.ToPlainText(message, agents, users);
    const agentContext = ConversationUtility.ToAgentContext(message, agents, users);
    const html = ConversationUtility.ToHTML(message, agents, users);
    Index

    Constructors

    Methods

    • Build ChatMessageContent from text and attachment data. This is the primary method for converting stored messages to AI-ready format.

      Parameters

      • messageText: string

        The message text (may contain @{...} tokens)

      • attachmentData: AttachmentData[]

        Array of attachment data with content

      • Optionalagents: AgentInfo[]

        Optional agents for mention resolution

      • Optionalusers: UserInfo[]

        Optional users for mention resolution

      Returns Promise<ChatMessageContent>

      ChatMessageContent ready for AI provider

    • Check if a message contains attachment references

      Parameters

      • text: string

        The message text to check

      Returns boolean

      true if the message contains attachment syntax

    • Check if a message contains form response syntax (@{"_mode":"form",...}) Useful for fast-path routing decisions without running full LLM inference.

      Form responses should always be routed back to the agent that requested the form, so this can be used to skip intent-checking prompts entirely.

      Parameters

      • text: string

        The message text to check

      Returns boolean

      true if the message contains form response syntax

    • Create a form response token string

      Parameters

      • action: string

        The action being performed (e.g., "createRecord")

      • fields: { label?: string; name: string; value: any }[]

        Array of field name/value pairs

      • Optionaltitle: string

        Optional form title for display

      Returns string

      Formatted @{...} string for the form response

    • Create a mention token string

      Parameters

      • type: "user" | "entity" | "agent" | "query"

        Type of mention (agent, user, entity, or query)

      • id: string

        ID of the mentioned entity

      • name: string

        Name of the mentioned entity

      • OptionalconfigurationId: string

        Optional agent configuration ID

      • OptionalconfigurationName: string

        Optional agent configuration name

      Returns string

      Formatted @{...} string for the mention

    • Get the ChatMessageContentBlock type from attachment type

      Parameters

      Returns "image_url" | "video_url" | "audio_url" | "file_url"

      The corresponding content block type

    • Determine if an attachment should be stored inline or in MJStorage

      Parameters

      • sizeBytes: number

        Size of the attachment in bytes

      • agentThreshold: number

        Agent-level threshold override (optional)

      • systemThreshold: number

        System default threshold

      Returns boolean

      true if should be stored inline, false if should use MJStorage

    • Convert message for agent consumption (LLM input)

      • Mentions: Just the name "Agent Name" (no @ prefix)
      • Forms: Full JSON for agent to understand context

      Parameters

      • text: string

        The message text to convert

      • Optionalagents: AgentInfo[]

        Optional array of agent information for name lookup

      • Optionalusers: UserInfo[]

        Optional array of user information for name lookup

      Returns string

      Agent-friendly representation of the message

    • Convert message to plain text (for display/export)

      • Mentions: "@Agent Name" or "@User Name"
      • Forms: "Form Response: Field1=Value1, Field2=Value2"

      Parameters

      • text: string

        The message text to convert

      • Optionalagents: AgentInfo[]

        Optional array of agent information for name lookup

      • Optionalusers: UserInfo[]

        Optional array of user information for name lookup

      Returns string

      Plain text representation of the message