storage

package
v0.38.8-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package storage provides local file storage for sandbox execution outputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Key          string `json:"key"`
	Size         int64  `json:"size"`
	LastModified string `json:"last_modified,omitempty"`
	URL          string `json:"url,omitempty"`
}

File represents a stored file's metadata.

type Scope added in v0.37.0

type Scope struct {
	SessionID   string
	ExecutionID string
}

Scope identifies the storage namespace for an execution's files. When a session is active, files are grouped under the session so a multi-turn session's outputs share one parent directory (<session>/<execution>/); otherwise they fall back to the execution ID alone.

type Service

type Service interface {
	// Upload stores a file scoped to a session/execution and returns its key,
	// public URL, and path on the server host.
	Upload(scope Scope, name string, body io.Reader) (UploadResult, error)
	// List returns files scoped to a session/execution, optionally filtered by prefix.
	List(scope Scope, prefix string) ([]File, error)
	// GetURL returns the public URL for a file scoped to a session/execution.
	GetURL(scope Scope, key string) string
	// ServeFile serves a stored file over HTTP.
	ServeFile(w http.ResponseWriter, r *http.Request, filePath string)
}

Service provides file storage backed by an afero filesystem.

func New

func New(fs afero.Fs, baseDir, baseURL string) Service

New creates a new storage service.

fs is the filesystem implementation (afero.OsFs for production, afero.MemMapFs for tests). baseDir is the root directory for stored files. baseURL is the server's public base URL used to construct file URLs.

type UploadResult added in v0.37.0

type UploadResult struct {
	Key  string
	URL  string
	Path string
}

UploadResult describes a stored file. Path is the file's location on the server host's filesystem — only directly openable when the server runs on the same host as the caller (e.g. the local CLI), not when storage lives in a container volume.

Jump to

Keyboard shortcuts

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