@vui-design/openclaw-plugin-feishu-progress 0.2.1 → 0.2.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vui-design/openclaw-plugin-feishu-progress",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "飞书任务进度卡片插件 — 在 AI 执行复杂多步骤任务时,实时更新飞书进度卡片",
5
5
  "keywords": [
6
6
  "openclaw-plugin",
@@ -35,7 +35,13 @@ export class FeishuClient {
35
35
  }),
36
36
  }
37
37
  );
38
- const data = (await res.json()) as { tenant_access_token: string; expire: number };
38
+ if (!res.ok) {
39
+ throw new Error(`飞书获取 token 失败: HTTP ${res.status}`);
40
+ }
41
+ const data = (await res.json()) as { tenant_access_token: string; expire: number; code: number; msg: string };
42
+ if (data.code !== 0) {
43
+ throw new Error(`飞书获取 token 失败: ${data.msg} (code=${data.code})`);
44
+ }
39
45
  // 提前 5 分钟过期,避免边界问题
40
46
  this.tokenCache = {
41
47
  token: data.tenant_access_token,
@@ -44,27 +50,6 @@ export class FeishuClient {
44
50
  return this.tokenCache.token;
45
51
  }
46
52
 
47
- async sendCard(chatId: string, card: object): Promise<string> {
48
- const token = await this.getToken();
49
- const res = await fetch(
50
- `${this.baseUrl}/open-apis/im/v1/messages?receive_id_type=chat_id`,
51
- {
52
- method: 'POST',
53
- headers: {
54
- Authorization: `Bearer ${token}`,
55
- 'Content-Type': 'application/json',
56
- },
57
- body: JSON.stringify({
58
- receive_id: chatId,
59
- msg_type: 'interactive',
60
- content: JSON.stringify(card),
61
- }),
62
- }
63
- );
64
- const data = (await res.json()) as { data: { message_id: string } };
65
- return data.data.message_id;
66
- }
67
-
68
53
  async sendText(chatId: string, text: string): Promise<string> {
69
54
  const token = await this.getToken();
70
55
  const res = await fetch(
@@ -82,22 +67,13 @@ export class FeishuClient {
82
67
  }),
83
68
  }
84
69
  );
85
- const data = (await res.json()) as { data: { message_id: string } };
70
+ if (!res.ok) {
71
+ throw new Error(`飞书发送消息失败: HTTP ${res.status}`);
72
+ }
73
+ const data = (await res.json()) as { code: number; msg: string; data: { message_id: string } };
74
+ if (data.code !== 0) {
75
+ throw new Error(`飞书发送消息失败: ${data.msg} (code=${data.code})`);
76
+ }
86
77
  return data.data.message_id;
87
78
  }
88
-
89
- async updateCard(messageId: string, card: object): Promise<void> {
90
- const token = await this.getToken();
91
- await fetch(`${this.baseUrl}/open-apis/im/v1/messages/${messageId}`, {
92
- method: 'PATCH',
93
- headers: {
94
- Authorization: `Bearer ${token}`,
95
- 'Content-Type': 'application/json',
96
- },
97
- body: JSON.stringify({
98
- msg_type: 'interactive',
99
- content: JSON.stringify(card),
100
- }),
101
- });
102
- }
103
79
  }