feat(onebot): Stream API transport plumbing (#163 phase 1)
Foundation for NapCat-compatible Stream API actions (chunked file upload/download): a single request answered by many response frames. - streaming.ts: StreamSink + frame wrappers (wrapStreamFrame / wrapStreamTerminal) matching NapCat's wire — each frame an OB11 envelope with stream:'stream-action', data.type ∈ stream/response/error, and message mirrored into wording. - ApiHandler: registerStreamAction / isStreamAction; handle() threads a sink; processStreamRequest drives WS multi-frame dispatch with optional liveness-based abort; dead processRequest removed. - action-kit: defineStreamAction (sink-aware run, registers as a stream action) reusing defineAction's parse/describe. - adapters: HTTP server streams chunked \r\n\r\n-delimited frames (no Content-Length, no false application/json), aborting on client disconnect; WS server/client use a backpressure-aware safeSendAsync and abort a stream once the socket closes. No stream actions are registered yet — those land in the next phases. Verified by two adversarial review passes. 480 onebot tests green.
This commit is contained in:
13 files changed
+452
-38
No files matched your search
@@ -68,7 +68,7 @@ import type { JsonObject, WsClientNetwork, WsServerNetwork } from '../src/types'
|
||||
function ctx(): NetworkAdapterContext {
|
||||
return {
|
||||
uin: '10001',
|
||||
api: { processRequest: async () => '' } as never,
|
||||
api: { processStreamRequest: async () => {} } as never,
|
||||
buildLifecycleEvent: (sub) => ({ post_type: 'meta_event', meta_event_type: 'lifecycle', sub_type: sub }),
|
||||
buildHeartbeatEvent: () => ({ post_type: 'meta_event', meta_event_type: 'heartbeat', interval: 5000 }),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user