Documentation
¶
Index ¶
- Constants
- func AudioKey(sessionID, filename string, now time.Time) string
- func BuildArtifactKey(request ArtifactPutRequest) string
- func CopyFile(ctx context.Context, srcKey, dstKey string) error
- func DefaultLocalPath() string
- func DeleteDocument(ctx context.Context, key string) error
- func DeleteFile(ctx context.Context, key string) error
- func DetectContentType(filename string) string
- func DocumentKey(filename string, now time.Time) string
- func DownloadFile(ctx context.Context, key string) ([]byte, error)
- func DownloadKey(sessionID, pageID, filename string, now time.Time) string
- func Exists(ctx context.Context, key string) (bool, error)
- func GeneratedImageKey(sessionID, filename string, now time.Time) string
- func GetFileURL(ctx context.Context, key string) (string, error)
- func HealthCheck(ctx context.Context) error
- func LoadDocument(ctx context.Context, key string) ([]byte, error)
- func MoveFile(ctx context.Context, srcKey, dstKey string) error
- func PDFKey(title string, now time.Time) string
- func ResetProvider()
- func ScreenshotKey(sessionID, pageID string, now time.Time) string
- func SetConfig(cfg Config)
- func StoreDocument(ctx context.Context, data []byte, filename string) (string, error)
- func StorePDF(ctx context.Context, data []byte, title string) (string, error)
- func StoreScreenshot(ctx context.Context, data []byte, sessionID, pageID string) (string, error)
- func UploadFile(ctx context.Context, key string, data []byte, contentType string) error
- func WebArtifactKey(sessionID, filename string, now time.Time) string
- type ArtifactMetadata
- type ArtifactNamespace
- type ArtifactPutRequest
- type ArtifactRef
- func ListFiles(ctx context.Context, prefix string, limit int) ([]ArtifactRef, error)
- func OpenFileReader(ctx context.Context, key string) (io.ReadCloser, ArtifactRef, error)
- func StatFile(ctx context.Context, key string) (ArtifactRef, error)
- func StoreAudioRef(ctx context.Context, store ArtifactStore, data []byte, ...) (ArtifactRef, error)
- func StoreDocumentRef(ctx context.Context, store ArtifactStore, data []byte, filename string) (ArtifactRef, error)
- func StoreGeneratedImageRef(ctx context.Context, store ArtifactStore, data []byte, ...) (ArtifactRef, error)
- func StorePDFRef(ctx context.Context, store ArtifactStore, data []byte, title string) (ArtifactRef, error)
- func StoreRAGDocumentRef(ctx context.Context, store ArtifactStore, data []byte, filename string) (ArtifactRef, error)
- func StoreScreenshotRef(ctx context.Context, store ArtifactStore, data []byte, ...) (ArtifactRef, error)
- func StoreWebArtifactRef(ctx context.Context, store ArtifactStore, data []byte, ...) (ArtifactRef, error)
- type ArtifactRetentionClass
- type ArtifactStore
- type Config
- type FileInfo
- type GCOptions
- type GCReport
- type ListOptions
- type LocalProvider
- func (p *LocalProvider) Delete(ctx context.Context, key string) error
- func (p *LocalProvider) Download(ctx context.Context, key string) ([]byte, error)
- func (p *LocalProvider) Exists(ctx context.Context, key string) (bool, error)
- func (p *LocalProvider) GetURL(ctx context.Context, key string) (string, error)
- func (p *LocalProvider) List(ctx context.Context, options ListOptions) ([]ObjectInfo, error)
- func (p *LocalProvider) OpenReader(ctx context.Context, key string) (io.ReadCloser, ObjectInfo, error)
- func (p *LocalProvider) Stat(ctx context.Context, key string) (ObjectInfo, error)
- func (p *LocalProvider) Upload(ctx context.Context, key string, data []byte, contentType string) error
- type ObjectInfo
- type ProviderType
- type Reaper
- type ReaperConfig
- type S3Provider
- func (p *S3Provider) Delete(ctx context.Context, key string) error
- func (p *S3Provider) Download(ctx context.Context, key string) ([]byte, error)
- func (p *S3Provider) Exists(ctx context.Context, key string) (bool, error)
- func (p *S3Provider) GetURL(ctx context.Context, key string) (string, error)
- func (p *S3Provider) List(ctx context.Context, options ListOptions) ([]ObjectInfo, error)
- func (p *S3Provider) OpenReader(ctx context.Context, key string) (io.ReadCloser, ObjectInfo, error)
- func (p *S3Provider) Stat(ctx context.Context, key string) (ObjectInfo, error)
- func (p *S3Provider) Upload(ctx context.Context, key string, data []byte, contentType string) error
- type StorageProvider
Constants ¶
const DefaultS3Region = "us-east-1"
Variables ¶
This section is empty.
Functions ¶
func AudioKey ¶
AudioKey builds a session-scoped key for a TTS/STT audio file. Layout: sessions/{sessionID}/artifacts/audio/{date}/{timestamp}-{filename}
func BuildArtifactKey ¶
func BuildArtifactKey(request ArtifactPutRequest) string
func DefaultLocalPath ¶
func DefaultLocalPath() string
DefaultLocalPath returns the root directory for the local artifact store. Using the runtime root directly (not a storage/ subdirectory) so that session-scoped keys (sessions/{id}/images/, sessions/{id}/tools/, …) land at the same level as plans and logs — all under ~/.config/seshat-cli/. Non-session namespaces (documents/, rag/, artifacts/web/) are unaffected.
func DetectContentType ¶
func DownloadKey ¶
DownloadKey builds a session-scoped storage key for a browser download. Layout: sessions/{sessionID}/tools/{pageID}/{date}/{timestamp}-{filename}
func GeneratedImageKey ¶
GeneratedImageKey builds a session-scoped key for an AI-generated image. Layout: sessions/{sessionID}/artifacts/images/{date}/{timestamp}-{filename}
func HealthCheck ¶
func ResetProvider ¶
func ResetProvider()
func ScreenshotKey ¶
ScreenshotKey builds a session-scoped storage key for a browser screenshot. Layout: sessions/{sessionID}/artifacts/screenshots/{pageID}/{date}/{timestamp}-screenshot.png Must match the path produced by BuildArtifactKey(NamespaceBrowserScreenshots).
func StoreDocument ¶
func StoreScreenshot ¶
func UploadFile ¶
Types ¶
type ArtifactMetadata ¶
type ArtifactMetadata struct {
Key string `json:"key"`
Namespace string `json:"namespace,omitempty"`
Filename string `json:"filename,omitempty"`
SessionID string `json:"session_id,omitempty"`
PageID string `json:"page_id,omitempty"`
ContentType string `json:"content_type,omitempty"`
Size int64 `json:"size,omitempty"`
ChecksumSHA256 string `json:"checksum_sha256,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
ModifiedAt time.Time `json:"modified_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
RetentionClass ArtifactRetentionClass `json:"retention_class,omitempty"`
}
ArtifactMetadata is the persisted control-plane record associated with a blob. It lets the runtime run GC, checks integrity, and prepare future document/RAG features without coupling this package to a specific database.
func ReadFileMetadata ¶
func ReadFileMetadata(ctx context.Context, key string) (ArtifactMetadata, error)
type ArtifactNamespace ¶
type ArtifactNamespace string
ArtifactNamespace groups stored objects by runtime-level responsibility. These prefixes are intentionally generic so the core can stay reusable while backend layers add higher-level document, RAG, or tenant semantics on top.
const ( NamespaceDocuments ArtifactNamespace = "documents" NamespaceWebArtifacts ArtifactNamespace = "artifacts/web" NamespaceBrowserScreenshots ArtifactNamespace = "artifacts/browser/screenshots" NamespaceBrowserDownloads ArtifactNamespace = "artifacts/browser/downloads" NamespaceRAGDocuments ArtifactNamespace = "rag/documents" )
type ArtifactPutRequest ¶
type ArtifactPutRequest struct {
Namespace ArtifactNamespace
Filename string
SessionID string
PageID string
ContentType string
Timestamp time.Time
RetentionClass ArtifactRetentionClass
TTL time.Duration
}
ArtifactPutRequest describes a runtime-level persisted artifact. The artifact store derives the storage key from this struct so callers do not duplicate key layout logic across browser, fetch, and future RAG layers.
type ArtifactRef ¶
type ArtifactRef struct {
Key string `json:"key"`
URL string `json:"url"`
ContentType string `json:"content_type,omitempty"`
Size int64 `json:"size,omitempty"`
ModifiedAt time.Time `json:"modified_at,omitempty"`
ChecksumSHA256 string `json:"checksum_sha256,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
Namespace string `json:"namespace,omitempty"`
}
ArtifactRef is the stable runtime-facing handle returned after persisting a blob. Callers should pass these refs around instead of assuming a local path or S3 URL.
func OpenFileReader ¶
func OpenFileReader(ctx context.Context, key string) (io.ReadCloser, ArtifactRef, error)
func StoreAudioRef ¶
func StoreAudioRef(ctx context.Context, store ArtifactStore, data []byte, sessionID, filename, contentType string) (ArtifactRef, error)
StoreAudioRef persists a TTS/STT audio file under the session's artifacts/audio/ dir.
func StoreDocumentRef ¶
func StoreDocumentRef(ctx context.Context, store ArtifactStore, data []byte, filename string) (ArtifactRef, error)
func StoreGeneratedImageRef ¶
func StoreGeneratedImageRef(ctx context.Context, store ArtifactStore, data []byte, sessionID, filename, contentType string) (ArtifactRef, error)
StoreGeneratedImageRef persists an AI-generated image under the session's artifacts/images/ dir.
func StorePDFRef ¶
func StorePDFRef(ctx context.Context, store ArtifactStore, data []byte, title string) (ArtifactRef, error)
func StoreRAGDocumentRef ¶
func StoreRAGDocumentRef(ctx context.Context, store ArtifactStore, data []byte, filename string) (ArtifactRef, error)
func StoreScreenshotRef ¶
func StoreScreenshotRef(ctx context.Context, store ArtifactStore, data []byte, sessionID, pageID string) (ArtifactRef, error)
func StoreWebArtifactRef ¶
func StoreWebArtifactRef(ctx context.Context, store ArtifactStore, data []byte, sessionID, filename, contentType string) (ArtifactRef, error)
StoreWebArtifactRef persists web-fetched content under the session's artifacts/web/ dir.
type ArtifactRetentionClass ¶
type ArtifactRetentionClass string
ArtifactRetentionClass controls lifecycle defaults for persisted artifacts.
const ( RetentionDurable ArtifactRetentionClass = "durable" RetentionTemporary ArtifactRetentionClass = "temporary" RetentionSession ArtifactRetentionClass = "session" )
type ArtifactStore ¶
type ArtifactStore interface {
Put(ctx context.Context, key string, body []byte, contentType string) (ArtifactRef, error)
PutArtifact(ctx context.Context, request ArtifactPutRequest, body []byte) (ArtifactRef, error)
Get(ctx context.Context, key string) ([]byte, error)
OpenReader(ctx context.Context, key string) (io.ReadCloser, ArtifactRef, error)
Stat(ctx context.Context, key string) (ArtifactRef, error)
List(ctx context.Context, options ListOptions) ([]ArtifactRef, error)
Metadata(ctx context.Context, key string) (ArtifactMetadata, error)
ListMetadata(ctx context.Context, options ListOptions) ([]ArtifactMetadata, error)
GarbageCollect(ctx context.Context, options GCOptions) (GCReport, error)
Delete(ctx context.Context, key string) error
Exists(ctx context.Context, key string) (bool, error)
URL(ctx context.Context, key string) (string, error)
}
ArtifactStore is the narrow abstraction consumed by browser/fetch/document layers. It deliberately hides provider-specific details so the runtime can switch between local and object storage without leaking infra concerns into web packages.
func DefaultArtifactStore ¶
func DefaultArtifactStore() (ArtifactStore, error)
DefaultArtifactStore returns the process-wide artifact store backed by the configured provider.
func NewArtifactStore ¶
func NewArtifactStore(provider StorageProvider) ArtifactStore
NewArtifactStore adapts an existing provider into the narrower artifact interface.
func NewArtifactStoreFromConfig ¶
func NewArtifactStoreFromConfig(cfg Config) (ArtifactStore, error)
NewArtifactStoreFromConfig creates an artifact store from an explicit Config, bypassing the process-wide provider singleton. Use when different SDK clients need independent storage backends.
type Config ¶
type Config struct {
Provider ProviderType
LocalPath string
S3Endpoint string
S3Bucket string
S3AccessKeyID string
S3SecretAccessKey string
S3Region string
S3KeyPrefix string
}
func GetConfigFromEnv ¶
func GetConfigFromEnv() Config
type GCOptions ¶
type GCOptions struct {
Now time.Time
Namespaces []ArtifactNamespace
Limit int
DryRun bool
}
GCOptions controls artifact garbage collection.
type GCReport ¶
type GCReport struct {
Scanned int `json:"scanned"`
Deleted int `json:"deleted"`
Kept int `json:"kept"`
Errors []string `json:"errors,omitempty"`
DeletedKeys []string `json:"deleted_keys,omitempty"`
}
GCReport summarizes one garbage collection pass.
type ListOptions ¶
ListOptions bounds provider-side listings so callers can enumerate namespaces without loading the full storage tree into memory.
type LocalProvider ¶
type LocalProvider struct {
// contains filtered or unexported fields
}
func NewLocalProvider ¶
func NewLocalProvider() (*LocalProvider, error)
func NewLocalProviderWithConfig ¶
func NewLocalProviderWithConfig(cfg Config) (*LocalProvider, error)
func (*LocalProvider) Delete ¶
func (p *LocalProvider) Delete(ctx context.Context, key string) error
func (*LocalProvider) List ¶
func (p *LocalProvider) List(ctx context.Context, options ListOptions) ([]ObjectInfo, error)
func (*LocalProvider) OpenReader ¶
func (p *LocalProvider) OpenReader(ctx context.Context, key string) (io.ReadCloser, ObjectInfo, error)
func (*LocalProvider) Stat ¶
func (p *LocalProvider) Stat(ctx context.Context, key string) (ObjectInfo, error)
type ObjectInfo ¶
type ObjectInfo struct {
Key string `json:"key"`
URL string `json:"url,omitempty"`
ContentType string `json:"content_type,omitempty"`
Size int64 `json:"size,omitempty"`
ModifiedAt time.Time `json:"modified_at,omitempty"`
ETag string `json:"etag,omitempty"`
}
ObjectInfo is the provider-level description of a stored object.
type ProviderType ¶
type ProviderType string
const ( ProviderLocal ProviderType = "local" ProviderS3 ProviderType = "s3" )
func GetProviderType ¶
func GetProviderType() ProviderType
type Reaper ¶
type Reaper struct {
// contains filtered or unexported fields
}
Reaper runs periodic storage GC for expiring artifact namespaces. It stays in internal/storage so hosts can reuse the same logic without duplicating timers or expiry policies across CLI, API, and SDK layers.
func NewReaper ¶
func NewReaper(store ArtifactStore, config ReaperConfig) *Reaper
type ReaperConfig ¶
type ReaperConfig struct {
Interval time.Duration
Namespaces []ArtifactNamespace
Limit int
}
ReaperConfig controls background garbage collection for expiring artifacts.
func DefaultReaperConfig ¶
func DefaultReaperConfig() ReaperConfig
type S3Provider ¶
type S3Provider struct {
// contains filtered or unexported fields
}
func NewS3Provider ¶
func NewS3Provider() (*S3Provider, error)
func NewS3ProviderWithConfig ¶
func NewS3ProviderWithConfig(cfg Config) (*S3Provider, error)
func (*S3Provider) List ¶
func (p *S3Provider) List(ctx context.Context, options ListOptions) ([]ObjectInfo, error)
func (*S3Provider) OpenReader ¶
func (p *S3Provider) OpenReader(ctx context.Context, key string) (io.ReadCloser, ObjectInfo, error)
func (*S3Provider) Stat ¶
func (p *S3Provider) Stat(ctx context.Context, key string) (ObjectInfo, error)
type StorageProvider ¶
type StorageProvider interface {
Upload(ctx context.Context, key string, data []byte, contentType string) error
Download(ctx context.Context, key string) ([]byte, error)
OpenReader(ctx context.Context, key string) (io.ReadCloser, ObjectInfo, error)
Stat(ctx context.Context, key string) (ObjectInfo, error)
List(ctx context.Context, options ListOptions) ([]ObjectInfo, error)
Delete(ctx context.Context, key string) error
GetURL(ctx context.Context, key string) (string, error)
Exists(ctx context.Context, key string) (bool, error)
}
func GetProvider ¶
func GetProvider() (StorageProvider, error)
func NewProviderFromConfig ¶
func NewProviderFromConfig(cfg Config) (StorageProvider, error)
NewProviderFromConfig creates a StorageProvider from an explicit Config without touching the process-wide singleton. Use this when you need per-instance storage.