Versions in this module Expand all Collapse all v0 v0.4.10 Jul 30, 2026 Changes in this version + const CurrentVersion + const EnvAgentDir + const EnvSessionDir + var ErrHarnessStorageReplacement = errors.New("session: harness-backed session replacement requires a SessionRepo") + func AssertValidSessionID(id string) error + func DefaultSessionDir(cwd, agentDir string) (string, error) + func DefaultSessionDirPath(cwd, agentDir string) (string, error) + func FindMostRecentSession(sessionDir, cwd string) string + func MarshalJSONL(entries []*FileEntry) ([]byte, error) + func MigrateSessionEntries(entries []*FileEntry, generators ...IDGenerator) (bool, error) + type AggregateStats struct + CacheReadTokens int64 + CacheWriteTokens int64 + Cost float64 + HasLatestCacheHitRate bool + InputTokens int64 + LatestCacheHitRate float64 + OutputTokens int64 + type Clock func() time.Time + type CompactionResult struct + Details any + EstimatedTokensAfter int64 + FirstKeptEntryID string + Summary string + TokensBefore int64 + Usage *ai.Usage + type FileEntry struct + Entry *SessionEntry + Header *SessionHeader + Type string + func LoadEntriesFromFile(path string) ([]*FileEntry, error) + func ParseSessionEntries(content string) []*FileEntry + func (entry *FileEntry) MarshalJSON() ([]byte, error) + func (entry *FileEntry) Raw() ([]byte, error) + type IDGenerator func() (string, error) + type NewSessionOptions struct + ID *string + ParentSession *string + type Option func(*managerOptions) + func WithAgentDir(path string) Option + func WithClock(clock Clock) Option + func WithCwdOverride(path string) Option + func WithEntryIDGenerator(generator IDGenerator) Option + func WithHarnessRepo(repo harness.SessionRepo) Option + func WithParentSession(path string) Option + func WithSessionID(id string) Option + func WithSessionIDGenerator(generator SessionIDGenerator) Option + type OptionalEntryFields struct + Details any + FromHook *bool + HasDetails bool + Usage *ai.Usage + type SessionContext struct + ActiveToolNames []string + Messages []json.RawMessage + Model *SessionModel + ThinkingLevel string + func BuildSessionContext(entries []SessionEntry, leafID *string) SessionContext + type SessionEntry struct + ActiveToolNames []string + Content json.RawMessage + CustomType string + Data json.RawMessage + Details json.RawMessage + Display bool + FirstKeptEntryID string + FromHook *bool + FromID string + ID string + Label *string + LeafTargetID *string + Message json.RawMessage + ModelID string + Name string + ParentID *string + Provider string + Summary string + TargetID string + ThinkingLevel string + Timestamp string + TokensBefore float64 + Type string + Usage *ai.Usage + func BuildContextEntries(entries []SessionEntry, leafID *string) []SessionEntry + func GetLatestCompactionEntry(entries []SessionEntry) *SessionEntry + func (entry SessionEntry) MarshalJSON() ([]byte, error) + func (entry SessionEntry) MarshalJSONWithParent(parentID *string) ([]byte, error) + type SessionHeader struct + CWD string + ID string + Metadata json.RawMessage + ParentSession *string + Timestamp string + Type string + Version *int + func (header SessionHeader) MarshalJSON() ([]byte, error) + type SessionIDGenerator func(time.Time) (string, error) + type SessionInfo struct + AllMessagesText string + CWD string + Created time.Time + FirstMessage string + ID string + MessageCount int + Modified time.Time + Name *string + ParentSessionPath *string + Path string + func List(cwd, sessionDir string, onProgress SessionListProgress, options ...Option) []SessionInfo + func ListAll(sessionDir string, onProgress SessionListProgress, options ...Option) []SessionInfo + type SessionListProgress func(loaded, total int) + type SessionManager struct + func ContinueRecent(cwd, sessionDir string, options ...Option) (*SessionManager, error) + func Create(cwd, sessionDir string, options ...Option) (*SessionManager, error) + func ForkFrom(sourcePath, targetCWD, sessionDir string, options ...Option) (*SessionManager, error) + func FromHarnessStorage(storage harness.SessionStorage, options ...Option) (*SessionManager, error) + func InMemory(cwd string, options ...Option) (*SessionManager, error) + func Open(path, sessionDir string, options ...Option) (*SessionManager, error) + func (manager *SessionManager) AggregateStats() (AggregateStats, uint64) + func (manager *SessionManager) AppendActiveToolsChange(activeToolNames []string) (string, error) + func (manager *SessionManager) AppendCompaction(summary string, firstKeptEntryID string, tokensBefore int64, ...) (string, error) + func (manager *SessionManager) AppendCustomEntry(customType string, data ...any) (string, error) + func (manager *SessionManager) AppendCustomMessageEntry(customType string, content any, display bool, details ...any) (string, error) + func (manager *SessionManager) AppendLabelChange(targetID string, label *string) (string, error) + func (manager *SessionManager) AppendMessage(message any) (string, error) + func (manager *SessionManager) AppendModelChange(provider, modelID string) (string, error) + func (manager *SessionManager) AppendSessionInfo(name string) (string, error) + func (manager *SessionManager) AppendThinkingLevelChange(level string) (string, error) + func (manager *SessionManager) Branch(id string) error + func (manager *SessionManager) BranchWithSummary(branchFromID *string, summary string, options ...OptionalEntryFields) (string, error) + func (manager *SessionManager) BuildContextEntries() []SessionEntry + func (manager *SessionManager) BuildSessionContext() SessionContext + func (manager *SessionManager) CreateBranchedSession(leafID string) (string, error) + func (manager *SessionManager) GetBranch(fromID ...string) []SessionEntry + func (manager *SessionManager) GetCWD() string + func (manager *SessionManager) GetChildren(parentID string) []SessionEntry + func (manager *SessionManager) GetCwd() string + func (manager *SessionManager) GetEntries() []SessionEntry + func (manager *SessionManager) GetEntry(id string) *SessionEntry + func (manager *SessionManager) GetHeader() *SessionHeader + func (manager *SessionManager) GetLabel(id string) *string + func (manager *SessionManager) GetLatestCompactionTimestamp() (string, bool) + func (manager *SessionManager) GetLeafEntry() *SessionEntry + func (manager *SessionManager) GetLeafID() *string + func (manager *SessionManager) GetSessionDir() string + func (manager *SessionManager) GetSessionFile() string + func (manager *SessionManager) GetSessionID() string + func (manager *SessionManager) GetSessionName() *string + func (manager *SessionManager) GetTree() []*SessionTreeNode + func (manager *SessionManager) HarnessMetadata() (harness.SessionMetadata, bool) + func (manager *SessionManager) HarnessRepo() harness.SessionRepo + func (manager *SessionManager) IsHarnessBacked() bool + func (manager *SessionManager) IsPersisted() bool + func (manager *SessionManager) JSONL() ([]byte, error) + func (manager *SessionManager) NewSession(options ...NewSessionOptions) (string, error) + func (manager *SessionManager) ResetLeaf() + func (manager *SessionManager) SetSessionFile(path string) error + func (manager *SessionManager) UsesDefaultSessionDir() bool + type SessionModel struct + ModelID string + Provider string + type SessionTreeNode struct + Children []*SessionTreeNode + Entry SessionEntry + Label *string + LabelTimestamp *string