Files
realizemultiagent/system-api/api-spec.json
2026-04-02 00:59:42 +08:00

588 lines
14 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "多Agent系统API规范",
"version": "1.0.0",
"description": "多Agent协作系统的标准化接口定义",
"created": "2026-03-31T14:41:00Z",
"lastUpdated": "2026-03-31T14:41:00Z",
"interfaces": {
"system": {
"description": "系统级接口",
"endpoints": {
"info": {
"path": "/api/system/info",
"method": "GET",
"description": "获取系统基本信息",
"response": {
"name": "string",
"version": "string",
"location": "string",
"status": "string"
}
},
"health": {
"path": "/api/system/health",
"method": "GET",
"description": "检查系统健康状态",
"response": {
"status": "string",
"components": "object",
"timestamp": "string"
}
},
"discover": {
"path": "/api/system/discover",
"method": "GET",
"description": "发现系统可用功能",
"response": {
"commands": "array",
"agents": "array",
"projects": "array"
}
}
}
},
"command": {
"description": "指令处理接口",
"endpoints": {
"parse": {
"path": "/api/command/parse",
"method": "POST",
"description": "解析用户输入为系统指令",
"request": {
"input": "string",
"context": "object"
},
"response": {
"type": "string",
"command": "string",
"args": "array",
"confidence": "number"
}
},
"execute": {
"path": "/api/command/execute",
"method": "POST",
"description": "执行系统指令",
"request": {
"command": "string",
"args": "array",
"options": "object"
},
"response": {
"success": "boolean",
"result": "object",
"taskId": "string",
"message": "string"
}
},
"list": {
"path": "/api/command/list",
"method": "GET",
"description": "列出所有可用指令",
"response": {
"basic": "array",
"advanced": "array",
"admin": "array"
}
}
}
},
"project": {
"description": "项目管理接口",
"endpoints": {
"create": {
"path": "/api/project/create",
"method": "POST",
"description": "创建新项目",
"request": {
"name": "string",
"type": "string",
"requirements": "string",
"timeline": "string"
},
"response": {
"id": "string",
"name": "string",
"status": "string",
"taskId": "string"
}
},
"list": {
"path": "/api/project/list",
"method": "GET",
"description": "列出所有项目",
"query": {
"status": "string",
"type": "string",
"limit": "number"
},
"response": {
"projects": "array",
"total": "number",
"page": "number"
}
},
"get": {
"path": "/api/project/{id}",
"method": "GET",
"description": "获取项目详情",
"response": {
"id": "string",
"name": "string",
"status": "string",
"tasks": "array",
"files": "array",
"timeline": "object"
}
},
"update": {
"path": "/api/project/{id}",
"method": "PUT",
"description": "更新项目信息",
"request": {
"status": "string",
"progress": "number",
"notes": "string"
},
"response": {
"success": "boolean",
"updated": "object"
}
}
}
},
"task": {
"description": "任务管理接口",
"endpoints": {
"create": {
"path": "/api/task/create",
"method": "POST",
"description": "创建新任务",
"request": {
"projectId": "string",
"title": "string",
"description": "string",
"assignee": "string",
"priority": "string"
},
"response": {
"id": "string",
"title": "string",
"status": "string",
"created": "string"
}
},
"assign": {
"path": "/api/task/{id}/assign",
"method": "POST",
"description": "分配任务给Agent",
"request": {
"agent": "string",
"deadline": "string"
},
"response": {
"success": "boolean",
"assignedTo": "string",
"deadline": "string"
}
},
"status": {
"path": "/api/task/{id}/status",
"method": "GET",
"description": "获取任务状态",
"response": {
"id": "string",
"status": "string",
"progress": "number",
"assignee": "string",
"updates": "array"
}
},
"complete": {
"path": "/api/task/{id}/complete",
"method": "POST",
"description": "标记任务完成",
"request": {
"result": "object",
"notes": "string"
},
"response": {
"success": "boolean",
"completedAt": "string",
"nextTask": "string"
}
}
}
},
"agent": {
"description": "Agent管理接口",
"endpoints": {
"list": {
"path": "/api/agent/list",
"method": "GET",
"description": "列出所有Agent",
"response": {
"agents": "array",
"active": "array",
"available": "array"
}
},
"start": {
"path": "/api/agent/{id}/start",
"method": "POST",
"description": "启动Agent",
"response": {
"success": "boolean",
"agentId": "string",
"status": "string"
}
},
"stop": {
"path": "/api/agent/{id}/stop",
"method": "POST",
"description": "停止Agent",
"response": {
"success": "boolean",
"stoppedAt": "string"
}
},
"status": {
"path": "/api/agent/{id}/status",
"method": "GET",
"description": "获取Agent状态",
"response": {
"id": "string",
"status": "string",
"currentTask": "string",
"performance": "object"
}
}
}
},
"file": {
"description": "文件管理接口",
"endpoints": {
"list": {
"path": "/api/file/list",
"method": "GET",
"description": "列出目录文件",
"query": {
"path": "string",
"type": "string"
},
"response": {
"path": "string",
"files": "array",
"directories": "array"
}
},
"read": {
"path": "/api/file/read",
"method": "GET",
"description": "读取文件内容",
"query": {
"path": "string",
"encoding": "string"
},
"response": {
"path": "string",
"content": "string",
"size": "number",
"modified": "string"
}
},
"write": {
"path": "/api/file/write",
"method": "POST",
"description": "写入文件内容",
"request": {
"path": "string",
"content": "string",
"append": "boolean"
},
"response": {
"success": "boolean",
"path": "string",
"size": "number"
}
},
"structure": {
"path": "/api/file/structure",
"method": "GET",
"description": "获取文件结构",
"response": {
"root": "string",
"structure": "object",
"totalFiles": "number"
}
}
}
},
"state": {
"description": "状态管理接口",
"endpoints": {
"get": {
"path": "/api/state",
"method": "GET",
"description": "获取系统状态",
"response": "object"
},
"update": {
"path": "/api/state",
"method": "PUT",
"description": "更新系统状态",
"request": "object",
"response": {
"success": "boolean",
"updated": "array",
"timestamp": "string"
}
},
"backup": {
"path": "/api/state/backup",
"method": "POST",
"description": "创建状态备份",
"response": {
"backupId": "string",
"timestamp": "string",
"size": "number"
}
},
"restore": {
"path": "/api/state/restore",
"method": "POST",
"description": "恢复状态备份",
"request": {
"backupId": "string"
},
"response": {
"success": "boolean",
"restoredFrom": "string"
}
}
}
}
},
"models": {
"command": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["standard", "natural", "admin"]
},
"command": {
"type": "string"
},
"args": {
"type": "array",
"items": {
"type": "string"
}
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": ["type", "command"]
},
"project": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string",
"enum": ["website", "application", "api", "tool", "other"]
},
"status": {
"type": "string",
"enum": ["planning", "active", "testing", "completed", "archived"]
},
"created": {
"type": "string",
"format": "date-time"
},
"timeline": {
"type": "object",
"properties": {
"start": {
"type": "string",
"format": "date-time"
},
"end": {
"type": "string",
"format": "date-time"
},
"duration": {
"type": "string"
}
}
}
},
"required": ["id", "name", "type", "status"]
},
"task": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"status": {
"type": "string",
"enum": ["todo", "in-progress", "testing", "done", "blocked"]
},
"priority": {
"type": "string",
"enum": ["P0", "P1", "P2", "P3"]
},
"assignee": {
"type": "string"
},
"created": {
"type": "string",
"format": "date-time"
},
"updated": {
"type": "string",
"format": "date-time"
}
},
"required": ["id", "title", "status", "priority"]
},
"agent": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"role": {
"type": "string",
"enum": ["pm", "fe", "be", "qa", "ui", "devops"]
},
"status": {
"type": "string",
"enum": ["stopped", "starting", "running", "busy", "error"]
},
"currentTask": {
"type": "string"
},
"performance": {
"type": "object",
"properties": {
"tasksCompleted": {
"type": "number"
},
"successRate": {
"type": "number"
},
"avgTime": {
"type": "number"
}
}
}
},
"required": ["id", "name", "role", "status"]
}
},
"errors": {
"400": {
"code": "BAD_REQUEST",
"message": "请求参数错误"
},
"401": {
"code": "UNAUTHORIZED",
"message": "未授权访问"
},
"404": {
"code": "NOT_FOUND",
"message": "资源不存在"
},
"409": {
"code": "CONFLICT",
"message": "资源冲突"
},
"500": {
"code": "INTERNAL_ERROR",
"message": "系统内部错误"
}
},
"security": {
"authentication": "none",
"authorization": "role-based",
"rateLimit": {
"requests": 100,
"period": "minute"
}
},
"examples": {
"createWebsite": {
"request": {
"endpoint": "/api/project/create",
"method": "POST",
"body": {
"name": "企业官网",
"type": "website",
"requirements": "响应式设计,深色主题,包含公司介绍、产品展示、联系表单",
"timeline": "2天"
}
},
"response": {
"id": "proj-20260331-001",
"name": "企业官网",
"status": "planning",
"taskId": "task-20260331-001"
}
},
"parseCommand": {
"request": {
"endpoint": "/api/command/parse",
"method": "POST",
"body": {
"input": "/网站 '测试页面' '今天'",
"context": {
"model": "deepseek-chat",
"session": "current"
}
}
},
"response": {
"type": "standard",
"command": "website",
"args": ["测试页面", "今天"],
"confidence": 0.95
}
}
}
}