GeezerVison is showing adk.dev — PluginManager | ADK for TypeScript: API Reference - v2.5.0
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-undefined value, 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.
Constructors
constructor
-
new PluginManager(plugins?: BasePlugin[]): PluginManager
Initializes the plugin service.
Parameters
Optionalplugins: BasePlugin[]
An optional list of plugins to register upon
initialization.
Returns PluginManager
Accessors
Methods
getPlugin
-
getPlugin(pluginName: string): BasePlugin | undefined
Retrieves a registered plugin by its name.
Parameters
- pluginName: string
The name of the plugin to retrieve.
The plugin instance if found, otherwise undefined.
registerPlugin
-
Parameters
- plugin: BasePlugin
The plugin instance to register.
Returns void
ThrowsIf the same exact plugin or a plugin with the same name is already
registered.
runAfterAgentCallback
-
runAfterAgentCallback( __namedParameters: { agent: BaseAgent; callbackContext: Context },): Promise<Content | undefined>
Runs the afterAgentCallback for all plugins.
Returns Promise<Content | undefined>
runAfterContextCompaction
-
Runs the afterContextCompaction for all plugins.
Returns Promise<void>
runAfterModelCallback
-
Runs the afterModelCallback for all plugins.
Returns Promise<LlmResponse | undefined>
runAfterNodeCallback
-
runAfterNodeCallback( __namedParameters: { node: BaseNode; nodeContext: NodeContext; output: unknown; },): Promise<unknown>
Runs the afterNodeCallback for all plugins.
Returns Promise<unknown>
runAfterRunCallback
-
runAfterRunCallback( __namedParameters: { invocationContext: InvocationContext },): Promise<void>
Runs the afterRunCallback for all plugins.
Returns Promise<void>
runAfterToolCallback
-
runAfterToolCallback( __namedParameters: { result: Record<string, unknown>; tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context; },): Promise<Record<string, unknown> | undefined>
Runs the afterToolCallback for all plugins.
Parameters
- __namedParameters: {
result: Record<string, unknown>; tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context; }
Returns Promise<Record<string, unknown> | undefined>
runBeforeAgentCallback
-
runBeforeAgentCallback( __namedParameters: { agent: BaseAgent; callbackContext: Context },): Promise<Content | undefined>
Runs the beforeAgentCallback for all plugins.
Returns Promise<Content | undefined>
runBeforeContextCompaction
-
Runs the beforeContextCompaction for all plugins.
Returns Promise<void>
runBeforeModelCallback
-
Runs the beforeModelCallback for all plugins.
Returns Promise<LlmResponse | undefined>
runBeforeNodeCallback
-
runBeforeNodeCallback( __namedParameters: { input: unknown; node: BaseNode; nodeContext: NodeContext; },): Promise<unknown>
Runs the beforeNodeCallback for all plugins.
Returns Promise<unknown>
runBeforeRunCallback
-
runBeforeRunCallback( __namedParameters: { invocationContext: InvocationContext },): Promise<Content | undefined>
Runs the beforeRunCallback for all plugins.
Returns Promise<Content | undefined>
runBeforeToolCallback
-
runBeforeToolCallback( __namedParameters: { tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context; },): Promise<Record<string, unknown> | undefined>
Runs the beforeToolCallback for all plugins.
Parameters
- __namedParameters: { tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context }
Returns Promise<Record<string, unknown> | undefined>
runBeforeToolSelection
-
runBeforeToolSelection( __namedParameters: { callbackContext: Context; tools: Readonly<Record<string, BaseTool>>; },): Promise<Readonly<Record<string, BaseTool>> | undefined>
Runs the beforeToolSelection for all plugins.
Parameters
- __namedParameters: { callbackContext: Context; tools: Readonly<Record<string, BaseTool>> }
Returns Promise<Readonly<Record<string, BaseTool>> | undefined>
runOnAgentErrorCallback
-
runOnAgentErrorCallback( params: { agent: BaseAgent; callbackContext: Context; error: Error },): Promise<void>
Runs the notification-only agent error callback for every plugin.
Returns Promise<void>
runOnEventCallback
-
Runs the onEventCallback for all plugins.
Returns Promise<Event | undefined>
runOnModelErrorCallback
-
runOnModelErrorCallback( __namedParameters: { callbackContext: Context; error: Error; llmRequest: LlmRequest; },): Promise<LlmResponse | undefined>
Runs the onModelErrorCallback for all plugins.
Parameters
- __namedParameters: { callbackContext: Context; error: Error; llmRequest: LlmRequest }
Returns Promise<LlmResponse | undefined>
runOnRunErrorCallback
-
runOnRunErrorCallback( params: { error: Error; invocationContext: InvocationContext },): Promise<void>
Runs the notification-only run error callback for every plugin.
Returns Promise<void>
runOnToolErrorCallback
-
runOnToolErrorCallback( __namedParameters: { error: Error; tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context; },): Promise<Record<string, unknown> | undefined>
Runs the onToolErrorCallback for all plugins.
Parameters
- __namedParameters: {
error: Error; tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context; }
Returns Promise<Record<string, unknown> | undefined>
runOnUserMessageCallback
-
runOnUserMessageCallback( __namedParameters: { invocationContext: InvocationContext; userMessage: Content; },): Promise<Content | undefined>
Runs the onUserMessageCallback for all plugins.
Returns Promise<Content | undefined>
Constructors
Accessors
Methods
|