chatccc 0.2.50 → 0.2.52

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,61 @@
1
+ /**
2
+ * platform-adapter.ts — IM 平台适配器接口
3
+ *
4
+ * 独立于 orchestrator.ts,避免 orchestrator ↔ session 循环依赖。
5
+ * 每个方法内部自行管理认证,消费者不感知 token 等认证细节。
6
+ */
7
+
8
+ export interface PlatformAdapter {
9
+ /** 平台标识,用于区分不同平台的行为(如 wechat、feishu 等) */
10
+ kind?: string;
11
+
12
+ /** 发送纯文本回复 */
13
+ sendText(chatId: string, text: string): Promise<boolean>;
14
+
15
+ /** 发送卡片回复(标题 + 内容 + 颜色模板) */
16
+ sendCard(
17
+ chatId: string,
18
+ title: string,
19
+ content: string,
20
+ template: string,
21
+ ): Promise<boolean>;
22
+
23
+ /** 发送原始卡片 JSON */
24
+ sendRawCard(chatId: string, cardJson: string): Promise<boolean>;
25
+
26
+ /** 创建群聊,返回新群 ID */
27
+ createGroup(name: string, userIds: string[]): Promise<string>;
28
+
29
+ /** 更新群名称和描述 */
30
+ updateChatInfo(
31
+ chatId: string,
32
+ name: string,
33
+ description: string,
34
+ ): Promise<void>;
35
+
36
+ /** 获取群信息 */
37
+ getChatInfo(chatId: string): Promise<{ name: string; description: string }>;
38
+
39
+ /** 解散群聊 */
40
+ disbandChat(chatId: string): Promise<void>;
41
+
42
+ /** 设置群头像 */
43
+ setChatAvatar(chatId: string, tool: string, status: string): Promise<void>;
44
+
45
+ /** 从群描述中提取 session 信息 */
46
+ extractSessionInfo(
47
+ description: string,
48
+ ): { sessionId: string; tool: string } | null;
49
+
50
+ // ---- 进度展示(display loop 使用) ----
51
+ // 不同平台能力不同:飞书用 CardKit 实时卡片,微信降级为纯文本。
52
+
53
+ /** 创建进度展示实体,返回唯一标识;不支持进度展示的平台返回 null */
54
+ cardCreate(cardJson: string): Promise<string | null>;
55
+
56
+ /** 将进度展示发送到指定会话,返回 message_id */
57
+ cardSend(chatId: string, cardId: string): Promise<string>;
58
+
59
+ /** 更新已发送的进度展示,sequence 保证有序 */
60
+ cardUpdate(cardId: string, cardJson: string, sequence: number): Promise<void>;
61
+ }
@@ -109,6 +109,8 @@ export interface DisplayCardState {
109
109
  cardCreatedAt: number;
110
110
  lastSentContent: string;
111
111
  streamErrorNotified: boolean;
112
+ /** 卡片轮转时记录的基线,轮转后只展示增量 */
113
+ rotationBaseline?: string;
112
114
  }
113
115
 
114
116
  export const displayCards = new Map<string, DisplayCardState>();