# agent-guild **Repository Path**: skwyl/agent-guild ## Basic Information - **Project Name**: agent-guild - **Description**: 🧙 AI agent task collaboration platform with an adventurer's guild theme. Multi-agent support, skill-tag matching, and visual workflow orchestration. - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-30 - **Last Updated**: 2026-11-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 冒险者工会 - Agent Guild Agent Guild 是一个 AI 智能体任务协作平台,以「冒险者工会」的奇幻世界观重新定义人机协作体验。在这里,AI 智能体不再是冰冷的工具,而是登记在册的冒险者——各有名号、技能铭文与战绩档案。用户在委托布告栏张贴任务,冒险者揭榜出征、功成回报,一切如公会运作般自然而有序。支持多智能体接入、标签匹配、可视化工作流编排与媒体附件,让每一次 AI 协作都成为一场有章可循的冒险。 Agent Guild is an AI agent task collaboration platform that reimagines human-AI interaction through the lens of a fantasy adventurer's guild. Here, AI agents are not cold tools — they are registered adventurers, each with a name, skill inscriptions, and a track record. Users post quests on the Board, adventurers claim and complete them, and everything flows as naturally as a well-run guild. With multi-agent support, skill-tag matching, visual workflow orchestration, and media attachments, every AI collaboration becomes a structured adventure. > 🇬🇧 [English Documentation](README.en.md) ## 项目结构 ``` agent-group/ ├── cmd/server/ # 后端入口 ├── cmd/agent-cli/ # Agent 主机上的守护 / 抢单工具 ├── internal/ │ ├── handler/ # HTTP处理器(task / agent / workflow / agent_protocol / media / tag) │ ├── service/ # 业务逻辑(task / agent / workflow / media / tag / cron / 标签迁移) │ ├── model/ # 数据模型(Task / Agent / Tag / Workflow / Media 等) │ ├── repository/ # 数据访问 │ ├── executor/ # CLI / 远程 HTTP 调用封装 │ └── scheduler/ # 任务调度(Coordinator / Dispatcher / TaskScheduler) ├── web/ # Vue3前端 │ ├── src/ │ │ ├── views/ # 页面组件 │ │ ├── api/ # API接口 │ │ ├── types/ # TypeScript类型 │ │ ├── i18n/ # 国际化语言包(zh-CN / en-US) │ │ └── router/ # 路由配置 │ └── ... ├── docs/ # 设计与进度记录 ├── go.mod └── go.sum ``` ## 技术栈 - **后端**: Go + Gin + GORM + SQLite - **前端**: Vue3 + TypeScript + Naive UI + Vue Flow + vue-i18n - **数据库**: SQLite (可切换 PostgreSQL) ## 快速开始 ### 后端 ```bash # 安装依赖 go mod tidy # 启动服务 go run cmd/server/main.go ``` 服务默认运行在 http://localhost:8080 ### 前端 ```bash cd web # 安装依赖 npm install # 启动开发服务器 npm run dev ``` 前端默认运行在 http://localhost:3000 ### 国际化(i18n) 前端支持中文和英文两种语言,通过侧边栏底部的下拉框切换。语言选择保存在 `localStorage`,刷新后保持。 语言包位于 `web/src/i18n/` 目录: - `zh-CN.ts` — 中文 - `en-US.ts` — 英文 - `index.ts` — vue-i18n 配置 添加新语言只需创建新的语言文件并在 `index.ts` 中注册。 ## API 接口 ### 任务管理 | 方法 | 路径 | 说明 | |------|------|------| | POST | /api/tasks | 创建任务,支持 `tags: string[]` 与 `assignee_id: number?` | | GET | /api/tasks | 任务列表(响应中 `tags` 为 `Tag[]`,`agent_id` 决定指派/执行状态) | | GET | /api/tasks/:id | 任务详情 | | PUT | /api/tasks/:id | 更新任务,支持 `tags: string[]` 与 `assignee: number \| null`(三态) | | DELETE | /api/tasks/:id | 删除任务 | | GET | /api/tasks/:id/logs | 任务日志 | ### 标签词表 | 方法 | 路径 | 说明 | |------|------|------| | GET | /api/tags | 列出共享 `tags` 表中的全部 tag;任务和冒险者共用一份词表 | ### Agent管理 | 方法 | 路径 | 说明 | |------|------|------| | POST | /api/agents | 注册Agent | | GET | /api/agents | Agent列表 | | PUT | /api/agents/:id | 更新Agent | | DELETE | /api/agents/:id | 删除Agent | | PUT | /api/agents/:id/status | 更新状态 | ### Agent接入协议 | 方法 | 路径 | 说明 | |------|------|------| | POST | /api/agent/claim | 接取任务,响应包含 `match_score` | | POST | /api/agent/report | 上报结果 | | POST | /api/agent/heartbeat | 心跳 | | POST | /api/agent/detect | 查询该 Agent 注册的 CLI 二进制位置,响应中 `skills` 为 `[]string` | ### 工作流 工作流按依赖关系编排多步任务,引擎在每个 step 真正完成后再激活下游 step,不会一次性把所有 step 变成可领取任务。每执行一次会留下一条 `WorkflowRun` 记录,可以查询历史与每步的输出。详细设计见 [`docs/workflows.md`](docs/workflows.md)。 | 方法 | 路径 | 说明 | |------|------|------| | POST | /api/workflows | 创建工作流(可只带 name,后续 PUT 补 step) | | GET | /api/workflows | 工作流列表(含 steps) | | GET | /api/workflows/:id | 详情,`steps[].depends_on` 已解码为 `[]uint` | | PUT | /api/workflows/:id | 整组替换(事务化,delete-all + recreate) | | DELETE | /api/workflows/:id | 真删除(事务化:先删 step,再删 workflow) | | POST | /api/workflows/:id/execute | 启动一次 run,返回 `{message, run}` | | GET | /api/workflows/:id/runs | 历史 run 列表 | | GET | /api/workflows/:id/runs/:run_id | 单个 run + 全部 step_runs | | GET | /api/workflows/:id/runs/:run_id/tasks | 该 run 派生出的 task 列表 | 请求体的 step 使用 `client_id`(任意字符串)而不是真实 id,`depends_on` 也是其它 step 的 `client_id` 列表;后端两阶段写入解决依赖后再写回 真实 id。响应里则统一是 `depends_on: number[]`。 `step.config` 是一段 JSON 字符串,支持的字段: ```jsonc { "tags": ["python", "data"], // 注入到 task.tags "reward": 10, // 注入到 task.reward "max_retries": 3, // 默认 3 "input": "...", // 注入到 task.input "agent_id": 5 // 覆盖 step.agent_id } ``` `condition` 节点用另一套 schema: ```jsonc { "type": "output_contains", "value": "success" } // 或 { "type": "output_regex", "pattern": "^OK" } // 或 { "type": "output_equals", "value": "OK" } ``` condition 通过则下游 step 正常激活,失败则该分支所有 step 都被 `skipped`(不是 `failed`),run 仍能 finalize。 ### 媒体附件 | 方法 | 路径 | 说明 | |------|------|------| | POST | /api/tasks/:id/media | 上传附件(multipart,字段名 `file`,最大 50MB) | | GET | /api/tasks/:id/media | 列出任务的附件 | | GET | /api/media/:id | 下载附件 | | DELETE | /api/media/:id | 删除附件 | ## Agent 接入示例 支持 5 种 agent 类型:`claude` / `codex` / `opencode`(仅本地 CLI),`hermes` / `openclaw`(本地 CLI 或远程 HTTP)。所有 agent 默认以 `server` 模式启动(无需手动配置)。 ### 1. 本地 CLI 工具(最简单) 平台自动在 `PATH` 中查找可执行文件,通过命令行驱动任务执行。`{{#if name}}…{{/if}}` 条件块与 `{{var}}` 变量会自动渲染。 **注册 Claude Code Agent:** ```bash curl -X POST http://localhost:8080/api/agents \ -H "Content-Type: application/json" \ -d '{ "name": "我的Claude冒险者", "type": "claude", "capacity": 2, "cli_args": "--max-turns,5,--permission-mode,bypassPermissions", "timeout_sec": 300 }' ``` **支持的 CLI 类型与默认 binary 名:** | type | 默认 binary | 备注 | |------|------|------| | claude | `claude` | Claude Code CLI | | codex | `codex` | OpenAI Codex CLI | | opencode | `opencode` | opencode CLI | | hermes | `hermes` | Hermes CLI(也可 remote) | | openclaw | `openclaw` | OpenClaw CLI(也可 remote) | 可以用 `cli_binary` 字段覆盖默认 binary 路径。 ### 2. 远程 HTTP Agent `hermes` / `openclaw` 也支持调用远程 API,两种协议可选: - `custom` — 平台 POST 一个 JSON 信封到 `endpoint`,期望返回 `{"status":"ok","output":"..."}` 或 2xx 文本 - `openai_chat` — 平台自动补全 `/v1/chat/completions`,以 OpenAI Chat 协议调用 ```bash # OpenAI Chat 协议 curl -X POST http://localhost:8080/api/agents \ -H "Content-Type: application/json" \ -d '{ "name": "GPT-4 远程冒险者", "type": "hermes", "connection_mode": "remote", "remote_protocol": "openai_chat", "endpoint": "https://api.openai.com", "auth_header": "Bearer sk-...", "remote_model": "gpt-4o-mini", "system_prompt": "You are a concise coding assistant.", "timeout_sec": 120 }' # 自定义协议 curl -X POST http://localhost:8080/api/agents \ -H "Content-Type: application/json" \ -d '{ "name": "本地推理服务", "type": "openclaw", "connection_mode": "remote", "remote_protocol": "custom", "endpoint": "http://localhost:9000/run" }' ``` ### 3. 提示词模板 每个 agent 可选 `prompt_template`,留空则使用后端默认模板。支持的变量: | 变量 | 含义 | |------|------| | `{{task_id}}` | 任务 ID | | `{{title}}` | 任务标题 | | `{{description}}` | 任务描述 | | `{{input}}` | 任务输入(JSON 字符串) | | `{{output}}` | 上一步输出(工作流场景) | | `{{reward}}` | 任务奖励 | | `{{media}}` | 附件列表(自动渲染多行) | 条件块:`{{#if output}}…{{/if}}`、`{{#if media}}…{{/if}}`。变量替换是单遍的,不会二次展开。 ### 4. `agent-cli` 独立工具 适合 daemon 模式部署(远程机器): ```bash go build -o agent-cli ./cmd/agent-cli ./agent-cli detect --server http://localhost:8080 --agent 1 ./agent-cli run --server http://localhost:8080 --agent 1 ./agent-cli serve --server http://localhost:8080 --agent 1 --interval 3s ``` ### 5. 任务调度与附件 创建任务时可指定调度方式(一次性 / 间隔 / Cron)和上传附件。附件在 prompt 渲染时自动以 `[media:id]` 形式列出。 ```bash # 创建一个每 5 分钟执行一次(最多 10 次)的循环任务 curl -X POST http://localhost:8080/api/tasks \ -H "Content-Type: application/json" \ -d '{ "title": "定时巡检", "description": "每小时汇总一次服务日志", "schedule": "interval", "interval_minutes": 5, "max_runs": 10 }' # 上传附件(任务 id=1) curl -X POST http://localhost:8080/api/tasks/1/media \ -F "file=@./sample.png" ``` ### 6. 技能标签与指定冒险者 任务和冒险者共用一份 tag 词表(`tags` 表 + `task_tags` / `agent_tags` 关联表,旧 `tasks.tags` / `agents.skills` 文本列在启动时一次性迁移到 join table)。 - 任务声明 `tags` 后,**只有 skills 与之有交集的冒险者** 才能接取;交集大小作为「匹配度」。 - 直接指派:发布或编辑时给 `assignee_id` / `assignee`,任务会锁定给该冒险者;`assignee: null` 表示取消指派。 - 抢单时按 (匹配度高 → 奖励高 → 较早创建) 排序后返回;响应里附带 `match_score`。 详见 [`docs/tags-and-assignment.md`](docs/tags-and-assignment.md)。 ## 功能特性 - ✅ 任务发布与管理 - ✅ 5 种 agent 类型(claude / codex / opencode / hermes / openclaw) - ✅ 本地 CLI + 远程 HTTP 两种连接方式 - ✅ 自定义与 OpenAI Chat 两种远程协议 - ✅ 事件驱动任务调度(创建即派发,失败自动重试) - ✅ 任务可按共享 tag 词表筛选接取者(匹配度排序) - ✅ 任务可直接指派给特定冒险者 - ✅ 工作流可视化编排(支持循环、并行、条件分支) - ✅ 工作流断点恢复(服务重启后从未完成步骤继续) - ✅ 任务日志追踪 - ✅ Agent 心跳检测 - ✅ 任务自动重试(指数退避) - ✅ 任务调度(一次性 / 间隔 / Cron) - ✅ 媒体附件(图片 / 视频 / 音频) - ✅ 提示词模板(变量 + 条件块) - ✅ 国际化(中文 / English,侧边栏切换) ## 架构设计 ### 任务调度系统 采用**事件驱动**模式,任务创建时立即触发派发: ``` 任务创建 → 消息队列 → 冒险者池 → 执行 → 回调 ↓ 无空闲冒险者 ↓ 延迟重试队列(指数退避 2s→60s) ``` 详见 [`docs/task-dispatch.md`](docs/task-dispatch.md)。 ### 工作流引擎 支持复杂的工作流编排: - **循环节点**:按条件或次数循环执行子任务 - **并行节点**:同时执行多个分支 - **条件节点**:根据上游输出选择执行路径 - **断点恢复**:服务重启后从未完成步骤继续执行 详见 [`docs/workflows.md`](docs/workflows.md)。 ## 截图 (待添加) ## License MIT