fleetreg

package
v0.14.3-dev Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package fleetreg pushes this host's fleet inventory — the tools, agents, and skills it has installed — up to cloudbox.

It is the counterpart of internal/agent/ollama's model-registry watcher, and deliberately the same shape: the host is the source of truth about itself, cloudbox caches that truth behind a freshness clock, and a content hash lets an unchanged snapshot cost one UPDATE instead of a rewrite.

The inventory is read straight out of coreutils/pkg/fleet rather than by shelling out to `bashy`. Outpost already depends on coreutils, so the registry is a library call — and a host that has no bashy binary installed still has a fleet, because the compiled-in baseline is part of the library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentHash

func ContentHash(assets []Asset) string

ContentHash is a deterministic sha256 over the reported inventory.

The push order cannot change it (assets are sorted), and no timestamp enters it — the whole point is that an unchanged host hashes the same across polls, so cloudbox can skip the rewrite and just move the freshness clock.

Types

type Asset

type Asset struct {
	Kind    string `json:"kind"`
	Name    string `json:"name"`
	Display string `json:"display,omitempty"`
	Detail  string `json:"detail,omitempty"`
}

Asset is one reported tool / agent / skill.

type Config

type Config struct {
	// CloudboxURL is the base URL (e.g. https://ai.dhnt.io).
	CloudboxURL string
	// AccessToken is the per-outpost bearer JWT. It must carry
	// fleet:registry — the scope minted for a HOST reporting a fact about
	// itself, not for a user authoring a definition.
	AccessToken string
	// AgentName is the host name cloudbox knows this outpost by.
	AgentName string

	PollInterval      time.Duration
	HeartbeatInterval time.Duration
	HTTP              *http.Client

	// Catalog is indirected for tests. Nil uses the host's real registry.
	Catalog func() *fleet.Catalog
	// Skills lists the skills installed in the host's local store. Nil uses
	// the default reader.
	//
	// It reads directory names rather than importing coreutils/pkg/skills:
	// that package pulls the dhnt skill-CNL runtime, and outpost is the lean
	// mesh supervisor. A name is all the inventory needs — a peer asking
	// "does host-a have the conductor skill" wants a yes, not the procedure.
	Skills func() []string
}

Config configures the watcher.

type PushError

type PushError struct {
	Status int
	Body   string
}

PushError carries the HTTP status so the caller can honor the endpoint's contract: 401 means stop (revoked or unknown token), 403 means the token lacks fleet:registry, 404 means this host is not paired under that owner. Only 5xx is worth retrying.

func (*PushError) Error

func (e *PushError) Error() string

func (*PushError) Fatal

func (e *PushError) Fatal() bool

Fatal reports whether retrying can never help.

type Watcher

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

Watcher polls the local fleet registry and pushes changes.

func New

func New(cfg Config) (*Watcher, error)

New validates cfg and constructs a Watcher.

func (*Watcher) Push

func (w *Watcher) Push(ctx context.Context, assets []Asset, contentHash string) (string, error)

Push sends one snapshot. It returns the server's `applied` verdict ("replaced" or "touched") so a caller can log what actually happened.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context)

Run polls until ctx is cancelled, pushing when the inventory changes and on a heartbeat so the freshness clock keeps ticking.

A failed push is logged and retried on the next tick; it never takes the daemon down. The inventory is a convenience for peers, not a dependency of anything running on this host.

func (*Watcher) Snapshot

func (w *Watcher) Snapshot() []Asset

Snapshot reads the host's current inventory.

Tools are the agentic-CLI kind only. A function kit is not something this host can be asked to launch, so reporting one would advertise a capability that does not exist.

Jump to

Keyboard shortcuts

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