session

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LockFileName = "session.lock"

LockFileName is the name of the lock file within a session directory

View Source
const SessionFileName = "session.json"

SessionFileName is the name of the session data file within a session directory

View Source
const SessionsDir = "sessions"

SessionsDir is the directory name within .claudio that contains all sessions

Variables

View Source
var ErrSessionLocked = errors.New("session is locked by another process")

ErrSessionLocked is returned when attempting to acquire a lock on an already-locked session

Functions

func CleanStaleLock

func CleanStaleLock(sessionDir string) (bool, error)

CleanStaleLock removes a stale lock file if the owning process is no longer running. Returns true if a stale lock was cleaned.

func CleanupStaleLocks

func CleanupStaleLocks(baseDir string) ([]string, error)

CleanupStaleLocks iterates through all sessions and removes stale lock files. Returns the IDs of sessions that had stale locks cleaned.

func GetSessionDir

func GetSessionDir(baseDir, sessionID string) string

GetSessionDir returns the path to a specific session's directory

func GetSessionsDir

func GetSessionsDir(baseDir string) string

GetSessionsDir returns the path to the sessions directory for a given base directory

func SessionExists

func SessionExists(baseDir, sessionID string) bool

SessionExists checks if a session with the given ID exists.

Types

type Info

type Info struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Created       time.Time `json:"created"`
	InstanceCount int       `json:"instance_count"`
	IsLocked      bool      `json:"is_locked"`
	LockInfo      *Lock     `json:"lock_info,omitempty"`
	SessionDir    string    `json:"session_dir"`
}

Info contains summary information about a session

func FindUnlockedSessions

func FindUnlockedSessions(baseDir string) ([]*Info, error)

FindUnlockedSessions returns all sessions that are not currently locked.

func GetSessionInfo

func GetSessionInfo(baseDir, sessionID string) (*Info, error)

GetSessionInfo returns detailed information about a specific session.

func ListSessions

func ListSessions(baseDir string) ([]*Info, error)

ListSessions returns information about all sessions in the base directory. Sessions are discovered by scanning .claudio/sessions/ for subdirectories containing session.json files.

type Lock

type Lock struct {
	SessionID string    `json:"session_id"`
	PID       int       `json:"pid"`
	Hostname  string    `json:"hostname"`
	StartedAt time.Time `json:"started_at"`
	// contains filtered or unexported fields
}

Lock represents an acquired session lock

func AcquireLock

func AcquireLock(sessionDir, sessionID string) (*Lock, error)

AcquireLock attempts to acquire an exclusive lock on the session directory. Returns ErrSessionLocked if the session is already in use by another process.

func IsLocked

func IsLocked(sessionDir string) (*Lock, bool)

IsLocked checks if a session directory is currently locked. Returns the lock info if locked, nil otherwise.

func ReadLock

func ReadLock(lockPath string) (*Lock, error)

ReadLock reads a lock file and returns the Lock info.

func (*Lock) Release

func (l *Lock) Release() error

Release releases the session lock by removing the lock file. Safe to call multiple times.

type SessionData

type SessionData struct {
	ID        string          `json:"id"`
	Name      string          `json:"name"`
	Created   time.Time       `json:"created"`
	Instances json.RawMessage `json:"instances"` // Keep raw to count without full parsing
}

SessionData represents the minimal session structure needed for discovery. This mirrors the Session struct from orchestrator but only includes the fields we need for listing.

Jump to

Keyboard shortcuts

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