inventory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 27 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 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

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

View Source
const AgentSchema = "hopsesh.agent/v1"

AgentSchema is the agent output format this build understands.

View Source
const HelperRel = ".local/share/hopsesh/bin/hopsesh"

HelperRel is where the helper lives, relative to the remote home directory.

Variables

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

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

func ClaudeSupports(ctx context.Context, claude, flag string) bool

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

func HelperBinary(explicit string, f *transport.Facts) (string, error)

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

func HelperPath(f *transport.Facts) string

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

func LocalClaude(ctx context.Context) (path, version string)

LocalClaude finds the claude binary and its version on this machine.

func LocalFacts

func LocalFacts(ctx context.Context) *transport.Facts

LocalFacts describes this machine.

func LocalHostName

func LocalHostName() string

LocalHostName is this machine's short name.

func LocalTarget

func LocalTarget(ctx context.Context) engine.Target

LocalTarget describes this machine as the destination of a move.

func NewestOf added in v0.2.0

func NewestOf(ms []*Machine, ss []*Session) int

NewestOf picks the newest copy among (machine, session) pairs of one session, by the same rule as the grouped listing.

func RemoveHelper

func RemoveHelper(ctx context.Context, conn *transport.Conn, f *transport.Facts) error

RemoveHelper deletes the helper from the machine.

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

func GroupByRepo(machines []*Machine, localRoots []string) []Group

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) Close

func (m *Machine) Close()

Close releases the machine's connections.

func (*Machine) Find

func (m *Machine) Find(query string) ([]*Session, error)

Find locates a session on a machine by id prefix or exact/substring title match.

func (*Machine) PlanSource

func (m *Machine) PlanSource(ctx context.Context) engine.Source

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.

func (*Machine) Source

func (m *Machine) Source() engine.Source

Source returns the engine source for a scanned machine.

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.

func (*Scanner) Scan

func (s *Scanner) Scan(ctx context.Context, hosts []config.Host, includeLocal bool) []*Machine

Scan scans this machine (if includeLocal) and every allowed host concurrently. Machines that fail are returned with a status and a hint instead of an error.

func (*Scanner) ScanHost

func (s *Scanner) ScanHost(ctx context.Context, h config.Host) *Machine

ScanHost scans one remote machine.

type Session

type Session struct {
	sessions.Summary
	Live *sessions.LiveEntry `json:"live,omitempty"`
	Git  *repos.GitState     `json:"git,omitempty"`
}

Session is one session with its machine-side context.

Jump to

Keyboard shortcuts

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