attachment

package
v0.0.0-...-93e3117 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceClipboardImage = "clipboard_image"
	SourcePhoneImage     = "phone_image"
	SourceFileImport     = "file_import"
	SourceBrowser        = "browser"
)

Variables

This section is empty.

Functions

func EncodeMeta

func EncodeMeta(meta Metadata) (string, error)

func LoadImage

func LoadImage(path string) ([]byte, string, error)

LoadImage reads an image using its content rather than its filename. Binary PPM images, commonly produced by QEMU's screendump command, are converted to PNG because browsers and chat-completion image inputs do not support PPM.

func PrepareImage

func PrepareImage(data []byte) ([]byte, string, error)

PrepareImage validates image bytes and normalizes formats that providers do not accept directly. Its MIME result is derived from content, not metadata.

Types

type Draft

type Draft struct {
	Metadata
	Token string
}

type Kind

type Kind string
const (
	KindImage       Kind = "image"
	KindAudio       Kind = "audio"
	KindVideo       Kind = "video"
	KindPDF         Kind = "pdf"
	KindText        Kind = "text"
	KindUnsupported Kind = "unsupported"
)

func ClassifyMIME

func ClassifyMIME(mimeType string) Kind

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(stateDir string) *Manager

func (*Manager) AdoptDraft

func (m *Manager) AdoptDraft(draft Draft, sessionID id.ID) (Metadata, error)

func (*Manager) CopyToSession

func (m *Manager) CopyToSession(meta Metadata, sessionID id.ID) (Metadata, error)

func (*Manager) DeleteSessionData

func (m *Manager) DeleteSessionData(sessionID id.ID) error

DeleteSessionData removes all durable attachments owned by a session.

func (*Manager) DraftsDir

func (m *Manager) DraftsDir() string

func (*Manager) ImportClipboardImage

func (m *Manager) ImportClipboardImage(png []byte) (Draft, error)

func (*Manager) ImportClipboardImageData

func (m *Manager) ImportClipboardImageData(data []byte, name string, mimeType string) (Draft, error)

func (*Manager) ImportFile

func (m *Manager) ImportFile(path string) (Draft, error)

func (*Manager) ImportImageData

func (m *Manager) ImportImageData(data []byte, name, mimeType, source string) (Draft, error)

ImportImageData stores an image as a draft that can be adopted by a chat turn.

func (*Manager) ImportSessionData

func (m *Manager) ImportSessionData(sessionID id.ID, data []byte, name, mimeType, source string) (Metadata, error)

ImportSessionData stores generated bytes directly as a durable session attachment.

func (*Manager) ImportSessionFile

func (m *Manager) ImportSessionFile(sessionID id.ID, path, mimeType, source string) (Metadata, error)

ImportSessionFile copies a local file into durable session attachment storage.

func (*Manager) ReadBytes

func (m *Manager) ReadBytes(meta Metadata) ([]byte, error)

func (*Manager) ReadText

func (m *Manager) ReadText(meta Metadata) (string, error)

func (*Manager) SessionDir

func (m *Manager) SessionDir(sessionID id.ID) string

func (*Manager) ValidateDraft

func (m *Manager) ValidateDraft(draft Draft) (Draft, error)

type Metadata

type Metadata struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	MIME     string `json:"mime"`
	Path     string `json:"path"`
	Size     int64  `json:"size"`
	Source   string `json:"source,omitempty"`
	Original string `json:"original,omitempty"`
}

func DecodeMeta

func DecodeMeta(raw string) (Metadata, error)

Jump to

Keyboard shortcuts

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