Initializes the plugin service.
Optionalplugins: BasePlugin[]An optional list of plugins to register upon initialization.
Retrieves a registered plugin by its name.
The name of the plugin to retrieve.
The plugin instance if found, otherwise undefined.
Runs the afterAgentCallback for all plugins.
Runs the afterModelCallback for all plugins.
Runs the afterRunCallback for all plugins.
Runs the afterToolCallback for all plugins.
Runs the beforeAgentCallback for all plugins.
Runs the beforeModelCallback for all plugins.
Runs the beforeRunCallback for all plugins.
Runs the beforeToolCallback for all plugins.
Runs the onEventCallback for all plugins.
Runs the onModelErrorCallback for all plugins.
Runs the onToolErrorCallback for all plugins.
Runs the onUserMessageCallback for all plugins.
Manages the registration and execution of plugins.
The PluginManager is an internal class that orchestrates the invocation of plugin callbacks at key points in the SDK's execution lifecycle. It maintains a list of registered plugins and ensures they are called in the order they were registered.
The core execution logic implements an "early exit" strategy: if any plugin callback returns a non-
undefinedvalue, the execution of subsequent plugins for that specific event is halted, and the returned value is propagated up the call stack. This allows plugins to short-circuit operations like agent runs, tool calls, or model requests.