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
@@ -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