@milerliu/feishu 0.1.9 → 0.1.10

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 +29 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milerliu/feishu",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Feishu/Lark channel plugin",
6
6
  "license": "MIT",
package/src/send.ts CHANGED
@@ -101,7 +101,7 @@ 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
104
+ // Stream content updates using Feishu message patch API
105
105
  const chunkSize = 300;
106
106
  const chunks: string[] = [];
107
107
  for (let i = 0; i < messageText.length; i += chunkSize) {
@@ -112,26 +112,42 @@ export async function sendStreamingMessageFeishu(params: {
112
112
  for (let i = 0; i < chunks.length; i++) {
113
113
  const partialContent = chunks.slice(0, i + 1).join("");
114
114
 
115
+ const updateCard = {
116
+ header: {
117
+ title: {
118
+ tag: "plain_text",
119
+ content: "AI 回复",
120
+ },
121
+ },
122
+ config: {
123
+ wide_screen_mode: true,
124
+ streaming_update: true,
125
+ },
126
+ elements: [
127
+ {
128
+ tag: "markdown",
129
+ content: partialContent,
130
+ },
131
+ ],
132
+ };
133
+
134
+ const updateContent = JSON.stringify(updateCard);
135
+
115
136
  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 },
137
+ // Use im v1 message patch API for card updates
138
+ const updateResponse = await (client as any).im.v1.message.patch({
139
+ path: { message_id: messageId },
119
140
  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
- },
141
+ msg_type: "interactive",
142
+ content: updateContent,
127
143
  },
128
144
  });
129
145
 
130
146
  if (updateResponse.code !== 0) {
131
- console.error(`Cardkit batch update failed: ${updateResponse.msg}`);
147
+ console.error(`Message patch failed: ${updateResponse.msg}`);
132
148
  }
133
149
  } catch (err) {
134
- console.error(`Cardkit update error: ${err}`);
150
+ console.error(`Message patch error: ${err}`);
135
151
  }
136
152
 
137
153
  if (i < chunks.length - 1) {