This repository has been archived on 2026-05-07. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
ccrm/daemon/internal/session/session.go

48 lines
1.6 KiB
Go

package session
import (
"time"
"github.com/fmartingr/ccrm/daemon/internal/claude"
)
// Status represents the state of a session.
type Status string
const (
StatusStarting Status = "starting"
StatusActive Status = "active"
StatusIdle Status = "idle"
StatusWaitingPermission Status = "waiting_permission"
StatusStopped Status = "stopped"
)
// Mode represents how a session is currently being operated.
type Mode string
const (
ModeSubprocess Mode = "subprocess" // daemon-controlled via subprocess protocol
ModeInteractive Mode = "interactive" // user-attached via tmux
)
// Session tracks a Claude Code session.
type Session struct {
Name string `json:"name"`
TmuxSession string `json:"tmux_session"` // always set to real tmux session name
ProjectPath string `json:"project_path"`
ClaudeSessionID string `json:"claude_session_id"`
TranscriptPath string `json:"transcript_path"`
LogPath string `json:"log_path"` // path to session JSONL log
Status Status `json:"status"`
Mode Mode `json:"mode"`
IsWorktree bool `json:"is_worktree"`
WorktreeBranch string `json:"worktree_branch"`
CreatedAt time.Time `json:"created_at"`
LastEventAt time.Time `json:"last_event_at"`
PendingPrompts []string `json:"-"`
ClaudeArgs []string `json:"-"` // original claude args for respawning
ExplicitStop bool `json:"-"` // true when user called Stop/Kill
// Subprocess mode only — not serialized
Process *claude.Process `json:"-"`
}