session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package session provides shared session management for agent runners. Sessions track the state of agent runs (Claude Code, Codex, etc.) and persist metadata to disk for later retrieval.

Index

Constants

View Source
const (
	StateRunning   = "running"
	StateStopped   = "stopped"
	StateCompleted = "completed"
)

State constants for session lifecycle.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles session persistence and lookup.

func NewManager

func NewManager(dir string) *Manager

NewManager creates a session manager for the given directory.

func (*Manager) CleanupOldSessions

func (m *Manager) CleanupOldSessions(maxAge time.Duration) error

CleanupOldSessions removes sessions older than the given duration.

func (*Manager) Create

func (m *Manager) Create(workspace, runID, name string, grants []string) (*Session, error)

Create creates a new session.

func (*Manager) Delete

func (m *Manager) Delete(id string) error

Delete removes a session.

func (*Manager) Dir

func (m *Manager) Dir() string

Dir returns the session storage directory.

func (*Manager) Get

func (m *Manager) Get(idOrName string) (*Session, error)

Get retrieves a session by ID or name.

func (*Manager) GetByWorkspace

func (m *Manager) GetByWorkspace(workspace string) (*Session, error)

GetByWorkspace returns the most recent session for a workspace.

func (*Manager) List

func (m *Manager) List() ([]*Session, error)

List returns all sessions, sorted by last accessed time (most recent first).

func (*Manager) Touch

func (m *Manager) Touch(id string) error

Touch updates the last accessed time of a session.

func (*Manager) UpdateState

func (m *Manager) UpdateState(id, state string) error

UpdateState updates the state of a session.

type Session

type Session struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	Workspace      string    `json:"workspace"`
	RunID          string    `json:"runId"`
	Grants         []string  `json:"grants"`
	CreatedAt      time.Time `json:"createdAt"`
	LastAccessedAt time.Time `json:"lastAccessedAt"`
	State          string    `json:"state"` // "running", "stopped", "completed"
}

Session represents an agent session (Claude Code, Codex, etc.).

Jump to

Keyboard shortcuts

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