@@ -7,6 +7,112 @@ servers:
77security :
88 - OAuthAccessToken : []
99paths :
10+ /api/v1/endpoints :
11+ get :
12+ summary : 分页读取当前用户端点
13+ description : 包含已停用端点;online 仅代表当前单进程连接。响应不缓存。
14+ parameters :
15+ - {name: page, in: query, schema: {type: integer, minimum: 1, maximum: 1000000, default: 1}}
16+ - {name: page_size, in: query, schema: {type: integer, minimum: 1, maximum: 100, default: 20}}
17+ responses :
18+ ' 200 ' :
19+ description : 端点分页
20+ content :
21+ application/json :
22+ schema :
23+ type : object
24+ required : [items, total, page, page_size]
25+ properties :
26+ items : {type: array, items: {$ref: '#/components/schemas/Endpoint'}}
27+ total : {type: integer}
28+ page : {type: integer}
29+ page_size : {type: integer}
30+ ' 400 ' : {$ref: '#/components/responses/ResourceError400'}
31+ ' 401 ' : {$ref: '#/components/responses/Unauthorized'}
32+ ' 503 ' : {$ref: '#/components/responses/EndpointUnavailable'}
33+ /api/v1/endpoints/connect :
34+ get :
35+ summary : 建立原生客户端端点桥接 WebSocket
36+ description : >-
37+ 仅接受 OAuth Bearer access token,不接受 Cookie 或 URL token。
38+ 非空 Origin 必须匹配 MONKEYAI_PUBLIC_URL;生产使用 WSS。
39+ Upgrade 后 5 秒内发送 hello,服务端依次发送 welcome、directory.snapshot。
40+ 使用协议主版本 1,UTF-8 JSON 文本消息最大 256 KiB(含分片累计),禁用压缩。
41+ request/response/event 信封及关闭码详见 design/endpoint-bridge-design.md。
42+ 4003 需恢复 OAuth 凭据,4001/4002 不自动重连;断线不得自动重发业务消息。
43+ responses :
44+ ' 101 ' : {description: WebSocket 升级成功}
45+ ' 400 ' : {$ref: '#/components/responses/ResourceError400'}
46+ ' 401 ' : {$ref: '#/components/responses/Unauthorized'}
47+ ' 403 ' : {$ref: '#/components/responses/ResourceError403'}
48+ ' 429 ' :
49+ description : 当前用户建连过于频繁,遵循 Retry-After 退避
50+ headers :
51+ Retry-After : {schema: {type: integer}}
52+ content :
53+ application/json :
54+ schema : {$ref: '#/components/schemas/ResourceError'}
55+ ' 503 ' : {$ref: '#/components/responses/EndpointUnavailable'}
56+ /api/v1/endpoints/{machine_id} :
57+ parameters :
58+ - {$ref: '#/components/parameters/EndpointMachine'}
59+ get :
60+ summary : 读取当前用户的单个端点
61+ responses :
62+ ' 200 ' : {$ref: '#/components/responses/EndpointResult'}
63+ ' 400 ' : {$ref: '#/components/responses/ResourceError400'}
64+ ' 401 ' : {$ref: '#/components/responses/Unauthorized'}
65+ ' 404 ' : {$ref: '#/components/responses/ResourceError404'}
66+ ' 503 ' : {$ref: '#/components/responses/EndpointUnavailable'}
67+ patch :
68+ summary : 修改端点别名
69+ requestBody :
70+ required : true
71+ content :
72+ application/json :
73+ schema :
74+ type : object
75+ additionalProperties : false
76+ required : [alias]
77+ properties :
78+ alias :
79+ type : [string, 'null']
80+ description : null 清除别名;非空白文本最多 128 UTF-8 字节,拒绝控制字符
81+ responses :
82+ ' 200 ' : {$ref: '#/components/responses/EndpointResult'}
83+ ' 400 ' : {$ref: '#/components/responses/ResourceError400'}
84+ ' 401 ' : {$ref: '#/components/responses/Unauthorized'}
85+ ' 404 ' : {$ref: '#/components/responses/ResourceError404'}
86+ ' 503 ' : {$ref: '#/components/responses/EndpointUnavailable'}
87+ /api/v1/endpoints/{machine_id}/revoke :
88+ parameters :
89+ - {$ref: '#/components/parameters/EndpointMachine'}
90+ post :
91+ summary : 停用端点并断开连接
92+ description : 幂等,不接受请求体。不等于撤销设备登录授权,持有有效账号凭据仍可显式恢复。
93+ responses :
94+ ' 200 ' : {$ref: '#/components/responses/EndpointResult'}
95+ ' 400 ' : {$ref: '#/components/responses/ResourceError400'}
96+ ' 401 ' : {$ref: '#/components/responses/Unauthorized'}
97+ ' 404 ' : {$ref: '#/components/responses/ResourceError404'}
98+ ' 503 ' : {$ref: '#/components/responses/EndpointUnavailable'}
99+ /api/v1/endpoints/{machine_id}/restore :
100+ parameters :
101+ - {$ref: '#/components/parameters/EndpointMachine'}
102+ post :
103+ summary : 恢复已停用端点
104+ description : 幂等,不接受请求体。不主动建立连接;active 端点最多 20 个,离线也计入。
105+ responses :
106+ ' 200 ' : {$ref: '#/components/responses/EndpointResult'}
107+ ' 400 ' : {$ref: '#/components/responses/ResourceError400'}
108+ ' 401 ' : {$ref: '#/components/responses/Unauthorized'}
109+ ' 404 ' : {$ref: '#/components/responses/ResourceError404'}
110+ ' 409 ' :
111+ description : active 端点达到上限,错误码 endpoint_limit_exceeded
112+ content :
113+ application/json :
114+ schema : {$ref: '#/components/schemas/ResourceError'}
115+ ' 503 ' : {$ref: '#/components/responses/EndpointUnavailable'}
10116 /oauth/connectors/{id}/callback :
11117 get :
12118 summary : 处理指定 MCP 的 OAuth 回调
@@ -2540,6 +2646,12 @@ components:
25402646 bearerFormat : OAuth 2.0 access token
25412647 description : Agent 登录授权流程签发的短期 access token。
25422648 parameters :
2649+ EndpointMachine :
2650+ name : machine_id
2651+ in : path
2652+ required : true
2653+ description : 规范小写、带连字符的 UUIDv4,仅限当前用户端点
2654+ schema : {type: string, format: uuid}
25432655 ResourceID :
25442656 name : id
25452657 in : path
@@ -2583,6 +2695,18 @@ components:
25832695 type : string
25842696 const : private, no-cache
25852697 responses :
2698+ EndpointResult :
2699+ description : 当前端点资料,时间为 Unix 毫秒
2700+ headers :
2701+ Cache-Control : {schema: {type: string, const: 'private, no-store'}}
2702+ content :
2703+ application/json :
2704+ schema : {$ref: '#/components/schemas/Endpoint'}
2705+ EndpointUnavailable :
2706+ description : 认证或存储暂不可用、连接数超限,或服务正在停止
2707+ content :
2708+ application/json :
2709+ schema : {$ref: '#/components/schemas/ResourceError'}
25862710 NotModified :
25872711 description : 当前接口内容未变化,无响应体。
25882712 headers :
@@ -2669,6 +2793,25 @@ components:
26692793 schema :
26702794 $ref : " #/components/schemas/ErrorResponse"
26712795 schemas :
2796+ Endpoint :
2797+ type : object
2798+ 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]
2799+ properties :
2800+ machine_id : {type: string, format: uuid}
2801+ device_name : {type: string}
2802+ alias : {type: [string, 'null']}
2803+ display_name : {type: string}
2804+ platform : {type: string, enum: [macos, windows, linux, ios, android]}
2805+ os_version : {type: string}
2806+ arch : {type: string}
2807+ client_version : {type: string}
2808+ protocol_version : {type: integer, const: 1}
2809+ status : {type: string, enum: [active, revoked]}
2810+ online : {type: boolean}
2811+ created_at : {type: integer, format: int64}
2812+ updated_at : {type: integer, format: int64}
2813+ last_seen_at : {type: [integer, 'null'], format: int64}
2814+ revoked_at : {type: [integer, 'null'], format: int64}
26722815 UserRuleInput :
26732816 type : object
26742817 properties :
0 commit comments