Documentation
¶
Index ¶
- Constants
- func DataMountPath(raw string) string
- func DataSubpath(containerPath string) (string, bool)
- func DecodeBase64(input string, maxBytes int64) (io.Reader, error)
- func ExtractStorageKey(accessPath string) string
- func InferNameFromRef(raw string) string
- func InferTypeFromExt(raw string) string
- func InferTypeFromMime(mime string) string
- func IsDataPath(raw string) bool
- func IsDataURL(raw string) bool
- func IsHTTPURL(raw string) bool
- func IsMediaAccessPath(raw string) bool
- func MapMediaType(rawType string) media.MediaType
- func MediaAccessPath(storageKey string) string
- func MetadataString(metadata map[string]any, key string) string
- func MimeFromDataURL(raw string) string
- func NormalizeBase64DataURL(input, mime string) string
- func NormalizeMime(raw string) string
- func PrepareReaderAndMime(reader io.Reader, mediaType media.MediaType, sourceMime string) (io.Reader, string, error)
- func ResolveMime(mediaType media.MediaType, sourceMime, sniffedMime string) string
- type Bundle
Constants ¶
const ( MetadataKeyBotID = "bot_id" MetadataKeyStorageKey = "storage_key" MetadataKeyName = "name" MetadataKeySourcePath = "source_path" MetadataKeySourceURL = "source_url" )
Variables ¶
This section is empty.
Functions ¶
func DataMountPath ¶
DataMountPath joins a relative path under the canonical container data mount.
func DataSubpath ¶
DataSubpath strips the canonical /data/ prefix and returns the container-relative path.
func DecodeBase64 ¶
DecodeBase64 decodes both raw base64 and data URL base64 content. The returned reader is bounded to maxBytes+1 for caller-side size validation.
func ExtractStorageKey ¶
ExtractStorageKey derives the media storage key from a consumer-facing media path. The legacy /data/media root remains readable during the transition.
func InferNameFromRef ¶
InferNameFromRef extracts a filename from a path or URL-like reference.
func InferTypeFromExt ¶
InferTypeFromExt infers attachment type from file extension.
func InferTypeFromMime ¶
InferTypeFromMime infers attachment type from MIME.
func IsDataPath ¶
IsDataPath reports whether the reference points to the container data mount.
func IsMediaAccessPath ¶
IsMediaAccessPath reports whether raw is under the current or legacy media root. Both roots are managed media during the transition.
func MapMediaType ¶
MapMediaType maps attachment type strings to media types.
func MediaAccessPath ¶
MediaAccessPath returns the consumer-facing media access path for a storage key.
func MetadataString ¶
MetadataString returns a trimmed string metadata value.
func MimeFromDataURL ¶
MimeFromDataURL extracts MIME from a data URL.
func NormalizeBase64DataURL ¶
NormalizeBase64DataURL normalizes raw base64 into a data URL.
func NormalizeMime ¶
NormalizeMime normalizes MIME to lowercase token form.
func PrepareReaderAndMime ¶
func PrepareReaderAndMime(reader io.Reader, mediaType media.MediaType, sourceMime string) (io.Reader, string, error)
PrepareReaderAndMime reads a small prefix for MIME sniffing and replays it.
func ResolveMime ¶
ResolveMime resolves source MIME and sniffed MIME into final MIME.
For image attachments, content sniffing takes precedence over the platform-reported MIME because platforms sometimes declare the wrong image subtype (e.g. "image/png" for a JPEG file). Using the wrong MIME causes multimodal API rejections (HTTP 400).
Types ¶
type Bundle ¶
type Bundle struct {
Type string
Base64 string
Path string
URL string
PlatformKey string
SourcePlatform string
ContentHash string
Name string
Mime string
Size int64
DurationMs int64
Width int
Height int
ThumbnailURL string
Caption string
Metadata map[string]any
}
Bundle is the internal attachment normalization shape shared across messaging, channel ingress, and gateway preparation. It is intentionally not exposed as a user-facing contract.
func BundleFromMap ¶
BundleFromMap builds a bundle from a generic JSON-like object.
func ParseToolInputBundles ¶
ParseToolInputBundles normalizes the `send.attachments` argument shape into internal bundles while preserving existing path resolution rules.
func (Bundle) MergeIntoMap ¶
MergeIntoMap applies bundle-owned fields into an existing JSON-like object. Unknown fields are preserved.
func (Bundle) Normalize ¶
Normalize canonicalizes transport fields and fills lightweight derived data such as MIME, name, and inferred type.