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 ¶
- func Main(cmd string, args []string) int
- type Change
- type ConfigEntry
- type DaemonReport
- type DoctorReport
- type Failure
- type FileEntry
- type Finding
- type HarnessReport
- type InstallResult
- type IntegrateResult
- type LayoutInfo
- type Manifest
- type Note
- type PersistenceReport
- type Runner
- type ServiceEntry
- type ServiceReport
- type ShellReport
- type Step
- type TOMLEdit
- type TerminalEntry
- type TerminalReport
- type UninstallReport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 extension, 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"`
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"`
// 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 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"`
}
PersistenceReport says whether detached sessions outlive the user's logout. Unknown facts (off Linux, logind not reachable) are null.
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 ServiceReport ¶
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 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).