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
- func Dir(configDir string) string
- func SessionDir(root, filesKey string) string
- type Service
- func (s *Service) Attach(_ context.Context, opts api.AttachArtifactOptions) (api.DropAttachment, error)
- func (s *Service) List(_ context.Context, _ api.None) ([]api.SessionArtifacts, error)
- func (s *Service) Open(_ context.Context, opts api.AttachArtifactOptions) (api.None, error)
- func (s *Service) PruneOrphans()
- func (s *Service) Purge(filesKey string)
- func (s *Service) RunWatch()
- func (s *Service) SetSessions(sessions Sessions, emit func(name string, data any))
- type Sessions
Constants ¶
const EnvVar = "LICH_ARTIFACT_DIR"
EnvVar names the session's own artifact directory in its environment.
Variables ¶
This section is empty.
Functions ¶
func SessionDir ¶
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 (*Service) Attach ¶
func (s *Service) Attach(_ context.Context, opts api.AttachArtifactOptions) (api.DropAttachment, error)
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) 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 ¶
Purge deletes the artifacts under one files key, its row being gone for good (store.SetSessionGone).
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.