Documentation
¶
Overview ¶
Package live decides what is running: Claude Code's live-session registry, the state word a hook left, and how long a session's transcript has been quiet. The rules are the bash ones (live_ids, deadp, tquiet and stext in bin/sitrep).
Index ¶
- Constants
- func Age(secs int64) string
- func Blocked(s state.Store, configDir, id, word string, now int64) (kind string, at int64, ok bool)
- func Changed(s state.Store, id string) (int64, bool)
- func Dead(set Set, id, word string, changed, now int64) bool
- func IsIdle(word string, quiet int64, hasQuiet bool) bool
- func Label(word string, changed, now int64, quiet int64, hasQuiet bool) string
- func LocalDomain() string
- func Quiet(configDir, id string, now int64) (int64, bool)
- func Word(s state.Store, id string) string
- type Entry
- type Registry
- type Set
Constants ¶
const (
BlockPermission = "permission"
)
Block kinds a hook records.
const BlockedSlack = 3
BlockedSlack is how long after a block the transcript may still be written, in seconds: Claude Code writes it once, 0.3 s after a dialog opens.
const Grace = 120
Grace is how long a session that is not in the registry may stay quiet before it counts as over: the registry lags a start and a /clear.
const IdleAfter = 600
IdleAfter is how long a working session's transcript may stay quiet before the session is shown as idle?.
Variables ¶
This section is empty.
Functions ¶
func Blocked ¶ added in v1.0.0
Blocked says whether a session is stopped at a dialog, and since when (seconds since the epoch). The permission hook wrote the file `blocked`; the block counts only while the session is working and its transcript has not been written since, so that an answered dialog and a crash leave nothing behind once the next transcript line is written, which for a long tool is when it finishes. A session without a readable transcript keeps the block until the file is removed.
func Changed ¶
Changed is when a session's state last changed, in seconds since the epoch: the state file's time, else the notes file's.
func Dead ¶
Dead says whether a session is over. With a readable registry a live process settles it; otherwise the session is over once it said so, or after two quiet minutes. Without a registry only its own word counts.
func IsIdle ¶ added in v1.1.0
IsIdle says whether a working session's transcript has been quiet long enough for it to be shown as idle?.
func Label ¶
Label is the state column: "waiting 3m". A working session whose transcript has been quiet for ten minutes is "idle? 12m".
func LocalDomain ¶
func LocalDomain() string
LocalDomain is how Claude Code names this machine's pid space.
Types ¶
type Entry ¶
Entry is one live session. PID is 0 when the process is in another pid space and cannot be judged here.
type Registry ¶
type Registry struct {
Dir string // the sessions folder
Run runner.Runner // for ps
Alive func(pid int) bool
Domain string // how Claude Code names this machine's pid space; empty when it cannot be worked out
}
Registry reads ~/.claude/sessions/<pid>.json. Its files are untrusted input, so everything used is checked.
func NewRegistry ¶
NewRegistry is the registry of a Claude config folder, with the real process checks.