Documentation
¶
Overview ¶
Package names answers one question: under what name can another session reach this session with SendMessage?
Claude Code keeps a registry of its live sessions in ~/.claude/sessions, one <pid>.json per process. Each file carries the sessionId, the display name the peer protocol uses ("name") with where it came from ("nameSource": auto, derived, ...), the unix socket other sessions write to ("messagingSocketPath") and busy/idle. Verified on this machine: the file 44569.json holds sessionId d7c789b4..., name "claimward", while the transcript's own title says "renew" -- the title is not the address.
A session with no registry file, or whose socket no longer exists, is UNRESOLVED. The package never invents a name from a title, a slug or a working directory.
Index ¶
Constants ¶
const RefLen = 6
RefLen is how many leading characters of the session id form a [ref].
Variables ¶
var SocketLive = func(p string) bool { fi, err := os.Stat(p) return err == nil && fi.Mode()&fs.ModeSocket != 0 }
SocketLive reports whether a registry socket still exists; tests replace it.
Functions ¶
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index resolves session ids against one reading of the registry.
func NewIndex ¶
NewIndex keeps the live peers: a name, and a socket that still exists. When a session has several entries the most recently updated wins.
type Peer ¶
type Peer struct {
PID int `json:"pid"`
SessionID string `json:"sessionId"`
Name string `json:"name"`
NameSource string `json:"nameSource"`
Socket string `json:"messagingSocketPath"`
Status string `json:"status"` // busy, idle, ...
UpdatedAt int64 `json:"updatedAt"`
}
Peer is one registry entry.
type Reach ¶
type Reach struct {
// Resolved is false when no live registry entry names the session.
Resolved bool `json:"resolved"`
// Name is the registry name, "" when unresolved.
Name string `json:"name,omitempty"`
// Ref disambiguates the name when two live sessions share it.
Ref string `json:"ref,omitempty"`
// Reachable is the exact string to put in SendMessage's `to`: Name, or
// "Name [Ref]" when the name is shared; "" when unresolved.
Reachable string `json:"reachable,omitempty"`
// Status is the peer's own busy/idle report.
Status string `json:"status,omitempty"`
}
Reach is how to address one session.