setup

package
v0.1.53 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 9 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 setup runs an agent's install toolchain inside the sandbox. The daemon owns this — the app just asks it to ensure/update the agent. Adapter changes ship with the daemon; compatible CLI releases can also be approved through its catalog.

Toolchain steps form a small dependency graph. A shared catalog holds reusable, cross-stack tools (git, node, …) that any agent references by name via Step.Requires; `Plan` expands an agent's steps against that catalog into a topologically-ordered, deduplicated install plan (dependencies first), so "who installs before who" is declarative and tools are never installed twice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OK

func OK(results []StepResult) bool

OK reports whether every step ended satisfied or installed.

func Plan

func Plan(agentSteps []agent.Step) ([]agent.Step, error)

Plan builds the ordered, deduplicated install plan: base prerequisites + the agent's own steps, with any reusable catalog tools they (transitively) require pulled in and ordered dependencies-first. Errors on an unknown dependency or a cycle.

Types

type Status

type Status struct {
	Running   bool         `json:"running"`
	OK        bool         `json:"ok"`
	Started   bool         `json:"started"`
	Current   string       `json:"current"`
	Steps     []StepResult `json:"steps"`
	Operation string       `json:"operation,omitempty"` // "setup" or "update"; shared by all clients
	Stage     string       `json:"stage,omitempty"`     // live check, download, configuration or verification
	Plan      []string     `json:"plan,omitempty"`      // ordered tool names; Steps contains their results
	StartedAt *time.Time   `json:"startedAt,omitempty"` // retained when clients reconnect; never a completion estimate
}

Status is the wire-shaped snapshot of an agent's toolchain install job: whether an install is in flight, its outcome so far, the step currently running (for a live "Installing X…" label), and the per-step results appended as the install progresses. JSON tags match the shape the HTTP layer emits so callers marshal it unchanged; the Go SDK returns it directly.

type StepResult

type StepResult struct {
	Name   string `json:"name"`
	Status string `json:"status"` // "satisfied" | "installed" | "failed"
	Output string `json:"output,omitempty"`
}

StepResult reports the outcome of one toolchain step.

func Run

func Run(ctx context.Context, steps []agent.Step, force bool, onStart func(name string), onStep func(StepResult)) []StepResult

Run executes the steps. Unless force is set, a passing Check short-circuits the install (idempotent "ensure"); force=true re-installs installable steps (update). `onStep` (optional) is called as each step finishes, so a caller can report live progress while the run is in flight (the API serves it over GET /setup while the install runs in the background).

type Tracker

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

Tracker runs per-agent toolchain installs in the BACKGROUND (an `npm i -g` can take minutes) so a caller's request never hangs while it installs; the caller polls Status for progress + completion. Only one install runs at a time per agent — a concurrent Start re-attaches to the in-flight job (idempotent, atomic) rather than starting a second run. The supervisor owns this Tracker for both the HTTP surface and the in-process Go SDK, and gates turns against it.

func NewTracker

func NewTracker() *Tracker

NewTracker builds an empty tracker.

func (*Tracker) MissingDependencies

func (t *Tracker) MissingDependencies(ctx context.Context, steps []agent.Step, force bool) []string

MissingDependencies is a read-only probe of shared tools in the declared setup plan. An installed CLI can still need setup after an upgrade adds a dependency. Personas share these short-lived results; manual refresh and a completed setup invalidate them.

func (*Tracker) Start

func (t *Tracker) Start(agentID string, steps []agent.Step, force bool, timeout time.Duration) Status

Start plans have already been resolved by the caller (via Plan). It launches the install for agentID in the background and returns immediately with a snapshot: a fresh {running:true,…} for a new run, or the live progress of the job already in flight (idempotent re-attach). The install runs on a DETACHED context — a caller/client disconnect can't abort it mid-write — bounded by timeout.

func (*Tracker) Status

func (t *Tracker) Status(agentID string) Status

Status snapshots agentID's install job. A never-started agent reports the zero Status (running/ok/started=false, empty steps).

Jump to

Keyboard shortcuts

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