Plugin
Defined in: src/plugins/plugin.ts:51
Abstract base class for objects that extend agent functionality.
Plugins provide a composable way to add behavior changes to agents by registering
hook callbacks in their initAgent method. Each plugin must have a unique name
for identification, logging, and duplicate prevention.
Examples
Section titled “Examples”class LoggingPlugin extends Plugin { get name(): string { return 'logging-plugin' }
override initAgent(agent: AgentData): void { agent.addHook(BeforeInvocationEvent, (event) => { console.log('Agent invocation started') }) }}
const agent = new Agent({ model, plugins: [new LoggingPlugin()],})class MyToolPlugin extends Plugin { get name(): string { return 'my-tool-plugin' }
override getTools(): Tool[] { return [myTool] }}Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Plugin(): Plugin;Returns
Section titled “Returns”Plugin
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get abstract name(): string;Defined in: src/plugins/plugin.ts:58
A stable string identifier for the plugin. Used for logging, duplicate detection, and plugin management.
For strands-vended plugins, names should be prefixed with strands:.
Returns
Section titled “Returns”string
Methods
Section titled “Methods”initAgent()
Section titled “initAgent()”initAgent(agent): void | Promise<void>;Defined in: src/plugins/plugin.ts:69
Initialize the plugin with the agent instance.
Override this method to register hooks and perform custom initialization.
When overriding, call super.initAgent(agent) to ensure tools from
getTools are registered automatically.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
agent | AgentData | The agent instance this plugin is being attached to |
Returns
Section titled “Returns”void | Promise<void>
getTools()
Section titled “getTools()”getTools(): Tool[];Defined in: src/plugins/plugin.ts:82
Returns tools provided by this plugin for auto-registration. Override to provide plugin-specific tools.
Returns
Section titled “Returns”Tool[]
Array of tools to register with the agent