qwen-code/packages/channels/plugin-example/src/protocol.ts
tanzhenxin f7979aa902 feat(channels): add streaming response hooks to ChannelBase
- Add onResponseChunk hook for progressive text display during streaming
- Add onResponseComplete hook for customizing response delivery
- Update mock plugin channel to support streaming chunks

This enables channels to display AI responses progressively as they stream,
improving user experience with real-time feedback.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 14:08:09 +00:00

31 lines
696 B
TypeScript

/**
* Shared protocol types for mock channel WebSocket communication.
*/
/** Server → Plugin Channel (WebSocket) */
export interface InboundMessage {
type: 'inbound';
messageId: string;
senderId: string;
senderName: string;
chatId: string;
text: string;
}
/** Plugin Channel → Server (WebSocket) — streaming chunk */
export interface ChunkMessage {
type: 'chunk';
messageId: string;
chatId: string;
text: string;
}
/** Plugin Channel → Server (WebSocket) — final response */
export interface OutboundMessage {
type: 'outbound';
messageId: string;
chatId: string;
text: string;
}
export type WsMessage = InboundMessage | ChunkMessage | OutboundMessage;