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
- func StatusLineCommand(manifest, settings string) string
- func StatusLineRelayed(manifest, dir string) bool
- 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 PowerShellReport
- type Runner
- type ScreenRulesReport
- type ServiceEntry
- type ServiceReport
- type ShellReport
- type StatusLineFile
- type StatusLineReport
- type Step
- type TOMLEdit
- type TerminalEntry
- type TerminalReport
- type UninstallReport
- type WSLReport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatusLineCommand ¶ added in v0.19.0
StatusLineCommand is the command of the user's statusLine that the relay in the Claude settings.json at settings took the place of, read from the manifest at manifest; "" when there is none.
func StatusLineRelayed ¶ added in v0.19.0
StatusLineRelayed reports whether the manifest at manifest records the relay in the settings.json of Claude configuration directory dir (a clean path): the directories a relay can report from.
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"`
// Original is the source text of the user's element ours took the
// place of (Claude's statusLine), put back by removal; absent when
// there was none. A string, so that it is kept byte for byte.
Original string `json:"original,omitempty"`
}
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"`
// StatusLine is the statusLine relay that measures Claude's limit
// windows (`integrate --statusline`).
StatusLine StatusLineReport `json:"statusline"`
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"`
// ScreenRules are the overrides of the screen rules on this host.
ScreenRules ScreenRulesReport `json:"screen_rules"`
// 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"`
// 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 ScreenRulesReport ¶ added in v0.22.0
type ScreenRulesReport struct {
Dir string `json:"dir"`
Files []wire.ScreenRulesFile `json:"files"`
}
ScreenRulesReport lists the override files of the screen rules (screenrules) in Dir; one that is not used adds a problem.
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 StatusLineFile ¶ added in v0.19.0
type StatusLineReport ¶ added in v0.19.0
type StatusLineReport struct {
// Installed: some settings.json has our relay as its statusLine.
Installed bool `json:"installed"`
// Replaced: one we relayed holds another statusLine now, so the limit
// windows are not measured there until `integrate --statusline`
// relays the new one.
Replaced bool `json:"replaced"`
// UserStatusLine: the user has a statusLine of their own, the one the
// relay runs or the one `integrate --statusline` would keep.
UserStatusLine bool `json:"user_status_line"`
Files []StatusLineFile `json:"files"`
}
StatusLineReport is doctor's view of the statusLine relay.
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).
Source Files
¶
- antigravity.go
- claude.go
- codex.go
- copilot.go
- diff.go
- doctor.go
- env.go
- extension.go
- fsutil.go
- grok.go
- harness.go
- install.go
- integrate.go
- jsonedit.go
- linger.go
- manifest.go
- omp.go
- opencode.go
- pi.go
- plist.go
- powershell.go
- proc_unix.go
- qwen.go
- redirguard_other.go
- service.go
- shell.go
- sid_other.go
- statusline.go
- target.go
- terminal.go
- toml.go
- uninstall.go
- wsl.go