artifact

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package artifact owns session-scoped, explicitly registered workspace deliverables. It stores metadata only; file content remains in the workspace.

Index

Constants

View Source
const (
	MaxInlineTextSize   int64 = 5 << 20
	MaxInlineBinarySize int64 = 25 << 20
	MaxDownloadSize     int64 = 250 << 20
	MaxShareSize        int64 = 25 << 20
)

Variables

View Source
var ErrTooLarge = errors.New("artifact is too large")

Functions

This section is empty.

Types

type Kind

type Kind string
const (
	KindAuto     Kind = "auto"
	KindText     Kind = "text"
	KindMarkdown Kind = "markdown"
	KindCode     Kind = "code"
	KindHTML     Kind = "html"
	KindImage    Kind = "image"
	KindPDF      Kind = "pdf"
	KindCSV      Kind = "csv"
	KindBinary   Kind = "binary"
)

type Loader

type Loader func(sessionID string) ([]Record, error)

type Record

type Record struct {
	ID           string    `json:"id"`
	SessionID    string    `json:"session_id"`
	RelativePath string    `json:"relative_path"`
	Title        string    `json:"title"`
	Kind         Kind      `json:"kind"`
	MediaType    string    `json:"media_type"`
	Size         int64     `json:"size"`
	Revision     int       `json:"revision"`
	UpdatedAt    time.Time `json:"updated_at"`
	Status       Status    `json:"status"`
	Focus        bool      `json:"focus,omitempty"`
}

Record is the metadata persisted in a session entry and exposed to the Web UI. It intentionally contains neither an absolute path nor file content.

type Recorder

type Recorder interface {
	RecordArtifact(Record) error
}

Recorder is the durable boundary. Register never publishes a revision until this append succeeds.

type RegisterRequest

type RegisterRequest struct {
	SessionID    string
	Workspace    string
	RelativePath string
	Title        string
	Kind         Kind
	Focus        bool
}

type Service

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

func NewService

func NewService(loader Loader, now func() time.Time) *Service

func (*Service) List

func (s *Service) List(ctx context.Context, sessionID, workspace string) ([]Record, error)

func (*Service) Open

func (s *Service) Open(ctx context.Context, sessionID, workspace, artifactID string) (Record, *os.File, error)

Open returns a read-only file descriptor constrained by os.Root. Unlike a validate-then-os.Open sequence, Root.Open prevents a concurrent symlink swap from redirecting the read outside the workspace.

func (*Service) Register

func (s *Service) Register(ctx context.Context, req RegisterRequest, recorder Recorder) (Record, error)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, sessionID, workspace, artifactID string) (Record, string, error)

Resolve revalidates a registered artifact at the time of use and returns its server-only absolute path. Callers must never serialize absolutePath.

type Status

type Status string
const (
	StatusAvailable   Status = "available"
	StatusMissing     Status = "missing"
	StatusUnsupported Status = "unsupported"
	StatusTooLarge    Status = "too_large"
	StatusError       Status = "error"
)

Jump to

Keyboard shortcuts

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