Documentation
¶
Overview ¶
Package store manages Aviary's file-based data directory.
Index ¶
- Constants
- func AgentDir(agentID string) string
- func AgentRulesPath(agentID string) string
- func AllJobDirs() []string
- func AllTaskCompileDirs() []string
- func AppendJSONL(path string, v any) error
- func BrowserMediaDir() string
- func CLIHomesDir() string
- func CheckpointDir(agentID string) string
- func CheckpointPath(agentID, checkpointID string) string
- func DataDir() string
- func DeleteAgentFile(agentID, file string) error
- func DeleteJSON(path string) error
- func DeletedSessionsPath() string
- func EnsureDirs() error
- func EnsureNewAgentTemplates(prev, next *config.Config) error
- func EnsureSessionChannel(agentID, sessionID, channelType, configuredID, channelID string) error
- func EnsureSessionChannelTarget(agentID, sessionID string, target SessionChannel) error
- func FindJobPath(id string) string
- func FindSessionPath(agentID, sessionID string) string
- func FindTaskCompilePath(id string) string
- func IncomingMediaDir(channelType string) string
- func InstanceID() (string, error)
- func JobPath(agentID, id string) string
- func ListAgentFiles(agentID string) ([]string, error)
- func ListJSON[T any](dir string, suffix string) ([]T, error)
- func MediaDir() string
- func NotesPath(_ string) string
- func OutgoingMediaDir(channelType string) string
- func PreferencesPath() string
- func ReadAgentFile(agentID, file string) (string, error)
- func ReadFile(path string) ([]byte, error)
- func ReadJSON[T any](path string) (T, error)
- func ReadJSONL[T any](path string) ([]T, error)
- func RenameAgentFile(agentID, from, to string) error
- func RenameMatchingAgentDirs(prev, next *config.Config) error
- func RewriteJSONL[T any](path string, entries []T) error
- func ScreenshotDir() string
- func SessionChannelsPath(agentID, sessionID string) string
- func SessionMetaPath(agentID, sessionID string) string
- func SessionPath(agentID, sessionID string) string
- func SetAuthDir(dir string)
- func SetDataDir(dir string)
- func SetSessionChannel(agentID, sessionID, channelType, configuredID, channelID string) error
- func SetSessionChannelTarget(agentID, sessionID string, target SessionChannel) error
- func SetWorkspaceDir(dir string)
- func StatePath() string
- func StripMarkdownCommentLines(content string) string
- func SubDir(name string) string
- func SyncAgentTemplate(agentID string) error
- func TaskCompilePath(agentID, id string) string
- func UpdateChannelMetadataState(prevCfg, nextCfg *config.Config, now time.Time) error
- func UpdateSessionMeta(path string, update func(*SessionMeta)) error
- func UsagePath() string
- func WorkspaceDir() string
- func WriteAgentFile(agentID, file, content string) error
- func WriteAppState(state *AppState) error
- func WriteJSON(path string, v any) error
- func WriteSessionChannels(cfg *SessionChannelsConfig) error
- type AppState
- type CLISessionMeta
- type ChannelMetadata
- type ConversationMeta
- type DisplayPreferences
- type NavPreferences
- type NotificationEvent
- type NotificationPreferences
- type NotificationQuietHours
- type NotificationRepeats
- type NotificationSound
- type Preferences
- type SessionChannel
- type SessionChannelsConfig
- type SessionMeta
Constants ¶
const ( DirAgents = "agents" // per-agent subdirectories DirCerts = "certs" DirAuth = "auth" DirMedia = "media" DirUsage = "usage" // DirProjects holds the Code Loop engine's work state and job transcripts. DirProjects = "projects" // Deprecated: legacy flat directories kept for backward-compat migration. DirJobs = "jobs" // deprecated: jobs now live under agents/<name>/jobs/ DirSessions = "sessions" // deprecated: sessions now live under agents/<name>/sessions/ )
Top-level directory name constants under DataDir().
Variables ¶
This section is empty.
Functions ¶
func AgentRulesPath ¶
AgentRulesPath returns the path for an agent's RULES.md file.
func AllJobDirs ¶
func AllJobDirs() []string
AllJobDirs returns all existing agents/<name>/jobs/ directory paths, plus the legacy jobs/ directory if it exists, for bulk job enumeration.
func AllTaskCompileDirs ¶
func AllTaskCompileDirs() []string
AllTaskCompileDirs returns all existing agents/<name>/task_compiles/ directory paths for bulk compile record enumeration.
func AppendJSONL ¶
AppendJSONL marshals v as a single JSON line and appends it to path. The file (and any parent directories) are created if they do not exist.
func BrowserMediaDir ¶
func BrowserMediaDir() string
BrowserMediaDir returns the directory where browser screenshots are saved. Browser artifacts are global resources (browser is not per-agent).
func CLIHomesDir ¶ added in v0.7.0
func CLIHomesDir() string
CLIHomesDir is where aviary keeps the settings overlays it launches agent CLIs with, so their bookkeeping writes never reach the user's own files.
func CheckpointDir ¶
CheckpointDir returns the directory where pending run checkpoints are stored for an agent: <datadir>/agents/<agentID>/checkpoints/.
func CheckpointPath ¶
CheckpointPath returns the path for a specific run checkpoint file: <datadir>/agents/<agentID>/checkpoints/<checkpointID>.json.
func DataDir ¶
func DataDir() string
DataDir returns the Aviary data directory. Resolution order: SetDataDir value > XDG_CONFIG_HOME > ~/.config/aviary.
func DeleteAgentFile ¶ added in v0.5.0
DeleteAgentFile deletes a file from an agent directory. Root-level protected files (AGENTS.md, MEMORY.md, RULES.md, SYSTEM.md) cannot be deleted.
func DeletedSessionsPath ¶ added in v0.7.85
func DeletedSessionsPath() string
DeletedSessionsPath returns the path to the log of deleted sessions' tombstones.
func EnsureNewAgentTemplates ¶
EnsureNewAgentTemplates syncs the embedded scaffold for agents that are present in next but absent from prev.
func EnsureSessionChannel ¶
EnsureSessionChannel adds channelType/configuredID/channelID to the session's channel config if it is not already present, then writes the file. It is a no-op when the channel target is already listed.
func EnsureSessionChannelTarget ¶ added in v0.6.1
func EnsureSessionChannelTarget(agentID, sessionID string, target SessionChannel) error
EnsureSessionChannelTarget adds target to the session's channel config if it is not already present, or updates the existing target when thread metadata changes.
func FindJobPath ¶
FindJobPath scans all known agent directories and returns the full path for the first job file matching id. Returns "" when not found.
func FindSessionPath ¶
FindSessionPath locates the .jsonl file for sessionID under the given agent. Returns "" when not found.
func FindTaskCompilePath ¶
FindTaskCompilePath scans all known agent directories and returns the full path for the first task compile record matching id. Returns "" when not found.
func IncomingMediaDir ¶
IncomingMediaDir returns the directory where inbound channel media is saved.
func InstanceID ¶ added in v0.7.0
InstanceID returns this Aviary instance's persisted ID, generating and saving an 8-character uppercase hex ID on first run.
func JobPath ¶
JobPath returns the path for a job file under the agent's jobs directory: <datadir>/agents/<agentID>/jobs/<id>.json.
func ListAgentFiles ¶ added in v0.5.0
ListAgentFiles returns all files under an agent directory, recursively including subdirectories. Returned paths are slash-delimited and relative to the agent dir.
func ListJSON ¶
ListJSON returns all values in dir whose file names match the given suffix. Typically called with suffix=".json".
func MediaDir ¶
func MediaDir() string
MediaDir returns the root directory for persisted media artifacts.
func NotesPath ¶
NotesPath returns the path for the human-editable markdown notes file in the current workspace directory.
func OutgoingMediaDir ¶
OutgoingMediaDir returns the directory where outbound channel media is saved.
func PreferencesPath ¶ added in v0.7.8
func PreferencesPath() string
PreferencesPath returns the on-disk location of the user's preferences.
func ReadAgentFile ¶ added in v0.5.0
ReadAgentFile reads a file from an agent directory. file must be a relative path beneath the agent directory.
func ReadFile ¶ added in v0.7.0
ReadFile reads the whole file at path. Unlike os.ReadFile, its handle never blocks WriteJSON from atomically renaming a new file over path: on Windows a reader that opens without delete sharing makes that rename fail, so a file polled while another goroutine or process saves it would intermittently refuse the save. WriteJSON's replaceFile does the other half.
func RenameAgentFile ¶ added in v0.7.0
RenameAgentFile moves a file within an agent directory, refusing to replace an existing file. Root-level protected files cannot be renamed, nor can a file be renamed to one of their names.
func RenameMatchingAgentDirs ¶
RenameMatchingAgentDirs renames on-disk agent directories for agents whose config changed only by name between prev and next. Ambiguous matches are ignored, and genuinely new agents are left for template sync.
func RewriteJSONL ¶
RewriteJSONL overwrites path with the given entries (used by compactor).
func ScreenshotDir ¶
func ScreenshotDir() string
ScreenshotDir returns the directory where browser screenshots are saved. Deprecated: use BrowserMediaDir.
func SessionChannelsPath ¶
SessionChannelsPath returns the path for the session's channel delivery config file: <datadir>/agents/<agentID>/sessions/<sessionID>.channels.json. It shares the same naming logic as SessionPath.
func SessionMetaPath ¶
SessionMetaPath returns the path for the sidecar metadata file for a session. It mirrors SessionPath but uses a .meta.json extension.
func SessionPath ¶
SessionPath returns the path for the given session file under the agent's sessions directory: <datadir>/agents/<agentID>/sessions/<sessionID>.jsonl.
func SetAuthDir ¶ added in v0.7.8
func SetAuthDir(dir string)
SetAuthDir makes SubDir(DirAuth) return dir instead of the auth directory under DataDir. `aviary watch` runs against a temporary data directory but reads and refreshes the user's own provider credentials in place, so it points this at the global auth directory rather than copying secrets. Pass an empty string to restore the default.
func SetDataDir ¶
func SetDataDir(dir string)
SetDataDir overrides the directory returned by DataDir. Pass an empty string to restore automatic resolution via XDG_CONFIG_HOME or ~/.config. This is intended for the --data-dir CLI flag and for tests.
func SetSessionChannel ¶
SetSessionChannel replaces the session's delivery config with a single target.
func SetSessionChannelTarget ¶ added in v0.6.1
func SetSessionChannelTarget(agentID, sessionID string, target SessionChannel) error
SetSessionChannelTarget replaces the session's delivery config with a single target.
func SetWorkspaceDir ¶
func SetWorkspaceDir(dir string)
SetWorkspaceDir overrides the directory returned by WorkspaceDir. Pass an empty string to restore automatic resolution via the process working directory. This is intended for tests and tools that need repo-local artifacts.
func StatePath ¶
func StatePath() string
StatePath returns the on-disk location for Aviary runtime metadata.
func StripMarkdownCommentLines ¶
StripMarkdownCommentLines removes HTML comment blocks from markdown when the content is being fed back into prompts or prompt-adjacent tools.
func SyncAgentTemplate ¶
SyncAgentTemplate merges the embedded agent scaffold into an agent directory. Files that do not yet exist are created. Existing files are never deleted or replaced wholesale; for markdown files, only the "Synced by Aviary" section is updated when present in both source and destination.
func TaskCompilePath ¶
TaskCompilePath returns the path for a task compile record under the agent's task_compiles directory: <datadir>/agents/<agentID>/task_compiles/<id>.json.
func UpdateChannelMetadataState ¶
UpdateChannelMetadataState updates per-channel lifecycle timestamps in state.json.
func UpdateSessionMeta ¶ added in v0.7.0
func UpdateSessionMeta(path string, update func(*SessionMeta)) error
UpdateSessionMeta applies update to the sidecar at path and writes it back atomically, serialized against every other update.
func WorkspaceDir ¶
func WorkspaceDir() string
WorkspaceDir returns the current workspace root. Resolution order: SetWorkspaceDir value > process working directory.
func WriteAgentFile ¶ added in v0.5.0
WriteAgentFile creates or replaces a file under an agent directory. file may be a relative path including subdirectories (e.g. notes/foo.txt).
func WriteAppState ¶
WriteAppState persists runtime metadata to disk.
func WriteJSON ¶
WriteJSON marshals v and atomically writes it to path. The write is atomic: data is written to a temp file then renamed. Parent directories are created if they do not exist.
func WriteSessionChannels ¶
func WriteSessionChannels(cfg *SessionChannelsConfig) error
WriteSessionChannels persists the channel delivery config for a session.
Types ¶
type AppState ¶
type AppState struct {
Channels map[string]ChannelMetadata `json:"channels,omitempty"`
// InstanceID names this Aviary instance. It is generated on first run and
// kept so the instance signs its Code Loop claims with the same identity
// across restarts.
InstanceID string `json:"instance_id,omitempty"`
}
AppState stores runtime metadata that should not live in aviary.yaml.
func ReadAppState ¶
ReadAppState loads runtime metadata from disk, returning an empty state if absent.
type CLISessionMeta ¶ added in v0.7.0
CLISessionMeta records the CLI-native session that a CLI-backed agent ("cli/..." model) resumes for an Aviary session.
type ChannelMetadata ¶
type ChannelMetadata struct {
EnabledAt time.Time `json:"enabled_at,omitempty"`
DisabledAt time.Time `json:"disabled_at,omitempty"`
}
ChannelMetadata stores lifecycle timestamps for a configured channel.
type ConversationMeta ¶
ConversationMeta holds the provider-native conversation ID for a session and when it was last used. Providers that support server-side history (e.g. the OpenAI Responses API) populate this so subsequent requests can pass only the new user turn instead of replaying the full message history.
type DisplayPreferences ¶ added in v0.7.25
type DisplayPreferences struct {
// Theme is "light", "dark" or "system" (following the OS).
Theme string `json:"theme,omitempty"`
// TextSize is "small", "default", "large" or "xlarge".
TextSize string `json:"textSize,omitempty"`
}
DisplayPreferences is the web UI's look (#1093): its color theme and text size. An empty field means the default, so options added later need no migration.
type NavPreferences ¶ added in v0.7.8
type NavPreferences struct {
}
NavPreferences is the web UI's customized navigation (#1003): per list of navigation items (agent pages, System pages, the top row), the user's order and the items they hid. Items the app adds later are not listed and take their default place.
type NotificationEvent ¶ added in v0.7.42
type NotificationEvent struct {
Enabled bool `json:"enabled"`
// Delivery is "big" (a banner across the top), "small" (a corner toast)
// or "system" (a system notification, or a toast without permission).
Delivery string `json:"delivery"`
// Sound is the event's own sound, "" for the default one, or "none".
Sound string `json:"sound,omitempty"`
}
NotificationEvent configures one event type.
type NotificationPreferences ¶ added in v0.7.42
type NotificationPreferences struct {
// Enabled is the master switch: off, nothing is delivered anywhere.
Enabled bool `json:"enabled"`
// System shows browser or installed-app notifications, once the browser
// grants permission; InApp shows banners and toasts in the web UI.
System bool `json:"system"`
InApp bool `json:"inApp"`
// Server has a macOS server show a Notification Center notification
// itself when no browser is connected.
Server bool `json:"server"`
Sound NotificationSound `json:"sound"`
QuietHours NotificationQuietHours `json:"quietHours"`
// Repeats controls repeating failures (#1419); nil means the defaults.
Repeats *NotificationRepeats `json:"repeats,omitempty"`
Events map[string]NotificationEvent `json:"events"`
}
NotificationPreferences controls the notification system (#1215): the master switch, each delivery method, sound, quiet hours, and each event type. Nil in Preferences means DefaultNotificationPreferences.
type NotificationQuietHours ¶ added in v0.7.42
type NotificationQuietHours struct {
Enabled bool `json:"enabled"`
Start string `json:"start"`
End string `json:"end"`
}
NotificationQuietHours holds back live delivery between Start and End, "HH:MM" in the server's local time; notifications still reach the bell.
type NotificationRepeats ¶ added in v0.7.75
type NotificationRepeats struct {
// Suppress merges repeats of the same failure into its entry, raising its
// count, and delivers only the first, for WindowMinutes after the last
// repeat.
Suppress bool `json:"suppress"`
WindowMinutes int `json:"windowMinutes"`
// Streak sends one notification once a source has failed StreakCount
// times in a row.
Streak bool `json:"streak"`
StreakCount int `json:"streakCount"`
}
NotificationRepeats controls how repeating failures of one source, such as a scheduled task that fails every run, notify.
type NotificationSound ¶ added in v0.7.42
type NotificationSound struct {
Enabled bool `json:"enabled"`
// Type is the default sound, one of the web UI's bundled sounds.
Type string `json:"type"`
// Volume is 0 to 100.
Volume int `json:"volume"`
}
NotificationSound is how notifications sound. Sound is off by default.
type Preferences ¶ added in v0.7.8
type Preferences struct {
Display DisplayPreferences `json:"display"`
Notifications *NotificationPreferences `json:"notifications,omitempty"`
}
Preferences holds the user's web UI preferences, kept on the server so they follow the user across browsers and devices.
func ReadPreferences ¶ added in v0.7.8
func ReadPreferences() (*Preferences, error)
ReadPreferences loads the user's preferences, returning empty ones if absent.
func UpdatePreferences ¶ added in v0.7.8
func UpdatePreferences(fn func(*Preferences)) (*Preferences, error)
UpdatePreferences applies fn to the stored preferences and saves the result.
type SessionChannel ¶
type SessionChannel struct {
Type string `json:"type"` // e.g. "signal", "slack"
ConfiguredID string `json:"configured_id,omitempty"` // configured channel instance ID from agent config
ID string `json:"id"` // channel/conversation target ID (phone number, Slack channel ID, etc.)
ThreadTS string `json:"thread_ts,omitempty"` // optional platform thread/root timestamp for threaded delivery
}
SessionChannel represents a delivery target for a session's responses.
type SessionChannelsConfig ¶
type SessionChannelsConfig struct {
SessionID string `json:"session_id"`
AgentID string `json:"agent_id"`
Channels []SessionChannel `json:"channels"`
}
SessionChannelsConfig is the content of a session's .channels.json sidecar file. It records which channels should receive outgoing responses for that session.
func FindAllSessionChannelsConfigs ¶
func FindAllSessionChannelsConfigs() ([]*SessionChannelsConfig, error)
FindAllSessionChannelsConfigs scans every agent's sessions directory and returns all existing session channel configs.
func ReadSessionChannels ¶
func ReadSessionChannels(agentID, sessionID string) (*SessionChannelsConfig, error)
ReadSessionChannels reads the channel delivery config for a session. Returns an empty config (not an error) when the file does not exist yet.
type SessionMeta ¶
type SessionMeta struct {
// Title is the session's display name: generated from its first prompt or
// set by a rename. The session's own name stays its lookup key.
Title string `json:"title,omitempty"`
Conversation *ConversationMeta `json:"conversation,omitempty"`
CLI *CLISessionMeta `json:"cli,omitempty"`
// LastMessageAt is when the session's last user or assistant message was
// persisted, recorded as each one is appended.
LastMessageAt *time.Time `json:"last_message_at,omitempty"`
}
SessionMeta is the sidecar metadata stored alongside a session JSONL file.
func ReadSessionMeta ¶
func ReadSessionMeta(path string) (SessionMeta, error)
ReadSessionMeta loads the sidecar metadata for a session. Returns a zero SessionMeta (not an error) when the file does not exist.