From f9900053b0e75560936cf014201478dce13b2078 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Tue, 30 Jun 2026 16:00:21 +0800 Subject: [PATCH] feat(onebot): backfill semantic roles across action params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1 of the debug-console expansion. Sweeps the 8 action files, swapping bare coercion primitives for the role-stamped equivalents from Phase 0 (or appending `.role()` where a `.default()`/`.optional()` field must keep its exact coercion). Coercion is byte-for-byte unchanged; the only intentional bound change is face_id min 1→0 (QQ face 0 is valid). Classification (verified against each run()): - group_id → f.groupId() everywhere. - user_id → f.userId() for any-user / friend / stranger / private-route targets (send_private, friend poke, friend add/remove, stranger info, private file transfer, forward-to-friend, share-contact). - user_id → f.memberId() only when it's a member of a sibling group_id (batch kick elements; the groupUserAction preset already injects it). - media file/image/record + file_id → f.file()/image()/record()/fileId() (or .role() when defaulted/optional); message_id/timestamp/duration via the constructor or .role() hatch as coercion requires. Polymorphic ids left as bare uint on purpose (no single role can honestly describe them): mark_msg_as_read.target_id (group# or uin), bot_appid, msg_seq, fileset_id, folder_id, chunk indices, stream_id. Catalog regenerated: 71 group_id / 25 user_id / 9 member_id / 19 message_id / 11 file_id / 7 image / 6 file roles surfaced. Done by 4 parallel agents; adversarially reviewed — zero coercion regressions, zero member/user misclassifications. --- packages/mcp/src/generated/catalog.json | 336 +++++++++++++----- packages/mcp/src/generated/catalog.ts | 336 +++++++++++++----- packages/onebot/src/actions/extended.ts | 86 ++--- packages/onebot/src/actions/friend.ts | 4 +- packages/onebot/src/actions/group-admin.ts | 6 +- packages/onebot/src/actions/group-album.ts | 2 +- packages/onebot/src/actions/group-file.ts | 18 +- packages/onebot/src/actions/message.ts | 6 +- packages/onebot/src/actions/qzone.ts | 12 +- .../onebot/src/actions/stream-download.ts | 4 +- 10 files changed, 551 insertions(+), 259 deletions(-) diff --git a/packages/mcp/src/generated/catalog.json b/packages/mcp/src/generated/catalog.json index a1868b97..b9bb2c6a 100644 --- a/packages/mcp/src/generated/catalog.json +++ b/packages/mcp/src/generated/catalog.json @@ -199,7 +199,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "image" }, { "name": "pinned", @@ -236,7 +237,8 @@ }, "image": { "type": "string", - "default": "" + "default": "", + "x-role": "image" }, "pinned": {}, "type": {}, @@ -288,6 +290,7 @@ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -300,7 +303,8 @@ "properties": { "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -656,6 +660,7 @@ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -693,7 +698,8 @@ "target_uin": { "type": "integer", "minimum": 1, - "description": "说说所属 QQ 号,省略则为机器人自己" + "description": "说说所属 QQ 号,省略则为机器人自己", + "x-role": "user_id" }, "images": { "type": "array", @@ -1065,6 +1071,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -1088,7 +1095,8 @@ "user_id": { "type": "integer", "minimum": 1, - "description": "QQ 号" + "description": "QQ 号", + "x-role": "user_id" }, "block": { "type": "boolean", @@ -1123,6 +1131,7 @@ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -1141,7 +1150,8 @@ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" } }, "required": [ @@ -1471,7 +1481,8 @@ "schema": { "type": "string" }, - "desc": "文件路径(限 stream 临时目录)/ http(s) URL" + "desc": "文件路径(限 stream 临时目录)/ http(s) URL", + "role": "file" }, { "name": "file_id", @@ -1480,7 +1491,8 @@ "schema": { "type": "string" }, - "desc": "文件 ID(缓存的图片/语音 id)" + "desc": "文件 ID(缓存的图片/语音 id)", + "role": "file_id" }, { "name": "chunk_size", @@ -1499,11 +1511,13 @@ "properties": { "file": { "type": "string", - "description": "文件路径(限 stream 临时目录)/ http(s) URL" + "description": "文件路径(限 stream 临时目录)/ http(s) URL", + "x-role": "file" }, "file_id": { "type": "string", - "description": "文件 ID(缓存的图片/语音 id)" + "description": "文件 ID(缓存的图片/语音 id)", + "x-role": "file_id" }, "chunk_size": { "type": "integer", @@ -1530,7 +1544,8 @@ "schema": { "type": "string" }, - "desc": "文件路径(限 stream 临时目录)/ http(s) URL" + "desc": "文件路径(限 stream 临时目录)/ http(s) URL", + "role": "file" }, { "name": "file_id", @@ -1539,7 +1554,8 @@ "schema": { "type": "string" }, - "desc": "文件 ID(缓存的图片/语音 id)" + "desc": "文件 ID(缓存的图片/语音 id)", + "role": "file_id" }, { "name": "chunk_size", @@ -1558,11 +1574,13 @@ "properties": { "file": { "type": "string", - "description": "文件路径(限 stream 临时目录)/ http(s) URL" + "description": "文件路径(限 stream 临时目录)/ http(s) URL", + "x-role": "file" }, "file_id": { "type": "string", - "description": "文件 ID(缓存的图片/语音 id)" + "description": "文件 ID(缓存的图片/语音 id)", + "x-role": "file_id" }, "chunk_size": { "type": "integer", @@ -1589,7 +1607,8 @@ "schema": { "type": "string" }, - "desc": "文件路径(限 stream 临时目录)/ http(s) URL" + "desc": "文件路径(限 stream 临时目录)/ http(s) URL", + "role": "file" }, { "name": "file_id", @@ -1598,7 +1617,8 @@ "schema": { "type": "string" }, - "desc": "文件 ID(缓存的图片/语音 id)" + "desc": "文件 ID(缓存的图片/语音 id)", + "role": "file_id" }, { "name": "chunk_size", @@ -1617,11 +1637,13 @@ "properties": { "file": { "type": "string", - "description": "文件路径(限 stream 临时目录)/ http(s) URL" + "description": "文件路径(限 stream 临时目录)/ http(s) URL", + "x-role": "file" }, "file_id": { "type": "string", - "description": "文件 ID(缓存的图片/语音 id)" + "description": "文件 ID(缓存的图片/语音 id)", + "x-role": "file_id" }, "chunk_size": { "type": "integer", @@ -1910,7 +1932,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "message_id" } ], "invariants": [], @@ -1919,7 +1942,8 @@ "properties": { "message_id": { "type": "string", - "default": "" + "default": "", + "x-role": "message_id" } }, "additionalProperties": true @@ -1948,6 +1972,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -1967,7 +1992,8 @@ }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -2000,6 +2026,7 @@ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -2019,7 +2046,8 @@ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -2040,6 +2068,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -2049,6 +2078,7 @@ "name": "target_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -2061,11 +2091,13 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "target_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -2623,7 +2655,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file_id" }, { "name": "file", @@ -2632,7 +2665,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file" } ], "invariants": [], @@ -2641,11 +2675,13 @@ "properties": { "file_id": { "type": "string", - "default": "" + "default": "", + "x-role": "file_id" }, "file": { "type": "string", - "default": "" + "default": "", + "x-role": "file" } }, "additionalProperties": true @@ -2924,6 +2960,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -2936,7 +2973,8 @@ "schema": { "type": "integer" }, - "default": 0 + "default": 0, + "role": "message_id" }, { "name": "count", @@ -2955,11 +2993,13 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "message_id": { "type": "integer", - "default": 0 + "default": 0, + "x-role": "message_id" }, "count": { "type": "integer", @@ -3207,6 +3247,7 @@ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -3219,7 +3260,8 @@ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -3327,6 +3369,7 @@ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -3351,7 +3394,8 @@ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "busid": {} }, @@ -3805,6 +3849,7 @@ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -3817,7 +3862,8 @@ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -4178,7 +4224,8 @@ "schema": { "type": "integer" }, - "default": 0 + "default": 0, + "role": "message_id" }, { "name": "count", @@ -4203,7 +4250,8 @@ }, "message_id": { "type": "integer", - "default": 0 + "default": 0, + "x-role": "message_id" }, "count": { "type": "integer", @@ -4479,7 +4527,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "image" }, { "name": "file_id", @@ -4488,7 +4537,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file_id" } ], "invariants": [], @@ -4497,11 +4547,13 @@ "properties": { "file": { "type": "string", - "default": "" + "default": "", + "x-role": "image" }, "file_id": { "type": "string", - "default": "" + "default": "", + "x-role": "file_id" } }, "additionalProperties": true @@ -4642,6 +4694,7 @@ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -4651,6 +4704,7 @@ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -4672,11 +4726,13 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "file_hash": { "type": "string", @@ -4772,7 +4828,8 @@ "type": "integer", "minimum": 0 }, - "default": 0 + "default": 0, + "role": "user_id" }, { "name": "start", @@ -4802,7 +4859,8 @@ "user_id": { "type": "integer", "minimum": 0, - "default": 0 + "default": 0, + "x-role": "user_id" }, "start": { "type": "integer", @@ -5079,6 +5137,7 @@ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5116,7 +5175,8 @@ "target_uin": { "type": "integer", "minimum": 1, - "description": "目标 QQ 号,省略则取机器人自己" + "description": "目标 QQ 号,省略则取机器人自己", + "x-role": "user_id" }, "pos": { "type": "integer", @@ -5185,7 +5245,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "record" }, { "name": "file_id", @@ -5194,7 +5255,8 @@ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file_id" } ], "invariants": [], @@ -5203,11 +5265,13 @@ "properties": { "file": { "type": "string", - "default": "" + "default": "", + "x-role": "record" }, "file_id": { "type": "string", - "default": "" + "default": "", + "x-role": "file_id" } }, "additionalProperties": true @@ -5379,6 +5443,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5393,7 +5458,8 @@ "user_id": { "type": "integer", "minimum": 1, - "description": "QQ 号" + "description": "QQ 号", + "x-role": "user_id" } }, "required": [ @@ -5527,6 +5593,7 @@ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5542,7 +5609,8 @@ "minimum": 0 }, "desc": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "role": "timestamp" } ], "invariants": [], @@ -5557,13 +5625,15 @@ "target_uin": { "type": "integer", "minimum": 1, - "description": "说说所属 QQ 号,省略则为机器人自己" + "description": "说说所属 QQ 号,省略则为机器人自己", + "x-role": "user_id" }, "abstime": { "type": "integer", "minimum": 0, "description": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "x-role": "timestamp" } }, "required": [ @@ -5609,6 +5679,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -5628,7 +5699,8 @@ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -5711,6 +5783,7 @@ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5730,7 +5803,8 @@ }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -5838,6 +5912,7 @@ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -5874,7 +5949,8 @@ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "parent_directory": { "type": "string", @@ -5942,6 +6018,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5954,7 +6031,8 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -6033,6 +6111,7 @@ "name": "image", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -6045,7 +6124,8 @@ "properties": { "image": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -6122,6 +6202,7 @@ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -6158,7 +6239,8 @@ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "current_parent_directory": { "type": "string", @@ -6309,6 +6391,7 @@ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6318,6 +6401,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6339,11 +6423,13 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "phone_number": { "type": "string", @@ -6374,6 +6460,7 @@ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6383,6 +6470,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6399,11 +6487,13 @@ }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -6546,6 +6636,7 @@ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6558,7 +6649,8 @@ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -6699,6 +6791,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6721,7 +6814,8 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "times": { "type": "integer", @@ -6763,6 +6857,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6772,6 +6867,7 @@ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6799,11 +6895,13 @@ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "auto_escape": { "type": "boolean", @@ -6887,6 +6985,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6896,6 +6995,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6908,11 +7008,13 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -6933,6 +7035,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6961,7 +7064,8 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "messages": { "description": "OneBot message: string | segment[] | object" @@ -6988,6 +7092,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -7017,7 +7122,8 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "message": { "description": "OneBot message: string | segment[] | object" @@ -7098,11 +7204,12 @@ "params": [ { "name": "face_id", - "type": "uint", + "type": "int", "required": true, + "role": "face_id", "schema": { "type": "integer", - "minimum": 1 + "minimum": 0 } }, { @@ -7131,7 +7238,8 @@ "properties": { "face_id": { "type": "integer", - "minimum": 1 + "minimum": 0, + "x-role": "face_id" }, "face_type": { "type": "integer", @@ -7288,6 +7396,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -7308,7 +7417,8 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "remark": { "type": "string" @@ -7646,6 +7756,7 @@ "name": "duration", "type": "int", "required": false, + "role": "duration", "schema": { "type": "integer", "minimum": 0 @@ -7672,7 +7783,8 @@ "duration": { "type": "integer", "minimum": 0, - "default": 1800 + "default": 1800, + "x-role": "duration" } }, "required": [ @@ -7842,7 +7954,8 @@ "type": "array", "items": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "member_id" }, "minItems": 1 } @@ -7871,7 +7984,8 @@ "type": "array", "items": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "member_id" }, "minItems": 1 }, @@ -7994,6 +8108,7 @@ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -8012,7 +8127,8 @@ }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -8033,6 +8149,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8075,7 +8192,8 @@ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "message_id": { "type": "integer", @@ -8111,6 +8229,7 @@ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8131,7 +8250,8 @@ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "remark": { "type": "string" @@ -8463,6 +8583,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -8484,7 +8605,8 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "event_type": { "type": "integer", @@ -8639,6 +8761,7 @@ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -8651,7 +8774,8 @@ "properties": { "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -8758,6 +8882,7 @@ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8770,7 +8895,8 @@ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -8803,6 +8929,7 @@ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -8812,6 +8939,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8833,11 +8961,13 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "phone_number": { "type": "string", @@ -8954,6 +9084,7 @@ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -8969,7 +9100,8 @@ "minimum": 0 }, "desc": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "role": "timestamp" } ], "invariants": [], @@ -8984,13 +9116,15 @@ "target_uin": { "type": "integer", "minimum": 1, - "description": "说说所属 QQ 号,省略则为机器人自己" + "description": "说说所属 QQ 号,省略则为机器人自己", + "x-role": "user_id" }, "abstime": { "type": "integer", "minimum": 0, "description": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "x-role": "timestamp" } }, "required": [ @@ -9202,6 +9336,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -9220,7 +9355,8 @@ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "additionalProperties": true @@ -9253,6 +9389,7 @@ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -9271,7 +9408,8 @@ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "additionalProperties": true @@ -9300,6 +9438,7 @@ "name": "file", "type": "string", "required": true, + "role": "file", "schema": { "type": "string", "minLength": 1 @@ -9354,7 +9493,8 @@ }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file" }, "name": { "type": "string", @@ -9419,6 +9559,7 @@ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -9445,7 +9586,8 @@ }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -9469,6 +9611,7 @@ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -9478,6 +9621,7 @@ "name": "file", "type": "string", "required": true, + "role": "file", "schema": { "type": "string", "minLength": 1 @@ -9508,11 +9652,13 @@ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file" }, "name": { "type": "string", diff --git a/packages/mcp/src/generated/catalog.ts b/packages/mcp/src/generated/catalog.ts index 2423e2b5..001b98c7 100644 --- a/packages/mcp/src/generated/catalog.ts +++ b/packages/mcp/src/generated/catalog.ts @@ -202,7 +202,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "image" }, { "name": "pinned", @@ -239,7 +240,8 @@ export const ACTIONS: CatalogAction[] = [ }, "image": { "type": "string", - "default": "" + "default": "", + "x-role": "image" }, "pinned": {}, "type": {}, @@ -291,6 +293,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -303,7 +306,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -659,6 +663,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -696,7 +701,8 @@ export const ACTIONS: CatalogAction[] = [ "target_uin": { "type": "integer", "minimum": 1, - "description": "说说所属 QQ 号,省略则为机器人自己" + "description": "说说所属 QQ 号,省略则为机器人自己", + "x-role": "user_id" }, "images": { "type": "array", @@ -1068,6 +1074,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -1091,7 +1098,8 @@ export const ACTIONS: CatalogAction[] = [ "user_id": { "type": "integer", "minimum": 1, - "description": "QQ 号" + "description": "QQ 号", + "x-role": "user_id" }, "block": { "type": "boolean", @@ -1126,6 +1134,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -1144,7 +1153,8 @@ export const ACTIONS: CatalogAction[] = [ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" } }, "required": [ @@ -1474,7 +1484,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "desc": "文件路径(限 stream 临时目录)/ http(s) URL" + "desc": "文件路径(限 stream 临时目录)/ http(s) URL", + "role": "file" }, { "name": "file_id", @@ -1483,7 +1494,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "desc": "文件 ID(缓存的图片/语音 id)" + "desc": "文件 ID(缓存的图片/语音 id)", + "role": "file_id" }, { "name": "chunk_size", @@ -1502,11 +1514,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file": { "type": "string", - "description": "文件路径(限 stream 临时目录)/ http(s) URL" + "description": "文件路径(限 stream 临时目录)/ http(s) URL", + "x-role": "file" }, "file_id": { "type": "string", - "description": "文件 ID(缓存的图片/语音 id)" + "description": "文件 ID(缓存的图片/语音 id)", + "x-role": "file_id" }, "chunk_size": { "type": "integer", @@ -1533,7 +1547,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "desc": "文件路径(限 stream 临时目录)/ http(s) URL" + "desc": "文件路径(限 stream 临时目录)/ http(s) URL", + "role": "file" }, { "name": "file_id", @@ -1542,7 +1557,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "desc": "文件 ID(缓存的图片/语音 id)" + "desc": "文件 ID(缓存的图片/语音 id)", + "role": "file_id" }, { "name": "chunk_size", @@ -1561,11 +1577,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file": { "type": "string", - "description": "文件路径(限 stream 临时目录)/ http(s) URL" + "description": "文件路径(限 stream 临时目录)/ http(s) URL", + "x-role": "file" }, "file_id": { "type": "string", - "description": "文件 ID(缓存的图片/语音 id)" + "description": "文件 ID(缓存的图片/语音 id)", + "x-role": "file_id" }, "chunk_size": { "type": "integer", @@ -1592,7 +1610,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "desc": "文件路径(限 stream 临时目录)/ http(s) URL" + "desc": "文件路径(限 stream 临时目录)/ http(s) URL", + "role": "file" }, { "name": "file_id", @@ -1601,7 +1620,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "desc": "文件 ID(缓存的图片/语音 id)" + "desc": "文件 ID(缓存的图片/语音 id)", + "role": "file_id" }, { "name": "chunk_size", @@ -1620,11 +1640,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file": { "type": "string", - "description": "文件路径(限 stream 临时目录)/ http(s) URL" + "description": "文件路径(限 stream 临时目录)/ http(s) URL", + "x-role": "file" }, "file_id": { "type": "string", - "description": "文件 ID(缓存的图片/语音 id)" + "description": "文件 ID(缓存的图片/语音 id)", + "x-role": "file_id" }, "chunk_size": { "type": "integer", @@ -1913,7 +1935,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "message_id" } ], "invariants": [], @@ -1922,7 +1945,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "message_id": { "type": "string", - "default": "" + "default": "", + "x-role": "message_id" } }, "additionalProperties": true @@ -1951,6 +1975,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -1970,7 +1995,8 @@ export const ACTIONS: CatalogAction[] = [ }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -2003,6 +2029,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -2022,7 +2049,8 @@ export const ACTIONS: CatalogAction[] = [ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -2043,6 +2071,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -2052,6 +2081,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "target_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -2064,11 +2094,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "target_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -2626,7 +2658,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file_id" }, { "name": "file", @@ -2635,7 +2668,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file" } ], "invariants": [], @@ -2644,11 +2678,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file_id": { "type": "string", - "default": "" + "default": "", + "x-role": "file_id" }, "file": { "type": "string", - "default": "" + "default": "", + "x-role": "file" } }, "additionalProperties": true @@ -2927,6 +2963,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -2939,7 +2976,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "integer" }, - "default": 0 + "default": 0, + "role": "message_id" }, { "name": "count", @@ -2958,11 +2996,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "message_id": { "type": "integer", - "default": 0 + "default": 0, + "x-role": "message_id" }, "count": { "type": "integer", @@ -3210,6 +3250,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -3222,7 +3263,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -3330,6 +3372,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -3354,7 +3397,8 @@ export const ACTIONS: CatalogAction[] = [ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "busid": {} }, @@ -3808,6 +3852,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -3820,7 +3865,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -4181,7 +4227,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "integer" }, - "default": 0 + "default": 0, + "role": "message_id" }, { "name": "count", @@ -4206,7 +4253,8 @@ export const ACTIONS: CatalogAction[] = [ }, "message_id": { "type": "integer", - "default": 0 + "default": 0, + "x-role": "message_id" }, "count": { "type": "integer", @@ -4482,7 +4530,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "image" }, { "name": "file_id", @@ -4491,7 +4540,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file_id" } ], "invariants": [], @@ -4500,11 +4550,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file": { "type": "string", - "default": "" + "default": "", + "x-role": "image" }, "file_id": { "type": "string", - "default": "" + "default": "", + "x-role": "file_id" } }, "additionalProperties": true @@ -4645,6 +4697,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -4654,6 +4707,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -4675,11 +4729,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "file_hash": { "type": "string", @@ -4775,7 +4831,8 @@ export const ACTIONS: CatalogAction[] = [ "type": "integer", "minimum": 0 }, - "default": 0 + "default": 0, + "role": "user_id" }, { "name": "start", @@ -4805,7 +4862,8 @@ export const ACTIONS: CatalogAction[] = [ "user_id": { "type": "integer", "minimum": 0, - "default": 0 + "default": 0, + "x-role": "user_id" }, "start": { "type": "integer", @@ -5082,6 +5140,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5119,7 +5178,8 @@ export const ACTIONS: CatalogAction[] = [ "target_uin": { "type": "integer", "minimum": 1, - "description": "目标 QQ 号,省略则取机器人自己" + "description": "目标 QQ 号,省略则取机器人自己", + "x-role": "user_id" }, "pos": { "type": "integer", @@ -5188,7 +5248,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "record" }, { "name": "file_id", @@ -5197,7 +5258,8 @@ export const ACTIONS: CatalogAction[] = [ "schema": { "type": "string" }, - "default": "" + "default": "", + "role": "file_id" } ], "invariants": [], @@ -5206,11 +5268,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file": { "type": "string", - "default": "" + "default": "", + "x-role": "record" }, "file_id": { "type": "string", - "default": "" + "default": "", + "x-role": "file_id" } }, "additionalProperties": true @@ -5382,6 +5446,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5396,7 +5461,8 @@ export const ACTIONS: CatalogAction[] = [ "user_id": { "type": "integer", "minimum": 1, - "description": "QQ 号" + "description": "QQ 号", + "x-role": "user_id" } }, "required": [ @@ -5530,6 +5596,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5545,7 +5612,8 @@ export const ACTIONS: CatalogAction[] = [ "minimum": 0 }, "desc": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "role": "timestamp" } ], "invariants": [], @@ -5560,13 +5628,15 @@ export const ACTIONS: CatalogAction[] = [ "target_uin": { "type": "integer", "minimum": 1, - "description": "说说所属 QQ 号,省略则为机器人自己" + "description": "说说所属 QQ 号,省略则为机器人自己", + "x-role": "user_id" }, "abstime": { "type": "integer", "minimum": 0, "description": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "x-role": "timestamp" } }, "required": [ @@ -5612,6 +5682,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -5631,7 +5702,8 @@ export const ACTIONS: CatalogAction[] = [ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -5714,6 +5786,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5733,7 +5806,8 @@ export const ACTIONS: CatalogAction[] = [ }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -5841,6 +5915,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -5877,7 +5952,8 @@ export const ACTIONS: CatalogAction[] = [ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "parent_directory": { "type": "string", @@ -5945,6 +6021,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -5957,7 +6034,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" } }, "required": [ @@ -6036,6 +6114,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "image", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -6048,7 +6127,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "image": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -6125,6 +6205,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file_id", "type": "string", "required": true, + "role": "file_id", "schema": { "type": "string", "minLength": 1 @@ -6161,7 +6242,8 @@ export const ACTIONS: CatalogAction[] = [ }, "file_id": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file_id" }, "current_parent_directory": { "type": "string", @@ -6312,6 +6394,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6321,6 +6404,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6342,11 +6426,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "phone_number": { "type": "string", @@ -6377,6 +6463,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6386,6 +6473,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6402,11 +6490,13 @@ export const ACTIONS: CatalogAction[] = [ }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -6549,6 +6639,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6561,7 +6652,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -6702,6 +6794,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6724,7 +6817,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "times": { "type": "integer", @@ -6766,6 +6860,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6775,6 +6870,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6802,11 +6898,13 @@ export const ACTIONS: CatalogAction[] = [ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "auto_escape": { "type": "boolean", @@ -6890,6 +6988,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6899,6 +6998,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -6911,11 +7011,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -6936,6 +7038,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -6964,7 +7067,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "messages": { "description": "OneBot message: string | segment[] | object" @@ -6991,6 +7095,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -7020,7 +7125,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "message": { "description": "OneBot message: string | segment[] | object" @@ -7101,11 +7207,12 @@ export const ACTIONS: CatalogAction[] = [ "params": [ { "name": "face_id", - "type": "uint", + "type": "int", "required": true, + "role": "face_id", "schema": { "type": "integer", - "minimum": 1 + "minimum": 0 } }, { @@ -7134,7 +7241,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "face_id": { "type": "integer", - "minimum": 1 + "minimum": 0, + "x-role": "face_id" }, "face_type": { "type": "integer", @@ -7291,6 +7399,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -7311,7 +7420,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "remark": { "type": "string" @@ -7649,6 +7759,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "duration", "type": "int", "required": false, + "role": "duration", "schema": { "type": "integer", "minimum": 0 @@ -7675,7 +7786,8 @@ export const ACTIONS: CatalogAction[] = [ "duration": { "type": "integer", "minimum": 0, - "default": 1800 + "default": 1800, + "x-role": "duration" } }, "required": [ @@ -7845,7 +7957,8 @@ export const ACTIONS: CatalogAction[] = [ "type": "array", "items": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "member_id" }, "minItems": 1 } @@ -7874,7 +7987,8 @@ export const ACTIONS: CatalogAction[] = [ "type": "array", "items": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "member_id" }, "minItems": 1 }, @@ -7997,6 +8111,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -8015,7 +8130,8 @@ export const ACTIONS: CatalogAction[] = [ }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -8036,6 +8152,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8078,7 +8195,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "message_id": { "type": "integer", @@ -8114,6 +8232,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8134,7 +8253,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "remark": { "type": "string" @@ -8466,6 +8586,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -8487,7 +8608,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "event_type": { "type": "integer", @@ -8642,6 +8764,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -8654,7 +8777,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -8761,6 +8885,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": true, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8773,7 +8898,8 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "required": [ @@ -8806,6 +8932,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -8815,6 +8942,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -8836,11 +8964,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" }, "phone_number": { "type": "string", @@ -8957,6 +9087,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "target_uin", "type": "uint", "required": false, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -8972,7 +9103,8 @@ export const ACTIONS: CatalogAction[] = [ "minimum": 0 }, "desc": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "role": "timestamp" } ], "invariants": [], @@ -8987,13 +9119,15 @@ export const ACTIONS: CatalogAction[] = [ "target_uin": { "type": "integer", "minimum": 1, - "description": "说说所属 QQ 号,省略则为机器人自己" + "description": "说说所属 QQ 号,省略则为机器人自己", + "x-role": "user_id" }, "abstime": { "type": "integer", "minimum": 0, "description": "说说发表时间(unix 秒),传真实值更可靠", - "default": 0 + "default": 0, + "x-role": "timestamp" } }, "required": [ @@ -9205,6 +9339,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -9223,7 +9358,8 @@ export const ACTIONS: CatalogAction[] = [ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "additionalProperties": true @@ -9256,6 +9392,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "group_id", "type": "uint", "required": false, + "role": "group_id", "schema": { "type": "integer", "minimum": 1 @@ -9274,7 +9411,8 @@ export const ACTIONS: CatalogAction[] = [ }, "group_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "group_id" } }, "additionalProperties": true @@ -9303,6 +9441,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file", "type": "string", "required": true, + "role": "file", "schema": { "type": "string", "minLength": 1 @@ -9357,7 +9496,8 @@ export const ACTIONS: CatalogAction[] = [ }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file" }, "name": { "type": "string", @@ -9422,6 +9562,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file", "type": "string", "required": true, + "role": "image", "schema": { "type": "string", "minLength": 1 @@ -9448,7 +9589,8 @@ export const ACTIONS: CatalogAction[] = [ }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "image" } }, "required": [ @@ -9472,6 +9614,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "user_id", "type": "uint", "required": true, + "role": "user_id", "schema": { "type": "integer", "minimum": 1 @@ -9481,6 +9624,7 @@ export const ACTIONS: CatalogAction[] = [ "name": "file", "type": "string", "required": true, + "role": "file", "schema": { "type": "string", "minLength": 1 @@ -9511,11 +9655,13 @@ export const ACTIONS: CatalogAction[] = [ "properties": { "user_id": { "type": "integer", - "minimum": 1 + "minimum": 1, + "x-role": "user_id" }, "file": { "type": "string", - "minLength": 1 + "minLength": 1, + "x-role": "file" }, "name": { "type": "string", diff --git a/packages/onebot/src/actions/extended.ts b/packages/onebot/src/actions/extended.ts index 56b06ce6..f6c86d84 100644 --- a/packages/onebot/src/actions/extended.ts +++ b/packages/onebot/src/actions/extended.ts @@ -141,7 +141,7 @@ export const actions = [ name: 'send_like', summary: '点赞', params: { - user_id: f.uint(), + user_id: f.userId(), // 原实现用 `asNumber(times) || 1`,present 0 会被当作缺省 1。 times: f.int({ min: 0 }).default(1), }, @@ -155,8 +155,8 @@ export const actions = [ name: 'friend_poke', summary: '好友拍一拍', params: { - user_id: f.uint(), - target_id: f.uint().optional(), + user_id: f.userId(), + target_id: f.userId().optional(), }, run: async (p, ctx) => { await ctx.bridge.apis.interaction.sendPoke(false, p.user_id, p.target_id); @@ -177,8 +177,8 @@ export const actions = [ name: 'send_poke', summary: '拍一拍(群聊/私聊自动路由)', params: { - user_id: f.uint(), - group_id: f.uint().optional(), + user_id: f.userId(), + group_id: f.groupId().optional(), }, run: async (p, ctx) => { if (p.group_id) { @@ -233,7 +233,7 @@ export const actions = [ name: 'set_group_reaction', summary: '群聊表情回应', params: { - group_id: f.uint().optional(), + group_id: f.groupId().optional(), message_id: f.messageId(), code: f.string({ allowEmpty: false }), is_set: f.bool().default(true), @@ -272,7 +272,7 @@ export const actions = [ defineAction({ name: 'add_custom_face', summary: '添加收藏表情', - params: { file: f.string({ allowEmpty: false }) }, + params: { file: f.image() }, run: async (p, ctx) => { try { const emojiId = await ctx.bridge.apis.profile.addCustomFace(p.file); @@ -339,7 +339,7 @@ export const actions = [ // param-validation time (retcode 1400) before run() ever fires. Use a // plain signed int; `.default(0)` keeps absent/present-0 → "fetch latest" // (matches the original `asNumber(message_id) || 0`). `count` stays ≥0. - message_id: f.int().default(0), + message_id: f.int().default(0).role('message_id'), count: f.int({ min: 0 }).default(20), }, run: async (p, ctx) => { @@ -361,9 +361,9 @@ export const actions = [ required: ['messages'], }, params: { - user_id: f.uint(), + user_id: f.userId(), // Signed int32 hash, frequently negative — see get_group_msg_history. - message_id: f.int().default(0), + message_id: f.int().default(0).role('message_id'), count: f.int({ min: 0 }).default(20), }, run: async (p, ctx) => { @@ -378,7 +378,7 @@ export const actions = [ summary: '标记群消息已读', params: { message_id: f.messageId(), - group_id: f.uint().optional(), + group_id: f.groupId().optional(), }, run: async (p, ctx) => { const meta = ctx.getMessageMeta(p.message_id); @@ -400,7 +400,7 @@ export const actions = [ summary: '标记私聊消息已读', params: { message_id: f.messageId(), - user_id: f.uint().optional(), + user_id: f.userId().optional(), }, run: async (p, ctx) => { const meta = ctx.getMessageMeta(p.message_id); @@ -447,7 +447,7 @@ export const actions = [ summary: '发送群公告', params: { content: f.string({ allowEmpty: false }), - image: f.string().default(''), + image: f.string().default('').role('image'), pinned: f.raw(), type: f.raw(), confirm_required: f.raw(), @@ -490,7 +490,7 @@ export const actions = [ params: { messages: f.message().optional(), message: f.message().optional(), - group_id: f.uint().optional(), + group_id: f.groupId().optional(), }, run: async (p, ctx) => { const messages = p.messages ?? p.message; @@ -514,7 +514,7 @@ export const actions = [ params: { messages: f.message().optional(), message: f.message().optional(), - group_id: f.uint().optional(), + group_id: f.groupId().optional(), }, run: async (p, ctx) => { const messages = p.messages ?? p.message; @@ -531,8 +531,8 @@ export const actions = [ summary: '获取图片信息', readOnly: true, params: { - file: f.string().default(''), - file_id: f.string().default(''), + file: f.string().default('').role('image'), + file_id: f.string().default('').role('file_id'), }, run: async (p, ctx) => { const file = p.file || p.file_id; @@ -548,8 +548,8 @@ export const actions = [ summary: '获取语音信息', readOnly: true, params: { - file: f.string().default(''), - file_id: f.string().default(''), + file: f.string().default('').role('record'), + file_id: f.string().default('').role('file_id'), }, run: async (p, ctx) => { const file = p.file || p.file_id; @@ -574,7 +574,7 @@ export const actions = [ required: ['text'], }, params: { - message_id: f.string().default(''), + message_id: f.string().default('').role('message_id'), }, // `raw` so message_id works whether the client sends a number or a string. run: async (_p, ctx, raw) => { @@ -684,7 +684,7 @@ export const actions = [ name: 'set_friend_remark', summary: '设置好友备注', params: { - user_id: f.uint(), + user_id: f.userId(), remark: f.string(), }, run: async (p, ctx) => { @@ -697,7 +697,7 @@ export const actions = [ name: 'set_group_remark', summary: '设置群备注', params: { - group_id: f.uint(), + group_id: f.groupId(), remark: f.string(), }, run: async (p, ctx) => { @@ -822,7 +822,7 @@ export const actions = [ name: 'set_diy_online_status', summary: '设置自定义在线状态', params: { - face_id: f.uint(), + face_id: f.faceId(), // 原实现用 `asNumber(face_type) || 1`,present 0 会被当作缺省 1。 face_type: f.int({ min: 0 }).default(1), wording: f.string().default(''), @@ -979,7 +979,7 @@ export const actions = [ summary: '转发单条消息给好友', params: { message_id: f.messageId(), - user_id: f.uint(), + user_id: f.userId(), }, run: async (p, ctx) => { try { @@ -996,7 +996,7 @@ export const actions = [ summary: '转发单条消息到群', params: { message_id: f.messageId(), - group_id: f.uint(), + group_id: f.groupId(), }, run: async (p, ctx) => { try { @@ -1044,7 +1044,7 @@ export const actions = [ }, params: { // 原实现 user_id 经 asNumber,无校验(0 也透传)。 - user_id: f.int({ min: 0 }).default(0), + user_id: f.int({ min: 0 }).default(0).role('user_id'), start: f.int({ min: 0 }).default(0), count: f.int({ min: 0 }).default(10), }, @@ -1367,8 +1367,8 @@ export const actions = [ required: ['arkMsg'], }, params: { - user_id: f.uint().optional(), - group_id: f.uint().optional(), + user_id: f.userId().optional(), + group_id: f.groupId().optional(), phone_number: f.string().default(''), }, run: async (p, ctx) => { @@ -1398,8 +1398,8 @@ export const actions = [ required: ['arkMsg'], }, params: { - user_id: f.uint().optional(), - group_id: f.uint().optional(), + user_id: f.userId().optional(), + group_id: f.groupId().optional(), phone_number: f.string().default(''), }, run: async (p, ctx) => { @@ -1427,7 +1427,7 @@ export const actions = [ readOnly: true, returns: '服务端生成的群推荐 Ark 卡片 JSON 字符串。', returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' }, - params: { group_id: f.uint() }, + params: { group_id: f.groupId() }, run: async (p, ctx) => { try { return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id)); @@ -1442,7 +1442,7 @@ export const actions = [ readOnly: true, returns: '服务端生成的群推荐 Ark 卡片 JSON 字符串。', returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' }, - params: { group_id: f.uint() }, + params: { group_id: f.groupId() }, run: async (p, ctx) => { try { return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id)); @@ -1565,7 +1565,7 @@ export const actions = [ defineAction({ name: 'set_qq_avatar', summary: '设置 QQ 头像', - params: { file: f.string({ allowEmpty: false }) }, + params: { file: f.image() }, run: async (p, ctx) => { try { await ctx.bridge.apis.profile.setAvatar(p.file); @@ -1580,7 +1580,7 @@ export const actions = [ name: 'set_input_status', summary: '设置输入状态', params: { - user_id: f.uint(), + user_id: f.userId(), // event_type 可能为 0(取消输入状态);缺省也按 0 处理(与旧 asNumber 行为一致)。 event_type: f.int().default(0), }, @@ -1598,7 +1598,7 @@ export const actions = [ name: 'get_group_info_ex', summary: '获取群信息(扩展)', readOnly: true, - params: { group_id: f.uint() }, + params: { group_id: f.groupId() }, run: async (p, ctx) => { if (ctx.getGroupInfo) { return okResponse(await ctx.getGroupInfo(p.group_id)); @@ -1611,7 +1611,7 @@ export const actions = [ name: 'get_group_detail_info', summary: '获取群详细信息', readOnly: true, - params: { group_id: f.uint() }, + params: { group_id: f.groupId() }, run: async (p, ctx) => { if (ctx.getGroupInfo) { return okResponse(await ctx.getGroupInfo(p.group_id)); @@ -1644,8 +1644,8 @@ export const actions = [ summary: '获取文件信息(仅图片/语音缓存;群文件请用 get_group_file_url)', readOnly: true, params: { - file_id: f.string().default(''), - file: f.string().default(''), + file_id: f.string().default('').role('file_id'), + file: f.string().default('').role('file'), }, run: async (p, ctx) => { const fileId = p.file || p.file_id; @@ -1712,7 +1712,7 @@ export const actions = [ }, required: ['status', 'ext_status'], }, - params: { user_id: f.uint() }, + params: { user_id: f.userId() }, run: async (p, ctx) => { const status = await ctx.bridge.apis.extras.getStrangerStatus(p.user_id); if (!status) return failedResponse(RETCODE.ACTION_FAILED, 'failed to fetch user status'); @@ -1934,7 +1934,7 @@ export const actions = [ }, required: ['texts', 'language'], }, - params: { image: f.string({ allowEmpty: false }) }, + params: { image: f.image() }, run: async (p, ctx) => { // A passed-in http(s) URL is used verbatim (NOT re-signed) — if it is a // stale CDN URL with an expired rkey the server fetch fails and surfaces @@ -2022,7 +2022,7 @@ export const actions = [ name: 'send_private_forward_msg', summary: '发送私聊合并转发', returns: '{ message_id, res_id, forward_id }', - params: { user_id: f.uint(), messages: f.message().optional(), message: f.message().optional() }, + params: { user_id: f.userId(), messages: f.message().optional(), message: f.message().optional() }, run: async (p, ctx, raw) => { const messages = p.messages ?? p.message; if (messages === undefined) return failedResponse(RETCODE.BAD_REQUEST, 'message/messages is required'); @@ -2407,8 +2407,8 @@ export const actions = [ returns: '{ message_id }', params: { fileset_id: f.string({ allowEmpty: false }), - user_id: f.uint().optional(), - group_id: f.uint().optional(), + user_id: f.userId().optional(), + group_id: f.groupId().optional(), }, run: async (p, ctx) => { if (!p.user_id && !p.group_id) { diff --git a/packages/onebot/src/actions/friend.ts b/packages/onebot/src/actions/friend.ts index cbf878ff..49bb4fb2 100644 --- a/packages/onebot/src/actions/friend.ts +++ b/packages/onebot/src/actions/friend.ts @@ -46,7 +46,7 @@ export const actions = [ }, required: ['user_id', 'nickname', 'sex', 'age'], }, - params: { user_id: f.uint().describe('QQ 号') }, + params: { user_id: f.userId().describe('QQ 号') }, run: async (p, ctx) => { const userId = p.user_id; if (ctx.getStrangerInfo) { @@ -60,7 +60,7 @@ export const actions = [ defineAction({ name: 'delete_friend', summary: '删除好友', - params: { user_id: f.uint().describe('QQ 号'), block: f.bool().default(false) }, + params: { user_id: f.userId().describe('QQ 号'), block: f.bool().default(false) }, run: async (p, ctx) => { await ctx.bridge.apis.friend.delete(p.user_id, p.block); return okResponse(); diff --git a/packages/onebot/src/actions/group-admin.ts b/packages/onebot/src/actions/group-admin.ts index 19441311..ab91f520 100644 --- a/packages/onebot/src/actions/group-admin.ts +++ b/packages/onebot/src/actions/group-admin.ts @@ -16,7 +16,7 @@ export const actions = [ groupAction({ name: 'set_group_kick_members', summary: '批量踢出群成员', - params: { user_id: f.array(f.uint()).nonEmpty(), reject_add_request: f.bool().default(false) }, + params: { user_id: f.array(f.memberId()).nonEmpty(), reject_add_request: f.bool().default(false) }, run: async (p, ctx) => { await ctx.bridge.apis.groupAdmin.kickMembers(p.group_id, p.user_id, p.reject_add_request); return okResponse(); @@ -26,7 +26,7 @@ export const actions = [ groupUserAction({ name: 'set_group_ban', summary: '禁言群成员(duration=0 解除)', - params: { duration: f.int({ min: 0 }).default(1800) }, + params: { duration: f.duration().default(1800) }, run: async (p, ctx) => { await ctx.bridge.apis.groupAdmin.muteMember(p.group_id, p.user_id, p.duration); return okResponse(); @@ -118,7 +118,7 @@ export const actions = [ groupAction({ name: 'set_group_portrait', summary: '设置群头像', - params: { file: f.string({ allowEmpty: false }) }, + params: { file: f.image() }, run: async (p, ctx) => { try { await ctx.bridge.apis.profile.setGroupAvatar(p.group_id, p.file); diff --git a/packages/onebot/src/actions/group-album.ts b/packages/onebot/src/actions/group-album.ts index df022179..8698fe7b 100644 --- a/packages/onebot/src/actions/group-album.ts +++ b/packages/onebot/src/actions/group-album.ts @@ -91,7 +91,7 @@ export const actions = [ params: { album_id: f.string({ allowEmpty: false }), album_name: f.string({ allowEmpty: false }), - file: f.string({ allowEmpty: false }), + file: f.image(), }, run: async (p, ctx) => { try { diff --git a/packages/onebot/src/actions/group-file.ts b/packages/onebot/src/actions/group-file.ts index fab90184..434b2df6 100644 --- a/packages/onebot/src/actions/group-file.ts +++ b/packages/onebot/src/actions/group-file.ts @@ -26,7 +26,7 @@ export const actions = [ // non-empty wins, else '/'. Both default '' so the `||` chain matches the // legacy `asString(folder) || asString(folder_id) || '/'`. params: { - file: f.string({ allowEmpty: false }), + file: f.file(), name: f.string().default(''), folder: f.string().default(''), folder_id: f.string().default(''), @@ -44,8 +44,8 @@ export const actions = [ summary: '上传私聊文件', returns: '{ file_id: string }', params: { - user_id: f.uint(), - file: f.string({ allowEmpty: false }), + user_id: f.userId(), + file: f.file(), name: f.string().default(''), upload_file: f.bool().default(true), }, @@ -67,7 +67,7 @@ export const actions = [ }, // busid is accepted but tolerant (see busidOr102): NapCat/LLBot ignore it, // so a present null/empty/non-numeric value must not 400 the request (#147). - params: { file_id: f.string({ allowEmpty: false }), busid: f.raw() }, + params: { file_id: f.fileId(), busid: f.raw() }, run: async (p, ctx) => { return okResponse({ url: await ctx.bridge.apis.groupFile.getUrl(p.group_id, p.file_id, busidOr102(p.busid)) }); }, @@ -183,7 +183,7 @@ export const actions = [ groupAction({ name: 'delete_group_file', summary: '删除群文件', - params: { file_id: f.string({ allowEmpty: false }) }, + params: { file_id: f.fileId() }, run: async (p, ctx) => { await ctx.bridge.apis.groupFile.delete(p.group_id, p.file_id); return okResponse(); @@ -194,7 +194,7 @@ export const actions = [ name: 'move_group_file', summary: '移动群文件', params: { - file_id: f.string({ allowEmpty: false }), + file_id: f.fileId(), parent_directory: f.string({ allowEmpty: false }), target_directory: f.string({ allowEmpty: false }), }, @@ -210,7 +210,7 @@ export const actions = [ name: 'rename_group_file', summary: '重命名群文件', params: { - file_id: f.string({ allowEmpty: false }), + file_id: f.fileId(), current_parent_directory: f.string().default('/'), new_name: f.string({ allowEmpty: false }), }, @@ -276,8 +276,8 @@ export const actions = [ // clients that only persist file_id, both user_id and file_hash are now // optional; file_hash falls through empty when absent. See issue #147. params: { - user_id: f.uint().optional(), - file_id: f.string({ allowEmpty: false }), + user_id: f.userId().optional(), + file_id: f.fileId(), file_hash: f.string().default(''), }, run: async (p, ctx) => { diff --git a/packages/onebot/src/actions/message.ts b/packages/onebot/src/actions/message.ts index eedf7b48..dfa589eb 100644 --- a/packages/onebot/src/actions/message.ts +++ b/packages/onebot/src/actions/message.ts @@ -47,8 +47,8 @@ export const actions = [ params: { message: f.message(), message_type: f.string().optional(), - group_id: f.uint().optional(), - user_id: f.uint().optional(), + group_id: f.groupId().optional(), + user_id: f.userId().optional(), auto_escape: f.bool().default(false), }, run: async (p, ctx) => { @@ -67,7 +67,7 @@ export const actions = [ name: 'send_private_msg', summary: '发送私聊消息', returns: '{ message_id: number }', - params: { user_id: f.uint(), message: f.message(), auto_escape: f.bool().default(false) }, + params: { user_id: f.userId(), message: f.message(), auto_escape: f.bool().default(false) }, run: async (p, ctx) => { const result = await ctx.sendPrivateMessage(p.user_id, p.message, p.auto_escape); return okResponse({ message_id: result.messageId }); diff --git a/packages/onebot/src/actions/qzone.ts b/packages/onebot/src/actions/qzone.ts index 38583293..3650d022 100644 --- a/packages/onebot/src/actions/qzone.ts +++ b/packages/onebot/src/actions/qzone.ts @@ -54,7 +54,7 @@ export const actions = [ }, summary: '获取 QQ 空间说说列表(默认机器人自己的空间)', params: { - target_uin: f.uint().describe('目标 QQ 号,省略则取机器人自己').optional(), + target_uin: f.userId().describe('目标 QQ 号,省略则取机器人自己').optional(), pos: f.int({ min: 0 }).describe('起始偏移').default(0), num: f.int({ min: 1, max: 100 }).describe('本页数量').default(20), }, @@ -167,8 +167,8 @@ export const actions = [ summary: '给一条说说点赞(QQ 空间)', params: { tid: f.string({ allowEmpty: false }).describe('说说 tid'), - target_uin: f.uint().describe('说说所属 QQ 号,省略则为机器人自己').optional(), - abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0), + target_uin: f.userId().describe('说说所属 QQ 号,省略则为机器人自己').optional(), + abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0).role('timestamp'), }, run: async (p, ctx) => { try { @@ -188,8 +188,8 @@ export const actions = [ summary: '取消对一条说说的点赞(QQ 空间;取消赞端点待真机核实)', params: { tid: f.string({ allowEmpty: false }).describe('说说 tid'), - target_uin: f.uint().describe('说说所属 QQ 号,省略则为机器人自己').optional(), - abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0), + target_uin: f.userId().describe('说说所属 QQ 号,省略则为机器人自己').optional(), + abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0).role('timestamp'), }, run: async (p, ctx) => { try { @@ -211,7 +211,7 @@ export const actions = [ params: { tid: f.string({ allowEmpty: false }).describe('说说 tid'), content: f.string({ allowEmpty: false }).describe('评论内容'), - target_uin: f.uint().describe('说说所属 QQ 号,省略则为机器人自己').optional(), + target_uin: f.userId().describe('说说所属 QQ 号,省略则为机器人自己').optional(), images: f.array(f.string({ allowEmpty: false })).describe('图片数组(可选),支持 file:// http:// base64://;自动上传').optional(), }, run: async (p, ctx) => { diff --git a/packages/onebot/src/actions/stream-download.ts b/packages/onebot/src/actions/stream-download.ts index 7389729a..d9ff1fcb 100644 --- a/packages/onebot/src/actions/stream-download.ts +++ b/packages/onebot/src/actions/stream-download.ts @@ -325,8 +325,8 @@ async function runDownload( // ─────────────────────────── action definitions ─────────────────────────── const downloadParams = { - file: f.string().optional().describe('文件路径(限 stream 临时目录)/ http(s) URL'), - file_id: f.string().optional().describe('文件 ID(缓存的图片/语音 id)'), + file: f.string().optional().describe('文件路径(限 stream 临时目录)/ http(s) URL').role('file'), + file_id: f.string().optional().describe('文件 ID(缓存的图片/语音 id)').role('file_id'), chunk_size: f.int({ min: 1 }).optional().describe('分块大小(字节,默认 64KB)'), };