Documentation
¶
Overview ¶
Package persistence provides persistence interfaces and common errors.
Package persistence provides abstract persistence layer for Runtime components.
This package implements the Repository Pattern to decouple Runtime from storage implementations. It provides interfaces for loading prompts, tools, and fragments from various backends (YAML files, JSON files, memory, packs, etc.).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilConfig is returned when a nil config is passed to SavePrompt. ErrNilConfig = errors.New("config cannot be nil") // ErrNilDescriptor is returned when a nil descriptor is passed to SaveTool. ErrNilDescriptor = errors.New("descriptor cannot be nil") // ErrEmptyTaskType is returned when a config has an empty task_type. ErrEmptyTaskType = errors.New("task_type cannot be empty") // ErrEmptyToolName is returned when a tool descriptor has an empty name. ErrEmptyToolName = errors.New("tool name cannot be empty") // ErrPromptNotFound is returned when a requested prompt is not found. ErrPromptNotFound = errors.New("prompt not found") // ErrToolNotFound is returned when a requested tool is not found. ErrToolNotFound = errors.New("tool not found") // ErrFragmentPathUnsupported is returned by LoadFragment from a repository // that cannot load a fragment by path, such as the in-memory one, which // holds fragments by name only. It does not satisfy fs.ErrNotExist: the // fragment may exist, and the repository cannot tell, so FragmentResolver // reports it rather than looking for the path elsewhere. ErrFragmentPathUnsupported = errors.New("this repository cannot load a fragment by path") // ErrFragmentPathOutsideBase is returned by LoadFragment for a relative // fragment path that resolves outside the repository's base directory. It // does not satisfy fs.ErrNotExist, so FragmentResolver does not look for // the path elsewhere. A lookup with no base dir (the resolver's // working-directory fallback) that leaves the working directory also // satisfies fs.ErrNotExist. An absolute path written in the config is not // affected. ErrFragmentPathOutsideBase = errors.New("fragment path resolves outside the repository's base directory") )
Sentinel errors for persistence operations.
Functions ¶
This section is empty.
Types ¶
type PromptRepository ¶
type PromptRepository interface {
// LoadPrompt loads a prompt configuration by task type
LoadPrompt(taskType string) (*prompt.Config, error)
// LoadFragment loads a fragment by name and optional path
LoadFragment(name, relativePath, baseDir string) (*prompt.Fragment, error)
// ListPrompts returns all available prompt task types
ListPrompts() ([]string, error)
// SavePrompt saves a prompt configuration (for future write support)
SavePrompt(config *prompt.Config) error
}
PromptRepository provides abstract access to prompt configurations
type ToolRepository ¶
type ToolRepository interface {
// LoadTool loads a tool descriptor by name
LoadTool(name string) (*tools.ToolDescriptor, error)
// ListTools returns all available tool names
ListTools() ([]string, error)
// SaveTool saves a tool descriptor (for future write support)
SaveTool(descriptor *tools.ToolDescriptor) error
}
ToolRepository provides abstract access to tool descriptors
Directories
¶
| Path | Synopsis |
|---|---|
|
Package common provides shared functionality for persistence repositories.
|
Package common provides shared functionality for persistence repositories. |
|
Package json provides JSON file-based implementations of persistence repositories.
|
Package json provides JSON file-based implementations of persistence repositories. |
|
Package memory provides in-memory implementations of persistence repositories.
|
Package memory provides in-memory implementations of persistence repositories. |
|
Package repotest is a contract suite for prompt.FragmentRepository implementations.
|
Package repotest is a contract suite for prompt.FragmentRepository implementations. |
|
Package yaml provides YAML file-based implementations of persistence repositories.
|
Package yaml provides YAML file-based implementations of persistence repositories. |