registry

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheTTL defines how long cached registry data is valid
	CacheTTL = 24 * time.Hour
)

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions compares two dotted version strings (e.g. "1.2.3"). Returns -1 if a < b, 0 if a == b, 1 if a > b. Returns 0 if either string is empty or unparseable (unknown = no opinion).

func ComputeVersionStatus

func ComputeVersionStatus(rawVersion string, fw Framework) string

ComputeVersionStatus extracts a semver from raw --version output and compares it against a framework's min/latest constraints. Convenience wrapper used by API handlers to avoid duplicating the extract+compare.

func ExtractVersion

func ExtractVersion(raw string) string

ExtractVersion pulls the first semver-ish version (X.Y.Z) from arbitrary --version output. Returns "" if no version pattern is found.

"zeroclaw 0.7.2"            → "0.7.2"
"v1.2.3-beta"               → "1.2.3"
"OpenClaw CLI version 2.1.0" → "2.1.0"

func VersionStatus

func VersionStatus(installed, minVersion, latestVersion string) string

VersionStatus determines the version state given the installed version and the registry's min/latest constraints. Returns:

""                 — no version data available
"outdated"         — below min_version (may have compatibility issues)
"update_available" — meets min_version but below latest_version
"current"          — at or above latest_version

Types

type Client

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

Client fetches and caches the Claw frameworks registry

func NewClient

func NewClient(registryURL string) (*Client, error)

NewClient creates a new registry client

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, forceRefresh bool) (*Registry, error)

Fetch retrieves the registry, using cache if available and not expired

func (*Client) GetFramework

func (c *Client) GetFramework(ctx context.Context, id string) (*Framework, error)

GetFramework retrieves a specific framework by ID

func (*Client) ListFrameworks

func (c *Client) ListFrameworks(ctx context.Context, forceRefresh bool) ([]Framework, error)

ListFrameworks returns all available frameworks. When forceRefresh is true the cache is bypassed.

type ConfigField

type ConfigField struct {
	Key            string          `json:"key"`                       // Config key (dot notation for nested: "gateway.port")
	Label          string          `json:"label"`                     // Display label
	Type           string          `json:"type"`                      // "text", "number", "select", "checkbox", "multiselect"
	Default        any             `json:"default,omitempty"`         // Default value
	Required       bool            `json:"required"`                  // Whether field is required
	Description    string          `json:"description"`               // Help text
	Options        []string        `json:"options,omitempty"`         // For select/multiselect types
	Suggestions    json.RawMessage `json:"suggestions,omitempty"`     // string[] or map[string]string[] for provider-keyed models
	SuggestionsKey string          `json:"suggestions_key,omitempty"` // field key to select from suggestions map
	Min            *int            `json:"min,omitempty"`             // For number types
	Max            *int            `json:"max,omitempty"`             // For number types
	Advanced       bool            `json:"advanced,omitempty"`        // Hide behind "advanced" toggle in quick setup
	Group          string          `json:"group,omitempty"`           // Layout group: same-group fields render side-by-side
}

ConfigField represents a single editable configuration field

type ConfigSchema

type ConfigSchema struct {
	CommonFields []ConfigField `json:"common_fields"` // Editable fields for the config form
	APIKeyHint   string        `json:"api_key_hint"`  // Instructions for setting API keys
}

ConfigSchema defines editable configuration fields for a framework

type Framework

type Framework struct {
	// Identity
	ID          string `json:"id"`                // "hermes", "zeroclaw", "openclaw"
	Name        string `json:"name"`              // Display name
	Description string `json:"description"`       // Short description
	Language    string `json:"language"`          // "python", "rust", "typescript"
	Repository  string `json:"repository"`        // GitHub URL
	Website     string `json:"website,omitempty"` // Official website URL (optional)

	// Installation
	InstallMethod string   `json:"install_method"` // "script", "cargo", "npm", "pip", "manual"
	InstallCmd    string   `json:"install_cmd"`    // Command or script URL
	Requirements  []string `json:"requirements"`   // ["python>=3.11", "node>=22"]

	// Version constraints (optional — empty means "no constraint" / "unknown")
	MinVersion    string `json:"min_version,omitempty"`    // Minimum compatible version (e.g. "0.7.0")
	LatestVersion string `json:"latest_version,omitempty"` // Latest known release version

	// Configuration
	ConfigFormat string        `json:"config_format"`           // "toml", "json", "yaml"
	ConfigPath   string        `json:"config_path"`             // "~/.hermes/config.yaml"
	ConfigDir    string        `json:"config_dir"`              // "~/.hermes"
	ConfigSchema *ConfigSchema `json:"config_schema,omitempty"` // Optional config form schema

	// Runtime
	BinaryPath  string `json:"binary_path"`            // "~/.local/bin/hermes"
	AdapterType string `json:"adapter_type"`           // "http", "websocket", "cli", "hybrid"
	DefaultPort int    `json:"default_port,omitempty"` // 0 if not applicable

	// Lifecycle commands
	StartCmd   string `json:"start_cmd"`   // "hermes gateway start"
	StopCmd    string `json:"stop_cmd"`    // "" (means PID-based)
	StatusCmd  string `json:"status_cmd"`  // "hermes status" or ""
	RestartCmd string `json:"restart_cmd"` // Optional explicit restart command

	// Status detection (for adapters without HTTP APIs)
	PIDFile   string `json:"pid_file,omitempty"`   // "~/.hermes/gateway.pid"
	StateFile string `json:"state_file,omitempty"` // "~/.hermes/gateway_state.json"
	HealthURL string `json:"health_url,omitempty"` // "http://localhost:42617/health"

	// Logs and activity
	LogDir    string `json:"log_dir"`    // "~/.hermes/logs"
	LogFormat string `json:"log_format"` // "text", "json"
}

Framework describes a single Claw agent framework

func (Framework) DefaultInstallCmd

func (fw Framework) DefaultInstallCmd() string

DefaultInstallCmd returns the default package-manager command for this framework (e.g. "cargo install zeroclaw"). Returns "" for non-package-manager install methods (script, manual).

func (Framework) IsCustomInstallCmd

func (fw Framework) IsCustomInstallCmd() bool

IsCustomInstallCmd reports whether the registry specifies a non-default install command for this framework (e.g. --git, @version, custom flags).

type Registry

type Registry struct {
	Version    string      `json:"version"`
	UpdatedAt  time.Time   `json:"updated_at"`
	Frameworks []Framework `json:"frameworks"`
}

Registry represents the complete Claw frameworks registry

Jump to

Keyboard shortcuts

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