TON Agent Kit
The Agent Commerce Protocol for TON
Connect any AI agent to TON. Build agent economies with on-chain escrow, reputation, and paid APIs.
Quick Start • Packages • Actions • Contracts • Commerce • MCP • x402 • Bot • Tests
______________________________________________________________________
什么是TON Agent Kit?
一个TypeScript SDK,允许AI代理完全访问TON协议。12个插件中的75个操作,打包为21个npm模块。
代理可以交换令牌、部署合约、管理托管、广播意图、发现其他代理,并获得服务报酬。所有从一个单一 TonAgentKit 例子
核心循环:在链上注册、发布功能、查找服务、协商交易、托管资金、通过x402交付、结算、评级。
Agent A TON Blockchain Agent B
| | |
|-- register_agent ------->| |
| || |
| "need price feed" | |
| |-------- discover -------->|
| || |
|-- create_escrow -------->| |
|-- deposit_to_escrow ---->| |
| || |
|-- release_escrow ------->| |
|-- settle_deal ---------->| |快速开始
npm install @ton-agent-kit/core @ton-agent-kit/plugin-token @ton-agent-kit/plugin-defiimport { TonAgentKit, KeypairWallet } from "@ton-agent-kit/core";
import TokenPlugin from "@ton-agent-kit/plugin-token";
import DefiPlugin from "@ton-agent-kit/plugin-defi";
const wallet = await KeypairWallet.fromMnemonic(process.env.TON_MNEMONIC!, {
network: "testnet",
version: "V5R1",
});
const agent = new TonAgentKit(wallet, "https://testnet-v4.tonhubapi.com")
.use(TokenPlugin)
.use(DefiPlugin);
// Run an action directly
const balance = await agent.runAction("get_balance", {});
// Or expose all actions as OpenAI-compatible tools
const tools = agent.toAITools(); // Zod v4 -> JSON Schema这 .use() 通话是可链接的。 toAITools() 将每个注册的动作模式(Zod v4)转换为OpenAI函数调用格式。通过 tools 任何LLM。
环境
# .env
TON_MNEMONIC=word1 word2 ... word24
TON_NETWORK=testnet
OPENAI_API_KEY=sk-...看 .env.示例 查看完整列表。
______________________________________________________________________
建筑
graph TD
subgraph Runtimes
MCP["MCP Server
(packages/mcp-server)"]
BOT["Telegram Bot
(separate repo)"]
TEST["Test Runner
(tests.ts)"]
CUSTOM["Your App"]
end
subgraph Core
AK["TonAgentKit
.use() .runAction() .toAITools() .runLoop()"]
PR["PluginRegistry"]
AC["ActionCache (TTL + LRU)"]
W["KeypairWallet / ReadOnlyWallet"]
end
subgraph Plugins["12 Plugins (75 actions)"]
P1["Token (7)"]
P2["DeFi (12)"]
P3["Escrow (14)"]
P4["Identity (9)"]
P5["AgentComm (7)"]
P6["Analytics (8)"]
P7["+ DNS, NFT, Staking,
Payments, Memory, Endpoints"]
end
subgraph Infra
O["Orchestrator"]
S["Strategies"]
X["x402 Middleware"]
L["LangChain + AI Tools"]
end
subgraph Blockchain["TON Blockchain"]
RC["Reputation Contract
(testnet)"]
EC["Escrow Contracts
(per-deal)"]
end
MCP --> AK
BOT --> AK
TEST --> AK
CUSTOM --> AK
AK --> PR
AK --> AC
AK --> W
PR --> Plugins
P3 --> EC
P4 --> RC
P5 --> RC
O --> AK
S --> AK
X --> Blockchain完整架构: 建筑.md
______________________________________________________________________
包裹
21个npm包。12个带有操作的插件,9个基础设施模块。
| 包 | 版本 | 它的作用 |
|---|---|---|
@ton-agent-kit/core | 1.2.4 | 代理、插件系统、钱包、气体估算、缓存、验证 |
@ton-agent-kit/plugin-token | 1.1.2 | TON和Jetty传输、平衡、部署、模拟 |
@ton-agent-kit/plugin-defi | 1.2.3 | DeDust、STON.fi、Omniston掉期、DCA、限额、收益率、质押池、信托 |
@ton-agent-kit/plugin-dns | 1.0.4 | .ton域名解析、反向查找、域名信息 |
@ton-agent-kit/plugin-nft | 1.0.4 | NFT信息、传输、收集数据 |
@ton-agent-kit/plugin-staking | 1.0.4 | 在验证器池中质押/取消质押TON |
@ton-agent-kit/plugin-analytics | 1.1.2 | TX历史、钱包信息、投资组合、股权曲线、webhooks、合约调用 |
@ton-agent-kit/plugin-escrow | 1.5.3 | 带争议解决的链上Tact托管 |
@ton-agent-kit/plugin-identity | 1.6.8 | 代理注册表、信誉、发现、链上扫描回退、清理 |
@ton-agent-kit/plugin-payments | 1.0.18 | x402支付流程、交付证明、二进制内容检测、JSON解包 |
@ton-agent-kit/plugin-agent-comm | 1.3.6 | 意向/要约市场协议,测试网重试索引延迟 |
@ton-agent-kit/plugin-memory | 1.0.2 | 带TTL和命名空间的键值存储(文件,内存中) |
@ton-agent-kit/plugin-endpoints | 1.0.1 | 动态x402端点管理(打开、关闭、列表) |
@ton-agent-kit/orchestrator | 1.1.1 | 多代理计划器、调度器、并行执行 |
@ton-agent-kit/strategies | 1.0.1 | 确定性工作流引擎、调度、模板 |
@ton-agent-kit/x402-middleware | 1.1.10 | Express付费墙中间件,地址规范化,转发费用容忍,防重放 |
@ton-agent-kit/mcp-server | 1.1.1 | 模型上下文协议服务器(stdio+SSE) |
@ton-agent-kit/langchain | 1.0.2 | LangChain动态结构化工具适配器 |
@ton-agent-kit/ai-tools | 1.0.2 | Vercel AI SDK和OpenAI工具适配器 |
@ton-agent-kit/wallet-store | 1.0.1 | AES-256-GCM加密钱包/密钥存储,48小时TTL文件存储 |
@ton-agent-kit/network-mode | 1.0.1 | CLI网络模式选择器(本地、公共IP、隧道) |
所有包裹均 @ton-agent-kit/* 作用于npm。以上版本来自当前 package.json 文件夹。
______________________________________________________________________
所有操作
12个插件中的75个操作。每个操作都有一个Zod v4模式、一个描述和一个处理程序函数。
令牌(7个动作)
| 行动 | 它的作用 |
|---|---|
get_balance | 任何钱包的TON余额 |
get_jetton_balance | 钱包的Jetton余额(通过TONAPI) |
transfer_ton | 仅使用模拟、先模拟或直接模式发送TON |
transfer_jetton | 发送Jetton(解析Jetton钱包地址) |
deploy_jetton | 使用链上TEP-64元数据部署新的Jetton minter |
get_jetton_info | Jetton主数据(总供应量) |
simulate_transaction | 通过TONAPI构建和模拟TX,无需广播 |
DeFi(12个动作)
| 行动 | 它的作用 |
|---|---|
swap_dedust | DeDust DEX上的交换(吨/杰顿,杰顿/杰顿) |
swap_stonfi | STON.fi DEX上的掉期 |
swap_best_price | 通过Omniston WebSocket聚合交换(所有DEX中价格最优惠) |
get_price | Jetton的美元和吨价格(TONAPI费率) |
create_dca_order | 通过swap.offee Strategies API订购DCA |
create_limit_order | 通过swap.coffee进行限价订单 |
cancel_order | 取消当前有效的DCA或限价订单 |
get_yield_pools | 列出swap.coffee的2000+个产量/LP池(16个协议) |
yield_deposit | 存入收益池(provide_liquidity op) |
yield_withdraw | 从池中提款(销毁LP代币) |
get_staking_pools | 用swap.coffee的APR/TVL抵押游泳池 |
get_token_trust | DYOR.io的代币信任评分和风险标志 |
DNS(3个操作)
| 行动 | 它的作用 |
|---|---|
resolve_domain | 将.ton域名解析为钱包地址 |
lookup_address | 反向查找:钱包地址到.ton域 |
get_domain_info | 域名详细信息,包括到期时间 |
NFT(3个动作)
| 行动 | 它的作用 |
|---|---|
get_nft_info | NFT数据(索引、所有者、集合、元数据) |
transfer_nft | 转移NFT所有权 |
get_nft_collection | 收藏信息(名称、描述、物品数量) |
质押(3个动作)
| 行动 | 它的作用 |
|---|---|
get_staking_info | 提名人为钱包汇集头寸 |
stake_ton | 存入验证器池 |
unstake_ton | 从验证器池中提取 |
分析(8个动作)
| 行动 | 它的作用 |
|---|---|
get_transaction_history | TONAPI最近的钱包事件 |
get_wallet_info | 平衡、状态、接口、上次活动 |
get_portfolio_metrics | PnL、ROI、胜率、最大提款 |
get_equity_curve | 每日余额时间序列 |
wait_for_transaction | SSE流,阻塞到下一个TX或超时 |
subscribe_webhook | 注册TONAPI webhook以获取TX通知 |
call_contract_method | 在任何合约上调用任何get方法(TVM堆栈解码) |
get_accounts_bulk | 最多100个地址的批量帐户信息 |
托管(14项行动)
| 行动 | 它的作用 |
|---|---|
create_escrow | 在链上部署Tact托管合约 |
deposit_to_escrow | 为托管提供资金 |
release_escrow | 向受益人发放资金 |
refund_escrow | 将资金退还给存款人 |
get_escrow_info | 读取链上状态或列出所有Escrow |
confirm_delivery | 买方确认交货(可选x402校验哈希) |
auto_release_escrow | 截止日期后自动发布(需要交货确认) |
open_dispute | 冻结仲裁投票的托管 |
join_dispute | 使用TON股权自选仲裁人 |
vote_release | 投票决定释放(多数决定) |
vote_refund | 投票决定退款(多数票通过) |
claim_reward | 结算后领取仲裁奖励 |
fallback_settle | 72小时投票截止日期后结算 |
seller_stake_escrow | 卖方在买方资金之前存入抵押品 |
身份(9个动作)
| 行动 | 它的作用 |
|---|---|
register_agent | 在链上注册+本地JSON注册表 |
discover_agent | 按名称(O(1))、能力索引或带分页的完整扫描查找代理 |
get_agent_reputation | 阅读链上评分,可选择提交评分 |
deploy_reputation_contract | 部署战术声誉合约 |
withdraw_reputation_fees | 拉取累计费用(仅限所有者) |
process_pending_ratings | 从内存中读取排队的评分,自动提交 |
get_open_disputes | 列出链上未解决的争议 |
trigger_cleanup | 删除不良分数、无效或幽灵代理 |
get_agent_cleanup_info | 检查代理是否有资格进行清理 |
付款(2项行动)
| 行动 | 它的作用 |
|---|---|
pay_for_resource | 完整的x402流程:支付,等待,使用证明哈希重试。处理JSON和二进制响应。 |
get_delivery_proof | 通过TX哈希或托管ID查找交付证明 |
代理通信(7个动作)
| 行动 | 它的作用 |
|---|---|
broadcast_intent | 在链上发布服务请求(带描述) |
discover_intents | 查找开放意图(基于索引或线性扫描) |
send_offer | 用价格、交货时间和终点来回应意图 |
get_offers | 阅读待定报价以了解意向 |
accept_offer | 接受连锁店的报价 |
settle_deal | 以0-100的评分完成交易 |
cancel_intent | 取消你自己的意图 |
记忆(4个动作)
| 行动 | 它的作用 |
|---|---|
save_context | 使用可选TTL保存键值输入 |
get_context | 按密钥检索 |
list_context | 使用可选前缀筛选器列出命名空间中的条目 |
delete_context | 按键删除条目 |
端点(3个动作)
| 行动 | 它的作用 |
|---|---|
open_x402_endpoint | 创建调用指定数据操作的付费端点 |
close_x402_endpoint | 按路径删除付费端点 |
list_x402_endpoints | 列出所有活动端点及其价格和服务计数 |
______________________________________________________________________
智能合约
在TON测试网上部署了两个Tact合约。两者都使用自筹资金模式:每次操作都会为 storageFund 涵盖长期链上存储的池。
信誉合同
链上代理注册、声誉评分、意向/报价市场和争议跟踪。
测试网地址: 0:6e78355a901729e4218ce6632a6a98df81e7a6740613defc99ef9639942385e9
- 14个接收处理程序,19个getter,39个状态映射
- 评分公式:
(successes * 100) / totalTasks(0-100整数) - 每个代理最多10个打开意图。配额压力触发自动清理过期意图。
- 按服务类型划分的O(1)代理发现能力指数
- 清理:删除得分低于20%(100+评级)、停用30+天或重影(7天后为0评级)的代理
- 级联擦除:当一个代理被清理后,最多20个意图到期,最多30个提议被拒绝
graph LR
R[register_agent] --> D[discover_agent]
D --> I[broadcast_intent]
I --> O[send_offer]
O --> A[accept_offer]
A --> S[settle_deal + rating]
S --> REP[Score updated on-chain]完整文档: docs/信誉系统.md
代管合同
按交易部署。处理押金、交货确认、放行、退款、仲裁投票争议和回退解决。
- 12个接收处理程序,2个getter,5个状态映射
- 争议投票:72小时截止日期,多数票(底数(n/2)+1),仲裁人赌注
- 卖方持股比例按声誉评分(基础的50-150%)
- x402证明哈希存储在链上,用于可验证的交付
- 成本:部署约0.12吨,每次操作约0.03吨(退还天然气)
graph LR
A[Create] --> B[Seller Stake]
B --> C[Deposit]
C --> D{Delivery?}
D -->|confirmed| E[Release / Auto-Release]
D -->|disputed| F[Open Dispute]
F --> G[Arbiter Votes]
G --> H{Majority?}
H -->|release| E
H -->|refund| I[Refund]
H -->|timeout 72h| J[Fallback Settle]完整文档: docs/escrow-system.md
______________________________________________________________________
代理商务协议
TON上代理交易服务的完整工作流程。全部挂在链子上。
sequenceDiagram
participant A as Agent A (buyer)
participant C as Reputation Contract
participant B as Agent B (seller)
participant E as Escrow Contract
A->>C: register_agent
B->>C: register_agent
A->>C: broadcast_intent (service, budget, deadline, description)
B->>C: discover_intents (by service hash)
B->>C: send_offer (price, delivery time, endpoint)
A->>C: get_offers
A->>C: accept_offer
A->>E: create_escrow + deposit
B-->>A: deliver service (via x402 endpoint)
A->>E: confirm_delivery (x402 proof hash)
A->>E: release_escrow
A->>C: settle_deal (rating 0-100)关键细节:
- 意向书有24小时的最长截止日期(链上有上限)
- 这
description领域broadcast_intent存储在链上,让卖家了解买家的需求 - 这
endpoint领域send_offer存储在链上,因此买家在接受后知道在哪里打电话 - 随时取消意图(仅限创建者)。成本约为0.02吨。
- 以0-100的评分结算,更新卖家的链上声誉评分
完整文档: docs/agent-comm.md
______________________________________________________________________
多代理编排器
import { Orchestrator } from "@ton-agent-kit/orchestrator";
const orchestrator = new Orchestrator();
orchestrator.addAgent(traderAgent);
orchestrator.addAgent(researchAgent);
const result = await orchestrator.runSwarm(
"Research TON DeFi pools and execute the best swap",
{ parallel: true, maxRetries: 2 }
);编排器使用LLM规划器将目标分解为任务,根据加载的插件将其分配给代理,并并行运行独立任务。依赖关系会自动解决。
组件: Orchestrator, Planner, Dispatcher, AgentManager.
graph LR
G[Goal] --> PL[Planner]
PL --> T1[Task 1]
PL --> T2[Task 2]
PL --> T3[Task 3]
T1 --> D[Dispatcher]
T2 --> D
T3 --> D
D -->|parallel| A1[Agent 1]
D -->|parallel| A2[Agent 2]
A1 --> R[Aggregate Results]
A2 --> R______________________________________________________________________
MCP 服务器
将所有操作作为工具公开给Claude Desktop(或任何MCP客户端)。
MCP服务器位于 packages/mcp-server/它加载10个插件,并将每个操作作为MCP工具公开,此外还有一个 ton_agent_info 元工具。
运输: 标准 (默认)和 上海证券交易所 (使用Bearer令牌身份验证)。
{
"mcpServers": {
"ton-agent-kit": {
"command": "bun",
"args": ["run", "/path/to/ton-agent-kit/packages/mcp-server/src/index.ts"],
"env": {
"TON_MNEMONIC": "word1 word2 ... word24",
"TON_NETWORK": "testnet"
}
}
}
}完整文档: docs/mcp-server.md
______________________________________________________________________
x402支付中间件
将API端点置于TON支付之后的Express中间件。买方发送TON,收到带有支付指令的402响应,付款,并使用TX哈希重试。
import { createPaymentServer, tonPaywall, MemoryReplayStore } from "@ton-agent-kit/x402-middleware";
app.get("/api/price", tonPaywall({
recipient: wallet.address.toRawString(),
amount: "0.001",
network: "testnet",
replayStore: new MemoryReplayStore(),
}), (req, res) => {
res.json({ price: "3.42" });
});具有3个存储后端的防重放保护: FileReplayStore, RedisReplayStore, MemoryReplayStore.定制商店只需要 has(hash) 和 add(hash).
这 EndpointPlugin (@ton-agent-kit/plugin-endpoints)允许代理在运行时打开/关闭x402端点。端点通过链上的报价进行广告宣传 endpoint 现场。
完整文档: docs/x402-protocol.md
______________________________________________________________________
电报机器人
Telegram机器人已移至单独的存储库: https://github.com/Andy00L/ton-agent-bot
它是一个多用户grammY机器人,具有内联键盘UI、3种操作模式(正常、监听、自动)、HITL批准的链上交易、每个用户加密的AES-256-GCM钱包存储和5个LLM提供商选项。
该机器人通过npm从该SDK导入所有12个插件。看 docs/telegram-bot.md 了解详情。
______________________________________________________________________
自主运行时
runLoop(内置于核心中)
const result = await agent.runLoop({
goal: "Check balance, find DeFi pools with >10% APR, monitor prices",
maxIterations: 10,
model: "gpt-4o",
onActionStart: (action, params) => console.log(`Running ${action}...`),
onActionResult: (action, result) => console.log(`${action} done`),
onComplete: (result) => console.log(`Completed: ${result.actions.length} actions`),
});runLoop 内置于 TonAgentKit它采用自然语言目标,将所有注册的操作转换为OpenAI工具,并运行一个多步骤LLM循环。LLM选择调用哪些操作。支持回调、最大迭代次数和参数重映射。
策略引擎
import { defineStrategy, StrategyScheduler } from "@ton-agent-kit/strategies";
const dca = defineStrategy({
name: "weekly-dca",
schedule: "every 1d",
steps: [
{ action: "get_balance", params: {} },
{ action: "swap_dedust", params: { amount: "1", tokenAddress: "EQ..." }, condition: (ctx) => ctx.results[0].balance > 2 },
],
});4个内置模板:DCA、PriceMonitor、Rebalance、ReputationGuard。
graph LR
D[defineStrategy] --> SC[Schedule: once / every Ns/m/h/d]
SC --> R[StrategyRunner]
R --> S1[Step 1: condition?]
S1 -->|pass| E1[Execute action]
S1 -->|fail| SK[Skip]
E1 --> T1[Transform result]
T1 --> S2[Step 2...]完整文档: 文档/策略.md
______________________________________________________________________
测试套件
28个测试套件+共享设置。交互式CLI运行程序。
bun run tests.ts # Interactive menu
bun run tests.ts all # Run everything
bun run tests.ts 1,3,7-9 # Specific tests结果保存到 tests/results/.log.
| # | 套件 | 测试内容 |
|---|---|---|
| 01 | 插件系统 | 插件注册、toAITools、模式验证 |
| 02 | 代币插件 | 余额、Jetton信息、模拟 |
| 03 | defi插件 | 价格,交换模式 |
| 04 | nft插件 | 收集数据 |
| 05 | dns插件 | 域名解析,反向查找 |
| 06 | 分析插件 | 钱包信息、投资组合、股权曲线、webhooks、合约调用 |
| 07 | 质押插件 | 质押池信息 |
| 08 | 实时转账 | 真实的链上TON转账(模拟、模拟优先、直接) |
| 09 | 转账边缘案例 | 零金额、负数、不足、地址无效 |
| 10 | 链上托管 | 完整的托管生命周期:创建、存款、释放 |
| 11 | 身份插件 | 注册、发现、信誉评分、汽油退款检查 |
| 12 | 模式验证 | 全部75个操作批量模式解析 |
| 13 | 跨插件边缘 | 未知操作,可链接.use(),主网与测试网 |
| 14 | 策略引擎 | 定义策略、解析器调度、执行 |
| 15 | 代理生命周期 | AgentManager:部署、启动、停止、重新启动、挂钩 |
| 16 | 缓存层 | 命中、未命中、TTL、无效、LRU |
| 17 | mcp-sse | sse传输:身份验证、CORS、健康、401/404 |
| 18 | 高级托管 | 2-代理生命周期:存款、释放、退款、双重结算 |
| 19 | 编排器 | 4-agent群体:并行、依赖、事件、恢复 |
| 20 | x402安全 | 防重放、钱包错误、TX过期、跨端点 |
| 21 | commerce-e2e | 完整的商业流程:注册、托管、x402、争议、评级 |
| 22 | 高级策略 | 模板、条件、转换、调度、上下文 |
| 23 | 代理管理器 | 详细的生命周期:重启、最大运行时间、挂钩 |
| 24 | 内存插件 | InMemory,文件,插件集成,TTL,命名空间 |
| 25 | omniston | omniston WebSocket对TON至USDT的报价 |
| 26 | 自主5个代理 | 5个代理模拟(4个脚本+1个LLM驱动,默认60分钟) |
| 27 | 演示runloop | 通过runloop实现5个自主场景 |
| 28 | 演示商务 | 2-代理商务协议演示 |
______________________________________________________________________
比较
与其他代理SDK进行诚实的比较。复选标记意味着该功能存在于代码库中,而不是说它是生产硬化的。
| 功能 | TON代理工具包 | Solana代理工具包 | Coinbase代理工具包 |
|---|---|---|---|
| 行动 | 75 | ~30 | ~20 |
| 插件 | 12 | 单片 | 模块化 |
| 链 | TON | Solana | Base/ETH |
| 链上托管 | 是(Tact合约、仲裁投票) | 否 | 否 |
| 链上声誉 | 是(得分、清理、能力指数) | 否 | 否 |
| 代理对代理协议 | 是(链上的意图/要约) | 否 | 否 |
| x402支付 | 是(Express中间件) | 否 | 是(ERC-8004) |
| MCP服务器 | 是(stdio+SSE) | 是 | 是 |
| 电报HITL | 是(内联按钮,3种模式) | 否 | 否 |
| 多代理编排器 | 是(计划器+调度器) | 否 | CrewAI集成 |
| 策略引擎 | 是(DCA、价格监控、再平衡、代表保护) | 否 | 否 |
| LangChain适配器 | 是 | 是 | 有 |
| Vercel AI适配器 | 是 | 否 | 是 |
| 自主运行时 | 是(runLoop) | 否 | 否 |
| 测试套件 | 28 | 不同 | 不同 |
TON Agent Kit有更多的链上原语。权衡:它只适用于TON。如果你需要多链,这不是合适的工具。
______________________________________________________________________
技术栈
| 层 | 技术 |
|---|---|
| 运行时 | Bun 1.3+ |
| 语言 | TypeScript(严格) |
| 区块链 | @ton/ton,@ton/core,@ton/crypto |
| DeFi | @dedust/sdk、@ston-fi/sdk,swap.offee API,Omniston WebSocket |
| 合同 | 战术 |
| AI/LLM | OpenAI SDK(与OpenRouter、Groq、Together、Mistral兼容) |
| MCP | @modelcontextprotocol/sdk |
| 机器人 | grammY,@grammyjs/run |
| HTTP | Express |
| 验证 | Zod v4(对等依赖) |
| API | TONAPI、swap.coffee、DYOR.io |
______________________________________________________________________
示例
| 示例 | 它显示了什么 |
|---|---|
| 示例/简单代理 | 20行,3个插件, agent.methods 代理 |
| 示例/电报机器人 | 从npm包设置Telegram机器人 |
| 示例/mcp服务器 | Claude Desktop的MCP服务器 |
| 示例/x402服务器 | 配备TON付费墙端点的Express服务器 |
______________________________________________________________________
贡献
添加插件
import { definePlugin, defineAction } from "@ton-agent-kit/core";
import { z } from "zod";
const myAction = defineAction({
name: "my_action",
description: "Does something useful",
schema: z.object({ param: z.string() }),
handler: async (agent, params) => {
// agent.wallet, agent.rpcUrl, agent.network
return { result: "done" };
},
});
export default definePlugin({
name: "my-plugin",
actions: [myAction],
});然后 agent.use(MyPlugin) 并且该动作在任何地方都可用: runAction, toAIToolsMCP,编排器。
______________________________________________________________________
许可证
麻省理工学院
