Files
Yoko 38ba4c5c1e 支持用户按设备 ID 手动移除远程登记 (#1584)
* 补齐 Agent 按目录版本移除离线设备的接口契约

* 按设备 ID 撤销登记并从远程目录移除

* 删除云电脑时撤销对应设备登记并回填历史残留

* 移除云电脑自动清理迁移,保留手动删除
2026-11-24 16:36:32 +08:00

8342 lines
317 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
openapi: 3.1.0
info:
title: MonkeyAI Agent API
description: 错误使用稳定 code 和本地化 message,不含 reason。Accept-Language 支持 zh-CN 和 en-US,缺省或未知语言回退 zh-CN;响应返回 Content-Language、Vary 和 X-Request-ID。错误文案追加 [trace_id] 链路编号,与日志 trace_id 对应,使用当前 OTel Trace ID。
version: 1.0.0
servers:
- url: /
security:
- OAuthAccessToken: []
paths:
/api/v1/system-images:
get:
summary: 查询管理员已发布的可用系统镜像
description: 需要 environment:read。只列出已就绪且未下架的镜像。客户端应预选 is_default 项并提交其真实 ID。
responses:
'200':
description: 可选镜像目录,不缓存。
content:
application/json:
schema:
type: object
required: [items]
properties:
items:
type: array
items:
type: object
required: [id, display_name, architectures, is_default]
properties:
id: {type: string, format: uuid}
display_name: {type: string}
architectures: {type: array, items: {type: string}}
is_default: {type: boolean}
/api/v1/environment-specifications:
get:
summary: 查询全局可选云电脑规格
description: 需要 environment:read。返回完整且有序的有效规格列表,不分页;Cache-Control 为 no-store。空列表表示管理员尚未配置或已清空规格,不能新建。创建时必须同时提交所选 id 与 version,revision 仅用于管理端整表更新。
responses:
'200':
description: 全局规格目录。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentSpecificationCatalog'
'401':
description: 登录凭据无效或过期。
'403':
description: 缺少 environment:read。
'500':
description: 内部存储错误。
/api/auth/v1/capabilities:
get:
summary: 读取当前可用功能
description: 无需登录。返回可用功能的布尔值,响应使用 Cache-Control no-store。
security: []
responses:
'200':
description: 当前生效的能力
content:
application/json:
schema:
type: object
additionalProperties: false
required: [allow_cloud_computer, allow_custom_branding]
properties:
allow_cloud_computer:
type: boolean
description: 是否支持新建云电脑。
allow_custom_branding:
type: boolean
description: 允许修改和使用自定义团队名称、产品名称和 Logo。
/api/v1/environment-hosts:
get:
summary: 查询本人可使用的宿主
description: 需要environment:read;按用户、分组及全员授权过滤后分页。仅返回已配置宿主的名称、架构及全局费率,不再返回宿主 resource,不暴露宿主私有报告。available是当前在线/镜像状态,最终创建仍在事务内校验宿主就绪状态、授权和余额。
parameters:
- {name: page, in: query, schema: {type: integer, minimum: 1}}
- {name: page_size, in: query, schema: {type: integer, minimum: 1, maximum: 100}}
responses:
'200':
description: 当前用户已授权宿主列表,Cache-Control为no-store。
content:
application/json:
schema:
type: object
required: [items, page, page_size]
properties:
items: {type: array, items: {$ref: '#/components/schemas/EnvironmentHostOption'}}
page: {type: integer}
page_size: {type: integer}
'403':
description: 缺少environment:read。
/api/v1/environments:
get:
summary: 查询环境列表
description: '默认不返回已确认删除和已离线归档的环境;在线等待删除和清理失败仍显示,过滤先于分页。所有响应使用 Cache-Control: no-store。需要 environment:read,只访问当前用户环境;旧 token 不会自动获得该权限。'
responses:
'200':
description: 成功。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentList'
'400':
description: 请求参数、字段或大小无效。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'401':
description: 登录凭据无效或过期。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'403':
description: 缺少管理员角色或对应 environment scope。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'404':
description: 资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'409':
description: 版本、幂等键、状态、计费或宿主准入冲突;响应 error.code 区分原因。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'500':
description: 内部存储或服务错误。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
parameters:
- name: page
in: query
schema:
type: integer
format: int64
minimum: 1
- name: page_size
in: query
schema:
type: integer
format: int64
minimum: 1
maximum: 100
post:
summary: 使用所选全局规格创建环境
description: >-
客户端提交 name、request_key、specification_id、specification_version 和从目录选择的 image_id,可选 host_id;不接受任意镜像地址。旧客户端不传 image_id 时使用当前默认镜像。
服务端在事务内校验规格及版本,按所选 CPU 和内存校验计费,并在已授权、在线、镜像及 runtime 就绪的宿主中选择环境数量最少者。
不限制宿主及用户环境数量,允许 CPU/内存超卖;宿主旧资源预设不参与准入。
request_key 按用户幂等并绑定规格、版本及宿主选择;成功请求即使规格后来修改或删除仍返回原环境,不重新调度或扣款。
缺少规格返回 400 invalid_request,已删除返回 409 specification_unavailable,版本变化返回 409 specification_changed。
镜像/runtime 未就绪返回 409 configuration_unavailable,没有可用宿主返回 409 capacity_unavailable。
所有响应使用 Cache-Control: no-store。需要 environment:manage,只访问当前用户环境;旧 token 不会自动获得该权限。
responses:
'202':
description: 请求已接受;操作结果通过查询环境或操作列表获得。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentResult'
'400':
description: 请求参数、字段或大小无效。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'401':
description: 登录凭据无效或过期。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'403':
description: 缺少管理员角色或对应 environment scope。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'404':
description: 资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'409':
description: 版本、幂等键、状态、计费或宿主准入冲突;响应 error.code 区分原因。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'500':
description: 内部存储或服务错误。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentCreation'
/api/v1/environments/{id}:
get:
summary: 查询环境详情
description: ' 所有响应使用 Cache-Control: no-store。 需要 environment:read,只访问当前用户环境;旧 token 不会自动获得该权限。'
responses:
'200':
description: 成功。
content:
application/json:
schema:
$ref: '#/components/schemas/Environment'
'400':
description: 请求参数、字段或大小无效。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'401':
description: 登录凭据无效或过期。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'403':
description: 缺少管理员角色或对应 environment scope。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'404':
description: 资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'409':
description: 版本、幂等键、状态、计费或宿主准入冲突;响应 error.code 区分原因。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'500':
description: 内部存储或服务错误。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
delete:
summary: 删除运行实例并保留持久目录
description: '删除仍保留存储预留;失败可用新 request_key 和当前 generation 重试删除。不会执行数据 purge。 所有响应使用 Cache-Control: no-store。
需要 environment:manage,只访问当前用户环境;旧 token 不会自动获得该权限。'
responses:
'202':
description: 请求已接受;操作结果通过查询环境或操作列表获得。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentResult'
'400':
description: 请求参数、字段或大小无效。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'401':
description: 登录凭据无效或过期。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'403':
description: 缺少管理员角色或对应 environment scope。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'404':
description: 资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'409':
description: 版本、幂等键、状态、计费或宿主准入冲突;响应 error.code 区分原因。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'500':
description: 内部存储或服务错误。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentChange'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/environments/{id}/runtime:
get:
summary: 查询本人环境的 runtime 版本与更新能力
description: 需要 environment:read;返回当前版本、server 最新版本、更新操作与停止要求,响应不缓存。
parameters:
- {name: id, in: path, required: true, schema: {type: string, format: uuid}}
responses:
'200':
description: 成功。
content:
application/json:
schema: {$ref: '#/components/schemas/EnvironmentRuntimeInfo'}
'401': {description: 未登录或凭据过期。}
'403': {description: 缺少 environment:read。}
'404': {description: 环境不存在或不属于当前用户。}
/api/v1/environments/{id}/runtime/upgrade:
post:
summary: 不重建容器更新本人环境的 runtime
description: 需要 environment:manage。环境必须已确认停止,宿主支持独立更新;保留容器、目录与设备身份。version 省略时选择 server 当前最新版本,显式版本可回退到 server 已有版本。请求使用 generation 与 request_key 保证并发安全和幂等,响应不缓存。
parameters:
- {name: id, in: path, required: true, schema: {type: string, format: uuid}}
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/EnvironmentRuntimeUpgrade'}
responses:
'202':
description: 已受理,查询 runtime 或操作记录等待 succeeded/failed。
content:
application/json:
schema: {$ref: '#/components/schemas/EnvironmentResult'}
'400': {description: 参数、额外字段或版本格式无效,不允许传下载地址。}
'401': {description: 未登录或凭据过期。}
'403': {description: 缺少 environment:manage。}
'404': {description: 环境不存在或不属于当前用户。}
'409': {description: 未停止、代次或幂等冲突、宿主不可用、版本已相同或不支持更新。}
'503': {description: server 尚未配置 runtime 发行资源。}
/api/v1/environments/{id}/operations:
get:
summary: 查询环境操作记录
description: ' 所有响应使用 Cache-Control: no-store。 需要 environment:read,只访问当前用户环境;旧 token 不会自动获得该权限。'
responses:
'200':
description: 成功。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentOperationList'
'400':
description: 请求参数、字段或大小无效。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'401':
description: 登录凭据无效或过期。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'403':
description: 缺少管理员角色或对应 environment scope。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'404':
description: 资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'409':
description: 版本、幂等键、状态、计费或宿主准入冲突;响应 error.code 区分原因。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'500':
description: 内部存储或服务错误。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: page
in: query
schema:
type: integer
format: int64
minimum: 1
- name: page_size
in: query
schema:
type: integer
format: int64
minimum: 1
maximum: 100
/api/v1/environments/{id}/stop:
post:
summary: 停止环境
description: '收到当前代次停止确认后才释放计算预留。 所有响应使用 Cache-Control: no-store。 需要 environment:manage,只访问当前用户环境;旧 token 不会自动获得该权限。'
responses:
'202':
description: 请求已接受;操作结果通过查询环境或操作列表获得。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentResult'
'400':
description: 请求参数、字段或大小无效。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'401':
description: 登录凭据无效或过期。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'403':
description: 缺少管理员角色或对应 environment scope。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'404':
description: 资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'409':
description: 版本、幂等键、状态、计费或宿主准入冲突;响应 error.code 区分原因。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'500':
description: 内部存储或服务错误。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentChange'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/environments/{id}/start:
post:
summary: 启动已停止环境
description: '只允许已确认停止的环境;沿用原宿主与持久卷,分配新实例。宿主离线时拒绝启动,不自动迁移。 所有响应使用 Cache-Control: no-store。 需要 environment:manage,只访问当前用户环境;旧
token 不会自动获得该权限。'
responses:
'202':
description: 请求已接受;操作结果通过查询环境或操作列表获得。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentResult'
'400':
description: 请求参数、字段或大小无效。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'401':
description: 登录凭据无效或过期。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'403':
description: 缺少管理员角色或对应 environment scope。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'404':
description: 资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'409':
description: 版本、幂等键、状态、计费或宿主准入冲突;响应 error.code 区分原因。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
'500':
description: 内部存储或服务错误。
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentError'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/EnvironmentChange'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/design-resources/config:
get:
summary: 查询设计资源双源配置
description: 成功返回裸对象,错误沿用现有控制面 error 信封;Cache-Control 为 no-store。base_url 是完整 base,不追加固定路径;publisher_id 未配置为 null。
responses:
'200':
description: 配置不含密钥;hub 地址固定内置;未导入时 available=false、snapshot=null。
content:
application/json:
schema: {$ref: '#/components/schemas/DesignConfig'}
'401': {description: 未登录,控制面错误信封}
'503': {description: 配置或存储不可用,控制面错误信封}
/api/v1/design-resources/token:
post:
summary: 为当前用户已登记设备签发设计凭据
description: hub JWT 使用 aud=respub-design;本地媒体 JWT 使用 aud=monkeyai-design-media 及 sub=用户ID,密钥独立,有效期10分钟。instance_id 由 Pro 入口复用持久化统计身份。响应 no-store,禁止记录凭据。设备移除后不得签发,已签发短期凭据按过期时间失效。
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [machine_id, target]
properties:
machine_id: {type: string}
target: {type: string, enum: [respub, monkeyai-media]}
responses:
'200':
description: 裸对象,不使用 catalog 信封
content:
application/json:
schema:
type: object
required: [token, expires_at]
properties:
token: {type: string}
expires_at: {type: string, format: date-time}
'400': {description: 请求格式或 target 无效,控制面错误信封}
'401': {description: 未登录,控制面错误信封}
'403': {description: 设备不属于当前用户或已移除}
'503': {description: 对应密钥、实例ID或 hub base 未配置}
/api/v1/design-resources/catalog/snapshot:
get:
summary: 读取当前或指定的冻结设计快照
parameters: &designSnapshotParameters
- {name: snapshot, in: query, schema: {type: string}, description: 本地为 release:<source_release_id>;省略使用 current,显式非法或未知返回404,不回落。}
- {name: publisher_id, in: query, schema: {type: string}, description: 提供时必须与发布者匹配,否则403。}
responses:
'200':
description: catalog 成功信封
content:
application/json:
schema:
allOf:
- {$ref: '#/components/schemas/DesignEnvelope'}
- {properties: {data: {$ref: '#/components/schemas/DesignSnapshot'}}}
'401': &design401 {description: unauthorized,catalog 信封,data=null}
'403': &design403 {description: forbidden,catalog 信封,data=null}
'404': &design404 {description: snapshot_not_found 或 resource_not_found,catalog 信封,data=null}
'503': &design503 {description: unavailable,catalog 信封,data=null}
/api/v1/design-resources/catalog/taxonomy:
get:
summary: 读取冻结词表、计数与模板关联
parameters: *designSnapshotParameters
responses:
'200':
description: 保留发布集的限定ID、count、provenance;四个数组均不为null,不重新累计计数。
content:
application/json:
schema:
allOf:
- {$ref: '#/components/schemas/DesignEnvelope'}
- properties:
data:
type: object
required: [modes, categories, mode_categories, resource_categories]
properties:
modes: {type: array, items: {type: object}}
categories: {type: array, items: {type: object}}
mode_categories: {type: array, items: {type: object}}
resource_categories: {type: array, items: {type: object}}
'401': *design401
'403': *design403
'404': *design404
'503': *design503
/api/v1/design-resources/catalog/{kind}:
parameters:
- {name: kind, in: path, required: true, schema: {type: string, enum: [templates, design-systems, styles, directions]}}
get:
summary: 分页查询冻结设计资源
description: 按 catalog_rank 和稳定ID排序。模板列表不返回提示词、skillPath、source_skill_path、files;系统列表不返回正文、metadata、files。所有成功结果使用 code=0、message为空、data承载数据;错误code为字符串。
parameters:
- {name: snapshot, in: query, schema: {type: string}}
- {name: publisher_id, in: query, schema: {type: string}}
- {name: page, in: query, schema: {type: integer, minimum: 1, default: 1}}
- {name: page_size, in: query, schema: {type: integer, minimum: 1, default: 20}, description: 超过100按100处理}
- {name: q, in: query, schema: {type: string}, description: ID或metadata JSON文本的确定性、不区分大小写搜索}
- {name: mode, in: query, schema: {type: string}, description: 模板词表限定ID或原始ID}
- {name: category, in: query, schema: {type: string}}
- {name: template_kind, in: query, schema: {type: string, enum: [bundle, prompt]}}
- {name: context, in: query, schema: {type: string}}
- {name: variant, in: query, schema: {type: string}}
- {name: recommended, in: query, schema: {type: boolean}}
responses:
'200':
description: 分页数据;空目录total_pages=0,越界items为空数组
content:
application/json:
schema:
allOf:
- {$ref: '#/components/schemas/DesignEnvelope'}
- {properties: {data: {$ref: '#/components/schemas/DesignPage'}}}
'400': &design400 {description: invalid_argument,catalog信封;参数非法或重复}
'401': *design401
'403': *design403
'404': *design404
'503': *design503
/api/v1/design-resources/catalog/{kind}/{id}:
parameters:
- {name: kind, in: path, required: true, schema: {type: string, enum: [templates, design-systems, styles, directions]}}
- {name: id, in: path, required: true, schema: {type: string}, description: catalog_id,按单个路径段编码}
get:
summary: 读取冻结资源详情
description: 模板保留原 skillPath,source_skill_path 为解析后的逻辑源路径或null,不参与业务摘要。详情、媒体和下载URL绑定同一 snapshot/publisher_id/content_digest。
parameters: &designResourceParameters
- {name: snapshot, in: query, schema: {type: string}}
- {name: publisher_id, in: query, schema: {type: string}}
- {name: content_digest, in: query, schema: {type: string}}
responses:
'200':
description: 资源详情,翻译无值时为对象、无预览为null
content:
application/json:
schema:
allOf:
- {$ref: '#/components/schemas/DesignEnvelope'}
- {properties: {data: {$ref: '#/components/schemas/DesignEntry'}}}
'400': *design400
'401': *design401
'403': *design403
'404': *design404
'409': &design409 {description: resource_version_mismatch,内容摘要不匹配}
'503': *design503
/api/v1/design-resources/catalog/templates/{id}/download:
parameters:
- {name: id, in: path, required: true, schema: {type: string}}
get: &designDownload
summary: 下载冻结源文件ZIP
description: 直接返回持久化ZIP,不302;支持单/多区间Range(最多32段)、If-None-Match、If-Range。强ETag是实际ZIP字节SHA,鉴权先于304/206;错误no-store。源文件按原逻辑路径,容器字节不承诺与hub相同。
parameters: *designResourceParameters
responses:
'200': {description: ZIP全量字节,含Content-Length和强ETag, content: {application/zip: {schema: {type: string, format: binary}}}}
'206': {description: 单区间或multipart/byteranges字节}
'304': {description: 已认证且ETag匹配,无正文}
'400': *design400
'401': *design401
'403': *design403
'404': *design404
'409': *design409
'416': {description: invalid_argument,Content-Range为bytes */size}
'503': *design503
head:
<<: *designDownload
summary: 查询冻结ZIP长度与ETag,不返回正文
/api/v1/design-resources/design-systems/{id}/download:
parameters:
- {name: id, in: path, required: true, schema: {type: string}}
get: *designDownload
head:
<<: *designDownload
summary: 查询系统ZIP长度与ETag,不返回正文
/api/v1/design-resources/catalog/previews/{id}/{path}:
parameters: &designMediaPathParameters
- {name: id, in: path, required: true, schema: {type: string}}
- {name: path, in: path, required: true, schema: {type: string}, description: catalog.files中的逻辑路径,逐段编码,路由支持多级路径}
get: &designMedia
summary: 读取设计媒体
description: 仅允许image/video/audio MIME。仅接受本地媒体JWT的Bearer或query token,有Authorization时优先且失败不降级。支持HEAD/Range/ETag/If-Range,认证先于304/206,private缓存和nosniff,SVG加sandbox CSP。token不得保存到业务URL或日志。
security:
- DesignMediaBearer: []
- DesignMediaQuery: []
parameters:
- {name: snapshot, in: query, schema: {type: string}}
- {name: publisher_id, in: query, schema: {type: string}}
- {name: content_digest, in: query, schema: {type: string}}
responses:
'200': {description: 原始媒体字节、Content-Length、强ETag、Accept-Ranges}
'206': {description: 单区间或最多32段的multipart/byteranges}
'304': {description: 已认证且ETag匹配}
'400': *design400
'401': *design401
'403': *design403
'404': *design404
'409': *design409
'416': {description: invalid_argument,所有区间不可满足}
'503': *design503
head:
<<: *designMedia
summary: 读取媒体响应头;错误无正文且no-store
/api/v1/design-resources/catalog/style-assets/{id}/{path}:
parameters: *designMediaPathParameters
get: *designMedia
head:
<<: *designMedia
summary: 读取风格媒体响应头
/.well-known/oauth-authorization-server:
get:
summary: 查询 OAuth 能力
security: []
responses:
'200':
description: issuer、授权、兑换、撤销地址和 scopes_supported;未实现的远程能力不声明。
content:
application/json:
schema:
type: object
properties:
grant_types_supported:
type: array
items: {type: string, enum: [authorization_code, refresh_token, 'urn:ietf:params:oauth:grant-type:device_code', 'urn:monkeyai:params:oauth:grant-type:pairing_code']}
description: 仅在设备授权启用时包含 device_code 和 pairing_code
scopes_supported: {type: array, items: {type: string}}
device_scopes_supported:
type: array
items: {type: string}
description: 启用设备授权时发布。account:ai-resources 是设备访问账号 AI 资源的委托,不替代资源自身权限。
/oauth/authorize:
get:
summary: 创建安装登录授权请求
description: 回调仅允许客户端已登记的应用 URI;Desktop 另允许 http://localhost:端口/oauth/callback、http://127.0.0.1:端口/oauth/callback 或 http://[::1]:端口/oauth/callback,端口必须为 1–65535,禁止用户信息、查询参数和片段。所有登录均要求浏览器明确确认和 CSRF 校验;启用远程中转时,Desktop 省略 scope 或传空字符串时使用默认远程执行权限;纯空白 scope 返回 invalid_scope。旧 token 不自动扩权,兑换和刷新不能扩大权限。
security: []
parameters:
- {name: response_type, in: query, required: true, schema: {type: string, const: code}}
- {name: client_id, in: query, required: true, schema: {type: string, enum: [monkeyai-desktop, monkeyai-mobile]}}
- {name: redirect_uri, in: query, required: true, schema: {type: string}}
- {name: state, in: query, required: true, schema: {type: string}}
- {name: code_challenge, in: query, required: true, schema: {type: string}}
- {name: code_challenge_method, in: query, required: true, schema: {type: string, const: S256}}
- {name: scope, in: query, schema: {type: string, maxLength: 1024}, description: 空格分隔;Mobile 不允许 device:bind、device:publish、session:report。}
- {name: audience, in: query, schema: {type: string, const: monkeyai-api, default: monkeyai-api}}
responses:
'302': {description: 跳转浏览器登录和授权确认页面}
'400': {description: OAuth invalid_request、invalid_scope 或 invalid_target}
'503': {description: OAuth server_error;保留本地登录状态并退避}
/oauth/token:
post:
summary: 兑换授权码、手机配对码或轮换安装凭据
description: 刷新保持 grant_id、scope 和机器绑定;已轮换 refresh token 重放会撤销整个授权族。手机配对使用 urn:monkeyai:params:oauth:grant-type:pairing_code,仅允许 monkeyai-mobile,必须提供 device_code 和 43–128 字符的 code_verifier;固定签发 device:connect、environment:read、files:read、files:write、resources:manage、session:control、session:read 账号权限,不绑定执行设备。等待批准返回 authorization_pending;并发改密或批准占用配对锁时也返回该可重试错误。轮询遵守 join 返回的 interval,每次 slow_down 增加 5 秒。所有响应 no-store。
security: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
required: [grant_type, client_id]
properties:
grant_type: {type: string, enum: [authorization_code, refresh_token, 'urn:ietf:params:oauth:grant-type:device_code', 'urn:monkeyai:params:oauth:grant-type:pairing_code']}
client_id: {type: string, enum: [monkeyai-desktop, monkeyai-mobile, monkeyai-runtime]}
device_code: {type: string}
code: {type: string}
redirect_uri: {type: string}
code_verifier: {type: string}
refresh_token: {type: string}
responses:
'200':
description: 新凭据;Cache-Control 为 no-store
content:
application/json:
schema:
type: object
required: [access_token, refresh_token, token_type, expires_in, grant_id, scope]
properties:
access_token: {type: string}
refresh_token: {type: string}
token_type: {type: string, const: Bearer}
expires_in: {type: integer}
grant_id: {type: string, format: uuid}
machine_id: {type: string, format: uuid, description: 独立授权冻结的目标机器}
server_id: {type: string, format: uuid, description: 独立授权的控制面标识}
scope: {type: string, description: 用户批准的规范化权限;兼容授权为空字符串}
'400':
description: OAuth invalid_grant、invalid_client、invalid_request、authorization_pending、slow_down、access_denied、expired_token 或 unsupported_grant_type
content:
application/json:
schema: {$ref: '#/components/schemas/OAuthError'}
'503':
description: OAuth server_error,不能按 invalid_grant 清理登录
content:
application/json:
schema: {$ref: '#/components/schemas/OAuthError'}
/oauth/pairing:
post:
summary: 创建手机扫码配对
description: 需要 Bearer 的 device:manage 权限。二维码 60 秒有效;secret 只在本次响应出现,数据库只存摘要。server 固定取服务端公开地址。请求体最多 64 KiB,所有响应 no-store;每 IP 每分钟最多创建 60 次。配对不形成长期设备绑定。
requestBody:
required: true
content:
application/json:
schema: {type: object, additionalProperties: false, maxProperties: 0}
responses:
'200':
description: 一次性二维码凭据,不得记录 secret 或二维码内容
headers: &pairingNoStore
Cache-Control: {description: 禁止缓存配对响应, schema: {type: string, const: no-store}}
content:
application/json:
schema:
type: object
additionalProperties: false
required: [pairing_id, secret, qr_payload, expires_in]
properties:
pairing_id: {type: string, format: uuid, description: 一次性配对标识}
secret: {type: string, minLength: 43, maxLength: 43, description: 32 字节随机数的无填充 base64url,仅返回一次}
qr_payload: {type: string, format: uri, description: 'https://work.baizhi.cloud/app-link/scan/?v=1&server=<公开服务地址>&id=<uuid>&secret=<secret>;仅这四个参数'}
expires_in: {type: integer, const: 60, description: 二维码有效秒数}
'400': {$ref: '#/components/responses/PairingInvalidRequest'}
'401': {$ref: '#/components/responses/PairingUnauthorized'}
'403': {$ref: '#/components/responses/PairingForbidden'}
'404': {$ref: '#/components/responses/PairingNotFound'}
'429': {$ref: '#/components/responses/PairingRateLimited'}
'500': {$ref: '#/components/responses/PairingServerError'}
'503': {$ref: '#/components/responses/PairingServiceUnavailable'}
/oauth/pairing/{pairingID}/join:
parameters:
- {$ref: '#/components/parameters/PairingID'}
post:
summary: 手机使用二维码 secret 加入配对
description: 无需登录;严格 JSON,最多 16 KiB,每 IP 每分钟最多 60 次。只允许一次加入;secret 错误、不存在、非法 ID 和过期统一返回 404 pairing_not_found。成功延长到 min(当前时间+60秒,创建时间+180秒)。所有响应 no-store,user_code/device_code 仅保存摘要。
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
required: [secret, code_challenge, code_challenge_method, machine_id, display_name, platform, os_version, arch]
properties:
secret: {type: string, description: 二维码中的原始 secret}
code_challenge: {type: string, minLength: 43, maxLength: 43, pattern: '^[A-Za-z0-9_-]{43}$', description: SHA-256 verifier 的无填充 base64url}
code_challenge_method: {type: string, const: S256, description: 仅支持 S256 PKCE}
machine_id: {type: string, format: uuid, description: 规范小写 UUIDv4;仅标识手机,不登记执行设备}
display_name: {type: string, minLength: 1, maxLength: 128, description: UTF-8 最多 128 字节,不得全空白或含控制字符}
platform: {type: string, enum: [android, ios, harmonyos], description: 手机系统}
os_version: {type: string, minLength: 1, maxLength: 64, description: UTF-8 最多 64 字节,不得全空白或含控制字符}
arch: {type: string, minLength: 1, maxLength: 32, description: UTF-8 最多 32 字节,不得全空白或含控制字符}
responses:
'200':
description: 手机展示短码,并保留设备码及原始 verifier 用于兑换
headers: *pairingNoStore
content:
application/json:
schema:
type: object
additionalProperties: false
required: [user_code, device_code, expires_in, interval]
properties:
user_code: {type: string, pattern: '^[A-HJ-NP-Z2-9]{4}-[A-HJ-NP-Z2-9]{4}$', description: 八位配对码,展示时带连字符}
device_code: {type: string, minLength: 43, maxLength: 43, description: 32 字节随机数的无填充 base64url}
expires_in: {type: integer, minimum: 1, maximum: 60, description: 剩余批准与兑换窗口秒数}
interval: {type: integer, const: 5, description: 初始轮询间隔秒数,slow_down 时客户端再加 5 秒}
'400': {$ref: '#/components/responses/PairingInvalidRequest'}
'404': {$ref: '#/components/responses/PairingNotFound'}
'409':
description: pairing_already_joined,二维码已被使用
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
'429': {$ref: '#/components/responses/PairingRateLimited'}
'500': {$ref: '#/components/responses/PairingServerError'}
/oauth/pairing/{pairingID}:
parameters:
- {$ref: '#/components/parameters/PairingID'}
get:
summary: 桌面端查询本人创建的配对
description: 需要有效 Bearer;非创建者与不存在统一返回 404 pairing_not_found。所有响应 no-store。只返回状态与手机公开信息,绝不返回 secret、device_code、user_code 或对应摘要。
responses:
'200':
description: 配对状态;已到期的活动记录显示 expired
headers: *pairingNoStore
content:
application/json:
schema:
type: object
additionalProperties: false
required: [pairing_id, status, expires_at]
properties:
pairing_id: {type: string, format: uuid, description: 配对标识}
status: {type: string, enum: [pending, joined, approved, consumed, denied, expired], description: 一次性配对状态}
expires_at: {type: string, format: date-time, description: 当前窗口到期时间}
device:
type: object
additionalProperties: false
description: 手机已加入且状态不为 pending 时返回;未加入即过期或撤销的记录不包含此字段
required: [display_name, platform, os_version]
properties:
display_name: {type: string, description: 手机展示名称}
platform: {type: string, enum: [android, ios, harmonyos], description: 手机系统}
os_version: {type: string, description: 系统版本}
'401': {$ref: '#/components/responses/PairingUnauthorized'}
'403': {$ref: '#/components/responses/PairingForbidden'}
'404': {$ref: '#/components/responses/PairingNotFound'}
'500': {$ref: '#/components/responses/PairingServerError'}
'503': {$ref: '#/components/responses/PairingServiceUnavailable'}
/oauth/pairing/{pairingID}/approve:
parameters:
- {$ref: '#/components/parameters/PairingID'}
post:
summary: 桌面端输入手机短码批准配对
description: 需要 Bearer 的 device:manage 权限,不使用浏览器 Cookie。请求体最多 64 KiB。大小写、空格和连字符规范化后校验;每次错码计数,累计 5 次置 denied。事务内复核 Bearer 并写 pairing.approved 审计;改密同事务撤销未兑换配对。所有响应 no-store。
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
required: [user_code]
properties:
user_code: {type: string, description: 手机显示的八位短码,允许小写、空格及连字符}
responses:
'200':
description: 批准已持久化,手机仍需使用 PKCE 兑换
headers: *pairingNoStore
content:
application/json:
schema:
type: object
additionalProperties: false
required: [status]
properties:
status: {type: string, const: approved, description: 配对已批准}
'400':
description: invalid_request(JSON 无效)或 invalid_user_code(错码,本次尝试已计数)
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
'401': {$ref: '#/components/responses/PairingUnauthorized'}
'403': {$ref: '#/components/responses/PairingForbidden'}
'404': {$ref: '#/components/responses/PairingNotFound'}
'409':
description: pairing_expired(已过期)或 pairing_resolved(不是 joined 状态,含连错五次)
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
'500': {$ref: '#/components/responses/PairingServerError'}
'503': {$ref: '#/components/responses/PairingServiceUnavailable'}
/oauth/revoke:
post:
summary: 撤销当前安装授权族
description: 可提交族内旧或新 access/refresh token;同用户其他安装不受影响;未知凭据幂等返回 200。
security: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
required: [client_id, token]
properties:
client_id: {type: string}
token: {type: string}
responses:
'200': {description: 撤销已持久化或凭据未知}
'400': {description: OAuth invalid_request}
'503': {description: OAuth server_error;撤销尚未确认成功}
/api/auth/v1/client-requests/{requestID}:
get:
summary: 查询冻结的安装授权请求
security: []
parameters:
- {name: requestID, in: path, required: true, schema: {type: string, format: uuid}}
responses:
'200':
description: 登录状态、客户端、权限和确认数据,不包含 OAuth token
content:
application/json:
schema:
type: object
properties:
request_id: {type: string, format: uuid}
authenticated: {type: boolean}
client: {type: object}
user: {type: [object, 'null']}
providers: {type: array, items: {type: object}}
scopes: {type: array, items: {type: string}}
scope_descriptions: {type: object, additionalProperties: {type: string}}
audience: {type: string, const: monkeyai-api}
consent_required: {type: boolean, const: true, description: 空权限列表也必须明确确认}
csrf_token: {type: string, description: 绑定当前浏览器登录和申请,提交时通过 X-CSRF-Token 回传}
'404': {description: 申请不存在、已完成或过期}
'503': {description: 登录方式暂不可用}
/api/auth/v1/client-requests/{requestID}/complete:
post:
summary: 确认授权并生成一次性回调
description: 所有授权均必须通过 CSRF 与来源校验,并明确提供批准列表;只能收窄。没有附加权限时也必须提交 approved_scopes 空数组。完成前会重新校验已保存的回调地址。
security:
- BrowserSession: []
parameters:
- {name: requestID, in: path, required: true, schema: {type: string, format: uuid}}
- {name: X-CSRF-Token, in: header, required: true, schema: {type: string}, description: 所有授权申请必填}
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
required: [approved_scopes]
properties:
approved_scopes: {type: array, items: {type: string}}
responses:
'200':
description: 含一次性授权码的回调地址;不缓存
content:
application/json:
schema:
type: object
required: [launch_url]
properties:
launch_url: {type: string}
'401': {description: 浏览器未登录}
'403': {description: 缺少明确确认或 CSRF/来源校验失败}
'404': {description: 申请不存在}
'409': {description: 申请已完成、过期、回调地址未登记或批准范围无效}
/oauth/device/authorization:
post:
summary: 申请独立 runtime 设备授权
description: RFC8628;冻结机器、公钥与权限。device_code 只保存摘要,短码保存服务端 HMAC 索引;默认十分钟、轮询五秒。不得将返回凭据写入日志。
security: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
required: [client_id, machine_id, execution_public_key, display_name, platform, arch]
properties:
client_id: {type: string, const: monkeyai-runtime}
scope: {type: string, deprecated: true, description: 兼容旧运行端;服务端忽略此字段,设备批准授予固定能力。}
machine_id: {type: string, format: uuid}
execution_public_key: {type: string, description: Ed25519 原始公钥的无填充 base64url}
display_name: {type: string, maxLength: 128}
platform: {type: string, enum: [macos, windows, linux]}
arch: {type: string, maxLength: 32}
responses:
'200':
description: 不缓存的设备申请凭据
content:
application/json:
schema:
type: object
required: [device_code, user_code, verification_uri, expires_in, interval]
properties:
device_code: {type: string}
user_code: {type: string}
verification_uri: {type: string, format: uri}
verification_uri_complete: {type: string, format: uri}
expires_in: {type: integer, const: 600}
interval: {type: integer, const: 5}
'400': {description: OAuth invalid_request、invalid_client 或 invalid_scope}
'429': {description: OAuth temporarily_unavailable,遵守 Retry-After}
'503': {description: OAuth server_error}
/api/auth/v1/device/decision:
post:
summary: 浏览器明确批准或拒绝独立执行授权
description: 申请只处理一次;权限只能收窄。已撤销设备恢复需要 restore_revoked=true,公钥冲突拒绝覆盖。
security:
- BrowserSession: []
parameters:
- {name: X-CSRF-Token, in: header, required: true, schema: {type: string}}
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
required: [request_id, decision]
properties:
request_id: {type: string, format: uuid}
decision: {type: string, enum: [approve, deny]}
approved_scopes: {type: array, deprecated: true, items: {type: string}, description: 兼容旧客户端;批准或拒绝针对整套运行端授权。}
restore_revoked: {type: boolean, default: false}
responses:
'200': {description: approved 或 denied 已持久化}
'400': {description: invalid_request}
'401': {description: 浏览器未登录}
'403': {description: CSRF、来源或账号状态校验失败}
'404': {description: request_not_found}
'409': {description: device_request_resolved、device_revoked 或 device_registration_conflict}
'503': {description: authorization_state_unavailable}
/api/auth/v1/client-requests/device:
get:
summary: 通过短码查询冻结的设备申请
description: /device 验证页使用;只展示设备、账号、指纹和权限,不返回 token 或 device_code。可用已有 client-requests/{requestID}?purpose=device 查询同一申请。
security: []
parameters:
- {name: purpose, in: query, required: true, schema: {type: string, const: device}}
- {name: user_code, in: query, required: true, schema: {type: string}}
responses:
'200': {description: 申请、登录方式、状态、requires_restore、registration_conflict 和绑定当前浏览器的 csrf_token}
'404': {description: 短码无效或过期}
'429': {description: rate_limited}
'503': {description: 策略或设备状态暂不可用}
/api/v1/sessions:
get:
summary: 查询本人的跨设备会话摘要
description: 要求 session:read 和启用会话元数据上报;只返回认证宿主记录,不含正文。stats 级策略不返回标题。设备离线、摘要过期或 boot/epoch 不匹配时 stale=true。
parameters:
- {name: machine_id, in: query, schema: {type: string, format: uuid}}
- {name: page, in: query, schema: {type: integer, minimum: 1, default: 1}}
- {name: page_size, in: query, schema: {type: integer, minimum: 1, maximum: 100, default: 20}}
responses:
'200':
description: 本人摘要分页
content:
application/json:
schema:
type: object
properties:
items: {type: array, items: {$ref: '#/components/schemas/SessionSummary'}}
pagination: {type: object, properties: {page: {type: integer}, page_size: {type: integer}, total: {type: integer}}}
server_time: {type: string, format: date-time}
'400': {description: 非法筛选或请求指定其他用户}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {description: permission_denied 或 reporting_disabled}
'503': {description: authorization_state_unavailable}
/preview/{machine_id}/{grant}/{path}:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
- {name: grant, in: path, required: true, schema: {type: string}, description: 额外绑定 artifact_id 和 preview_origin 的目录授权}
- {name: path, in: path, required: true, schema: {type: string}}
get:
summary: 在产物专属 origin 中执行隔离预览
description: 需配置独立 HTTPS 泛域名模板。验证产物派生 Host、签名、授权族、范围和期限;使用 opaque sandbox 禁止持久存储、Cookie、ServiceWorker、表单和嵌套应用。原有 Desktop 自定义产物 origin 语义不变。
security: []
responses:
'200': {description: HTML 或相对资源;no-store、sandbox allow-scripts,禁止 allow-same-origin}
'206': {description: 资源 Range 响应}
'403': {description: 产物、Host 或文件授权无效}
'404': {description: 未配置预览服务}
'503': {description: 目标或授权不可用}
head:
summary: 查询隔离产物资源响应头
security: []
responses:
'200': {description: 资源响应头}
'403': {description: 产物授权无效}
'503': {description: 目标或授权不可用}
/api/v1/sessions/{id}:
parameters:
- name: id
in: path
required: true
schema: {type: string, format: uuid}
get:
summary: 查询本人指定会话摘要
description: 要求 session:read;跨用户与不存在统一返回 404,遵循上报及标题策略。
responses:
'200':
description: 本人会话摘要
content:
application/json:
schema: {$ref: '#/components/schemas/SessionSummary'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {description: permission_denied 或 reporting_disabled}
'404': {description: 会话不存在或不属于当前用户}
'503': {description: authorization_state_unavailable}
put:
summary: 创建或更新一期会话元数据快照
description: 接收统计元数据及可选会话标题;state_seq 单调递增,同序号内容必须一致。已验证宿主从 OAuth 授权族取得,机器头只做一致性检查;旧无 scope 客户端仅能写入尚未验证的兼容宿主。省略标题字段时保留已有值,未知字段会被忽略。
parameters:
- name: X-MAI-Machine-ID
in: header
required: true
schema: {type: string, format: uuid}
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: true
required: [state_seq, client, session_type, started_at]
properties:
runtime:
type: object
additionalProperties: false
required: [boot_id, lease_epoch]
properties:
boot_id: {type: string, format: uuid}
lease_epoch: {type: integer, format: int64, minimum: 1}
description: 可选实时摘要;必须匹配当前活动宿主,不改变 state_seq 业务快照摘要。历史补传省略。
state_seq: {type: integer, format: int64, minimum: 0}
client:
type: object
additionalProperties: true
required: [type, machine_id, version]
properties:
type: {type: string, enum: [desktop, web, extension, mobile, runtime, unknown]}
machine_id: {type: string, format: uuid}
version: {type: string}
engine_version: {type: [string, 'null']}
runtime_version: {type: [string, 'null']}
session_type: {type: string, enum: [conversation, workflow, tool, scheduled]}
parent_session_id: {type: [string, 'null'], format: uuid}
title: {type: [string, 'null'], description: UTF-8 最多 512 字节}
title_source: {type: [string, 'null'], description: UTF-8 最多 128 字节}
expert_id: {type: [string, 'null'], format: uuid}
model_id: {type: [string, 'null'], format: uuid}
mode: {type: [string, 'null']}
workspace_kind: {type: [string, 'null']}
started_at: {type: string, format: date-time}
client_deleted_at: {type: [string, 'null'], format: date-time}
responses:
'200':
description: 已确认的会话快照及轮次游标
content:
application/json:
schema:
type: object
required: [state_seq, acked_turn, server_time]
properties:
state_seq: {type: integer, format: int64}
acked_turn: {type: integer}
server_time: {type: string, format: date-time}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/ResourceError403'}
'409': {$ref: '#/components/responses/ResourceError409'}
'429': {description: 请求过于频繁,遵守 Retry-After}
/api/v1/sessions/{id}/turns:
parameters:
- name: id
in: path
required: true
schema: {type: string, format: uuid}
post:
summary: 批量追加已完成的轮次报告
description: 接收已完成轮次的统计事实、可选用户正文及封存本轮时的会话标题;仅处理已声明字段,未知字段会被忽略。
parameters:
- name: X-MAI-Machine-ID
in: header
required: true
schema: {type: string, format: uuid}
- name: after_turn
in: query
required: true
schema: {type: integer, minimum: 0}
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: true
required: [facts_version, turns]
properties:
facts_version: {type: integer, minimum: 1}
snapshots:
type: array
maxItems: 50
items:
type: object
additionalProperties: true
required: [snapshot_id, items]
properties:
snapshot_id: {type: string, description: 'sha256: 前缀的规范化资源快照摘要'}
revision: {type: [integer, 'null']}
state_version: {type: [integer, 'null']}
items: {type: array, items: {type: object}}
turns:
type: array
minItems: 1
maxItems: 50
items:
type: object
additionalProperties: true
required: [turn_index, input_seq, started_at, ended_at, stop_reason, resources_snapshot_id, input]
properties:
turn_index: {type: integer, minimum: 1}
input_seq: {type: integer, format: int64}
started_at: {type: string, format: date-time}
ended_at: {type: string, format: date-time}
stop_reason: {type: string, enum: [complete, interrupted, error, max_turns, output_limit, unknown]}
error_code: {type: [string, 'null']}
recovered: {type: boolean}
model_id: {type: [string, 'null'], format: uuid}
title: {type: [string, 'null'], description: 封存本轮时的会话标题,UTF-8 最多 512 字节,不得含 NUL}
title_source: {type: [string, 'null'], enum: [prompt, agent, user, null]}
thinking: {type: [object, 'null'], description: enabled 和 effort,不含思考内容}
resources_snapshot_id: {type: string}
client_version: {type: [string, 'null']}
engine_version: {type: [string, 'null']}
usage: {type: [object, 'null'], description: 仅四类 Token 计数,不含请求或响应正文}
subagent_usage: {type: [object, 'null']}
context_used: {type: [integer, 'null']}
context_window: {type: [integer, 'null']}
input:
type: object
additionalProperties: true
required: [kind]
description: 输入类型、来源、正文、截断标记及数量统计;正文去掉附件行,可含换行。
properties:
kind: {type: string}
text: {type: [string, 'null'], description: 客户端最多保留 2000 个 Unicode 码点,服务端上限为 8192 UTF-8 字节,不得含 NUL}
text_truncated: {type: boolean, default: false, description: 正文被截断时为 true,未截断时可省略}
origin:
type: [object, 'null']
additionalProperties: true
properties:
client_type: {type: [string, 'null']}
machine_id: {type: [string, 'null']}
command_skill_id: {type: [string, 'null']}
attachments: {type: integer, minimum: 0}
canvas_nodes: {type: integer, minimum: 0}
steers: {type: integer, minimum: 0}
files_changed: {type: object, description: 仅 created、updated、deleted 数量}
compactions: {type: integer}
permissions: {type: object, description: 仅 asked、allowed、denied 数量}
tools: {type: array, maxItems: 500, items: {type: object}}
skill_events: {type: array, items: {type: object}}
truncated: {type: boolean}
responses:
'200':
description: 已确认轮次和资源快照
content:
application/json:
schema:
type: object
required: [acked_turn, accepted, duplicates, snapshots_acked]
properties:
acked_turn: {type: integer}
accepted: {type: integer}
duplicates: {type: integer}
snapshots_acked: {type: array, items: {type: string}}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/ResourceError403'}
'404': {$ref: '#/components/responses/ResourceError404'}
'409': {$ref: '#/components/responses/ResourceError409'}
'413': {description: 请求体超过服务端限制}
'422': {description: facts_version 不支持,错误响应包含 supported}
'429': {description: 请求过于频繁,遵守 Retry-After}
/api/v1/endpoints:
get:
summary: 分页读取当前用户端点
description: 默认保持旧目录;添加 X-MAI-Runtime-API=1,或使用已获 device:connect 的新 Desktop 授权,返回远程目录。新目录需要 device:connect,包含平铺的 items、total、page、page_size 和真实 version,不以资料上报判断在线。display_name 优先使用用户手动别名;已绑定云环境且归属、公钥一致时使用创建环境的名称,否则使用设备上报名称。此规则同样适用于已有和离线的云环境设备。
parameters:
- {name: X-MAI-Runtime-API, in: header, schema: {type: string, const: '1'}}
- {name: capability, in: query, schema: {type: string, enum: [execute]}}
- {name: page, in: query, schema: {type: integer, minimum: 1, maximum: 1000000, default: 1}}
- {name: page_size, in: query, schema: {type: integer, minimum: 1, maximum: 100, default: 20}}
responses:
'200':
description: 旧端点分页或显式协商的远程目录
content:
application/json:
schema:
oneOf:
- type: object
required: [items, total, page, page_size]
properties:
items: {type: array, items: {$ref: '#/components/schemas/Endpoint'}}
total: {type: integer}
page: {type: integer}
page_size: {type: integer}
- {$ref: '#/components/schemas/RuntimeDirectory'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'503': {$ref: '#/components/responses/EndpointUnavailable'}
/api/v1/endpoint-bridge:
get:
summary: 证明设备身份并建立控制或数据隧道
description: 功能启用后可用;OAuth 要求 device:bind,publish 另要求 device:publish。hello/challenge/proof/ready/ready_ack 后进入二进制 yamux,bind_identity 确认后关闭。详见 design/remote-runtime-protocol.md。
parameters:
- {name: channel_kind, in: query, required: true, schema: {type: string, enum: [control, data]}}
- {name: tunnel_version, in: query, required: true, schema: {type: integer, const: 1}}
responses:
'101': {description: WebSocket 升级成功,HTTP 对应 WS、HTTPS 对应 WSS;后续错误通过握手错误消息或关闭返回}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/ResourceError403'}
'409': {description: upgrade_required}
'429': {description: relay_overloaded,遵守 Retry-After}
'503': {description: device_draining 或授权暂不可用}
/api/v1/endpoints/{machine_id}/connections:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
post:
summary: 创建或续期目标设备连接
description: 要求 device:connect 及申请的业务权限;同一 connection 串行续期,只能收窄权限,协议不能改变。ticket 15 分钟,只存 hash,原票据最多宽限 30 秒。撤销、过期和收窄不享受宽限。
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
connection_id: {type: string, format: uuid}
scopes: {type: array, items: {type: string, enum: ['session:read', 'session:control', 'files:read', 'files:write', 'resources:manage']}}
supported_protocols:
type: object
properties:
acp: {type: array, items: {type: integer}}
runtime_api: {type: array, items: {type: integer}}
responses:
'200':
description: 不缓存的目标连接凭据
content:
application/json:
schema:
type: object
required: [connection_id, machine_id, http_base, ticket, ticket_version, expires_at, expires_in, server_time, scopes, protocol]
properties:
connection_id: {type: string, format: uuid}
machine_id: {type: string, format: uuid}
http_base: {type: string, format: uri}
ticket: {type: string}
ticket_version: {type: integer, format: int64}
expires_at: {type: string, format: date-time}
expires_in: {type: integer}
server_time: {type: string, format: date-time}
scopes: {type: array, items: {type: string}}
protocol: {type: object, properties: {acp: {type: integer}, runtime_api: {type: integer}}}
'400': {description: invalid_request 或 invalid_scope}
'401': {description: connection_expired 或 OAuth 失效}
'403': {$ref: '#/components/responses/ResourceError403'}
'404': {description: device_not_found}
'409': {description: upgrade_required}
'429': {description: device_connection_limit 或 relay_overloaded}
'503': {description: device_offline 或 authorization_state_unavailable}
/api/v1/endpoints/{machine_id}/proxy/terminal:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
get:
summary: 通过设备数据通道附着远程终端
description: '远程执行中转启用时默认提供终端入口,并发布布尔 features.terminal_ws=true,无需终端专用环境变量。必须提供 monkeyai.terminal.v1 业务子协议,票据通过 monkeyai.token.<ticket> 或 Bearer 传递;双来源必须一致,拒绝重复凭据、额外业务子协议和未知查询参数。要求 session:control,observe 亦然。复用签名访问断言及实时租约,固定上游 Host device.internal、路径 /terminal。安装版允许 app://monkeyai,开发来源沿精确白名单。每数据隧道共享 15 条常规数据流(终端最多 8 条),另留 1 条候选;候选累计 5 秒内须转入常规,否则关闭。101 后透明转发,不启动或关闭 shell。详见 design/remote-terminal-backend.md。'
security:
- RuntimeTicket: []
parameters:
- name: reattach
in: query
required: false
description: 仅接受恰好一个值为 1 的参数;申请候选预算,不证明替换合法性。
schema: {type: string, const: '1'}
responses:
'101':
description: 执行端成功升级,回选 monkeyai.terminal.v1;不返回 token 子协议、Cookie 或压缩扩展。
headers:
Sec-WebSocket-Protocol: {schema: {type: string, const: monkeyai.terminal.v1}}
Cache-Control: {schema: {type: string, const: no-store}}
'400': {description: invalid_request;执行端非 101 错误按实际状态及内容类型透传}
'401': {description: connection_expired}
'403': {description: permission_denied 或 device_revoked}
'404': {description: not_found,远程执行中转未启用或路径未知}
'429': {description: terminal_limit_reached;执行端亦可返回 access_limit_reached}
'503': {description: device_offline、authorization_state_unavailable 或执行端 terminal_unavailable}
/api/v1/endpoints/{machine_id}/proxy/{path}:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
- {name: path, in: path, required: true, schema: {type: string}, description: 'ACP、cap/{server}/mcp、uploads/* 或 files/{grant}/* 白名单目标'}
get:
summary: 转发 WebSocket、MCP SSE 或获准文件
description: ticket Bearer 或 monkeyai.v1 与 monkeyai.token.<ticket> WebSocket 子协议;中转消费票据,只转发 monkeyai.v1。安装版允许 app://monkeyai,开发 Origin 通过 MONKEYAI_RUNTIME_DESKTOP_ORIGINS 显式配置;业务 Host 为 device.internal。文件另外要求限定 grant。不接受 OAuth token 替代 ticket,已转发 JSON-RPC 错误保留原格式。
security:
- RuntimeTicket: []
responses:
'101': {description: ACP WebSocket 升级}
'200': {description: 目标原始响应,流式转发}
'206': {description: 文件 Range 响应}
'401': {description: connection_expired}
'403': {description: permission_denied}
'503': {description: device_offline 或 authorization_state_unavailable}
post:
summary: 转发会话、配置、交互、资源写入或 MCP 请求
description: /read/session 要求 session:read;/read/config 要求 resources:manage;/read/interaction 要求 session:control;/write/resource 同时要求 resources:manage 和 session:read。/cap/{server}/mcp 要求 files:read。正文等待响应头 150 秒,资源写入 225 秒。
security:
- RuntimeTicket: []
responses:
'200': {description: 目标原始响应,不自动重放写入}
'401': {description: connection_expired}
'403': {description: permission_denied}
'503': {description: device_offline 或 authorization_state_unavailable}
put:
summary: 流式写入目标上传槽位
security:
- RuntimeTicket: []
responses:
'200': {description: 目标原始响应,最大 64 MiB}
'413': {description: 上传超出限额}
'503': {description: 目标或授权不可用}
head:
summary: 探测文件或上传 offset
security:
- RuntimeTicket: []
responses:
'200': {description: 目标响应头}
'503': {description: 目标或授权不可用}
delete:
summary: 关闭 MCP 会话
security:
- RuntimeTicket: []
responses:
'200': {description: 目标原始响应}
'503': {description: 目标或授权不可用}
/endpoints/{machine_id}/files/{grant}/{path}:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
- {name: grant, in: path, required: true, schema: {type: string}, description: 设备 Ed25519 签名的限定文件授权,不写入入口日志}
- {name: path, in: path, required: true, schema: {type: string}}
get:
summary: 在独立文件 origin 下载获准文件
description: 验证配置的 Host、完整设备归属、签名、路径、版本和期限;共享域强制下载,不执行 HTML。
security: []
responses:
'200': {description: 流式文件,attachment、sandbox、nosniff、no-referrer}
'206': {description: Range 响应}
'403': {description: 文件授权无效}
'503': {description: 目标或授权不可用}
head:
summary: 查询获准文件响应头
security: []
responses:
'200': {description: 文件响应头}
'403': {description: 文件授权无效}
'503': {description: 目标或授权不可用}
/api/v1/endpoints/connect:
get:
summary: 建立原生客户端端点桥接 WebSocket
description: >-
仅接受 OAuth Bearer access token,不接受 Cookie 或 URL token。
非空 Origin 必须匹配 MONKEYAI_PUBLIC_URL;HTTP 使用 WS,HTTPS 使用 WSS。
Upgrade 后 5 秒内发送 hello,服务端依次发送 welcome、directory.snapshot。
使用协议主版本 1,UTF-8 JSON 文本消息最大 256 KiB(含分片累计),禁用压缩。
request/response/event 信封及关闭码详见 design/endpoint-bridge-design.md。
4003 需恢复 OAuth 凭据,4001/4002 不自动重连;断线不得自动重发业务消息。
responses:
'101': {description: WebSocket 升级成功}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/ResourceError403'}
'429':
description: 当前用户建连过于频繁,遵循 Retry-After 退避
headers:
Retry-After: {schema: {type: integer}}
content:
application/json:
schema: {$ref: '#/components/schemas/ResourceError'}
'503': {$ref: '#/components/responses/EndpointUnavailable'}
/api/v1/endpoints/{machine_id}:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
delete:
summary: 移除远程执行登记
description: 要求 device:manage;仅按 machine_id 撤销当前用户的远程登记,无需请求体。远程设备目录不再返回该设备。托管保留登录、公钥、网关密钥和已受理任务;重复删除幂等,其他用户统一 404。
responses:
'204': {description: 远程授权已撤销}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/ResourceError403'}
'404': {description: device_not_found}
'503': {description: authorization_state_unavailable}
put:
summary: 登记或更新当前用户的设备元数据
description: 不依赖会话上报开关;不会恢复已撤销端点;设备数量不设上限,仍受登记频率限制。
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
required: [device_name, platform, os_version, arch, client_version]
properties:
device_name: {type: string, maxLength: 128}
platform: {type: string, minLength: 1, maxLength: 64, description: 客户端上报的平台名称,最多 64 个 UTF-8 字节,不限制固定枚举。}
os_version: {type: string, maxLength: 64}
arch: {type: string, maxLength: 32}
client_version: {type: string, maxLength: 64}
protocol_version: {type: [integer, 'null']}
client_type: {type: [string, 'null']}
client_name: {type: [string, 'null']}
channel: {type: [string, 'null']}
locale: {type: [string, 'null']}
system_locale: {type: [string, 'null']}
timezone: {type: [string, 'null']}
runtime_version: {type: [string, 'null']}
engine_version: {type: [string, 'null']}
electron_version: {type: [string, 'null']}
responses:
'200': {$ref: '#/components/responses/EndpointResult'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'409': {description: endpoint_revoked}
'429': {description: 设备登记每用户每小时最多一百次,遵守 Retry-After}
'503': {$ref: '#/components/responses/EndpointUnavailable'}
get:
summary: 读取当前用户的单个端点
responses:
'200': {$ref: '#/components/responses/EndpointResult'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'404': {$ref: '#/components/responses/ResourceError404'}
'503': {$ref: '#/components/responses/EndpointUnavailable'}
patch:
summary: 修改端点别名
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
required: [alias]
properties:
alias:
type: [string, 'null']
description: null 清除别名;非空白文本最多 128 UTF-8 字节,拒绝控制字符
responses:
'200': {$ref: '#/components/responses/EndpointResult'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'404': {$ref: '#/components/responses/ResourceError404'}
'503': {$ref: '#/components/responses/EndpointUnavailable'}
/api/v1/endpoints/{machine_id}/revoke:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
post:
summary: 停用端点并断开连接
description: 幂等,不接受请求体。已验证执行设备要求 device:manage,并同步撤销新远程访问;保留托管安装登录,恢复远程访问需新证明。
responses:
'200': {$ref: '#/components/responses/EndpointResult'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'404': {$ref: '#/components/responses/ResourceError404'}
'503': {$ref: '#/components/responses/EndpointUnavailable'}
/api/v1/endpoints/{machine_id}/restore:
parameters:
- {$ref: '#/components/parameters/EndpointMachine'}
post:
summary: 恢复已停用端点
description: 幂等,不接受请求体。不主动建立连接;设备数量不设上限。该入口不恢复新远程执行开关。
responses:
'200': {$ref: '#/components/responses/EndpointResult'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'404': {$ref: '#/components/responses/ResourceError404'}
'503': {$ref: '#/components/responses/EndpointUnavailable'}
/oauth/connectors/{id}/callback:
get:
summary: 处理指定 MCP 的 OAuth 回调
description: 校验 MCP id 与 state 绑定、有效期及配置版本,单次消费授权事务并在服务端交换和保存 Token。无需浏览器会话或 Agent Token。
security: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: state
in: query
required: true
schema:
type: string
- name: code
in: query
description: 授权成功时返回的授权码。
schema:
type: string
- name: error
in: query
description: 授权拒绝或取消时返回的错误码。
schema:
type: string
responses:
'200':
description: 凭证已保存,浏览器显示授权成功页面。
content:
text/html:
schema:
type: string
'400':
$ref: '#/components/responses/ResourceError400'
'409':
$ref: '#/components/responses/ResourceError409'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
/api/auth/v1/methods:
get:
summary: 读取公开登录方式开关
security: []
responses:
"200":
description: 仅包含登录开关,不包含 SMTP 或 OAuth 密钥
content:
application/json:
schema:
$ref: "#/components/schemas/EmailLoginMethods"
"503":
description: 认证配置不可用
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
/api/auth/v1/branding:
get:
summary: 读取公开品牌信息
description: 公开返回团队名称、产品名称、授权机器码及有效商业授权标记。仅宿主确认合法且当前有效的付费授权时标记为 true;未配置校验器或读取失败时为 false。不会返回授权文件、客户信息、席位、有效期或密钥。
security: []
responses:
"200":
description: 公开品牌信息
content:
application/json:
schema:
type: object
required:
- workspace_name
- product_name
- logo_url
- machine_code
- has_commercial_license
additionalProperties: false
properties:
workspace_name:
type: string
description: 团队名称。
product_name:
type: string
description: 工具名称。
logo_url:
type: string
description: admin 页面使用的自定义 Logo 绝对 URL,未设置时为空字符串;不下发至 Agent settings。
machine_code:
type: string
description: 与管理员付费授权页面相同的授权机器码;宿主未提供时为空字符串,不是统计实例 ID。
has_commercial_license:
type: boolean
description: 是否已导入通过现有付费授权校验且当前有效的商业授权。缺失、无效、过期或无法确认时为 false。
/api/auth/v1/branding/logo:
get:
summary: 读取公开品牌 Logo
description: 无需登录,返回当前 Logo,统一为 PNG;支持 ETag 条件请求。未设置或存储不可用时返回 404,页面回退默认图片。
security: []
parameters:
- in: query
name: v
schema:
type: string
description: branding.logo_url 中的图片版本。
responses:
"200":
description: 当前品牌 Logo
content:
image/png:
schema:
type: string
format: binary
"304":
description: Logo 未变化
"404":
description: 没有可用的自定义 Logo
/api/auth/v1/email/code:
post:
summary: 发送邮箱验证码
description: login 受 email_code_enabled 控制;reset 受 password_enabled 控制。每邮箱每分钟最多 1 次、每小时最多 10 次,每连接来源 IP 每小时最多 30
次;失败发送也计入限额。开启 email_code_auto_registration_enabled 时,新邮箱可获取 login 验证码;
未开启自动注册的未知邮箱、停用或不符合用途的账号返回相同成功响应但不发送邮件。
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- purpose
properties:
email: &a1
type: string
format: email
maxLength: 254
description: 邮箱会去除首尾空白并转为小写。
purpose:
type: string
enum:
- login
- reset
responses:
"200":
description: 操作成功
content:
application/json:
schema:
type: object
required:
- message
- retry_after
properties:
message:
type: string
retry_after:
type: integer
const: 30
"400":
description: 请求无效,或验证码无效、过期、超过错误次数限制
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"401":
description: 邮箱密码不匹配或账号不符合登录入口角色
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"403":
description: 对应登录方式或注册开关关闭
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"409":
description: 邮箱已存在,注册冲突
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"429":
description: 验证码发送过于频繁
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
headers:
Retry-After:
schema:
type: integer
const: 60
"500":
description: 认证操作失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"502":
description: 邮件发送失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"503":
description: 认证配置或邮件服务不可用
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
/api/auth/v1/email/reset-password:
post:
summary: 通过邮箱验证码重置密码
description: 使用 reset 用途验证码,需要开启密码登录。重置后撤销全部旧浏览器会话、OAuth token
和未使用授权码,并使现有登录验证码失效。不会自动登录。
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- code
- password
properties:
email: *a1
code: &a2
type: string
pattern: ^[0-9]{6}$
description: 十分钟内有效的六位数字验证码,仅可使用一次。
password: &a3
type: string
minLength: 12
maxLength: 1024
writeOnly: true
description: 新密码至少 12 个字符,长度按 UTF-8 字节校验。
responses:
"200":
description: 操作成功
content:
application/json:
schema:
type: object
required:
- reset
properties:
reset:
type: boolean
const: true
"400":
description: 请求无效,或验证码无效、过期、超过错误次数限制
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"401":
description: 邮箱密码不匹配或账号不符合登录入口角色
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"403":
description: 对应登录方式或注册开关关闭
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"409":
description: 邮箱已存在,注册冲突
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"429":
description: 验证码发送过于频繁
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
headers:
Retry-After:
schema:
type: integer
const: 60
"500":
description: 认证操作失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"502":
description: 邮件发送失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"503":
description: 认证配置或邮件服务不可用
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
/api/auth/v1/login:
post:
summary: 使用密码登录客户端
description: 需要开启 password_enabled,允许启用状态的普通用户和管理员;成功设置 HttpOnly、SameSite=Lax 会话
Cookie,HTTPS 环境附加 Secure。
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- password
properties:
email: *a1
password:
type: string
maxLength: 1024
writeOnly: true
responses:
"200":
description: 操作成功
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthUser"
headers:
Set-Cookie:
schema:
type: string
description: monkeyai_session 会话 Cookie,默认有效期 7 天。
"400":
description: 请求无效,或验证码无效、过期、超过错误次数限制
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"401":
description: 邮箱密码不匹配或账号不符合登录入口角色
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"403":
description: 对应登录方式或注册开关关闭
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"409":
description: 邮箱已存在,注册冲突
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"429":
description: 验证码发送过于频繁
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
headers:
Retry-After:
schema:
type: integer
const: 60
"500":
description: 认证操作失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"502":
description: 邮件发送失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"503":
description: 认证配置或邮件服务不可用
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
/api/auth/v1/email/login:
post:
summary: 使用邮箱验证码登录客户端
description: 需要开启 email_code_enabled,使用 login
用途验证码。允许启用状态的普通用户和管理员,成功建立浏览器会话;验证码最多允许 5 次错误尝试。
开启 email_code_auto_registration_enabled 时,新邮箱验证成功后自动创建无密码的普通账号并登录;
默认姓名为邮箱。提交验证码时重新检查开关,已有停用账号不能自动创建或登录。
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- code
properties:
email: *a1
code: *a2
responses:
"200":
description: 操作成功
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthUser"
headers:
Set-Cookie:
schema:
type: string
description: monkeyai_session 会话 Cookie,默认有效期 7 天。
"400":
description: 请求无效,或验证码无效、过期、超过错误次数限制
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"401":
description: 邮箱密码不匹配或账号不符合登录入口角色
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"403":
description: 对应登录方式或注册开关关闭
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"409":
description: 邮箱已存在,注册冲突
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"429":
description: 验证码发送过于频繁
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
headers:
Retry-After:
schema:
type: integer
const: 60
"500":
description: 认证操作失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"502":
description: 邮件发送失败
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
"503":
description: 认证配置或邮件服务不可用
content:
application/json:
schema:
$ref: "#/components/schemas/EmailAuthError"
/api/v1/billing/account:
get:
summary: 查询当前用户积分状态
description: 使用 Bearer access token 确定用户,返回当前周期额度、余额及可用积分(等于余额);冻结字段为兼容旧客户端保留,迁移后为零;周期到期后按最新额度创建新账户。余额和可用积分可能为负数,不应截断为零。
responses:
'200':
description: 请求成功
content:
application/json:
schema:
$ref: '#/components/schemas/CreditAccount'
'400':
description: 参数不合法
'401':
description: 未登录
'403':
description: 权限不足
'409':
description: 修订号、幂等键或交易状态冲突
/api/v1/billing/entries:
get:
summary: 分页查询当前用户积分消耗历史
description: 仅返回当前 Bearer access token 所属用户的扣费和退款记录,不包含额度发放、重置或管理员调整;默认查询所有周期,按发生时间、记录 ID 倒序排列。用户身份由服务端确定,不支持指定其他用户或分组,不返回内部元数据。
parameters:
- in: query
name: page
schema:
type: integer
minimum: 1
maximum: 100000
default: 1
- in: query
name: page_size
schema:
type: integer
minimum: 1
maximum: 100
default: 20
- in: query
name: content
description: 按消费项目名称模糊搜索。
schema:
type: string
maxLength: 200
- in: query
name: category
schema:
type: string
enum: [model, tool, image, video, environment, other]
- in: query
name: mode
schema:
type: string
enum: [local, remote]
- in: query
name: entry_type
description: 不指定时同时返回扣费和退款。
schema:
type: string
enum: [charge, refund]
- in: query
name: from
description: 起始时间(含),须携带时区。
schema:
type: string
format: date-time
- in: query
name: until
description: 结束时间(不含),须携带时区,且晚于起始时间。
schema:
type: string
format: date-time
responses:
'200':
description: 请求成功;无记录时 items 为 []。
content:
application/json:
schema:
$ref: '#/components/schemas/CreditEntriesResponse'
'400':
description: 搜索条件、时间范围或流水类型不合法
'401':
description: 缺少、无效或已过期的 access token
'500':
$ref: '#/components/responses/ResourceError500'
/mcp/connectors/{id}:
parameters:
- in: path
name: id
schema:
type: string
format: uuid
required: true
- in: header
name: MCP-Protocol-Version
description: 后续请求应携带握手协商的版本;未知版本返回 400。
schema:
type: string
enum:
- '2024-11-05'
- '2025-03-26'
- '2025-06-18'
- '2025-11-25'
post:
summary: 调用免认证连接的 MCP 网关
description: 仅用于免认证连接,使用全局 mcp:invoke API Key 认证用户并校验连接使用权。集中和独立认证必须改用具体凭证地址,省略凭证返回 400 credential_selection_required。
tools/list 和 tools/call 实时发现上游工具,使用上游原始工具名称,并叠加本地工具开关;没有开关记录时默认启用。
security:
- InvocationKey: []
parameters:
- in: header
name: Idempotency-Key
schema:
type: string
maxLength: 128
- in: header
name: X-Session-ID
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
jsonrpc:
const: '2.0'
id:
type:
- string
- number
description: 请求必须携带,通知省略;原值随响应返回。
method:
type: string
examples:
- initialize
- notifications/initialized
- ping
- tools/list
- tools/call
params:
type: object
description: tools/call 使用精确工具名称 name 和对象 arguments,保留 _meta 等扩展字段;tools/list 返回完整目录,不接受非空 cursor。
required:
- jsonrpc
- method
responses:
'200':
description: JSON-RPC 结果或协议错误
headers:
X-Billing-Transaction-ID:
schema:
type: string
format: uuid
X-Billing-Status:
schema:
type: string
enum:
- pending
content:
application/json:
schema:
type: object
properties:
jsonrpc:
const: '2.0'
id:
type:
- string
- number
- 'null'
result: {}
error:
type: object
properties:
code:
type: integer
message:
type: string
data: {}
required:
- code
- message
required:
- jsonrpc
- id
'202':
description: 已接收通知,响应体为空
'400':
description: 请求格式、参数或协议版本不合法
'401':
description: 调用密钥缺失、失效或没有 mcp:invoke 作用域
'402':
description: 积分不足
'403':
description: 请求来源、用户、会话或连接认证不允许调用
'404':
description: 连接不存在、已禁用或未获授权
'409':
description: 幂等键或交易状态冲突,不重复执行工具
headers:
X-Billing-Transaction-ID:
schema:
type: string
format: uuid
'413':
description: 请求体超过 1 MiB
'415':
description: 请求类型必须为 application/json
'502':
description: 上游连接或握手失败
get:
summary: 此无状态入口不提供 SSE 订阅
security:
- InvocationKey: []
responses:
'405':
description: 不支持此方法,Allow 为 POST
'401':
description: 调用密钥无效
'403':
description: 请求来源不允许
delete:
summary: 此无状态入口不维护下游 MCP 会话
security:
- InvocationKey: []
responses:
'405':
description: 不支持此方法,Allow 为 POST
'401':
description: 调用密钥无效
'403':
description: 请求来源不允许
/mcp/connectors/{id}/credentials/{credential_id}:
parameters:
- in: path
name: id
schema:
type: string
format: uuid
required: true
- in: header
name: MCP-Protocol-Version
description: 后续请求应携带握手协商的版本;未知版本返回 400。
schema:
type: string
enum:
- '2024-11-05'
- '2025-03-26'
- '2025-06-18'
- '2025-11-25'
- name: credential_id
in: path
required: true
schema:
type: string
format: uuid
post:
summary: 调用指定凭证的 MCP 网关
description: 使用全局 mcp:invoke API Key 认证用户;地址明确指定集中或独立凭证。每次请求校验用户的连接使用权、凭证与连接关系及当前状态,独立凭证必须属于调用用户。撤销的凭证地址不自动切换到新凭证。 tools/list
和 tools/call 实时发现上游工具,不读取目录缓存;保留各认证模式的历史工具 ID 和禁用配置,独立认证不新增工具配置,无认证/集中认证叠加本地单价,未配置默认启用。
security:
- InvocationKey: []
parameters:
- in: header
name: Idempotency-Key
schema:
type: string
maxLength: 128
- in: header
name: X-Session-ID
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
jsonrpc:
const: '2.0'
id:
type:
- string
- number
description: 请求必须携带,通知省略;原值随响应返回。
method:
type: string
examples:
- initialize
- notifications/initialized
- ping
- tools/list
- tools/call
params:
type: object
description: tools/call 使用精确工具名称 name 和对象 arguments,保留 _meta 等扩展字段;tools/list 返回完整目录,不接受非空 cursor。
required:
- jsonrpc
- method
responses:
'200':
description: JSON-RPC 结果或协议错误
headers:
X-Billing-Transaction-ID:
schema:
type: string
format: uuid
X-Billing-Status:
schema:
type: string
enum:
- pending
content:
application/json:
schema:
type: object
properties:
jsonrpc:
const: '2.0'
id:
type:
- string
- number
- 'null'
result: {}
error:
type: object
properties:
code:
type: integer
message:
type: string
data: {}
required:
- code
- message
required:
- jsonrpc
- id
'202':
description: 已接收通知,响应体为空
'400':
description: 请求格式、参数或协议版本不合法
'401':
description: 调用密钥缺失、失效或没有 mcp:invoke 作用域
'402':
description: 积分不足
'403':
description: 请求来源、用户、会话或连接认证不允许调用
'404':
description: 连接不存在、已禁用或未获授权
'409':
description: 幂等键或交易状态冲突,不重复执行工具
headers:
X-Billing-Transaction-ID:
schema:
type: string
format: uuid
'413':
description: 请求体超过 1 MiB
'415':
description: 请求类型必须为 application/json
'502':
description: 上游连接或握手失败
get:
summary: 此无状态入口不提供 SSE 订阅
security:
- InvocationKey: []
responses:
'405':
description: 不支持此方法,Allow 为 POST
'401':
description: 调用密钥无效
'403':
description: 请求来源不允许
delete:
summary: 此无状态入口不维护下游 MCP 会话
security:
- InvocationKey: []
responses:
'405':
description: 不支持此方法,Allow 为 POST
'401':
description: 调用密钥无效
'403':
description: 请求来源不允许
/api/v1/groups:
get:
summary: 列出或搜索可分享的分组
description: 未提供 q 时返回全部未删除分组及虚拟根组;提供非空 q 时按名称不区分大小写进行字面子串匹配,返回未删除分组及名称匹配的虚拟根组,不包含成员信息。根组名称来自 branding.workspace_name,搜索时优先返回且计入 limit。分享给父组可覆盖后代组成员;分享给根组覆盖系统全体用户,包括后续新增用户。
parameters:
- in: query
name: q
schema: {type: string}
description: 可选的分组名称搜索关键词;省略或去除首尾空白后为空时返回全部分组。
- in: query
name: limit
schema: {type: integer, minimum: 1, maximum: 100, default: 20}
description: 搜索时返回的最多分组数。
responses:
'200':
description: 分组列表。
content:
application/json:
schema: {$ref: '#/components/schemas/SearchGroupsResponse'}
'400': {$ref: '#/components/responses/BadRequest'}
'401': {$ref: '#/components/responses/Unauthorized'}
'500': {$ref: '#/components/responses/InternalError'}
/api/v1/users:
get:
summary: 按用户名或邮箱查找分享接收用户
description: 不区分大小写的字面子串匹配,仅返回有效用户,排除当前用户。用户名对应用户的 name 字段。按名称和 ID 排序,最多返回 limit 项;结果过多时请细化关键词。
parameters:
- in: query
name: q
required: true
schema:
type: string
minLength: 1
maxLength: 200
description: 去除首尾空白后长度为 1—200 字节。
- in: query
name: limit
schema:
type: integer
minimum: 1
maximum: 100
default: 20
responses:
'200':
description: 匹配的用户简要信息。
content:
application/json:
schema:
$ref: '#/components/schemas/SearchUsersResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/models/tags:
get:
summary: 列出当前用户可用模型配置的标签
responses:
'200':
description: 去重后的标签列表。
content:
application/json:
schema:
$ref: '#/components/schemas/AgentTagsResponse'
/api/v1/models:
get:
summary: 读取 Agent 模型目录
description: 仅包含启用的系统授权模型、自有模型和收到分享的模型,同时返回模型代理地址与鉴权方式。版本只覆盖模型目录和代理信息。
parameters:
- $ref: '#/components/parameters/IfNoneMatch'
- $ref: '#/components/parameters/AgentSearch'
- $ref: '#/components/parameters/AgentOwner'
- $ref: '#/components/parameters/AgentTagID'
- $ref: '#/components/parameters/AgentTagIDs'
- $ref: '#/components/parameters/AgentPage'
- $ref: '#/components/parameters/AgentPageSize'
responses:
'200':
description: 模型目录数据,不包含服务端密钥。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentModelsResponse'
'304':
$ref: '#/components/responses/NotModified'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
post:
summary: 创建当前用户的个人模型
description: 所有者由登录身份确定。创建时 api_key 必填,积分倍率由服务端设为 1,初始仅本人可用。
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateUserModelInput'
responses:
'201':
description: 创建成功,密钥原文不返回。
content:
application/json:
schema:
$ref: '#/components/schemas/UserModel'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
/api/v1/models/{modelID}:
parameters:
- in: path
name: modelID
required: true
schema:
type: string
format: uuid
get:
summary: 读取自己的模型以供编辑
description: 系统模型或他人模型均返回 404。已禁用的自有模型仍可读取。
responses:
'200':
description: 模型配置,不包含密钥原文。
content:
application/json:
schema:
$ref: '#/components/schemas/UserModel'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
put:
summary: 修改自己的模型
description: 完整替换可编辑配置。api_key 省略或为空时保留原密钥;已有分享、启用状态和积分倍率保持不变。
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserModelInput'
responses:
'200':
description: 修改成功。
content:
application/json:
schema:
$ref: '#/components/schemas/UserModel'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
delete:
summary: 删除自己的模型
description: 软删除并在同一事务内清除分享授权,后续配置下发和代理调用立即不可用。
responses:
'204':
description: 删除成功,无响应体。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
/api/v1/resources/shares:
post:
summary: 批量分享自己的资源给指定用户或分组
description: 支持 model、rule、skill、connector、expert、kb;个人规则共享后接收者可选择使用,但不能强制应用。个人 Connector 的接收方使用自己的独立凭证。分享个人专家时,其所有者持有的个人 skill、connector 自动随专家授予只读使用权限,新增或移除依赖即时生效;规则、系统资源及他人资源仍需单独授权,不允许借专家转分享。个人知识库分享可指定 access_level=read_only 或 read_write,读写包含内容删除,不包含转授权。省略权限的新授权默认只读,重复分享保留已有权限;明确权限可更新对应主体的权限。每批资源 1—100 项,用户与分组 ID 合计 1—100 项;任一资源非本人所有、任一接收用户无效或分组不存在时整批回滚。禁止直接分享给自己,不允许接收方转分享。组授权覆盖其后代组成员并随成员关系变化即时生效;全零 UUID 根组表示全员授权,包括后续新增用户;个人知识库不允许新增全员分享,历史全员分享可保留或撤销。
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ShareResourcesInput'
responses:
'204':
description: 整批分享成功,无响应体。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
delete:
summary: 批量撤销指定用户或分组的资源分享
description: 仅所有者可以撤销。只移除本批指定资源与用户或分组间的直接授权,不影响其他用户/分组的授权;专家分享撤销后,其依赖的继承权限一并失效,但保留依赖自身及其他专家授予的使用权限。不存在的授权视为成功,允许撤销已停用或已删除的接收对象。任一资源无权操作则整批回滚。
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ShareResourcesInput'
responses:
'204':
description: 整批撤销成功,无响应体。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
/api/v1/settings:
get:
summary: 读取 Agent 设置
description: 只返回此类资源,独立计算版本;每次请求重新检查当前用户身份和资源权限。
parameters:
- $ref: '#/components/parameters/IfNoneMatch'
responses:
'200':
description: 设置数据,不包含服务端密钥。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentSettingsResponse'
'304':
$ref: '#/components/responses/NotModified'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/rules:
get:
summary: 读取 Agent 规则
description: 仅返回系统授权规则、当前用户创建及分享给当前用户的个人规则;共享的个人规则不能强制应用。独立计算版本,每次请求重新检查当前用户身份和资源权限。
parameters:
- $ref: '#/components/parameters/IfNoneMatch'
- $ref: '#/components/parameters/AgentSearch'
- $ref: '#/components/parameters/AgentOwner'
- $ref: '#/components/parameters/AgentPage'
- $ref: '#/components/parameters/AgentPageSize'
responses:
'200':
description: 规则数据,不包含服务端密钥。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentRulesResponse'
'304':
$ref: '#/components/responses/NotModified'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
post:
summary: 创建当前用户的个人规则
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserRuleInput'
responses:
'201':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/RuleResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'500':
$ref: '#/components/responses/ResourceError500'
description: 归属固定为当前用户;个人规则可分享给指定用户使用,但仅创建者可读取详情、编辑、删除及管理分享。
/api/v1/skills/tags:
get:
summary: 列出当前用户可用技能配置的标签
responses:
'200':
description: 去重后的标签列表。
content:
application/json:
schema:
$ref: '#/components/schemas/AgentTagsResponse'
/api/v1/skills:
get:
summary: 读取 Agent 技能
description: 只返回此类资源,独立计算版本;每次请求重新检查当前用户身份和资源权限。
parameters:
- $ref: '#/components/parameters/IfNoneMatch'
- $ref: '#/components/parameters/AgentSearch'
- $ref: '#/components/parameters/AgentOwner'
- $ref: '#/components/parameters/AgentTagID'
- $ref: '#/components/parameters/AgentTagIDs'
- $ref: '#/components/parameters/AgentPage'
- $ref: '#/components/parameters/AgentPageSize'
responses:
'200':
description: 技能数据,不包含服务端密钥。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentSkillsResponse'
'304':
$ref: '#/components/responses/NotModified'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
post:
summary: 上传 ZIP 创建个人技能
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
package:
type: string
format: binary
description: 最多 500 MiB ZIP,解包最多 1 GiB。
metadata:
type: string
description: 可选 JSON 对象字符串,仅 tag_ids 可写;名称、描述和包信息以服务端解析 SKILL.md 的结果为准。
required:
- package
responses:
'201':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/SkillResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'500':
$ref: '#/components/responses/ResourceError500'
description: 技能包最多 500 MiB,解包最多 1 GiB。归属固定为当前用户;初始启用,上传元数据不能配置授权、归属或存储路径。
/api/v1/experts/tags:
get:
summary: 列出当前用户可用专家配置的标签
responses:
'200':
description: 去重后的标签列表。
content:
application/json:
schema:
$ref: '#/components/schemas/AgentTagsResponse'
/api/v1/experts/avatar-support:
get:
summary: 查询个人专家头像写入能力
description: 客户端在提交 avatar 字段前查询;version 为 1 表示支持 JSON data URL 与 null 移除,available 表示已配置头像存储。响应不可缓存。
responses:
'200':
description: 当前头像写入能力。
content:
application/json:
schema:
type: object
required: [version, available]
properties:
version:
type: integer
enum: [1]
available:
type: boolean
'401':
$ref: '#/components/responses/ResourceError401'
/api/v1/experts:
get:
summary: 读取 Agent 专家
description: 返回启用的系统授权专家、自有专家及收到分享的个人专家;包含归属与修订号,所有者可查看 shared_users。独立计算版本,每次请求重新检查身份和资源权限。
parameters:
- $ref: '#/components/parameters/IfNoneMatch'
- $ref: '#/components/parameters/AgentSearch'
- $ref: '#/components/parameters/AgentOwner'
- $ref: '#/components/parameters/AgentTagID'
- $ref: '#/components/parameters/AgentTagIDs'
- $ref: '#/components/parameters/AgentPage'
- $ref: '#/components/parameters/AgentPageSize'
responses:
'200':
description: 专家数据,不包含服务端密钥。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentExpertsResponse'
'304':
$ref: '#/components/responses/NotModified'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
post:
summary: 创建当前用户的个人专家
requestBody:
required: true
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/UserExpertInput'
- required:
- prompt
responses:
'201':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/ExpertResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'500':
$ref: '#/components/responses/ResourceError500'
'503':
description: 头像存储不可用,错误码 expert_avatar_unavailable。
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
description: 归属固定为当前用户,默认启用;仅允许关联自己可用的模型、规则、技能和连接。分享通过 /resources/shares 管理。avatar 随专家正文原子保存,头像无效或存储失败时不创建资源。
/api/v1/connectors/tags:
get:
summary: 列出当前用户可用连接器配置的标签
responses:
'200':
description: 去重后的标签列表。
content:
application/json:
schema:
$ref: '#/components/schemas/AgentTagsResponse'
/api/v1/connectors:
get:
summary: 读取 Agent 连接器
description: 只返回连接及凭证元数据,保留空 tools 数组及对应 tools_version(独立认证在内嵌凭证下返回),不发起远端工具查询(含内置知识库);ETag 不随远端工具变化。每次请求重新检查当前用户身份和资源权限。
parameters:
- $ref: '#/components/parameters/IfNoneMatch'
- $ref: '#/components/parameters/AgentSearch'
- $ref: '#/components/parameters/AgentOwner'
- $ref: '#/components/parameters/AgentTagID'
- $ref: '#/components/parameters/AgentTagIDs'
- $ref: '#/components/parameters/AgentPage'
- $ref: '#/components/parameters/AgentPageSize'
responses:
'200':
description: 连接器数据,不包含服务端密钥。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentConnectorsResponse'
'304':
$ref: '#/components/responses/NotModified'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
post:
summary: 创建当前用户的个人 Connector
requestBody:
required: true
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/UserConnectorInput'
required:
- name
- url
- authorization_mode
responses:
'201':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectorResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'500':
$ref: '#/components/responses/ResourceError500'
description: 直接配置 Connector 地址、认证方式和 OAuth 应用,不使用 Provider。个人连接仅支持 none / independent,凭证通过独立接口管理。
/api/v1/api-keys:
get:
summary: 查询当前用户的调用密钥
responses:
'200':
description: 当前用户的调用密钥元数据列表,不包含密钥原文。
content:
application/json:
schema:
$ref: '#/components/schemas/APIKeysResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
post:
summary: 创建调用密钥
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateAPIKeyInput'
responses:
'201':
description: 创建成功;api_key 原文只在本次响应中返回。
content:
application/json:
schema:
$ref: '#/components/schemas/CreatedAPIKey'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
/api/v1/api-keys/{keyID}:
parameters:
- $ref: '#/components/parameters/KeyID'
delete:
summary: 撤销调用密钥
responses:
'204':
description: 撤销成功,无响应体。
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/api-keys/{keyID}/rotate:
parameters:
- $ref: '#/components/parameters/KeyID'
post:
summary: 轮换调用密钥
description: 创建同名、同权限的新密钥并撤销原密钥。
responses:
'201':
description: 轮换成功;api_key 原文只在本次响应中返回。
content:
application/json:
schema:
$ref: '#/components/schemas/CreatedAPIKey'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/connectors/{id}/icon:
get:
summary: 按用户权限读取连接图标
responses:
'200':
description: 按用户权限读取连接图标
content:
image/png:
schema:
type: string
format: binary
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
put:
summary: 上传连接图标
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectorResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: If-Match
in: header
required: true
description: 上次读取返回的 ETag,例如 "1"。
schema:
type: string
- name: id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
icon:
type: string
format: binary
description: PNG/JPEG,最多 1 MiB,最多 4096×4096。
required:
- icon
description: 系统连接由管理员维护,个人连接由所有者维护;携带连接 If-Match。
/api/v1/experts/{id}/manifest:
get:
summary: 读取当前用户可用专家的完整清单
responses:
'200':
description: 读取当前用户可用专家的完整清单
content:
application/json:
schema:
$ref: '#/components/schemas/ExpertManifest'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
'304':
description: ETag 未变化
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/resources/resolve:
post:
summary: 解析专家、规则、技能与连接绑定
description: 返回兼容旧客户端的 tools 和 tools_version。工具读取选定认证上下文最近一次成功同步的目录,不访问上游;没有有效快照时返回空 tools。服务端保留权限、工具开关和单价规则,并应用专家工具允许/拒绝规则,拒绝规则优先。
responses:
'200':
description: 解析专家、规则、技能与连接绑定
content:
application/json:
schema:
$ref: '#/components/schemas/ExpertManifest'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ResolveResources'
/api/v1/experts/{id}/skills/{skillID}/package:
get:
summary: 按专家委托下载技能包
responses:
'200':
description: 按专家委托下载技能包
content:
application/zip:
schema:
type: string
format: binary
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: skillID
in: path
required: true
schema:
type: string
format: uuid
- name: sha256
in: query
schema:
type: string
description: 客户端清单记录的包摘要;与当前包不同返回 412。
/api/v1/connectors/{id}/test:
post:
summary: 执行真实 MCP 握手与全量工具发现
description: 独立认证必须使用包含 credential_id 的接口,否则返回 400 credential_selection_required。连接级工具适用于 none / centralized;集中测试仅限管理员。
responses:
'200':
description: 执行真实 MCP 握手与全量工具发现
content:
application/json:
schema:
type: object
properties:
connection_status:
type: string
tool_count:
type: integer
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/connectors/{id}/tools:
get:
summary: 实时读取认证上下文的工具目录
description: 每次请求远端 MCP 获取完整工具定义,失败直接返回错误,不回退数据库目录。无认证/集中认证叠加本地开关和单价,未配置时默认启用、单价为零;独立认证保留历史工具 ID 和启停配置,但不新增配置且单价固定为零。响应为 private, no-store。独立认证必须使用明确指定 credential_id 的接口,否则返回 400 credential_selection_required;始终校验连接和凭证的访问权限。
responses:
'200':
description: 读取认证上下文的工具目录
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/MCPTool'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/connectors/{id}/oauth/authorizations:
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
post:
summary: 添加命名 OAuth 凭证,每次成功新建
responses:
'200':
description: 成功;不返回凭证秘密。
content:
application/json:
schema:
$ref: '#/components/schemas/OAuthAuthorization'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorizationName'
/api/v1/connector-authorizations/{id}:
get:
summary: 查询本人发起的授权事务状态
description: 保存凭证后自动测试连接并发现工具,测试尝试完成后返回 succeeded 和 credential_id;测试失败不影响授权成功,结果记录在凭证测试状态中。
responses:
'200':
description: 查询本人发起的授权事务状态
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorizationStatus'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/skills/{id}/package:
get:
summary: 按当前权限下载技能包
responses:
'200':
description: 按当前权限下载技能包
content:
application/zip:
schema:
type: string
format: binary
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: sha256
in: query
schema:
type: string
description: 客户端清单记录的包摘要;与当前包不同返回 412。
put:
summary: 替换自己的个人技能 ZIP
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
package:
type: string
format: binary
description: 最多 500 MiB ZIP,解包最多 1 GiB。
metadata:
type: string
description: 可选 JSON 对象字符串,仅 tag_ids 可写;名称、描述和包信息以服务端解析 SKILL.md 的结果为准。
required:
- package
responses:
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'500':
$ref: '#/components/responses/ResourceError500'
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/SkillResource'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
description: 替换完整技能包,名称和描述以新 ZIP 的 SKILL.md 为准;保留既有分享和启用状态。
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
/api/v1/experts/{id}/avatar:
get:
summary: 读取有权访问的专家头像
description: 专家所有者或获授权用户可读取;无头像或无访问权限时返回 404。
parameters:
- $ref: '#/components/parameters/ResourceID'
responses:
'200':
description: 专家头像;按真实图片内容返回类型,使用私有缓存。
content:
image/png:
schema: {type: string, format: binary}
image/jpeg:
schema: {type: string, format: binary}
image/webp:
schema: {type: string, format: binary}
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
/api/v1/experts/{id}:
get:
summary: 读取自己的个人专家
parameters:
- $ref: '#/components/parameters/ResourceID'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/ExpertResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
put:
summary: 编辑自己的个人专家
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserExpertInput'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/ExpertResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'503':
description: 头像存储不可用,错误码 expert_avatar_unavailable。
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
description: name 必填。仅更新输入声明的业务字段;不能修改归属、启用状态或分享关系。avatar 省略保留原图、null 移除、data URL 替换,与正文使用同一次事务和 revision。必须携带最近详情响应的 ETag 作为 If-Match,分享变更也会递增 revision。
delete:
summary: 删除自己的个人专家
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
responses:
'204':
description: 资源已软删除,相关分享同步清理。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
/api/v1/rules/{id}:
get:
summary: 读取自己的个人规则
parameters:
- $ref: '#/components/parameters/ResourceID'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/RuleResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
put:
summary: 编辑自己的个人规则
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserRuleInput'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/RuleResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
description: name、content 必填。仅创建者可修改规则名称和正文,不能修改归属或授权。必须携带最近详情响应的 ETag 作为 If-Match。
delete:
summary: 删除自己的个人规则
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
responses:
'204':
description: 个人规则已软删除。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
/api/v1/skills/{id}:
get:
summary: 读取自己的个人技能
parameters:
- $ref: '#/components/parameters/ResourceID'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/SkillResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
put:
summary: 编辑自己的个人技能
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserSkillInput'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/SkillResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
description: name 必填。仅更新输入声明的业务字段;不能修改归属、启用状态或分享关系。必须携带最近详情响应的 ETag 作为 If-Match,分享变更也会递增 revision。 description、content
省略时保留原值;编辑后重写完整 ZIP,更新大小与摘要,保留附属文件。
delete:
summary: 删除自己的个人技能
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
responses:
'204':
description: 资源已软删除,相关分享同步清理。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
/api/v1/connectors/{id}:
get:
summary: 读取自己的个人 Connector
parameters:
- $ref: '#/components/parameters/ResourceID'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectorResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
put:
summary: 编辑自己的个人 Connector
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserConnectorInput'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectorResource'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
description: 直接编辑连接,携带连接 If-Match。关键配置变更递增 config_revision 并使旧凭证、目录和授权事务失效;Client Secret 轮换不使既有 Token 失效。
delete:
summary: 删除自己的个人 Connector
parameters:
- $ref: '#/components/parameters/ResourceID'
- $ref: '#/components/parameters/IfMatch'
responses:
'204':
description: 资源已软删除,相关分享同步清理。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
/api/v1/skills/{id}/manifest:
get:
summary: 读取自己的个人技能正文
parameters:
- $ref: '#/components/parameters/ResourceID'
responses:
'200':
description: 资源详情;仅资源所有者可编辑。
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/UserSkillManifest'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'404':
$ref: '#/components/responses/ResourceError404'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
/api/v1/connectors/{id}/credentials:
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
get:
summary: 列出当前用户的独立凭证
responses:
'200':
description: 成功;不返回凭证秘密。
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/ConnectorCredential'
required:
- items
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
post:
summary: 新增 HTTP Header 凭证并自动测试连接
description: 保存后由服务端自动发现工具并返回最新测试状态;测试失败仍保留凭证,可通过测试接口重试。
responses:
'201':
description: 成功;不返回凭证秘密。
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectorCredential'
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CredentialInput'
/api/v1/connectors/{id}/credentials/{credential_id}:
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: credential_id
in: path
required: true
schema:
type: string
format: uuid
get:
summary: 读取指定凭证元数据及 ETag
responses:
'200':
description: 成功;不返回凭证秘密。
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectorCredential'
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
patch:
summary: 改名或整组替换 Header
description: 替换 Header 后自动测试连接与工具发现,不保存工具目录;仅改名不触发测试。
responses:
'200':
description: 成功;不返回凭证秘密。
content:
application/json:
schema:
$ref: '#/components/schemas/ConnectorCredential'
headers:
ETag:
$ref: '#/components/headers/RevisionETag'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CredentialPatch'
parameters:
- name: If-Match
in: header
required: true
schema:
type: string
description: 当前凭证 revision 的带双引号 ETag;冲突返回 412 revision_conflict。
delete:
summary: 本地撤销指定凭证并失效其工具目录
responses:
'204':
description: 操作成功。
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: If-Match
in: header
required: true
schema:
type: string
description: 当前凭证 revision 的带双引号 ETag;冲突返回 412 revision_conflict。
/api/v1/connectors/{id}/credentials/{credential_id}/oauth/authorizations:
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: credential_id
in: path
required: true
schema:
type: string
format: uuid
post:
summary: 重新授权指定凭证,成功后保持 ID 并失效原目录
responses:
'200':
description: 成功;不返回凭证秘密。
content:
application/json:
schema:
$ref: '#/components/schemas/OAuthAuthorization'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters:
- name: If-Match
in: header
required: true
schema:
type: string
description: 当前凭证 revision 的带双引号 ETag;冲突返回 412 revision_conflict。
/api/v1/connectors/{id}/credentials/{credential_id}/test:
post:
summary: 执行真实 MCP 握手与全量工具发现
description: 操作明确指定的凭证上下文;校验连接、凭证、当前用户和配置版本。管理端工具只读上下文允许查看系统连接用户工具,不能代用户测试。
responses:
'200':
description: 执行真实 MCP 握手与全量工具发现
content:
application/json:
schema:
type: object
properties:
connection_status:
type: string
tool_count:
type: integer
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: credential_id
in: path
required: true
schema:
type: string
format: uuid
/api/v1/connectors/{id}/credentials/{credential_id}/tools:
get:
summary: 实时读取认证上下文的工具目录
description: 每次请求远端 MCP 获取完整工具定义,失败直接返回错误,不回退数据库目录。无认证/集中认证叠加本地开关和单价,未配置时默认启用、单价为零;独立认证保留历史工具 ID 和启停配置,但不新增配置且单价固定为零。响应为 private, no-store。独立认证必须使用明确指定 credential_id 的接口,否则返回 400 credential_selection_required;始终校验连接和凭证的访问权限。
responses:
'200':
description: 读取认证上下文的工具目录
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/MCPTool'
'400':
$ref: '#/components/responses/ResourceError400'
'401':
$ref: '#/components/responses/ResourceError401'
'403':
$ref: '#/components/responses/ResourceError403'
'404':
$ref: '#/components/responses/ResourceError404'
'409':
$ref: '#/components/responses/ResourceError409'
'412':
$ref: '#/components/responses/ResourceError412'
'428':
$ref: '#/components/responses/ResourceError428'
'500':
$ref: '#/components/responses/ResourceError500'
'502':
$ref: '#/components/responses/ResourceError502'
parameters: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: credential_id
in: path
required: true
schema:
type: string
format: uuid
/v1/images/inputs:
post:
summary: 上传当前用户的生图参考图片
description: 调用密钥需要 model:invoke 权限;仅接受一张不超过 16 MiB 的 PNG/JPEG。
security: [{ModelInvocationKey: []}, {ModelApiKey: []}]
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [file]
properties:
file: {type: string, format: binary}
responses:
'201':
description: 用户专属文件,24 小时内可用于生图任务
content:
application/json:
schema: {$ref: '#/components/schemas/ImageInputFile'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
/v1/images/generations:
post:
summary: 创建生图任务
description: 原生异步接口,返回任务 ID;不与 OpenAI Images 同路径同步语义兼容。
security: [{ModelInvocationKey: []}, {ModelApiKey: []}]
parameters:
- {name: Idempotency-Key, in: header, schema: {type: string, maxLength: 128}}
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ImageGenerateInput'}
responses:
'202':
description: 任务已受理,客户端用任务 ID 查询结果
content:
application/json:
schema: {$ref: '#/components/schemas/ImageTask'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'409': {$ref: '#/components/responses/ResourceError409'}
/v1/images/edits:
post:
summary: 创建图片编辑任务
description: 仅模型原生支持编辑时开放;images 引用此前上传的原图。
security: [{ModelInvocationKey: []}, {ModelApiKey: []}]
parameters:
- {name: Idempotency-Key, in: header, schema: {type: string, maxLength: 128}}
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ImageEditInput'}
responses:
'202':
description: 编辑任务已受理
content:
application/json:
schema: {$ref: '#/components/schemas/ImageTask'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'409': {$ref: '#/components/responses/ResourceError409'}
/v1/images/tasks/{id}:
get:
summary: 查询当前用户的生图任务
description: 返回本地任务状态、图片访问地址与用量;结果图片到期后返回 expired 状态。
security: [{ModelInvocationKey: []}, {ModelApiKey: []}]
parameters: [{name: id, in: path, required: true, schema: {type: string, format: uuid}}]
responses:
'200':
description: 当前用户的任务
content:
application/json:
schema: {$ref: '#/components/schemas/ImageTask'}
'401': {$ref: '#/components/responses/Unauthorized'}
'404': {$ref: '#/components/responses/ResourceError404'}
/v1/images/outputs/{id}:
get:
summary: 下载当前用户的生图结果
description: 需要调用密钥;图片到期或不属于当前用户时返回 404。
security: [{ModelInvocationKey: []}, {ModelApiKey: []}]
parameters: [{name: id, in: path, required: true, schema: {type: string, format: uuid}}]
responses:
'200':
description: 生图内容,仅返回 PNG、JPEG 或 WebP
content:
image/png: {schema: {type: string, format: binary}}
image/jpeg: {schema: {type: string, format: binary}}
image/webp: {schema: {type: string, format: binary}}
'401': {$ref: '#/components/responses/Unauthorized'}
'404': {$ref: '#/components/responses/ResourceError404'}
/api/v1/feedback:
post:
summary: 提交用户反馈
description: >-
使用 Agent OAuth access token 提交文字反馈和可选截图。请求使用 multipart/form-data,最多上传 3 张
PNG、JPEG 或 WebP 图片,单张最多 5 MiB,总请求最多 16 MiB。content 和 images 至少提供一项。
parameters:
- name: Idempotency-Key
in: header
required: false
description: 建议客户端为可重试请求提供;同一用户相同 Key 和请求内容只创建一条反馈。
schema: {type: string, maxLength: 128}
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/FeedbackMultipartInput'
responses:
'201':
description: 反馈已创建
content:
application/json:
schema:
$ref: '#/components/schemas/FeedbackSubmission'
'200':
description: 幂等键命中已有反馈
content:
application/json:
schema:
$ref: '#/components/schemas/FeedbackSubmission'
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/Unauthorized'}
'409': {$ref: '#/components/responses/ResourceError409'}
'500': {$ref: '#/components/responses/ResourceError500'}
/api/v1/kb:
get:
summary: 读取 Agent 知识库目录
description: 只返回启用且通过系统授权、用户归属或分享关系可用的知识库。支持 owner、q、标签筛选和分页;team 为系统知识库,mine 为本人创建的个人知识库,shared 为其他用户分享的个人知识库。列表返回所有者 user;共享用户和分组仅资源所有者可见。响应包含 capabilities 与 embedding_configured,能力由绑定的向量模型自动推导;未配置向量模型时仍完整支持 lexical 检索。
parameters:
- $ref: '#/components/parameters/IfNoneMatch'
- $ref: '#/components/parameters/AgentSearch'
- $ref: '#/components/parameters/AgentOwner'
- $ref: '#/components/parameters/AgentTagID'
- $ref: '#/components/parameters/AgentTagIDs'
- $ref: '#/components/parameters/AgentPage'
- $ref: '#/components/parameters/AgentPageSize'
responses:
'200':
description: 知识库目录数据。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
content:
application/json:
schema:
$ref: '#/components/schemas/AgentKnowledgeBasesResponse'
'304': {$ref: '#/components/responses/NotModified'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'500': {$ref: '#/components/responses/ResourceError500'}
post:
summary: 创建当前用户的个人知识库
description: 归属固定为当前用户,创建后默认启用。后端自动选择可用的系统 embedding 模型,有可用模型时支持混合检索,否则仅使用全文检索;无需指定向量模型。可配置 fusion_config 和 tag_ids。分享通过 /resources/shares 管理,type 为 kb。
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/KbUserInput'}
multipart/form-data:
schema:
type: object
required: [metadata, avatar]
properties:
metadata:
type: string
description: JSON 字符串,字段与 application/json 请求一致。
avatar:
type: string
format: binary
description: 必须且仅上传一个 PNG、JPEG 或 WebP 图片文件,最多 1 MiB;不修改图标时使用 application/json。
encoding:
metadata: {contentType: application/json}
avatar: {contentType: 'image/png, image/jpeg, image/webp'}
responses:
'201':
description: 个人知识库已创建
headers:
ETag: {$ref: '#/components/headers/RevisionETag'}
Cache-Control: {$ref: '#/components/headers/CacheControl'}
content:
application/json:
schema: {$ref: '#/components/schemas/KbDetail'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'500': {$ref: '#/components/responses/ResourceError500'}
/api/v1/kb/tags:
get:
summary: 列出当前用户可用知识库的标签
responses:
'200':
description: 去重后的标签列表。
content:
application/json:
schema:
$ref: '#/components/schemas/AgentTagsResponse'
/api/v1/kb/search:
post:
summary: 检索可访问知识库分片
description: 与 MCP kb_search 共用同一底层逻辑,仅检索 kb_ids 中当前用户可访问且已有学习完成文档的知识库;省略 kb_ids 时检索全部符合条件的可访问知识库。绑定可用向量模型的知识库自动执行 lexical+vector weighted RRF;未绑定时仅执行 lexical;向量通道运行时失败时降级为 lexical。
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/KbSearchInput'}
responses:
'200':
description: 检索响应,包含实际通道、融合参数、降级与告警
content:
application/json:
schema: {$ref: '#/components/schemas/KbSearchResponse'}
'400': {description: 参数无效,控制面错误信封}
'401': {description: 未登录,控制面错误信封}
/api/v1/kb/{id}/images/upload:
parameters: [{$ref: '#/components/parameters/ResourceID'}]
post:
summary: 上传知识库正文图片
description: 需要 OAuth access token 及启用知识库的正文写权限,支持个人库所有者或拥有 read_write 授权的成员;只有阅读权限时返回 403,无访问权限时返回 404。 使用 multipart/form-data 的 file 字段上传一张图片,最多 32 MiB、2500 万像素,支持 PNG、JPEG、GIF、WebP;按真实内容完整解码校验,拒绝 SVG。图片按知识库和内容摘要存入对象存储,不新增关联表。返回的 url 及 markdown 可写入文档正文,读取时仍检查当前权限。此操作不创建或修改文档。
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [file]
properties:
file: {type: string, format: binary}
responses:
'201':
description: 图片已保存;重复上传相同图片返回同一知识库内的相同地址。
content:
application/json:
schema:
type: object
required: [name, url, mime_type, size_bytes, markdown]
properties:
name: {type: string, description: 内容摘要加真实图片扩展名}
url: {type: string, description: 受权限保护的 /api/kb/<id>/assets/<name> 相对地址}
mime_type: {type: string, enum: [image/png, image/jpeg, image/gif, image/webp]}
size_bytes: {type: integer, minimum: 1, maximum: 33554432}
markdown: {type: string, description: 可直接插入正文的 Markdown 图片语法}
'400': {description: 无效图片、文件超限或 multipart 字段不合法}
'401': {description: 未登录或凭证失效}
'403': {description: 无正文写权限或非管理员调用管理端接口}
'404': {description: 知识库不存在或不可访问}
'409': {description: 知识库不允许编辑}
'503': {description: 未配置知识库对象存储}
/api/v1/kb/{id}/avatar:
parameters: [{$ref: '#/components/parameters/ResourceID'}]
get:
summary: 读取知识库图标
description: 需要登录且拥有目标知识库读取权限;撤销权限后不能继续读取。返回 PNG、JPEG 或 WebP 原图;不公开对象存储地址。
responses:
'200':
description: 知识库图标
content:
image/png:
schema: {type: string, format: binary}
image/jpeg:
schema: {type: string, format: binary}
image/webp:
schema: {type: string, format: binary}
'401': {$ref: '#/components/responses/ResourceError401'}
'404': {$ref: '#/components/responses/ResourceError404'}
/api/v1/kb/{id}:
parameters: [{$ref: '#/components/parameters/ResourceID'}]
get:
summary: 读取可访问的知识库
description: 返回知识库详情。所有者可读取 grants、shared_users 和 shared_groups;被分享者只能读取知识库本身和所有者信息。
responses:
'200':
description: 知识库详情
headers:
ETag: {$ref: '#/components/headers/RevisionETag'}
Cache-Control: {$ref: '#/components/headers/CacheControl'}
content:
application/json:
schema: {$ref: '#/components/schemas/KbDetail'}
'401': {description: 未登录,控制面错误信封}
'404': {description: 不存在或无权访问,控制面错误信封}
put:
summary: 更新当前用户拥有的个人知识库
description: 仅知识库所有者可以更新。可修改名称、描述、标签和 fusion_config;向量能力由绑定的向量模型自动推导。变更 embedding 绑定必须使用管理端专用接口。必须携带最近详情响应的 ETag 作为 If-Match。
parameters:
- $ref: '#/components/parameters/IfMatch'
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/KbUserInput'}
multipart/form-data:
schema:
type: object
required: [metadata, avatar]
properties:
metadata:
type: string
description: JSON 字符串,字段与 application/json 请求一致。
avatar:
type: string
format: binary
description: 必须且仅上传一个 PNG、JPEG 或 WebP 图片文件,最多 1 MiB;不修改图标时使用 application/json。
encoding:
metadata: {contentType: application/json}
avatar: {contentType: 'image/png, image/jpeg, image/webp'}
responses:
'200':
description: 更新后的知识库详情
headers:
ETag: {$ref: '#/components/headers/RevisionETag'}
Cache-Control: {$ref: '#/components/headers/CacheControl'}
content:
application/json:
schema: {$ref: '#/components/schemas/KbDetail'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'404': {$ref: '#/components/responses/ResourceError404'}
'412': {$ref: '#/components/responses/ResourceError412'}
'428': {$ref: '#/components/responses/ResourceError428'}
'500': {$ref: '#/components/responses/ResourceError500'}
delete:
summary: 删除当前用户拥有的个人知识库
description: 硬删除知识库及其文档、分片、学习任务、授权和标签;系统知识库及其他用户的知识库返回 404。必须携带最近详情响应的 ETag 作为 If-Match。
parameters:
- $ref: '#/components/parameters/IfMatch'
responses:
'204': {description: 个人知识库已删除}
'401': {$ref: '#/components/responses/ResourceError401'}
'404': {$ref: '#/components/responses/ResourceError404'}
'412': {$ref: '#/components/responses/ResourceError412'}
'428': {$ref: '#/components/responses/ResourceError428'}
'500': {$ref: '#/components/responses/ResourceError500'}
/api/v1/kb/permissions/list:
get:
summary: 查询本人个人知识库的授权清单
description: 仅个人库所有者可调用;读写成员及系统库均不能通过此入口管理授权。每个人或组是一条独立记录。
parameters:
- {name: kb_id, in: query, required: true, schema: {type: string, format: uuid}}
responses:
'200':
description: 授权清单与知识库版本
headers:
ETag: {$ref: '#/components/headers/RevisionETag'}
content:
application/json:
schema: {$ref: '#/components/schemas/KbGrantsResponse'}
'401': {$ref: '#/components/responses/ResourceError401'}
'404': {$ref: '#/components/responses/ResourceError404'}
/api/v1/kb/permissions/update:
put:
summary: 更新本人个人知识库的授权清单
description: 仅所有者可修改;以知识库现有 revision 进行并发控制。差异更新保留授权记录标识,省略现有主体的 access_level 时保留原权限,新主体默认只读。未包含的旧主体授权被移除;重复主体、非法权限及新增全员授权返回 400。
parameters:
- $ref: '#/components/parameters/IfMatch'
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [kb_id, grants]
properties:
kb_id: {type: string, format: uuid}
grants: {type: array, items: {$ref: '#/components/schemas/ResourceGrant'}}
responses:
'200':
description: 更新后的授权清单与知识库版本
headers:
ETag: {$ref: '#/components/headers/RevisionETag'}
content:
application/json:
schema: {$ref: '#/components/schemas/KbGrantsResponse'}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'404': {$ref: '#/components/responses/ResourceError404'}
'412': {$ref: '#/components/responses/ResourceError412'}
'428': {$ref: '#/components/responses/ResourceError428'}
/api/v1/kb/documents/restudy:
post:
summary: 重新学习有读写权限的知识库文档
description: 个人库所有者或读写成员可调用;支持系统库,文件夹不允许学习。ids 去重后最多 200 项。先检查全部文档归属;逐项返回 succeeded/failed,文件夹失败不影响其他文档。
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [kb_id, ids]
properties:
kb_id: {type: string, format: uuid}
ids: {type: array, minItems: 1, maxItems: 200, items: {type: string, format: uuid}}
responses:
'202': {description: 已接受文档学习, content: {application/json: {schema: {$ref: '#/components/schemas/KbDocumentOperationResult'}}}}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'403': {description: 仅有只读权限}
'404': {$ref: '#/components/responses/ResourceError404'}
/api/v1/kb/{id}/documents:
parameters: [{$ref: '#/components/parameters/ResourceID'}]
get:
summary: 查询当前用户可访问的知识库文档
description: 返回当前用户有权限的系统或个人知识库文档。系统知识库需同时具备系统资源使用资格及知识库授权;个人知识库允许所有者或明确分享给当前用户的用户读取。支持分页,并可按标题或文件名、学习状态和来源类型筛选;列表不返回正文。
parameters:
- $ref: '#/components/parameters/AgentPage'
- $ref: '#/components/parameters/AgentPageSize'
- name: q
in: query
description: 按文档标题或文件名做不区分大小写的包含匹配。
schema: {type: string}
- name: status
in: query
description: 按文档学习状态筛选。
schema: {type: string, enum: [pending, learning, learned, failed]}
- name: source_type
in: query
description: 按文档来源类型筛选。
schema: {type: string, enum: [text, file, url]}
responses:
'200':
description: 文档列表
content:
application/json:
schema:
type: object
required: [items, total_count, page, page_size]
properties:
items: {type: array, items: {$ref: '#/components/schemas/KbDocumentSummary'}}
total_count: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1, maximum: 100}
'400': {description: 分页、状态或来源类型参数无效,控制面错误信封}
'401': {description: 未登录,控制面错误信封}
'404': {description: 不存在或无权访问,控制面错误信封}
post:
summary: 向当前用户可写的知识库新增文档
description: 个人库所有者或具有读写权限的成员可新增文档,支持系统库和共享个人库。文档创建后进入学习队列,响应返回 status=pending,不等待切分、全文索引和向量化完成。
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/KbDocumentCreateInput'}
responses:
'202': {description: '文档已创建并入队学习', content: {application/json: {schema: {$ref: '#/components/schemas/KbDocument'}}}}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'403': {description: 仅有只读权限}
'404': {$ref: '#/components/responses/ResourceError404'}
'500': {$ref: '#/components/responses/ResourceError500'}
/api/v1/kb/{id}/documents/delete:
parameters: [{$ref: '#/components/parameters/ResourceID'}]
post:
summary: 删除知识库文档或文件夹(支持多个 ID)
description: ids 去重后最多 200 项,文件夹删除覆盖子树。协作写入须逐项提供 expected_revisions,全部归属与版本校验通过后执行。
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/KbDocumentDeleteInput'}
responses:
'200': {description: 操作结果, content: {application/json: {schema: {$ref: '#/components/schemas/KbDocumentOperationResult'}}}}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'403': {description: 无写入权限}
'404': {$ref: '#/components/responses/ResourceError404'}
'412': {description: 文档版本已变化}
'428': {description: 缺少文档版本}
/api/v1/kb/{id}/documents/move:
parameters:
- $ref: '#/components/parameters/ResourceID'
post:
summary: 移动当前用户可写的知识库文档树节点
description: 个人库所有者或具有读写权限的成员可移动文件夹或文档。协作写入需提供 expected_revisions。parent_id 为空表示根节点,prev_id 和 next_id 用于同级排序。
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/KbDocumentMoveInput'}
responses:
'200': {description: '节点已移动', content: {application/json: {schema: {$ref: '#/components/schemas/KbDocumentOperationResult'}}}}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'403': {description: 仅有只读权限}
'412': {description: 文档版本已变化}
'428': {description: 缺少文档版本}
'404': {$ref: '#/components/responses/ResourceError404'}
/api/v1/kb/{id}/documents/{documentId}:
parameters:
- $ref: '#/components/parameters/ResourceID'
- name: documentId
in: path
required: true
schema: {type: string, format: uuid}
get:
summary: 读取当前用户可访问的知识库文档详情
description: 返回当前用户有权限的系统或个人知识库文档。系统知识库按只读或读写授权使用;个人知识库允许所有者或明确分享给当前用户的用户读取正文。
responses:
'200': {description: '文档详情', content: {application/json: {schema: {$ref: '#/components/schemas/KbDocument'}}}}
'401': {$ref: '#/components/responses/ResourceError401'}
'404': {$ref: '#/components/responses/ResourceError404'}
put:
parameters:
- name: If-Match
in: header
schema: {type: string}
description: 文档 revision,加双引号;协作删除必填,协作更新可改用正文 expected_revision。
summary: 更新当前用户可写的知识库文档
description: 个人库所有者或具有读写权限的成员可更新;协作写入需提供 expected_revision 或 If-Match,版本冲突返回 412,缺失返回 428,只读返回 403。更新后取消旧学习任务并重新入队,响应返回 status=pending;文档必须属于路径中的知识库。
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/KbDocumentUpdateInput'}
responses:
'202': {description: '文档已更新并重新入队', content: {application/json: {schema: {$ref: '#/components/schemas/KbDocument'}}}}
'400': {$ref: '#/components/responses/ResourceError400'}
'401': {$ref: '#/components/responses/ResourceError401'}
'404': {$ref: '#/components/responses/ResourceError404'}
'403': {description: 仅有只读权限}
'412': {description: 文档版本已变化}
'428': {description: 缺少文档版本}
'500': {$ref: '#/components/responses/ResourceError500'}
/mcp/kb:
post:
summary: 百智办公知识库 MCP
description: 使用含 mcp:invoke 的全局 API Key。无状态 streamable HTTP JSON-RPC;支持 initialize、ping、tools/list、tools/call。工具为 kb_list、kb_list_documents、kb_get_document、kb_create_document、kb_update_document、kb_delete_document、kb_search。kb_list 支持 owner、q、标签和分页,返回与 GET /api/v1/kb 一致的 knowledge_bases、user、total_count、page、page_size 和 version;kb_list_documents 支持分页、标题或文件名搜索、学习状态和来源类型筛选。文档读取工具支持当前用户有权限的系统或个人知识库;文档写入允许个人库所有者或目标库的读写成员,不能管理授权或删除整个库。MCP 协作更新/删除须传 expected_revision。
security: [{InvocationKey: []}]
parameters:
- {name: MCP-Protocol-Version, in: header, required: false, schema: {type: string, enum: ['2024-11-05', '2025-03-26', '2025-06-18', '2025-11-25']}}
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [jsonrpc, id, method]
properties:
jsonrpc: {type: string, enum: ['2.0']}
id: {type: [string, integer, 'null']}
method: {type: string, enum: [initialize, ping, 'tools/list', 'tools/call']}
params: {type: object, additionalProperties: true}
responses:
'200':
description: JSON-RPC 响应;tools/call 同时提供 content[0].text JSON 与 structuredContent。
content:
application/json:
schema:
type: object
required: [jsonrpc, id]
properties:
jsonrpc: {type: string, enum: ['2.0']}
id: {type: [string, integer, 'null']}
result: {type: object, additionalProperties: true}
error:
type: object
properties:
code: {type: integer}
message: {type: string}
data: {}
'202': {description: JSON-RPC 通知已接收}
'401': {description: 缺少、无效或缺少 mcp:invoke scope 的调用密钥}
'415': {description: 请求不是 application/json}
components:
securitySchemes:
DesignMediaBearer:
type: http
scheme: bearer
bearerFormat: JWT
description: 仅aud=monkeyai-design-media,不能使用Agent access token或hub JWT
DesignMediaQuery:
type: apiKey
in: query
name: token
description: 短期本地媒体JWT;存在Authorization时优先使用它且失败不降级
RuntimeTicket:
type: http
scheme: bearer
description: 只允许指定目标设备和批准业务权限的短期票据;WebSocket 使用 monkeyai.v1 与 monkeyai.token.<ticket> 子协议。
BrowserSession:
type: apiKey
in: cookie
name: monkeyai_session
description: 浏览器登录会话;新增 scope 确认同时要求绑定申请的 CSRF token。
ModelInvocationKey:
type: http
scheme: bearer
description: 带 model:invoke 权限的长期调用密钥。
ModelApiKey:
type: apiKey
in: header
name: X-Api-Key
description: 同一调用密钥,优先于 Authorization Bearer。
InvocationKey:
type: http
scheme: bearer
description: 含 mcp:invoke 的长期调用密钥。
OAuthAccessToken:
type: http
scheme: bearer
bearerFormat: OAuth 2.0 access token
description: Agent 登录授权流程签发的短期 access token。
parameters:
PairingID:
name: pairingID
in: path
required: true
description: 创建接口返回的规范小写 UUID
schema: {type: string, format: uuid}
EndpointMachine:
name: machine_id
in: path
required: true
description: 规范小写、带连字符的 UUIDv4,仅限当前用户端点
schema: {type: string, format: uuid}
ResourceID:
name: id
in: path
required: true
schema:
type: string
format: uuid
IfMatch:
name: If-Match
in: header
required: true
description: 最近详情响应中的修订号 ETag,例如 "1";缺省返回 428,已过期返回 412。
schema:
type: string
IfNoneMatch:
in: header
name: If-None-Match
description: 此接口上一次响应的 ETag;当前用户可见内容未变化时返回 304。
schema:
type: string
AgentSearch:
name: q
in: query
description: 按名称或描述做不区分大小写的包含匹配;模型与规则没有描述字段,仅匹配名称。与 owner、标签组合后再分页,total_count 为筛选后的总数。
schema: {type: string}
AgentOwner:
name: owner
in: query
description: 资源归属筛选。team 为系统资源;mine 为本人创建的个人资源;shared 为其他用户分享给当前用户的个人资源。
schema: {type: string, enum: [all, team, mine, shared], default: all}
AgentTagID:
name: tag_id
in: query
description: 单标签筛选,兼容旧调用;与 tag_ids 同时传入时匹配任一标签。
schema: {type: string, format: uuid}
AgentTagIDs:
name: tag_ids
in: query
style: form
explode: true
description: 多标签筛选,可重复传入或以逗号分隔;匹配任一标签(OR),不重复返回资源,total_count 为筛选后总数。
schema:
type: array
items: {type: string, format: uuid}
AgentPage:
name: page
in: query
schema: {type: integer, minimum: 1, default: 1, maximum: 1000000}
AgentPageSize:
name: page_size
in: query
schema: {type: integer, minimum: 1, maximum: 100, default: 20}
KeyID:
in: path
name: keyID
required: true
description: 调用密钥 UUID。
schema:
type: string
format: uuid
headers:
RevisionETag:
description: 资源修订号,以双引号包围,例如 "1";创建、编辑、分享、撤销分享及删除都会更新修订号。
schema:
type: string
ETag:
description: 当前接口响应内容的稳定 SHA-256 版本,以双引号包围。
schema:
type: string
CacheControl:
description: 按用户隔离缓存,每次使用前重新验证。
schema:
type: string
const: private, no-cache
responses:
PairingInvalidRequest:
description: invalid_request,请求体格式、设备信息或 PKCE challenge 无效
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
PairingUnauthorized:
description: invalid_token(缺少、无效或过期的 Bearer)或 unauthorized(事务内复核发现登录已失效)
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
PairingForbidden:
description: permission_denied,缺少 device:manage 或使用执行设备授权访问控制端接口
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
PairingNotFound:
description: pairing_not_found(不存在、非法 ID、非创建者、join secret 不符或 join 已过期)或 pairing_unavailable(设备授权未启用)
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
PairingRateLimited:
description: rate_limited,每 IP 每分钟最多 60 次,遵守 Retry-After
headers:
<<: *pairingNoStore
Retry-After: {description: 重试等待秒数, schema: {type: string, const: '60'}}
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
PairingServerError:
description: server_error,数据库或事务失败,操作未确认成功
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
PairingServiceUnavailable:
description: service_unavailable,入口认证服务暂不可用
headers: *pairingNoStore
content:
application/json:
schema: {$ref: '#/components/schemas/PairingError'}
EndpointResult:
description: 当前端点资料,时间为 Unix 毫秒
headers:
Cache-Control: {schema: {type: string, const: 'private, no-store'}}
content:
application/json:
schema: {$ref: '#/components/schemas/Endpoint'}
EndpointUnavailable:
description: 认证或存储暂不可用、连接数超限,或服务正在停止
content:
application/json:
schema: {$ref: '#/components/schemas/ResourceError'}
NotModified:
description: 当前接口内容未变化,无响应体。
headers:
ETag:
$ref: '#/components/headers/ETag'
Cache-Control:
$ref: '#/components/headers/CacheControl'
ResourceError400:
description: 字段或关联无效
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError401:
description: 需要登录
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError403:
description: 无权操作
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError404:
description: 资源不存在或无权访问
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError409:
description: 名称或引用冲突
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError412:
description: 修订或技能包摘要已变化
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError428:
description: 缺少 If-Match
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError500:
description: 读取或保存失败
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
ResourceError502:
description: 上游连接失败
content:
application/json:
schema:
$ref: '#/components/schemas/ResourceError'
BadRequest:
description: 请求参数或请求体无效。
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
Unauthorized:
description: 缺少 access token,或 token 无效、已过期。
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
NotFound:
description: 指定资源不存在或不属于当前用户。
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
InternalError:
description: 服务内部错误。
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
schemas:
PairingError:
type: object
additionalProperties: false
required: [error]
properties:
error:
type: object
additionalProperties: false
required: [code, message]
properties:
code: {type: string, enum: [invalid_request, invalid_token, unauthorized, permission_denied, pairing_not_found, pairing_unavailable, pairing_already_joined, pairing_expired, pairing_resolved, invalid_user_code, rate_limited, server_error, service_unavailable], description: 具体错误码,以各端点响应说明为准}
message: {type: string, description: 面向用户的错误说明,不含敏感凭据}
OAuthError:
type: object
additionalProperties: false
required: [error, error_description]
properties:
error: {type: string, enum: [invalid_grant, invalid_client, invalid_request, authorization_pending, slow_down, access_denied, expired_token, unsupported_grant_type, server_error], description: OAuth 标准或配对授权错误码}
error_description: {type: string, description: 不含敏感凭据的错误说明}
EnvironmentUsage:
type: object
description: 当前实例最近一次 Docker CPU/内存采样;只存最新值,不保存历史。采集失败或旧 engine 可省略,不能将缺失视为零。超过 90 秒的样本应标记过期。
required: [at]
properties:
at: {type: string, format: date-time}
cpu_cores:
type: number
minimum: 0
maximum: 1048576
description: CPU 使用核数,1 表示占满一个逻辑核;展示百分比时除以配置核数。
memory_bytes:
type: integer
format: int64
minimum: 0
description: Docker 内存使用量,排除 inactive file 缓存;包含 gVisor 沙箱开销。
additionalProperties: false
EnvironmentBillingPricing:
type: object
required: [cpu_credits_per_core_hour, memory_credits_per_gib_hour]
properties:
cpu_credits_per_core_hour:
$ref: '#/components/schemas/CreditAmount'
memory_credits_per_gib_hour:
$ref: '#/components/schemas/CreditAmount'
EnvironmentBillingBudget:
type: object
required: [balance, hourly_credits, remaining_seconds, running_environments, low_balance]
description: 当前用户已预付运行环境的合计费率;remaining_seconds为最近的已付费到期时间距离现在的秒数,不含余额可购买的时长。
properties:
balance:
$ref: '#/components/schemas/CreditAmount'
hourly_credits:
$ref: '#/components/schemas/CreditAmount'
remaining_seconds:
type: [integer, 'null']
format: int64
minimum: 0
running_environments:
type: integer
minimum: 0
low_balance:
type: boolean
description: 当前可用余额不足以按已付费小时的单价再续付全部运行环境一小时;不影响已购买小时的有效期。
EnvironmentBilling:
type: object
required: [state, hourly_credits, settled_credits, settled_seconds]
properties:
state:
type: string
description: CPU 和内存单价均为零时为 free,不影响历史结算记录。
enum: [free, waiting, running, stopped, unknown]
hourly_credits:
$ref: '#/components/schemas/CreditAmount'
settled_credits:
$ref: '#/components/schemas/CreditAmount'
settled_seconds: {type: integer, format: int64, minimum: 0, description: 累计已付费时长;新增预付记录每笔3600秒,包含尚未使用时间及历史按秒结算时长}
prepaid_until: {type: string, format: date-time, description: 最近购买小时的到期时间;停止不退款,期限内重启不重复扣费}
stop_reason:
type: string
enum: [insufficient_credits, billing_unavailable]
budget:
$ref: '#/components/schemas/EnvironmentBillingBudget'
Environment:
type: object
required:
- machine_id
- runtime_ready
- connectable
- stale
- id
- user_id
- host_id
- name
- generation
- instance_id
- desired
- phase
- observed_generation
- observed_at
- reason
- storage_retained
- workload_verified
- spec
- created_at
- deleted_at
properties:
billing:
$ref: '#/components/schemas/EnvironmentBilling'
billing_stop_reason:
type: string
enum: [insufficient_credits, billing_unavailable]
runtime_version:
type: string
description: 最近一次宿主上报的 runtime 版本,未知为空。
usage_stale:
type: boolean
description: 最新资源样本超过 90 秒;由服务端计算,不能当作当前实时值。
usage:
$ref: '#/components/schemas/EnvironmentUsage'
machine_id:
type: [string, 'null']
format: uuid
runtime_ready:
type: boolean
connectable:
type: boolean
stale:
type: boolean
id:
type: string
format: uuid
user_id:
type: string
format: uuid
host_id:
type: string
format: uuid
name:
type: string
generation:
type: integer
format: int64
minimum: 1
instance_id:
type: string
format: uuid
desired:
type: string
enum:
- running
- stopped
- deleted
phase:
type: string
enum:
- pending
- preparing
- starting
- running
- stopping
- stopped
- deleting
- deleted
- failed
observed_generation:
type: integer
format: int64
minimum: 0
observed_at:
type:
- string
- 'null'
format: date-time
reason:
type: string
enum:
- ''
- apply_failed
- inspect_failed
- process_exited
- local_state_conflict
- runtime_failed
- runtime_upgrade_failed
storage_retained:
type: boolean
const: true
workload_verified:
type: boolean
const: false
spec:
$ref: host.yaml#/components/schemas/EnvironmentSpec
created_at:
type: string
format: date-time
archived_at:
type: string
format: date-time
description: 已从使用列表移除但仍待宿主清理的归档时间;仅在此状态存在,不代表宿主已删除。
deleted_at:
type: [string, 'null']
format: date-time
description: 宿主确认当前代次删除完成的时间;未完成或失败时为 null。已删除详情和幂等操作回执仍可查询。
description: phase 是最后一次观察结果,判断当前目标是否完成必须同时检查 observed_generation == generation。running 仅表示容器进程运行,connectable 还要求当前代次观测、有效设备授权及中转双通道在线。
EnvironmentRuntimeUpgrade:
type: object
required: [generation, request_key]
properties:
generation: {type: integer, format: int64, minimum: 1}
request_key: {type: string, minLength: 1, maxLength: 128}
version: {type: string, pattern: '^[0-9]{1,8}\.[0-9]{1,8}\.[0-9]{1,8}$'}
additionalProperties: false
EnvironmentRuntimeInfo:
type: object
required: [current_version, latest_version, update_available, can_update]
properties:
current_version: {type: string, description: 最近一次宿主上报的实际选择版本,未知为空。}
latest_version: {type: string, description: server 配置的发行版本,资源未配置或缺失时为空。}
target_version: {type: string}
update_available: {type: boolean}
can_update: {type: boolean}
reason: {type: string}
operation: {$ref: '#/components/schemas/EnvironmentOperation'}
EnvironmentOperation:
type: object
required:
- id
- environment_id
- generation
- desired
- status
- reason
- created_at
- finished_at
properties:
kind: {type: string, enum: [create, lifecycle, runtime_upgrade]}
target_version: {type: string, description: runtime 更新的固定目标版本。}
id:
type: string
format: uuid
environment_id:
type: string
format: uuid
generation:
type: integer
format: int64
minimum: 1
desired:
type: string
enum:
- running
- stopped
- deleted
status:
type: string
enum:
- pending
- succeeded
- failed
- superseded
reason:
type: string
enum:
- ''
- apply_failed
- inspect_failed
- process_exited
- local_state_conflict
- runtime_failed
- runtime_upgrade_failed
created_at:
type: string
format: date-time
finished_at:
type:
- string
- 'null'
format: date-time
EnvironmentChange:
type: object
required:
- generation
- request_key
properties:
generation:
type: integer
format: int64
minimum: 1
request_key:
type: string
pattern: ^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$
additionalProperties: false
EnvironmentResult:
type: object
required:
- environment
- operation
properties:
environment:
$ref: '#/components/schemas/Environment'
operation:
$ref: '#/components/schemas/EnvironmentOperation'
EnvironmentError:
type: object
required:
- error
properties:
error:
type: object
required:
- message
properties:
code:
type: string
message:
type: string
EnvironmentList:
type: object
required:
- items
- page
- page_size
properties:
items:
type: array
items:
$ref: '#/components/schemas/Environment'
page:
type: integer
format: int64
minimum: 1
page_size:
type: integer
format: int64
minimum: 1
maximum: 100
EnvironmentOperationList:
type: object
required:
- items
- page
- page_size
properties:
items:
type: array
items:
$ref: '#/components/schemas/EnvironmentOperation'
page:
type: integer
format: int64
minimum: 1
page_size:
type: integer
format: int64
minimum: 1
maximum: 100
EnvironmentSpecification:
type: object
additionalProperties: false
required: [id, version, cpu_millis, memory_bytes]
properties:
id: {type: string, format: uuid, description: 稳定规格 ID,删除后不可复用}
version: {type: integer, format: int64, minimum: 1, description: CPU 或内存变化时递增;仅重排不变}
cpu_millis: {type: integer, format: int64, minimum: 100, maximum: 256000, description: CPU 毫核,1000 表示 1 核}
memory_bytes: {type: integer, format: int64, minimum: 268435456, maximum: 1099511627776, description: 内存字节;管理端显示 GB,按 1024³ 换算}
EnvironmentSpecificationCatalog:
type: object
additionalProperties: false
required: [revision, items]
properties:
revision: {type: integer, format: int64, minimum: 0, description: 整表版本,每次管理端成功保存后递增}
items:
type: array
maxItems: 100
items: {$ref: '#/components/schemas/EnvironmentSpecification'}
EnvironmentHostOption:
type: object
required: [id, name, architecture, billing, available]
properties:
id: {type: string, format: uuid}
name: {type: string}
architecture: {type: string}
billing: {$ref: 'admin.yaml#/components/schemas/EnvironmentBillingConfig'}
available: {type: boolean}
reason: {type: string}
EnvironmentCreation:
type: object
required:
- name
- request_key
- specification_id
- specification_version
properties:
specification_id:
type: string
format: uuid
description: 从 environment-specifications 获取的有效规格 ID。
image_id:
type: string
format: uuid
description: 从 system-images 选定的镜像 ID,参与创建幂等校验。
specification_version:
type: integer
format: int64
minimum: 1
description: 用户选择时对应的规格版本;变化后需刷新并重新选择。
host_id:
type: string
format: uuid
description: 可选已授权宿主。省略时在有权限且就绪的宿主间调度;资源来自所选全局规格,价格来自全局计费配置,幂等键绑定宿主选择。
name:
type: string
minLength: 1
maxLength: 128
description: 名称最多 128 个 UTF-8 字节,不能有首尾空白或控制换行。
request_key:
type: string
pattern: ^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$
additionalProperties: false
DesignSnapshot:
type: object
required: [publisher_id, release_id, schema_version, digest_schema]
properties:
publisher_id: {type: string}
release_id: {type: string}
schema_version: {type: integer, const: 1}
digest_schema: {type: string, const: design-content-v1}
DesignConfig:
type: object
required: [schema_version, publisher_id, respub, monkeyai]
properties:
schema_version: {type: integer, const: 1}
publisher_id: {type: [string, 'null']}
respub:
type: [object, 'null']
properties: {base_url: {type: string, format: uri}}
monkeyai:
type: object
required: [base_url, available, snapshot]
properties:
base_url: {type: string, format: uri}
available: {type: boolean}
snapshot:
oneOf:
- {$ref: '#/components/schemas/DesignSnapshot'}
- {type: 'null'}
DesignEnvelope:
type: object
required: [code, message, data]
properties:
code: {type: [integer, string], description: 成功0,失败字符串错误码}
message: {type: string}
data: {}
DesignPage:
type: object
required: [items, total, page, page_size, total_pages, asset_snapshot_id]
properties:
items: {type: array, items: {$ref: '#/components/schemas/DesignEntry'}}
total: {type: integer}
page: {type: integer}
page_size: {type: integer}
total_pages: {type: integer}
asset_snapshot_id: {type: string}
DesignEntry:
type: object
required: [id, content_digest, asset_snapshot_id]
properties:
id: {type: string}
content_digest: {type: string}
asset_snapshot_id: {type: string}
skillPath: {type: string, description: 原始业务字段,保留摘要输入}
source_skill_path: {type: [string, 'null'], description: 仅模板详情;解析后的逻辑路径,跨项目互验待验收}
files:
type: array
items:
type: object
required: [path, sha256, size, mime]
properties:
path: {type: string}
sha256: {type: string}
size: {type: integer, minimum: 0}
mime: {type: string}
role: {type: string}
download:
type: [object, 'null']
properties: {url: {type: string, format: uri}}
download_url: {type: string, format: uri}
FeedbackMultipartInput:
type: object
additionalProperties: false
required: [category]
properties:
category:
type: string
enum: [bug, feature, experience, other]
content:
type: string
maxLength: 5000
rating:
type: integer
minimum: 1
maximum: 5
platform:
type: string
enum: [desktop, mobile, web, other]
default: other
client_version:
type: string
maxLength: 64
images:
type: array
maxItems: 3
items:
type: string
format: binary
description: PNG、JPEG 或 WebP 图片;单张最多 5 MiB。
FeedbackSubmission:
type: object
additionalProperties: false
required: [id, created_at, attachments]
properties:
id: {type: string, format: uuid}
created_at: {type: string, format: date-time}
attachments:
type: array
items:
$ref: '#/components/schemas/FeedbackAttachment'
FeedbackAttachment:
type: object
additionalProperties: false
required: [id, mime_type, byte_size, width, height, downloadable]
properties:
id: {type: string, format: uuid}
mime_type:
type: string
enum: [image/png, image/jpeg, image/webp]
byte_size: {type: integer, format: int64, minimum: 1}
width: {type: integer, minimum: 1}
height: {type: integer, minimum: 1}
downloadable: {type: boolean}
SessionSummary:
type: object
required: [id, machine_id, session_type, state_seq, host_revision, device_status, stale]
properties:
id: {type: string, format: uuid}
machine_id: {type: string, format: uuid}
session_type: {type: string}
parent_session_id: {type: [string, 'null'], format: uuid}
title: {type: string, description: 仅 full 策略返回}
title_source: {type: [string, 'null']}
state_seq: {type: integer, format: int64}
host_revision: {type: integer, format: int64}
started_at: {type: string, format: date-time}
last_active_at: {type: [string, 'null'], format: date-time}
reported_at: {type: [string, 'null'], format: date-time}
device_status: {type: string}
stale: {type: boolean}
RuntimeDirectory:
type: object
required: [items, total, page, page_size, version]
properties:
items:
type: array
items:
type: object
required: [machine_id, display_name, execution_supported, remote_access_state, status, protocols]
properties:
machine_id: {type: string, format: uuid}
display_name: {type: string}
platform: {type: string}
arch: {type: string}
execution_supported: {type: boolean}
remote_access_state: {type: string, enum: [disabled, enabled]}
deployment_mode: {type: string, enum: ['', desktop_managed, standalone]}
status: {type: string, enum: [online, offline, auth_required, draining, updating, incompatible]}
last_seen_at: {type: [string, 'null'], format: date-time}
runtime_version: {type: [string, 'null']}
engine_version: {type: [string, 'null']}
protocols: {type: object, additionalProperties: {type: array, items: {type: integer}}}
capability_summary: {type: object}
engine_health: {type: string}
boot_id: {type: string, format: uuid}
total: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1}
version: {type: string, minLength: 1}
Endpoint:
type: object
required: [machine_id, device_name, alias, display_name, platform, os_version, arch, client_version, protocol_version, status, online, created_at, updated_at, last_seen_at, revoked_at]
properties:
machine_id: {type: string, format: uuid}
device_name: {type: string}
alias: {type: [string, 'null']}
display_name: {type: string}
platform: {type: string, minLength: 1, maxLength: 64, description: 客户端上报的平台名称,最多 64 个 UTF-8 字节。}
os_version: {type: string}
arch: {type: string}
client_version: {type: string}
protocol_version: {type: integer, const: 1}
status: {type: string, enum: [active, revoked]}
online: {type: boolean}
created_at: {type: integer, format: int64}
updated_at: {type: integer, format: int64}
last_seen_at: {type: [integer, 'null'], format: int64}
revoked_at: {type: [integer, 'null'], format: int64}
UserRuleInput:
type: object
properties:
content:
type: string
name:
type: string
minLength: 1
maxLength: 200
required:
- name
- content
description: 仅声明的字段可由当前用户写入;归属、启用状态、授权和其他服务端字段忽略。
UserSkillInput:
type: object
properties:
name:
type: string
description:
type: string
description: 省略时保留原值。
content:
type: string
description: 省略时保留原值。
tag_ids:
type: array
items:
type: string
format: uuid
required:
- name
description: 仅声明的字段可由当前用户写入;归属、启用状态、授权和其他服务端字段忽略。
UserExpertInput:
type: object
properties:
avatar:
type: [string, 'null']
writeOnly: true
maxLength: 349551
description: 省略保留原头像,null 移除;字符串必须为 PNG、JPEG 或 WebP 的 base64 data URL,解码后不超过 256 KiB,宽高均不超过 512 像素。与客户端图片准备器保持一致;存储不可用返回 503 expert_avatar_unavailable,图片无效返回 400 expert_avatar_invalid,超限返回 400 expert_avatar_too_large。
tag_ids:
type: array
items: {type: string, format: uuid}
description:
type: string
prompt:
type: string
rule_ids:
type: array
items:
type: string
format: uuid
skill_ids:
type: array
items:
type: string
format: uuid
name:
type: string
minLength: 1
maxLength: 200
connectors:
type: array
items:
$ref: '#/components/schemas/ConnectorDependency'
required:
- name
UserConnectorInput:
type: object
properties:
tag_ids:
type: array
items: {type: string, format: uuid}
description:
type: string
name:
type: string
minLength: 1
maxLength: 200
url:
type: string
format: uri
authorization_mode:
type: string
enum:
- none
- independent
authorization_method:
type:
- string
- 'null'
enum:
- oauth
- http_header
- null
oauth_config:
$ref: '#/components/schemas/OAuthConnectionConfig'
oauth_client_secret:
type: string
writeOnly: true
description: 省略保留,空字符串清空;应用或端点变更时省略会清除旧 Secret。
required:
- name
description: 仅声明的字段可由当前用户写入;归属、启用状态、授权和其他服务端字段忽略。
UserSkillManifest:
type: object
required:
- name
- description
- content
- revision
properties:
name:
type: string
description:
type: string
content:
type: string
revision:
type: integer
EmailAuthError:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
properties:
code:
type: string
message:
type: string
EmailLoginMethods:
type: object
required:
- password_enabled
- email_code_enabled
- email_code_auto_registration_enabled
properties:
password_enabled:
type: boolean
description: 密码登录开关,未配置时默认 true,同时约束管理员和普通用户。
email_code_enabled:
type: boolean
description: 验证码登录开关,默认 false。
email_code_auto_registration_enabled:
type: boolean
description: 邮箱验证码自动注册开关,默认 false;开启后新邮箱通过验证码登录时自动创建普通账号。
EmailAuthUser:
type: object
required:
- id
- name
- email
- role
- status
- joined_at
properties:
id:
type: string
format: uuid
name:
type: string
email:
type: string
format: email
maxLength: 254
description: 邮箱会去除首尾空白并转为小写。
role:
type: string
enum:
- admin
- user
status:
type: string
enum:
- active
- disabled
joined_at:
type: string
format: date-time
avatar_url:
type: string
description: 最终展示头像,优先自定义头像,否则使用 OAuth 同步头像;均为空时省略。
last_login_at:
type: string
format: date-time
CreditAmount:
type: string
pattern: ^-?\d+(\.\d{1,6})?$
description: 十进制定点积分,最多六位小数。
CreditAccount:
type: object
properties:
version:
type: string
description: 当前账户的版本,随账本变更更新;用于管理员调整时检查并发及重复提交,历史账户条目可省略。
id:
type: string
format: uuid
user_id:
type: string
format: uuid
group_id:
type: string
format: uuid
period_start_at:
type: string
format: date-time
period_end_at:
type: string
format: date-time
balance:
$ref: '#/components/schemas/CreditAmount'
frozen:
$ref: '#/components/schemas/CreditAmount'
description: 兼容字段,迁移后为零。
available:
$ref: '#/components/schemas/CreditAmount'
quota:
$ref: '#/components/schemas/CreditAmount'
required:
- id
- user_id
- balance
- frozen
- available
- quota
- period_start_at
- period_end_at
CreditEntriesResponse:
type: object
required: [items, total, page, page_size]
properties:
items:
type: array
items:
$ref: '#/components/schemas/CreditConsumptionEntry'
total:
type: integer
format: int64
page:
type: integer
page_size:
type: integer
CreditConsumptionEntry:
type: object
additionalProperties: false
required: [id, transaction_id, entry_type, category, item_name, credit_delta, balance_after, mode, occurred_at]
properties:
id:
type: string
format: uuid
transaction_id:
type: [string, 'null']
format: uuid
entry_type:
type: string
enum: [charge, refund]
category:
type: string
enum: [model, tool, image, video, environment, other]
item_name:
type: string
credit_delta:
$ref: '#/components/schemas/CreditAmount'
description: 本条积分变动,扣费为负、退款为正。
balance_after:
$ref: '#/components/schemas/CreditAmount'
description: 本条发生后对应周期账户的余额,可能为负数。
mode:
type: string
enum: [local, remote]
occurred_at:
type: string
format: date-time
UserSummary:
type: object
required:
- id
- name
- email
properties:
id: &id006
type: string
format: uuid
name:
type: string
description: 用户名。
email:
type: string
format: email
GroupSummary:
type: object
required: [id, name, parent_id]
properties:
id: {type: string, format: uuid}
name: {type: string}
parent_id:
type: [string, 'null']
format: uuid
description: 顶层分组的父 ID 为全零 UUID 的虚拟根组 ID;根组自身为 null,可作为全员分享对象。
SearchGroupsResponse:
type: object
required: [groups]
properties:
groups:
type: array
items: {$ref: '#/components/schemas/GroupSummary'}
SearchUsersResponse:
type: object
required:
- users
properties:
users:
type: array
items:
$ref: '#/components/schemas/UserSummary'
AgentTagsResponse:
type: object
required: [version, tags]
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
tags:
type: array
items:
$ref: '#/components/schemas/ResourceTag'
AgentModelsResponse:
type: object
required:
- version
- models
- model_gateway
- total_count
- page
- page_size
additionalProperties: false
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
total_count: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1}
models:
type: array
description: 当前用户可用的资源,空集合返回 []。
items:
$ref: '#/components/schemas/AgentModel'
model_gateway:
$ref: '#/components/schemas/ModelGateway'
UserModelInput:
type: object
required:
- model_id
- display_name
- protocol
- base_url
properties:
model_id: &id001
type: string
description: 上游模型名称,非代理调用时的内部模型 ID。
display_name: &id002
type: string
description: 展示名称。
protocol: &id003
type: string
enum:
- openai_chat_completions
- openai_responses
- anthropic
- image_generation
- video_generation
- openai_embeddings
kind:
type: string
enum: [text, image, video, embedding]
default: text
provider:
type: string
enum: [passthrough, openai_images, openai_responses_image, volcengine, xai, agnes]
image_config:
$ref: '#/components/schemas/AgentImageConfig'
base_url: &id004
type: string
format: uri
description: 上游 HTTP(S) 地址,不允许包含用户名密码。
api_key:
type: string
writeOnly: true
description: 上游密钥,仅写入;更新时省略或为空表示保留。
tag_ids:
type: array
items: {type: string, format: uuid}
advanced_config: &id005
type: object
required:
- context_window_tokens
- max_output_tokens
- supports_vision
properties:
context_window_tokens:
type: integer
format: int64
minimum: 0
max_output_tokens:
type: integer
format: int64
minimum: 0
supports_vision:
type: boolean
supports_reasoning:
type: boolean
default: false
CreateUserModelInput:
allOf:
- $ref: '#/components/schemas/UserModelInput'
- type: object
required:
- api_key
properties:
api_key:
type: string
minLength: 1
writeOnly: true
UserModel:
type: object
required:
- id
- ownership_type
- user
- model_id
- display_name
- protocol
- kind
- provider
- base_url
- api_key_configured
- credit_multiplier
- authorization
- enabled
- created_at
- updated_at
properties:
model_id: *id001
display_name: *id002
protocol: *id003
kind:
type: string
enum: [text, image, video, embedding]
provider:
type: string
enum: [passthrough, openai_images, openai_responses_image, volcengine, xai, agnes]
image_config:
$ref: '#/components/schemas/AgentImageConfig'
image_pricing:
$ref: '#/components/schemas/AgentImagePricing'
embedding_config:
$ref: '#/components/schemas/EmbeddingConfig'
base_url: *id004
advanced_config: *id005
id: *id006
ownership_type:
type: string
const: user
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
api_key_configured:
type: boolean
tags:
type: array
items: {$ref: '#/components/schemas/ResourceTag'}
credit_multiplier:
type: number
exclusiveMinimum: 0
description: 服务端管理,用户不可修改。
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 当前所有者直接分享的分组,未分享时为空数组。
authorization:
type: object
required:
- user_ids
- group_ids
properties:
user_ids:
type: array
items: *id006
group_ids:
type: array
items: *id006
enabled:
type: boolean
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
ShareResourcesInput:
type: object
description: user_ids 与 group_ids 至少填写一项,原始数组合计最多 100 项;重复项去重。group_ids 中的全零 UUID 根组表示系统全员授权,包括后续新增用户;撤销根组分享只移除全员授权,保留独立的用户及其他分组授权。
required:
- resources
properties:
access_level:
type: string
enum: [read_only, read_write]
description: 仅当本批资源全部为 kb 时支持,省略则保留已有权限,新主体只读。
resources:
type: array
minItems: 1
maxItems: 100
items:
type: object
required:
- type
- id
properties:
type:
type: string
enum:
- model
- rule
- skill
- connector
- expert
- kb
description: 可分享的个人资源类型;其他类型返回 400。
id: *id006
user_ids:
type: array
maxItems: 100
items: *id006
description: 接收用户 ID,重复项自动去重。
group_ids:
type: array
maxItems: 100
items: *id006
description: 接收分组 ID,重复项自动去重;全零 UUID 表示系统全员授权,不展开成员。
ErrorResponse:
type: object
required: [error]
properties:
error:
$ref: "#/components/schemas/Error"
Error:
type: object
required: [code, message]
properties:
code:
type: string
description: 供调用方识别错误类别的稳定代码。
examples: [api_key_error]
message:
type: string
description: 服务端按 Accept-Language 返回的本地化错误说明,末尾附 [trace_id] 链路编号,可直接展示;业务判断使用 code,不匹配 message 文本。
references:
description: 原有业务恢复字段,仅按接口契约读取。
ResourceVersion:
type: string
pattern: ^sha256:[0-9a-f]{64}$
description: 当前接口实际下发内容的 SHA-256 摘要,不包含 version 字段。
AgentSettingsResponse:
type: object
required:
- version
- settings
additionalProperties: false
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
settings:
$ref: '#/components/schemas/AgentSettings'
AgentRulesResponse:
type: object
required:
- version
- rules
- total_count
- page
- page_size
additionalProperties: false
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
total_count: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1}
rules:
type: array
description: 当前用户可用的资源,空集合返回 []。
items:
$ref: '#/components/schemas/AgentRule'
AgentSkillsResponse:
type: object
required:
- version
- skills
- total_count
- page
- page_size
additionalProperties: false
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
total_count: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1}
skills:
type: array
description: 当前用户可用的资源,空集合返回 []。
items:
$ref: '#/components/schemas/AgentSkill'
AgentExpertsResponse:
type: object
required:
- version
- experts
- total_count
- page
- page_size
additionalProperties: false
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
total_count: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1}
experts:
type: array
description: 当前用户可用的资源,空集合返回 []。
items:
$ref: '#/components/schemas/AgentExpert'
AgentConnectorsResponse:
type: object
required:
- version
- connectors
- total_count
- page
- page_size
additionalProperties: false
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
total_count: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1}
connectors:
type: array
description: 当前用户可用的资源,空集合返回 []。
items:
$ref: '#/components/schemas/AgentConnector'
AgentKnowledgeBasesResponse:
type: object
required:
- version
- knowledge_bases
- total_count
- page
- page_size
additionalProperties: false
properties:
version:
$ref: '#/components/schemas/ResourceVersion'
total_count: {type: integer, minimum: 0}
page: {type: integer, minimum: 1}
page_size: {type: integer, minimum: 1}
knowledge_bases:
type: array
description: 当前用户可用的知识库,空集合返回 []。
items:
$ref: '#/components/schemas/Kb'
AgentSettings:
type: object
description: 按设置域组织的全局设置;只返回已配置的设置域,服务端密钥字段已移除。
properties:
branding:
$ref: "#/components/schemas/BrandingSettings"
authentication:
$ref: "#/components/schemas/AuthenticationSettings"
email:
$ref: "#/components/schemas/EmailSettings"
billing:
$ref: "#/components/schemas/BillingSettings"
additionalProperties:
type: object
description: 后续新增设置域的配置对象。
BrandingSettings:
type: object
required: [workspace_name, product_name]
properties:
workspace_name:
type: string
description: 工作区名称。
product_name:
type: string
description: Agent 向用户展示的产品名称。
additionalProperties: true
AuthenticationSettings:
type: object
properties:
email_code_auto_registration_enabled:
type: boolean
description: 邮箱验证码登录遇到不存在的用户时是否自动创建普通账号;未配置时默认 false。
password_enabled:
type: boolean
description: 是否允许密码登录。
email_code_enabled:
type: boolean
description: 是否允许邮箱验证码登录。
oauth_connections:
type: array
description: 已配置的 OAuth 登录连接;不包含 client_secret。
items:
$ref: "#/components/schemas/OAuthConnection"
additionalProperties: true
OAuthConnection:
type: object
required: [id, provider, name, client_id, enabled]
properties:
id:
type: string
description: OAuth 连接的稳定标识。
provider:
type: string
enum: [github, google, microsoft, gitlab, oidc, baizhiyun]
description: OAuth 或 OIDC 提供方。
name:
type: string
description: 登录界面展示的连接名称。
client_id:
type: string
description: OAuth Client ID。
issuer_url:
type: string
format: uri
description: OIDC Issuer URL;oidc 和 baizhiyun 必填,其他连接可不返回。
authorization_url:
type: string
format: uri
description: 自定义授权端点;使用提供方默认端点时可不返回。
token_url:
type: string
format: uri
description: 自定义 Token 端点;使用提供方默认端点时可不返回。
userinfo_url:
type: string
format: uri
description: 自定义用户信息端点;使用提供方默认端点时可不返回。
scopes:
type: array
description: 请求上游授权时使用的 Scope;使用默认 Scope 时可不返回。百智云默认为 auth_certification、openid、phone、user、email。
items:
type: string
enabled:
type: boolean
description: 此登录连接是否启用。
auto_registration_enabled:
type: boolean
default: true
description: 通过此连接登录且用户不存在时是否自动创建普通账号;未配置时默认 true。
additionalProperties: true
EmailSettings:
type: object
properties:
sender_name:
type: string
description: 邮件发件人名称。
sender_email:
type: string
format: email
description: 邮件发件人地址。
smtp_host:
type: string
description: SMTP 服务器主机名。
smtp_port:
type: integer
minimum: 1
maximum: 65535
description: SMTP 服务器端口。
smtp_username:
type: string
description: SMTP 登录用户名。
smtp_encryption:
type: string
enum: [none, starttls, tls]
description: SMTP 连接加密方式。
additionalProperties: true
BillingSettings:
type: object
properties:
input_credits_per_million_tokens:
$ref: '#/components/schemas/CreditAmount'
description: 每百万输入 Token 消耗的积分。
cached_input_credits_per_million_tokens:
$ref: '#/components/schemas/CreditAmount'
description: 每百万缓存输入 Token 消耗的积分。
output_credits_per_million_tokens:
$ref: '#/components/schemas/CreditAmount'
description: 每百万输出 Token 消耗的积分。
quota_refresh_cycle:
type: string
enum:
- daily
- weekly
- monthly
description: 积分额度刷新周期。
charging_mode:
description: local 为本地扣费;remote 为百智云扣费,仅具有有效百智云登录身份的用户可访问系统资源,用户自建资源仍遵循原授权。
type: string
enum:
- local
- remote
enabled:
type: boolean
description: 是否启用计费。
additionalProperties: false
ModelGateway:
type: object
required: [base_url, authentication]
properties:
base_url:
type: string
format: uri
description: 兼容模型 SDK 的代理 Base URL。
authentication:
type: string
enum: [api_key]
description: 模型代理使用用户创建的调用密钥鉴权。
ImageInputFile:
type: object
required: [file_id, mime_type, width, height, expires_at]
properties:
file_id: {type: string, format: uuid}
mime_type: {type: string}
width: {type: integer, minimum: 1}
height: {type: integer, minimum: 1}
expires_at: {type: string, format: date-time}
ImageReference:
type: object
required: [file_id]
properties:
file_id: {type: string, format: uuid}
ImageGenerateInput:
type: object
additionalProperties: false
required: [model, prompt]
properties:
model: {type: string}
prompt: {type: string, minLength: 1}
reference_images:
type: array
items: {$ref: '#/components/schemas/ImageReference'}
quality: {$ref: '#/components/schemas/ImageQuality'}
aspect_ratio: {type: string, description: '模型目录公布的比例,如 1:1、9:16。'}
count: {type: integer, minimum: 1}
ImageEditInput:
type: object
additionalProperties: false
required: [model, prompt, images]
properties:
model: {type: string}
prompt: {type: string, minLength: 1}
images:
type: array
minItems: 1
items: {$ref: '#/components/schemas/ImageReference'}
mask: {$ref: '#/components/schemas/ImageReference'}
quality: {$ref: '#/components/schemas/ImageQuality'}
aspect_ratio: {type: string}
count: {type: integer, minimum: 1}
ImageTask:
type: object
required: [id, operation, status]
properties:
id: {type: string, format: uuid}
operation: {type: string, enum: [generate, edit]}
status: {type: string, enum: [pending, running, succeeded, failed, unknown, expired]}
outputs:
type: array
items:
type: object
required: [url, mime_type, width, height]
properties:
url: {type: string, description: 相对路径;下载时需要同一调用密钥。}
mime_type: {type: string}
width: {type: integer, minimum: 1}
height: {type: integer, minimum: 1}
usage:
type: object
properties:
requested_images: {type: integer, minimum: 0}
generated_images: {type: integer, minimum: 0}
credits: {type: string, description: 最终结算积分,完成后提供。}
ImageQuality:
type: string
enum: [1K, 2K, 4K]
description: 平台统一的生图画质档位;具体像素由供应商适配器映射。
AgentImageConfig:
type: object
required: [qualities, aspect_ratios, default_quality, default_aspect_ratio]
properties:
qualities:
type: array
minItems: 1
uniqueItems: true
items: {$ref: '#/components/schemas/ImageQuality'}
aspect_ratios:
type: array
minItems: 1
uniqueItems: true
items: {type: string}
default_quality: {$ref: '#/components/schemas/ImageQuality'}
default_aspect_ratio: {type: string}
operations:
type: array
readOnly: true
items: {type: string, enum: [generate, edit]}
max_images: {type: integer, minimum: 1, readOnly: true}
max_reference_images: {type: integer, minimum: 0, readOnly: true}
supports_reference_image: {type: boolean, readOnly: true}
supports_mask: {type: boolean, readOnly: true}
allowed_aspect_ratios:
type: object
readOnly: true
additionalProperties: {type: array, items: {type: string}}
AgentImageMultiplier:
type: object
required: [name, multiplier]
properties:
name: {$ref: '#/components/schemas/ImageQuality'}
multiplier:
type: string
description: 大于 0 的十进制倍率,最多 6 位小数。
AgentImagePricing:
type: object
required: [rates]
description: 每种开放画质的单张最终积分价;旧版基础价和倍率按原计价规则换算,不改变原费用。
properties:
rates:
type: array
minItems: 1
maxItems: 3
items:
type: object
required: [quality, credits_per_image]
properties:
quality: {$ref: '#/components/schemas/ImageQuality'}
credits_per_image: {type: string, pattern: '^[0-9]+(\.[0-9]{1,6})?$'}
EmbeddingConfig:
type: object
required: [dimension]
properties:
dimension:
type: integer
minimum: 1
maximum: 16000
description: 服务端保存时自动探测的向量维度,1–16000;客户端不可配置。
AgentModel:
type: object
required:
- ownership_type
- user
- id
- model
- display_name
- protocol
- kind
- credit_multiplier
properties:
ownership_type:
type: string
enum:
- system
- user
description: 资源归属,固定为 system 或 user;分享不会改变此值。自有和他人分享的个人模型均为 user,通过 user.id 与当前用户 ID 比较区分。
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
creator:
$ref: '#/components/schemas/UserSummary'
description: 他人创建的用户模型返回创建者;自己的模型和系统模型不返回。
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
items:
$ref: '#/components/schemas/UserSummary'
description: 仅自己的用户模型返回分享用户列表,未分享时为空数组,排除已删除用户。接收方和系统模型不返回此字段。
id:
type: string
format: uuid
description: MonkeyAI 内部模型 UUID,模型代理兼容使用该值作为请求的 model。
model:
type: string
description: 格式为 model_id@id,由数据库 models.model_id 与内部模型 UUID 拼接;Agent 调用模型代理时将此值作为请求的 model,代理精确定位配置并转换为上游模型名称。
display_name:
type: string
description: Agent 向用户展示的模型名称。
protocol:
type: string
enum: [openai_chat_completions, openai_responses, anthropic, image_generation, video_generation, openai_embeddings]
description: MonkeyAI 与上游服务通信时使用的协议。
kind:
type: string
enum: [text, image, video, embedding]
image_config:
$ref: '#/components/schemas/AgentImageConfig'
image_pricing:
$ref: '#/components/schemas/AgentImagePricing'
embedding_config:
$ref: '#/components/schemas/EmbeddingConfig'
context_window_tokens:
type: integer
format: int64
minimum: 0
description: 文本模型必须大于 0;生图模型为 0。
max_output_tokens:
type: integer
format: int64
minimum: 0
description: 文本模型必须大于 0;生图模型为 0。
supports_vision:
type: boolean
description: 模型是否支持图像输入。
supports_reasoning:
type: boolean
description: 模型是否支持推理能力。
credit_multiplier:
type: number
exclusiveMinimum: 0
description: 本模型消耗积分时使用的倍率。
tags:
type: array
items: {$ref: '#/components/schemas/ResourceTag'}
APIKeysResponse:
type: object
required: [api_keys]
properties:
api_keys:
type: array
description: 当前用户的调用密钥元数据,不包含可用于鉴权的密钥原文。
items:
$ref: "#/components/schemas/APIKey"
CreateAPIKeyInput:
type: object
required:
- name
properties:
name:
type: string
minLength: 1
description: 便于用户识别密钥用途的名称。
scopes:
type: array
description: 调用权限;不传或传空数组时默认为 model:invoke。
default:
- model:invoke
uniqueItems: true
items:
type: string
enum:
- model:invoke
- mcp:invoke
expires_in_days:
type: integer
minimum: 1
maximum: 365
default: 90
description: 密钥自创建时起的有效天数。
additionalProperties: false
description: 创建全局调用密钥;MCP 使用 mcp:invoke scope,无需绑定连接或凭证,具体资源访问权由代理地址及用户权限决定。
APIKey:
type: object
required:
- id
- user_id
- name
- key_prefix
- scopes
- expires_at
- created_at
properties:
id:
type: string
format: uuid
description: 调用密钥 ID。
user_id:
type: string
format: uuid
description: 密钥所属用户 ID。
user_name:
type: string
description: 密钥所属用户的显示名称。
name:
type: string
description: 用户设置的密钥名称。
key_prefix:
type: string
description: 用于识别密钥的安全前缀,不可用于鉴权。
examples:
- mk_abcd1234
scopes:
type: array
description: 密钥具备的调用权限。
minItems: 1
uniqueItems: true
items:
type: string
enum:
- model:invoke
- mcp:invoke
expires_at:
type: string
format: date-time
description: 密钥过期时间。
last_used_at:
type: string
format: date-time
description: 最近一次成功使用时间;从未使用时不返回。
created_at:
type: string
format: date-time
description: 密钥创建时间。
revoked_at:
type: string
format: date-time
description: 密钥撤销时间;尚未撤销时不返回。
CreatedAPIKey:
allOf:
- $ref: "#/components/schemas/APIKey"
- type: object
required: [api_key]
properties:
api_key:
type: string
pattern: "^mk_"
description: 可用于模型或 MCP 请求鉴权的密钥原文,只返回一次。
ResourceGrant:
type: object
properties:
id: {type: string, format: uuid, readOnly: true}
access_level:
type: string
enum: [read_only, read_write]
description: 知识库只读或读写权限;读写包含删除内容,不包含管理授权或删除整个库。旧请求省略时保留现有权限,新主体默认只读。
user_id:
type:
- string
- 'null'
format: uuid
user:
readOnly: true
description: 用户授权的展示信息;分组、全员授权或用户已删除时为 null。停用用户仍返回信息,便于撤销授权。
anyOf:
- $ref: '#/components/schemas/UserSummary'
- type: 'null'
group_id:
type:
- string
- 'null'
format: uuid
usage_requirement:
type: string
enum:
- optional
- required
description: 仅系统规则可设置 required。
required:
- usage_requirement
ResourceError:
type: object
properties:
error:
type: object
properties:
code:
type: string
message:
type: string
references:
type:
- array
- 'null'
items:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
required:
- code
- message
required:
- error
ResourceTag:
type: object
properties:
id:
type: string
format: uuid
name:
type: string
required:
- id
- name
OAuthConnectionConfig:
type: object
description: dynamic 模式只需 MCP URL,首次授权自动发现 OAuth 元数据并动态注册客户端;发现及注册结果由后端维护,同一 URL 的普通编辑保留结果,修改 URL 后重新发现。manual 或未指定模式时,授权与 Token URL 必填,Client ID 和 Registration URL 至少填写一个。后续授权与刷新复用客户端;不支持需要初始访问令牌的注册端点。
properties:
mode:
type: string
enum: ['', manual, dynamic]
description: 动态自动发现与传统手动配置分开;未指定时沿用已有手动端点配置。
resource:
type: string
readOnly: true
description: 自动发现的资源标识,授权及 Token 请求携带此 resource 参数。
authorization_url:
type: string
token_url:
type: string
client_id:
type: string
registration_url:
type: string
description: RFC 7591 动态客户端注册端点;已有 Client ID 时复用,动态注册密钥到期后在下次授权前重新注册,旧客户端对应的凭证需重新授权。
token_endpoint_auth_method:
type: string
enum: ['', none, client_secret_post, client_secret_basic]
description: 自动发现模式按服务端元数据选择认证方式,优先 none;手动端点配置留空时,动态注册请求 none,已有客户端沿用 client_secret_post;注册后保存服务端返回的方式。
client_secret_expires_at:
type: integer
format: int64
readOnly: true
description: 注册服务器返回的客户端密钥到期时间(Unix 秒);未返回或为 0 表示无已知期限,由后端维护,修改请求中的值被忽略。
scopes:
type: string
ResourceIssue:
type: object
properties:
code:
type: string
blocking:
type: boolean
connector_id:
type: string
format: uuid
required:
- code
- blocking
MCPTool:
type: object
properties:
id:
type: string
description: 普通 MCP 保留已有 UUID,未配置工具使用稳定 UUID;内置知识库沿用工具名称作为 ID。
name:
type: string
description:
type: string
input_schema:
type: object
enabled:
type: boolean
credits_per_call:
type: number
minimum: 0
required:
- id
- name
- description
- input_schema
- enabled
- credits_per_call
AgentRule:
type: object
properties:
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 仅规则所有者读取个人规则目录时返回共享用户列表,未共享时为 [];接收者和系统规则不返回。
ownership_type:
type: string
enum:
- system
- user
description: 独立资源目录返回;个人规则可由创建者分享给指定用户使用。
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
revision:
type: integer
minimum: 1
description: 独立资源目录返回;管理详情和修改接口使用此修订号作为 ETag。
id:
type: string
format: uuid
name:
type: string
name_i18n:
type: object
additionalProperties: {type: string}
description_i18n:
type: object
additionalProperties: {type: string}
content:
type: string
sha256:
type: string
required:
type: boolean
description: 系统规则命中的授权为 required 时不可关闭;optional 可由 Agent 关闭。首次获取的规则默认开启,之后非强制规则的开关状态由 Agent 维护。个人规则固定为 false。
required:
- id
- name
- content
- sha256
- required
AgentSkill:
type: object
properties:
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 仅资源所有者和管理端读取个人资源时返回共享用户列表,未共享时为 [],排除已删除用户;接收方和系统资源不返回。目录中的用户信息变化会更新 ETag。
ownership_type:
type: string
enum:
- system
- user
description: 独立资源目录返回;分享不改变资源归属。
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
revision:
type: integer
minimum: 1
description: 独立资源目录返回;管理详情和修改接口使用此修订号作为 ETag。
id:
type: string
format: uuid
name:
type: string
description:
type: string
name_i18n:
type: object
additionalProperties: {type: string}
description_i18n:
type: object
additionalProperties: {type: string}
package_sha256:
type: string
package_size_bytes:
type: integer
file_count:
type: integer
download_path:
type: string
tags:
type: array
items:
$ref: '#/components/schemas/ResourceTag'
required:
- id
- name
- description
- package_sha256
- download_path
AgentConnector:
type: object
properties:
tags:
type: array
items: {$ref: '#/components/schemas/ResourceTag'}
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 仅资源所有者和管理端读取个人资源时返回共享用户列表,未共享时为 [],排除已删除用户;接收方和系统资源不返回。目录中的用户信息变化会更新 ETag。
ownership_type:
type: string
enum:
- system
- user
description: 独立资源目录返回;分享不改变资源归属。
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
revision:
type: integer
minimum: 1
description: 独立资源目录返回;管理详情和修改接口使用此修订号作为 ETag。
id:
type: string
format: uuid
icon_path:
type: string
name:
type: string
description:
type: string
name_i18n:
type: object
additionalProperties: {type: string}
description_i18n:
type: object
additionalProperties: {type: string}
authorization_mode:
type: string
enum:
- none
- centralized
- independent
authorization_method:
type:
- string
- 'null'
authorization_status:
type: string
enum:
- not_required
- authorized
- authorization_required
connection_status:
type: string
capabilities:
type: array
items:
type: string
enum:
- catalog
- invoke
mcp_gateway:
$ref: '#/components/schemas/MCPGateway'
tools:
type: array
items:
$ref: '#/components/schemas/MCPTool'
description: 本地快照中的启用工具,字段结构兼容旧客户端;无工具时为 []。独立认证专家清单在 credentials 内返回,resolve 提升所选凭证的工具。连接列表中此字段固定为空数组。内置知识库返回本地定义。
tools_version:
type: string
description: tools 内容的哈希;专家清单和 resolve 基于服务端过滤后的工具计算。
credentials:
type: array
items:
$ref: '#/components/schemas/AgentCredential'
credential_id:
type: string
format: uuid
description: 集中认证返回当前集中凭证 ID;独立认证在 resolve 选定后返回所选凭证 ID。
required:
type: boolean
required:
- id
- name
- description
- authorization_mode
- capabilities
description: 连接列表保留空 tools 数组及对应 tools_version(独立认证在内嵌凭证下返回),不发起远端工具查询。专家 manifest 和 resolve 保留 tools 与 tools_version。独立认证目录在 credentials 内返回当前用户每份凭证的状态和专属代理地址,resolve 提升所选凭证的工具及网关;集中认证返回当前集中凭证的代理地址,免认证返回连接地址。专家允许/拒绝规则在服务端应用,拒绝规则优先。专家列表只读本地依赖和授权状态,版本随可见的本地工具快照变化;专家清单和解析读取本地快照,尚未同步的连接返回空工具列表。
AgentExpert:
type: object
properties:
tags:
type: array
items: {$ref: '#/components/schemas/ResourceTag'}
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 仅资源所有者和管理端读取个人资源时返回共享用户列表,未共享时为 [],排除已删除用户;接收方和系统资源不返回。目录中的用户信息变化会更新 ETag。
ownership_type:
type: string
enum:
- system
- user
description: 独立资源目录返回;分享不改变资源归属。
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
revision:
type: integer
minimum: 1
description: 独立资源目录返回;管理详情和修改接口使用此修订号作为 ETag。
id:
type: string
format: uuid
name:
type: string
description:
type: string
name_i18n:
type: object
additionalProperties: {type: string}
description_i18n:
type: object
additionalProperties: {type: string}
avatar_path:
type: string
version:
type: string
manifest_path:
type: string
available:
type: boolean
issues:
type: array
items:
$ref: '#/components/schemas/ResourceIssue'
required:
- id
- name
- version
- manifest_path
- available
- issues
ExpertManifest:
type: object
properties:
expert_id:
type: string
name:
type: string
name_i18n:
type: object
additionalProperties: {type: string}
description_i18n:
type: object
additionalProperties: {type: string}
avatar_path:
type: string
prompt:
type: string
version:
type: string
available:
type: boolean
rules:
type: array
items:
$ref: '#/components/schemas/AgentRule'
skills:
type: array
items:
$ref: '#/components/schemas/AgentSkill'
connectors:
type: array
items:
$ref: '#/components/schemas/AgentConnector'
issues:
type: array
items:
$ref: '#/components/schemas/ResourceIssue'
required:
- expert_id
- prompt
- version
- available
- rules
- skills
- connectors
- issues
ResolveResources:
type: object
properties:
expert_id:
type: string
format: uuid
rule_ids:
type: array
items:
type: string
format: uuid
skill_ids:
type: array
items:
type: string
format: uuid
connector_bindings:
type: object
additionalProperties:
type: string
format: uuid
description: 本次已选择的独立 Connector ID 到凭证 ID;不会隐式选择连接。无绑定时恰好一个有效凭证才自动选择,多份返回 credential_selection_required。
connector_ids:
type: array
items:
type: string
format: uuid
OAuthAuthorization:
type: object
properties:
id:
type: string
format: uuid
authorization_url:
type: string
format: uri
expires_at:
type:
- string
- 'null'
format: date-time
required:
- id
- authorization_url
- expires_at
AuthorizationStatus:
type: object
properties:
id:
type: string
format: uuid
status:
type: string
enum:
- pending
- processing
- succeeded
- failed
- expired
credential_id:
type:
- string
- 'null'
format: uuid
expires_at:
type:
- string
- 'null'
format: date-time
required:
- id
- status
CredentialInput:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 128
http_headers:
type: object
minProperties: 1
maxProperties: 30
additionalProperties:
type: string
writeOnly: true
description: 完整 Header 键值;禁止大小写重复、CR/LF、Host、传输控制、Mcp-*、Content-Type 和 Accept。整组替换,响应不回填。
required:
- name
- http_headers
RuleResource:
type: object
properties:
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 个人规则的共享用户列表;仅所有者及管理端可读取,未共享时为 []。
id:
type: string
format: uuid
name:
type: string
revision:
type: integer
minimum: 1
ownership_type:
type: string
enum:
- system
- user
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
icon_path:
type: string
enabled:
type: boolean
grants:
description: 系统规则的授权范围;个人规则的指定用户只读共享授权(不可强制应用),仅所有者及管理端可读取。
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
content:
type: string
required:
- id
- name
- revision
- grants
RuleInput:
type: object
properties:
content:
type: string
name:
type: string
minLength: 1
maxLength: 200
grants:
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
required:
- name
- content
SkillResource:
type: object
properties:
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 仅资源所有者和管理端读取个人资源时返回共享用户列表,未共享时为 [],排除已删除用户;接收方和系统资源不返回。目录中的用户信息变化会更新 ETag。
id:
type: string
format: uuid
name:
type: string
revision:
type: integer
minimum: 1
ownership_type:
type: string
enum:
- system
- user
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
icon_path:
type: string
enabled:
type: boolean
grants:
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
description:
type: string
package_file_name:
type: string
package_sha256:
type: string
package_size_bytes:
type: integer
file_count:
type: integer
tags:
type: array
items:
$ref: '#/components/schemas/ResourceTag'
required:
- id
- name
- revision
- grants
SkillInput:
type: object
properties:
name:
type: string
description:
type: string
content:
type: string
tag_ids:
type: array
items:
type: string
format: uuid
grants:
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
required:
- name
ExpertResource:
type: object
properties:
avatar_path:
type: string
readOnly: true
description: 头像读取路径,包含图片版本;个人接口返回 /api/v1/experts/{id}/avatar?v=...,无头像时省略。
tags:
type: array
items: {$ref: '#/components/schemas/ResourceTag'}
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 仅资源所有者和管理端读取个人资源时返回共享用户列表,未共享时为 [],排除已删除用户;接收方和系统资源不返回。目录中的用户信息变化会更新 ETag。
id:
type: string
format: uuid
name:
type: string
revision:
type: integer
minimum: 1
ownership_type:
type: string
enum:
- system
- user
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
icon_path:
type: string
enabled:
type: boolean
grants:
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
description:
type: string
prompt:
type: string
rule_ids:
type: array
items:
type: string
format: uuid
skill_ids:
type: array
items:
type: string
format: uuid
connectors:
type: array
items:
$ref: '#/components/schemas/ConnectorDependency'
required:
- id
- name
- revision
- grants
ExpertInput:
type: object
properties:
tag_ids:
type: array
items: {type: string, format: uuid}
description:
type: string
prompt:
type: string
rule_ids:
type: array
items:
type: string
format: uuid
skill_ids:
type: array
items:
type: string
format: uuid
name:
type: string
minLength: 1
maxLength: 200
grants:
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
connectors:
type: array
items:
$ref: '#/components/schemas/ConnectorDependency'
required:
- name
- prompt
ConnectorResource:
type: object
properties:
tags:
type: array
items: {$ref: '#/components/schemas/ResourceTag'}
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅资源所有者可见的直接分享分组,未分享时为空数组;不展开成员。
shared_users:
type: array
readOnly: true
items:
$ref: '#/components/schemas/UserSummary'
description: 仅资源所有者和管理端读取个人资源时返回共享用户列表,未共享时为 [],排除已删除用户;接收方和系统资源不返回。目录中的用户信息变化会更新 ETag。
id:
type: string
format: uuid
name:
type: string
name_i18n:
type: object
additionalProperties: {type: string}
description_i18n:
type: object
additionalProperties: {type: string}
revision:
type: integer
minimum: 1
ownership_type:
type: string
enum:
- system
- user
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 资源所有者的基本信息;系统资源返回创建者,分享不改变归属。
icon_path:
type: string
enabled:
type: boolean
grants:
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
description:
type: string
url:
type: string
format: uri
authorization_mode:
type: string
enum:
- none
- centralized
- independent
authorization_method:
type:
- string
- 'null'
oauth_config:
$ref: '#/components/schemas/OAuthConnectionConfig'
callback_url:
type: string
readOnly: true
description: OAuth MCP 的专属完整回调地址,格式为 {MONKEYAI_PUBLIC_URL}/oauth/connectors/{id}/callback;非 OAuth 连接为空字符串。
config_revision:
type: integer
credential_configured:
type: boolean
connection_status:
type: string
credentials:
type: array
items:
$ref: '#/components/schemas/ConnectorCredential'
required:
- id
- name
- revision
- grants
- callback_url
ConnectorInput:
type: object
properties:
tag_ids:
type: array
items: {type: string, format: uuid}
description:
type: string
url:
type: string
format: uri
name:
type: string
minLength: 1
maxLength: 200
grants:
type: array
items:
$ref: '#/components/schemas/ResourceGrant'
authorization_mode:
type: string
enum:
- none
- centralized
- independent
authorization_method:
type:
- string
- 'null'
enum:
- oauth
- http_header
- null
oauth_config:
$ref: '#/components/schemas/OAuthConnectionConfig'
oauth_client_secret:
type: string
writeOnly: true
description: 省略保留,空字符串清空;应用或端点变更时省略会清除旧 Secret。
required:
- name
AgentCredential:
allOf:
- $ref: '#/components/schemas/ConnectorCredential'
- type: object
properties:
tools:
type: array
items:
$ref: '#/components/schemas/MCPTool'
description: 仅专家清单内嵌凭证返回快照中的启用工具;未认证时为 []。连接列表中此字段固定为空数组。
tools_version:
type: string
description: tools 内容的哈希。
mcp_gateway:
$ref: '#/components/schemas/MCPGateway'
AuthorizationName:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 128
required:
- name
ConnectorCredential:
type: object
properties:
id:
type: string
format: uuid
connector_id:
type: string
format: uuid
user:
oneOf:
- $ref: '#/components/schemas/UserSummary'
- type: 'null'
readOnly: true
description: 凭证所属的平台用户基本信息;集中凭证为 null,不读取上游 OAuth 用户资料。
name:
type: string
revision:
type: integer
config_revision:
type: integer
authorization_status:
type: string
enum:
- authorized
- authorization_required
- revoked
connection_status:
type: string
enum:
- unknown
- connected
- error
header_names:
type: array
items:
type: string
last_checked_at:
type:
- string
- 'null'
format: date-time
last_error:
type:
- string
- 'null'
oauth_expires_at:
type:
- string
- 'null'
format: date-time
created_at:
type:
- string
- 'null'
format: date-time
updated_at:
type:
- string
- 'null'
format: date-time
revoked_at:
type:
- string
- 'null'
format: date-time
required:
- id
- connector_id
- user
- name
- revision
- authorization_status
- connection_status
ConnectorDependency:
type: object
properties:
required:
type: boolean
tool_allowlist:
type: array
items:
type: string
tool_denylist:
type: array
items:
type: string
connector_id:
type: string
format: uuid
required:
- connector_id
CredentialPatch:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 128
http_headers:
type: object
minProperties: 1
maxProperties: 30
additionalProperties:
type: string
writeOnly: true
description: 完整 Header 键值;禁止大小写重复、CR/LF、Host、传输控制、Mcp-*、Content-Type 和 Accept。整组替换,响应不回填。
minProperties: 1
MCPGateway:
type: object
properties:
url:
type: string
format: uri
description: 以 /mcp 为前缀:免认证为 /mcp/connectors/{id},集中或独立认证为 /mcp/connectors/{id}/credentials/{credential_id}。全局 API Key
认证用户,服务端校验地址对应连接使用权、凭证归属和有效性。
transport:
const: streamable_http
authentication:
const: api_key
required_scope:
const: mcp:invoke
required:
- url
- transport
- authentication
- required_scope
KbUserInput:
type: object
additionalProperties: false
required: [name]
properties:
name: {type: string, minLength: 1, maxLength: 200}
description: {type: string}
fusion_config: {$ref: '#/components/schemas/KbFusionConfig'}
tag_ids: {type: array, items: {type: string, format: uuid}}
Kb:
type: object
required: [id, name, description, ownership_type, enabled, revision, embedding_model_id, embedding_dimension, fusion_config, embedding_configured, capabilities, index_job_summary, document_count, learned_count, tags, updated_at]
properties:
avatar_path:
type: string
description: 受权限保护的图标读取路径 /api/v1/kb/{id}/avatar,包含图片版本参数;无图标时为空或省略。
permissions:
type: object
readOnly: true
properties:
effective_access_level: {type: string, enum: [read_only, read_write, '']}
can_read: {type: boolean}
can_write_content: {type: boolean}
can_manage_permissions: {type: boolean}
can_manage_knowledge_base: {type: boolean}
can_delete_knowledge_base: {type: boolean}
id: {type: string, format: uuid}
name: {type: string}
description: {type: string}
ownership_type: {type: string, enum: [system, user]}
user:
$ref: '#/components/schemas/UserSummary'
readOnly: true
description: 知识库所有者的基本信息;系统知识库返回创建者,分享不改变归属。
shared_users:
type: array
readOnly: true
items: {$ref: '#/components/schemas/UserSummary'}
description: 仅知识库所有者可见的共享用户列表,未共享时为 [];接收方不返回。
shared_groups:
type: array
readOnly: true
items: {$ref: '#/components/schemas/GroupSummary'}
description: 仅知识库所有者可见的直接分享分组,未共享时为 [],不展开成员。
enabled: {type: boolean}
revision: {type: integer}
embedding_model_id: {type: [string, 'null'], format: uuid}
embedding_dimension: {type: [integer, 'null']}
fusion_config: {$ref: '#/components/schemas/KbFusionConfig'}
embedding_configured: {type: boolean}
capabilities: {$ref: '#/components/schemas/KbIndexCapabilities'}
index_job_summary: {$ref: '#/components/schemas/KbIndexJobSummary'}
document_count: {type: integer}
learned_count: {type: integer}
tags: {type: array, items: {type: object}}
updated_at: {type: string, format: date-time}
KbGrantsResponse:
type: object
required: [grants, revision]
properties:
grants: {type: array, items: {$ref: '#/components/schemas/ResourceGrant'}}
revision: {type: integer, minimum: 1}
KbDetail:
allOf:
- $ref: '#/components/schemas/Kb'
- type: object
properties:
grants:
type: array
readOnly: true
items: {$ref: '#/components/schemas/ResourceGrant'}
description: 仅知识库所有者可见的授权范围;被分享者不返回。
KbDocument:
type: object
required: [id, kb_id, node_type, title, source_type, content, status, chunk_count, revision, created_at, updated_at]
properties:
updated_by_user_id: {type: [string, 'null'], format: uuid}
content_updated_at: {type: [string, 'null'], format: date-time}
id: {type: string, format: uuid}
kb_id: {type: string, format: uuid}
parent_id: {type: [string, 'null'], format: uuid}
node_type: {type: string, enum: [folder, document]}
position: {type: number}
children: {type: array, items: {$ref: '#/components/schemas/KbDocument'}}
title: {type: string}
source_type: {type: string, enum: [text, file, url]}
content: {type: string}
file_name: {type: [string, 'null']}
mime_type: {type: [string, 'null']}
size_bytes: {type: integer}
status: {type: string, enum: [pending, learning, learned, failed]}
error_message: {type: [string, 'null']}
chunk_count: {type: integer}
revision: {type: integer}
learned_at: {type: [string, 'null'], format: date-time}
created_at: {type: string, format: date-time}
updated_at: {type: string, format: date-time}
KbDocumentSummary:
type: object
required: [id, kb_id, node_type, title, source_type, status, chunk_count, revision, created_at, updated_at]
properties:
updated_by_user_id: {type: [string, 'null'], format: uuid}
content_updated_at: {type: [string, 'null'], format: date-time}
id: {type: string, format: uuid}
kb_id: {type: string, format: uuid}
parent_id: {type: [string, 'null'], format: uuid}
node_type: {type: string, enum: [folder, document]}
position: {type: number}
children: {type: array, items: {$ref: '#/components/schemas/KbDocumentSummary'}}
title: {type: string}
source_type: {type: string, enum: [text, file, url]}
file_name: {type: [string, 'null']}
mime_type: {type: [string, 'null']}
size_bytes: {type: integer}
status: {type: string, enum: [pending, learning, learned, failed]}
error_message: {type: [string, 'null']}
chunk_count: {type: integer}
revision: {type: integer}
learned_at: {type: [string, 'null'], format: date-time}
created_at: {type: string, format: date-time}
updated_at: {type: string, format: date-time}
KbDocumentDeleteInput:
type: object
additionalProperties: false
required: [ids]
properties:
ids: {type: array, minItems: 1, maxItems: 200, items: {type: string, format: uuid}}
expected_revisions: {type: object, additionalProperties: {type: integer, minimum: 1}}
KbDocumentOperationResult:
type: object
required: [succeeded, failed]
properties:
succeeded: {type: array, items: {type: string, format: uuid}}
failed:
type: array
items:
type: object
required: [id, reason]
properties:
id: {type: string}
reason: {type: string}
KbDocumentMoveInput:
type: object
additionalProperties: false
required: [ids]
properties:
ids: {type: array, minItems: 1, maxItems: 200, items: {type: string, format: uuid}}
expected_revisions: {type: object, additionalProperties: {type: integer, minimum: 1}}
parent_id: {type: [string, 'null'], format: uuid}
prev_id: {type: string, format: uuid, description: 指定相邻节点排序时 ids 只能含一个 ID。}
next_id: {type: string, format: uuid, description: 指定相邻节点排序时 ids 只能含一个 ID。}
KbDocumentCreateInput:
type: object
additionalProperties: false
required: [title]
properties:
title: {type: string, minLength: 1}
parent_id: {type: [string, 'null'], format: uuid}
node_type: {type: string, enum: [folder, document], default: document}
source_type: {type: string, enum: [text, file, url], default: text}
content: {type: string, minLength: 1}
file_name: {type: string}
mime_type: {type: string}
size_bytes: {type: integer, minimum: 0}
KbDocumentUpdateInput:
type: object
additionalProperties: false
properties:
expected_revision: {type: integer, minimum: 1, description: 协作写入必须提供读取到的文档版本。}
title: {type: string, minLength: 1}
source_type: {type: string, enum: [text, file, url]}
content: {type: string}
file_name: {type: string}
mime_type: {type: string}
size_bytes: {type: integer, minimum: 0}
KbSearchInput:
type: object
additionalProperties: false
required: [query]
properties:
kb_ids: {type: array, maxItems: 50, items: {type: string, format: uuid}}
query: {type: string, minLength: 1}
top_k: {type: integer, minimum: 1, maximum: 20, default: 8}
filters: {type: object, additionalProperties: true, description: 当前版本保留字段,暂不参与过滤。}
KbSearchResult:
type: object
required: [kb_id, document_id, chunk_id, chunk_index, content, title, score, retrieval_source, citation]
properties:
kb_id: {type: string, format: uuid}
document_id: {type: string, format: uuid}
chunk_id: {type: string, format: uuid}
chunk_index: {type: integer}
content: {type: string}
title: {type: string}
score: {type: number}
retrieval_source: {type: string, enum: [lexical, vector, both]}
citation: {$ref: '#/components/schemas/KbCitation'}
KbFusionConfig:
type: object
additionalProperties: false
required: [type, k, weights]
properties:
type: {type: string, enum: [weighted_rrf]}
k: {type: integer, minimum: 1, default: 60}
weights:
type: object
required: [lexical, vector]
additionalProperties: false
properties:
lexical: {type: number, minimum: 0, default: 0.3}
vector: {type: number, minimum: 0, default: 0.7}
KbIndexCapabilities:
type: object
additionalProperties: false
required: [search_modes, channels, embedding_configured]
properties:
search_modes: {type: array, items: {type: string, enum: [lexical, hybrid]}}
channels: {type: array, items: {type: string, enum: [lexical, vector]}}
embedding_configured: {type: boolean}
KbIndexJobSummary:
type: object
additionalProperties: false
required: [pending, running, failed, by_operation]
properties:
pending: {type: integer}
running: {type: integer}
failed: {type: integer}
by_operation:
type: object
additionalProperties:
type: object
additionalProperties: {type: integer}
KbCitation:
type: object
additionalProperties: false
required: [heading_path, page_no, source_url]
properties:
heading_path: {type: [string, 'null']}
page_no: {type: [integer, 'null']}
source_url: {type: [string, 'null']}
KbSearchResponse:
type: object
required: [query, retrieval_mode, channels_used, fusion, degraded, warnings, items]
properties:
query: {type: string}
retrieval_mode: {type: string, enum: [lexical, hybrid, vector]}
channels_used: {type: array, items: {type: string, enum: [lexical, vector]}}
fusion:
type: object
description: 单库或参数一致时为 weighted_rrf 配置;不一致时返回 k_by_kb 与 weights_by_kb。
additionalProperties: true
degraded: {type: boolean}
warnings: {type: array, items: {type: string}}
items: {type: array, items: {$ref: '#/components/schemas/KbSearchResult'}}