@openclaw-harness/orchestrator
v0.1.0
Published
OpenClaw Harness Orchestrator - Multi-Agent coordination and task dispatching
Maintainers
Readme
@openclaw-harness/orchestrator
English | 中文
多 Agent 协调和任务分发
特性
- 🤖 Agent 管理 - 注册、管理和监控多个 Agent
- 🎯 智能路由 - 能力匹配、负载均衡、成本优化
- 🔄 Agent 交接 - Agent 之间的无缝上下文转移
- 📢 广播 - 向多个 Agent 广播消息
安装
npm install @openclaw-harness/orchestrator快速开始
import { HarnessOrchestratorPlugin } from '@openclaw-harness/orchestrator';
const plugin = new HarnessOrchestratorPlugin();
// 初始化
await plugin.init(openClawContext);
// 获取编排器服务
const orchestratorService = openClawContext.api.getService('harness:orchestrator');
// 注册 Agent
await orchestratorService.registerAgent({
id: 'my-agent',
name: '我的 Agent',
capabilities: [{ name: 'text-generation', description: '生成文本' }]
});
// 分发任务
const result = await orchestratorService.dispatchTask({
id: 'task-1',
type: 'text-generation',
description: '写一首诗',
input: {},
priority: 'medium'
});路由策略
- 能力匹配 - 根据任务类型选择具有相应能力的 Agent
- 轮询 - 平均分配任务到所有可用 Agent
- 负载均衡 - 选择负载最轻的 Agent
- 成本优化 - 优先选择成本较低的 Agent
- 性能优化 - 选择响应时间最短的 Agent
CLI 命令
# 列出所有 Agent
openclaw harness:agent:list
# 从 JSON 文件注册 Agent
openclaw harness:agent:register ./agent-config.json
# 注销 Agent
openclaw harness:agent:unregister <agent-id>
# 查看 Agent 状态
openclaw harness:agent:status <agent-id>
# 分发任务
openclaw harness:task:dispatch '{"id":"task-1","type":"text-generation","description":"写一首诗"}'
# Agent 交接
openclaw harness:agent:handoff <from-agent-id> <to-agent-id>
# 查看指标
openclaw harness:orchestrator:metricsHTTP API
# 列出所有 Agent
curl http://localhost:3000/harness/agents
# 注册 Agent
curl -X POST http://localhost:3000/harness/agents \
-H "Content-Type: application/json" \
-d @agent-config.json
# 分发任务
curl -X POST http://localhost:3000/harness/tasks \
-H "Content-Type: application/json" \
-d '{"id":"task-1","type":"text-generation","description":"写一首诗","input":{},"priority":"medium"}'
# Agent 交接
curl -X POST http://localhost:3000/harness/handoff \
-H "Content-Type: application/json" \
-d '{"fromAgentId": "agent-1", "toAgentId": "agent-2"}'Agent 配置示例
{
"id": "tech-agent",
"name": "技术支持 Agent",
"description": "处理技术问题",
"capabilities": [
{ "name": "technical-support", "description": "处理技术问题" },
{ "name": "debugging", "description": "调试代码问题" }
],
"tools": ["search", "code-executor", "file-reader"],
"model": "gpt-4"
}协调模式
Supervisor 模式
一个主管 Agent 管理多个工作 Agent:
const coordination = orchestratorService.createCoordination({
type: 'supervisor',
config: {
supervisorAgentId: 'supervisor',
workerAgentIds: ['worker1', 'worker2'],
delegationStrategy: 'auto'
}
});Pipeline 模式
多个 Agent 按顺序处理任务:
const coordination = orchestratorService.createCoordination({
type: 'pipeline',
config: {
stages: [
{ id: 'stage1', agentId: 'agent1' },
{ id: 'stage2', agentId: 'agent2' }
],
errorHandling: 'stop'
}
});文档
查看 完整文档 获取更多详情。
许可证
MIT © OpenClaw Harness Team
