Overview
The plugin instance is returned by thecreatePlugin function and provides methods to register features (credentials, tools, models) and start the plugin process.
Methods
addCredential
Adds a new credential definition to the plugin registry.Parameters
The credential definition to register
Throws
- Validation error if the credential definition does not match the schema
Example
addTool
Adds a new tool definition to the plugin registry.Parameters
The tool definition to register
Throws
- Validation error if the tool definition does not match the schema
Example
addModel
Adds a new model definition to the plugin registry.Parameters
The model definition to register
Throws
- Validation error if the model definition does not match the schema
Example
run
Starts the plugin’s main process. This method:- Establishes a connection to the Hub Server via the transporter
- Registers the plugin (in debug mode)
- Sets up event listeners for credential authentication and tool invocation
- Configures signal handlers for graceful shutdown on SIGINT and SIGTERM
Returns
Promise that resolves when the plugin has started successfully
Example
Event Handling
Whenrun() is called, the plugin automatically handles these events from the Hub:
credential_auth_spec
Triggered when a credential needs to be authenticated. The plugin:- Parses the incoming message with credential data
- Resolves the credential definition from the registry
- Executes the
authenticatemethod if defined - Sends back
credential_auth_spec_responseorcredential_auth_spec_error
invoke_tool
Triggered when a tool should be executed. The plugin:- Parses the incoming message with tool name and parameters
- Resolves the tool definition from the registry
- Executes the
invokemethod with provided parameters and credentials - Sends back
invoke_tool_responseorinvoke_tool_error