@milerliu/feishu 0.1.9 → 0.1.11

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/send.ts +15 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milerliu/feishu",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Feishu/Lark channel plugin",
6
6
  "license": "MIT",
package/src/send.ts CHANGED
@@ -101,44 +101,29 @@ export async function sendStreamingMessageFeishu(params: {
101
101
  return sendCardFeishu({ cfg, to, card: fallbackCard });
102
102
  }
103
103
 
104
- // Stream content updates using Feishu cardkit batch_update API
105
- const chunkSize = 300;
104
+ // Send multiple messages with delay to simulate streaming effect
105
+ const chunkSize = 500;
106
106
  const chunks: string[] = [];
107
107
  for (let i = 0; i < messageText.length; i += chunkSize) {
108
108
  chunks.push(messageText.slice(i, i + chunkSize));
109
109
  }
110
110
 
111
- // Send updates with small delay
112
- for (let i = 0; i < chunks.length; i++) {
113
- const partialContent = chunks.slice(0, i + 1).join("");
114
-
115
- try {
116
- // Use cardkit v1 API for batch update
117
- const updateResponse = await (client as any).cardkit.v1.cards.batch_update({
118
- path: { card_id: cardId },
119
- data: {
120
- card: {
121
- header: {
122
- title: { tag: "plain_text", content: "AI 回复" },
123
- },
124
- config: { wide_screen_mode: true, streaming_update: true },
125
- elements: [{ tag: "markdown", content: partialContent }],
126
- },
127
- },
128
- });
129
-
130
- if (updateResponse.code !== 0) {
131
- console.error(`Cardkit batch update failed: ${updateResponse.msg}`);
132
- }
133
- } catch (err) {
134
- console.error(`Cardkit update error: ${err}`);
135
- }
111
+ // Send first message
112
+ const firstCard = buildMarkdownCard(chunks[0]);
113
+ const firstResult = await sendCardFeishu({ cfg, to, card: firstCard });
136
114
 
137
- if (i < chunks.length - 1) {
138
- await new Promise((resolve) => setTimeout(resolve, 150));
139
- }
115
+ // Send remaining chunks as separate messages
116
+ for (let i = 1; i < chunks.length; i++) {
117
+ await new Promise((resolve) => setTimeout(resolve, 100));
118
+ const chunkCard = buildMarkdownCard(chunks[i]);
119
+ await sendCardFeishu({ cfg, to, card: chunkCard });
140
120
  }
141
121
 
122
+ return {
123
+ messageId: firstResult.messageId,
124
+ chatId: receiveId,
125
+ };
126
+
142
127
  return {
143
128
  messageId,
144
129
  chatId: receiveId,