/** * PluginLifecycleManager, plugin lifecycle and capability enforcement. * * Tracks all plugins through the 8-state lifecycle machine, resolves capability * manifests on load, and emits PluginEvents at every state transition. * * Gated by the `plugin-lifecycle` capability gate (runtime.pluginLifecycle). */ import type { PluginLoaderDeps, LoadedPlugin } from '../../plugins/loader.js'; import { type PluginPathOptions } from '../../plugins/loader.js'; import type { PluginLifecycleState } from '../store/domains/plugins.js'; import { type PluginLifecycleManagerOptions, type PluginLifecycleRecord, type PluginManifestV2 } from './types.js'; import { PluginTrustStore, type PluginTrustTier } from './trust.js'; import { PluginQuarantineEngine } from './quarantine.js'; /** * PluginLifecycleManager tracks all plugins through structured lifecycle * transitions and emits typed PluginEvents at each state change. */ export declare class PluginLifecycleManager { private readonly records; private readonly sessionId; private readonly capabilityPolicy; private readonly trustTierResolver; private readonly runtimeBus; /** Trust store, manages tier records for all plugins. */ readonly trustStore: PluginTrustStore; /** Quarantine engine, tracks and applies quarantine constraints. */ readonly quarantine: PluginQuarantineEngine; constructor(options?: PluginLifecycleManagerOptions); /** Returns the lifecycle record for a plugin, or undefined if unknown. */ getRecord(name: string): Readonly | undefined; /** Returns all plugin lifecycle records as an array. */ getAllRecords(): ReadonlyArray>; /** Returns names of all plugins in a given state. */ getPluginsInState(state: PluginLifecycleState): string[]; /** Returns names of all currently operational plugins (active or degraded). */ getOperationalPlugins(): string[]; /** * Register a discovered plugin. Creates its lifecycle record in the * `discovered` state and emits PLUGIN_DISCOVERED. */ registerDiscovered(manifest: PluginManifestV2, pluginDir: string): void; /** * Load a plugin using the existing loader infrastructure. * * Transitions: discovered/disabled → loading → loaded → active * On failure: loading → error */ loadPlugin(manifest: PluginManifestV2, pluginDir: string, deps: PluginLoaderDeps, cacheBust?: number): Promise; /** * Unload a plugin. Transitions active/loaded/degraded → unloading → disabled. */ unloadPlugin(name: string, reason?: string, loaderDeps?: { getLoadedPlugin?: (name: string) => LoadedPlugin | undefined; }): Promise; /** * setTrustTier, Assign a trust tier to a plugin and re-sync the record. * * If the plugin has an active lifecycle record, the trust tier in the record * is updated immediately. Capability re-resolution requires a reload. */ setTrustTier(name: string, tier: PluginTrustTier, note?: string): void; /** * quarantinePlugin, Apply quarantine to a named plugin. * * Revokes high-risk capabilities from the live manifest, marks the record as * quarantined, and records the reason as the latest degradation. Active * plugins transition to `degraded`; already-degraded plugins stay degraded. * Non-operational plugins keep their current lifecycle state but still emit * PLUGIN_DEGRADED so runtime observers see the quarantine. * * @returns true if quarantine was applied; false if not tracked or already quarantined. */ quarantinePlugin(name: string, reason: string): boolean; /** * liftQuarantine, Remove quarantine from a plugin. * * Capabilities are NOT restored here; the operator should reload the plugin * after lifting so that trust-aware re-resolution can grant capabilities * appropriate for the updated tier. * * @returns true if quarantine was lifted; false if no active quarantine. */ liftQuarantine(name: string): boolean; /** Mark a plugin as degraded (partial functionality) while keeping it operational. */ degradePlugin(name: string, reason: string, affectedCapabilities?: string[]): void; /** * Record a plugin error. Recoverable errors update observability state and emit * PLUGIN_ERROR without changing lifecycle state. Fatal errors move * active/loaded/degraded plugins to `error`. */ recordError(name: string, error: string, fatal: boolean): void; /** * Scan for plugins and register newly discovered ones. * Existing records are not modified. */ scanAndRegister(pathOptions: PluginPathOptions): void; /** * Apply a state machine transition for a named plugin. * Records the transition in the plugin's history. * Returns the TransitionResult from the state machine. */ private transition; /** * Partially update a plugin record's mutable fields. */ private updateRecord; private emit; } //# sourceMappingURL=manager.d.ts.map