Documentation
¶
Overview ¶
Package vessel provides a containerized workspace for AI agents, built on containerd to run commands, manage snapshots, and plug in custom storage.
Index ¶
- type CompressedStorage
- func (s *CompressedStorage) DeleteSnapshot(ctx context.Context, vesselID, snapshotID string) error
- func (s *CompressedStorage) DeleteVessel(ctx context.Context, vesselID string) error
- func (s *CompressedStorage) LoadImage(ctx context.Context, imageRef string) (io.ReadCloser, error)
- func (s *CompressedStorage) LoadSnapshot(ctx context.Context, vesselID, snapshotID string) (io.ReadCloser, error)
- func (s *CompressedStorage) LoadVesselManifest(ctx context.Context, vesselID string) ([]byte, error)
- func (s *CompressedStorage) SaveSnapshot(ctx context.Context, vesselID, snapshotID string, reader io.Reader) error
- func (s *CompressedStorage) SaveVesselManifest(ctx context.Context, vesselID string, manifest []byte) error
- type ExecOptions
- type ExecResult
- type File
- type IDGenerator
- type Image
- type LocalStorage
- func (s *LocalStorage) DeleteSnapshot(ctx context.Context, vesselID, snapshotID string) error
- func (s *LocalStorage) DeleteVessel(ctx context.Context, vesselID string) error
- func (s *LocalStorage) LoadImage(ctx context.Context, imageRef string) (io.ReadCloser, error)
- func (s *LocalStorage) LoadSnapshot(ctx context.Context, vesselID, snapshotID string) (io.ReadCloser, error)
- func (s *LocalStorage) LoadVesselManifest(ctx context.Context, vesselID string) ([]byte, error)
- func (s *LocalStorage) SaveSnapshot(ctx context.Context, vesselID, snapshotID string, reader io.Reader) error
- func (s *LocalStorage) SaveVesselManifest(ctx context.Context, vesselID string, manifest []byte) error
- type Manager
- type ManagerConfig
- type SnapshotManifest
- type Storage
- type UniqueIDGenerator
- type Vessel
- type VesselManifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompressedStorage ¶
type CompressedStorage struct {
// contains filtered or unexported fields
}
CompressedStorage wraps another Storage and transparently compresses artifacts.
func (*CompressedStorage) DeleteSnapshot ¶
func (s *CompressedStorage) DeleteSnapshot(ctx context.Context, vesselID, snapshotID string) error
DeleteSnapshot forwards deletion to the underlying store.
func (*CompressedStorage) DeleteVessel ¶
func (s *CompressedStorage) DeleteVessel(ctx context.Context, vesselID string) error
DeleteVessel removes vessel data in the underlying store.
func (*CompressedStorage) LoadImage ¶
func (s *CompressedStorage) LoadImage(ctx context.Context, imageRef string) (io.ReadCloser, error)
LoadImage wraps the underlying reader with gzip decompression.
func (*CompressedStorage) LoadSnapshot ¶
func (s *CompressedStorage) LoadSnapshot(ctx context.Context, vesselID, snapshotID string) (io.ReadCloser, error)
LoadSnapshot returns a decompressed snapshot Reader.
func (*CompressedStorage) LoadVesselManifest ¶
func (s *CompressedStorage) LoadVesselManifest(ctx context.Context, vesselID string) ([]byte, error)
LoadVesselManifest delegates manifest retrieval without compression.
func (*CompressedStorage) SaveSnapshot ¶
func (s *CompressedStorage) SaveSnapshot(ctx context.Context, vesselID, snapshotID string, reader io.Reader) error
SaveSnapshot compresses snapshot diffs before writing to storage.
func (*CompressedStorage) SaveVesselManifest ¶
func (s *CompressedStorage) SaveVesselManifest(ctx context.Context, vesselID string, manifest []byte) error
SaveVesselManifest delegates manifest persistence without compression.
type ExecOptions ¶
type ExecOptions struct {
// Command names the command and arguments to run inside the vessel.
Command []string
// WorkDir overrides the working directory inside the vessel.
WorkDir string
// Env carries optional environment variables in KEY=VALUE form.
Env []string
// Terminal enables TTY mode for interactive commands.
Terminal bool
// Stdin supplies an optional stdin reader.
Stdin io.Reader
// Stdout captures stdout; defaults to discard.
Stdout io.Writer
// Stderr captures stderr; defaults to discard.
Stderr io.Writer
// PersistResult keeps filesystem changes after the command finishes.
PersistResult bool
}
ExecOptions controls how commands run inside a vessel container.
type ExecResult ¶
type ExecResult struct {
// ExitCode is the exit status reported by containerd.
ExitCode int
}
ExecResult contains the exit status returned by Exec.
type File ¶
type File interface {
io.Closer
io.Reader
io.ReaderAt
io.Writer
io.WriterAt
io.Seeker
Name() string
Stat() (os.FileInfo, error)
Sync() error
Truncate(size int64) error
}
File reuses os.File-like semantics for interacting with workspace files.
type IDGenerator ¶
type IDGenerator interface {
NewID() string
}
IDGenerator produces unique identifiers for vessels and snapshots.
type LocalStorage ¶
type LocalStorage struct {
// contains filtered or unexported fields
}
LocalStorage stores vessel metadata and layers on the filesystem.
func (*LocalStorage) DeleteSnapshot ¶
func (s *LocalStorage) DeleteSnapshot(ctx context.Context, vesselID, snapshotID string) error
DeleteSnapshot removes a snapshot diff from disk.
func (*LocalStorage) DeleteVessel ¶
func (s *LocalStorage) DeleteVessel(ctx context.Context, vesselID string) error
DeleteVessel removes all local data associated with a vessel.
func (*LocalStorage) LoadImage ¶
func (s *LocalStorage) LoadImage(ctx context.Context, imageRef string) (io.ReadCloser, error)
LoadImage loads a persisted container image for import into containerd.
func (*LocalStorage) LoadSnapshot ¶
func (s *LocalStorage) LoadSnapshot(ctx context.Context, vesselID, snapshotID string) (io.ReadCloser, error)
LoadSnapshot opens a stored snapshot diff for replay.
func (*LocalStorage) LoadVesselManifest ¶
LoadVesselManifest returns the serialized manifest bytes for a vessel.
func (*LocalStorage) SaveSnapshot ¶
func (s *LocalStorage) SaveSnapshot(ctx context.Context, vesselID, snapshotID string, reader io.Reader) error
SaveSnapshot stores a new snapshot diff stream for a vessel.
func (*LocalStorage) SaveVesselManifest ¶
func (s *LocalStorage) SaveVesselManifest(ctx context.Context, vesselID string, manifest []byte) error
SaveVesselManifest writes the current vessel manifest to disk.
type Manager ¶
type Manager interface {
CreateVessel(ctx context.Context, imageRef string, workDir string) (Vessel, error)
OpenVessel(ctx context.Context, vesselID string) (Vessel, error)
DeleteVessel(ctx context.Context, vesselID string) error
Close() error
}
Manager coordinates lifecycle of containerized workspaces.
func NewManager ¶
func NewManager(config *ManagerConfig) (Manager, error)
NewManager creates a Manager backed by containerd and the provided storage.
type ManagerConfig ¶
type ManagerConfig struct {
// ContainerdAddress is the containerd socket path, defaults to `/run/containerd/containerd.sock`
// or `XDG_RUNTIME_DIR/containerd/containerd.sock` for rootless usage.
ContainerdAddress string
// Namespace scopes images and snapshots inside containerd, defaults to "vessel".
Namespace string
// Rootless enables fuse-overlayfs and adjusts runtime paths for non-root usage.
Rootless bool
// Storage provides snapshot and manifest persistence, defaults to `LocalStorage` with `CompressedStorage` decorator.
Storage Storage
// MountRoot is the directory where vessel mounts are created, defaults to `~/.local/share/vessel/mounts`.
MountRoot string
// IDGenerator generates unique identifiers for vessels and snapshots, defaults to `UniqueIDGenerator`.
IDGenerator IDGenerator
}
ManagerConfig configures how a Manager connects to containerd and storage.
type SnapshotManifest ¶
type SnapshotManifest struct {
ID string `json:"id"`
VesselID string `json:"vesselId"`
ParentID string `json:"parentId"`
Message string `json:"message"`
Checksum string `json:"checksum"`
Size int64 `json:"size"`
CreateTime time.Time `json:"createTime"`
Labels map[string]string `json:"labels"`
}
SnapshotManifest describes an immutable snapshot diff for a vessel.
type Storage ¶
type Storage interface {
SaveVesselManifest(ctx context.Context, vesselID string, manifest []byte) error
LoadVesselManifest(ctx context.Context, vesselID string) ([]byte, error)
LoadImage(ctx context.Context, imageRef string) (io.ReadCloser, error)
SaveSnapshot(ctx context.Context, vesselID, snapshotID string, reader io.Reader) error
LoadSnapshot(ctx context.Context, vesselID, snapshotID string) (io.ReadCloser, error)
DeleteSnapshot(ctx context.Context, vesselID, snapshotID string) error
DeleteVessel(ctx context.Context, vesselID string) error
}
Storage abstracts persistence for manifests, layers, and container images.
func NewCompressedStorage ¶
NewCompressedStorage decorates a Storage with gzip compression.
type UniqueIDGenerator ¶
type UniqueIDGenerator struct{}
UniqueIDGenerator is the default implementation of IDGenerator that produces monotonic-ish hex identifiers mixing timestamp and randomness.
func NewUniqueIDGenerator ¶
func NewUniqueIDGenerator() *UniqueIDGenerator
NewUniqueIDGenerator creates a new UniqueIDGenerator instance.
func (*UniqueIDGenerator) NewID ¶
func (g *UniqueIDGenerator) NewID() string
NewID returns a unique 16-character hex identifier.
type Vessel ¶
type Vessel interface {
ID() string
GetManifest() *VesselManifest
OpenFile(path string, flag int, perm os.FileMode) (File, error)
ReadFile(path string) ([]byte, error)
WriteFile(path string, data []byte, perm os.FileMode) error
DeleteFile(path string) error
RenameFile(oldPath, newPath string) error
Stat(path string) (os.FileInfo, error)
MakeDir(path string, perm os.FileMode) error
MakeDirAll(path string, perm os.FileMode) error
ReadDir(path string) ([]os.DirEntry, error)
Exec(ctx context.Context, opts *ExecOptions) (*ExecResult, error)
CreateSnapshot(ctx context.Context, message string) (*SnapshotManifest, error)
RestoreSnapshot(ctx context.Context, snapshotID string) error
DeleteSnapshot(ctx context.Context, snapshotID string) error
ListSnapshots(ctx context.Context) ([]*SnapshotManifest, error)
Close() error
}
Vessel represents a mutable container workspace backed by snapshots.
type VesselManifest ¶
type VesselManifest struct {
ID string `json:"id"`
BaseImageRef string `json:"baseImageRef"`
CurrentSnapshotID string `json:"currentSnapshotId"`
WorkDir string `json:"workDir"`
CreateTime time.Time `json:"createTime"`
UpdateTime time.Time `json:"updateTime"`
Labels map[string]string `json:"labels"`
Snapshots []*SnapshotManifest `json:"snapshots"`
}
VesselManifest tracks the vessel state persisted in storage.