install

package
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 36 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 install implements stagent's ledger-based installer: `install` (layout + manifest; after an update, the running daemon and the shell wrapper blocks already in place), `integrate` (harness hooks, shell wrappers, login service; planned as unified diffs before anything is written), `doctor` (state report, orphans) and `uninstall` (stop / unhook / purge). The app runs these over plain SSH exec and parses their JSON (PROTOCOL.md).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(cmd string, args []string) int

Main runs one installer command and returns the exit code.

Types

type Change

type Change struct {
	ID     string `json:"id"`
	Target string `json:"target"`
	// Action is create | modify | delete, or skip for a target that could
	// not be planned (Error says why).
	Action  string `json:"action"`
	Summary string `json:"summary"`
	Diff    string `json:"diff"`
	Error   string `json:"error,omitempty"`
	// ErrorCode classifies Error for the app (errorCode).
	ErrorCode string `json:"error_code,omitempty"`
	// contains filtered or unexported fields
}

Change is one entry of `integrate` output (and of the removals unhook performs).

type ConfigEntry

type ConfigEntry struct {
	ID       string `json:"id"`
	Path     string `json:"path"`
	Owned    bool   `json:"owned,omitempty"`
	Created  bool   `json:"created"` // the file did not exist before
	Identify string `json:"identify"`

	SHA256Before string `json:"sha256_before,omitempty"`
	SHA256After  string `json:"sha256_after"`
	// Backup restores the file to its pre-stagent content. Cleared when the
	// file was changed by someone else between two of our edits.
	Backup string `json:"backup,omitempty"`
	// CreatedDirs are the missing parent directories our write of the file
	// created; deleting the file also deletes those that are empty again.
	CreatedDirs []string `json:"created_dirs,omitempty"`

	// CreatedContainers are JSON pointers (e.g. "/hooks/Stop") of objects
	// and arrays we added; they are removed again once empty.
	CreatedContainers []string   `json:"created_containers,omitempty"`
	TOMLEdits         []TOMLEdit `json:"toml_edits,omitempty"`
	ModifiedAt        int64      `json:"modified_at"`
}

ConfigEntry records one integration target. For files we own entirely (omp and Pi extensions, Copilot CLI hooks, fish wrapper, service unit) Owned is set and removal deletes the file; for shared config files our elements are identified by Identify and removed element-wise, unless the file is unchanged since our last edit and a valid backup exists, in which case it is restored.

type DaemonReport

type DaemonReport struct {
	Running  bool   `json:"running"`
	PID      int    `json:"pid"`
	Version  string `json:"version"`
	Sessions int    `json:"sessions"`
	// BootstrapSwapped is whether the running daemon moved itself to the
	// per-user bootstrap port (macOS); null when it is not running, off
	// macOS, or it is a version before 0.4.0. BootstrapError says why it
	// failed; null otherwise.
	BootstrapSwapped *bool   `json:"bootstrap_swapped"`
	BootstrapError   *string `json:"bootstrap_error"`
}

type DoctorReport

type DoctorReport struct {
	Version  string `json:"version"`
	Protocol int    `json:"protocol"`
	OS       string `json:"os"`
	Arch     string `json:"arch"`
	Home     string `json:"home"`
	// HostID is the host's id (hostid); absent until stagent created it
	// (install, the bridge's hello or the daemon). doctor never creates it.
	HostID string       `json:"host_id,omitempty"`
	Layout LayoutInfo   `json:"layout"`
	Daemon DaemonReport `json:"daemon"`
	// Blocked names the stagent location another user owns (ipc.Blocked),
	// so no daemon or kept shell can work; null when nothing is blocked.
	Blocked      *wire.Blocked     `json:"blocked"`
	Harnesses    []HarnessReport   `json:"harnesses"`
	ShellWrapper ShellReport       `json:"shell_wrapper"`
	Service      ServiceReport     `json:"service"`
	Persistence  PersistenceReport `json:"persistence"`
	// Terminal is Terminal.app's close confirmation (macOS; null
	// elsewhere).
	Terminal *TerminalReport `json:"terminal"`
	// PowerShell lists the installed PowerShells with their effective
	// execution policy (Windows; null elsewhere).
	PowerShell []PowerShellReport `json:"powershell"`
	// RedirectionGuard is whether this doctor process runs with Windows'
	// RedirectionGuard: started over SSH, as kept shells are, it follows
	// no junction a user created (scoop's shims fail). Null off Windows or
	// when unknown.
	RedirectionGuard *bool `json:"redirection_guard"`
	// Notify comes from the daemon's last failures file, so it is there
	// whether or not the daemon runs.
	Notify wire.NotifyStatus `json:"notify"`
	// Unwrapped: agents started without a stagent session that the
	// running daemon saw (empty when it does not run).
	Unwrapped []wire.UnwrappedLaunch `json:"unwrapped"`
	Orphans   []Finding              `json:"orphans"`
	Problems  []string               `json:"problems"`
}

DoctorReport is the output of `stagent doctor` (PROTOCOL.md).

type Failure

type Failure struct {
	Path     string   `json:"path"`
	Reason   string   `json:"reason"`
	Sessions []string `json:"sessions"`
}

type FileEntry

type FileEntry struct {
	Path   string `json:"path"`
	Kind   string `json:"kind"`
	SHA256 string `json:"sha256,omitempty"`
}

type Finding

type Finding struct {
	Target string `json:"target"`
	Detail string `json:"detail"`
}

Finding names something stagent left on the host.

type HarnessReport

type HarnessReport struct {
	ID             string   `json:"id"`
	Found          bool     `json:"found"`
	Path           string   `json:"path"`
	Version        string   `json:"version"`
	ConfigPath     string   `json:"config_path"`
	Integrated     bool     `json:"integrated"`
	HooksSupported bool     `json:"hooks_supported"`
	Notes          []string `json:"notes"`
	// RemoteControlAtStartup (claude only; other harnesses omit it) is
	// remoteControlAtStartup in ~/.claude/settings.json: true, false or
	// null when absent, not a boolean or unreadable.
	RemoteControlAtStartup json.RawMessage `json:"remote_control_at_startup,omitempty"`
}

type InstallResult

type InstallResult struct {
	OK      bool       `json:"ok"`
	Version string     `json:"version"`
	Layout  LayoutInfo `json:"layout"`
	// ReplacedDaemon is the version of the running daemon this install
	// replaced with its own (an update); empty when none was replaced.
	ReplacedDaemon string `json:"replaced_daemon,omitempty"`
	// Changes are the shell wrapper files rewritten to this version's block
	// (refreshShellWrapper), in integrate's form.
	Changes []*Change `json:"changes"`
	Notes   []Note    `json:"notes"`
}

InstallResult is the output of `stagent install`.

type IntegrateResult

type IntegrateResult struct {
	Applied bool `json:"applied"`
	// Result sums up the outcome: ok | partial | nothing_to_do | failed
	// (summarize).
	Result string `json:"result"`
	// LoginShell is the base name of $SHELL ("" when unknown).
	LoginShell string    `json:"login_shell"`
	Changes    []*Change `json:"changes"`
	Notes      []Note    `json:"notes"`
}

IntegrateResult is the output of `stagent integrate`.

type LayoutInfo

type LayoutInfo struct {
	Root            string `json:"root"`
	Bin             string `json:"bin"`
	RunDir          string `json:"run_dir"`
	DataDir         string `json:"data_dir"`
	DataOnNetworkFS bool   `json:"data_on_network_fs"`
}

LayoutInfo is the part of the layout the app shows and the uninstaller needs even if the home directory changes.

type Manifest

type Manifest struct {
	ManifestVersion int    `json:"manifest_version"`
	Version         string `json:"version"` // stagent version that last wrote it
	CreatedAt       int64  `json:"created_at"`
	UpdatedAt       int64  `json:"updated_at"`

	Layout     LayoutInfo `json:"layout"`
	DaemonAddr string     `json:"daemon_addr"` // actual socket / pipe location

	Files    []FileEntry    `json:"files"`    // files created by install (the binary)
	Dirs     []string       `json:"dirs"`     // directories created by install
	Configs  []*ConfigEntry `json:"configs"`  // integration targets created or modified
	Services []ServiceEntry `json:"services"` // login services / scheduled tasks
	// Backups are the pre-edit copies of modified config files. A backup is
	// deleted once its content is restored into the file; one that could not
	// be restored (the file changed since) stays until purge.
	Backups []string `json:"backups"`
	// LingerEnabled: `integrate --linger` turned lingering on (it was off).
	// Only then do `integrate --remove linger` and `uninstall --linger`
	// turn it back off.
	LingerEnabled bool `json:"linger_enabled,omitempty"`
	// TerminalNoWarn lists the Terminal.app profiles `integrate --terminal`
	// added stagent to (noWarnProcesses, macOS). `integrate --remove
	// terminal` and `uninstall --level unhook` take out only that entry.
	TerminalNoWarn []TerminalEntry `json:"terminal_no_warn,omitempty"`
}

Manifest is the installation ledger (layout.Manifest): everything stagent created or changed on the host, so that uninstall can take it back out.

type Note added in v0.4.1

type Note struct {
	Code string            `json:"code"`
	Text string            `json:"text"`
	Args map[string]string `json:"args,omitempty"`
}

Note is one remark of install / integrate (PROTOCOL.md): Text in English for people; Code, with Args, for a client that words it itself. A Code keeps its meaning; Text may be reworded.

type PersistenceReport added in v0.3.0

type PersistenceReport struct {
	RunDir string `json:"run_dir"`
	// RunDirSurvivesLogout: RunDir is outside $XDG_RUNTIME_DIR, which
	// logind deletes at the last logout.
	RunDirSurvivesLogout bool  `json:"run_dir_survives_logout"`
	KillUserProcesses    *bool `json:"kill_user_processes"`
	Linger               *bool `json:"linger"`
	// LingerNeeded: agents started here end at logout unless lingering is
	// turned on (lingerNeeded); null when unknown.
	LingerNeeded *bool `json:"linger_needed"`
	// LingerReason says why LingerNeeded is true (lingerReason* values);
	// null otherwise.
	LingerReason *string `json:"linger_reason"`
	// LingerEnabledByStagent: the manifest records that `integrate
	// --linger` turned lingering on.
	LingerEnabledByStagent bool `json:"linger_enabled_by_stagent"`
	// WSL is WSL を動かし続ける when Linux runs in WSL; null otherwise.
	WSL *WSLReport `json:"wsl"`
}

PersistenceReport says whether detached sessions outlive the user's logout. Unknown facts (off Linux, logind not reachable) are null.

type PowerShellReport added in v0.5.0

type PowerShellReport struct {
	ID   string `json:"id"`   // powershell | pwsh
	Name string `json:"name"` // Windows PowerShell 5.1 | PowerShell 7
	Path string `json:"path"`
	// ExecutionPolicy is the effective policy (Get-ExecutionPolicy); null
	// when it could not be read.
	ExecutionPolicy *string `json:"execution_policy"`
	// LoadsProfile is false when that policy keeps the profile's wrapper
	// from running (Restricted, AllSigned); null when unknown.
	LoadsProfile *bool `json:"loads_profile"`
}

PowerShellReport is one installed PowerShell in `doctor` (Windows).

type Runner

type Runner interface {
	Run(timeout time.Duration, name string, args ...string) (output string, err error)
}

Runner executes system commands (systemctl, launchctl, schtasks, harness --version). Tests substitute a fake so nothing touches the real system.

type ServiceEntry

type ServiceEntry struct {
	Kind   string `json:"kind"` // systemd | launchd | schtasks
	Name   string `json:"name"` // unit / label / task name
	Path   string `json:"path,omitempty"`
	SHA256 string `json:"sha256,omitempty"` // task definition (schtasks)
}

type ServiceReport

type ServiceReport struct {
	Kind      string `json:"kind"` // systemd | launchd | schtasks | none
	Installed bool   `json:"installed"`
	Running   bool   `json:"running"`
}

type ShellReport

type ShellReport struct {
	Installed bool     `json:"installed"`
	Files     []string `json:"files"`
	// LastRunAt is when `stagent run --handoff=auto` (a shell wrapper) last
	// started a program on this host, unix ms; null when never.
	LastRunAt *int64 `json:"last_run_at"`
	// LastRunSurvivesLogout is whether that start outlives the user's
	// logout: on Linux where it ended up after leaving the login session,
	// judged with logind's settings now; on macOS whether it swapped its
	// bootstrap port. Null when unknown or never recorded (before 0.4.0,
	// Windows).
	LastRunSurvivesLogout *bool `json:"last_run_survives_logout"`
	// LastRunBootstrapError is why that start's swap failed (macOS); null
	// otherwise.
	LastRunBootstrapError *string `json:"last_run_bootstrap_error"`
}

type Step

type Step struct {
	Action string `json:"action"`
	Target string `json:"target"`
	OK     bool   `json:"ok"`
	Error  string `json:"error,omitempty"`
}

type TOMLEdit

type TOMLEdit struct {
	Kind         string `json:"kind"`   // features_hooks | notify
	Action       string `json:"action"` // added | changed
	PreviousLine string `json:"previous_line,omitempty"`
	AddedHeader  bool   `json:"added_header,omitempty"` // we also added [features]
	AddedBlank   bool   `json:"added_blank,omitempty"`  // and a blank line before it
}

TOMLEdit records a line-level change to Codex's config.toml.

type TerminalEntry added in v0.4.0

type TerminalEntry struct {
	Profile string `json:"profile"`
	// CreatedKey: the profile had no noWarnProcesses, so Terminal's default
	// list was written along.
	CreatedKey bool `json:"created_key,omitempty"`
}

TerminalEntry records one profile `integrate --terminal` added stagent to.

type TerminalReport added in v0.4.0

type TerminalReport struct {
	// Profiles is the number of Terminal profiles (0 when Terminal has
	// none saved or they cannot be read).
	Profiles int `json:"profiles"`
	// NoWarn: every profile has stagent in noWarnProcesses.
	NoWarn bool `json:"no_warn"`
	// AddedByStagent: the manifest records profiles `integrate --terminal`
	// added stagent to.
	AddedByStagent bool `json:"added_by_stagent"`
}

TerminalReport is doctor's view of Terminal.app (macOS).

type UninstallReport

type UninstallReport struct {
	Level     string    `json:"level"`
	Steps     []Step    `json:"steps"`
	Removed   []string  `json:"removed"`
	Failed    []Failure `json:"failed"`
	Remaining []Finding `json:"remaining"`
}

UninstallReport is the output of `stagent uninstall`.

type WSLReport added in v0.6.0

type WSLReport struct {
	// Distro is $WSL_DISTRO_NAME ("" when unset).
	Distro string `json:"distro"`
	// ConfigPath is the Linux path of the user's .wslconfig, whether or not
	// it exists; null when the Windows profile cannot be reached.
	ConfigPath *string `json:"config_path"`
	// InstanceIdleTimeout is [general] instanceIdleTimeout in ms, WSL's
	// default when the file or the key is absent or not an integer; null
	// when the file cannot be read.
	InstanceIdleTimeout *int64 `json:"instance_idle_timeout"`
	// NetworkingMode is [wsl2] networkingMode (lower case), "nat" when
	// absent; null when the file cannot be read.
	NetworkingMode *string `json:"networking_mode"`
	// KeepRunningNeeded: WSL stops this distribution when idle
	// (InstanceIdleTimeout >= 0). It follows the file, which WSL reads
	// only when it starts. Null when InstanceIdleTimeout is.
	KeepRunningNeeded *bool `json:"keep_running_needed"`
	// KeepRunningByStagent: the manifest records that `integrate
	// --wsl-keep-running` wrote the line, and the file still has it.
	KeepRunningByStagent bool `json:"keep_running_by_stagent"`
}

WSLReport is doctor's view of WSL (persistence.wsl; null off WSL).

Jump to

Keyboard shortcuts

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