agent-kit-plugin

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Creating Hedera Agent Kit Plugins

创建Hedera Agent Kit插件

This skill provides guidance for creating custom plugins that extend the Hedera Agent Kit. Plugins allow adding new tools for Hedera network interactions—token operations, account management, consensus service, smart contracts, and custom integrations.
本技能提供创建扩展Hedera Agent Kit的自定义插件的指导。插件允许添加用于Hedera网络交互的新工具——包括代币操作、账户管理、共识服务、智能合约以及自定义集成。

Quick Start

快速开始

To create a Hedera plugin in 5 steps:
  1. Install dependencies: Set up a TypeScript project with
    @hashgraph/hedera-agent-kit
    and
    @hiero-ledger/sdk
  2. Create plugin structure: Create an
    index.ts
    with the plugin definition and a
    tools/
    directory
  3. Define tools: Each tool is a class extending
    BaseTool
    — this opts the tool into the hooks/policies lifecycle
  4. Export properly: Export the plugin object and tool name constants
  5. Register with agent: Import and pass the plugin in the toolkit
    configuration.plugins
    array
只需5步即可创建Hedera插件:
  1. 安装依赖:创建一个TypeScript项目,安装
    @hashgraph/hedera-agent-kit
    和
    @hiero-ledger/sdk
  2. 创建插件结构:创建包含插件定义的
    index.ts
    文件和
    tools/
    目录
  3. 定义工具:每个工具都是继承自
    BaseTool
    的类——这样工具就可以接入钩子/策略生命周期
  4. 正确导出:导出插件对象和工具名称常量
  5. 在Agent中注册:导入插件并将其添加到工具包的
    configuration.plugins
    数组中

Plugin Interface

插件接口

Every Hedera plugin implements this interface from
@hashgraph/hedera-agent-kit
:
typescript
import { Plugin } from '@hashgraph/hedera-agent-kit';

export interface Plugin {
  name: string;           // Unique kebab-case identifier
  version?: string;       // Semantic version (e.g., "1.0.0")
  description?: string;   // Brief explanation of plugin purpose
  tools: (context: Context) => Tool[];  // Factory returning tools
}
The
tools
function receives a
Context
object containing network configuration and returns an array of
Tool
objects.
BaseTool
itself implements
Tool
, so a
BaseTool
subclass instance is a valid return value.
每个Hedera插件都实现了
@hashgraph/hedera-agent-kit
中的这个接口:
typescript
import { Plugin } from '@hashgraph/hedera-agent-kit';

export interface Plugin {
  name: string;           // Unique kebab-case identifier
  version?: string;       // Semantic version (e.g., "1.0.0")
  description?: string;   // Brief explanation of plugin purpose
  tools: (context: Context) => Tool[];  // Factory returning tools
}
tools
函数接收包含网络配置的
Context
对象,并返回
Tool
对象数组。
BaseTool
本身实现了
Tool
接口,因此
BaseTool
子类的实例是有效的返回值。

BaseTool

BaseTool

Tools are written as classes extending
BaseTool
, which implements
Tool
and runs a 7-stage lifecycle:
text
[1] preToolExecutionHook
[2] normalizeParams        ← your logic
[3] postParamsNormalizationHook
[4] coreAction             ← your logic
[5] postCoreActionHook
[6] secondaryAction        ← your logic (skipped via shouldSecondaryAction for queries)
[7] postToolExecutionHook
Hooks and policies registered on the agent kit fire at stages 1, 3, 5, and 7 automatically — you never call them manually.
A subclass must provide:
MemberTypeNotes
method
string
Snake-case identifier with
_tool
suffix
name
string
Human-readable display name
description
string
LLM-facing description (typically built in the constructor from a prompt function)
parameters
z.ZodObject
Zod schema for input validation
normalizeParams(params, context, client)
asyncStage 2 — resolve defaults, validate format
coreAction(normalised, context, client)
asyncStage 4 — build the transaction or perform the query
secondaryAction(request, client, context)
asyncStage 6 — sign/submit the transaction (no-op for queries)
Optional overrides:
outputParser
,
shouldSecondaryAction
(return
false
for query-only tools),
handleError
, and the four hook methods.
工具以继承
BaseTool
的类的形式编写,
BaseTool
实现了
Tool
接口,并运行7阶段的生命周期:
text
[1] preToolExecutionHook
[2] normalizeParams        ← your logic
[3] postParamsNormalizationHook
[4] coreAction             ← your logic
[5] postCoreActionHook
[6] secondaryAction        ← your logic (skipped via shouldSecondaryAction for queries)
[7] postToolExecutionHook
在Agent Kit上注册的钩子和策略会在第1、3、5、7阶段自动触发——你无需手动调用它们。
子类必须实现以下成员:
成员类型说明
method
string
蛇形命名的标识符,以
_tool
后缀结尾
name
string
人类可读的显示名称
description
string
面向LLM的描述(通常在构造函数中通过提示函数生成)
parameters
z.ZodObject
用于输入校验的Zod模式
normalizeParams(params, context, client)
async第2阶段——解析默认值,校验格式
coreAction(normalised, context, client)
async第4阶段——构建交易或执行查询
secondaryAction(request, client, context)
async第6阶段——签名/提交交易(查询工具跳过此步骤)
可选的重写项:
outputParser
、
shouldSecondaryAction
(仅查询工具返回
false
)、
handleError
以及四个钩子方法。

Tool Types

工具类型

Mutation tools — state-changing operations (token create/mint/transfer, account update, topic submit).
coreAction
builds the
Transaction
,
secondaryAction
calls
handleTransaction()
. Use
transactionToolOutputParser
.
Query tools — read-only operations (token info, balances, mirror-node fetches).
coreAction
returns the result directly. Override
shouldSecondaryAction
to return
false
. Use
untypedQueryOutputParser
.
变更工具(Mutation tools)——改变状态的操作(代币创建/铸造/转账、账户更新、主题提交)。
coreAction
构建
Transaction
,
secondaryAction
调用
handleTransaction()
。使用
transactionToolOutputParser
。
查询工具(Query tools)——只读操作(代币信息、余额、镜像节点查询)。
coreAction
直接返回结果。重写
shouldSecondaryAction
返回
false
。使用
untypedQueryOutputParser
。

File Structure Pattern

文件结构模式

Follow this structure for all Hedera plugins:
my-hedera-plugin/
├── index.ts                    # Plugin definition and exports
└── tools/
    └── category/               # Group related tools
        ├── create-something.ts
        └── get-something.ts
所有Hedera插件请遵循以下结构:
my-hedera-plugin/
├── index.ts                    # Plugin definition and exports
└── tools/
    └── category/               # Group related tools
        ├── create-something.ts
        └── get-something.ts

Creating a Tool

创建工具

Step 1: Define the Tool Constant

步骤1:定义工具常量

typescript
export const MY_TOOL_NAME = 'my_tool_name_tool';
Use UPPER_SNAKE_CASE with
_TOOL
suffix for the constant. The value should be lowercase snake_case.
typescript
export const MY_TOOL_NAME = 'my_tool_name_tool';
常量使用大写下划线命名(UPPER_SNAKE_CASE),并以
_TOOL
后缀结尾。常量值应为小写下划线形式(snake_case)。

Step 2: Create the Prompt Function

步骤2:创建提示函数

typescript
const myToolPrompt = (context: Context = {}) => {
  return `This tool does X on Hedera.
Parameters:
- param1 (str, required): Description of param1
- param2 (int, optional): Description of param2, defaults to 0`;
};
typescript
const myToolPrompt = (context: Context = {}) => {
  return `This tool does X on Hedera.
Parameters:
- param1 (str, required): Description of param1
- param2 (int, optional): Description of param2, defaults to 0`;
};

Step 3: Define Parameters with Zod

步骤3:使用Zod定义参数

typescript
import { z } from 'zod';

const myToolParameters = (_context: Context = {}) => {
  return z.object({
    param1: z.string().describe('Description of param1'),
    param2: z.number().optional().describe('Description of param2'),
  });
};

type MyToolParams = z.infer<ReturnType<typeof myToolParameters>>;
See
references/zod-schema-patterns.md
for common Hedera parameter patterns.
typescript
import { z } from 'zod';

const myToolParameters = (_context: Context = {}) => {
  return z.object({
    param1: z.string().describe('Description of param1'),
    param2: z.number().optional().describe('Description of param2'),
  });
};

type MyToolParams = z.infer<ReturnType<typeof myToolParameters>>;
常见的Hedera参数模式请参考
references/zod-schema-patterns.md
。

Step 4: Implement the BaseTool subclass (mutation example)

步骤4:实现BaseTool子类(变更工具示例)

typescript
import { Client, Status } from '@hiero-ledger/sdk';
import {
  BaseTool,
  Context,
  handleTransaction,
  RawTransactionResponse,
  transactionToolOutputParser,
} from '@hashgraph/hedera-agent-kit';

const postProcess = (response: RawTransactionResponse) =>
  `Operation completed.
Transaction ID: ${response.transactionId}`;

export class MyTool extends BaseTool<MyToolParams, MyToolParams> {
  method = MY_TOOL_NAME;
  name = 'My Tool Display Name';
  description: string;
  parameters: ReturnType<typeof myToolParameters>;
  outputParser = transactionToolOutputParser;

  constructor(context: Context) {
    super();
    this.description = myToolPrompt(context);
    this.parameters = myToolParameters(context);
  }

  // Stage 2 — resolve defaults
  async normalizeParams(params: MyToolParams) {
    return params;
  }

  // Stage 4 — build the transaction (do not sign here)
  async coreAction(params: MyToolParams, _context: Context, _client: Client) {
    // return new SomeTransaction()...;
    return undefined as any;
  }

  // Stage 6 — sign and submit
  async secondaryAction(transaction: any, client: Client, context: Context) {
    return handleTransaction(transaction, client, context, postProcess);
  }

  async handleError(error: unknown) {
    const message = 'Failed to execute' + (error instanceof Error ? `: ${error.message}` : '');
    console.error(`[${MY_TOOL_NAME}]`, message);
    return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };
  }
}
typescript
import { Client, Status } from '@hiero-ledger/sdk';
import {
  BaseTool,
  Context,
  handleTransaction,
  RawTransactionResponse,
  transactionToolOutputParser,
} from '@hashgraph/hedera-agent-kit';

const postProcess = (response: RawTransactionResponse) =>
  `Operation completed.
Transaction ID: ${response.transactionId}`;

export class MyTool extends BaseTool<MyToolParams, MyToolParams> {
  method = MY_TOOL_NAME;
  name = 'My Tool Display Name';
  description: string;
  parameters: ReturnType<typeof myToolParameters>;
  outputParser = transactionToolOutputParser;

  constructor(context: Context) {
    super();
    this.description = myToolPrompt(context);
    this.parameters = myToolParameters(context);
  }

  // Stage 2 — resolve defaults
  async normalizeParams(params: MyToolParams) {
    return params;
  }

  // Stage 4 — build the transaction (do not sign here)
  async coreAction(params: MyToolParams, _context: Context, _client: Client) {
    // return new SomeTransaction()...;
    return undefined as any;
  }

  // Stage 6 — sign and submit
  async secondaryAction(transaction: any, client: Client, context: Context) {
    return handleTransaction(transaction, client, context, postProcess);
  }

  async handleError(error: unknown) {
    const message = 'Failed to execute' + (error instanceof Error ? `: ${error.message}` : '');
    console.error(`[${MY_TOOL_NAME}]`, message);
    return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };
  }
}

Step 5: Export a Factory

步骤5:导出工厂函数

typescript
const tool = (context: Context): BaseTool => new MyTool(context);
export default tool;
The factory pattern lets the plugin's
tools(context)
function instantiate a fresh tool per request with the right context bound.
typescript
const tool = (context: Context): BaseTool => new MyTool(context);
export default tool;
工厂模式使得插件的
tools(context)
函数可以为每个请求实例化一个新的、绑定了正确上下文的工具。

Query-tool variant — skip stage 6

查询工具变体——跳过第6阶段

For read-only tools, override
shouldSecondaryAction
so the lifecycle stops after
coreAction
, and have
secondaryAction
pass the result through unchanged:
typescript
export class MyQueryTool extends BaseTool<MyToolParams, MyToolParams> {
  // ... method/name/description/parameters as above ...
  outputParser = untypedQueryOutputParser;

  async normalizeParams(params: MyToolParams) {
    return params;
  }

  async coreAction(params: MyToolParams, _context: Context, client: Client) {
    return await someHederaQuery(params, client);
  }

  async shouldSecondaryAction() {
    return false;
  }

  async secondaryAction(result: any) {
    return result;
  }
}
对于只读工具,重写
shouldSecondaryAction
,使生命周期在
coreAction
之后停止,并让
secondaryAction
原样传递结果:
typescript
export class MyQueryTool extends BaseTool<MyToolParams, MyToolParams> {
  // ... method/name/description/parameters as above ...
  outputParser = untypedQueryOutputParser;

  async normalizeParams(params: MyToolParams) {
    return params;
  }

  async coreAction(params: MyToolParams, _context: Context, client: Client) {
    return await someHederaQuery(params, client);
  }

  async shouldSecondaryAction() {
    return false;
  }

  async secondaryAction(result: any) {
    return result;
  }
}

Creating the Plugin Index

创建插件入口文件

typescript
import { Context, Plugin } from '@hashgraph/hedera-agent-kit';
import myTool, { MY_TOOL_NAME } from './tools/category/my-tool';

export const myPlugin: Plugin = {
  name: 'my-hedera-plugin',
  version: '1.0.0',
  description: 'A plugin for custom Hedera operations',
  tools: (context: Context) => {
    return [
      myTool(context),
    ];
  },
};

export const myPluginToolNames = {
  MY_TOOL_NAME,
} as const;

export default { myPlugin, myPluginToolNames };
typescript
import { Context, Plugin } from '@hashgraph/hedera-agent-kit';
import myTool, { MY_TOOL_NAME } from './tools/category/my-tool';

export const myPlugin: Plugin = {
  name: 'my-hedera-plugin',
  version: '1.0.0',
  description: 'A plugin for custom Hedera operations',
  tools: (context: Context) => {
    return [
      myTool(context),
    ];
  },
};

export const myPluginToolNames = {
  MY_TOOL_NAME,
} as const;

export default { myPlugin, myPluginToolNames };

Post-Processing Results

结果后处理

secondaryAction
typically delegates to
handleTransaction
, which calls a
postProcess
function with the raw transaction response:
typescript
const postProcess = (response: RawTransactionResponse) => {
  if (response.scheduleId) {
    return `Scheduled transaction created.
Transaction ID: ${response.transactionId}
Schedule ID: ${response.scheduleId.toString()}`;
  }
  return `Operation completed.
Transaction ID: ${response.transactionId}`;
};
secondaryAction
通常委托给
handleTransaction
,后者会调用
postProcess
函数并传入原始交易响应:
typescript
const postProcess = (response: RawTransactionResponse) => {
  if (response.scheduleId) {
    return `Scheduled transaction created.
Transaction ID: ${response.transactionId}
Schedule ID: ${response.scheduleId.toString()}`;
  }
  return `Operation completed.
Transaction ID: ${response.transactionId}`;
};

RETURN_BYTES
mode —
raw.bytes
is a
Uint8Array

RETURN_BYTES
模式——
raw.bytes
为
Uint8Array
类型

When a tool runs in
RETURN_BYTES
mode,
raw.bytes
returned by
ResponseParserService
is always a plain
Uint8Array
in both Node.js and browser environments. Pass it directly to
Transaction.fromBytes()
— no manual conversion is needed.
typescript
const bytes = toolCall.parsedData.raw.bytes;
const tx = Transaction.fromBytes(bytes);
当工具以
RETURN_BYTES
模式运行时,
ResponseParserService
返回的
raw.bytes
在Node.js和浏览器环境中都是普通的
Uint8Array
类型。直接将其传递给
Transaction.fromBytes()
即可——无需手动转换。
typescript
const bytes = toolCall.parsedData.raw.bytes;
const tx = Transaction.fromBytes(bytes);

Naming Conventions

命名规范

ElementConventionExample
Plugin namekebab-case
my-token-plugin
Plugin variablecamelCase
myTokenPlugin
Tool classPascalCase +
Tool
CreateTokenTool
Tool constantUPPER_SNAKE_CASE +
_TOOL
CREATE_TOKEN_TOOL
Tool method valuesnake_case +
_tool
create_token_tool
Tool filekebab-case
create-token.ts
Tool names exportcamelCase +
ToolNames
myTokenPluginToolNames
元素规范示例
插件名称短横线命名(kebab-case)
my-token-plugin
插件变量小驼峰命名(camelCase)
myTokenPlugin
工具类帕斯卡命名(PascalCase)+
Tool
后缀
CreateTokenTool
工具常量大写下划线(UPPER_SNAKE_CASE)+
_TOOL
后缀
CREATE_TOKEN_TOOL
工具method值小写下划线(snake_case)+
_tool
后缀
create_token_tool
工具文件短横线命名(kebab-case)
create-token.ts
工具名称导出对象小驼峰(camelCase)+
ToolNames
后缀
myTokenPluginToolNames

Common Imports

常用导入

typescript
// From @hashgraph/hedera-agent-kit (core)
import {
  Context,
  Plugin,
  BaseTool,
  handleTransaction,
  RawTransactionResponse,
  transactionToolOutputParser,
  untypedQueryOutputParser,
} from '@hashgraph/hedera-agent-kit';

// Built-in plugins live in the /plugins subpath
import { coreTokenPlugin, coreAccountPlugin } from '@hashgraph/hedera-agent-kit/plugins';

// Hedera SDK is a peer dependency
import { Client, Status } from '@hiero-ledger/sdk';

// For parameter validation
import { z } from 'zod';
typescript
// From @hashgraph/hedera-agent-kit (core)
import {
  Context,
  Plugin,
  BaseTool,
  handleTransaction,
  RawTransactionResponse,
  transactionToolOutputParser,
  untypedQueryOutputParser,
} from '@hashgraph/hedera-agent-kit';

// Built-in plugins live in the /plugins subpath
import { coreTokenPlugin, coreAccountPlugin } from '@hashgraph/hedera-agent-kit/plugins';

// Hedera SDK is a peer dependency
import { Client, Status } from '@hiero-ledger/sdk';

// For parameter validation
import { z } from 'zod';

Additional Resources

更多资源

Reference Files

参考文件

For detailed patterns and techniques, consult:
  • references/plugin-interface.md
    - Plugin interface,
    BaseTool
    lifecycle in depth
  • references/zod-schema-patterns.md
    - Common Zod schemas for Hedera parameters
  • references/prompt-patterns.md
    - Prompt generation patterns for tool descriptions
  • references/error-handling.md
    - Error handling and output parsing patterns
有关详细的模式和技巧,请查阅:
  • references/plugin-interface.md
    - 插件接口、
    BaseTool
    生命周期详解
  • references/zod-schema-patterns.md
    - Hedera参数常用Zod模式
  • references/prompt-patterns.md
    - 工具描述的提示生成模式
  • references/error-handling.md
    - 错误处理与输出解析模式

Example Files

示例文件

Working examples in
examples/
:
  • examples/simple-plugin/
    - Minimal
    BaseTool
    query (starter template)
  • examples/token-plugin/
    - Mutation (
    CreateTokenTool
    ) and query (
    GetTokenInfoTool
    )
    BaseTool
    subclasses
examples/
目录下的可运行示例:
  • examples/simple-plugin/
    - 最简
    BaseTool
    查询工具(入门模板)
  • examples/token-plugin/
    - 变更工具(
    CreateTokenTool
    )和查询工具(
    GetTokenInfoTool
    )的
    BaseTool
    子类实现

Best Practices

最佳实践

  1. One file per tool, named after the tool in kebab-case
  2. Group related tools under category directories in
    tools/
  3. Stable class names:
    <DoesWhat>Tool
    (e.g.,
    CreateTokenTool
    )
  4. Resolve defaults in
    normalizeParams
    , not in
    coreAction
    — keeps the build step pure
  5. Build, don't submit, in
    coreAction
    — submission belongs in
    secondaryAction
    where hooks can react
  6. Override
    handleError
    so logs are tagged with the tool method
  7. Validate with Zod's
    .describe()
    — every field; descriptions guide the agent
  8. Export tool name constants so consumers can reference tools programmatically
  1. 每个工具一个文件,以短横线命名的工具名作为文件名
  2. 将相关工具分组放在
    tools/
    目录下的分类子目录中
  3. 稳定的类名:
    <功能>Tool
    格式(例如
    CreateTokenTool
    )
  4. 在
    normalizeParams
    中解析默认值
    ,而不是在
    coreAction
    中——保持构建步骤的纯粹性
  5. coreAction
    只构建,不提交
    ——提交操作属于
    secondaryAction
    的职责,这样钩子可以响应
  6. 重写
    handleError
    ,以便日志带有工具method的标记
  7. 使用Zod的
    .describe()
    进行校验
    ——每个字段都要有描述;描述会指导Agent的行为
  8. 导出工具名称常量,以便使用者可以以编程方式引用工具

Registering a Plugin with a Toolkit

在工具包中注册插件

Plugins are passed explicitly to the toolkit you choose. Toolkits live in dedicated packages — pick the one that matches your framework:
FrameworkToolkit package
LangChain
@hashgraph/hedera-agent-kit-langchain
Vercel AI SDK
@hashgraph/hedera-agent-kit-ai-sdk
ElizaOS
@hashgraph/hedera-agent-kit-elizaos
MCP
@hashgraph/hedera-agent-kit-mcp
Empty
plugins
array means zero tools.
List every plugin you need explicitly, or use
allCorePlugins
from the
/plugins
subpath to load every built-in core plugin at once.
typescript
import { Client, PrivateKey } from '@hiero-ledger/sdk';
import { AgentMode } from '@hashgraph/hedera-agent-kit';
import { coreTokenPlugin, coreAccountPlugin } from '@hashgraph/hedera-agent-kit/plugins';
import { HederaLangchainToolkit } from '@hashgraph/hedera-agent-kit-langchain';
import { myPlugin } from './my-hedera-plugin';

const client = Client.forTestnet().setOperator(
  process.env.ACCOUNT_ID!,
  PrivateKey.fromStringECDSA(process.env.PRIVATE_KEY!),
);

const toolkit = new HederaLangchainToolkit({
  client,
  configuration: {
    plugins: [coreTokenPlugin, coreAccountPlugin, myPlugin],
    context: { mode: AgentMode.AUTONOMOUS },
  },
});

const tools = toolkit.getTools();
To load every built-in core plugin at once, import
allCorePlugins
:
typescript
import { allCorePlugins } from '@hashgraph/hedera-agent-kit/plugins';
// ...
plugins: [...allCorePlugins, myPlugin],
插件需要显式传递给你选择的工具包。工具包位于独立的包中——选择与你的框架匹配的版本:
框架工具包包名
LangChain
@hashgraph/hedera-agent-kit-langchain
Vercel AI SDK
@hashgraph/hedera-agent-kit-ai-sdk
ElizaOS
@hashgraph/hedera-agent-kit-elizaos
MCP
@hashgraph/hedera-agent-kit-mcp
plugins
数组为空意味着没有任何工具。
请显式列出你需要的所有插件,或者使用
/plugins
子路径中的
allCorePlugins
一次性加载所有内置核心插件。
typescript
import { Client, PrivateKey } from '@hiero-ledger/sdk';
import { AgentMode } from '@hashgraph/hedera-agent-kit';
import { coreTokenPlugin, coreAccountPlugin } from '@hashgraph/hedera-agent-kit/plugins';
import { HederaLangchainToolkit } from '@hashgraph/hedera-agent-kit-langchain';
import { myPlugin } from './my-hedera-plugin';

const client = Client.forTestnet().setOperator(
  process.env.ACCOUNT_ID!,
  PrivateKey.fromStringECDSA(process.env.PRIVATE_KEY!),
);

const toolkit = new HederaLangchainToolkit({
  client,
  configuration: {
    plugins: [coreTokenPlugin, coreAccountPlugin, myPlugin],
    context: { mode: AgentMode.AUTONOMOUS },
  },
});

const tools = toolkit.getTools();
要一次性加载所有内置核心插件,请导入
allCorePlugins
:
typescript
import { allCorePlugins } from '@hashgraph/hedera-agent-kit/plugins';
// ...
plugins: [...allCorePlugins, myPlugin],

Workflow Summary

工作流程总结

  1. Create plugin directory with
    index.ts
    and
    tools/
    subdirectory
  2. For each tool, write a
    BaseTool
    subclass and a factory function in its own file
  3. Export tools from
    index.ts
    along with tool name constants
  4. Pass the plugin in the toolkit's
    configuration.plugins
    array
  5. Tools become available to the AI agent
For complete working examples, see the
examples/
directory.
  1. 创建插件目录,包含
    index.ts
    和
    tools/
    子目录
  2. 为每个工具编写一个
    BaseTool
    子类,并在单独的文件中编写工厂函数
  3. 在
    index.ts
    中导出工具以及工具名称常量
  4. 将插件添加到工具包的
    configuration.plugins
    数组中
  5. 工具即可供AI Agent使用
完整的可运行示例请参考
examples/
目录。