feat(onebot,mcp): catalog the Stream API actions (#163 phase 4)
Surface the six Stream API actions in the self-generated docs catalog under a new 流式接口 category: export each module's specs as an `actions` array (register now iterates it) and widen the doc collector's spec type to anything carrying describe() so defineStreamAction results qualify alongside defineAction. Regenerated the MCP catalog snapshot. End-to-end verified on a live account over HTTP: test_download_stream (10 frames + terminal), an upload_file_stream round-trip (200 KB chunked in → sent as a c2c file → download_file_stream back out, byte- and sha256-exact), and the SSRF guard rejecting a cloud-metadata URL.
This commit is contained in:
5 files changed
+814
-8
No files matched your search
@@ -535,6 +535,21 @@
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "clean_stream_temp_file",
|
||||
"aliases": [],
|
||||
"summary": "清理流式传输临时文件(仅清理 stream 上传/下载目录)",
|
||||
"returns": "{ message, removed }",
|
||||
"readOnly": false,
|
||||
"params": [],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "click_inline_keyboard_button",
|
||||
"aliases": [],
|
||||
@@ -1408,6 +1423,180 @@
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "download_file_image_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式方式下载图片(缓存图片 id / URL / stream 目录本地文件)",
|
||||
"returns": "流式帧:file_info → file_chunk* → file_complete",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "file",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
{
|
||||
"name": "file_id",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file": {
|
||||
"type": "string",
|
||||
"description": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
"file_id": {
|
||||
"type": "string",
|
||||
"description": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
"chunk_size": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "download_file_record_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式方式下载语音(缓存语音 id / URL / stream 目录本地文件)",
|
||||
"returns": "流式帧:file_info → file_chunk* → file_complete",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "file",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
{
|
||||
"name": "file_id",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file": {
|
||||
"type": "string",
|
||||
"description": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
"file_id": {
|
||||
"type": "string",
|
||||
"description": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
"chunk_size": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "download_file_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式方式下载文件(stream 目录本地文件 / URL / 缓存媒体)",
|
||||
"returns": "流式帧:file_info → file_chunk* → file_complete",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "file",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
{
|
||||
"name": "file_id",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file": {
|
||||
"type": "string",
|
||||
"description": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
"file_id": {
|
||||
"type": "string",
|
||||
"description": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
"chunk_size": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "download_fileset",
|
||||
"aliases": [],
|
||||
@@ -8502,6 +8691,38 @@
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "test_download_stream",
|
||||
"aliases": [],
|
||||
"summary": "测试下载流(推送 10 个数据帧,验证流式传输,不触达 QQ)",
|
||||
"returns": "流式帧:data_chunk*10 → data_complete(error=true 时以 error 帧结束)",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "error",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"default": false,
|
||||
"desc": "是否触发测试错误"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "boolean",
|
||||
"description": "是否触发测试错误",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "trans_group_file",
|
||||
"aliases": [],
|
||||
@@ -8621,6 +8842,181 @@
|
||||
},
|
||||
"category": "空间"
|
||||
},
|
||||
{
|
||||
"name": "upload_file_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式分块方式上传文件到机器人本地(返回可用于发送的本地路径)",
|
||||
"returns": "流式帧:分块确认 type=stream、完成 type=response(含 file_path/file_size/sha256)",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "stream_id",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"desc": "流 ID(客户端生成的 UUID,限 [A-Za-z0-9_-])"
|
||||
},
|
||||
{
|
||||
"name": "chunk_data",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "分块数据(Base64)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_index",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"desc": "分块索引(从 0 开始)"
|
||||
},
|
||||
{
|
||||
"name": "total_chunks",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "总分块数(新流必填)"
|
||||
},
|
||||
{
|
||||
"name": "file_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"desc": "文件总大小(字节)"
|
||||
},
|
||||
{
|
||||
"name": "expected_sha256",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "期望的整文件 SHA256(校验)"
|
||||
},
|
||||
{
|
||||
"name": "is_complete",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"desc": "是否为最后一个分块/触发合并"
|
||||
},
|
||||
{
|
||||
"name": "filename",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件名"
|
||||
},
|
||||
{
|
||||
"name": "reset",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"desc": "重置并丢弃该流"
|
||||
},
|
||||
{
|
||||
"name": "verify_only",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"desc": "仅查询当前流状态"
|
||||
},
|
||||
{
|
||||
"name": "file_retention",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"default": 300000,
|
||||
"desc": "合并文件保留毫秒(0=不回收)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"stream_id": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "流 ID(客户端生成的 UUID,限 [A-Za-z0-9_-])"
|
||||
},
|
||||
"chunk_data": {
|
||||
"type": "string",
|
||||
"description": "分块数据(Base64)"
|
||||
},
|
||||
"chunk_index": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "分块索引(从 0 开始)"
|
||||
},
|
||||
"total_chunks": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "总分块数(新流必填)"
|
||||
},
|
||||
"file_size": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "文件总大小(字节)"
|
||||
},
|
||||
"expected_sha256": {
|
||||
"type": "string",
|
||||
"description": "期望的整文件 SHA256(校验)"
|
||||
},
|
||||
"is_complete": {
|
||||
"type": "boolean",
|
||||
"description": "是否为最后一个分块/触发合并"
|
||||
},
|
||||
"filename": {
|
||||
"type": "string",
|
||||
"description": "文件名"
|
||||
},
|
||||
"reset": {
|
||||
"type": "boolean",
|
||||
"description": "重置并丢弃该流"
|
||||
},
|
||||
"verify_only": {
|
||||
"type": "boolean",
|
||||
"description": "仅查询当前流状态"
|
||||
},
|
||||
"file_retention": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "合并文件保留毫秒(0=不回收)",
|
||||
"default": 300000
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"stream_id"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "upload_forward_msg",
|
||||
"aliases": [],
|
||||
@@ -9013,6 +9409,10 @@
|
||||
{
|
||||
"category": "空间",
|
||||
"count": 7
|
||||
},
|
||||
{
|
||||
"category": "流式接口",
|
||||
"count": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -538,6 +538,21 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "clean_stream_temp_file",
|
||||
"aliases": [],
|
||||
"summary": "清理流式传输临时文件(仅清理 stream 上传/下载目录)",
|
||||
"returns": "{ message, removed }",
|
||||
"readOnly": false,
|
||||
"params": [],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "click_inline_keyboard_button",
|
||||
"aliases": [],
|
||||
@@ -1411,6 +1426,180 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "download_file_image_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式方式下载图片(缓存图片 id / URL / stream 目录本地文件)",
|
||||
"returns": "流式帧:file_info → file_chunk* → file_complete",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "file",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
{
|
||||
"name": "file_id",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file": {
|
||||
"type": "string",
|
||||
"description": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
"file_id": {
|
||||
"type": "string",
|
||||
"description": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
"chunk_size": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "download_file_record_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式方式下载语音(缓存语音 id / URL / stream 目录本地文件)",
|
||||
"returns": "流式帧:file_info → file_chunk* → file_complete",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "file",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
{
|
||||
"name": "file_id",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file": {
|
||||
"type": "string",
|
||||
"description": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
"file_id": {
|
||||
"type": "string",
|
||||
"description": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
"chunk_size": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "download_file_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式方式下载文件(stream 目录本地文件 / URL / 缓存媒体)",
|
||||
"returns": "流式帧:file_info → file_chunk* → file_complete",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "file",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
{
|
||||
"name": "file_id",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file": {
|
||||
"type": "string",
|
||||
"description": "文件路径(限 stream 临时目录)/ http(s) URL"
|
||||
},
|
||||
"file_id": {
|
||||
"type": "string",
|
||||
"description": "文件 ID(缓存的图片/语音 id)"
|
||||
},
|
||||
"chunk_size": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "分块大小(字节,默认 64KB)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "download_fileset",
|
||||
"aliases": [],
|
||||
@@ -8505,6 +8694,38 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "test_download_stream",
|
||||
"aliases": [],
|
||||
"summary": "测试下载流(推送 10 个数据帧,验证流式传输,不触达 QQ)",
|
||||
"returns": "流式帧:data_chunk*10 → data_complete(error=true 时以 error 帧结束)",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "error",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"default": false,
|
||||
"desc": "是否触发测试错误"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "boolean",
|
||||
"description": "是否触发测试错误",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "trans_group_file",
|
||||
"aliases": [],
|
||||
@@ -8624,6 +8845,181 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "空间"
|
||||
},
|
||||
{
|
||||
"name": "upload_file_stream",
|
||||
"aliases": [],
|
||||
"summary": "以流式分块方式上传文件到机器人本地(返回可用于发送的本地路径)",
|
||||
"returns": "流式帧:分块确认 type=stream、完成 type=response(含 file_path/file_size/sha256)",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "stream_id",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"desc": "流 ID(客户端生成的 UUID,限 [A-Za-z0-9_-])"
|
||||
},
|
||||
{
|
||||
"name": "chunk_data",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "分块数据(Base64)"
|
||||
},
|
||||
{
|
||||
"name": "chunk_index",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"desc": "分块索引(从 0 开始)"
|
||||
},
|
||||
{
|
||||
"name": "total_chunks",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"desc": "总分块数(新流必填)"
|
||||
},
|
||||
{
|
||||
"name": "file_size",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"desc": "文件总大小(字节)"
|
||||
},
|
||||
{
|
||||
"name": "expected_sha256",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "期望的整文件 SHA256(校验)"
|
||||
},
|
||||
{
|
||||
"name": "is_complete",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"desc": "是否为最后一个分块/触发合并"
|
||||
},
|
||||
{
|
||||
"name": "filename",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": "文件名"
|
||||
},
|
||||
{
|
||||
"name": "reset",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"desc": "重置并丢弃该流"
|
||||
},
|
||||
{
|
||||
"name": "verify_only",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"desc": "仅查询当前流状态"
|
||||
},
|
||||
{
|
||||
"name": "file_retention",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"default": 300000,
|
||||
"desc": "合并文件保留毫秒(0=不回收)"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"stream_id": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "流 ID(客户端生成的 UUID,限 [A-Za-z0-9_-])"
|
||||
},
|
||||
"chunk_data": {
|
||||
"type": "string",
|
||||
"description": "分块数据(Base64)"
|
||||
},
|
||||
"chunk_index": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "分块索引(从 0 开始)"
|
||||
},
|
||||
"total_chunks": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "总分块数(新流必填)"
|
||||
},
|
||||
"file_size": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "文件总大小(字节)"
|
||||
},
|
||||
"expected_sha256": {
|
||||
"type": "string",
|
||||
"description": "期望的整文件 SHA256(校验)"
|
||||
},
|
||||
"is_complete": {
|
||||
"type": "boolean",
|
||||
"description": "是否为最后一个分块/触发合并"
|
||||
},
|
||||
"filename": {
|
||||
"type": "string",
|
||||
"description": "文件名"
|
||||
},
|
||||
"reset": {
|
||||
"type": "boolean",
|
||||
"description": "重置并丢弃该流"
|
||||
},
|
||||
"verify_only": {
|
||||
"type": "boolean",
|
||||
"description": "仅查询当前流状态"
|
||||
},
|
||||
"file_retention": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "合并文件保留毫秒(0=不回收)",
|
||||
"default": 300000
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"stream_id"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "流式接口"
|
||||
},
|
||||
{
|
||||
"name": "upload_forward_msg",
|
||||
"aliases": [],
|
||||
@@ -9017,5 +9413,9 @@ export const CATEGORIES: CatalogCategory[] = [
|
||||
{
|
||||
"category": "空间",
|
||||
"count": 7
|
||||
},
|
||||
{
|
||||
"category": "流式接口",
|
||||
"count": 6
|
||||
}
|
||||
];
|
||||
@@ -12,7 +12,7 @@
|
||||
// deferred product decision; this module produces format-agnostic data plus a
|
||||
// Markdown default. Point any renderer at `collectActionDocs()`.
|
||||
|
||||
import type { ActionDoc, ActionSpec, Field } from './action-kit';
|
||||
import type { ActionDoc } from './action-kit';
|
||||
import { actions as infoActions } from './actions/info';
|
||||
import { actions as messageActions } from './actions/message';
|
||||
import { actions as friendActions } from './actions/friend';
|
||||
@@ -23,8 +23,13 @@ import { actions as requestActions } from './actions/request';
|
||||
import { actions as extendedActions } from './actions/extended';
|
||||
import { actions as groupAlbumActions } from './actions/group-album';
|
||||
import { actions as qzoneActions } from './actions/qzone';
|
||||
import { actions as streamFileActions } from './actions/stream-file';
|
||||
import { actions as streamDownloadActions } from './actions/stream-download';
|
||||
|
||||
type AnySpec = ActionSpec<Record<string, Field<unknown>>>;
|
||||
// The doc collector only ever calls `describe()`, so any spec carrying it
|
||||
// qualifies — this admits both `defineAction` (ActionSpec) and
|
||||
// `defineStreamAction` (StreamActionSpec) results without coupling to either.
|
||||
type AnySpec = { describe(): ActionDoc };
|
||||
|
||||
// Source file = domain category. Each doc is tagged so the MCP / UI can group.
|
||||
const GROUPS: ReadonlyArray<{ category: string; specs: readonly AnySpec[] }> = [
|
||||
@@ -38,6 +43,7 @@ const GROUPS: ReadonlyArray<{ category: string; specs: readonly AnySpec[] }> = [
|
||||
{ category: '扩展', specs: extendedActions },
|
||||
{ category: '群相册', specs: groupAlbumActions },
|
||||
{ category: '空间', specs: qzoneActions },
|
||||
{ category: '流式接口', specs: [...streamFileActions, ...streamDownloadActions] },
|
||||
];
|
||||
|
||||
/** Every declarative action's doc (with category), sorted by name. */
|
||||
|
||||
@@ -368,11 +368,10 @@ const testDownloadStream = defineStreamAction({
|
||||
},
|
||||
});
|
||||
|
||||
export const actions = [downloadFileStream, downloadFileImageStream, downloadFileRecordStream, testDownloadStream];
|
||||
|
||||
export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
downloadFileStream.register(h, ctx);
|
||||
downloadFileImageStream.register(h, ctx);
|
||||
downloadFileRecordStream.register(h, ctx);
|
||||
testDownloadStream.register(h, ctx);
|
||||
for (const a of actions) a.register(h, ctx);
|
||||
}
|
||||
|
||||
// Exposed for tests.
|
||||
|
||||
@@ -359,9 +359,10 @@ const cleanStreamTempFile = defineAction({
|
||||
},
|
||||
});
|
||||
|
||||
export const actions = [uploadFileStream, cleanStreamTempFile];
|
||||
|
||||
export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
uploadFileStream.register(h, ctx);
|
||||
cleanStreamTempFile.register(h, ctx);
|
||||
for (const a of actions) a.register(h, ctx);
|
||||
}
|
||||
|
||||
// Exposed for tests.
|
||||
|
||||
Reference in new issue
Block a user