artifacts

package
v0.6.7-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package artifacts persists immutable image files and their conversation references.

Index

Constants

View Source
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

View Source
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

func DeleteReferences(ctx context.Context, tx *sqlx.Tx, conversationID string) ([]string, error)

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

func RemoveFiles(dbPath string, artifactIDs []string) error

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

func Open(ctx context.Context, dbPath string) (*Store, error)

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) Close

func (s *Store) Close() error

Close releases the database connection.

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.

Jump to

Keyboard shortcuts

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