{
"openapi": "3.0.1",
"info": {
"title": "AgentD Service API",
"description": "AgentD后端服务API接口文档,用于前端应用连接和管理AI代理",
"version": "1.0.0"
},
"tags": [
{
"name": "Health"
},
{
"name": "Agents"
},
{
"name": "Sessions"
},
{
"name": "Messages"
},
{
"name": "Models"
},
{
"name": "Events"
},
{
"name": "Conversations"
},
{
"name": "Skills"
},
{
"name": "SkillRepos"
},
{
"name": "McpServers"
}
],
"paths": {
"/healthz": {
"get": {
"summary": "健康检查",
"deprecated": false,
"description": "服务存活检查",
"tags": ["Health"],
"parameters": [],
"responses": {
"200": {
"description": "服务正常运行",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": ["ok"],
"description": "服务状态"
}
},
"required": ["status"]
},
"example": {
"status": "ok"
}
}
},
"headers": {}
}
},
"security": []
}
},
"/agent-templates": {
"get": {
"summary": "列出预置 Agent 模板",
"deprecated": false,
"description": "列出本地预置 Agent 模板(只读,零网络、零 DB,离线可用)。source_commit 为模板 skill 来源仓库的 commit,未预热或离线时为 null",
"tags": ["Agents"],
"parameters": [],
"responses": {
"200": {
"description": "成功获取预置模板列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AgentTemplate"
}
},
"example": [
{
"name": "oeAware-app-perf-optimizer",
"description": "应用层性能优化",
"version": "1.0.0",
"skill_count": 5,
"skills": ["app-profile", "flamegraph-analyze"],
"source_commit": "8f2c1a9"
}
]
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agent-templates/{name}/instantiate": {
"post": {
"summary": "一键实例化预置模板",
"deprecated": false,
"description": "按模板名称创建 Agent(安装模板定义的 skills 与 system prompt)。默认模型不可用时返回 400;同名 Agent 已存在时返回 409,错误体 error.details.agent_id 为已存在的 Agent ID",
"tags": ["Agents"],
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "模板名称(模板目录名,也是实例化后的 Agent 名称)"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InstantiateAgentTemplateRequest"
},
"example": {
"model_id": "your-model-id",
"sandbox_type": "local_process"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "成功实例化模板",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentResponse"
},
"example": {
"id": "agent-uuid",
"name": "oeAware-app-perf-optimizer",
"description": "应用层性能优化",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"status": "running",
"sandbox_id": null,
"workspace_path": "/path/to/workspace",
"idle_timeout_seconds": 300,
"has_scheduled_tasks": false,
"model_id": "your-model-id",
"mcp_server_list": [],
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00",
"default_session_id": "session-uuid",
"process_port": 8000
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "默认模型不可用或请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "模板不存在"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "同名 Agent 已存在(error.code = AGENT_ALREADY_INSTANTIATED)"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents": {
"get": {
"summary": "列出所有 Agent",
"deprecated": false,
"description": "列出所有 Agent",
"tags": ["Agents"],
"parameters": [],
"responses": {
"200": {
"description": "成功获取代理列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AgentResponse"
}
},
"example": [
{
"id": "agent-uuid-1",
"name": "my-agent",
"description": "这是一个测试智能体",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"status": "running",
"sandbox_id": null,
"workspace_path": "/path/to/workspace",
"idle_timeout_seconds": 3600,
"has_scheduled_tasks": false,
"model_id": null,
"mcp_server_list": [],
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00",
"default_session_id": "session-uuid",
"process_port": 8000
}
]
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"post": {
"summary": "创建 Agent",
"deprecated": false,
"description": "创建新 Agent,启动沙箱和 Adapter",
"tags": ["Agents"],
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateAgentRequest"
},
"example": {
"name": "my-agent",
"description": "这是一个测试智能体",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"idle_timeout_seconds": 3600,
"sandbox_id": null,
"has_scheduled_tasks": false,
"model_id": null,
"mcp_server_list": []
}
}
},
"required": true
},
"responses": {
"201": {
"description": "成功创建代理",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentResponse"
},
"example": {
"id": "agent-uuid",
"name": "my-agent",
"description": "这是一个测试智能体",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"status": "running",
"sandbox_id": null,
"workspace_path": "/path/to/workspace",
"idle_timeout_seconds": 3600,
"has_scheduled_tasks": false,
"model_id": null,
"mcp_server_list": [],
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00",
"default_session_id": "session-uuid",
"process_port": 8000
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/agenthub": {
"post": {
"summary": "从 AgentHub 创建 Agent",
"deprecated": false,
"description": "从远程 git 仓库拉取 agent 模板(UAS v1.0 规范的 agent.yaml),解析后自动创建 Agent 并安装模板中定义的 skills 和 system prompt",
"tags": ["Agents"],
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateAgentHubRequest"
},
"example": {
"git_url": "https://gitcode.com/duan_pengjie/agent_template.git",
"branch": "main",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"idle_timeout_seconds": 300,
"model_id": "your-model-id"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "成功从 AgentHub 创建代理",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentResponse"
},
"example": {
"id": "agent-uuid",
"name": "Template Agent",
"description": "From agent template",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"status": "running",
"sandbox_id": null,
"workspace_path": "/path/to/workspace",
"idle_timeout_seconds": 300,
"has_scheduled_tasks": false,
"model_id": "your-model-id",
"mcp_server_list": [],
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00",
"default_session_id": "session-uuid",
"process_port": 8000
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}": {
"get": {
"summary": "获取 Agent 详情",
"deprecated": false,
"description": "根据ID获取特定AI代理的详细信息",
"tags": ["Agents"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功获取代理信息",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentResponse"
},
"example": {
"id": "agent-uuid",
"name": "my-agent",
"description": "这是一个测试智能体",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"status": "running",
"sandbox_id": null,
"workspace_path": "/path/to/workspace",
"idle_timeout_seconds": 3600,
"has_scheduled_tasks": false,
"model_id": null,
"mcp_server_list": [],
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00",
"default_session_id": "session-uuid",
"process_port": 8000
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"delete": {
"summary": "删除 Agent",
"deprecated": false,
"description": "删除 Agent - 备份运行时 → 停止运行时 → 清理沙箱 → 删除本地记录",
"tags": ["Agents"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "成功删除代理",
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/pause": {
"post": {
"summary": "暂停 Agent",
"deprecated": false,
"description": "暂停 Agent,保留沙箱状态和所有资源",
"tags": ["Agents"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功暂停代理",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentResponse"
},
"example": {
"id": "agent-uuid",
"name": "my-agent",
"description": "这是一个测试智能体",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"status": "paused",
"sandbox_id": "container-id",
"workspace_path": "/path/to/workspace",
"idle_timeout_seconds": 3600,
"has_scheduled_tasks": false,
"model_id": null,
"mcp_server_list": [],
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:30:00",
"default_session_id": "session-uuid",
"process_port": 8000
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/resume": {
"post": {
"summary": "恢复 Agent",
"deprecated": false,
"description": "恢复已暂停的 Agent,根据状态分支处理",
"tags": ["Agents"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功恢复代理",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentResponse"
},
"example": {
"id": "agent-uuid",
"name": "my-agent",
"description": "这是一个测试智能体",
"sandbox_type": "local_process",
"adapter_type": "openclaw",
"status": "running",
"sandbox_id": "container-id",
"workspace_path": "/path/to/workspace",
"idle_timeout_seconds": 3600,
"has_scheduled_tasks": false,
"model_id": null,
"mcp_server_list": [],
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:35:00",
"default_session_id": "session-uuid",
"process_port": 8000
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/mcp-servers/{server_id}/enable": {
"post": {
"summary": "启用 MCP Server",
"deprecated": false,
"description": "为指定 Agent 启用 MCP Server,执行 _setup_mcp 将配置应用到 runtime",
"tags": ["Agents"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "server_id",
"in": "path",
"description": "MCP Server 配置唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功启用 MCP Server",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/McpServerResponse"
},
"example": {
"id": "server-uuid",
"mcp_server_name": "example-server",
"mcp_server_config": {
"example-server": {
"command": "npx",
"args": ["-y", "mcp-server-example"]
}
},
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-13T10:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/mcp-servers/{server_id}/disable": {
"post": {
"summary": "禁用 MCP Server",
"deprecated": false,
"description": "为指定 Agent 卸载 MCP Server,执行 openclaw mcp unset 从 runtime 移除配置",
"tags": ["Agents"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "server_id",
"in": "path",
"description": "MCP Server 配置唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功禁用 MCP Server",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/McpServerResponse"
},
"example": {
"id": "server-uuid",
"mcp_server_name": "example-server",
"mcp_server_config": {
"example-server": {
"command": "npx",
"args": ["-y", "mcp-server-example"]
}
},
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-13T10:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions": {
"get": {
"summary": "列出 Agent 的所有会话",
"deprecated": false,
"description": "列出 Agent 的所有会话(以 witty-agent-server 为主,刷新本地缓存)",
"tags": ["Sessions"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "runtime_agent_id",
"in": "query",
"description": "远端 witty-agent-server 中的 runtime agent ID",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功获取会话列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SessionResponse"
}
},
"example": [
{
"id": "session-uuid",
"agent_id": "agent-uuid",
"status": "idle",
"context_initialized": true,
"runtime_type": "openclaw",
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00"
}
]
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"post": {
"summary": "创建会话",
"deprecated": false,
"description": "创建新会话(透传到 witty-agent-server)",
"tags": ["Sessions"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "runtime_agent_id",
"in": "query",
"description": "远端 witty-agent-server 中的 runtime agent ID",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
},
"example": {}
}
}
},
"responses": {
"201": {
"description": "成功创建会话",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SessionResponse"
},
"example": {
"id": "session-uuid",
"agent_id": "agent-uuid",
"status": "idle",
"context_initialized": true,
"runtime_type": "openclaw",
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions/{session_id}": {
"get": {
"summary": "获取会话详情",
"deprecated": false,
"description": "获取会话详情(优先本地,透传 witty-agent-server)",
"tags": ["Sessions"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "runtime_agent_id",
"in": "query",
"description": "远端 witty-agent-server 中的 runtime agent ID",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功获取会话详情",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SessionResponse"
},
"example": {
"id": "session-uuid",
"agent_id": "agent-uuid",
"status": "idle",
"context_initialized": true,
"runtime_type": "openclaw",
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"delete": {
"summary": "删除会话",
"deprecated": false,
"description": "删除会话(透传到 witty-agent-server,删除本地记录)",
"tags": ["Sessions"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "runtime_agent_id",
"in": "query",
"description": "远端 witty-agent-server 中的 runtime agent ID",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "成功删除会话",
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions/{session_id}/abort": {
"post": {
"summary": "中止会话",
"deprecated": false,
"description": "中止正在运行的会话",
"tags": ["Sessions"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "成功中止会话",
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions/{session_id}/messages": {
"post": {
"summary": "发送消息(非流式)",
"deprecated": false,
"description": "witty-service 对外通过 REST 发送消息并返回非流式聚合结果;内部到 witty-agent-server 的消息通道仍是 WebSocket",
"tags": ["Messages"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SendMessageRequest"
},
"example": {
"content": "帮我查一下最近的错误日志"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功发送消息",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MessageEventsResponse"
},
"example": {
"sandbox_type": "local_process",
"events": [
{
"type": "message.delta",
"session_id": "session-id",
"event_id": "uuid",
"ts_ms": 1775650000123,
"runtime_type": "openclaw",
"payload": {
"delta": "当"
}
},
{
"type": "message.completed",
"session_id": "session-id",
"event_id": "uuid",
"ts_ms": 1775650000123,
"runtime_type": "openclaw",
"payload": {
"text": "当前工作环境..."
}
}
]
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions/{session_id}/messages/stream": {
"post": {
"summary": "发送消息(流式)",
"deprecated": false,
"description": "witty-service 对外通过 REST 提供 SSE 流式返回;内部到 witty-agent-server 的消息通道仍是 WebSocket",
"tags": ["Messages"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SendMessageRequest"
},
"example": {
"content": "帮我查一下最近的错误日志"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功建立流连接",
"content": {
"text/event-stream": {
"schema": {
"type": "string"
},
"example": "data: {\"sandbox_type\":\"local_process\",\"event\":{\"type\":\"message.delta\",\"session_id\":\"session-id\",\"event_id\":\"uuid\",\"ts_ms\":1775650000123,\"runtime_type\":\"openclaw\",\"payload\":{\"delta\":\"当\"}}}"
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions/{session_id}/messages/regenerate": {
"post": {
"summary": "重新生成最后一条助手回复(流式)",
"deprecated": false,
"description": "重跑会话中最后一条助手回复:不新增用户消息,先删除被替换的旧回复行,再以当初触发它的那条用户提问重跑。SSE 事件契约与 POST .../messages/stream 完全一致。没有请求体——作用对象由会话推导,因为流式生成的助手消息在客户端是本地 UUID,与服务端 id 对不上。",
"tags": ["Messages"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功建立流连接",
"content": {
"text/event-stream": {
"schema": {
"type": "string"
},
"example": "data: {\"sandbox_type\":\"local_process\",\"event\":{\"type\":\"message.delta\",\"session_id\":\"session-id\",\"event_id\":\"uuid\",\"ts_ms\":1775650000123,\"runtime_type\":\"openclaw\",\"payload\":{\"delta\":\"当\"}}}"
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "没有可重生成的助手回复(REGENERATE_TARGET_NOT_FOUND)"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "同会话已有生成在飞(SESSION_BUSY)"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions/{session_id}/messages/stream/reconnect": {
"post": {
"summary": "SSE 流重连",
"deprecated": false,
"description": "重新连接到已有消息流,通过 WebSocket 接收事件",
"tags": ["Messages"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功建立 WebSocket 连接",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {}
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/sessions/{session_id}/events": {
"get": {
"summary": "查询会话事件回放",
"deprecated": false,
"description": "查询会话事件回放(透传到 witty-agent-server)",
"tags": ["Events"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "runtime_agent_id",
"in": "query",
"description": "远端 witty-agent-server 中的 runtime agent ID",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "offset",
"in": "query",
"description": "分页偏移",
"required": false,
"schema": {
"type": "integer",
"default": 0
}
},
{
"name": "limit",
"in": "query",
"description": "每页数量",
"required": false,
"schema": {
"type": "integer",
"default": 50
}
}
],
"responses": {
"200": {
"description": "成功获取事件列表",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SessionEventPage"
},
"example": {
"items": [
{
"id": "event-id",
"session_id": "session-id",
"type": "message.delta",
"source": "assistant",
"payload": {},
"timestamp": "2026-03-31T12:34:56.000000Z"
}
],
"pagination": {
"offset": 0,
"limit": 50,
"total": 1
}
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/conversations": {
"get": {
"summary": "列出会话摘要",
"deprecated": false,
"description": "查询本地数据库,返回会话列表及最新消息摘要",
"tags": ["Conversations"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功获取会话摘要列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ConversationSummary"
}
},
"example": [
{
"session_id": "session-uuid",
"title": "会话标题",
"latest_message": "最近的消息内容",
"is_pinned": false,
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:30:00"
}
]
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/conversations/{session_id}": {
"get": {
"summary": "获取会话详情",
"deprecated": false,
"description": "查询本地数据库,支持消息分页(limit/before)",
"tags": ["Conversations"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "每页数量",
"required": false,
"schema": {
"type": "integer",
"default": 20
}
},
{
"name": "before",
"in": "query",
"description": "分页游标,获取此时间戳之前的消息",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
}
}
],
"responses": {
"200": {
"description": "成功获取会话详情",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ConversationDetail"
},
"example": {
"session_id": "session-uuid",
"title": "会话标题",
"is_pinned": false,
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T12:30:00",
"messages": [
{
"id": "message-uuid",
"role": "user",
"content": "用户消息内容",
"created_at": "2026-04-10T12:00:00"
},
{
"id": "message-uuid",
"role": "assistant",
"content": "助手回复内容",
"created_at": "2026-04-10T12:01:00"
}
]
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"patch": {
"summary": "更新会话元数据",
"deprecated": false,
"description": "修改标题、置顶状态,仅更新本地数据库",
"tags": ["Conversations"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "session_id",
"in": "path",
"description": "会话唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateConversationRequest"
},
"example": {
"title": "新的会话标题",
"is_pinned": true
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功更新会话元数据",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ConversationSummary"
},
"example": {
"session_id": "session-uuid",
"title": "新的会话标题",
"latest_message": "最近的消息内容",
"is_pinned": true,
"created_at": "2026-04-10T12:00:00",
"updated_at": "2026-04-10T13:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/skills": {
"post": {
"summary": "安装技能",
"deprecated": false,
"description": "为指定 agent 安装一个技能;支持本地已发现技能与 WittyHub 技能",
"tags": ["Skills"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InstallAgentSkillRequest"
},
"example": {
"skill_id": "skill-uuid",
"skill_name": "terminal-helper"
}
}
},
"required": true
},
"responses": {
"202": {
"description": "成功提交安装请求",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentSkillResponse"
},
"example": {
"agent_id": "agent-uuid",
"skill_id": "skill-uuid",
"source_type": "git",
"repo_id": "repo-uuid",
"skill_name": "terminal-helper",
"installed_at": "2026-06-03T10:00:00Z",
"relative_path": "skills/terminal-helper/SKILL.md",
"metadata": {
"title": "Terminal Helper"
},
"skill_source": "git",
"skill_md_url": "https://github.com/example/skills/blob/main/skills/terminal-helper/SKILL.md"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/skills/installed": {
"get": {
"summary": "查询已安装技能",
"deprecated": false,
"description": "读取本地数据库中该 agent 的已安装技能记录",
"tags": ["Skills"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功获取已安装技能列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AgentSkillResponse"
}
},
"example": [
{
"agent_id": "agent-uuid",
"skill_id": "skill-uuid",
"source_type": "git",
"repo_id": "repo-uuid",
"skill_name": "terminal-helper",
"installed_at": "2026-06-03T10:00:00Z",
"relative_path": "skills/terminal-helper/SKILL.md",
"metadata": {
"title": "Terminal Helper"
},
"skill_source": "git",
"skill_md_url": "https://github.com/example/skills/blob/main/skills/terminal-helper/SKILL.md"
}
]
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/skills/installed/sync": {
"post": {
"summary": "同步已安装技能",
"deprecated": false,
"description": "主动从 runtime 拉取已安装技能并同步到本地,再返回最新结果",
"tags": ["Skills"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功同步并获取已安装技能列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AgentSkillResponse"
}
},
"example": [
{
"agent_id": "agent-uuid",
"skill_id": "skill-uuid",
"source_type": "git",
"repo_id": "repo-uuid",
"skill_name": "terminal-helper",
"installed_at": "2026-06-03T10:00:00Z",
"relative_path": "skills/terminal-helper/SKILL.md",
"metadata": {
"title": "Terminal Helper"
},
"skill_source": "git",
"skill_md_url": "https://github.com/example/skills/blob/main/skills/terminal-helper/SKILL.md"
}
]
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/agents/{agent_id}/skills/uninstall": {
"post": {
"summary": "卸载技能",
"deprecated": false,
"description": "卸载 agent 上的某个已安装技能",
"tags": ["Skills"],
"parameters": [
{
"name": "agent_id",
"in": "path",
"description": "Agent 唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UninstallAgentSkillRequest"
},
"example": {
"skill_id": "skill-uuid"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功卸载技能",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AgentSkillResponse"
},
"example": {
"agent_id": "agent-uuid",
"skill_id": "skill-uuid",
"source_type": "git",
"repo_id": "repo-uuid",
"skill_name": "terminal-helper",
"installed_at": "2026-06-03T10:00:00Z",
"relative_path": "skills/terminal-helper/SKILL.md",
"metadata": {
"title": "Terminal Helper"
},
"skill_source": "git",
"skill_md_url": "https://github.com/example/skills/blob/main/skills/terminal-helper/SKILL.md"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/skills/repos": {
"get": {
"summary": "查询技能仓库列表",
"deprecated": false,
"description": "列出所有已注册技能仓库",
"tags": ["SkillRepos"],
"parameters": [],
"responses": {
"200": {
"description": "成功获取技能仓库列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SkillRepositoryResponse"
}
},
"example": [
{
"repo_id": "repo-uuid",
"repo_name": "https://github.com/example/skills@main",
"source_type": "git",
"branch": "main",
"url": "https://github.com/example/skills",
"local_path": "/home/user/witty-service/skill-repositories/skills-repo-uuid",
"skill_discover_status": "done",
"skill_num": 12
}
]
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"post": {
"summary": "注册技能仓库",
"deprecated": false,
"description": "注册一个 Git 技能仓库,并异步开始扫描",
"tags": ["SkillRepos"],
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SkillRepositoryRequest"
},
"example": {
"source_type": "git",
"url": "https://github.com/example/skills.git",
"branch": "main"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "成功创建技能仓库",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SkillRepositoryResponse"
},
"example": {
"repo_id": "repo-uuid",
"repo_name": "https://github.com/example/skills@main",
"source_type": "git",
"branch": "main",
"url": "https://github.com/example/skills",
"local_path": "/home/user/witty-service/skill-repositories/skills-repo-uuid",
"skill_discover_status": "init",
"skill_num": 0
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/skills/repos/upload": {
"post": {
"summary": "上传技能仓库",
"deprecated": false,
"description": "上传 ZIP 归档注册本地技能仓库,并异步开始扫描",
"tags": ["SkillRepos"],
"parameters": [],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "ZIP 文件"
}
},
"required": ["file"]
}
}
},
"required": true
},
"responses": {
"201": {
"description": "成功上传技能仓库",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SkillRepositoryResponse"
},
"example": {
"repo_id": "repo-uuid",
"repo_name": "uploaded-skill-repo",
"source_type": "local",
"branch": null,
"url": null,
"local_path": "/home/user/witty-service/skill-repositories/uploaded/repo-uuid.zip",
"skill_discover_status": "init",
"skill_num": 0
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/skills/repos/{repo_id}": {
"get": {
"summary": "查询技能仓库详情",
"deprecated": false,
"description": "获取单个技能仓库详情",
"tags": ["SkillRepos"],
"parameters": [
{
"name": "repo_id",
"in": "path",
"description": "技能仓库唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功获取技能仓库详情",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SkillRepositoryResponse"
},
"example": {
"repo_id": "repo-uuid",
"repo_name": "https://github.com/example/skills@main",
"source_type": "git",
"branch": "main",
"url": "https://github.com/example/skills",
"local_path": "/home/user/witty-service/skill-repositories/skills-repo-uuid",
"skill_discover_status": "done",
"skill_num": 12
}
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"patch": {
"summary": "更新技能仓库",
"deprecated": false,
"description": "更新技能仓库配置",
"tags": ["SkillRepos"],
"parameters": [
{
"name": "repo_id",
"in": "path",
"description": "技能仓库唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SkillRepositoryRequest"
},
"example": {
"source_type": "git",
"url": "https://github.com/example/skills.git",
"branch": "develop"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功更新技能仓库",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SkillRepositoryResponse"
},
"example": {
"repo_id": "repo-uuid",
"repo_name": "https://github.com/example/skills@develop",
"source_type": "git",
"branch": "develop",
"url": "https://github.com/example/skills",
"local_path": "/home/user/witty-service/skill-repositories/skills-repo-uuid",
"skill_discover_status": "done",
"skill_num": 12
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"delete": {
"summary": "删除技能仓库",
"deprecated": false,
"description": "删除技能仓库记录,并尽量清理本地归档或 clone 目录",
"tags": ["SkillRepos"],
"parameters": [
{
"name": "repo_id",
"in": "path",
"description": "技能仓库唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "成功删除技能仓库",
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/skills/discover": {
"post": {
"summary": "扫描全部技能仓库",
"deprecated": false,
"description": "同步扫描全部技能仓库,刷新 skills 索引",
"tags": ["SkillRepos"],
"parameters": [],
"responses": {
"200": {
"description": "成功扫描技能仓库",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SkillRepositoryResponse"
}
},
"example": [
{
"repo_id": "repo-uuid",
"repo_name": "https://github.com/example/skills@main",
"source_type": "git",
"branch": "main",
"url": "https://github.com/example/skills",
"local_path": "/home/user/witty-service/skill-repositories/skills-repo-uuid",
"skill_discover_status": "done",
"skill_num": 12
}
]
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/skills/discover/{repo_id}": {
"post": {
"summary": "扫描指定技能仓库",
"deprecated": false,
"description": "同步扫描指定仓库",
"tags": ["SkillRepos"],
"parameters": [
{
"name": "repo_id",
"in": "path",
"description": "技能仓库唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功扫描技能仓库",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SkillRepositoryResponse"
},
"example": {
"repo_id": "repo-uuid",
"repo_name": "https://github.com/example/skills@main",
"source_type": "git",
"branch": "main",
"url": "https://github.com/example/skills",
"local_path": "/home/user/witty-service/skill-repositories/skills-repo-uuid",
"skill_discover_status": "done",
"skill_num": 12
}
}
},
"headers": {}
},
"202": {
"description": "仓库正在扫描中",
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/skills/skills": {
"get": {
"summary": "查询技能清单",
"deprecated": false,
"description": "列出当前已发现的技能清单",
"tags": ["SkillRepos"],
"parameters": [],
"responses": {
"200": {
"description": "成功获取技能清单",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SkillResponse"
}
},
"example": [
{
"skill_id": "skill-uuid",
"repo_id": "repo-uuid",
"skill_name": "terminal-helper",
"relative_path": "skills/terminal-helper/SKILL.md",
"metadata": {
"title": "Terminal Helper"
},
"skill_source": "git",
"skill_md_url": "https://github.com/example/skills/blob/main/skills/terminal-helper/SKILL.md"
}
]
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/mcp-servers": {
"get": {
"summary": "获取 MCP Server 列表",
"deprecated": false,
"description": "获取所有 MCP Server 配置列表",
"tags": ["McpServers"],
"parameters": [],
"responses": {
"200": {
"description": "成功获取 MCP Server 列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/McpServerResponse"
}
},
"example": [
{
"id": "server-uuid-1",
"mcp_server_name": "example-server",
"mcp_server_config": {
"example-server": {
"command": "npx",
"args": ["-y", "mcp-server-example"]
}
},
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-13T10:00:00"
}
]
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"post": {
"summary": "添加 MCP Server 配置",
"deprecated": false,
"description": "添加新的 MCP Server 配置",
"tags": ["McpServers"],
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateMcpServerRequest"
},
"example": {
"mcp_server_config": {
"example-server": {
"command": "npx",
"args": ["-y", "mcp-server-example"]
}
}
}
}
},
"required": true
},
"responses": {
"201": {
"description": "成功创建 MCP Server 配置",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/McpServerResponse"
},
"example": {
"id": "server-uuid",
"mcp_server_name": "example-server",
"mcp_server_config": {
"example-server": {
"command": "npx",
"args": ["-y", "mcp-server-example"]
}
},
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-13T10:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/mcp-servers/{server_id}": {
"put": {
"summary": "更新 MCP Server 配置",
"deprecated": false,
"description": "更新指定的 MCP Server 配置",
"tags": ["McpServers"],
"parameters": [
{
"name": "server_id",
"in": "path",
"description": "MCP Server 配置唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateMcpServerRequest"
},
"example": {
"mcp_server_name": "updated-server",
"mcp_server_config": {
"updated-server": {
"command": "npx",
"args": ["-y", "mcp-server-example"]
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功更新 MCP Server 配置",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/McpServerResponse"
},
"example": {
"id": "server-uuid",
"mcp_server_name": "updated-server",
"mcp_server_config": {
"updated-server": {
"command": "npx",
"args": ["-y", "mcp-server-example"]
}
},
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-14T12:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"delete": {
"summary": "删除 MCP Server 配置",
"deprecated": false,
"description": "删除指定的 MCP Server 配置",
"tags": ["McpServers"],
"parameters": [
{
"name": "server_id",
"in": "path",
"description": "MCP Server 配置唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "成功删除 MCP Server 配置",
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/models": {
"get": {
"summary": "获取大模型列表",
"deprecated": false,
"description": "获取所有大模型配置列表",
"tags": ["Models"],
"parameters": [],
"responses": {
"200": {
"description": "成功获取模型列表",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ModelResponse"
}
},
"example": [
{
"id": "model-uuid-1",
"name": "gpt-4o",
"provider": "openai",
"api_base_url": "https://api.openai.com/v1",
"description": "OpenAI GPT-4 Omni 模型",
"enabled": true,
"max_tokens": 4096,
"temperature": 0.7,
"is_default": true,
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-13T10:00:00"
}
]
}
},
"headers": {}
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"post": {
"summary": "添加大模型配置",
"deprecated": false,
"description": "添加新的大模型配置",
"tags": ["Models"],
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateModelRequest"
},
"example": {
"name": "gpt-4o",
"provider": "openai",
"api_key": "sk-xxxxxxxxxx",
"api_base_url": "https://api.openai.com/v1",
"description": "OpenAI GPT-4 Omni 模型",
"enabled": true,
"max_tokens": 4096,
"temperature": 0.7,
"is_default": true
}
}
},
"required": true
},
"responses": {
"201": {
"description": "成功创建模型配置",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModelResponse"
},
"example": {
"id": "model-uuid",
"name": "gpt-4o",
"provider": "openai",
"api_base_url": "https://api.openai.com/v1",
"description": "OpenAI GPT-4 Omni 模型",
"enabled": true,
"max_tokens": 4096,
"temperature": 0.7,
"is_default": true,
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-13T10:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"409": {
"$ref": "#/components/responses/Conflict",
"description": "资源状态冲突"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
},
"/models/{model_id}": {
"put": {
"summary": "更新大模型配置",
"deprecated": false,
"description": "更新指定的大模型配置",
"tags": ["Models"],
"parameters": [
{
"name": "model_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateModelRequest"
},
"example": {
"name": "gpt-4o-updated",
"api_base_url": "https://api.openai.com/v1",
"description": "Updated OpenAI GPT-4 Omni 模型",
"enabled": true,
"max_tokens": 8192,
"temperature": 0.8,
"is_default": true
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功更新模型配置",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModelResponse"
},
"example": {
"id": "model-uuid",
"name": "gpt-4o-updated",
"provider": "openai",
"api_base_url": "https://api.openai.com/v1",
"description": "Updated OpenAI GPT-4 Omni 模型",
"enabled": true,
"max_tokens": 8192,
"temperature": 0.8,
"is_default": true,
"created_at": "2026-04-13T10:00:00",
"updated_at": "2026-04-14T12:00:00"
}
}
},
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
},
"delete": {
"summary": "删除大模型配置",
"deprecated": false,
"description": "删除指定的大模型配置",
"tags": ["Models"],
"parameters": [
{
"name": "model_id",
"in": "path",
"description": "模型配置唯一标识",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "成功删除模型配置",
"headers": {}
},
"400": {
"$ref": "#/components/responses/BadRequest",
"description": "请求参数错误"
},
"401": {
"$ref": "#/components/responses/Unauthorized",
"description": "未授权"
},
"404": {
"$ref": "#/components/responses/NotFound",
"description": "资源不存在"
},
"500": {
"$ref": "#/components/responses/InternalServerError",
"description": "服务器内部错误"
}
},
"security": []
}
}
},
"components": {
"schemas": {
"AgentResponse": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Agent 唯一标识"
},
"name": {
"type": "string",
"description": "Agent 名称"
},
"description": {
"type": "string",
"description": "Agent 描述",
"nullable": true
},
"sandbox_type": {
"type": "string",
"enum": ["docker", "local_process", "e2b"],
"description": "沙箱类型"
},
"adapter_type": {
"type": "string",
"description": "适配器类型:如 openclaw"
},
"status": {
"type": "string",
"enum": ["running", "paused", "stopped", "error"],
"description": "Agent 状态"
},
"sandbox_id": {
"type": "string",
"description": "沙箱 ID",
"nullable": true
},
"workspace_path": {
"type": "string",
"description": "工作区路径"
},
"idle_timeout_seconds": {
"type": "integer",
"description": "空闲超时时间(秒)"
},
"has_scheduled_tasks": {
"type": "boolean",
"description": "是否有定时任务"
},
"model_id": {
"type": "string",
"description": "模型 ID",
"nullable": true
},
"mcp_server_list": {
"type": "array",
"items": {
"type": "string"
},
"description": "MCP Server ID 列表"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "更新时间"
},
"default_session_id": {
"type": "string",
"description": "默认会话 ID",
"nullable": true
},
"process_port": {
"type": "integer",
"description": "本地进程沙箱的端口号(仅 sandbox_type=local_process 时有值)",
"nullable": true
}
},
"required": [
"id",
"name",
"sandbox_type",
"adapter_type",
"status",
"workspace_path",
"idle_timeout_seconds",
"has_scheduled_tasks",
"created_at",
"updated_at"
]
},
"CreateAgentRequest": {
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1,
"description": "Agent 名称,最小长度 1"
},
"description": {
"type": "string",
"description": "Agent 描述,默认空字符串",
"nullable": true
},
"sandbox_type": {
"type": "string",
"enum": ["docker", "local_process", "e2b"],
"description": "沙箱类型:docker、local_process、e2b"
},
"adapter_type": {
"type": "string",
"description": "适配器类型:如 openclaw"
},
"idle_timeout_seconds": {
"type": "integer",
"minimum": 1,
"description": "空闲超时时间(秒),必须大于 0"
},
"sandbox_id": {
"type": "string",
"description": "沙箱 ID",
"nullable": true
},
"has_scheduled_tasks": {
"type": "boolean",
"default": false,
"description": "是否有定时任务,默认 false"
},
"model_id": {
"type": "string",
"description": "模型 ID,关联 /models 中配置的模型",
"nullable": true
},
"mcp_server_list": {
"type": "array",
"items": {
"type": "string"
},
"description": "MCP Server ID 列表,关联 /mcp-servers 中配置的 MCP Server",
"nullable": true
}
},
"required": ["name", "sandbox_type", "adapter_type", "idle_timeout_seconds"]
},
"CreateAgentHubRequest": {
"type": "object",
"properties": {
"git_url": {
"type": "string",
"description": "远程 git 仓库地址"
},
"branch": {
"type": "string",
"description": "git 分支,默认 main",
"nullable": true
},
"sandbox_type": {
"type": "string",
"enum": ["docker", "local_process", "e2b"],
"description": "沙箱类型:docker、local_process、e2b"
},
"adapter_type": {
"type": "string",
"description": "适配器类型:如 openclaw"
},
"idle_timeout_seconds": {
"type": "integer",
"minimum": 1,
"description": "空闲超时时间(秒),必须大于 0"
},
"sandbox_id": {
"type": "string",
"description": "沙箱 ID",
"nullable": true
},
"has_scheduled_tasks": {
"type": "boolean",
"default": false,
"description": "是否有定时任务,默认 false"
},
"model_id": {
"type": "string",
"description": "模型 ID,关联 /models 中配置的模型",
"nullable": true
}
},
"required": ["git_url", "sandbox_type", "adapter_type", "idle_timeout_seconds"]
},
"AgentTemplate": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "模板名称(唯一,也是实例化后的 Agent 名称)"
},
"description": {
"type": "string",
"description": "模板描述"
},
"version": {
"type": "string",
"description": "模板版本,缺省 1.0.0"
},
"skill_count": {
"type": "integer",
"description": "顶层 skill 数量(嵌套载荷不计)"
},
"skills": {
"type": "array",
"items": {
"type": "string"
},
"description": "顶层 skill 名称列表"
},
"source_commit": {
"type": "string",
"nullable": true,
"description": "模板 skill 来源仓库的 commit hash;离线或未预热时为 null"
},
"default_prompt": {
"type": "string",
"nullable": true,
"description": "模板声明的默认使用提问(来自模板的 prompt.default);未声明时可能为 null 或缺失,前端两种都按「未声明」处理。点击模版后据此填入输入框,不做自动发送"
}
},
"required": ["name", "description", "version", "skill_count", "skills", "source_commit"]
},
"InstantiateAgentTemplateRequest": {
"type": "object",
"properties": {
"model_id": {
"type": "string",
"description": "模型 ID,必须是已启用且为默认的模型"
},
"sandbox_type": {
"type": "string",
"enum": ["docker", "local_process", "e2b"],
"description": "沙箱类型,前端固定传 local_process"
}
},
"required": ["model_id", "sandbox_type"]
},
"SessionResponse": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "会话唯一标识"
},
"agent_id": {
"type": "string",
"description": "所属 Agent ID"
},
"status": {
"type": "string",
"enum": ["running", "idle", "error"],
"description": "会话运行态"
},
"context_initialized": {
"type": "boolean",
"description": "witty-agent-server 是否已完成上下文初始化"
},
"runtime_type": {
"type": "string",
"description": "运行时类型:如 openclaw"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "更新时间"
}
},
"required": [
"id",
"agent_id",
"status",
"context_initialized",
"runtime_type",
"created_at",
"updated_at"
]
},
"SendMessageRequest": {
"type": "object",
"properties": {
"content": {
"type": "string",
"minLength": 1,
"description": "消息内容,最小长度 1"
}
},
"required": ["content"]
},
"MessageEvent": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "事件类型",
"enum": [
"message.delta",
"message.completed",
"tool.call.started",
"tool.call.response",
"session.usage",
"session.runtime.changed",
"stream.error",
"client.error"
]
},
"session_id": {
"type": "string",
"description": "会话 ID"
},
"event_id": {
"type": "string",
"description": "事件 ID"
},
"ts_ms": {
"type": "integer",
"description": "时间戳(毫秒)"
},
"runtime_type": {
"type": "string",
"description": "运行时类型"
},
"payload": {
"type": "object",
"description": "事件负载,结构取决于事件类型",
"properties": {}
}
},
"required": ["type", "session_id", "event_id", "ts_ms", "runtime_type", "payload"]
},
"MessageEventsResponse": {
"type": "object",
"properties": {
"sandbox_type": {
"type": "string",
"description": "Agent 的沙箱类型,取值来自 agent 配置的 sandbox backend,例如 docker、local_process、e2b"
},
"events": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MessageEvent"
},
"description": "事件数组,每个事件包含 type、session_id、event_id、ts_ms、runtime_type、payload"
}
},
"required": ["sandbox_type", "events"]
},
"SessionEvent": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "事件 ID"
},
"session_id": {
"type": "string",
"description": "会话 ID"
},
"type": "string",
"description": "事件类型"
},
"source": {
"type": "string",
"description": "事件来源"
},
"payload": {
"type": "object",
"description": "事件负载",
"properties": {}
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "时间戳"
}
},
"required": ["id", "session_id", "type", "source", "payload", "timestamp"]
},
"SessionEventPage": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SessionEvent"
},
"description": "事件列表"
},
"pagination": {
"type": "object",
"properties": {
"offset": {
"type": "integer",
"description": "分页偏移"
},
"limit": {
"type": "integer",
"description": "每页数量"
},
"total": {
"type": "integer",
"description": "总数量"
}
},
"required": ["offset", "limit", "total"],
"description": "分页信息"
}
},
"required": ["items", "pagination"]
},
"ModelResponse": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "模型配置唯一标识"
},
"name": {
"type": "string",
"description": "模型名称"
},
"provider": {
"type": "string",
"enum": [
"openai",
"anthropic",
"google",
"ollama",
"azure",
"deepseek",
"glm",
"minimax",
"kimi",
"custom"
],
"description": "模型提供商"
},
"api_base_url": {
"type": "string",
"description": "API 基础地址"
},
"description": {
"type": "string",
"description": "模型描述",
"nullable": true
},
"enabled": {
"type": "boolean",
"description": "是否启用"
},
"max_tokens": {
"type": "integer",
"description": "最大输出 tokens 数"
},
"temperature": {
"type": "number",
"description": "生成温度"
},
"is_default": {
"type": "boolean",
"description": "是否为默认模型"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "更新时间"
}
},
"required": [
"id",
"name",
"provider",
"api_base_url",
"enabled",
"max_tokens",
"temperature",
"is_default",
"created_at",
"updated_at"
]
},
"CreateModelRequest": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "模型名称,如 gpt-4o、claude-3-opus-20240229"
},
"provider": {
"type": "string",
"enum": [
"openai",
"anthropic",
"google",
"ollama",
"azure",
"deepseek",
"glm",
"minimax",
"kimi",
"custom"
],
"description": "模型提供商"
},
"api_key": {
"type": "string",
"description": "API 密钥"
},
"api_base_url": {
"type": "string",
"description": "API 基础地址,默认根据 provider 自动设置",
"nullable": true
},
"description": {
"type": "string",
"description": "模型描述,默认空字符串",
"nullable": true
},
"enabled": {
"type": "boolean",
"default": true,
"description": "是否启用,默认 true"
},
"max_tokens": {
"type": "integer",
"default": 4096,
"description": "最大输出 tokens 数,默认 4096"
},
"temperature": {
"type": "number",
"default": 0.7,
"description": "生成温度,范围 0-2,默认 0.7"
},
"is_default": {
"type": "boolean",
"default": false,
"description": "是否设为默认模型,默认 false"
}
},
"required": ["name", "provider", "api_key"]
},
"UpdateModelRequest": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "模型名称"
},
"provider": {
"type": "string",
"enum": [
"openai",
"anthropic",
"google",
"ollama",
"azure",
"deepseek",
"glm",
"minimax",
"kimi",
"custom"
],
"description": "模型提供商"
},
"api_key": {
"type": "string",
"description": "API 密钥"
},
"api_base_url": {
"type": "string",
"description": "API 基础地址"
},
"description": {
"type": "string",
"description": "模型描述"
},
"enabled": {
"type": "boolean",
"description": "是否启用"
},
"max_tokens": {
"type": "integer",
"description": "最大输出 tokens 数"
},
"temperature": {
"type": "number",
"description": "生成温度,范围 0-2"
},
"is_default": {
"type": "boolean",
"description": "是否设为默认模型"
}
}
},
"ConversationSummary": {
"type": "object",
"properties": {
"session_id": {
"type": "string",
"description": "会话唯一标识"
},
"title": {
"type": "string",
"description": "会话标题"
},
"latest_message": {
"type": "string",
"description": "最新消息摘要"
},
"is_pinned": {
"type": "boolean",
"description": "是否置顶"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "更新时间"
}
},
"required": ["session_id", "title", "latest_message", "is_pinned", "created_at", "updated_at"]
},
"MessageItem": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "消息唯一标识"
},
"role": {
"type": "string",
"enum": ["user", "assistant"],
"description": "消息角色"
},
"content": {
"type": "string",
"description": "消息内容"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
}
},
"required": ["id", "role", "content", "created_at"]
},
"ConversationDetail": {
"type": "object",
"properties": {
"session_id": {
"type": "string",
"description": "会话唯一标识"
},
"title": {
"type": "string",
"description": "会话标题"
},
"is_pinned": {
"type": "boolean",
"description": "是否置顶"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "更新时间"
},
"messages": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MessageItem"
},
"description": "消息列表"
}
},
"required": ["session_id", "title", "is_pinned", "created_at", "updated_at", "messages"]
},
"UpdateConversationRequest": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "会话标题"
},
"is_pinned": {
"type": "boolean",
"description": "是否置顶"
}
}
},
"SkillInfo": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "技能唯一标识"
},
"name": {
"type": "string",
"description": "技能名称"
},
"description": {
"type": "string",
"description": "技能描述",
"nullable": true
},
"enabled": {
"type": "boolean",
"description": "是否启用"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
}
},
"required": ["id", "name", "enabled", "created_at"]
},
"InstallAgentSkillRequest": {
"type": "object",
"properties": {
"skill_id": {
"type": "string",
"description": "技能唯一标识;安装时skill_id 用于记录元数据"
},
"skill_name": {
"type": "string",
"description": "技能名;主要用于安装和日志定位"
},
"source_type": {
"type": "string",
"description": "安装来源类型;如安装 WittyHub 技能时传 wittyhub",
"nullable": true
},
"source_url": {
"type": "string",
"description": "技能来源地址;source_type 为 wittyhub 时必填",
"nullable": true
}
},
"required": ["skill_id", "skill_name"]
},
"UninstallAgentSkillRequest": {
"type": "object",
"properties": {
"skill_id": {
"type": "string",
"description": "已安装技能 ID"
}
},
"required": ["skill_id"]
},
"AgentSkillResponse": {
"type": "object",
"properties": {
"agent_id": {
"type": "string",
"description": "所属 agent"
},
"skill_id": {
"type": "string",
"description": "技能 ID"
},
"source_type": {
"type": "string",
"description": "安装来源类型,如 builtin、git、local、clawhub、wittyhub"
},
"repo_id": {
"type": "string",
"description": "来源仓库 ID",
"nullable": true
},
"skill_name": {
"type": "string",
"description": "技能名"
},
"installed_at": {
"type": "string",
"format": "date-time",
"description": "安装时间,统一序列化为 UTC ISO8601"
},
"relative_path": {
"type": "string",
"description": "技能文档相对路径",
"nullable": true
},
"metadata": {
"type": "object",
"description": "技能元数据",
"nullable": true,
"properties": {}
},
"skill_source": {
"type": "string",
"description": "技能来源标识或地址,如 git、local、builtin、clawhub、wittyhub",
"nullable": true
},
"skill_md_url": {
"type": "string",
"description": "技能说明地址",
"nullable": true
}
},
"required": ["agent_id", "skill_id", "source_type", "skill_name", "installed_at"]
},
"SkillRepositoryRequest": {
"type": "object",
"properties": {
"source_type": {
"type": "string",
"enum": ["git", "local"],
"description": "来源类型:git 或 local"
},
"url": {
"type": "string",
"description": "Git clone 地址,支持 HTTPS / SSH,服务端会做归一化",
"nullable": true
},
"branch": {
"type": "string",
"description": "指定分支;为空时 discover 后会自动回填实际分支",
"nullable": true
},
"local_path": {
"type": "string",
"description": "本地路径(通常由上传接口生成)",
"nullable": true
}
},
"required": ["source_type"]
},
"SkillRepositoryResponse": {
"type": "object",
"properties": {
"repo_id": {
"type": "string",
"description": "仓库唯一标识"
},
"repo_name": {
"type": "string",
"description": "仓库名称"
},
"source_type": {
"type": "string",
"enum": ["git", "local", "builtin", "clawhub"],
"description": "来源类型"
},
"branch": {
"type": "string",
"description": "分支名称",
"nullable": true
},
"url": {
"type": "string",
"description": "Git URL",
"nullable": true
},
"local_path": {
"type": "string",
"description": "本地路径",
"nullable": true
},
"skill_discover_status": {
"type": "string",
"enum": ["init", "discovering", "done", "failed"],
"description": "技能发现状态"
},
"skill_num": {
"type": "integer",
"description": "技能数量"
}
},
"required": ["repo_id", "repo_name", "source_type", "skill_discover_status", "skill_num"]
},
"SkillResponse": {
"type": "object",
"properties": {
"skill_id": {
"type": "string",
"description": "技能唯一标识"
},
"repo_id": {
"type": "string",
"description": "所属仓库 ID;第三方聚合来源可能为空",
"nullable": true
},
"skill_name": {
"type": "string",
"description": "技能名"
},
"relative_path": {
"type": "string",
"description": "SKILL.md 相对路径或绝对路径",
"nullable": true
},
"metadata": {
"type": "object",
"description": "技能元数据",
"properties": {}
},
"skill_source": {
"type": "string",
"description": "技能来源标识或地址,如 git、local、builtin、clawhub、wittyhub",
"nullable": true
},
"skill_md_url": {
"type": "string",
"description": "技能说明文档地址",
"nullable": true
}
},
"required": ["skill_id", "skill_name"]
},
"McpServerResponse": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "MCP Server 配置唯一标识"
},
"mcp_server_name": {
"type": "string",
"description": "MCP Server 名称"
},
"mcp_server_config": {
"type": "object",
"description": "MCP 配置(JSON 格式)",
"properties": {}
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "创建时间"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "更新时间"
}
},
"required": ["id", "mcp_server_name", "mcp_server_config", "created_at", "updated_at"]
},
"CreateMcpServerRequest": {
"type": "object",
"properties": {
"mcp_server_config": {
"type": "object",
"description": "MCP 配置(JSON 格式),系统自动从配置的 key 中提取 mcp_server_name",
"properties": {}
}
},
"required": ["mcp_server_config"]
},
"UpdateMcpServerRequest": {
"type": "object",
"properties": {
"mcp_server_name": {
"type": "string",
"description": "MCP Server 名称"
},
"mcp_server_config": {
"type": "object",
"description": "MCP 配置(JSON 格式)",
"properties": {}
}
}
},
"ErrorResponse": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string",
"description": "错误码"
},
"message": {
"type": "string",
"description": "错误消息"
},
"details": {
"type": "object",
"description": "错误详情",
"properties": {},
"nullable": true
}
},
"required": ["code", "message"]
}
},
"required": ["error"]
}
},
"responses": {
"Unauthorized": {
"description": "未授权",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"error": {
"code": "UNAUTHORIZED",
"message": "未授权访问"
}
}
}
}
},
"BadRequest": {
"description": "请求参数错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"error": {
"code": "BAD_REQUEST",
"message": "请求参数错误"
}
}
}
}
},
"NotFound": {
"description": "资源不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"error": {
"code": "NOT_FOUND",
"message": "资源不存在"
}
}
}
}
},
"Conflict": {
"description": "资源状态冲突",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"error": {
"code": "CONFLICT",
"message": "资源状态冲突"
}
}
}
}
},
"InternalServerError": {
"description": "服务器内部错误",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"error": {
"code": "INTERNAL_ERROR",
"message": "服务器内部错误"
}
}
}
}
}
}
}