Creating a Plugin
Plugin Interface
Every plugin must implement the Plugin interface:Tool Interface
Each tool must implement the Tool interface:Step-by-Step Guide
Step 1: Create Plugin Directory Structure
Step 2: Implement Your Tool
Create your tool file (e.g., tools/my-service/my-tool.ts):Step 3: Create Plugin Definition
Create your plugin index file (index.ts):Best Practices
Parameter Validation- Use Zod schemas for robust input validation
- Provide clear descriptions for all parameters
- Mark required vs optional parameters appropriately
- Group related tools by service type
- Use consistent naming conventions
- Follow the established directory structure
- Use
handleTransaction()to facilitate human-in-the-loop and autonomous execution flows - Respect the AgentMode (
AUTONOMOUSvsRETURN_BYTES) - Implement proper transaction building patterns
Tool Output Parsing
The Hedera Agent Kit tools return a structured JSON output that needs to be parsed to be useful for the agent and the user. LangChain v0.3 (Classic) In the classic approach, the agent handles the tool output automatically, but you may need to parse it if you are handling tool calls manually. LangChain v1 (New) In LangChain v1, we use theResponseParserService to handle tool outputs. This service normalizes the output from both transaction and query tools into a consistent format:
Using Your Custom Plugin
LangChain v0.3 (Classic)Examples and References
- See existing core plugins in typescript/src/plugins/core-*-plugin/
- Follow the patterns established in tools like transfer-hbar.ts
- See typescript/examples/langchain-v1/tool-calling-agent.ts for usage examples
Publish and Register Your Plugin
To create a plugin to be use with the Hedera Agent Kit, you will need to create a plugin in your own repository, publish an npm package, and provide a description of the functionality included in that plugin, as well as the required and optional parameters. Once you have a repository, published npm package, and a README with a description of the functionality included in that plugin in your plugin’s repo, as well, add it to the Hedera Agent Kit by forking and opening a Pull Request that includes:- Include the plugin as a bullet point under the Third Party Plugin section in the README.md in the hedera-agent-kit-js.
- Include the name, a brief description, and a link to the repository with the README, as well the URL linked to the published npm package.
- If you would like to include your plugin functionality in the Hedera plugin built for ElizaOS simply make a PR to add your plugin name to the
pluginsarray in the Hedera ElizaOS plugin where the configuration is initiated. The hedera-agent-kit adaptor architecture means your plugin functionality will be usable with no additional configuration needed.