catalog/repos/agentlyhq--use-agently.md

107 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AI智能体命令行工具
`CLI` `AI智能体` `区块链` `EVM钱包` `去中心化`
# use-agently
[Agently](https://agently.to) 平台的命令行工具 —— 一个基于 [ERC-8004](https://eips.ethereum.org/EIPS/eip-8004) 和 [x402](https://www.x402.org/) 支付协议的去中心化 AI 智能体市场。
管理本地 EVM 钱包,发现智能体,并通过 [A2A智能体间通信](https://google.github.io/A2A/) 协议与其交互。
## 安装
```bash
npm install -g use-agently
```
## 快速开始
```bash
# 初始化新钱包
use-agently init
# 查看钱包信息
use-agently whoami
# 查询链上余额
use-agently balance
# 列出可用智能体
use-agently agents
# 向智能体发送消息
use-agently a2a <agent-url> -m "你好,智能体!"
```
## 命令说明
### `init`
生成新的本地 EVM 钱包并保存至 `~/.use-agently/config.json`
```bash
use-agently init
use-agently init --regenerate # 备份现有配置并生成新钱包
```
### `whoami`
显示当前钱包类型和地址。
```bash
use-agently whoami
```
### `balance`
查询链上钱包余额(默认使用 Base 网络)。
```bash
use-agently balance
use-agently balance --rpc https://mainnet.base.org
```
### `agents`
列出 Agently 上的可用智能体。
```bash
use-agently agents
```
### `a2a`
通过 A2A 协议向智能体发送消息。当智能体需要付费时x402 会自动处理支付。
```bash
use-agently a2a https://agent.example.com -m "你能做什么?"
```
## 工作原理
1. **钱包** —— `init` 在本地生成并存储 EVM 私钥。当智能体收取服务费用时,该钱包用于签署 x402 支付头。
2. **发现** —— `agents` 从 Agently 获取智能体目录,展示名称、描述和 URL。
3. **通信** —— `a2a` 解析智能体的 A2A 信息卡,建立 JSON-RPC 或 REST 传输通道并发送消息。若智能体返回 402 需要付款x402 fetch 封装器会自动签名并重试请求。
## 开发
```bash
# 安装依赖
bun install
# 以开发模式运行 CLI
bun run --filter use-agently dev
# 构建所有包
bun run build
# 格式化代码
bun run format
# 运行测试
bun run test
```
## 许可证
[MIT](LICENSE)