uni-agent

统一智能体协议适配层。一套 API 调用所有 Agent 协议(ANP/MCP/A2A/AITP 等)。当用户需要调用 Agent、跨协议通信、连接工具时触发此技能。

154 stars

Best use case

uni-agent is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

统一智能体协议适配层。一套 API 调用所有 Agent 协议(ANP/MCP/A2A/AITP 等)。当用户需要调用 Agent、跨协议通信、连接工具时触发此技能。

Teams using uni-agent should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/uni-agent/SKILL.md --create-dirs "https://raw.githubusercontent.com/zrt-ai-lab/opencode-skills/main/uni-agent/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/uni-agent/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How uni-agent Compares

Feature / Agentuni-agentStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

统一智能体协议适配层。一套 API 调用所有 Agent 协议(ANP/MCP/A2A/AITP 等)。当用户需要调用 Agent、跨协议通信、连接工具时触发此技能。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# UniAgent - 统一智能体协议适配层

"Connect Any Agent, Any Protocol"

## 设计理念

### 问题
当前 Agent 协议生态割裂:
- **MCP**:Anthropic 的工具调用协议
- **A2A**:Google 的 Agent 间协作协议
- **ANP**:去中心化身份 + Agent 网络协议
- **AITP**:NEAR 的交互交易协议
- ...

开发者需要为每个协议学习不同的 SDK、实现不同的调用逻辑。

### 解决方案
UniAgent 提供统一抽象层,一套 API 适配所有协议:

```python
from uni_agent import UniAgent

agent = UniAgent()

# 调用 ANP Agent
agent.call("amap@anp", "maps_weather", {"city": "北京"})

# 调用 MCP Server
agent.call("filesystem@mcp", "read_file", {"path": "/tmp/a.txt"})

# 调用 A2A Agent
agent.call("assistant@a2a", "chat", {"message": "hello"})

# 调用 AITP Agent(带支付)
agent.call("shop@aitp", "purchase", {"item": "coffee", "amount": 10})
```

## 架构设计

```
┌─────────────────────────────────────────────────────────┐
│                      UniAgent                           │
│                   统一调用接口                            │
├─────────────────────────────────────────────────────────┤
│  call(agent_id, method, params) -> result               │
│  discover(capability) -> List[Agent]                    │
│  connect(agent_id) -> Connection                        │
└────────────────────────┬────────────────────────────────┘
                         │
              ┌──────────┴──────────┐
              │   Protocol Router   │
              │   协议路由 & 适配    │
              └──────────┬──────────┘
                         │
   ┌─────────┬───────────┼───────────┬─────────┐
   ▼         ▼           ▼           ▼         ▼
┌──────┐ ┌──────┐   ┌──────┐   ┌──────┐  ┌──────┐
│ ANP  │ │ MCP  │   │ A2A  │   │ AITP │  │ ...  │
│Adapter│ │Adapter│  │Adapter│  │Adapter│ │Adapter│
└──────┘ └──────┘   └──────┘   └──────┘  └──────┘
```

## 核心概念

### 1. Agent ID 格式
```
<agent_name>@<protocol>

示例:
- amap@anp          # ANP 协议的高德地图 Agent
- filesystem@mcp   # MCP 协议的文件系统 Server
- gemini@a2a       # A2A 协议的 Gemini Agent
- shop@aitp        # AITP 协议的商店 Agent
```

### 2. 统一调用接口
```python
result = agent.call(
    agent_id="amap@anp",      # Agent 标识
    method="maps_weather",     # 方法名
    params={"city": "北京"},   # 参数
    timeout=30                 # 可选超时
)
```

### 3. 能力发现
```python
# 发现所有能提供天气服务的 Agent
agents = agent.discover("weather")
# 返回: [
#   {"id": "amap@anp", "protocol": "anp", "methods": [...]},
#   {"id": "weather@mcp", "protocol": "mcp", "methods": [...]}
# ]
```

### 4. 协议适配器接口
```python
class ProtocolAdapter(ABC):
    """协议适配器基类"""
    
    @abstractmethod
    def connect(self, agent_config: dict) -> Connection:
        """建立连接"""
        pass
    
    @abstractmethod
    def call(self, connection: Connection, method: str, params: dict) -> dict:
        """调用方法"""
        pass
    
    @abstractmethod
    def discover(self, capability: str) -> List[AgentInfo]:
        """发现 Agent"""
        pass
    
    @abstractmethod
    def close(self, connection: Connection):
        """关闭连接"""
        pass
```

## 支持的协议

| 协议 | 状态 | 适配器 | 说明 |
|------|------|--------|------|
| ANP | ✅ 已实现 | `adapters/anp.py` | 去中心化身份 + Agent 网络 |
| MCP | ✅ 已实现 | `adapters/mcp.py` | LLM 工具调用 |
| A2A | ✅ 已实现 | `adapters/a2a.py` | Agent 间协作 |
| AITP | ✅ 已实现 | `adapters/aitp.py` | 交互 + 交易 |
| Agent Protocol | ✅ 已实现 | `adapters/agent_protocol.py` | REST API |
| LMOS | ✅ 已实现 | `adapters/lmos.py` | 企业级平台 |

## 使用方式

### CLI 调用

```bash
# 调用 ANP Agent
python scripts/uni_cli.py call amap@anp maps_weather '{"city":"北京"}'

# 调用 MCP Server
python scripts/uni_cli.py call filesystem@mcp read_file '{"path":"/tmp/a.txt"}'

# 发现 Agent
python scripts/uni_cli.py discover weather

# 列出已注册 Agent
python scripts/uni_cli.py list
```

### Python SDK

```python
from uni_agent import UniAgent

# 初始化
agent = UniAgent(config_path="config/agents.yaml")

# 调用
result = agent.call("amap@anp", "maps_weather", {"city": "北京"})
print(result)

# 批量调用
results = agent.batch_call([
    ("amap@anp", "maps_weather", {"city": "北京"}),
    ("amap@anp", "maps_weather", {"city": "上海"}),
])
```

## 配置文件

### config/agents.yaml
```yaml
agents:
  # ANP Agents
  - id: amap
    protocol: anp
    ad_url: https://agent-connect.ai/mcp/agents/amap/ad.json
    
  - id: hotel
    protocol: anp
    ad_url: https://agent-connect.ai/agents/hotel-assistant/ad.json

  # MCP Servers
  - id: filesystem
    protocol: mcp
    command: npx
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
    
  - id: github
    protocol: mcp
    command: npx
    args: ["-y", "@modelcontextprotocol/server-github"]
    env:
      GITHUB_TOKEN: "${GITHUB_TOKEN}"

  # A2A Agents
  - id: assistant
    protocol: a2a
    endpoint: https://example.com/.well-known/agent.json
```

### config/identity.yaml
```yaml
# 身份配置(跨协议通用)
identity:
  # ANP DID 身份
  anp:
    did_document: config/did.json
    private_key: config/private-key.pem
  
  # A2A 认证
  a2a:
    auth_type: oauth2
    client_id: "${A2A_CLIENT_ID}"
    client_secret: "${A2A_CLIENT_SECRET}"
```

## 目录结构

```
uni-agent/
├── SKILL.md                 # 本文件
├── README.md                # 使用文档
├── setup.sh                 # 一键安装
├── requirements.txt         # Python 依赖
├── config/
│   ├── agents.yaml          # Agent 注册表
│   ├── identity.yaml        # 身份配置
│   └── .gitignore
├── adapters/
│   ├── __init__.py
│   ├── base.py              # 适配器基类
│   ├── anp.py               # ANP 适配器
│   ├── mcp.py               # MCP 适配器
│   ├── a2a.py               # A2A 适配器
│   └── aitp.py              # AITP 适配器
├── scripts/
│   └── uni_cli.py           # CLI 工具
└── docs/
    ├── architecture.md      # 架构文档
    └── adapters.md          # 适配器开发指南
```

## 扩展新协议

1. 创建适配器文件 `adapters/new_protocol.py`
2. 继承 `ProtocolAdapter` 基类
3. 实现 `connect`、`call`、`discover`、`close` 方法
4. 在 `adapters/__init__.py` 注册

```python
# adapters/new_protocol.py
from .base import ProtocolAdapter

class NewProtocolAdapter(ProtocolAdapter):
    protocol_name = "new_protocol"
    
    def connect(self, agent_config):
        # 实现连接逻辑
        pass
    
    def call(self, connection, method, params):
        # 实现调用逻辑
        pass
    
    # ...
```

## 依赖

```bash
pip install anp aiohttp mcp pyyaml
```

Related Skills

videocut-subtitle

154
from zrt-ai-lab/opencode-skills

字幕生成与烧录。转录→词典纠错→审核→烧录。触发词:加字幕、生成字幕、字幕

videocut-self-update

154
from zrt-ai-lab/opencode-skills

自更新 skills。记录用户反馈,更新方法论和规则。触发词:更新规则、记录反馈、改进skill

videocut-install

154
from zrt-ai-lab/opencode-skills

环境准备。安装依赖、下载模型、验证环境。触发词:安装、环境准备、初始化

videocut-clip

154
from zrt-ai-lab/opencode-skills

执行视频剪辑。根据确认的删除任务执行FFmpeg剪辑,循环直到零口误,生成字幕。触发词:执行剪辑、开始剪、确认剪辑

videocut-clip-oral

154
from zrt-ai-lab/opencode-skills

口播视频转录和口误识别。生成审查稿和删除任务清单。触发词:剪口播、处理视频、识别口误

video-subtitle-remover

154
from zrt-ai-lab/opencode-skills

视频硬字幕/水印去除技能。自动配置基于 YaoFANGUK/video-subtitle-remover 的环境并执行去字幕。当用户要求"去除视频字幕"、"去水印"、"把这个视频的字幕干掉"时触发此技能。

video-stickfigure

154
from zrt-ai-lab/opencode-skills

火柴人图片生成技能。使用AI生成粉笔画风格火柴人,并用HSV统一背景色。当需要生成火柴人视频素材时触发。

video-creator

154
from zrt-ai-lab/opencode-skills

视频创作技能。图片+音频合成视频,支持TTS配音、淡入淡出转场、字幕、片尾、BGM。当用户提到「生成视频」「做视频」「教学视频」「图文转视频」「做视频号」「配音视频」「图文结合视频」「古诗视频」「故事视频」时触发。内含生图→配音→合成全流程,无需单独调用image-service。

video-copywriting

154
from zrt-ai-lab/opencode-skills

短视频文案创作技能。包含爆款公式、黄金结构、三关校验。当需要撰写短视频文案时触发。

story-to-scenes

154
from zrt-ai-lab/opencode-skills

长文本拆镜批量生图引擎。将故事、课程、连环画脚本智能拆分场景,批量生成风格统一、角色一致的配图。当用户提到「拆镜生图」「故事配图」「批量场景图」「连环画生成」「绘本生成」时使用此技能。

smart-query

154
from zrt-ai-lab/opencode-skills

智能数据库查询技能。通过SSH隧道连接线上数据库,支持自然语言转SQL、执行查询、表结构探索。当用户需要查询数据库、问数据、看表结构时使用此技能。

skill-creator

154
from zrt-ai-lab/opencode-skills

Skill 开发指南。当用户需要创建新 Skill 或更新已有 Skill 时触发,提供标准化模板、目录规范和最佳实践。