Skip to content
docsv0.13.1

PluginsManager

Discovers, gates, orders, and boots the plugins that make up a running Milpa application. The direct port of the host's legacy manager with every host coupling replaced: globals became {@see ManagerConfig}, the enabled set reads through {@see PluginRegistryInterface}, the tool registry is the core contract, and the plugin list is instance state.

PluginsManager::__construct()

public function __construct(Milpa\Interfaces\Di\DIContainerInterface $container, Milpa\Plugin\Contracts\PluginRegistryInterface $registry, Milpa\Plugin\Runtime\ManagerConfig $config):

Parameters

Parameters of __construct()
NameTypeDescription
$containerMilpa\Interfaces\Di\DIContainerInterface
$registryMilpa\Plugin\Contracts\PluginRegistryInterface
$configMilpa\Plugin\Runtime\ManagerConfig

PluginsManager::getPluginsMetadata()

public function getPluginsMetadata(): array

Plugin metadata for every scanned plugin, resequenced to boot order.

PluginsManager::blockingReasonWithout()

public function blockingReasonWithout(string $pluginName): ?string

El motivo por el que apagar `$pluginName` dejaría el grafo bloqueado, o `null` si no lo haría. Resuelve el MISMO grafo que el arranque, con ese plugin fuera. No es una aproximación: usa el perfil del host y el resolver que van a decidir de verdad, así que una respuesta afirmativa aquí es la misma que se daría en el siguiente arranque. Sin perfil legible contesta `null`, o sea «adelante»: es exactamente lo que hace el resto de esta clase cuando no lo encuentra —{@see self::cachedGraphIsBootable()} lo dice con todas sus letras— porque inventar un perfil bloquearía apagados que hoy funcionan. Un plugin que no está entre los activos tampoco bloquea nada: apagar lo que ya está apagado no cambia el grafo.

Parameters

Parameters of blockingReasonWithout()
NameTypeDescription
$pluginNamestring

PluginsManager::blockingReasonWith()

public function blockingReasonWith(string $newPluginClass): ?string

El motivo por el que AGREGAR `$newPluginClass` dejaría el grafo bloqueado, o `null` si cerraría. La otra mitad de {@see self::blockingReasonWithout()}: el invariante es uno —el grafo nunca se deja abierto por una mutación (greenhouse decisions/0178). Un plugin sin `#[PluginMetadata]` no declara `requires`: agregarlo no puede abrir el grafo, así que no hay nada que bloquear. Si el resolver mismo TRUENA, se falla CERRADO al agregar (a diferencia de quitar, que tiene vía de recuperación): un registro que podría abrir el grafo y no se pudo verificar no se autoriza.

Parameters

Parameters of blockingReasonWith()
NameTypeDescription
$newPluginClassstring

PluginsManager::getPlugins()

public function getPlugins(): array

Returns all booted plugin instances, keyed by plugin name.

PluginsManager::getPlugin()

public function getPlugin(string $name): ?Milpa\Interfaces\Plugin\PluginInterface

Returns a single booted plugin instance by name, or null if no such plugin has been booted.

Parameters

Parameters of getPlugin()
NameTypeDescription
$namestring

PluginsManager::isEnabled()

public function isEnabled(string $name): bool

Whether the given plugin name is currently enabled.

Parameters

Parameters of isEnabled()
NameTypeDescription
$namestring

PluginsManager::getToolProviderPromptSections()

public function getToolProviderPromptSections(): array

Get prompt sections from all plugins that implement ToolProviderInterface. This allows dynamically building the AI system prompt based on registered tools.

Returns

All prompt sections from tool providers

PluginsManager::addPluginPath()

public function addPluginPath(string $path): void

Registers a directory where plugins may be found.

Parameters

Parameters of addPluginPath()
NameTypeDescription
$pathstringPhysical path to the plugins directory.

PluginsManager::removePluginPath()

public function removePluginPath(string $path): void

Removes a previously registered path from the plugins directory list.

Parameters

Parameters of removePluginPath()
NameTypeDescription
$pathstringPhysical path to the plugins directory to remove.

PluginsManager::getPluginsPaths()

public function getPluginsPaths(): array

Returns every path currently registered as a possible plugin location.

PluginsManager::loadPlugins()

public function loadPlugins(): void

Loads and registers plugins from every registered plugin path. Implements caching to avoid a disk scan on every request. The fresh path (cache miss/stale) runs ONE milpa/resolver resolution that both GATES the graph (a `blocked` verdict throws, with the report's learnable first line as the message) and ORDERS the boot ($this->plugins is re-sequenced by the report's loadOrder[]); the cache then persists that order, so the cache-hit path boots it without re-sorting.

PluginsManager::scanPluginsPath()

public function scanPluginsPath(string $pluginPath): void

Scan plugins in a path and collect metadata WITHOUT booting. Used to enable contract validation and dependency ordering.

Parameters

Parameters of scanPluginsPath()
NameTypeDescription
$pluginPathstring

PluginsManager::getMetadata()

public function getMetadata(string $className): array

Plugin metadata read from the #[PluginMetadata] attribute — the single authority for plugin identity (D5). A plugin's milpa.json remains the distribution manifest on disk; divergence between the two surfaces as a doctor parity warning, never as a different boot graph.

Parameters

Parameters of getMetadata()
NameTypeDescription
$classNamestringFully-qualified plugin class name.

Throws

\Exception When the class does not exist or declares no metadata.