app

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 61 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 app is what hopsesh does, for every front end (command line, terminal UI, desktop app, the agents' skill): scan machines for sessions of every agent, plan and carry out moves and continuations, undo them, and keep the agents' integration current.

Index

Constants

View Source
const (
	BranchHandoff = "handoff" // the branch hopsesh pushed for a hand-off
	BranchVendor  = "vendor"  // the cloud's own branch, brought home
)

Branch kinds.

View Source
const (
	CloudReady       = "ready"
	CloudCLIMissing  = "cli-missing"  // the driver is not installed here
	CloudCLIOld      = "cli-old"      // the driver is older than any version the cloud was tested with
	CloudSignedOut   = "signed-out"   // the driver is not signed in with the account the cloud needs
	CloudNotEligible = "not-eligible" // the plan or the organization does not allow cloud sessions
	CloudNotAllowed  = "not-allowed"  // the user has not allowed hopsesh to use it
	CloudError       = "error"
)

Cloud statuses.

View Source
const (
	CompanionName = "MyCNC"
	CompanionPage = "https://codonic.dev/apps/mycnc/"
)

MyCNC is the phone companion hopsesh recommends: an iPhone and iPad app that controls the agents on a Mac running MyCNC Host. hopsesh only reads whether MyCNC Host is here (its presence file) and opens its links; it never installs or starts it.

View Source
const (
	GuardBlock  = config.OriginalBlock
	GuardAdvise = config.OriginalAdvise
	GuardOff    = config.OriginalOff
)

Guard modes (config "original").

View Source
const (
	CheckOK      = "ok"
	CheckWarn    = "warn"
	CheckError   = "error"
	CheckOff     = "off"
	CheckUnknown = "unknown"
)

States of a check. Gray (off, unknown) is never a failure; warn works but needs attention (an older hopsesh, an outdated skill); error does not work.

View Source
const (
	FixSetUp   = "setup"   // set hopsesh up there (hosts setup)
	FixUpdate  = "update"  // update hopsesh there (hosts setup)
	FixReceive = "receive" // turn receiving on
	FixServe   = "serve"   // start hopsesh serve at login (hopsesh serve install)
	FixHooks   = "hooks"   // install the movement hooks
	FixSkill   = "skill"   // install or update the skill
	FixCLI     = "cli"     // put the hopsesh command on PATH
	FixAlign   = "align"   // bring this machine's other copies of hopsesh to this version
	FixApprove = "approve" // the user approves the hook in the agent (hopsesh never does)
)

Fixes a check can offer (Check.Fix): the action that puts it right.

View Source
const (
	ProtectedYes     = "yes"
	ProtectedNo      = "no"
	ProtectedUnknown = "unknown"
)

Verdicts of OriginalProtection.

View Source
const (
	HookInstalled     = "installed"
	HookNeedsApproval = "needs-approval" // installed; the agent runs it only after the user trusts it there
	HookRemoved       = "removed"
	HookAbsent        = "absent"
	HookUnsupported   = "unsupported"
	HookFailed        = "failed"
)

Per-item hook results.

View Source
const (
	// PresenceLogin: hopsesh runs in the login session there and answers for it.
	PresenceLogin = "login"
	// PresenceInstalled: hopsesh is there, but not in a login session (nobody is logged
	// in, or it was not set up to start at login): SSH-only answers, plus sending.
	PresenceInstalled = "installed"
	// PresenceOlder: hopsesh there is older than this one's protocol 6.
	PresenceOlder = "older"
	// PresenceSSH: no hopsesh there; it is read over SSH only.
	PresenceSSH = "ssh"
)

How hopsesh works with a machine (Machine.Presence).

View Source
const (
	StatusOK          = "ok"
	StatusUnreachable = "unreachable"
	StatusAuth        = "auth"
	StatusHostKey     = "host-key"
	StatusKeyChanged  = "host-key-changed"
	StatusTSCheck     = "tailscale-check"
	StatusLocalNet    = "local-network" // macOS local network privacy blocked it
	StatusError       = "error"
)

Machine statuses.

View Source
const DefaultCloudTimeout = 8 * time.Second

DefaultCloudTimeout is how long a scan waits for one cloud's listing.

View Source
const MinBlockVersion = lineage.FirstFileFormatVersion

MinBlockVersion is the first hopsesh that can block or warn an original a 0.6+ hopsesh moved: older ones cannot read the lineage files (lineage.FileFormat) that say where the session went.

View Source
const MovedOriginal = "moved-original: "

MovedOriginal starts the error that refuses to continue an old copy, so the window can tell it from other failures and offer to continue it anyway.

View Source
const SizeMessages = "messages"

SizeMessages is Entry.SizeUnit when Session.Size counts settled messages, not bytes.

View Source
const StatusDetailsTTL = statusDetailsTTL

StatusDetailsTTL is how long a machine's hooks, as read, are current: reading them again sooner gives the same answer.

Variables

View Source
var ErrAmbiguous = errors.New("several sessions match")

ErrAmbiguous means a reference matches several sessions.

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

View Source
var ErrNoPreview = errors.New("this agent's conversations can't be previewed")

ErrNoPreview means the session's agent cannot show the end of its conversation.

View Source
var ErrOpenElsewhere = errors.New("it is already open")

ErrOpenElsewhere means a session already runs in a tab: show that one instead of a second copy writing to the same conversation.

Functions

func AccountLabel added in v0.4.1

func AccountLabel(p *agent.RuntimeProfile) string

AccountLabel describes the current sign-in for a root, never its historical owner.

func AccountsDir added in v0.5.0

func AccountsDir(home string) string

AccountsDir is where hopsesh makes account folders under a home folder.

func Behind added in v0.6.2

func Behind(version, newest string) bool

Behind reports whether version is older than newest (development builds never are).

func BlockReason added in v0.4.2

func BlockReason(notice string, key agent.SessionKey) string

BlockReason is what the agent shows when it refuses a prompt in a blocked original.

func CLIExecutable added in v0.5.0

func CLIExecutable() (string, error)

CLIExecutable is the hopsesh command-line program on this machine (the app's own when in the app).

func CleanupDecision added in v0.4.0

func CleanupDecision(c BranchCandidate, f BranchFacts) (offer bool, why string)

CleanupDecision decides whether hopsesh offers to delete a branch, and says why (not).

func CompanionLink(endpoint, machine string, k agent.SessionKey) string

CompanionLink is the link that opens a session in MyCNC (it only ever opens a view); machine is hopsesh's name for the session's machine, which MyCNC shows when it isn't connected to it.

func EntryIdentity added in v0.4.0

func EntryIdentity(machine, key string) string

func EntrySize added in v0.9.0

func EntrySize(e Entry) string

EntrySize is an entry's session size as people read it: "812 KB", or "24 messages" for an agent that counts messages. It is "" when the size is unknown.

func GuardBlocks added in v0.4.2

func GuardBlocks(status string) bool

GuardBlocks reports whether a movement status keeps the original blocked: the work was prepared or continued elsewhere, or both copies already differ. A separate fork never blocks: the original is meant to go on.

func HumanBytes added in v0.6.0

func HumanBytes(n int64) string

HumanBytes is n as people read a file size: 812 KB, 3.4 MB, 9.8 GB.

func LocalInstalls added in v0.7.0

func LocalInstalls(ctx context.Context) installs.List

LocalInstalls lists hopsesh on this machine.

func LocalName

func LocalName() string

LocalName is this machine's name in lineage: $HOPSESH_MACHINE, else its short host name.

func MovementHookErrors added in v0.5.0

func MovementHookErrors(action string, statuses []MovementHookStatus) error

MovementHookErrors is the error a command-line action reports: every failed item, and for install every agent that cannot take the hook.

func Newest added in v0.6.2

func Newest(ss []MachineStatus) (string, string)

Newest is the newest hopsesh among ss and the machine that has it.

func NewestHopsesh added in v0.6.2

func NewestHopsesh(inv *Inventory) string

NewestHopsesh is the newest hopsesh on inv's machines ("" when none is a release).

func OldCopyError added in v0.7.0

func OldCopyError(e Entry) error

OldCopyError refuses to continue e, an old copy, and says where its session went.

func OwnerLabel added in v0.4.5

func OwnerLabel(o SessionOwner) string

OwnerLabel names a session's account for people: its email, "another account" for one no profile is signed in to now, or "" when the agent did not record it.

func OwnerLine added in v0.4.5

func OwnerLine(o SessionOwner, p *agent.RuntimeProfile) string

OwnerLine describes a session's account and where it is stored, for text views: "run by a@x · stored in Claude Code default (signed in as b@y now)".

func Owners added in v0.5.0

func Owners(s agent.Summary) []agent.OwnerRun

Owners are the accounts a session ran under, oldest first: its own records, or for an older summary only its Remote Control owner.

func OwnersDir added in v0.8.0

func OwnersDir() string

OwnersDir is where other programs' owner records are.

func ParseSessionLink(raw string) (endpoint string, k agent.SessionKey, ok bool)

ParseSessionLink reads a hopsesh://session link.

func Rules

func Rules(bin string) agent.Rules

Rules are the hopsesh commands agents may run without asking (read-only) and the ones that always ask.

func SessionLink(endpoint string, k agent.SessionKey) string

SessionLink is hopsesh's own link to a session: hopsesh://session/<endpoint>/<agent>/<session>, with ?profile= for an account folder other than the default.

func StepCommand added in v0.4.0

func StepCommand(s move.TermStep) (*exec.Cmd, error)

StepCommand is a terminal step's driver run on the terminal itself, unwatched (where this system has no pseudo-terminal), with the relay's environment; on Windows an npm command shim runs as the program behind it, as in the relay.

func StepRelay added in v0.4.0

func StepRelay(s move.TermStep) *term.Relay

StepRelay is the relay that runs a terminal step in a terminal: the driver's argument list in its folder, with this process's environment less the cloud's Unset and plus the step's Env, and a capture for the module's reader.

func StepTab added in v0.4.0

func StepTab(s move.TermStep) pty.Spec

StepTab is the app's terminal tab for a terminal step: the driver's argument list in its folder, with the user's environment less the cloud's Unset (and other terminals' variables, see pty.Env) plus the step's Env, its output captured for the module's reader. The tab says what it runs and where.

func TabArgv added in v0.4.0

func TabArgv(argv []string) ([]string, error)

TabArgv is a command's argument list as the app's terminal tabs run it: the program found on this process's PATH, else on the login shell's, and on Windows a command shim (npm's codex.cmd) replaced by the program it starts, since a tab never runs a batch file (see internal/core/winshim).

Types

type Activity

type Activity struct {
	Journal *journal.Journal `json:"journal"`
	CanUndo bool             `json:"canUndo"`
	Why     string           `json:"why,omitempty"` // why not: undone, or what changed since
	// Part: it is a leg of a hop (Journal.PartOf), undone with it.
	Part bool `json:"part,omitempty"`
}

Activity is one operation hopsesh carried out, and whether it can be undone now.

type AddAccountOptions added in v0.5.0

type AddAccountOptions struct {
	// Command adds <agent>-<name> (claude-work) to the shell on that machine.
	Command bool `json:"command"`
}

AddAccountOptions are the choices of a new account folder.

type AgentSetup added in v0.6.2

type AgentSetup struct {
	Agent        agent.ID `json:"agent"`
	Name         string   `json:"name"`              // "Claude Code"
	Profile      string   `json:"profile,omitempty"` // "" for the default folder
	ProfileLabel string   `json:"profileLabel,omitempty"`
	// Account is who is signed in there (an email, when the agent says), and Folder the
	// agent folder itself: what tells two folders of one agent apart.
	Account string `json:"account,omitempty"`
	Folder  string `json:"folder,omitempty"`
	Hook    Check  `json:"hook"`
	Skill   Check  `json:"skill"`
	// Plugin: the agent's hook is a plugin it loads (OpenCode), not a hook in its settings.
	Plugin bool `json:"plugin,omitempty"`
}

AgentSetup is one agent folder's hook and skill on a machine.

type AgentState

type AgentState struct {
	Agent   agent.ID      `json:"agent"`
	Name    string        `json:"name"`
	Install agent.Install `json:"install"`
	Error   string        `json:"error,omitempty"`
}

AgentState is an agent as found on a machine.

type AgentUsage added in v0.6.0

type AgentUsage struct {
	Agent    agent.ID `json:"agent"`
	Name     string   `json:"name"`
	Sessions int      `json:"sessions"`
	Bytes    int64    `json:"bytes"`
	Messages int64    `json:"messages,omitempty"`
}

AgentUsage is how much one agent's sessions take on one machine: the session files its listing sized (each copy where it is), or, for an agent that keeps them in a database (OpenCode), their messages.

type App

type App struct {
	Catalog *catalog.Store

	Cfg      config.Config
	Reg      *registry.Registry // every compiled-in module
	StateDir string
	Audit    *audit.Log
	Log      *slog.Logger
	// Passwords answers ssh password questions for machines that log in with one (nil:
	// such machines are reported, not scanned).
	Passwords func(h config.Host) transport.PasswordFunc
	// PeerDial reaches hopsesh on a configured machine (nil: over SSH).
	PeerDial func(ctx context.Context, h config.Host) (*PeerConn, error)
	// CloudTimeout bounds one cloud's listing in a scan (0: DefaultCloudTimeout).
	CloudTimeout time.Duration
	// Steps runs a cloud driver's terminal step where the user answers it (the command
	// line's and the terminal UI's relay, the app's terminal window); nil: this front end
	// has none, and a hand-off to a cloud that needs one is blocked with the reason.
	Steps move.StepRunner
	// RunHere runs a driver's command in this front end's terminal and waits for it (the
	// teleport that brings a hop's session here); nil: the front end opens it itself, and the
	// hop waits for ContinueHop.
	RunHere RunHere
	// Terminals are the terminal apps launches open in (empty: this system's), and Procs
	// what finding a session's tab reads of the process table (nil: this machine's).
	Terminals termapp.Set
	Procs     termapp.Procs

	// Skills renders the hopsesh skill (nil: this front end installs no skill).
	Skills SkillFiles
	// Login is set in hopsesh serve, which runs in the user's login session (nil
	// elsewhere).
	Login *Login
	// contains filtered or unexported fields
}

App holds what every use case needs.

func New

func New(cfg config.Config, reg *registry.Registry, stateDir string, log *audit.Log) *App

New returns an App for the modules and configuration.

func (*App) AccountLogin added in v0.4.0

func (a *App) AccountLogin(ctx context.Context, id string, elsewhere ...bool) (agent.Command, error)

AccountLogin returns a vendor-owned login command; callers explicitly run it in a terminal. Desktop deep links are not used because they cannot select this profile. AccountLogin is the sign-in command of an account folder on this machine. elsewhere: the person signs in from another machine's browser (a link and a code are printed).

func (*App) Accounts added in v0.4.0

func (a *App) Accounts() ([]agent.RuntimeProfile, error)

func (*App) Activities

func (a *App) Activities() ([]Activity, error)

Activities lists what hopsesh did, newest first. Whether each can still be undone is checked on this machine's files only (other machines, remotes and clouds are checked when undoing).

func (*App) AddAccount added in v0.5.0

func (a *App) AddAccount(ctx context.Context, machine string, id agent.ID, name string, tags []string, o AddAccountOptions) (agent.RuntimeProfile, error)

AddAccount makes a new account folder for an agent on a machine (this one, or one with hopsesh running in its login session), ready to sign in. Its sign-in is not touched here: AccountSignIn runs it.

func (*App) Adopt added in v0.4.0

func (a *App) Adopt(ctx context.Context, journal string, exited bool) (*move.Fetch, error)

Adopt looks for what the driver wrote for a fetch (by its journal) and adopts it once it is there; exited: the driver has ended. The fetch says whether it is still waiting.

func (*App) AlignHere added in v0.7.0

func (a *App) AlignHere(ctx context.Context, progress func(SetupStep)) (*MachineSetup, error)

AlignHere brings the other copies of hopsesh on this machine to this one's version: the same steps as updating another machine, except that the login service is only moved, never added (starting at login here is the user's choice).

func (*App) Apply

func (a *App) Apply(ctx context.Context, p *move.Plan, in move.Input, progress func(string)) (res *move.Result, err error)

Apply carries out a plan.

func (*App) ArchiveLineage added in v0.4.0

func (a *App) ArchiveLineage(ctx context.Context, inv *Inventory, e Entry) (*journal.Journal, error)

ArchiveLineage explicitly removes unsupported metadata from the active namespace. It retains the original sidecar beside the transcript; Activity can undo the rename.

func (*App) AttachTerminal added in v0.5.0

func (a *App) AttachTerminal(ctx context.Context, machine, id string, in io.Reader, out io.Writer, sizes <-chan [2]int, problems func(string)) (int, error)

AttachTerminal shows one of hopsesh's terminals on machine in this terminal (in, out), until its program ends (its exit code) or the connection does (an error; it keeps running there).

func (*App) AwaitStep added in v0.4.0

func (a *App) AwaitStep(ctx context.Context, s move.TermStep, sess *pty.Session) (move.StepResult, error)

AwaitStep waits for a terminal step running in the app's tab sess (started from StepTab) to end, and reads the session it started, as RunStepHere does for a relay. A step whose output names no session ends with agent.ErrNoSession; the window then offers to paste the link (PastedStep).

func (*App) BringTarget added in v0.4.0

func (a *App) BringTarget(inv *Inventory, e Entry) agent.ID

BringTarget is the local agent that gets a cloud-only module's session (Copilot's log, Amp's thread) when the user names none: the agent it was handed off from, by its lineage, else the first agent here, in display order, that takes sessions; "" when none here can.

func (*App) Brought added in v0.4.0

func (a *App) Brought(f *move.Fetch) Brought

Brought describes a fetch with its module's name.

func (*App) CachedInventory added in v0.4.1

func (a *App) CachedInventory() *Inventory

func (*App) CanChangeDir added in v0.6.2

func (a *App) CanChangeDir(inv *Inventory, e Entry) bool

CanChangeDir reports whether a session's folder can be changed: its agent's module has the capability, and the session is on this machine or on one where hopsesh runs (it makes the change there).

func (*App) CanRename added in v0.4.0

func (a *App) CanRename(e Entry) bool

CanRename reports whether a session can be renamed in its agent's own data.

func (*App) CatalogScope added in v0.4.1

func (a *App) CatalogScope() string

func (*App) ChangeDir added in v0.6.2

func (a *App) ChangeDir(ctx context.Context, c *DirChange) (string, error)

ChangeDir carries out a planned folder change of a closed session (or one hopsesh quits first), in a journal (undo reverses it), and checks that the agent now finds the session in the new folder. It returns the journal's id.

func (*App) ClaimMovementNotice added in v0.4.0

func (a *App) ClaimMovementNotice(ctx context.Context, id agent.ID, profile, sessionID, event, notice string, identity ...MovementNoticeIdentity) (*MovementNoticeClaim, error)

ClaimMovementNotice starts a resume generation or prepares a changed prompt notice. An abandoned, failed, or timed-out attempt remains pending. Old receipts that predate write acknowledgments are deliberately not delivery evidence.

func (*App) CleanupCandidates added in v0.4.0

func (a *App) CleanupCandidates(ctx context.Context) []BranchCandidate

CleanupCandidates lists the branches hand-offs and bring-backs left on their remotes, asks each remote (read-only: ls-remote, and a fetch of the commits it needs into no ref) whether their work is merged into its default branch, and says which hopsesh offers to delete. Where gh is installed, a pull request GitHub merged (a squash or a rebase) counts too. It changes nothing.

func (*App) ClientCatalog added in v0.8.0

func (a *App) ClientCatalog(ctx context.Context, p clientapi.CatalogParams) clientapi.Catalog

ClientCatalog is the client API's catalog: the sessions and machines a scan finds.

func (*App) CloseRemoteTerminal added in v0.5.0

func (a *App) CloseRemoteTerminal(ctx context.Context, machine, id string) error

CloseRemoteTerminal ends one of them.

func (*App) CloseTerminal added in v0.5.0

func (a *App) CloseTerminal(id string) error

CloseTerminal ends one of hopsesh serve's terminals.

func (*App) CloudModule added in v0.4.0

func (a *App) CloudModule(name string) (agent.Module, agent.Cloud, bool)

CloudModule is the enabled module that reaches a cloud, with the cloud's declaration.

func (*App) Connect

func (a *App) Connect(ctx context.Context, h config.Host) (*host.Machine, error)

Connect reaches a configured machine and probes it (one round trip).

func (*App) ContinueHop added in v0.4.0

func (a *App) ContinueHop(ctx context.Context, id string, progress func(string)) (*move.Result, error)

ContinueHop takes a waiting hop on once the copy is here: it adopts the copy if it has appeared, then hands it off. A hop still waiting is returned as it is.

func (*App) DefaultOptions

func (a *App) DefaultOptions() move.Options

DefaultOptions are move options from the configuration.

func (*App) DeleteBranches added in v0.4.0

func (a *App) DeleteBranches(ctx context.Context, ids []string) (*CleanupResult, error)

DeleteBranches deletes the branches the user picked (by id) among the ones hopsesh offers, each with a lease at the commit it was checked at, under one journal: undo pushes them back. A branch that moved, or is no longer offered, is left alone and reported.

func (*App) DropStep added in v0.4.0

func (a *App) DropStep(id string)

DropStep removes a written step and its outcome.

func (*App) DropTicket added in v0.4.0

func (a *App) DropTicket(id string)

DropTicket removes a ticket whose terminal did not open.

func (*App) EditAccount added in v0.4.0

func (a *App) EditAccount(id, name string, tags []string, generation int) error

func (*App) EndDestination added in v0.4.2

func (a *App) EndDestination(ctx context.Context, p *move.Plan, in move.Input) error

EndDestination uses the reviewed module/profile and checks its registration before asking the module to end the original. It never applies the transfer.

func (*App) EnrichMovement added in v0.4.0

func (a *App) EnrichMovement(ctx context.Context, inv *Inventory)

EnrichMovement joins receipt metadata and observes native content in memory. It never writes remote files or alters journaled sidecars during a scan.

func (*App) EnvChoices added in v0.4.0

func (a *App) EnvChoices(inv *Inventory, cloud, repo string) []move.EnvChoice

EnvChoices are the environments a hand-off to a cloud can run in, for a repository: the one configured for it first, then the ones the cloud's listing shows (the most used first), then the ones configured for other repositories.

func (*App) ExternalOwners added in v0.8.0

func (a *App) ExternalOwners() map[agent.SessionKey][]OwnerRecord

ExternalOwners reads the owner records whose process still runs, by session.

func (*App) FamilyName added in v0.5.0

func (a *App) FamilyName(r Relationship) string

FamilyName is the name the user gave a family, if any.

func (*App) Fetches added in v0.4.0

func (a *App) Fetches() ([]*move.Fetch, error)

Fetches lists what was brought from clouds, newest first.

func (*App) FoldersToMove added in v0.5.0

func (a *App) FoldersToMove() ([]FolderMove, error)

FoldersToMove are the account folders on this machine still in hopsesh's state folder, where resetting hopsesh would delete them.

func (*App) FollowUp added in v0.4.0

func (a *App) FollowUp(ctx context.Context, cloud string, id agent.SessionID, text string) (agent.CloudSession, error)

FollowUp sends a message to a cloud session through its module (it starts a model turn there, on the user's plan).

func (*App) ForgetAccount added in v0.4.0

func (a *App) ForgetAccount(id string, generation int) error

func (*App) FreshSelection added in v0.4.1

func (a *App) FreshSelection(ctx context.Context, e Entry) (*Inventory, Entry, error)

FreshSelection bypasses browsing summaries and only reaches the source and destination.

func (*App) GitFor added in v0.4.0

func (a *App) GitFor(r Ref) func(Entry) bool

GitFor narrows a scan's git probe (ScanOptions.GitFor) to what working with the sessions r names needs: the folders of every session r could match, and of the sessions whose lineage names a cloud copy (a cloud session's repository and checkout come from them). Other folders are left alone, so one that git cannot read in time (offloaded to a cloud drive, say) does not hold up a command about another session.

func (*App) Guard added in v0.6.2

func (a *App) Guard(ctx context.Context, src *Machine, key agent.SessionKey) *move.Guard

Guard is what the source machine says about blocking or warning a session of key's agent left there once it moves: hopsesh new enough to read where it went (its version is known from the scan), and the hook in that agent folder, read now from its one hook file over the plan's own connection (no agent or shell is asked, nothing is cached). nil when hopsesh isn't there: the planner says so itself.

func (*App) HandoffDefaults added in v0.4.0

func (a *App) HandoffDefaults(cloud string) move.Options

HandoffDefaults are the options a hand-off starts with, from the configuration.

func (*App) HandoffTargets added in v0.4.0

func (a *App) HandoffTargets(inv *Inventory, e Entry) []HandoffTarget

HandoffTargets are the clouds a session could be handed off to, each enabled or with its reason: an option is refused with its reason, never hidden.

func (*App) HopTargets added in v0.4.0

func (a *App) HopTargets(inv *Inventory, e Entry) []HandoffTarget

HopTargets are the clouds a cloud session could be handed on to, each enabled or with its reason (never hidden).

func (*App) Hops added in v0.4.0

func (a *App) Hops() []*Hop

Hops lists the hops, newest first.

func (*App) InstallNoticeHooks added in v0.4.0

func (a *App) InstallNoticeHooks(ctx context.Context, id agent.ID, profile string) ([]MovementHookStatus, error)

InstallNoticeHooks is an explicit setup action; defaults being on does not bypass the user's/vendor's hook trust flow. Empty selectors cover all local profiles.

func (*App) InstallSkill

func (a *App) InstallSkill(ctx context.Context, files map[string][]byte, version, bin string, force, rules bool) (SkillReport, error)

InstallSkill writes the same files into every agent's skills folder in one go (and, with rules, each agent's approval rules). A copy the user edited stops the install unless force.

func (*App) IsCloud added in v0.4.0

func (a *App) IsCloud(name string) bool

IsCloud reports whether a name is a cloud's.

func (*App) Journals

func (a *App) Journals() ([]*journal.Journal, error)

Journals lists what can be undone, newest first.

func (*App) KeepPartial added in v0.4.0

func (a *App) KeepPartial(journal string) error

KeepPartial records that the user keeps a partial copy as it is.

func (*App) LiveHere added in v0.4.0

func (a *App) LiveHere(ctx context.Context, inv *Inventory) map[agent.SessionKey]agent.LiveInfo

LiveHere asks the agents on this machine which of its sessions in inv are open now (their own registries and locks, no scan): by session key, for the sessions whose agent can tell.

func (*App) LoadHop added in v0.4.0

func (a *App) LoadHop(id string) (*Hop, error)

LoadHop reads a hop's record by its journal.

func (*App) LocalAccountEndpoint added in v0.4.1

func (a *App) LocalAccountEndpoint(ctx context.Context) (string, error)

LocalAccountEndpoint reads identity without launching an agent or contacting peers.

func (*App) LocalAccounts added in v0.5.0

func (a *App) LocalAccounts(ctx context.Context) ([]agent.RuntimeProfile, error)

LocalAccounts checks every account folder on this machine now (hopsesh serve answering another machine) and returns them, without their tags (the user's own words).

func (*App) LocalLedger added in v0.5.0

func (a *App) LocalLedger() []LedgerRecord

LocalLedger is every record hopsesh keeps on this machine (hopsesh serve answering another machine, so its sessions there show who ran them).

func (*App) LocalProtection added in v0.5.0

func (a *App) LocalProtection(ctx context.Context) Protection

LocalProtection checks this machine's command, hooks and skill.

func (*App) LocalRemoteDefaults added in v0.7.0

func (a *App) LocalRemoteDefaults(ctx context.Context) (RemoteDefaults, error)

LocalRemoteDefaults reads this machine's agent folders' Remote Control defaults.

func (*App) LocalRoots

func (a *App) LocalRoots() []string

LocalRoots are folders searched for checkouts on this machine.

func (*App) LocalTools added in v0.5.0

func (a *App) LocalTools(ctx context.Context) []agent.Install

LocalTools is every agent's install on this machine as hopsesh in the login session sees it: the desktop apps and their own sign-ins included.

func (*App) MachineProtection added in v0.5.0

func (a *App) MachineProtection(ctx context.Context, machine string) (Protection, error)

MachineProtection asks hopsesh on another machine for its protection.

func (*App) MachineRemoteDefaults added in v0.7.0

func (a *App) MachineRemoteDefaults(ctx context.Context, machine string, set *bool) (RemoteDefaults, error)

MachineRemoteDefaults reads, or with set changes, another machine's Remote Control defaults through hopsesh in its login session there.

func (*App) MachineStatuses added in v0.6.2

func (a *App) MachineStatuses(ctx context.Context, inv *Inventory, o StatusOptions) []MachineStatus

MachineStatuses is what hopsesh can do on each machine of inv, newest version first considered. Hooks, skill and command are read again when older than statusDetailsTTL (or with Refresh), in parallel; everything else comes from the scan.

func (*App) Module

func (a *App) Module(id agent.ID) (agent.Module, bool)

Module returns an enabled module by id.

func (*App) Modules

func (a *App) Modules() []agent.Module

Modules returns the enabled modules.

func (*App) MoveFolders added in v0.5.0

func (a *App) MoveFolders() ([]FolderMove, error)

MoveFolders moves the account folders FoldersToMove names, after the user confirmed. Their sessions and sign-ins move with them; their ids stay.

func (*App) MovementNoticeDelivery added in v0.4.0

func (a *App) MovementNoticeDelivery(id agent.ID, profile, sessionID, notice string, identity ...MovementNoticeIdentity) bool

MovementNoticeDelivery is evidence that this exact notice was supplied to the lifecycle hook. It never means the model or user read it. Read-only: no new directories, receipts, account probes, or scan, even when nothing was delivered.

func (*App) MovementNoticeDetailsForPath added in v0.4.0

func (a *App) MovementNoticeDetailsForPath(ctx context.Context, id agent.ID, profile, sessionID, path string) (MovementNoticeDetails, error)

MovementNoticeDetailsForPath is deliberately local-only and bounded: no Scan, agent process, network, account probe or hook-supplied command is executed. Lookup never writes scan evidence: a concurrent refresh may have newer facts.

func (*App) MovementNoticeHooks added in v0.4.0

func (a *App) MovementNoticeHooks(ctx context.Context, action string, id agent.ID, profile, bin string) ([]MovementHookStatus, error)

MovementNoticeHooks manages hooks only on this machine. Each agent profile is one item with its own Result; the error is only for a request that could not be attempted. A nonempty profile is an exact registered ID (never a prefix, label, path, or remote registration). An empty profile selects all registered local profiles plus an unregistered default root. Empty id selects all enabled agents; a profile requires an agent. bin must be the absolute installed CLI executable, including when called by GUI.

func (*App) MyTerminal added in v0.4.0

func (a *App) MyTerminal(ctx context.Context) termapp.Terminal

MyTerminal is the terminal app launches open in: the configured one when installed, else the best installed one.

func (*App) NewSessionCommand added in v0.5.0

func (a *App) NewSessionCommand(ctx context.Context, id agent.ID, profile, dir string, restart bool) (agent.Command, error)

NewSessionCommand starts a new session of an agent in dir, signed in as the account of the folder profile ("" its default folder). restart: the person agreed to restart the agent's background service when no program of its version is here (decision D2); without it such a start is agent.ErrRestartsService.

func (*App) NewTicket added in v0.4.0

func (a *App) NewTicket(l Launch) (string, error)

NewTicket writes the ticket for a launch. The agent's program is resolved here, where the login shell's PATH is known, so the tab finds it whatever its own PATH is.

func (*App) NoticeHooks added in v0.4.0

func (a *App) NoticeHooks(ctx context.Context) ([]MovementHookStatus, error)

NoticeHooks is the GUI's local hook setup status. Installed means the exact current integration is present; it does not imply vendor trust or delivery.

func (*App) NoticeHooksFor added in v0.4.2

func (a *App) NoticeHooksFor(ctx context.Context, id agent.ID, profile string) ([]MovementHookStatus, error)

NoticeHooksFor reports one agent's (or every agent's) hooks, as installed by this app.

func (*App) OldCopy added in v0.7.0

func (a *App) OldCopy(e Entry) bool

OldCopy reports whether e is the copy a move left behind, which must not be continued, resumed elsewhere or moved again: the session went on from where it moved (a separate fork leaves its original current, and a released one is the user's choice to go on).

func (*App) OpenElsewhere added in v0.4.0

func (a *App) OpenElsewhere(ctx context.Context, key agent.SessionKey, live agent.LiveInfo) error

OpenElsewhere says where a session already runs, when it does: in a tab hopsesh can show (found), or in a terminal it cannot (live).

func (*App) OpenInTerminal added in v0.4.0

func (a *App) OpenInTerminal(ctx context.Context, prog string, t termapp.Terminal, l Launch) (termapp.Opened, error)

OpenInTerminal writes a launch's ticket and opens `<prog> terminal-open <ticket>` in t (nil: MyTerminal), falling back to another installed terminal when t is missing or macOS denies hopsesh control of it. When nothing opens, the error wraps termapp.ErrNoTerminal (copy the command instead).

func (*App) OpenStepInTerminal added in v0.4.0

func (a *App) OpenStepInTerminal(ctx context.Context, prog string, t termapp.Terminal, stepID, dir string) (termapp.Opened, error)

OpenStepInTerminal opens `<prog> terminal-step <id>` (a hand-off's step the app wrote) in t (nil: MyTerminal), with the same fallback: beside the session the user is in where the terminal can (iTerm2 with its Python API on), else as a tab.

func (*App) OpenTerminal added in v0.5.0

func (a *App) OpenTerminal(ctx context.Context, req peer.TerminalRequest) (peer.Terminal, error)

OpenTerminal runs what req asks in a terminal this hopsesh serve owns.

func (*App) OriginalGuard added in v0.4.2

func (a *App) OriginalGuard(key agent.SessionKey, operation, status string) string

OriginalGuard is how the copy left behind is protected for this movement: block, advise or off (released originals are advised once, never blocked).

func (a *App) ParseCloudLink(s string) (agent.Module, string, agent.SessionID, bool)

ParseCloudLink reads a cloud session's link or id with the modules that know their vendor's links: the module, the cloud and the id.

func (*App) Paste added in v0.4.0

func (a *App) Paste(ctx context.Context, link, checkout string) (Pasted, error)

Paste remembers a cloud session by its link or id, with the checkout here it works on ("" when not known yet), so scans list it.

func (*App) Pasted added in v0.4.0

func (a *App) Pasted() []Pasted

Pasted returns the pasted cloud sessions.

func (*App) PastedStep added in v0.4.0

func (a *App) PastedStep(s move.TermStep, link string) (agent.CloudSession, error)

PastedStep is the session a link the user pasted names, for a terminal step whose output named none (or that ran where hopsesh could not watch it).

func (*App) Plan

func (a *App) Plan(ctx context.Context, inv *Inventory, e Entry, target agent.ID, opt move.Options) (*move.Plan, move.Input, error)

Plan works out how a session comes here, in the same agent or (target set) another. A cloud session is brought from its cloud (a fetch).

func (*App) PlanChangeDir added in v0.6.2

func (a *App) PlanChangeDir(ctx context.Context, inv *Inventory, e Entry, dir string, o DirOptions) (*DirChange, error)

PlanChangeDir says what moving a session on this machine to dir does.

func (*App) PlanChangeDirOn added in v0.6.3

func (a *App) PlanChangeDirOn(ctx context.Context, machine string, key agent.SessionKey, dir string, o DirOptions) (*RemoteDir, error)

PlanChangeDirOn asks hopsesh on machine to plan moving its session key to dir there (dir is a folder there; ~ is that machine's home).

func (*App) PlanHandoff added in v0.4.0

func (a *App) PlanHandoff(ctx context.Context, inv *Inventory, e Entry, cloud string, opt move.Options) (*move.Plan, error)

PlanHandoff works out handing a session off to a cloud. Nothing changes.

func (*App) PlanHop added in v0.4.0

func (a *App) PlanHop(ctx context.Context, inv *Inventory, e Entry, to string, via agent.ID, opt move.Options) (*move.Plan, error)

PlanHop works out handing a cloud session on to another cloud through this machine: the bring-back (into via, or the cloud's own agent: "" picks as Bring here does) and the hand-off, as far as it can be planned before the session is here. opt holds the hand-off's choices (the environment, the clean-up); opt.TargetDir chooses the repository's checkout here. Nothing changes.

func (*App) PlanUpdate added in v0.7.0

func (a *App) PlanUpdate(ctx context.Context, machine string) (*UpdatePlan, error)

PlanUpdate lists hopsesh on machine and says what setting it up or updating it would do.

func (*App) Preview added in v0.4.0

func (a *App) Preview(ctx context.Context, inv *Inventory, e Entry, n int) (agent.Preview, error)

Preview reads the end of a session's conversation on its machine: the last n messages (the module's Previewer reads only the end of the file).

func (*App) PreviewSelected added in v0.4.1

func (a *App) PreviewSelected(ctx context.Context, e Entry, n int) (agent.Preview, error)

PreviewSelected resolves a registered source without enumerating sessions or borrowing a background scan's connection. It never reads saved transcript text.

func (*App) ReadStep added in v0.4.0

func (a *App) ReadStep(s move.TermStep, r *term.Relay) (agent.CloudSession, error)

ReadStep reads the session a terminal step started from what its relay saw, through the module (agent.CloudStepReader), and forgets the output.

func (*App) ReadStepOutput added in v0.4.0

func (a *App) ReadStepOutput(s move.TermStep, out agent.StepOutput) (agent.CloudSession, error)

ReadStepOutput reads the session a terminal step started from what it printed (a relay's or an app tab's capture), through the module's agent.CloudStepReader.

func (*App) Receiving added in v0.6.2

func (a *App) Receiving(m *Machine) bool

Receiving reports whether hopsesh on m runs in the login session there and accepts sessions (the green mark beside a machine).

func (*App) RecordOwner added in v0.5.0

func (a *App) RecordOwner(ctx context.Context, id agent.ID, profile, session string)

RecordOwner notes the account the session's root is signed in to now, as the agent starts or takes a prompt. It never fails the hook.

func (*App) RecoverReceipts added in v0.4.0

func (a *App) RecoverReceipts(ctx context.Context, id string) error

RecoverReceipts retries only the durable metadata acknowledgments of one journal. Native destination guards remain mandatory, and an undone journal cannot be revived.

func (*App) RefreshAccount added in v0.4.1

func (a *App) RefreshAccount(ctx context.Context, id string) (agent.RuntimeProfile, error)

RefreshAccount probes exactly one registered profile and preserves the last known account when the check fails. It never reads credential files or copies logins.

func (*App) RefreshMachineStatus added in v0.7.0

func (a *App) RefreshMachineStatus(ctx context.Context, m *Machine, force bool) bool

RefreshMachineStatus reads one machine's hooks, skill and command again when they are older than statusDetailsTTL (always, with force), and keeps them for MachineStatuses. false: they could not be read (the machine isn't reached, or has no hopsesh).

func (*App) RegisterAccount added in v0.4.0

func (a *App) RegisterAccount(ctx context.Context, machine string, id agent.ID, name, root string, tags []string) (agent.RuntimeProfile, error)

RegisterAccount adopts a known root, or creates an empty private root on this machine. Authentication is a separate explicit vendor CLI action. No credentials are copied.

func (*App) ReleaseOriginal added in v0.4.2

func (a *App) ReleaseOriginal(key agent.SessionKey, operation string) error

ReleaseOriginal removes the block (or advice) from one original for its current movement. Continuing there afterwards makes the copies diverge: moving back then needs a comparison or a separate fork instead of a clean return.

func (*App) Released added in v0.4.2

func (a *App) Released(key agent.SessionKey, operation string) bool

Released reports whether the user removed the block for this movement of key.

func (*App) RememberEnv added in v0.4.0

func (a *App) RememberEnv(p *move.Plan) bool

RememberEnv records, after a hand-off worked, the environment it ran in as its repository's, when the configuration named none (the caller saves the configuration). It reports whether it changed anything.

func (*App) RemoteTerminal added in v0.5.0

func (a *App) RemoteTerminal(ctx context.Context, machine string, req peer.TerminalRequest) (peer.Terminal, error)

RemoteTerminal has hopsesh on machine run req in a terminal it owns there.

func (*App) RemoteTerminals added in v0.5.0

func (a *App) RemoteTerminals(ctx context.Context, machine string) ([]peer.Terminal, error)

RemoteTerminals lists the terminals hopsesh runs on machine.

func (*App) RemoveNoticeHooks added in v0.4.0

func (a *App) RemoveNoticeHooks(ctx context.Context, id agent.ID, profile string) ([]MovementHookStatus, error)

func (*App) RemoveSkill

func (a *App) RemoveSkill(ctx context.Context, files map[string][]byte, bin string, force bool) error

RemoveSkill removes every copy hopsesh owns, and the approval rules.

func (*App) Rename added in v0.4.0

func (a *App) Rename(ctx context.Context, inv *Inventory, e Entry, title string) (string, error)

Rename gives a session a new title in its agent's own data, the way the agent's own rename does, in a journal (Activity undoes it). It returns the journal's id.

func (*App) ReopenNotice added in v0.4.4

func (a *App) ReopenNotice(ctx context.Context, id agent.ID, profile, sessionID, event, source string) (text string, block, handled bool)

ReopenNotice answers the original's hook while it must be reopened. A fresh start or resume loads the new work and clears the record; any other prompt is refused with how to reopen it. handled is false when there is nothing to reopen.

func (*App) RepoEnvs added in v0.4.0

func (a *App) RepoEnvs(inv *Inventory, cloud string) []RepoEnv

RepoEnvs are the repositories hopsesh knows (configured for the cloud, or a session's checkout) with the environment configured for each, for a cloud that needs one.

func (*App) RestoreBlock added in v0.4.2

func (a *App) RestoreBlock(key agent.SessionKey) error

RestoreBlock undoes ReleaseOriginal.

func (*App) Resume

func (a *App) Resume(inv *Inventory, e Entry, o agent.ResumeOptions) (agent.Command, error)

Resume is the command that continues a session that is already on this machine.

func (*App) ResumeShell

func (a *App) ResumeShell(inv *Inventory, e Entry) (string, error)

ResumeShell is Resume as a line for this machine's shell.

func (*App) Role added in v0.4.2

func (a *App) Role(e Entry) *RoleInfo

Role describes entry e, or nil for a copy that never moved.

func (*App) RunInThisTerminal added in v0.4.0

func (a *App) RunInThisTerminal(l Launch, tio TerminalIO) (int, error)

RunInThisTerminal runs a launch in this terminal (the command line's and the terminal UI's --run): labels when Out is a terminal, the record while a session runs, and the agent's exit code.

func (*App) RunServe added in v0.5.0

func (a *App) RunServe(ctx context.Context) error

RunServe is hopsesh serve: it answers hopsesh on this machine's other side of SSH (hopsesh peer hands its conversation over) and the terminals it runs, until ctx ends.

func (*App) RunStepFile added in v0.4.0

func (a *App) RunStepFile(id string, tio TerminalIO) error

RunStepFile runs a written step in this terminal (the hidden `hopsesh terminal-step <id>`) and writes its outcome for the app: the session's id and link, or what stopped it. It says in the terminal what is going on, before and after, and labels the tab (tio.Labels) while the step runs.

func (*App) RunStepHere added in v0.4.0

func (a *App) RunStepHere(s move.TermStep, in io.Reader, out io.Writer, ask func() string) (move.StepResult, error)

RunStepHere runs a terminal step in this process's terminal (in, out) through a relay, and reads the session from what it printed. Where this system has no pseudo-terminal, the driver runs on the terminal directly, unwatched, and the session's link comes from the user (ask; nil: no session).

func (*App) RunTicket added in v0.4.0

func (a *App) RunTicket(id string, tio TerminalIO) error

RunTicket runs a ticket in this terminal (the hidden `hopsesh terminal-open <id>`): labels, the agent's command, a record while it runs, and its exit code after.

func (*App) Running added in v0.4.0

func (a *App) Running(key agent.SessionKey) bool

Running reports whether hopsesh started a session that still runs (a record whose process is alive): a session the agent's own files may not show as open (Codex).

func (*App) SaveStep added in v0.4.0

func (a *App) SaveStep(s move.TermStep) (string, error)

SaveStep writes a terminal step for `hopsesh terminal-step <id>` and returns its id.

func (*App) Scan

func (a *App) Scan(ctx context.Context, o ScanOptions) *Inventory

Scan reads this machine, the allowed machines and the clouds in parallel. A machine or a cloud that cannot be read is returned with a status and a hint, not an error. The clouds are listed through this machine once its own sessions are listed (their lineage names the cloud copies hopsesh made), alongside the other machines.

func (*App) Serve

func (a *App) Serve(ctx context.Context, r io.Reader, w io.Writer) error

Serve answers another machine's hopsesh on r and w until r ends (hopsesh peer --stdio). It receives sessions only when this machine opted in (peer receive = true).

func (*App) ServeClient added in v0.8.0

func (a *App) ServeClient(ctx context.Context, r io.Reader, w io.Writer) error

ServeClient answers a program on this machine with hopsesh's client API on r and w (hopsesh client --stdio, or a client connection to hopsesh serve) until r ends.

func (*App) SessionMovementNotice added in v0.4.0

func (a *App) SessionMovementNotice(ctx context.Context, id agent.ID, profile, sessionID string) (string, error)

func (*App) SessionMovementNoticeForPath added in v0.4.0

func (a *App) SessionMovementNoticeForPath(ctx context.Context, id agent.ID, profile, sessionID, path string) (string, error)

func (*App) SessionTab added in v0.4.0

func (a *App) SessionTab(ctx context.Context, key agent.SessionKey, livePID int) (termapp.Found, bool, error)

SessionTab finds the tab a session on this machine runs in: from the agent's own process id (livePID, from its registry; 0 when it has none) and hopsesh's records of the launches it started. False with a nil error: no tab hopsesh can show.

func (*App) SetLocalRemoteDefault added in v0.7.0

func (a *App) SetLocalRemoteDefault(ctx context.Context, on bool) (RemoteDefaults, error)

SetLocalRemoteDefault turns Remote Control for every session on or off in each of this machine's agent folders that has the setting.

func (*App) SetUpLocalProtection added in v0.5.0

func (a *App) SetUpLocalProtection(ctx context.Context, rules bool) (Protection, error)

SetUpLocalProtection installs the protection hooks for every agent folder here and the skill in every folder its agents read it from (rules: also let agents run hopsesh's read-only commands without asking). A copy of the skill the user edited is left alone.

func (*App) SetUpMachine added in v0.5.0

func (a *App) SetUpMachine(ctx context.Context, machine string, progress func(SetupStep)) (*MachineSetup, error)

SetUpMachine installs this hopsesh on a machine reached over SSH (only when the user asks: scanning never does), lets it receive sessions, and registers it to start in the login session there at each login. Nothing needs administrator rights there.

func (*App) SetUpProtectionOn added in v0.5.0

func (a *App) SetUpProtectionOn(ctx context.Context, machine string, rules bool) (Protection, error)

SetUpProtectionOn sets protection up on another machine, through hopsesh there.

func (*App) SetupKeyLogin

func (a *App) SetupKeyLogin(ctx context.Context, h config.Host, createKey bool) (*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.

func (*App) ShowTab added in v0.4.0

func (a *App) ShowTab(ctx context.Context, f termapp.Found) error

ShowTab brings a session's found tab forward, after checking its process is still on that tab.

func (*App) Skill

func (a *App) Skill(ctx context.Context, files map[string][]byte, bin string) SkillReport

Skill reports the skill copies and rules against files (this build's rendering).

func (*App) Specs

func (a *App) Specs() []agent.Spec

Specs returns the enabled modules' Specs.

func (*App) StartPush

func (a *App) StartPush(ctx context.Context, inv *Inventory, e Entry, to config.Host, target agent.ID, opt move.Options) (*Push, error)

StartPush connects to hopsesh on another machine and has it plan receiving a session from this machine, in its own agent or (target) another. Nothing changes until Commit.

func (*App) StatusCachedAt added in v0.7.0

func (a *App) StatusCachedAt() time.Time

StatusCachedAt is when what MachineStatuses read last was written (zero: never), for a caller that keeps a CachedOnly result until it changes.

func (*App) StepOutcomeOf added in v0.4.0

func (a *App) StepOutcomeOf(id string) (*StepOutcome, error)

StepOutcomeOf is a written step's outcome once its terminal wrote one (nil until then).

func (*App) TerminalApps added in v0.4.0

func (a *App) TerminalApps(ctx context.Context) []termapp.Info

TerminalApps lists the terminal apps hopsesh can open launches in here, and whether each is installed.

func (*App) TerminalByID added in v0.4.0

func (a *App) TerminalByID(id string) (termapp.Terminal, error)

TerminalByID is one of the terminal apps by its id.

func (*App) TestCloud added in v0.4.0

func (a *App) TestCloud(ctx context.Context, name string) (agent.CloudTest, error)

TestCloud probes a cloud through its module, read-only: the login and the driver's flags. The result is kept for a little while for the hand-off plans.

func (*App) Undo

func (a *App) Undo(ctx context.Context, match string, force bool) (*journal.Journal, error)

Undo reverses a journal: by id, by a session id it concerns, or the newest when match is "". Writes on other machines are undone over SSH. Unless force, it refuses when a file the operation wrote changed since (that later work would be lost).

func (*App) WaitChangedDir added in v0.6.2

func (a *App) WaitChangedDir(ctx context.Context, c *DirChange, interval time.Duration) error

WaitChangedDir waits until the open session's agent has moved it to the planned folder (the user typed c.InSession there), checking every interval until ctx ends.

func (*App) WatchLaunch added in v0.4.0

func (a *App) WatchLaunch(ctx context.Context, h termapp.Handle) (<-chan int, error)

WatchLaunch reports a launch's exit code once it ends (see termapp.Watcher): from hopsesh's own records, and -1 when its tab was closed first. It errors when the launch's terminal cannot watch (only iTerm2 with its Python API turned on can); callers then do without.

func (*App) WatchSessions added in v0.4.1

func (a *App) WatchSessions(ctx context.Context, changed func(), opts WatchOptions)

WatchSessions uses the same bounded directory watcher as the 0.5 runtime. Reconciliation still covers network filesystems, overflow, and missed events.

type Arrival added in v0.4.2

type Arrival struct {
	Operation string    `json:"operation"`
	Kind      string    `json:"kind"` // moved | continued | fetched | handoff | returned | continuation
	Fork      bool      `json:"fork,omitempty"`
	Machine   string    `json:"machine"`
	Agent     agent.ID  `json:"agent"`
	AgentName string    `json:"agentName"`
	At        time.Time `json:"at"`
}

Arrival is how this copy came to be where it is: moved or continued here from another place, brought back from a cloud, handed off, or moved back (returned) to a copy that had left. It is the moved copy's side of a Departure.

type BranchCandidate added in v0.4.0

type BranchCandidate struct {
	ID         string `json:"id"`
	Kind       string `json:"kind"` // BranchHandoff | BranchVendor
	Branch     string `json:"branch"`
	Repo       string `json:"repo,omitempty"`
	Checkout   string `json:"checkout"`
	Remote     string `json:"remote"`
	Cloud      string `json:"cloud"`
	CloudTitle string `json:"cloudTitle"`
	Session    string `json:"session,omitempty"`
	Title      string `json:"title,omitempty"`
	Source     string `json:"source"` // the journal of the hand-off or bring-back
	// Policy is the cloud's delete_branch for it (after-merge | on-undo | never).
	Policy string `json:"policy"`
	// Sha is where the branch is on the remote ("" : gone); Into, the default branch it was
	// checked against; Merged and By say whether and how its work is in it ("history": its
	// commit is in the default branch's history; "pull request #12": GitHub says so).
	Sha    string `json:"sha,omitempty"`
	Into   string `json:"into,omitempty"`
	Merged bool   `json:"merged"`
	By     string `json:"by,omitempty"`
	// Brought is when the cloud's work came here, when it did.
	Brought time.Time `json:"brought,omitzero"`
	// Offer: hopsesh offers to delete it now; Why says why (not), for people.
	Offer bool   `json:"offer"`
	Why   string `json:"why"`
}

BranchCandidate is a branch a hand-off or a bring-back left on a remote, and whether hopsesh offers to delete it now.

type BranchFacts added in v0.4.0

type BranchFacts struct {
	Exists bool   // on the remote
	Merged bool   // its work is in the default branch
	By     string // how that is known
	Into   string // the default branch
	Error  string // the remote could not be asked
}

BranchFacts are what git and the remote say about a candidate.

type Brought added in v0.4.0

type Brought struct {
	Journal    string `json:"journal"`
	Cloud      string `json:"cloud"`
	CloudTitle string `json:"cloudTitle"`
	Session    string `json:"session,omitempty"` // the cloud session's id
	URL        string `json:"url,omitempty"`
	Title      string `json:"title"`
	Agent      string `json:"agent"` // the agent it is in here
	Worktree   string `json:"worktree"`
	// Outcome is waiting, complete, partial, empty, or code (the code only).
	Outcome  string `json:"outcome"`
	Restored int    `json:"restored,omitempty"`
	Expected int    `json:"expected,omitempty"`
	Stated   bool   `json:"stated,omitempty"`
	// Check is how a copy with no stated count was checked (move.Checked*); Note, what the
	// user must do in the driver's terminal for the copy to be saved (while it waits).
	Check string `json:"check,omitempty"`
	Note  string `json:"note,omitempty"`
	// Branch is the branch the code is on here; Renamed, the cloud's own name for it.
	Branch   string `json:"branch,omitempty"`
	Renamed  string `json:"renamed,omitempty"`
	NoBranch bool   `json:"noBranch,omitempty"`
	// Command is what to run next: the driver's command while waiting, the command that
	// resumes the copy once it is here.
	Command string        `json:"command,omitempty"`
	Run     agent.Command `json:"run"`
	Key     string        `json:"key,omitempty"` // the copy here (agent/session)
	// Message is the outcome in words; Issue, the upstream problem it points to.
	Message  string `json:"message"`
	Issue    string `json:"issue,omitempty"`
	IssueRef string `json:"issueRef,omitempty"`
	MirrorOf string `json:"mirrorOf,omitempty"`
	// Written: hopsesh wrote the copy from what the driver brought as text, at Fidelity;
	// Changes sums up the code; Loss is what stayed in the cloud; Noun, what the cloud calls
	// its sessions.
	Written  bool     `json:"written,omitempty"`
	Fidelity string   `json:"fidelity,omitempty"`
	Changes  string   `json:"changes,omitempty"`
	Loss     []string `json:"loss,omitempty"`
	Noun     string   `json:"noun,omitempty"`
	Continue string   `json:"continue,omitempty"` // the agent to continue in now (id)
	// ContinueName is that agent's name.
	ContinueName string   `json:"continueName,omitempty"`
	Appended     bool     `json:"appended,omitempty"`
	Kept         bool     `json:"kept,omitempty"`
	Warnings     []string `json:"warnings,omitempty"`
}

Brought is a fetch from a cloud as every front end shows it (and the command line's --json prints it): waiting for the user's terminal, or what came back.

func BroughtOf added in v0.4.0

func BroughtOf(f *move.Fetch, agentName string) Brought

BroughtOf describes a fetch; agentName is the module's name ("Claude Code").

type Check added in v0.6.2

type Check struct {
	State  string `json:"state"`            // Check*
	Text   string `json:"text"`             // what it found, in a few words
	Reason string `json:"reason,omitempty"` // why it is not ok
	Fix    string `json:"fix,omitempty"`    // Fix*: what puts it right
}

Check is one thing hopsesh checked on a machine.

type CleanupResult added in v0.4.0

type CleanupResult struct {
	Journal string            `json:"journal"`
	Deleted []BranchCandidate `json:"deleted"`
	// Failed are the branches hopsesh did not delete, with why.
	Failed map[string]string `json:"failed,omitempty"`
}

CleanupResult is what deleting branches did.

type Cloud added in v0.4.0

type Cloud struct {
	Name      string   `json:"name"`
	Title     string   `json:"title"`
	Agent     agent.ID `json:"agent"`
	AgentName string   `json:"agentName"`
	Driver    string   `json:"driver"`
	Version   string   `json:"version,omitempty"` // the driver's version here
	// Tested: the driver's version is one the cloud was tested with.
	Tested bool   `json:"tested"`
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
	Hint   string `json:"hint,omitempty"`
	// Listable: the module can list this cloud's sessions; otherwise Sessions is 0 because
	// nothing was asked.
	Listable bool `json:"listable"`
	Sessions int  `json:"sessions"`
	// Partial: the vendor cannot list everything, so the sessions are the ones hopsesh
	// could find.
	Partial bool `json:"partial,omitempty"`
	// Fetchable: the module can bring this cloud's sessions here.
	Fetchable bool `json:"fetchable"`
	// Mirrors are local sessions the vendor mirrors (Remote Control), among Sessions.
	Mirrors int `json:"mirrors,omitempty"`
	// Allowed: the user allowed hopsesh to use this cloud.
	Allowed bool `json:"allowed"`
	// Noun is what the cloud calls its sessions ("task"); Limits, what hopsesh cannot reach
	// there; NeedsEnv: a hand-off runs in an environment the user picks (EnvHint says how to
	// make one).
	Noun     string   `json:"noun"`
	Limits   []string `json:"limits,omitempty"`
	NeedsEnv bool     `json:"needsEnv,omitempty"`
	EnvHint  string   `json:"envHint,omitempty"`
}

Cloud is a vendor cloud as a scan found it. Clouds are reached from this machine only: the vendor's login lives with the driver here.

type Companion added in v0.8.0

type Companion struct {
	Name string `json:"name"`
	Page string `json:"page"`
	// Supported: MyCNC Host runs on this kind of machine (macOS).
	Supported bool `json:"supported"`
	// Installed: its presence file is here (MyCNC Host writes it at every launch and
	// removes it only when uninstalled); Running: its socket answers a ping.
	Installed bool   `json:"installed"`
	Running   bool   `json:"running"`
	Version   string `json:"version,omitempty"`
}

Companion is MyCNC Host on this machine, as far as hopsesh can tell.

func DetectCompanion added in v0.8.0

func DetectCompanion() Companion

DetectCompanion reads MyCNC Host's presence file and pings its socket.

type Copy

type Copy struct {
	Profile    *agent.RuntimeProfile `json:"profile,omitempty"`
	Machine    string                `json:"machine"`
	Agent      agent.ID              `json:"agent"`
	AgentName  string                `json:"agentName"`
	Key        agent.SessionKey      `json:"key"`
	Local      bool                  `json:"local,omitempty"`
	LastActive time.Time             `json:"lastActive"`
	LeftBehind bool                  `json:"leftBehind,omitempty"` // moved on since (Entry.MovedOn)
	Live       bool                  `json:"live,omitempty"`
	Newest     bool                  `json:"newest,omitempty"`
	// contains filtered or unexported fields
}

Copy is one copy of a session that exists in several places or agents.

type Counters added in v0.4.4

type Counters struct {
	Scans           int64 `json:"scans"`
	ContentReads    int64 `json:"contentReads"`    // transcripts and sidecars opened
	TranscriptReads int64 `json:"transcriptReads"` // native transcripts read for movement
}

Counters is the work scans did in this process, for resource budgets in tests and the idle benchmark: they count work instead of timing it, so they do not flake.

func ResourceCounters added in v0.4.4

func ResourceCounters() Counters

type DirChange added in v0.6.2

type DirChange struct {
	Entry Entry         `json:"entry"`
	Plan  agent.DirPlan `json:"plan"`
	// Open: the session is open now. InSession is then what to type in it (the agent's own
	// folder change, which keeps the session), "" when the agent has none; StopFirst: hopsesh
	// quits it first (--stop-local).
	Open      bool   `json:"open"`
	InSession string `json:"inSession,omitempty"`
	StopFirst bool   `json:"stopFirst,omitempty"`
	// contains filtered or unexported fields
}

DirChange is a planned folder change.

type DirOptions added in v0.6.2

type DirOptions struct {
	OtherRepo bool // allow a folder that is not a checkout of the session's repository
	StopLocal bool // quit the session first when it is open
}

DirOptions are the choices of a folder change.

type Entry

type Entry struct {
	Cached             bool              `json:"cached,omitempty"`
	NativeRelationship bool              `json:"nativeRelationship,omitempty"` // verified during this scan; no persisted family receipt
	Returns            []ReturnCandidate `json:"returns,omitempty"`
	Movement           *MovementNotice   `json:"movement,omitempty"`
	// Departure is where this copy's branch went since, from lineage (whether or not
	// movement notices are on): this copy was moved on.
	Departure *MovementNotice `json:"departure,omitempty"`
	// Arrival is how this copy came here (when it has not moved on since).
	Arrival    *Arrival  `json:"arrival,omitempty"`
	ObservedAt time.Time `json:"observedAt,omitempty"`
	// Location is where the session lives. Machine is the machine whose files hold it, or
	// the cloud's name for a cloud session (so "claude-cloud:<id>" names one).
	Location          agent.Location    `json:"location"`
	Machine           string            `json:"machine"`
	Agent             agent.ID          `json:"agent"`
	AgentName         string            `json:"agentName"`
	Session           agent.Summary     `json:"session"`
	Live              agent.LiveInfo    `json:"live"`
	Git               *repos.GitState   `json:"git,omitempty"`
	GitError          string            `json:"gitError,omitempty"` // the checkout could not be read
	CanArchiveLineage bool              `json:"canArchiveLineage,omitempty"`
	LineageError      string            `json:"lineageError,omitempty"`
	Lineage           *lineage.Manifest `json:"lineage,omitempty"`
	// Cloud is a cloud session as its cloud listed it.
	Cloud *agent.CloudSession `json:"cloud,omitempty"`
	// Checkout is a cloud session's repository checked out here, when known.
	Checkout string `json:"checkout,omitempty"`
	// Original is the session a cloud session was handed off from ("machine:agent/id").
	Original string                `json:"original,omitempty"`
	Profile  *agent.RuntimeProfile `json:"profile,omitempty"`
	// SizeUnit is what Session.Size counts: "" for bytes, SizeMessages for an agent that
	// keeps its sessions in a database (agent.VirtualSessions).
	SizeUnit string `json:"sizeUnit,omitempty"`
}

Entry is one session at one location: a machine, or a cloud.

func (Entry) MovedOn added in v0.4.2

func (e Entry) MovedOn() bool

MovedOn reports whether this copy was left behind by a move: lineage records a departure, or, for a copy without lineage, an older hopsesh labelled its title.

func (Entry) Status

func (e Entry) Status() string

Status is a session's state in words: "live …", where it went ("moved to studio"), "ended", or a cloud session's state ("running", "state unknown").

type FolderMove added in v0.5.0

type FolderMove struct {
	ID    string   `json:"id"`
	Name  string   `json:"name"`
	Agent agent.ID `json:"agent"`
	From  string   `json:"from"`
	To    string   `json:"to"`
}

FolderMove is one account folder hopsesh keeps in its state folder, and where it goes.

type Group

type Group struct {
	Identity string `json:"identity"`
	Name     string `json:"name"`
	Remote   string `json:"remote,omitempty"`
	Local    string `json:"localCheckout,omitempty"` // a checkout on this machine
	Items    []Item `json:"items"`
}

Group is sessions of one repository.

type HandoffTarget added in v0.4.0

type HandoffTarget struct {
	Cloud string `json:"cloud"`
	Title string `json:"title"`
	Agent string `json:"agent"` // the agent that runs there
	OK    bool   `json:"ok"`
	Why   string `json:"why,omitempty"` // why not, in words
	// Note says what the cloud gets ("a briefing and the code on a branch"), and what it
	// cannot do here.
	Note   string `json:"note,omitempty"`
	Bundle bool   `json:"bundle,omitempty"` // it goes as an upload (the remote is not one the cloud clones)
	// Limits are what hopsesh cannot reach in that cloud (agent.Cloud.Limits), said beside it.
	Limits []string `json:"limits,omitempty"`
}

HandoffTarget is a cloud a session can be handed off to, or the reason it cannot.

type Hop added in v0.4.0

type Hop struct {
	Journal string          `json:"journal"`
	Time    time.Time       `json:"time"`
	Title   string          `json:"title"`
	From    string          `json:"from"`
	Session agent.SessionID `json:"session"`
	To      string          `json:"to"`
	ToTitle string          `json:"toTitle"`
	Fetch   string          `json:"fetch,omitempty"`
	Handoff string          `json:"handoff,omitempty"`
	Options move.Options    `json:"options"`
	Result  move.HopResult  `json:"result"`
}

Hop is the record of a hop, kept in the state folder: its legs' journals, the hand-off's choices, and where it stands (a hop whose first leg waits for the user's terminal goes on with ContinueHop).

type Inventory

type Inventory struct {
	Discovering bool       `json:"discovering,omitempty"`
	Machines    []*Machine `json:"machines"`
	Clouds      []*Cloud   `json:"clouds"`
	Entries     []Entry    `json:"entries"`
	// Adopted are sessions brought from a cloud that this scan found and adopted (their
	// driver wrote them since); Waiting, the ones still waiting for it.
	Adopted []*move.Fetch `json:"adopted,omitempty"`
	Waiting []*move.Fetch `json:"waiting,omitempty"`
}

Inventory is the result of a scan.

func MergeDiscovery added in v0.4.1

func MergeDiscovery(old *Inventory, u ScanUpdate) *Inventory

MergeDiscovery removes unseen rows only after a successful complete source scan.

func (*Inventory) AccountGroups added in v0.4.1

func (inv *Inventory) AccountGroups() []Group

AccountGroups groups sessions by the account that ran them (OwnerOf) within each root: a root signed in to another account before keeps that account's sessions apart, and sessions whose account was not recorded are not filed under the root's sign-in.

func (*Inventory) Close

func (inv *Inventory) Close()

Close ends every connection the scan opened.

func (*Inventory) Cloud added in v0.4.0

func (inv *Inventory) Cloud(name string) *Cloud

Cloud returns a scanned cloud by name.

func (*Inventory) CloudEntry added in v0.4.0

func (inv *Inventory) CloudEntry(a *App, cloud string, id agent.SessionID) (Entry, error)

CloudEntry is a cloud session as an entry: the scanned one, or, for an id the scan did not list (a link pasted on the command line), one made from the id.

func (*Inventory) FamilyGroups added in v0.4.0

func (inv *Inventory) FamilyGroups() []Group

FamilyGroups uses the same verified relationships as the desktop. Copies already combined by Items count once; unrelated titles remain separate.

func (*Inventory) Find

func (inv *Inventory) Find(r Ref) (Entry, error)

Find returns the session a reference names. Without a machine, the newest copy of the session is chosen.

func (*Inventory) Groups

func (inv *Inventory) Groups(localRoots []string) []Group

Groups arranges sessions by repository; sessions outside git are in a group with no identity. localRoots are searched for checkouts on this machine.

func (*Inventory) Items

func (inv *Inventory) Items() []Item

Items combines only verified copies. Unknown native identities remain scoped to their endpoint, profile and installation, even when titles or IDs match.

func (*Inventory) Local

func (inv *Inventory) Local() *Machine

Local returns this machine.

func (*Inventory) Logins added in v0.4.5

func (inv *Inventory) Logins() Logins

Logins collects the profiles' sign-ins, for OwnerOf.

func (*Inventory) Machine

func (inv *Inventory) Machine(name string) *Machine

Machine returns a scanned machine by name.

func (*Inventory) Relationships added in v0.4.0

func (inv *Inventory) Relationships() map[string]Relationship

func (*Inventory) Usage added in v0.6.0

func (inv *Inventory) Usage(machine string) []AgentUsage

Usage is what each agent's sessions on machine take, largest first.

type Item

type Item struct {
	Entry  Entry  `json:"entry"`
	Copies []Copy `json:"copies,omitempty"`
}

Item is one session, shown as its newest copy, with every copy when there are several.

type KeyLogin

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.

type Launch added in v0.4.0

type Launch struct {
	Kind   termapp.Kind
	Run    agent.Command
	Key    agent.SessionKey // the session a KindSession launch resumes
	Labels termapp.Labels
}

Launch is a command to open in a terminal app.

type LedgerRecord added in v0.5.0

type LedgerRecord struct {
	Agent   agent.ID         `json:"agent"`
	Root    string           `json:"root"`
	Session string           `json:"session"`
	Runs    []agent.OwnerRun `json:"runs"`
}

LedgerRecord is one session's record of the accounts it ran under, as hopsesh on its machine kept it.

type Login added in v0.5.0

type Login struct {
	Terms *pty.Manager
	// contains filtered or unexported fields
}

Login is hopsesh serve's own state: it runs in the user's login session, where the sign-ins and apps are, and owns the terminals it runs for hopsesh on other machines, so they outlive the connections that show them.

func (*Login) List added in v0.5.0

func (l *Login) List() []peer.Terminal

List returns its terminals, oldest first.

type Logins added in v0.4.5

type Logins map[string][]*agent.RuntimeProfile

Logins maps the account fingerprints the registered profiles are signed in to now to those profiles, on every machine the inventory reached (a few installs: cheap to build per session).

func (Logins) OwnerOf added in v0.4.5

func (l Logins) OwnerOf(e Entry) SessionOwner

OwnerOf is the account that ran e, as its records say, matched to a profile signed in to it now for the email. Several profiles signed in to the same fingerprint with different emails, or a run naming only a shared organisation, leave the email unknown rather than guess.

type Machine

type Machine struct {
	Kind        agent.LocationKind `json:"kind"` // always agent.AtMachine (clouds are in Inventory.Clouds)
	Name        string             `json:"name"`
	Destination string             `json:"destination,omitempty"`
	Local       bool               `json:"local"`
	Status      string             `json:"status"`
	Error       string             `json:"error,omitempty"`
	Hint        string             `json:"hint,omitempty"`
	OS          string             `json:"os,omitempty"`
	Phase       string             `json:"phase,omitempty"`
	CheckedAt   time.Time          `json:"checkedAt,omitempty"`
	Agents      []AgentState       `json:"agents"`
	// Hopsesh is the version of hopsesh installed there ("" when none was found).
	Hopsesh string `json:"hopsesh,omitempty"`
	// Presence is how hopsesh works with the machine (see Presence*); PresenceWhy says
	// why, when it is not PresenceLogin.
	Presence    string `json:"presence,omitempty"`
	PresenceWhy string `json:"presenceWhy,omitempty"`
	// contains filtered or unexported fields
}

Machine is a scanned machine.

func (*Machine) HopseshVersion added in v0.6.2

func (m *Machine) HopseshVersion() string

HopseshVersion is hopsesh's version on m: this program's own on this machine.

func (*Machine) Host

func (m *Machine) Host() *host.Machine

Host returns the machine's connection (nil when it was not reached).

func (*Machine) Install

func (m *Machine) Install(id agent.ID) (agent.Install, bool)

Install returns an agent's install there.

func (*Machine) InstallProfile added in v0.4.0

func (m *Machine) InstallProfile(id agent.ID, profile string) (agent.Install, bool)

InstallProfile selects the exact registered root. An empty selector means the default.

type MachineSetup added in v0.5.0

type MachineSetup struct {
	Machine string           `json:"machine"`
	Version string           `json:"version"`
	Program string           `json:"program"`
	Service loginsvc.Status  `json:"service"`
	Login   bool             `json:"login"` // hopsesh answers from the login session there now
	Steps   []SetupStep      `json:"steps"`
	Hello   *peer.HelloReply `json:"hello,omitempty"`
}

MachineSetup is what setting hopsesh up on a machine did.

type MachineStatus added in v0.6.2

type MachineStatus struct {
	Machine string `json:"machine"`
	Local   bool   `json:"local"`
	// Version is hopsesh's version there ("" when it is not installed); Newest is the
	// newest on any of your machines, and NewestOn the machine that has it.
	Version   string `json:"version,omitempty"`
	Newest    string `json:"newest,omitempty"`
	NewestOn  string `json:"newestOn,omitempty"`
	Reach     Check  `json:"reach"`
	Hopsesh   Check  `json:"hopsesh"`
	Login     Check  `json:"login"`
	Receiving Check  `json:"receiving"`
	CLI       Check  `json:"cli"`
	// Copies is whether every hopsesh there is one version (Installs lists them); nil
	// Installs: not read yet.
	Copies   Check          `json:"copies"`
	Installs *installs.List `json:"installs,omitempty"`
	Agents   []AgentSetup   `json:"agents"`
	// Todo counts the checks that have a fix; Total every check there is.
	Todo  int `json:"todo"`
	Total int `json:"total"`
	// CheckedAt is when the machine was reached; DetailsAt when its hooks, skill and
	// command were read (they are read less often). Stale: they are older than
	// statusStale and could not be read again, so they are shown as unknown.
	CheckedAt time.Time `json:"checkedAt"`
	DetailsAt time.Time `json:"detailsAt,omitempty"`
	Stale     bool      `json:"stale,omitempty"`
}

MachineStatus is what hopsesh can do on one machine.

func (MachineStatus) AgentFolder added in v0.7.0

func (s MachineStatus) AgentFolder(id agent.ID, profile string) (AgentSetup, bool)

AgentFolder is agent id's folder for profile as last read: the folder with exactly that profile, else the agent's only folder there. Never the default folder of several: its hook would vouch for a folder it doesn't cover.

func (MachineStatus) CanBlock added in v0.6.2

func (s MachineStatus) CanBlock(id agent.ID, profile string) (bool, []string)

CanBlock reports whether a session of agent (in profile) moved from this machine can block or warn its original there, and why not (OriginalProtection: only a yes can).

func (MachineStatus) OriginalProtection added in v0.7.0

func (s MachineStatus) OriginalProtection(id agent.ID, profile string) (verdict, why, fix string)

OriginalProtection is whether hopsesh on s.Machine blocks or warns a copy of agent id in profile left there by a move, as its hooks were last read (nothing is read now): yes, no or unknown, why not in a few words, and the Fix* that puts it right. Only that agent folder's hook counts, or the agent's only folder there: another folder's hook says nothing about this copy. A hook waiting for approval doesn't block yet.

type MovementHookStatus added in v0.4.0

type MovementHookStatus struct {
	Agent        agent.ID `json:"agent"`
	Profile      string   `json:"profile"`
	ProfileLabel string   `json:"profileLabel,omitempty"`
	Path         string   `json:"path,omitempty"`
	Installed    bool     `json:"installed"`
	Enabled      bool     `json:"enabled"`
	Supported    bool     `json:"supported"`
	Reason       string   `json:"reason,omitempty"`
	Evidence     string   `json:"evidence,omitempty"`
	// Trust is the agent's own answer for agents that skip untrusted hooks (Codex): an
	// installed hook delivers nothing until the user trusts it there.
	Trust *agent.HookTrust `json:"trust,omitempty"`
	// Result is this item's outcome (HookInstalled ... HookAbsent); Reason says why for a
	// failed or unsupported one. One item's failure never hides the others.
	Result string `json:"result,omitempty"`
	// What the hook covers here: the agent's version, whether that is its CLI or the
	// runtime bundled in its desktop app (agent.RuntimeApp), and the desktop app's name.
	Version string `json:"version,omitempty"`
	Runtime string `json:"runtime,omitempty"`
	CLI     bool   `json:"cli,omitempty"`
	App     string `json:"app,omitempty"`
	// Plugin: the hook is a folder hopsesh owns whole that the agent loads as a plugin
	// (OpenCode), not entries in the agent's settings. Outdated: it is installed but holds
	// files other than this hopsesh's (an older hopsesh's, or edited); an install replaces
	// them.
	Plugin   bool `json:"plugin,omitempty"`
	Outdated bool `json:"outdated,omitempty"`
}

MovementHookStatus reports installation, not vendor trust or actual delivery. Vendor/session/project policy can still disable an installed hook.

type MovementNotice added in v0.4.0

type MovementNotice struct {
	ProfileLabel string   `json:"profileLabel,omitempty"`
	Operation    string   `json:"operation"`
	Status       string   `json:"status"`
	Text         string   `json:"text"`
	Machine      string   `json:"machine"`
	Agent        agent.ID `json:"agent"`
	AgentName    string   `json:"agentName"`
	// Cloud is the destination cloud's title, when the session went to a cloud.
	Cloud     string    `json:"cloud,omitempty"`
	Key       string    `json:"key"`
	Profile   string    `json:"profile"`
	CheckedAt time.Time `json:"checkedAt"`
	Delivery  string    `json:"delivery"`
	// At is when the move left this copy.
	At time.Time `json:"at,omitzero"`
	// SourceChanged: this copy gained work after the move (its transcript grew past where
	// the move read it, and it was active well after the move). Its listing alone tells,
	// so it is known for a copy on another machine too, which a scan never reads whole.
	// SourceChangedAt is its last activity.
	SourceChanged   bool      `json:"sourceChanged,omitempty"`
	SourceChangedAt time.Time `json:"sourceChangedAt,omitzero"`
}

type MovementNoticeClaim added in v0.4.0

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

MovementNoticeClaim is an attempted delivery. Only Written, called after a complete successful stdout write, records supplied-to-hook evidence. Attempts never suppress retries; the token fences concurrent/resumed attempts.

func (*MovementNoticeClaim) Written added in v0.4.0

func (c *MovementNoticeClaim) Written(ctx context.Context) error

type MovementNoticeDetails added in v0.4.0

type MovementNoticeDetails struct {
	Key       agent.SessionKey
	Text      string
	Summary   string // where the session went, without the advice (for a block reason)
	Operation string
	Status    string
}

MovementNoticeDetails keeps delivery identity and text in the same validated lookup snapshot. Receipt writers must use this source Key and Operation/Status, not reread the scan cache, which may be absent, older, or concurrently refreshed. Empty Text means no notice; a successfully resolved Key is still returned.

type MovementNoticeIdentity added in v0.4.0

type MovementNoticeIdentity struct {
	Operation string
	Status    string
}

MovementNoticeIdentity comes from the same validated lookup as the notice text, or from the inventory notice itself. Delivery never reads scan caches.

type OwnerRecord added in v0.8.0

type OwnerRecord struct {
	Owner    string           `json:"owner"`
	PID      int              `json:"pid"`
	Started  string           `json:"started,omitempty"`
	Session  agent.SessionKey `json:"session"`
	Endpoint string           `json:"endpoint,omitempty"`
	// Stop is how to ask the owner to stop it, in its own words (shown, never run).
	Stop string `json:"stop,omitempty"`
}

OwnerRecord is one record.

func OwnerOf added in v0.8.0

func OwnerOf(records map[agent.SessionKey][]OwnerRecord, e Entry) *OwnerRecord

OwnerOf is the program running e, from its owner records: a record counts only while its process is one of those the agent says have the session open (when the agent says), so a reused process id never names an owner.

type Pasted added in v0.4.0

type Pasted struct {
	Cloud    string          `json:"cloud"`
	ID       agent.SessionID `json:"id"`
	Repo     string          `json:"repo,omitempty"`
	Checkout string          `json:"checkout,omitempty"`
	Title    string          `json:"title,omitempty"`
	Time     time.Time       `json:"time"`
}

Pasted is a cloud session the user named by its link or id ("Paste a link…"), which hopsesh then lists with what it knows.

type PeerConn

type PeerConn struct {
	Out    io.Reader
	In     io.Writer
	Close  func()
	Stderr func() string
}

PeerConn is a connection to hopsesh on another machine: its output, its input, and how to end it (stderr is what it reported, for errors).

type Protection added in v0.5.0

type Protection struct {
	Machine string               `json:"machine"`
	Local   bool                 `json:"local"`
	Version string               `json:"version"`
	Program string               `json:"program,omitempty"` // the hopsesh command the hooks run
	Command bool                 `json:"command"`           // it is there and runs
	Hooks   []MovementHookStatus `json:"hooks"`
	Skill   SkillReport          `json:"skill"`
	Checked time.Time            `json:"checked"`
	Error   string               `json:"error,omitempty"`
}

Protection is what keeps a machine's originals protected and its agents knowing hopsesh: the hopsesh command, the protection hook in each agent's folders, and the skill. One model for this machine and, through hopsesh there, every other one.

type Push

type Push struct {
	Plan   *move.Plan
	Peer   peer.HelloReply
	Pushed string // the branch was pushed first ("" when not)
	// contains filtered or unexported fields
}

Push is a session on this machine on its way to another machine's hopsesh: planned there, not yet carried out.

func (*Push) Close

func (p *Push) Close()

Close ends the connection (an uncommitted push changes nothing).

func (*Push) Commit

func (p *Push) Commit(ctx context.Context) (*PushResult, error)

Commit carries out the push: the other machine installs or converts the session, then this machine records, in its own journal, what changes for its copy (its lineage).

type PushResult

type PushResult struct {
	Result  *move.Result `json:"result"`
	Journal string       `json:"journal"` // undo here undoes both machines
	Machine string       `json:"machine"`
	Pushed  string       `json:"pushed,omitempty"`
}

PushResult is a finished push.

type Ref

type Ref struct {
	Machine string
	Agent   agent.ID
	Profile string
	Query   string
}

Ref names a session: [machine:][agent/]<id, id prefix or title>.

func ParseRef

func ParseRef(s string) Ref

ParseRef reads a session reference.

type Relationship added in v0.4.0

type Relationship struct {
	Family     string   `json:"family"`
	Branch     string   `json:"branch"`
	Parent     string   `json:"parent,omitempty"`
	Name       string   `json:"name"`
	BranchName string   `json:"branchName"`
	Depth      int      `json:"depth"`
	Evidence   string   `json:"evidence"`
	Issue      string   `json:"issue,omitempty"`
	Ancestors  []string `json:"ancestors,omitempty"`
	Branches   int      `json:"branches"`
	// Former is the ID 0.4.5 and earlier gave an unlinked family (it changed with the
	// profile's sign-in), so a name saved for it still applies.
	Former string `json:"-"`
}

Relationship is presentation metadata. Only verified lineage provides a shared family ID; an untracked native copy gets its own namespaced identity. It is never an append/merge authority and scanning does not persist it.

type Release added in v0.4.2

type Release struct {
	Operation string    `json:"operation"`
	At        time.Time `json:"at"`
}

Release is the user's choice to continue one original despite its movement.

type RemoteDefault added in v0.7.0

type RemoteDefault struct {
	Agent        agent.ID `json:"agent"`
	AgentName    string   `json:"agentName"`
	Profile      string   `json:"profile,omitempty"`
	ProfileLabel string   `json:"profileLabel,omitempty"`
	Path         string   `json:"path,omitempty"`
	On           bool     `json:"on"`
	Reason       string   `json:"reason,omitempty"` // why it can't be set in this folder
	Error        string   `json:"error,omitempty"`
}

RemoteDefault is one agent folder's own "start Remote Control for every session" setting (Claude Code's remoteControlAtStartup in its user settings).

type RemoteDefaults added in v0.7.0

type RemoteDefaults struct {
	Machine string          `json:"machine"`
	Local   bool            `json:"local"`
	Folders []RemoteDefault `json:"folders"`
	Error   string          `json:"error,omitempty"`
}

RemoteDefaults are a machine's agent folders' Remote Control defaults.

type RemoteDir added in v0.6.3

type RemoteDir struct {
	Machine string
	Change  DirChange // as hopsesh there planned it
	// contains filtered or unexported fields
}

RemoteDir is a folder change of a session on another machine, planned and carried out by hopsesh there (it writes nothing there over SSH itself): this machine keeps a journal that names the one hopsesh there keeps, so hopsesh undo here reverses it there.

func (*RemoteDir) Apply added in v0.6.3

func (r *RemoteDir) Apply(ctx context.Context) (string, error)

Apply has hopsesh there carry out the change, and records here which journal it keeps.

func (*RemoteDir) Close added in v0.6.3

func (r *RemoteDir) Close()

Close ends the conversation with hopsesh there.

func (*RemoteDir) Wait added in v0.6.3

func (r *RemoteDir) Wait(ctx context.Context, d time.Duration) error

Wait has hopsesh there wait, at most d, until the open session's agent has moved it (the user typed Change.InSession in it there).

type RepoEnv added in v0.4.0

type RepoEnv struct {
	Repo string `json:"repo"`
	Env  string `json:"env,omitempty"` // configured ("": the plan asks)
	// Unsupported says why the cloud cannot take the repository ("" when it can).
	Unsupported string `json:"unsupported,omitempty"`
}

RepoEnv is one repository's environment in a cloud, for the Machines page's table.

type ReturnCandidate added in v0.4.0

type ReturnCandidate struct {
	Replica      string   `json:"replica"`
	Machine      string   `json:"machine"`
	Agent        agent.ID `json:"agent"`
	AgentName    string   `json:"agentName"`
	Profile      string   `json:"profile"`
	ProfileLabel string   `json:"profileLabel"`
	Title        string   `json:"title,omitempty"`
	Key          string   `json:"key"`
	Status       string   `json:"status"`
	Reason       string   `json:"reason"`
	Local        bool     `json:"local"`
}

type RoleInfo added in v0.4.2

type RoleInfo struct {
	Kind  string `json:"kind"`  // blocked | moved-out | diverged | forked-out | moved | returned | fork
	Glyph string `json:"glyph"` // ◆ ◇ ! ⑂ ● ↩
	Word  string `json:"word"`  // Moved to Codex, Moved from Claude Code, Moved back from Codex, …
	Line  string `json:"line"`  // where it went or came from, and the protection
}

RoleInfo is what a copy is in its session's journey, in the words and glyphs the command line and terminal UI share with the app (always a word with the glyph).

type RuleState

type RuleState struct {
	Agent string `json:"agent"` // as people read it: "OpenCode (Work)"
	// AgentID and Profile name the agent folder (Profile "" the default one).
	AgentID agent.ID `json:"agentId"`
	Profile string   `json:"profile,omitempty"`
	Path    string   `json:"path"`
	Present bool     `json:"present"`
}

RuleState is one agent's approval rules.

type RunHere added in v0.4.0

type RunHere func(ctx context.Context, run agent.Command) error

RunHere runs a driver's command in this front end's own terminal and waits for it (the teleport a hop's first leg needs); nil: the front end opens it itself, and the hop waits.

type ScanOptions

type ScanOptions struct {
	NoCache       bool             // fresh action validation never reads cached summaries
	Progress      func(ScanUpdate) // serialized immutable batches; never owns transports
	ForceAccounts bool             // explicitly refresh public login metadata
	Hosts         []string         // only these machines and clouds ("" or none: every allowed one)
	NoLocal       bool             // leave this machine out
	SkipGit       bool             // no git state (faster)
	// GitFor, when set, limits the git probe to the folders of the sessions it accepts (the
	// others get no git state); see App.GitFor. On another machine it also chooses the
	// native forks that are verified (see remoteForks) and the moved copies that are observed
	// (see enrichMovement).
	GitFor func(Entry) bool
}

ScanOptions narrow a scan.

type ScanUpdate added in v0.4.1

type ScanUpdate struct {
	Machine  *Machine
	Clouds   []*Cloud
	Entries  []Entry
	Complete bool
	Listed   bool // summaries and lineage are ready, before slower enrichment
}

ScanUpdate describes one independently progressing source. Preliminary rows have unknown presence and require fresh validation before an action.

type SessionOwner added in v0.4.5

type SessionOwner struct {
	// Recorded is whether the account was recorded: by the agent (Claude Code's per-run
	// organisation and Remote Control records, Codex's session creator) or by hopsesh's
	// prompt hook. Without it the account that ran the session is not known.
	Recorded bool `json:"recorded"`
	// Email is the latest recorded account's email, when a registered profile is signed in
	// to exactly that account; "" for a recorded account no profile is signed in to now.
	Email string `json:"email,omitempty"`
	// Profile is the name of the profile signed in to it, when that is not the session's
	// own root.
	Profile string `json:"profile,omitempty"`
	// Current is whether the session's own root is signed in to its account now.
	Current bool `json:"current,omitempty"`
	// Key is a stable fingerprint of the latest recorded account (the same after any
	// sign-in change), for grouping and saved filters.
	Key string `json:"key,omitempty"`
	// Earlier names the other accounts it ran under before, when it changed accounts.
	Earlier string `json:"earlier,omitempty"`
	// Pending: its folder's sign-in has not been checked yet, so whether it ran under
	// another account is not known yet either.
	Pending bool `json:"pending,omitempty"`
}

SessionOwner is the account that ran a session, as far as the agent recorded it. A profile's sign-in only says who is signed in to that root now: a root that was signed in to another account before holds that account's sessions too, so a session is never labelled with its root's sign-in unless its own record matches it.

type SetupStep added in v0.5.0

type SetupStep struct {
	Name   string `json:"name"`
	State  string `json:"state"` // done, skipped, waiting, failed
	Detail string `json:"detail,omitempty"`
}

SetupStep is one step of setting hopsesh up on a machine.

type SkillCopy

type SkillCopy struct {
	Dir    string                `json:"dir"`
	Agents []string              `json:"agents"` // display names
	Status integrate.SkillStatus `json:"status"`
}

SkillCopy is one place the skill goes, shared by every agent that reads that folder.

type SkillFiles added in v0.5.0

type SkillFiles func(bin string) map[string][]byte

SkillFiles renders the hopsesh skill for a hopsesh program (bin); set by the front end (the skill's words live there).

type SkillReport

type SkillReport struct {
	Copies []SkillCopy `json:"copies"`
	Rules  []RuleState `json:"rules"`
	InSync bool        `json:"inSync"` // every copy is current
	State  string      `json:"state"`  // the worst copy's state
}

SkillReport is the skill and rules across every agent installed here.

type StatusOptions added in v0.6.2

type StatusOptions struct {
	// Refresh reads every machine's hooks, skill and command again, however recent.
	Refresh bool
	// CachedOnly never reads them: what was read last, as it is (for a quick listing).
	CachedOnly bool
}

StatusOptions control MachineStatuses.

type StepOutcome added in v0.4.0

type StepOutcome struct {
	Session   *agent.CloudSession `json:"session,omitempty"`
	Error     string              `json:"error,omitempty"`
	NoSession bool                `json:"noSession,omitempty"`
	Code      int                 `json:"code"`
}

StepOutcome is how a step handed to a terminal ended: the session it started, or what stopped it (NoSession: it ended without a session or a refusal, so a pasted link may still come).

type TerminalIO added in v0.4.0

type TerminalIO struct {
	In       io.Reader
	Out, Err io.Writer
	// Labels: Out is a terminal (not a pipe, not JSON), so labels may be printed.
	Labels bool
	// Hold keeps the tab open once the agent ends, as a shell (a terminal whose tab
	// closes with its command).
	Hold   bool
	Getenv func(string) string
}

TerminalIO is the terminal hopsesh's verb runs in.

type UpdatePlan added in v0.7.0

type UpdatePlan struct {
	Machine  string          `json:"machine"`
	Version  string          `json:"version"` // this hopsesh's, which it brings
	Installs installs.List   `json:"installs"`
	Steps    []installs.Step `json:"steps"`
	Restarts bool            `json:"restarts"` // hopsesh restarts in the login session there
	Ends     int             `json:"ends"`     // terminals hopsesh runs there that the restart ends
}

UpdatePlan is what updating hopsesh on a machine would do, for the dialog that asks.

type WatchOptions added in v0.4.4

type WatchOptions struct {
	// Active reports whether anyone is looking (nil: always). While nobody is, the
	// watcher holds no watches at all: every file event costs the process tens of
	// wakeups, and agents write their sessions many times a second. The front end's own
	// background refresh covers that time; looking again re-arms and refreshes once.
	Active func() bool
	// Current returns the app whose configuration names the roots (nil: this one).
	Current func() *App
}

WatchOptions tune WatchSessions for a front end.

Jump to

Keyboard shortcuts

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