plugin

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 59 Imported by: ? 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

Index

Constants

View Source
const (
	// Lifecycle state changes.
	EventStateChange = "plugin/state_change"

	// Install flow.
	EventInstallStarted  = "plugin/install_started"
	EventInstallFinished = "plugin/install_finished"
	EventInstallError    = "plugin/install_error"

	// Dev install flow.
	EventDevInstallStart    = "plugin/dev_install_start"
	EventDevInstallError    = "plugin/dev_install_error"
	EventDevInstallComplete = "plugin/dev_install_complete"

	// Plugin reload.
	EventReloadStart    = "plugin/dev_reload_start"
	EventReloadError    = "plugin/dev_reload_error"
	EventReloadComplete = "plugin/dev_reload_complete"

	// Update.
	EventUpdateStarted  = "plugin/update_started"
	EventUpdateError    = "plugin/update_error"
	EventUpdateComplete = "plugin/update_complete"

	// Initialization.
	EventInitComplete = "plugin/init_complete"

	// Durable installed-inventory changes.
	EventInventoryChanged = "plugin/inventory_changed"

	// Crash recovery.
	EventCrash               = "plugin/crash"
	EventCrashRecoveryFailed = "plugin/crash_recovery_failed"
	EventRecovered           = "plugin/recovered"

	// State persistence.
	EventStateWriteError = "plugin/state_write_error"

	// Protocol version.
	EventDeprecatedProtocol = "plugin/deprecated_protocol"

	// Process logging.
	EventProcessLog = "plugin/process/log"
)

Plugin event constants.

View Source
const (
	MaxPluginSize = 1024 * 1024 * 1024 // 1GB
)

Variables

This section is empty.

Functions

func Copy

func Copy(srcFile, dstFile string) error

func CopyDir

func CopyDir(dst, src string) error

CopyDir copies the content of src to dst. src should be a full path.

func CopyDirectory

func CopyDirectory(scrDir, dest string) error
func CopySymLink(source, dest string) error

func CreateIfNotExists

func CreateIfNotExists(dir string, perm os.FileMode) error

func Exists

func Exists(filePath string) bool

func FindGoBinary

func FindGoBinary() (string, error)

FindGoBinary looks for the Go binary in a number of well-known paths in case it's not available in the PATH.

func FindNodeBinary

func FindNodeBinary() (string, error)

FindNodeBinary tries to locate the Node.js binary across common install paths.

func FindPnpmBinary

func FindPnpmBinary() (string, error)

FindPnpmBinary looks for the Pnpm binary in a number of well-known paths in case it's not available in the PATH.

func HydrateBuildOpts

func HydrateBuildOpts(opts *types.BuildOpts) error

HydrateBuildOpts adds the additional build options if they are not specified.

func PrepareCommandWithBinaries

func PrepareCommandWithBinaries(
	command string,
	args []string,
	binaries ...string,
) (*exec.Cmd, error)

PrepareCommandWithBinaries returns an exec.Cmd with extended PATH to include the directories of provided binary paths.

func ValidateForPhase added in v0.1.4

func ValidateForPhase(phase lifecycle.PluginPhase, meta config.PluginMeta, location string) error

ValidateForPhase checks that a plugin meets the requirements for the given phase.

Types

type CrashRecoveryState added in v0.1.4

type CrashRecoveryState struct {
	Attempts    int
	NextBackoff time.Duration
	LastAttempt time.Time
}

CrashRecoveryState tracks exponential backoff for a single plugin.

type DeprecatedProtocolPayload added in v0.2.0

type DeprecatedProtocolPayload struct {
	PluginID       string `json:"pluginID"`
	Version        int    `json:"version"`
	CurrentVersion int    `json:"currentVersion"`
}

DeprecatedProtocolPayload is sent with EventDeprecatedProtocol.

type DevServerChecker

type DevServerChecker interface {
	IsManaged(pluginID string) bool
}

DevServerChecker allows the plugin manager to check if a plugin is managed by the dev server system.

type HealthChecker added in v0.1.4

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

HealthChecker periodically checks the health of running plugins and triggers crash recovery when issues are detected.

func NewHealthChecker added in v0.1.4

func NewHealthChecker(logger logging.Logger, pm *pluginManager) *HealthChecker

NewHealthChecker creates a new HealthChecker.

func (*HealthChecker) CancelRecovery added in v0.1.4

func (hc *HealthChecker) CancelRecovery(pluginID string)

CancelRecovery cancels any in-progress crash recovery goroutine for the given plugin. This should be called when a plugin is uninstalled to prevent recovery loops.

func (*HealthChecker) HandleCrashWithBackoff added in v0.1.4

func (hc *HealthChecker) HandleCrashWithBackoff(pluginID string)

HandleCrashWithBackoff handles a plugin crash with exponential backoff. Uses an iterative loop instead of recursion to avoid stack growth.

func (*HealthChecker) IsInCrashCycle added in v0.2.0

func (hc *HealthChecker) IsInCrashCycle(pluginID string) bool

IsInCrashCycle returns true if the plugin has already crashed at least once within the current budget window. Used by HandlePluginCrash to suppress repeated "plugin/crash" notifications during crash-recover-crash loops.

func (*HealthChecker) ResetBudget added in v0.4.0

func (hc *HealthChecker) ResetBudget(pluginID string)

ResetBudget clears the crash budget and recovery state for a plugin. This should be called when the user manually triggers a reload so that the plugin gets fresh retry attempts instead of being immediately rejected by an exhausted budget from a prior crash cycle.

func (*HealthChecker) Start added in v0.1.4

func (hc *HealthChecker) Start(ctx context.Context)

Start begins the periodic health check loop.

type LoadPluginOptions

type LoadPluginOptions struct {
	DevMode       bool
	DevModePath   string
	ExistingState *plugintypes.PluginStateRecord
	// contains filtered or unexported fields
}

LoadPluginOptions configures how a plugin is loaded.

type Manager

type Manager interface {
	Initialize(ctx context.Context) error
	Run(ctx context.Context)
	Shutdown()

	InstallInDevMode() (*config.PluginMeta, error)
	InstallDevPluginFromPath(path string) (sdktypes.PluginInfo, error)
	UnlinkDevPlugin(id string) (sdktypes.PluginInfo, error)
	InstallFromPathPrompt() (*config.PluginMeta, error)
	InstallPluginFromPath(path string) (*config.PluginMeta, error)
	InstallPluginVersion(pluginID string, version string) (*config.PluginMeta, error)

	LoadPlugin(id string, opts *LoadPluginOptions) (sdktypes.PluginInfo, error)
	ReloadPlugin(id string) (sdktypes.PluginInfo, error)
	UnloadPlugin(id string) error
	StopDevPlugin(id string) error
	ReloadManagedPlugin(ctx context.Context, id, source, generation string) error
	RetryFailedPlugin(id string) (sdktypes.PluginInfo, error)
	UninstallPlugin(id string) (sdktypes.PluginInfo, error)

	GetPlugin(id string) (sdktypes.PluginInfo, error)
	ListPlugins() []sdktypes.PluginInfo
	GetPluginMeta(id string) (config.PluginMeta, error)
	ListPluginMetas() []config.PluginMeta

	ListAvailablePlugins() ([]registry.AvailablePlugin, error)
	SearchPlugins(query, category, sort string) ([]registry.AvailablePlugin, error)
	GetPluginReadme(pluginID string) (string, error)
	GetPluginVersions(pluginID string) ([]registry.VersionInfo, error)
	GetPluginReviews(pluginID string, page int) ([]registry.Review, error)
	GetPluginDownloadStats(pluginID string) (*registry.DownloadStats, error)
	GetPluginReleaseHistory(pluginID string) ([]registry.VersionInfo, error)

	HandlePluginCrash(pluginID string)

	SetDevServerChecker(checker DevServerChecker)
	SetDevServerManager(mgr *devserver.DevServerManager)
	SetPluginLogManager(mgr *pluginlog.Manager)
}

Manager manages the lifecycle and registration of plugins.

func NewManager

func NewManager(
	logger logging.Logger,
	stateRoot *appstate.ScopedRoot,
	pluginsRoot *appstate.ScopedRoot,
	resourceController resource.Controller,
	settingsController settings.Controller,
	execController pluginexec.Controller,
	networkerController networker.Controller,
	logsController pluginlogs.Controller,
	metricController pluginmetric.Controller,
	managers map[string]plugintypes.PluginManager,
	settingsProvider pkgsettings.Provider,
	registryClient *registry.Client,
	telemetryConfigFn func() TelemetryEnvConfig,
) Manager

NewManager returns a new plugin manager.

type PIDTracker added in v0.4.0

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

PIDTracker persists kernel process identity plus supervisor provenance. Numeric legacy PIDs are retained as rejected recovery evidence, never kill authority. Live children remain owned by go-plugin Client.Kill, including on Darwin.

func NewPIDTracker added in v0.4.0

func NewPIDTracker(root *appstate.ScopedRoot) *PIDTracker

func (*PIDTracker) CheckAvailable added in v0.5.0

func (t *PIDTracker) CheckAvailable(id, workspaceID string) error

CheckAvailable runs before exec: unresolved recovery evidence must block a second backend, not merely reject recording it after its startup side effects.

func (*PIDTracker) CleanupStale added in v0.4.0

func (t *PIDTracker) CleanupStale(logger logging.Logger)

func (*PIDTracker) RecordOwned added in v0.5.0

func (t *PIDTracker) RecordOwned(id string, pid int, owner devsession.ProcessOwner) error

func (*PIDTracker) Remove added in v0.4.0

func (t *PIDTracker) Remove(id string)

func (*PIDTracker) Save added in v0.4.0

func (t *PIDTracker) Save() error

type PluginBuilder

type PluginBuilder struct{}

type PluginErrorPayload added in v0.4.1

type PluginErrorPayload struct {
	PluginID string `json:"pluginID"`
	Error    string `json:"error,omitempty"`
}

PluginErrorPayload is sent with EventCrash, EventCrashRecoveryFailed and EventRecovered (which leaves Error empty).

type PluginRefAdapter added in v0.4.0

type PluginRefAdapter struct{ Mgr Manager }

PluginRefAdapter adapts plugin.Manager to devserver.PluginRef.

func (*PluginRefAdapter) GetDevPluginInfo added in v0.4.0

func (a *PluginRefAdapter) GetDevPluginInfo(pluginID string) (bool, string, error)

type PluginReloaderAdapter added in v0.4.0

type PluginReloaderAdapter struct{ Mgr Manager }

PluginReloaderAdapter adapts plugin.Manager to devserver.PluginReloader.

func (*PluginReloaderAdapter) ReloadManagedPlugin added in v0.5.0

func (a *PluginReloaderAdapter) ReloadManagedPlugin(ctx context.Context, id, source, generation string) error

func (*PluginReloaderAdapter) ReloadPlugin added in v0.4.0

func (a *PluginReloaderAdapter) ReloadPlugin(id string) error

func (*PluginReloaderAdapter) StopDevPlugin added in v0.5.0

func (a *PluginReloaderAdapter) StopDevPlugin(id string) error

type ReconcileResult added in v0.1.4

type ReconcileResult struct {
	Records map[string]*plugintypes.PluginRecord
	// Orphans are directories found on disk but not in persisted state.
	Orphans []string
	// Ghosts are entries in persisted state but not on disk.
	Ghosts []string
}

ReconcileResult contains the reconciled plugin state.

type Reconciler added in v0.1.4

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

Reconciler audits the filesystem against persisted state and produces a consistent set of plugin records for the manager.

func NewReconciler added in v0.1.4

func NewReconciler(logger logging.Logger) *Reconciler

NewReconciler creates a new Reconciler.

func (*Reconciler) Reconcile added in v0.1.4

func (r *Reconciler) Reconcile(
	ctx context.Context,
	pluginDir string,
	persistedStates []plugintypes.PluginStateRecord,
) (*ReconcileResult, error)

Reconcile compares the filesystem with persisted state and produces a consistent set of plugin records.

func (*Reconciler) ReconcileFromFilesystem added in v0.1.4

func (r *Reconciler) ReconcileFromFilesystem(
	ctx context.Context,
	pluginDir string,
) (*ReconcileResult, error)

ReconcileFromFilesystem rebuilds state entirely from the filesystem. Used when the state file is corrupt or missing.

type ServiceWrapper added in v0.4.0

type ServiceWrapper struct {
	Mgr Manager
}

ServiceWrapper exposes only the frontend-safe methods of plugin.Manager. Internal methods (SetDevServerChecker, SetPluginLogManager, HandlePluginCrash, Initialize, Run, Shutdown) are excluded to avoid binding warnings from interface/function-type parameters.

func (*ServiceWrapper) GetPlugin added in v0.4.0

func (s *ServiceWrapper) GetPlugin(id string) (sdktypes.PluginInfo, error)

func (*ServiceWrapper) GetPluginDownloadStats added in v0.4.0

func (s *ServiceWrapper) GetPluginDownloadStats(pluginID string) (*registry.DownloadStats, error)

func (*ServiceWrapper) GetPluginMeta added in v0.4.0

func (s *ServiceWrapper) GetPluginMeta(id string) (config.PluginMeta, error)

func (*ServiceWrapper) GetPluginReadme added in v0.4.0

func (s *ServiceWrapper) GetPluginReadme(pluginID string) (string, error)

func (*ServiceWrapper) GetPluginReleaseHistory added in v0.4.0

func (s *ServiceWrapper) GetPluginReleaseHistory(pluginID string) ([]registry.VersionInfo, error)

func (*ServiceWrapper) GetPluginReviews added in v0.4.0

func (s *ServiceWrapper) GetPluginReviews(pluginID string, page int) ([]registry.Review, error)

func (*ServiceWrapper) GetPluginVersions added in v0.4.0

func (s *ServiceWrapper) GetPluginVersions(pluginID string) ([]registry.VersionInfo, error)

func (*ServiceWrapper) InstallDevPluginFromPath added in v0.5.0

func (s *ServiceWrapper) InstallDevPluginFromPath(path string) (sdktypes.PluginInfo, error)

func (*ServiceWrapper) InstallFromPathPrompt added in v0.4.0

func (s *ServiceWrapper) InstallFromPathPrompt() (*config.PluginMeta, error)

func (*ServiceWrapper) InstallInDevMode added in v0.4.0

func (s *ServiceWrapper) InstallInDevMode() (*config.PluginMeta, error)

func (*ServiceWrapper) InstallPluginFromPath added in v0.4.0

func (s *ServiceWrapper) InstallPluginFromPath(path string) (*config.PluginMeta, error)

func (*ServiceWrapper) InstallPluginVersion added in v0.4.0

func (s *ServiceWrapper) InstallPluginVersion(pluginID, version string) (*config.PluginMeta, error)

func (*ServiceWrapper) ListAvailablePlugins added in v0.4.0

func (s *ServiceWrapper) ListAvailablePlugins() ([]registry.AvailablePlugin, error)

func (*ServiceWrapper) ListPluginMetas added in v0.4.0

func (s *ServiceWrapper) ListPluginMetas() []config.PluginMeta

func (*ServiceWrapper) ListPlugins added in v0.4.0

func (s *ServiceWrapper) ListPlugins() []sdktypes.PluginInfo

func (*ServiceWrapper) LoadPlugin added in v0.4.0

func (s *ServiceWrapper) LoadPlugin(id string, opts *LoadPluginOptions) (sdktypes.PluginInfo, error)

func (*ServiceWrapper) ReloadPlugin added in v0.4.0

func (s *ServiceWrapper) ReloadPlugin(id string) (sdktypes.PluginInfo, error)

func (*ServiceWrapper) RetryFailedPlugin added in v0.4.0

func (s *ServiceWrapper) RetryFailedPlugin(id string) (sdktypes.PluginInfo, error)

func (*ServiceWrapper) SearchPlugins added in v0.4.0

func (s *ServiceWrapper) SearchPlugins(query, category, sort string) ([]registry.AvailablePlugin, error)

func (*ServiceWrapper) UninstallPlugin added in v0.4.0

func (s *ServiceWrapper) UninstallPlugin(id string) (sdktypes.PluginInfo, error)

func (*ServiceWrapper) UnlinkDevPlugin added in v0.5.0

func (s *ServiceWrapper) UnlinkDevPlugin(id string) (sdktypes.PluginInfo, error)

type StateChangePayload added in v0.1.4

type StateChangePayload struct {
	PluginID  string                `json:"pluginID"`
	From      lifecycle.PluginPhase `json:"from"`
	To        lifecycle.PluginPhase `json:"to"`
	Reason    string                `json:"reason"`
	Timestamp time.Time             `json:"timestamp"`
}

StateChangePayload is sent with EventStateChange.

type StateWriteErrorPayload added in v0.4.1

type StateWriteErrorPayload struct {
	PluginID string `json:"pluginID"`
	Detail   string `json:"detail"`
}

StateWriteErrorPayload is sent with EventStateWriteError.

type TelemetryEnvConfig added in v0.3.0

type TelemetryEnvConfig struct {
	Enabled           bool
	OTLPEndpoint      string
	Profiling         bool
	PyroscopeEndpoint string
}

TelemetryEnvConfig holds the subset of telemetry configuration injected into plugin processes. Auth credentials are NOT included — they are managed host-side only.

type UpdateErrorPayload added in v0.4.0

type UpdateErrorPayload struct {
	PluginID string `json:"pluginID"`
	Error    string `json:"error"`
}

UpdateErrorPayload is sent with EventUpdateError.

type UpdatePayload added in v0.4.0

type UpdatePayload struct {
	PluginID string `json:"pluginID"`
	Version  string `json:"version"`
}

UpdatePayload is sent with EventUpdateStarted and EventUpdateComplete.

Directories

Path Synopsis
Package pluginlog manages per-plugin log capture with file persistence, in-memory ring buffering, and callback-based real-time streaming.
Package pluginlog manages per-plugin log capture with file persistence, in-memory ring buffering, and callback-based real-time streaming.

Jump to

Keyboard shortcuts

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