media

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package media provides shared utility functions for building and describing messenger.Attachment values across platform adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DescribeAttachments

func DescribeAttachments(attachments []messenger.Attachment, baseDir ...string) string

DescribeAttachments generates a human-readable text description of the given attachments. This is used to augment user messages so the LLM knows about any attached files. Includes local file paths when available so the LLM can use read_file to access the content.

When baseDir is non-empty, absolute LocalPaths that fall under baseDir are converted to relative paths so the file tool (which rejects absolute paths) can resolve them. Paths outside baseDir are left absolute as a fallback.

Example output: "[Attached: report.pdf (application/pdf, 1.2 MB) → .genie/whatsapp/media/report.pdf]"

func ExtFromMIME

func ExtFromMIME(mime string) string

ExtFromMIME returns a file extension (including the dot) for the given MIME type. Returns ".bin" if the MIME type is unknown.

func FormatFileSize

func FormatFileSize(bytes int64) string

FormatFileSize returns a human-readable file size string.

func MIMEFromFilename

func MIMEFromFilename(name string) string

MIMEFromFilename returns a MIME type based on the file extension. Returns "application/octet-stream" if the extension is unknown.

func NameFromMIME

func NameFromMIME(mime, prefix string) string

NameFromMIME generates a filename from a MIME type and a prefix. Used when the platform doesn't provide a filename (e.g., images, audio). Example: NameFromMIME("image/jpeg", "image") → "image.jpg"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL