Documentation
¶
Overview ¶
Package artifacts persists immutable image files and their conversation references.
Index ¶
- Constants
- Variables
- func DeleteReferences(ctx context.Context, tx *sqlx.Tx, conversationID string) ([]string, error)
- func RemoveFiles(dbPath string, artifactIDs []string) error
- func SaveReferences(ctx context.Context, tx *sqlx.Tx, conversationID string, ...) error
- type Store
- func (s *Store) Close() error
- func (s *Store) Get(ctx context.Context, conversationID, artifactID string) (tooltypes.ToolAttachment, string, error)
- func (s *Store) GetByShortCode(ctx context.Context, code string) (tooltypes.ToolAttachment, string, error)
- func (s *Store) Put(ctx context.Context, conversationID, toolCallID string, ...) (tooltypes.ToolAttachment, error)
Constants ¶
const ( // MaxBytes bounds an uploaded image's encoded size. MaxBytes int64 = 32 * 1024 * 1024 // MaxPixels bounds decoded image allocation, including all frames of a GIF. MaxPixels int64 = 40_000_000 )
Variables ¶
var ErrNotFound = errors.New("image artifact not found")
ErrNotFound means the image is missing or is not referenced in the requested scope.
Functions ¶
func DeleteReferences ¶
DeleteReferences removes a conversation's references and metadata for images with no remaining references. Returned IDs must be unlinked only after the caller commits its transaction.
func RemoveFiles ¶
RemoveFiles unlinks immutable files after their metadata deletion has committed. A failure is recoverable by the next startup sweep and cannot roll back the committed deletion.
func SaveReferences ¶
func SaveReferences(ctx context.Context, tx *sqlx.Tx, conversationID string, results map[string]tooltypes.StructuredToolResult) error
SaveReferences adds references from an authoritative conversation snapshot in its save transaction. It deliberately retains earlier uploads not yet present in a checkpoint. This also handles live forks.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns immutable files beside the shared SQLite database.
func Open ¶
Open opens artifact storage after the shared database migrations have been applied. It sweeps abandoned uploads and unreferenced files older than 24 hours.
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, conversationID, artifactID string) (tooltypes.ToolAttachment, string, error)
Get resolves an image referenced by the conversation. The returned path is local to the control plane.
func (*Store) GetByShortCode ¶
func (s *Store) GetByShortCode(ctx context.Context, code string) (tooltypes.ToolAttachment, string, error)
GetByShortCode resolves a short link only while at least one conversation references its image. HTTP callers must still enforce the control plane's authentication policy.
func (*Store) Put ¶
func (s *Store) Put( ctx context.Context, conversationID, toolCallID string, attachment tooltypes.ToolAttachment, source io.Reader, ) (tooltypes.ToolAttachment, error)
Put validates and stores an image, adding its conversation/tool reference before returning. The caller must authenticate the upload's conversation and tool-call ownership.