live

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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 Age

func Age(secs int64) string

Age writes seconds as <1m, 5m, 3h or 2d.

func Changed

func Changed(s state.Store, id string) (int64, bool)

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

func Dead(set Set, id, word string, changed, now int64) bool

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 Label

func Label(word string, changed, now int64, quiet int64, hasQuiet bool) string

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.

func Quiet

func Quiet(configDir, id string, now int64) (int64, bool)

Quiet is how many seconds the session's transcript has been unchanged (the shortest, if there are several). An interrupt fires no Stop hook, but the transcript still shows life.

func Word

func Word(s state.Store, id string) string

Word is a session's state word from the file a hook wrote, from an allow-list (the file is untrusted input), else "-".

Types

type Entry

type Entry struct {
	ID  state.ID
	PID int
}

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

func NewRegistry(configDir string, run runner.Runner) Registry

NewRegistry is the registry of a Claude config folder, with the real process checks.

func (Registry) Read

func (r Registry) Read(ctx context.Context) Set

Read lists the live sessions. OK is false when the registry holds no file, or no live session.

type Set

type Set struct {
	Entries []Entry
	OK      bool
}

Set is what the registry says is live. OK is false when nothing live could be read, which means the registry cannot be trusted either way.

func (Set) Has

func (s Set) Has(id string) bool

Has says whether a live process has this session id.

func (Set) PID

func (s Set) PID(id string) (int, bool)

PID is the first live process of a session, when it runs on this machine.

Jump to

Keyboard shortcuts

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