names

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: BSD-3-Clause Imports: 8 Imported by: ? 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 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

View Source
const RefLen = 6

RefLen is how many leading characters of the session id form a [ref].

Variables

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

func IsMissing

func IsMissing(err error) bool

IsMissing reports whether err means the registry directory is absent.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index resolves session ids against one reading of the registry.

func NewIndex

func NewIndex(peers []Peer) *Index

NewIndex keeps the live peers: a name, and a socket that still exists. When a session has several entries the most recently updated wins.

func (*Index) Reach

func (ix *Index) Reach(sessionID string) Reach

Reach is how to address the session with this full id.

func (*Index) Sessions

func (ix *Index) Sessions() []string

Sessions lists the live session ids, sorted.

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.

func ParsePeer

func ParsePeer(b []byte) (Peer, bool)

ParsePeer decodes one registry file.

func ReadPeers

func ReadPeers(claudeDir string) (peers []Peer, skipped int, err error)

ReadPeers reads every registry entry under claudeDir. skipped counts files that could not be read or understood; err is set when the directory itself cannot be listed, which is NOT the same as "no sessions": the caller must report it. A missing directory is an error too.

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.

func Lookup

func Lookup(claudeDir, sessionID string) (Reach, error)

Lookup reads the registry under claudeDir and resolves one session id. It is the library entry point for other tools (agentsync).

func (Reach) String

func (r Reach) String() string

String is Reachable, or "(unresolved)".

Jump to

Keyboard shortcuts

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