setup

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package setup owns the transactional domain core for installing JetKVM into supported agent hosts. Host-native CLIs remain the terminal authority.

Index

Constants

View Source
const (
	CanonicalMCPCommand = "jetkvm"
	MarketplaceSource   = "kaaanata/jetkvm-cli"
	MarketplaceName     = "jetkvm"
	PluginReference     = "jetkvm@jetkvm"
)

Variables

View Source
var (
	ErrInvalidTarget    = errors.New("invalid setup target")
	ErrHostUnavailable  = errors.New("agent host CLI is unavailable")
	ErrCommandFailed    = errors.New("agent host command failed")
	ErrSetupConflict    = errors.New("setup conflict")
	ErrMigrationNeeded  = errors.New("legacy direct integration requires explicit migration")
	ErrInvalidPlan      = errors.New("setup plan does not match the authoritative transition")
	ErrStalePlan        = errors.New("setup plan is stale")
	ErrReceiptNotFound  = errors.New("setup receipt not found")
	ErrRollbackConflict = errors.New("setup rollback ownership conflict")
	ErrVerification     = errors.New("setup verification failed")
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string   `json:"name"`
	Args []string `json:"args,omitempty"`
	Dir  string   `json:"dir,omitempty"`
}

type CommandResult

type CommandResult struct {
	Stdout   []byte
	Stderr   []byte
	ExitCode int
}

type Component

type Component struct {
	Present bool     `json:"present"`
	Source  string   `json:"source,omitempty"`
	Version string   `json:"version,omitempty"`
	Command string   `json:"command,omitempty"`
	Args    []string `json:"args,omitempty"`
}

type Config

type Config struct {
	Runner   Runner
	StateDir string
	Now      func() time.Time
}

type DoctorCheck

type DoctorCheck struct {
	Name    string `json:"name"`
	OK      bool   `json:"ok"`
	Message string `json:"message"`
}

type DoctorReport

type DoctorReport struct {
	Target   Target        `json:"target"`
	Status   DoctorStatus  `json:"status"`
	State    State         `json:"state"`
	Checks   []DoctorCheck `json:"checks"`
	Observed time.Time     `json:"observed_at"`
}

type DoctorStatus

type DoctorStatus string
const (
	DoctorReady          DoctorStatus = "ready"
	DoctorActionRequired DoctorStatus = "action_required"
	DoctorConflict       DoctorStatus = "conflict"
)

type Host

type Host string
const (
	HostCodex      Host = "codex"
	HostClaudeCode Host = "claude-code"
)

type JournalEntry

type JournalEntry struct {
	Step             string    `json:"step"`
	Command          Command   `json:"command"`
	AfterFingerprint string    `json:"after_fingerprint,omitempty"`
	CompletedAt      time.Time `json:"completed_at"`
}

type Mode

type Mode string
const (
	ModePlugin Mode = "plugin"
	ModeDirect Mode = "direct"
)

type Plan

type Plan struct {
	ID                uuid.UUID `json:"id"`
	Target            Target    `json:"target"`
	PluginVersion     string    `json:"plugin_version"`
	InitialState      State     `json:"initial_state"`
	BeforeFingerprint string    `json:"before_fingerprint"`
	Steps             []Step    `json:"steps,omitempty"`
	DryRun            bool      `json:"dry_run"`
	CreatedAt         time.Time `json:"created_at"`
}

type PlanRequest

type PlanRequest struct {
	Target        Target
	PluginVersion string
	Migrate       bool
	DryRun        bool
}

type Receipt

type Receipt struct {
	SchemaVersion     int            `json:"schema_version"`
	ID                uuid.UUID      `json:"id"`
	PlanID            uuid.UUID      `json:"plan_id"`
	Target            Target         `json:"target"`
	PluginVersion     string         `json:"plugin_version,omitempty"`
	Status            ReceiptStatus  `json:"status"`
	InitialState      State          `json:"initial_state"`
	BeforeFingerprint string         `json:"before_fingerprint"`
	AfterFingerprint  string         `json:"after_fingerprint,omitempty"`
	OwnedComponents   []string       `json:"owned_components,omitempty"`
	Journal           []JournalEntry `json:"journal,omitempty"`
	RollbackJournal   []JournalEntry `json:"rollback_journal,omitempty"`
	FailureKind       string         `json:"failure_kind,omitempty"`
	CreatedAt         time.Time      `json:"created_at"`
	UpdatedAt         time.Time      `json:"updated_at"`
}

type ReceiptStatus

type ReceiptStatus string
const (
	ReceiptPrepared         ReceiptStatus = "prepared"
	ReceiptCommitted        ReceiptStatus = "committed"
	ReceiptRolledBack       ReceiptStatus = "rolled_back"
	ReceiptRollbackConflict ReceiptStatus = "rollback_conflict"
	ReceiptFailed           ReceiptStatus = "failed"
	ReceiptDryRun           ReceiptStatus = "dry_run"
	ReceiptUninstalled      ReceiptStatus = "uninstalled"
)

type Runner

type Runner interface {
	Run(context.Context, Command) (CommandResult, error)
}

Runner is the only process execution boundary. Implementations must not interpret a non-zero exit as success or inject credentials into commands.

type Scope

type Scope string
const (
	ScopeUser    Scope = "user"
	ScopeProject Scope = "project"
	ScopeLocal   Scope = "local"
)

type Service

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

func NewService

func NewService(config Config) (*Service, error)

func (*Service) Apply

func (s *Service) Apply(ctx context.Context, plan Plan) (Receipt, error)

func (*Service) Doctor

func (s *Service) Doctor(ctx context.Context, target Target, version string) (DoctorReport, error)

func (*Service) Inspect

func (s *Service) Inspect(ctx context.Context, target Target, pluginVersion string) (Snapshot, error)

func (*Service) Plan

func (s *Service) Plan(ctx context.Context, request PlanRequest) (Plan, error)

func (*Service) Uninstall

func (s *Service) Uninstall(ctx context.Context, target Target, dryRun bool) (Receipt, error)

type Snapshot

type Snapshot struct {
	Target      Target    `json:"target"`
	HostVersion string    `json:"host_version,omitempty"`
	Marketplace Component `json:"marketplace"`
	Plugin      Component `json:"plugin"`
	DirectMCP   Component `json:"direct_mcp"`
	State       State     `json:"state"`
	Fingerprint string    `json:"fingerprint"`
}

type State

type State string
const (
	StateAbsent          State = "absent"
	StateEquivalent      State = "equivalent"
	StateOwnedOutdated   State = "owned_outdated"
	StateForeignConflict State = "foreign_conflict"
	StateLegacyDirect    State = "legacy_direct"
	StatePartial         State = "partial"
)

type Step

type Step struct {
	Name      string  `json:"name"`
	Do        Command `json:"do"`
	Undo      Command `json:"undo"`
	Component string  `json:"component"`
	Creates   bool    `json:"creates"`
}

type Store

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

func NewStore

func NewStore(directory string) (*Store, error)

func (*Store) LatestOwned

func (s *Store) LatestOwned(target Target) (Receipt, error)

func (*Store) Load

func (s *Store) Load(id uuid.UUID) (Receipt, error)

func (*Store) Save

func (s *Store) Save(receipt Receipt) error

type Target

type Target struct {
	Host      Host   `json:"host"`
	Mode      Mode   `json:"mode"`
	Scope     Scope  `json:"scope"`
	Workspace string `json:"workspace,omitempty"`
}

func (Target) Normalize

func (t Target) Normalize() Target

Normalize applies the public setup defaults. Direct mode is never inferred: only an explicit ModeDirect value selects it.

func (Target) Validate

func (t Target) Validate() error

Jump to

Keyboard shortcuts

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