Documentation
¶
Overview ¶
Package inventory scans machines for Claude Code sessions and joins each session with its live status and git state. It is shared by the CLI, TUI and GUI.
Index ¶
- Constants
- Variables
- func ClaudeSupports(ctx context.Context, claude, flag string) bool
- func HelperBinary(explicit string, f *transport.Facts) (string, error)
- func HelperPath(f *transport.Facts) string
- func InstallHelper(ctx context.Context, conn *transport.Conn, f *transport.Facts, bin string) (string, error)
- func LocalClaude(ctx context.Context) (path, version string)
- func LocalFacts(ctx context.Context) *transport.Facts
- func LocalHostName() string
- func LocalTarget(ctx context.Context) engine.Target
- func NewestOf(ms []*Machine, ss []*Session) int
- func RemoveHelper(ctx context.Context, conn *transport.Conn, f *transport.Facts) error
- type Copy
- type Group
- type GroupedEntry
- type KeyLogin
- type Machine
- type Scanner
- type Session
Constants ¶
const ( StatusOK = "ok" StatusLocal = "local" StatusUnreachable = "unreachable" StatusAuth = "auth" StatusHostKey = "host-key" StatusKeyChanged = "host-key-changed" StatusTSCheck = "tailscale-check" StatusLocalNet = "local-network" // macOS local network privacy blocked it StatusNoClaude = "no-claude" StatusError = "error" )
Status of a machine scan.
const AgentSchema = "hopsesh.agent/v1"
AgentSchema is the agent output format this build understands.
const HelperRel = ".local/share/hopsesh/bin/hopsesh"
HelperRel is where the helper lives, relative to the remote home directory.
Variables ¶
var ErrHelperMismatch = errors.New("the helper on that machine does not match the one hopsesh installed (not run)")
ErrHelperMismatch means the helper on the machine is not the one hopsesh uploaded.
var ErrNoLocalKey = errors.New("this machine has no SSH key that ssh would use for it")
ErrNoLocalKey means this machine has no SSH key that ssh would offer to the machine; SetupKeyLogin can create one (createKey).
Functions ¶
func ClaudeSupports ¶
ClaudeSupports reports whether this machine's claude lists a command-line flag in its help (feature detection, rather than guessing from version numbers).
func HelperBinary ¶
HelperBinary picks the local hopsesh binary to upload: explicit, or this program when it can run there (same OS and architecture, or a universal macOS build to a Mac).
func HelperPath ¶
HelperPath is the helper's absolute path on a machine.
func InstallHelper ¶
func InstallHelper(ctx context.Context, conn *transport.Conn, f *transport.Facts, bin string) (string, error)
InstallHelper uploads bin to the machine, checks it runs and matches, and returns its SHA-256 for the config.
func LocalClaude ¶
LocalClaude finds the claude binary and its version on this machine.
func LocalFacts ¶
LocalFacts describes this machine.
func LocalTarget ¶
LocalTarget describes this machine as the destination of a move.
Types ¶
type Copy ¶ added in v0.2.0
type Copy struct {
Machine string `json:"machine"`
Local bool `json:"local,omitempty"`
LastActive time.Time `json:"lastActive"`
MovedTo string `json:"movedTo,omitempty"`
Live bool `json:"live,omitempty"`
Newest bool `json:"newest,omitempty"`
}
Copy is one machine's copy of a session that exists on several machines.
type Group ¶
type Group struct {
Identity string `json:"identity"`
Name string `json:"name"`
Remote string `json:"remote,omitempty"`
Local string `json:"localCheckout,omitempty"`
Entries []GroupedEntry `json:"entries"`
}
Group is sessions of one repository across machines.
func GroupByRepo ¶
GroupByRepo groups sessions by repository identity; sessions outside git go to a "no repository" group (identity ""). localRoots are searched for local checkouts.
type GroupedEntry ¶
type GroupedEntry struct {
Machine string `json:"machine"`
Session *Session `json:"session"`
Copies []Copy `json:"copies,omitempty"`
}
GroupedEntry is one session in a group. When the same session exists on several machines (it was moved), the entry shows the newest copy and lists all of them.
type KeyLogin ¶ added in v0.2.0
type KeyLogin struct {
PublicKey string `json:"publicKey"` // the local key file whose public half was installed
Created bool `json:"created"` // the key was made for this
Added bool `json:"added"` // false: the machine already had it
}
KeyLogin is what SetupKeyLogin did.
func SetupKeyLogin ¶ added in v0.2.0
func SetupKeyLogin(ctx context.Context, h config.Host, pw transport.PasswordFunc, createKey bool, stateDir string, log *audit.Log) (*KeyLogin, error)
SetupKeyLogin moves a password machine to key login: it logs in once with the password, adds this machine's public key to the account's authorized_keys, and checks that a login without a password now works. It does not change the configuration; the caller switches the machine to key login when this succeeds.
type Machine ¶
type Machine struct {
Name string `json:"name"`
Destination string `json:"destination"`
Local bool `json:"local"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
Hint string `json:"hint,omitempty"`
Facts *transport.Facts `json:"facts,omitempty"`
Sessions []Session `json:"sessions"`
// contains filtered or unexported fields
}
Machine is one scanned machine.
func (*Machine) Find ¶
Find locates a session on a machine by id prefix or exact/substring title match.
func (*Machine) PlanSource ¶
PlanSource is Source with the login there read too (once per scan), so a plan can tell whether both machines use the same Claude account.
type Scanner ¶
type Scanner struct {
StateDir string
Log *audit.Log
Options sessions.ListOptions
// SkipGit skips the git probe (faster listing).
SkipGit bool
// Passwords supplies the password for machines that log in with one (nil: such
// machines fail with an explanation).
Passwords func(h config.Host) transport.PasswordFunc
}
Scanner scans machines.