Documentation
¶
Overview ¶
Package installer is the public UAP installer API for standard local Agent Plugins packages. Callers must not import raw Store or Kernel types through this package; composition stays inside New. Inspect reports pending native intents, journals and unfinished receipts without recovering them. Recover takes that observation and refuses a changed scope. Request.Targets selects two distinct registered clients. Historical group removal retains Claude/Codex limits; selected native removal needs its typed capability. Switch remains unpublished.
Index ¶
- Variables
- type Assessment
- type AssessmentOutcome
- type BindingFacts
- type ClientMetadata
- type ClientResult
- type ClientTarget
- type ComponentDecision
- type Config
- type Decision
- type DeliveryPlan
- type Engine
- func (e *Engine) Apply(ctx context.Context, prepared *PreparedOperation, decision Decision) (result Result, err error)
- func (e *Engine) Discover() []ClientMetadata
- func (e *Engine) Inspect(_ context.Context) (Inspection, error)
- func (e *Engine) LocalPackageTreeDigest(ctx context.Context, packageRoot string) (string, error)
- func (e *Engine) Prepare(ctx context.Context, req Request) (*PreparedOperation, error)
- func (e *Engine) Recover(ctx context.Context, observed Inspection) (Result, error)
- func (e *Engine) RecoverCurrent(ctx context.Context) (Result, error)
- func (e *Engine) ReserveIdentity(req IdentityRequest) (IdentityReservation, error)
- func (e *Engine) SupportsClient(clientID string) bool
- func (e *Engine) SwitchRetained(ctx context.Context, req Request, decision Decision) (Result, error)
- func (e *Engine) VerifyProfileAuthority(ctx context.Context, installationID, bindingID string) error
- type IdentityRequest
- type IdentityReservation
- type InspectedBinding
- type InspectedInstallation
- type Inspection
- type NextAction
- type OpenCodePreparedHost
- type OpenCodeProbe
- type Operation
- type Outcome
- type PendingJournal
- type PendingNativeIntent
- type PendingReceipt
- type Plan
- type PlanDiagnostic
- type PlanTarget
- type PreparedOperation
- type ProgressEvent
- type ProgressPhase
- type RecoveryObservation
- type RecoveryReport
- type Request
- type Result
- type TargetFacts
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidConfig = errors.New("installer config rejected") ErrUnsupported = errors.New("installer operation is not published in this beta") ErrInvalidHandle = errors.New("prepared operation does not belong to this engine") ErrHandleClosed = errors.New("prepared operation is closed") ErrHandleBusy = errors.New("prepared operation is applying") ErrAlreadyApplied = errors.New("prepared operation already reached a terminal apply") ErrCancelled = errors.New("installer apply canceled") ErrRecoveryRequired = errors.New("installer recovery required") ErrPlanChanged = errors.New("installer recovery plan changed") ErrInvalidRequest = errors.New("installer request rejected") ErrAmbiguousInstallations = errors.New("ambiguous installations") ErrIncomplete = errors.New("required components missing from plan") ErrUpdateRequired = errors.New("install cannot change an active revision; use update") ErrNotInstalled = errors.New("update and repair require an existing owned binding") ErrAssessmentRejected = errors.New("package assessment is not allow") )
var ErrHostTargetRequired = hostprep.ErrHostTargetRequired
Functions ¶
This section is empty.
Types ¶
type Assessment ¶
type Assessment struct {
TreeDigest string
Outcome AssessmentOutcome
Reason string
}
Assessment is a digest-bound content verdict. It is not a filesystem plan.
type AssessmentOutcome ¶
type AssessmentOutcome string
AssessmentOutcome is the host-visible scanner verdict.
const ( AssessmentAllow AssessmentOutcome = "allow" AssessmentBlock AssessmentOutcome = "block" )
type BindingFacts ¶
type BindingFacts struct {
ProfileAuthority *domain.ProfileAuthority `json:"-"`
// SelectedDelivery is immutable operational authority, excluded from diagnostic JSON.
SelectedDelivery domain.SelectedDelivery `json:"-"`
InstallationID, ClientID, BindingID, Scope string
TargetPath, DataRoot, DataReceiptID string
OperationID, TreeDigest string
}
BindingFacts is the typed committed-binding view for host seams.
type ClientMetadata ¶
type ClientMetadata struct {
ClientID string
Scopes []string
ExecutablePresent bool
ExecutablePath string
Bindings []InspectedBinding
}
ClientMetadata is read-only provider surface. Discover does not execute files.
type ClientResult ¶
type ClientResult struct {
ProfileAuthority *domain.ProfileAuthority `json:"-"`
// SelectedDelivery is immutable operational authority, excluded from diagnostic JSON.
SelectedDelivery domain.SelectedDelivery `json:"-"`
ClientID, BindingID, TreeDigest string
Materialization, Activation, Authentication, Policy, Verification string
RequiredComponents []string
}
ClientResult is the public per-client lifecycle view. Mapping is not a bool.
type ClientTarget ¶
type ClientTarget struct {
ClientID, ClientConfigRoot, ClientExecutable string
PackageRoot string
ExternalUninstalled bool
}
ClientTarget is one registered selection in a mutating group request. Group removal retains the published Claude/Codex boundary.
type ComponentDecision ¶
type ComponentDecision struct{ Kind, Name, Support, Reason string }
type Config ¶
type Config struct {
// OpenCodeProbe defaults to the explicit-target facade. New captures and pins
// the allowlisted environment once; it never executes a probe.
OpenCodeProbe OpenCodeProbe
OpenCodeProbeEnvironment []string
// StateRoot is the owned UAP namespace. It is required and must be an
// absolute clean path. New does not create it.
StateRoot string
StateFile, LockFile, OperationsDir, PluginDataBase, ManagedRoot, TempRoot string
HelperExecutable, HelperVersion string
// Registry is the explicit set of client adapters supported by this
// executable. Nil is rejected rather than silently enabling every client.
Registry *clients.Registry
// EnableNativeObserver composes the namespace-aware client observer for
// repair and recovery. Callers that provide a real command runner should
// enable it; leaving it off retains the filesystem-only compatibility path.
EnableNativeObserver bool
Runner ports.CommandRunner
// ServerName selects the declared MCP server whose args the host may replace.
ServerName string
// ProjectArgs replaces args of ServerName. It is host-owned and must be
// deterministic. A missing declared server or a callback error fails staging.
ProjectArgs func(BindingFacts) ([]string, error)
// OnCommittedBinding runs after the package commit and before activation.
// Failed handoffs can be retried for the same binding and digest. Hosts must
// make effects idempotent using those identities, not the attempt OperationID.
OnCommittedBinding func(context.Context, BindingFacts) error
// Assess is optional and digest-bound. The constructor does not start a
// download scanner. When set, block and unavailable never become allow.
Assess func(context.Context, string, string) (Assessment, error)
// TrustedLocalPackages is an explicit policy for bundled or otherwise
// pre-authorized local bytes. When false, Prepare requires either Assess or
// a digest-bound Request.Assessment; nil is never an implicit allow.
TrustedLocalPackages bool
// Progress reports coarse phases. It must not return an error, prompt, or
// start a nested installer.
Progress func(ProgressEvent)
// ClientExecutables are optional explicit client paths Discover Lstats
// without executing. Empty entries fall back to PATH presence of the
// well-known binary name. New copies the map.
ClientExecutables map[string]string
}
Config is copied by New. Later mutation of the caller's value is ignored.
type Decision ¶
type Decision struct {
Confirmed bool
}
Decision is host UI confirmation, outside mutation locks.
type DeliveryPlan ¶
type DeliveryPlan struct {
ProfileAuthority *domain.ProfileAuthority `json:"-"`
// SelectedDelivery is immutable operational authority, excluded from diagnostic JSON.
SelectedDelivery domain.SelectedDelivery `json:"-"`
ActivePath string
Status, PackageMode, InstallIntent, PhysicalArtifactID string
Activation, Authentication, Policy, Verification string
Components []ComponentDecision
UserActions, LocalActions, Warnings []string
Diagnostics []PlanDiagnostic
}
DeliveryPlan is the provider's presentation snapshot, without mutation APIs. LocalActions may contain host paths and are for private human output only.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the process-local installer. It does not export Store or Kernel.
func New ¶
New validates Config and copies it. It does not create directories, open a journal, or execute a helper or client.
func (*Engine) Apply ¶
func (e *Engine) Apply(ctx context.Context, prepared *PreparedOperation, decision Decision) (result Result, err error)
Apply executes a prepared operation. A canceled decision returns before usecase mutation, recovery, and callbacks. Result is populated even when err != nil. Close during Apply returns ErrHandleBusy without releasing the snapshot.
func (*Engine) Discover ¶
func (e *Engine) Discover() []ClientMetadata
Discover returns metadata for the explicitly registered providers, including executable presence and current bindings. It does not create state, run a helper, or execute a found file.
func (*Engine) Inspect ¶
func (e *Engine) Inspect(_ context.Context) (Inspection, error)
Inspect is read-only. It does not recover journals or invoke host seams.
func (*Engine) LocalPackageTreeDigest ¶
snapshotLocalPackage uses packagedigest executable overrides so Windows host FileMode (no 0111 on regular files) does not drop logical bin/ helpers from TreeDigest. AcquireLocal hashes POSIX bits from the checkout. LocalPackageTreeDigest is the canonical TreeDigest of a local package root. It snapshots into TempRoot, does not write installer state, and does not report Progress. Optional Assess still binds that digest.
func (*Engine) Prepare ¶
Prepare captures a sealed snapshot for install or inspects owned state for remove. It does not mutate installed client config or the Notifications runtime ledger.
func (*Engine) Recover ¶
Recover finishes already recorded UAP transactions for the observed scope. It reconciles only persisted selected native intents, without rediscovery. A new pending operation that was not in observed returns ErrPlanChanged without recovery.
func (*Engine) RecoverCurrent ¶
RecoverCurrent inspects this root and recovers that exact live scope.
func (*Engine) ReserveIdentity ¶
func (e *Engine) ReserveIdentity(req IdentityRequest) (IdentityReservation, error)
ReserveIdentity returns installation and binding IDs without creating TempRoot, capturing a snapshot, or mutating client config.
func (*Engine) SupportsClient ¶
SupportsClient reports whether the composition root registered the client for this engine. The facade never broadens a caller's explicit registry.
func (*Engine) SwitchRetained ¶
func (e *Engine) SwitchRetained(ctx context.Context, req Request, decision Decision) (Result, error)
SwitchRetained is the §5.5.1 retained-only metadata update. It revises source/digest for a data_retained installation with zero live bindings. Active installations must use Update. RequiredComponents are ignored: this step does not install clients.
type IdentityRequest ¶
type IdentityRequest struct {
ClientID string
InstallationID string
Allocate bool
// DeclaredName is the plugin.json name used to derive a prospective
// BindingID for a new install. Empty leaves BindingID unset until Prepare
// or an existing binding is found.
DeclaredName string
ClientConfigRoot string
}
IdentityRequest selects an installation without capturing a package snapshot.
type IdentityReservation ¶
type IdentityReservation struct {
InstallationID string
BindingID string
Scope string
TargetPath string
}
IdentityReservation is the §7.2 identity view. BindingID and TargetPath are filled from an existing binding, or derived from DeclaredName without staging when this is a new install.
type InspectedBinding ¶
type InspectedBinding struct {
ClientID, BindingID, Scope, TargetPath, DataRoot, TreeDigest string
Materialization, Activation, Authentication, Verification string
}
InspectedBinding is a public subset of one client binding.
type InspectedInstallation ¶
type InspectedInstallation struct {
InstallationID string
TreeDigest string
Bindings []InspectedBinding
DataRetained bool
DataRoots []string
}
InspectedInstallation is a public subset of one UAP installation.
type Inspection ¶
type Inspection struct {
StateRoot string
Installations []InspectedInstallation
Recovery RecoveryObservation
}
Inspection is a read-only view of owned UAP state. Recovery facts are limited identities, not raw JSON and not an executable plan.
type NextAction ¶
NextAction is a structured follow-up. It is not a bool and not a retry token.
type OpenCodePreparedHost ¶
type OpenCodePreparedHost = opencodehost.NativePrepared
OpenCodePreparedHost preserves the facade contract while sharing its pure, immutable native authority with the CLI's existing lifecycle consumer.
type OpenCodeProbe ¶
OpenCodeProbe is a trusted composition port. It receives a fresh target copy on each call; production defaults to the one bounded explicit-target facade.
type Operation ¶
type Operation string
Operation is the process-local lifecycle verb. Install, update, repair, and remove are published. Two registered mutation targets use Request.Targets.
const ( OpInstall Operation = "install" OpRemove Operation = "remove" OpUpdate Operation = "update" OpRepair Operation = "repair" // OpRefreshProjection re-renders an intact installed package with current // host projection inputs while retaining its exact package revision. OpRefreshProjection Operation = "refresh_projection" )
type Outcome ¶
type Outcome string
Outcome is the coarse public result. Mapping is not a bool.
const ( OutcomeUnchanged Outcome = "unchanged" OutcomeCompleted Outcome = "completed" OutcomeIncomplete Outcome = "incomplete" OutcomeRecovery Outcome = "recovery_required" OutcomeConflict Outcome = "conflict" OutcomeCancelled Outcome = "cancelled" //nolint:misspell // Preserve the public outcome wire value. )
type PendingJournal ¶
type PendingJournal struct {
OperationID, Digest, BindingID, InstallationID, TargetPath, Phase string
}
PendingJournal is one open directory-swap journal.
type PendingNativeIntent ¶
type PendingNativeIntent struct {
Binding BindingFacts
Intent domain.PendingNativeIntent `json:"-"`
NativeProfileRoot string
Digest string
}
PendingNativeIntent exposes the exact persisted attempt and selected facts. Diagnostic serialization cannot grant selected-delivery authority. Digest binds the complete binding (including ownership and revision), not settings document bytes: unrelated foreign edits are reconciled by the native adapter.
func (PendingNativeIntent) MarshalJSON ¶
func (pending PendingNativeIntent) MarshalJSON() ([]byte, error)
MarshalJSON renders the existing domain intent for diagnostics. Unmarshal does not restore Intent or Binding.SelectedDelivery (both json:"-"); a JSON round trip cannot create the typed observation accepted by Recover.
type PendingReceipt ¶
type PendingReceipt struct {
OperationID, BindingID, InstallationID, TargetPath, Phase string
JournalPresent bool
}
PendingReceipt is an unfinished state receipt, including state_committed after the matching journal was already removed.
type Plan ¶
type Plan struct {
ProfileAuthority *domain.ProfileAuthority `json:"-"`
OpenCodeProfile *opencodehost.Profile `json:",omitempty"`
OpenCodeSelections []opencodehost.Selection `json:",omitempty"`
// SelectedDelivery is immutable operational authority, excluded from diagnostic JSON.
SelectedDelivery domain.SelectedDelivery `json:"-"`
Operation Operation
SourceRoot string
TreeDigest string
DigestAlgorithm string
ClientID string
ConfigRoot string
TargetPath string
InstallationID string
BindingID string
HelperVersion string
HelperDigest string
RequiredMissing []string
NoChange bool
Targets []PlanTarget
Delivery DeliveryPlan
Client ClientResult
RequiresConfirmation bool
}
Plan is an immutable copy for presentation. Operational paths are included because the embedding host already chose explicit roots.
type PlanDiagnostic ¶
type PlanDiagnostic struct{ Severity, Boundary, Code, Path, Item, Message string }
type PlanTarget ¶
type PlanTarget struct {
ProfileAuthority *domain.ProfileAuthority `json:"-"`
// SelectedDelivery is immutable operational authority, excluded from diagnostic JSON.
SelectedDelivery domain.SelectedDelivery `json:"-"`
ClientID, ConfigRoot, TargetPath, BindingID, TreeDigest string
NoChange bool
}
PlanTarget is one client's prepared identity in a group handle.
type PreparedOperation ¶
type PreparedOperation struct {
// contains filtered or unexported fields
}
PreparedOperation owns a sealed source snapshot until Close or a terminal Apply.
func (*PreparedOperation) Close ¶
func (p *PreparedOperation) Close() error
func (*PreparedOperation) Plan ¶
func (p *PreparedOperation) Plan() Plan
type ProgressEvent ¶
type ProgressEvent struct {
Phase ProgressPhase
}
ProgressEvent is an observational checkpoint. The observer does not decide.
type ProgressPhase ¶
type ProgressPhase string
ProgressPhase is a coarse installer phase. Percent complete is not invented.
const ( ProgressPrepare ProgressPhase = "prepare" ProgressPreflight ProgressPhase = "preflight" ProgressStage ProgressPhase = "stage" ProgressCommit ProgressPhase = "commit" ProgressActivate ProgressPhase = "activate" ProgressVerify ProgressPhase = "verify" ProgressComplete ProgressPhase = "complete" )
type RecoveryObservation ¶
type RecoveryObservation struct {
// StateDigest binds all persisted bindings, receipts and installation facts.
StateDigest string
Required bool
Journals []PendingJournal
NativeIntents []PendingNativeIntent
Receipts []PendingReceipt
Reason string
}
RecoveryObservation is the §5.8 read-only pending-transaction view.
type RecoveryReport ¶
type RecoveryReport struct {
Resolved []PendingReceipt
Remaining []PendingReceipt
Unknown []PendingReceipt
}
RecoveryReport is the §5.8 resolved/remaining/unknown receipt view. It is populated even when Recover returns an error.
type Request ¶
type Request struct {
Operation Operation
PackageRoot string
// SourceRoot is the stable absolute local source identity when PackageRoot
// points at a host-owned sealed snapshot. Empty means PackageRoot itself.
SourceRoot string
// ExecutableFiles preserves a host-acquired snapshot's logical file modes.
// Nil infers local package executables; a non-nil empty slice means none.
// Supported for single-target requests only. Assessment still has to match
// the resulting complete tree digest.
ExecutableFiles []string
ClientID string
ClientConfigRoot string
ClientExecutable string
InstallationID string
OperationID string
Selector string
RequiredComponents []string
// Assessment is a host decision for these exact local bytes. It is copied
// and digest-checked by Prepare. Confirmation of the filesystem plan does
// not create or alter this security decision.
Assessment *Assessment
// ExternalUninstalled is host attestation that the selected client's
// native plugin was already removed, or was never activated. Confirmed
// Apply does not invent this fact.
ExternalUninstalled bool
// Targets selects one explicit client or two Claude/Codex clients in a group.
// Empty means the single ClientID fields. Groups keep the same Operation verb.
Targets []ClientTarget
// KnownTargets carries host-observed facts for installed sibling bindings
// that are not selected by this operation. The installer verifies BindingID
// against owned state before using ConfigRoot or Executable; it never reads a
// host sidecar or guesses a profile from HOME.
KnownTargets []TargetFacts
// contains filtered or unexported fields
}
Request is copied by Prepare. Subsequent caller edits do not change the handle.
type Result ¶
type Result struct {
// Delivery is the actual lifecycle plan, absent when Apply stopped before planning.
Delivery *DeliveryPlan
Operation Operation
InstallationID string
Outcome Outcome
Binding BindingFacts
ManualActions []string
Reason string
NoChange bool
Mutated bool
RequiresConfirmation bool
DataRetained bool
Client ClientResult
Targets []ClientResult
NextActions []NextAction
// Recovery classifies observed receipts after Recover. Apply leaves it empty.
Recovery RecoveryReport
}
Result is returned together with an error when part of the work already happened.
Source Files
¶
- apply.go
- apply_confirm.go
- config.go
- confirmation.go
- discover.go
- doc.go
- engine.go
- errors.go
- group.go
- group_apply.go
- group_handoff.go
- group_prepare.go
- group_remove.go
- identity.go
- inspect.go
- journal_recovery.go
- native_recovery.go
- opencode_host.go
- opencode_host_snapshot.go
- opencode_recovery.go
- package.go
- prepare.go
- presentation.go
- seams.go
- selected_lifecycle.go
- switch_retained.go
- target_facts.go
- types.go