Private mdPrivate modalityAdd a new attachment to a conversation detail. Handles validation, storage decision, thumbnail generation, and record creation.
The ID of the conversation detail
The attachment data and metadata
The AI agent (for limit overrides)
The AI model (for capability limits)
The current user context
Current attachment counts for validation
The result with created attachment or error
Private attachmentPrivate calculatePrivate createCreate an attachment record in the database using strongly-typed entity.
Create an AttachmentContent reference for embedding in messages. Maps from entity to the content block type used in AI messages.
The attachment entity
The attachment content reference
Delete an attachment and its underlying storage.
The attachment ID
The current user context
Whether deletion succeeded
Private deleteDelete a file from MJStorage
Private generateGenerate a thumbnail for an image. Returns base64-encoded thumbnail data.
Note: This is a placeholder implementation. In production, you'd use a library like sharp or Jimp for server-side image processing, or Canvas API for client-side.
Get attachment data with content URL. For inline attachments, returns the base64 data URL. For MJStorage attachments, returns a pre-authenticated download URL.
The attachment entity
The current user context
The attachment with content URL
Get all attachments for a conversation detail.
The conversation detail ID
The current user context
Array of attachment entities
Get attachments for multiple conversation details (batch load).
Array of conversation detail IDs
The current user context
Map of conversation detail ID to attachments
Get a pre-authenticated download URL for an MJStorage file.
The File entity ID
The current user context
The download URL or null if unavailable
Private getGet modality by name (e.g., 'Image', 'Audio', 'Video', 'File')
Private loadLoad and cache modalities for efficient lookup
Private uploadUpload data to MJStorage
Service for managing conversation attachments. Handles validation, storage, thumbnails, and CRUD operations.