feat(onebot): backfill semantic roles across action params

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.
This commit is contained in:
DrSmoothl committed 2026-06-30 16:00:21 +08:00
1 parent 14a61f4ce8
commit f9900053b0
10 files changed
+551 -259

No files matched your search

+9 -9
View File
@@ -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) => {