artifact

package
v0.94.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package artifact keeps the pages a session's agent writes to show the user, a report, a diagram, a mockup, one directory per session outside its checkout, so they never land in git. The session's browser opens them from there (internal/preview), whatever provider runs in it.

A directory is named by the session's files key (store.SessionFilesKey), which a resume carries to the row's fresh id, so it lives exactly as long as the session: closing the card parks the row and keeps it, a restart and a resume find it again, and a path the agent already said keeps naming its page. Deleting the row deletes it (Purge), and a directory whose row is gone without lich seeing it go, a crash, is cleared at the next startup (PruneOrphans).

Index

Constants

View Source
const EnvVar = "LICH_ARTIFACT_DIR"

EnvVar names the session's own artifact directory in its environment.

Variables

This section is empty.

Functions

func Dir

func Dir(configDir string) string

Dir is where a lich with this config directory keeps every session's artifacts.

func SessionDir

func SessionDir(root, filesKey string) string

SessionDir is the directory under root of the session whose files key is filesKey, "" for a key that is not a single path element.

Types

type Service

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

func New

func New(root string, live func(filesKey string) bool) *Service

func (*Service) Attach

Attach puts From's artifact Name where SessionID can read it. The same session gets the artifact's own path; another gets a copy in its own folder, since a confined session cannot read the folder of the session beside it, and the copy outlives From. The source is read through an os.Root, so a link inside From's folder cannot copy a file from outside it.

func (*Service) List

func (s *Service) List(_ context.Context, _ api.None) ([]api.SessionArtifacts, error)

List is every open session's artifacts, for a window that just attached.

func (*Service) Of

func (s *Service) Of(sessionID string) []api.Artifact

Of is session's artifacts, newest first: what its Artifacts tab lists.

func (*Service) Open

Open loads From's artifact Name in SessionID's browser.

func (*Service) PruneOrphans

func (s *Service) PruneOrphans()

PruneOrphans deletes the directories no row holds the files key of. Startup only: no session has spawned yet, so none has its directory mounted.

func (*Service) Purge

func (s *Service) Purge(filesKey string)

Purge deletes the artifacts under one files key, its row being gone for good (store.SetSessionGone).

func (*Service) RunWatch

func (s *Service) RunWatch()

RunWatch emits ArtifactsEvent for every open session whose list changed since the last pass, and an empty one for a session no longer open. It never returns.

func (*Service) SetSessions

func (s *Service) SetSessions(sessions Sessions, emit func(name string, data any))

SetSessions wires the sessions and where ArtifactsEvent goes. Startup wiring, called before anything serves.

type Sessions

type Sessions struct {
	// Open maps every open session to its files key.
	Open  func() (map[string]string, error)
	Key   func(sessionID string) string
	Label func(sessionID string) string
	Lang  func() prompt.Lang
	// Show loads the page at path, in the artifact folder of session from,
	// in session's browser (main.go: the preview server and internal/browser).
	Show func(session, from, path string) error
}

Sessions is what the lists and copies read the sessions through (internal/store). Startup wiring, see SetSessions.

Jump to

Keyboard shortcuts

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