Help us shape the future of Go! Take the 2026 Go Developer Survey

agentstorage

package
v0.0.77 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatRelativeAge added in v0.0.57

func FormatRelativeAge(now, t time.Time) string

FormatRelativeAge formats the age of t relative to now for human session lists. Zero t → "-"; age < 1s (after clamping future to 0) → "just now"; otherwise short units (s/m/h/d), max 2 non-zero units, zero stops chain, " ago".

Types

type Config

type Config struct {
	DefaultAgentRunner string `json:"default_agent_runner"`
	DefaultModel       string `json:"default_model"`
	LastSession        string `json:"last_session"`
	// SelectedWorkspace is the active workspace path for status + new sessions.
	SelectedWorkspace string `json:"selected_workspace,omitempty"`
	// RecentWorkspaces is an MRU list of workspace paths (newest first, max ~12).
	RecentWorkspaces []string `json:"recent_workspaces,omitempty"`
}

Config persisted at config.json under the store home.

type Message

type Message struct {
	ID        string `json:"id"`
	Text      string `json:"text"`
	SessionID string `json:"session_id"`
	CreatedAt string `json:"created_at"`
}

Message is a queued user follow-up in messages.jsonl.

type Session

type Session struct {
	Meta SessionMeta
}

Session wraps session metadata for API consumers.

type SessionMeta

type SessionMeta struct {
	Runner            string `json:"runner"`
	SessionID         string `json:"session_id"`
	InitialPrompt     string `json:"initial_prompt,omitempty"`
	RunnerSessionID   string `json:"runner_session_id,omitempty"`
	TerminalSessionID string `json:"terminal_session_id,omitempty"`
	Status            string `json:"status"`
	Workspace         string `json:"workspace,omitempty"`
	Model             string `json:"model,omitempty"`
	// PrependPaths are absolute directories prepended to the TTY child PATH (ordered, no dedup).
	PrependPaths []string `json:"prepend_paths,omitempty"`
	// Env is ordered KEY=VALUE entries applied to the TTY child (last-win per key).
	Env []string `json:"env,omitempty"`
	// AgentRunnerConfigHome is the agent data dir (grok: GROK_HOME, codex: CODEX_HOME).
	AgentRunnerConfigHome string `json:"agent_runner_config_home,omitempty"`
	CreatedAt             string `json:"created_at,omitempty"`
	UpdatedAt             string `json:"updated_at,omitempty"`
}

SessionMeta is stored in sessions/<session_id>/meta.json.

func (*SessionMeta) UnmarshalJSON added in v0.0.43

func (m *SessionMeta) UnmarshalJSON(data []byte) error

type Store

type Store interface {
	Home() string
	Config() (Config, error)
	SaveConfig(Config) error
	ListSessions() ([]SessionMeta, error)
	ClearAllSessions() error
	GetSession(sessionID string) (*Session, error)
	CreateSession(sessionID string, meta SessionMeta) error
	UpdateSessionStatus(sessionID, status string) error
	UpdateSessionRunnerSessionID(sessionID, runnerSessionID string) error
	UpdateSessionTerminalSessionID(sessionID, terminalSessionID string) error
	// UpdateSessionWorkspace sets meta.workspace (e.g. after Grok session relocate).
	UpdateSessionWorkspace(sessionID, workspace string) error
	// UpdateSessionEnvConfig writes session-scoped TTY child env fields.
	// prependPaths/env replace the stored lists; configHome replaces when non-empty.
	UpdateSessionEnvConfig(sessionID string, prependPaths, env []string, configHome string) error
	AppendEvent(sessionID string, ev types.AgentEvent) error
	ReadEvents(sessionID string, afterOffset int64) ([]types.AgentEvent, int64, error)
	AppendMessage(sessionID, text string) (Message, error)
	PopMessages(sessionID string) ([]Message, error)
	ListMessages(sessionID string) ([]Message, error)
}

Store is the durable agent-run storage contract. Session identity is bare sessionID; runner is metadata on SessionMeta only.

func NewFileStore

func NewFileStore(home string) (Store, error)

NewFileStore opens the default file-backed store. AGENT_RUN_HOME overrides home.

Jump to

Keyboard shortcuts

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