host

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpdatePhaseIdle        = "idle"
	UpdatePhaseChecking    = "checking"
	UpdatePhaseDownloading = "downloading"
	UpdatePhaseReady       = "ready"
	UpdatePhaseWaitingIdle = "waiting_for_idle"
	UpdatePhaseInstalling  = "installing"
	UpdatePhaseVerifying   = "verifying"
	UpdatePhaseSuccess     = "success"
	UpdatePhaseFailed      = "failed"
	UpdatePhaseRolledBack  = "rolled_back"
	UpdatePhaseBlocked     = "blocked"
	UpdatePhaseDisabled    = "disabled"
)

Update phases reported to the hub and persisted across restarts. The hub only displays them; it cannot advance or bypass the local updater policy.

View Source
const (
	UpdateChannelStable      = "stable"
	UpdateChannelPrerelease  = "prerelease"
	UpdateChannelDevelopment = "development"

	DefaultUpdateInterval = 6 * time.Hour
	MinUpdateInterval     = 15 * time.Minute
	MaxUpdateInterval     = 7 * 24 * time.Hour
)

Variables

View Source
var ErrNoRelease = errors.New("no published release")

ErrNoRelease means the release feed is reachable but contains no publishable release. During alpha this is the normal state, not an update failure.

View Source
var Version = "alpha"

Functions

func AddUpdateWatchdogArgs

func AddUpdateWatchdogArgs(target, previous, expected string) []string

AddUpdateWatchdogArgs is used by the CLI parser tests to keep the flag names in one place.

func CheckAgentVersion

func CheckAgentVersion(agent, version string) (tested, recognized bool)

CheckAgentVersion reports whether a detected version is inside any tested band. recognized is false when the matrix has no entry or the version could not be parsed.

func ClearUpdateBlock

func ClearUpdateBlock(version string)

ClearUpdateBlock removes a version from the persisted display state after an operator explicitly unblocks it in the local configuration.

func ConfigDir

func ConfigDir() (string, error)

func ConfigPath

func ConfigPath() (string, error)

func DefaultForbiddenArgs

func DefaultForbiddenArgs() []string

func Doctor

func Doctor(cfg Config, cfgErr error, out io.Writer) int

Doctor prints configuration problems and returns the number of issues.

func FetchHubPublicKey

func FetchHubPublicKey(ctx context.Context, hubURL string) (string, error)

FetchHubPublicKey reads the hub's command-signing key. Pairing uses this to pin the key; an existing host also calls it on startup when it was paired before command signing existed (trust on first use).

func HideConsoleWindow added in v0.1.7

func HideConsoleWindow()

HideConsoleWindow is a no-op outside Windows.

func InstallOwnUpdate

func InstallOwnUpdate(staged string) error

InstallOwnUpdate replaces the currently running executable without touching the daemon service or host identity. It is used by the standalone `nexus` client. On Windows a small detached helper waits for this process to exit before replacing the locked image.

func InstallStagedUpdate

func InstallStagedUpdate(staged string, force bool) error

InstallStagedUpdate replaces the running daemon binary after asking the per-user service to restart. force must be set explicitly because the restart interrupts active agent runs; callers should verify that no runs are active before setting it.

func NewIdentity

func NewIdentity() (ed25519.PublicKey, ed25519.PrivateKey, error)

func NormalizeUpdateChannel

func NormalizeUpdateChannel(channel, currentVersion string) string

NormalizeUpdateChannel resolves auto and unknown channel names. Stable is always the safe default; an unknown value must never silently select prereleases.

func PlatformName

func PlatformName() string

func ReadHostname

func ReadHostname() string

func RollbackUpdate

func RollbackUpdate(force bool) error

RollbackUpdate restores nexusd.previous through the same service restart path. The currently installed binary is kept as nexusd.failed for diagnosis.

func SaveConfig

func SaveConfig(cfg Config) error

func SaveUpdatePrefs

func SaveUpdatePrefs(prefs UpdateSettings) error

SaveUpdatePrefs stores normalized updater settings without touching any other field. It never changes the host identity or pairing.

func ServiceAction

func ServiceAction(action string) error

ServiceAction installs, uninstalls or queries the per-user background service. It intentionally never creates a root/SYSTEM service.

func ServiceInstalled

func ServiceInstalled() bool

ServiceInstalled reports whether the per-user service that can restart the daemon after a binary replacement is present.

func StageUpdate

func StageUpdate(ctx context.Context, info UpdateInfo, stagedDir string, requireSignature bool) (string, error)

StageUpdate downloads the archive and checksum file, verifies the SHA-256 digest (and the cosign bundle when cosign is installed or required), then extracts nexusd into the staged directory.

func StageUpdateNamed

func StageUpdateNamed(ctx context.Context, info UpdateInfo, stagedDir, binaryName string, requireSignature bool) (string, string, error)

StageUpdateNamed stages one executable from a release archive. It is shared by the daemon and the terminal client so both use the same checksum, signature and extraction rules.

func StageUpdateWithMode

func StageUpdateWithMode(ctx context.Context, info UpdateInfo, stagedDir string, requireSignature bool) (string, string, error)

StageUpdateWithMode also reports the trust mode that was actually used: "cosign" or "checksum-only". A failed signature is never downgraded to checksum-only.

func StartUpdateWatchdog

func StartUpdateWatchdog(expected string) error

StartUpdateWatchdog copies the current (known working) executable and starts it in a detached scope before the binary is replaced. If the new daemon does not report the expected version within the startup window, the copy restores nexusd.previous and restarts the service. Windows uses the Task Scheduler helper instead because a running image cannot be replaced in place.

func VerifyStagedBinary

func VerifyStagedBinary(ctx context.Context, path, expected string) error

VerifyStagedBinary runs the downloaded daemon's version command before it can replace a working installation. A wrong or non-executable binary is rejected here, not after the service restart.

func VerifyStagedBinaryNamed

func VerifyStagedBinaryNamed(ctx context.Context, path, name, expected string) error

VerifyStagedBinaryNamed checks the version output of a staged executable.

func VerifyUpdateAndRollback

func VerifyUpdateAndRollback(target, previous, expected string) error

VerifyUpdateAndRollback is the detached half of StartUpdateWatchdog. It waits for the new daemon to publish its runtime status and rolls back only when the service is present but not healthy.

Types

type ACPRun

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

ACPRun drives any Agent Client Protocol adapter over stdio. This is how agents without a native structured driver (for example Claude Code via claude-code-acp) get text streaming, tool cards and approvals.

func (*ACPRun) CompleteElicitation added in v0.1.15

func (r *ACPRun) CompleteElicitation(_ context.Context, _ acp.CompleteElicitationNotification) error

Completion notifications are harmless when elicitation is unsupported.

func (*ACPRun) CreateElicitation added in v0.1.15

The client does not advertise elicitation support. Reject requests using the ACP method-not-found error, as required by the SDK.

func (*ACPRun) Interrupt

func (r *ACPRun) Interrupt() error

func (*ACPRun) Options

func (r *ACPRun) Options(context.Context) (protocol.RunOptions, error)

Options returns only what the agent actually advertised: config options categorised as model/thought level and the session's mode list.

func (*ACPRun) Prompt

func (r *ACPRun) Prompt(text string, options *protocol.PromptOptions) error

func (*ACPRun) ReadTextFile

ReadTextFile is not advertised to the agent, so this is only a safety net.

func (*ACPRun) ReplyApproval

func (r *ACPRun) ReplyApproval(id, decision string) error

func (*ACPRun) RequestPermission

func (*ACPRun) SessionUpdate

func (r *ACPRun) SessionUpdate(_ context.Context, params acp.SessionNotification) error

func (*ACPRun) Stop

func (r *ACPRun) Stop()

type Action

type Action struct {
	Kind     string // resume, new, fork
	NativeID string
	Cwd      string
	Agent    string
}

Action describes a terminal-mode run request.

type Adapter

type Adapter interface {
	Name() string
	Detect(context.Context) (protocol.AgentInfo, error)
	ListSessions(context.Context) ([]protocol.Session, error)
	Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)
	Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)
	BuildCommand(Action) (Command, error)
}

Adapter is implemented per coding agent. Discovery must work without starting the agent; Control only produces argv and never executes anything.

func DetectAdapters

func DetectAdapters(logger *slog.Logger) []Adapter

DetectAdapters returns one adapter per installed agent. Unknown agents are ignored instead of failing the daemon.

type AgentVersionRange

type AgentVersionRange struct {
	Agent      string
	Min        string
	Max        string
	Structured bool
	// Note explains a supported band that intentionally has no structured
	// driver, for example OpenCode 1.x.
	Note string
}

AgentVersionRange is the tested version band for one agent. Structured mode is disabled outside the band unless the host explicitly allows untested versions; terminal mode remains available.

func AgentMatrix

func AgentMatrix() []AgentVersionRange

AgentMatrix returns a copy of the tested version matrix.

func (AgentVersionRange) TestedRange

func (r AgentVersionRange) TestedRange() string

TestedRange renders the band for display and documentation.

type ClaudeAdapter

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

ClaudeAdapter discovers Claude Code sessions from its JSONL store and starts the native CLI for terminal runs.

func NewClaudeAdapter

func NewClaudeAdapter(bin string) *ClaudeAdapter

func (*ClaudeAdapter) BuildCommand

func (a *ClaudeAdapter) BuildCommand(action Action) (Command, error)

func (*ClaudeAdapter) Detect

func (*ClaudeAdapter) ListSessions

func (a *ClaudeAdapter) ListSessions(ctx context.Context) ([]protocol.Session, error)

func (*ClaudeAdapter) Name

func (a *ClaudeAdapter) Name() string

func (*ClaudeAdapter) Search

func (a *ClaudeAdapter) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

func (*ClaudeAdapter) Transcript

func (a *ClaudeAdapter) Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)

func (*ClaudeAdapter) WatchPaths

func (a *ClaudeAdapter) WatchPaths() []string

type CodexAdapter

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

CodexAdapter discovers Codex CLI rollouts and starts the native CLI.

func NewCodexAdapter

func NewCodexAdapter(bin string) *CodexAdapter

func (*CodexAdapter) BuildCommand

func (a *CodexAdapter) BuildCommand(action Action) (Command, error)

func (*CodexAdapter) Detect

func (*CodexAdapter) ListSessions

func (a *CodexAdapter) ListSessions(ctx context.Context) ([]protocol.Session, error)

func (*CodexAdapter) Name

func (a *CodexAdapter) Name() string

func (*CodexAdapter) Search

func (a *CodexAdapter) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

func (*CodexAdapter) Transcript

func (a *CodexAdapter) Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)

func (*CodexAdapter) WatchPaths

func (a *CodexAdapter) WatchPaths() []string

type CodexRun

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

CodexRun drives Codex CLI's experimental app-server over JSONL/JSON-RPC.

func (*CodexRun) Interrupt

func (r *CodexRun) Interrupt() error

func (*CodexRun) Options

func (r *CodexRun) Options(_ context.Context) (protocol.RunOptions, error)

Options returns Codex's catalog models and their advertised reasoning efforts. Models are filtered to the non-hidden catalog entries.

func (*CodexRun) Prompt

func (r *CodexRun) Prompt(text string, options *protocol.PromptOptions) error

func (*CodexRun) ReplyApproval

func (r *CodexRun) ReplyApproval(id, decision string) error

func (*CodexRun) Stop

func (r *CodexRun) Stop()

type Command

type Command struct {
	Path string
	Args []string
	Cwd  string
	Env  []string
}

Command is a resolved process launch, including a Windows shim wrapper if the agent is installed as .cmd/.bat/.ps1.

type CommandCodeAdapter added in v0.1.5

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

CommandCodeAdapter discovers Command Code sessions and starts the native CLI. Structured runs use the generic ACP driver through `command-code acp`.

func NewCommandCodeAdapter added in v0.1.5

func NewCommandCodeAdapter(bin string) *CommandCodeAdapter

func (*CommandCodeAdapter) BuildCommand added in v0.1.5

func (a *CommandCodeAdapter) BuildCommand(action Action) (Command, error)

func (*CommandCodeAdapter) Detect added in v0.1.5

func (*CommandCodeAdapter) ListSessions added in v0.1.5

func (a *CommandCodeAdapter) ListSessions(ctx context.Context) ([]protocol.Session, error)

func (*CommandCodeAdapter) Name added in v0.1.5

func (a *CommandCodeAdapter) Name() string

func (*CommandCodeAdapter) Search added in v0.1.5

func (a *CommandCodeAdapter) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

func (*CommandCodeAdapter) Transcript added in v0.1.5

func (a *CommandCodeAdapter) Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)

func (*CommandCodeAdapter) WatchPaths added in v0.1.5

func (a *CommandCodeAdapter) WatchPaths() []string

type Config

type Config struct {
	HubURL             string `json:"hub_url"`
	HostID             string `json:"host_id"`
	HostName           string `json:"host_name"`
	PrivateKey         string `json:"private_key"`
	HubPublicKey       string `json:"hub_public_key,omitempty"`
	HubSigningRequired bool   `json:"hub_signing_required,omitempty"`
	Policy             Policy `json:"policy"`
	// Updates configures the host-local auto-updater. Omitted means enabled
	// with the official defaults; a hub cannot change these settings.
	Updates *UpdateSettings `json:"updates,omitempty"`
	// RunBufferBytes bounds the per-run terminal replay buffer. Omitted means
	// 1 MiB; values below 64 KiB or above 16 MiB are clamped.
	RunBufferBytes int `json:"run_buffer_bytes,omitempty"`
	// ACPCommands maps an agent name to an Agent Client Protocol adapter
	// command line, for example {"claude": "claude-code-acp"}. When empty the
	// daemon looks for the claude-agent-acp or claude-code-acp binary on PATH.
	ACPCommands map[string]string `json:"acp_commands,omitempty"`
	// AllowUntestedAgentVersions keeps structured mode enabled for agents
	// outside the tested version band. Every use is audited.
	AllowUntestedAgentVersions bool `json:"allow_untested_agent_versions,omitempty"`
	// SearchIndex enables the host-local FTS5 transcript cache. Omitted means
	// enabled; set it to false to keep transcript text out of a local index.
	SearchIndex *bool `json:"search_index,omitempty"`
}

Config is stored next to the host key in the per-user config directory.

func LoadConfig

func LoadConfig() (Config, error)

func Pair

func Pair(ctx context.Context, hubURL, code, name string) (Config, string, error)

Pair redeems a one-time pairing code and stores the host identity. It returns the short authentication string the user must compare with the hub.

func (Config) ACPCommand

func (c Config) ACPCommand(agent string) string

ACPCommand returns the ACP adapter command configured for an agent.

func (Config) RunBufferBytesOrDefault

func (c Config) RunBufferBytesOrDefault() int

RunBufferBytesOrDefault returns the bounded terminal replay size.

func (Config) SearchIndexEnabled

func (c Config) SearchIndexEnabled() bool

SearchIndexEnabled reports whether the local search index may be built.

func (Config) SigningKey

func (c Config) SigningKey() (ed25519.PrivateKey, error)

func (Config) UpdatePrefs

func (c Config) UpdatePrefs() UpdateSettings

UpdatePrefs returns the host-local updater settings with defaults applied.

type CursorAdapter added in v0.1.12

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

CursorAdapter discovers Cursor agent transcripts and starts the Cursor CLI. Structured runs use the generic ACP driver through `cursor-agent acp`.

Cursor stores desktop and background-agent transcripts under ~/.cursor/projects/<encoded-workspace>/agent-transcripts/<session>/<session>.jsonl. The folder name is a lossy encoding of the workspace path, so the working directory is read from a terminal transcript when one exists and decoded from the folder name as a last resort.

func NewCursorAdapter added in v0.1.12

func NewCursorAdapter(bin string) *CursorAdapter

func (*CursorAdapter) BuildCommand added in v0.1.12

func (a *CursorAdapter) BuildCommand(action Action) (Command, error)

func (*CursorAdapter) Detect added in v0.1.12

func (*CursorAdapter) ListSessions added in v0.1.12

func (a *CursorAdapter) ListSessions(ctx context.Context) ([]protocol.Session, error)

func (*CursorAdapter) Name added in v0.1.12

func (a *CursorAdapter) Name() string

func (*CursorAdapter) Search added in v0.1.12

func (a *CursorAdapter) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

func (*CursorAdapter) Transcript added in v0.1.12

func (a *CursorAdapter) Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)

func (*CursorAdapter) WatchPaths added in v0.1.12

func (a *CursorAdapter) WatchPaths() []string

type Daemon

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

Daemon owns the hub link, discovery loop and run manager.

func NewDaemon

func NewDaemon(cfg Config, logger *slog.Logger) *Daemon

func NewDaemonWithAdapters

func NewDaemonWithAdapters(cfg Config, logger *slog.Logger, adapters []Adapter) *Daemon

NewDaemonWithAdapters builds a daemon with an explicit adapter set. It is used by tests and by embedding scenarios; production uses DetectAdapters.

func (*Daemon) Adapters

func (d *Daemon) Adapters() []Adapter

func (*Daemon) CheckUpdateNow

func (d *Daemon) CheckUpdateNow(ctx context.Context, channel string) (UpdateInfo, error)

CheckUpdateNow triggers a host-local check, for example from the hub's "Check for updates" button. It never installs anything.

func (*Daemon) InstallUpdateNow

func (d *Daemon) InstallUpdateNow(ctx context.Context) error

InstallUpdateNow honours the host-local remote-install policy. The caller may be the hub, but only the host decides whether that request is allowed.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

func (*Daemon) SetRemoteInstall added in v0.1.5

func (d *Daemon) SetRemoteInstall(enabled bool) (*protocol.UpdateStatus, error)

SetRemoteInstall persists the host-local remote-install switch. It never changes the channel, signature policy or release source, which stay local.

type DevinAdapter added in v0.1.12

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

DevinAdapter reads the Devin CLI session database read-only and starts the Devin CLI for terminal runs. Structured runs use the generic ACP driver through `devin acp`. Devin Desktop bundles the same CLI and session store.

func NewDevinAdapter added in v0.1.12

func NewDevinAdapter(bin string) *DevinAdapter

func (*DevinAdapter) BuildCommand added in v0.1.12

func (a *DevinAdapter) BuildCommand(action Action) (Command, error)

func (*DevinAdapter) Detect added in v0.1.12

func (*DevinAdapter) ListSessions added in v0.1.12

func (a *DevinAdapter) ListSessions(ctx context.Context) ([]protocol.Session, error)

func (*DevinAdapter) Name added in v0.1.12

func (a *DevinAdapter) Name() string

func (*DevinAdapter) Search added in v0.1.12

func (a *DevinAdapter) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

func (*DevinAdapter) Transcript added in v0.1.12

func (a *DevinAdapter) Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)

func (*DevinAdapter) WatchPaths added in v0.1.12

func (a *DevinAdapter) WatchPaths() []string

type DoctorCheck

type DoctorCheck struct {
	ID     string `json:"id"`
	Status string `json:"status"` // ok, warning, error
	Detail string `json:"detail"`
}

DoctorCheck is a sanitized diagnostic result suitable for the hub UI. It intentionally omits host ids, paths, keys and configuration values.

type DoctorReport

type DoctorReport struct {
	Version string        `json:"version"`
	Issues  int           `json:"issues"`
	Checks  []DoctorCheck `json:"checks"`
}

DoctorReport is the safe subset of `nexusd doctor` exposed to the hub.

type GeminiAdapter

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

GeminiAdapter is a best-effort adapter for Gemini CLI. Its on-disk chat format is less stable than the other agents, so unknown files are skipped and never break indexing.

func NewGeminiAdapter

func NewGeminiAdapter(bin string) *GeminiAdapter

func (*GeminiAdapter) BuildCommand

func (a *GeminiAdapter) BuildCommand(action Action) (Command, error)

func (*GeminiAdapter) Detect

func (*GeminiAdapter) ListSessions

func (a *GeminiAdapter) ListSessions(ctx context.Context) ([]protocol.Session, error)

func (*GeminiAdapter) Name

func (a *GeminiAdapter) Name() string

func (*GeminiAdapter) Search

func (a *GeminiAdapter) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

func (*GeminiAdapter) Transcript

func (a *GeminiAdapter) Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)

func (*GeminiAdapter) WatchPaths

func (a *GeminiAdapter) WatchPaths() []string

type OpenCodeAdapter

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

OpenCodeAdapter reads the OpenCode SQLite store read-only and starts the native OpenCode TUI for terminal runs.

func NewOpenCodeAdapter

func NewOpenCodeAdapter(bin string) *OpenCodeAdapter

func (*OpenCodeAdapter) BuildCommand

func (a *OpenCodeAdapter) BuildCommand(action Action) (Command, error)

func (*OpenCodeAdapter) Detect

func (*OpenCodeAdapter) ListSessions

func (a *OpenCodeAdapter) ListSessions(ctx context.Context) ([]protocol.Session, error)

func (*OpenCodeAdapter) Name

func (a *OpenCodeAdapter) Name() string

func (*OpenCodeAdapter) Search

func (a *OpenCodeAdapter) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

func (*OpenCodeAdapter) Transcript

func (a *OpenCodeAdapter) Transcript(ctx context.Context, nativeID string, offset, limit int) (protocol.Transcript, error)

func (*OpenCodeAdapter) WatchPaths

func (a *OpenCodeAdapter) WatchPaths() []string

type Policy

type Policy struct {
	AllowedRoots  []string `json:"allowed_roots"`
	AllowedAgents []string `json:"allowed_agents"`
	AllowNew      bool     `json:"allow_new_sessions"`
	AllowFork     bool     `json:"allow_fork"`
	ForbiddenArgs []string `json:"forbidden_args"`
	// AllowAllRoots removes the directory filter entirely: every discovered
	// session is advertised and every non-empty path may be read or started.
	// A missing field is resolved on load: new and legacy home-only configs
	// default to true, a config with custom roots keeps them restricted.
	AllowAllRoots *bool `json:"allow_all_roots,omitempty"`
	// AllowForceResume permits the hub to ask for a resume even when a
	// best-effort process scan reports the native session as open elsewhere.
	// Omitted means enabled for backward compatibility.
	AllowForceResume *bool `json:"allow_force_resume,omitempty"`
	// AllowPersistentApprovals permits the agent's own persistent permission
	// option ("always"). Off by default: unlike a one-time approval, a
	// persistent grant removes every future prompt for that action.
	AllowPersistentApprovals bool `json:"allow_persistent_approvals,omitempty"`
	// ProcessGraceSeconds is how long a stopped run may take to exit before
	// its process tree is killed. Zero means the five-second default.
	ProcessGraceSeconds int `json:"process_grace_seconds,omitempty"`
}

Policy is enforced on the host and cannot be overridden by the hub.

func DefaultPolicy

func DefaultPolicy() Policy

func (Policy) AgentAllowed

func (p Policy) AgentAllowed(name string) bool

AgentAllowed checks a name against the policy; an empty list means "all detected agents".

func (Policy) AllowAllRootsEnabled added in v0.1.11

func (p Policy) AllowAllRootsEnabled() bool

AllowAllRootsEnabled reports whether the directory filter is disabled. A nil pointer is restricted so tests and hand-built policies keep the previous fail-closed behaviour; LoadConfig resolves the default.

func (Policy) ArgsAllowed

func (p Policy) ArgsAllowed(args []string) error

ArgsAllowed rejects permission-bypass flags even if the hub asks for them.

func (Policy) ForceResumeAllowed

func (p Policy) ForceResumeAllowed() bool

ForceResumeAllowed reports whether a force-resume request is acceptable. The zero value is enabled so existing configurations keep working.

func (Policy) ProcessGrace

func (p Policy) ProcessGrace() time.Duration

ProcessGrace returns the configured grace period, clamped to a sane range.

func (Policy) WithinRoots

func (p Policy) WithinRoots(path string) bool

WithinRoots reports whether path is inside one of the allowed roots.

type Run

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

Run is one live process attached to an agent session.

func (*Run) Resize

func (r *Run) Resize(cols, rows int) error

func (*Run) Stop

func (r *Run) Stop()

func (*Run) Write

func (r *Run) Write(data []byte) (int, error)

type RuntimeStatus

type RuntimeStatus = runtimeStatus

RuntimeStatus is the last published active-run snapshot. A status older than two minutes is treated as stale by ReadRuntimeStatus.

func ReadRuntimeStatus

func ReadRuntimeStatus() (RuntimeStatus, bool)

ReadRuntimeStatus exposes the running daemon's runtime snapshot to the installer and status command. It never blocks on the daemon.

type SearchIndex

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

SearchIndex is a host-local SQLite FTS5 cache. It never leaves the host: the hub only receives hit metadata and an index status. The index is a second local copy of transcript text, so the file is created with 0600 permissions and can be disabled with search_index=false.

func OpenSearchIndex

func OpenSearchIndex(path string) (*SearchIndex, error)

OpenSearchIndex opens or creates the index in a host-local directory.

func (*SearchIndex) Close

func (x *SearchIndex) Close() error

Close releases the database handle.

func (*SearchIndex) Count

func (x *SearchIndex) Count() (int, error)

Count returns the number of indexed sessions.

func (*SearchIndex) MarshalStatus

func (x *SearchIndex) MarshalStatus() string

MarshalStatus is a small helper for the CLI.

func (*SearchIndex) Rebuild

func (x *SearchIndex) Rebuild(ctx context.Context, adapters []Adapter, policy Policy, log *slog.Logger) error

Rebuild drops and rebuilds the whole index.

func (*SearchIndex) Refresh

func (x *SearchIndex) Refresh(ctx context.Context, adapters []Adapter, policy Policy, log *slog.Logger) error

Refresh incrementally indexes changed sessions.

func (*SearchIndex) Search

func (x *SearchIndex) Search(ctx context.Context, query string, limit int) ([]protocol.SearchHit, error)

Search runs a ranked FTS5 query. Only metadata is returned.

func (*SearchIndex) SetDisabled

func (x *SearchIndex) SetDisabled()

SetDisabled reports the configured-off state without opening a database.

func (*SearchIndex) Status

func (x *SearchIndex) Status() protocol.IndexStatus

Status returns the current progress.

type StoreWatcher

type StoreWatcher interface {
	WatchPaths() []string
}

StoreWatcher is implemented by adapters that can name the local files whose mtimes change when a session is created or extended. The daemon polls this small fingerprint instead of rescanning every session file on every tick.

type StructuredRun

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

StructuredRun drives an agent through its own local server protocol. The first implementation targets OpenCode's v2 HTTP API; terminal mode remains the universal fallback for every other agent.

func (*StructuredRun) Interrupt

func (r *StructuredRun) Interrupt() error

func (*StructuredRun) Options

Options returns the model, reasoning-variant and agent choices that the running OpenCode server actually exposes.

func (*StructuredRun) Prompt

func (r *StructuredRun) Prompt(text string, options *protocol.PromptOptions) error

func (*StructuredRun) ReplyApproval

func (r *StructuredRun) ReplyApproval(id, decision string) error

func (*StructuredRun) Stop

func (r *StructuredRun) Stop()

type UpdateInfo

type UpdateInfo struct {
	Current      string    `json:"current"`
	Latest       string    `json:"latest"`
	Available    bool      `json:"available"`
	Prerelease   bool      `json:"prerelease"`
	Channel      string    `json:"channel,omitempty"`
	AssetName    string    `json:"asset_name,omitempty"`
	ChecksumURL  string    `json:"checksum_url,omitempty"`
	SignatureURL string    `json:"signature_url,omitempty"`
	DownloadURL  string    `json:"download_url,omitempty"`
	Notes        string    `json:"notes,omitempty"`
	PublishedAt  time.Time `json:"published_at,omitempty"`
}

func CheckForUpdate

func CheckForUpdate(ctx context.Context, currentVersion, channel string) (UpdateInfo, error)

CheckForUpdate reads the release list directly from GitHub. The hub is never involved in choosing or serving the binary, so a compromised hub cannot substitute an executable.

func CheckForUpdateCached

func CheckForUpdateCached(ctx context.Context, currentVersion, channel, etag string) (info UpdateInfo, newETag string, notModified bool, err error)

CheckForUpdateCached is CheckForUpdate with an ETag for conditional requests. notModified is true when GitHub answered 304; the caller should reuse its cached metadata.

type UpdateSettings

type UpdateSettings struct {
	Disabled             bool     `json:"disabled,omitempty"`
	Channel              string   `json:"channel,omitempty"`
	CheckIntervalMinutes int      `json:"check_interval_minutes,omitempty"`
	InstallWhenIdle      *bool    `json:"install_when_idle,omitempty"`
	RequireSignature     *bool    `json:"require_signature,omitempty"`
	AllowRemoteInstall   bool     `json:"allow_remote_install,omitempty"`
	BlockedVersions      []string `json:"blocked_versions,omitempty"`
}

UpdateSettings controls the host-local auto-updater. The settings live on the host and are never pushed by the hub. A nil Updates field in an existing config means "official defaults": enabled, stable, every six hours, install when idle, SHA-256 verification and optional cosign when installed.

func (UpdateSettings) InstallIdle

func (u UpdateSettings) InstallIdle() bool

InstallIdle reports whether updates may be installed automatically.

func (UpdateSettings) Interval

func (u UpdateSettings) Interval() time.Duration

Interval returns the configured check interval.

func (UpdateSettings) IsBlocked

func (u UpdateSettings) IsBlocked(version string) bool

IsBlocked reports whether a version was temporarily blocked after failures.

func (UpdateSettings) Resolve

func (u UpdateSettings) Resolve() UpdateSettings

Resolve returns a normalized copy of the settings with defaults applied.

func (UpdateSettings) SignatureRequired

func (u UpdateSettings) SignatureRequired() bool

SignatureRequired reports whether a cosign bundle must verify successfully. The default is false: SHA-256 is always verified, and cosign is optional. Set require_signature to true on hosts that have cosign installed.

type UpdateState

type UpdateState = updateState

UpdateState is the persisted updater snapshot exposed to the CLI.

func ReadUpdateState

func ReadUpdateState() (UpdateState, bool)

ReadUpdateState returns the persisted updater state, if any.

Jump to

Keyboard shortcuts

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