@qwen-code/channel-feishu 0.21.0-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ import { ChannelBase } from '@qwen-code/channel-base';
2
+ import type { ChannelConfig, ChannelBaseOptions, ChannelAgentBridge, ChannelTaskLifecycleEvent, SessionTarget } from '@qwen-code/channel-base';
3
+ export declare class FeishuChannel extends ChannelBase {
4
+ private eventDispatcher;
5
+ private wsClient?;
6
+ private httpServer?;
7
+ private seenMessages;
8
+ private dedupTimer?;
9
+ /** Card state keyed by inbound messageId (unique per request). */
10
+ private cardSessions;
11
+ /** Map sessionId → inbound messageId, set in onPromptStart. */
12
+ private sessionToInboundMsg;
13
+ /** Question title keyed by inbound messageId. */
14
+ private msgToQuestion;
15
+ /** Sender @tag keyed by inbound messageId. */
16
+ private msgToSenderName;
17
+ /** Sender open_id keyed by inbound messageId — for stop-button auth in group chats. */
18
+ private msgToSenderId;
19
+ /** Tracks messages that were stopped. Cleaned up by onResponseComplete, onPromptEnd, stale timer, and disconnect. */
20
+ private stoppedMessages;
21
+ private botOpenId?;
22
+ private tokenCache?;
23
+ private tokenRefreshPromise?;
24
+ private collapsible;
25
+ private collapsibleThreshold;
26
+ constructor(name: string, config: ChannelConfig, bridge: ChannelAgentBridge, options?: ChannelBaseOptions);
27
+ supportsProactiveSend(): boolean;
28
+ /** Build the event handler map shared between WebSocket and webhook modes. */
29
+ private buildHandlerMap;
30
+ connect(): Promise<void>;
31
+ private connectWebSocket;
32
+ private connectWebhook;
33
+ private fetchBotInfo;
34
+ /**
35
+ * Fetch the content of a message by ID.
36
+ * For interactive cards, extracts markdown text from card elements.
37
+ */
38
+ private fetchMessageContent;
39
+ /**
40
+ * Extract text content from a Feishu interactive card JSON structure.
41
+ * Supports both v2 format ({ schema, body: { elements } }) and
42
+ * v1/API-returned format ({ title, elements: [[...]] }).
43
+ */
44
+ private extractCardText;
45
+ private getTenantAccessToken;
46
+ private refreshToken;
47
+ sendMessage(chatId: string, text: string): Promise<void>;
48
+ protected pushProactive(target: SessionTarget, text: string): Promise<void>;
49
+ protected pushProactiveDelivery(target: SessionTarget, text: string): Promise<void>;
50
+ private sendMessageInternal;
51
+ private createStreamingCard;
52
+ private updateCard;
53
+ /** Delete a card message from Feishu to prevent orphaned "思考中..." cards. */
54
+ private deleteCard;
55
+ protected onResponseChunk(chatId: string, chunk: string, sessionId: string): void;
56
+ protected onResponseBoundary(_chatId: string, sessionId: string): void;
57
+ private isKnownInboundMessageId;
58
+ private knownInboundMessageId;
59
+ private statusLabelFor;
60
+ private stopLabelFor;
61
+ private finalizeStoppedCardUpdate;
62
+ protected onTaskLifecycle(event: ChannelTaskLifecycleEvent): void;
63
+ protected onResponseComplete(chatId: string, fullText: string, sessionId: string): Promise<void>;
64
+ protected onPromptStart(chatId: string, sessionId: string, messageId?: string): void;
65
+ protected onPromptEnd(_chatId: string, sessionId: string, messageId?: string): Promise<void>;
66
+ private addReaction;
67
+ private removeReaction;
68
+ private onCardAction;
69
+ disconnect(): void;
70
+ /**
71
+ * Count code fence boundaries in text using line-by-line tracking.
72
+ * Handles indented fences and inline triple-backticks consistently.
73
+ */
74
+ private countFences;
75
+ /**
76
+ * Strip markdown tables from text while preserving code-fenced blocks.
77
+ * Collapses consecutive table rows into a single replacement line.
78
+ */
79
+ private stripTables;
80
+ private cleanupCard;
81
+ private onMessage;
82
+ /**
83
+ * Extract text and media keys from Feishu message content.
84
+ */
85
+ private extractContent;
86
+ }