@zhin.js/adapter-slack 1.0.44 → 1.0.47

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.47
4
+
5
+ ### Patch Changes
6
+
7
+ - 5073d4c: chore: chore: update TypeScript version to ^5.9.3 across all plugins and packages
8
+ feat: enhance ai-text-as-image output registration with off handler for cleanup
9
+ fix: remove unnecessary logging in ensureBuiltinFontsCached function
10
+ refactor: simplify action handlers in html-renderer tools
11
+ chore: add README files for queue-sandbox-poc and event-delivery packages
12
+ chore: adjust pnpm workspace configuration to exclude games directory
13
+ chore: update tsconfig to include plugins directory for TypeScript compilation
14
+ - Updated dependencies [5073d4c]
15
+ - zhin.js@1.0.60
16
+
17
+ ## 1.0.46
18
+
19
+ ### Patch Changes
20
+
21
+ - c212bf7: fix: 适配器优化
22
+ - Updated dependencies [c212bf7]
23
+ - zhin.js@1.0.59
24
+
25
+ ## 1.0.45
26
+
27
+ ### Patch Changes
28
+
29
+ - zhin.js@1.0.58
30
+
3
31
  ## 1.0.44
4
32
 
5
33
  ### Patch Changes
package/lib/adapter.d.ts CHANGED
@@ -12,9 +12,5 @@ export declare class SlackAdapter extends Adapter<SlackBot> {
12
12
  listMembers(botId: string, sceneId: string): Promise<string[]>;
13
13
  getGroupInfo(botId: string, sceneId: string): Promise<any>;
14
14
  start(): Promise<void>;
15
- /**
16
- * 注册 Slack 平台特有工具(邀请到频道等)
17
- */
18
- private registerSlackPlatformTools;
19
15
  }
20
16
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,OAAO,EACP,MAAM,EAGP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC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AAM;IAQ3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
package/lib/adapter.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Slack 适配器
3
3
  */
4
- import { Adapter, createGroupManagementTools, } from "zhin.js";
4
+ import { Adapter, } from "zhin.js";
5
5
  import { SlackBot } from "./bot.js";
6
6
  export class SlackAdapter extends Adapter {
7
7
  constructor(plugin) {
@@ -37,274 +37,7 @@ export class SlackAdapter extends Adapter {
37
37
  }
38
38
  // ── 生命周期 ───────────────────────────────────────────────────────
39
39
  async start() {
40
- this.registerSlackPlatformTools();
41
- const groupTools = createGroupManagementTools(this, this.name);
42
- groupTools.forEach((t) => this.addTool(t));
43
40
  await super.start();
44
41
  }
45
- /**
46
- * 注册 Slack 平台特有工具(邀请到频道等)
47
- */
48
- registerSlackPlatformTools() {
49
- // 邀请用户到频道
50
- this.addTool({
51
- name: 'slack_invite_to_channel',
52
- description: '邀请用户加入 Slack 频道',
53
- parameters: {
54
- type: 'object',
55
- properties: {
56
- bot: { type: 'string', description: 'Bot 名称' },
57
- channel: { type: 'string', description: '频道 ID' },
58
- users: { type: 'array', items: { type: 'string' }, description: '用户 ID 列表' },
59
- },
60
- required: ['bot', 'channel', 'users'],
61
- },
62
- platforms: ['slack'],
63
- scopes: ['group'],
64
- permissionLevel: 'group_admin',
65
- execute: async (args) => {
66
- const { bot: botId, channel, users } = args;
67
- const bot = this.bots.get(botId);
68
- if (!bot)
69
- throw new Error(`Bot ${botId} 不存在`);
70
- const success = await bot.inviteToChannel(channel, users);
71
- return { success, message: success ? `已邀请用户加入频道` : '操作失败' };
72
- },
73
- });
74
- // 设置频道话题
75
- this.addTool({
76
- name: 'slack_set_topic',
77
- description: '设置 Slack 频道话题',
78
- parameters: {
79
- type: 'object',
80
- properties: {
81
- bot: { type: 'string', description: 'Bot 名称' },
82
- channel: { type: 'string', description: '频道 ID' },
83
- topic: { type: 'string', description: '新话题' },
84
- },
85
- required: ['bot', 'channel', 'topic'],
86
- },
87
- platforms: ['slack'],
88
- scopes: ['group'],
89
- permissionLevel: 'group_admin',
90
- execute: async (args) => {
91
- const { bot: botId, channel, topic } = args;
92
- const bot = this.bots.get(botId);
93
- if (!bot)
94
- throw new Error(`Bot ${botId} 不存在`);
95
- const success = await bot.setChannelTopic(channel, topic);
96
- return { success, message: success ? `已设置频道话题` : '操作失败' };
97
- },
98
- });
99
- // 归档频道
100
- this.addTool({
101
- name: 'slack_archive_channel',
102
- description: '归档 Slack 频道',
103
- parameters: {
104
- type: 'object',
105
- properties: {
106
- bot: { type: 'string', description: 'Bot 名称' },
107
- channel: { type: 'string', description: '频道 ID' },
108
- },
109
- required: ['bot', 'channel'],
110
- },
111
- platforms: ['slack'],
112
- scopes: ['group'],
113
- permissionLevel: 'group_admin',
114
- execute: async (args) => {
115
- const { bot: botId, channel } = args;
116
- const bot = this.bots.get(botId);
117
- if (!bot)
118
- throw new Error(`Bot ${botId} 不存在`);
119
- const success = await bot.archiveChannel(channel);
120
- return { success, message: success ? `已归档频道` : '操作失败' };
121
- },
122
- });
123
- // 置顶消息
124
- this.addTool({
125
- name: 'slack_pin_message',
126
- description: '置顶 Slack 消息',
127
- parameters: {
128
- type: 'object',
129
- properties: {
130
- bot: { type: 'string', description: 'Bot 名称' },
131
- channel: { type: 'string', description: '频道 ID' },
132
- timestamp: { type: 'string', description: '消息时间戳' },
133
- },
134
- required: ['bot', 'channel', 'timestamp'],
135
- },
136
- platforms: ['slack'],
137
- scopes: ['group'],
138
- permissionLevel: 'group_admin',
139
- execute: async (args) => {
140
- const { bot: botId, channel, timestamp } = args;
141
- const bot = this.bots.get(botId);
142
- if (!bot)
143
- throw new Error(`Bot ${botId} 不存在`);
144
- const success = await bot.pinMessage(channel, timestamp);
145
- return { success, message: success ? `已置顶消息` : '操作失败' };
146
- },
147
- });
148
- // 添加反应
149
- this.addTool({
150
- name: 'slack_add_reaction',
151
- description: '给 Slack 消息添加表情反应',
152
- parameters: {
153
- type: 'object',
154
- properties: {
155
- bot: { type: 'string', description: 'Bot 名称' },
156
- channel: { type: 'string', description: '频道 ID' },
157
- timestamp: { type: 'string', description: '消息时间戳' },
158
- emoji: { type: 'string', description: '表情名称(不含冒号)' },
159
- },
160
- required: ['bot', 'channel', 'timestamp', 'emoji'],
161
- },
162
- platforms: ['slack'],
163
- scopes: ['group', 'private'],
164
- permissionLevel: 'user',
165
- execute: async (args) => {
166
- const { bot: botId, channel, timestamp, emoji } = args;
167
- const bot = this.bots.get(botId);
168
- if (!bot)
169
- throw new Error(`Bot ${botId} 不存在`);
170
- const success = await bot.addReaction(channel, timestamp, emoji);
171
- return { success, message: success ? `已添加反应 :${emoji}:` : '操作失败' };
172
- },
173
- });
174
- // 移除表情反应
175
- this.addTool({
176
- name: 'slack_remove_reaction',
177
- description: '移除 Slack 消息上的表情反应',
178
- parameters: {
179
- type: 'object',
180
- properties: {
181
- bot: { type: 'string', description: 'Bot 名称' },
182
- channel_id: { type: 'string', description: '频道 ID' },
183
- timestamp: { type: 'string', description: '消息时间戳' },
184
- name: { type: 'string', description: '表情名称(如 thumbsup、heart)' },
185
- },
186
- required: ['bot', 'channel_id', 'timestamp', 'name'],
187
- },
188
- platforms: ['slack'],
189
- scopes: ['group'],
190
- permissionLevel: 'user',
191
- execute: async (args) => {
192
- const { bot: botId, channel_id, timestamp, name } = args;
193
- const bot = this.bots.get(botId);
194
- if (!bot)
195
- throw new Error(`Bot ${botId} 不存在`);
196
- const success = await bot.removeReaction(channel_id, timestamp, name);
197
- return { success, message: success ? `已移除反应 :${name}:` : '操作失败' };
198
- },
199
- });
200
- // 取消置顶消息
201
- this.addTool({
202
- name: 'slack_unpin_message',
203
- description: '取消 Slack 频道中消息的置顶',
204
- parameters: {
205
- type: 'object',
206
- properties: {
207
- bot: { type: 'string', description: 'Bot 名称' },
208
- channel_id: { type: 'string', description: '频道 ID' },
209
- timestamp: { type: 'string', description: '消息时间戳' },
210
- },
211
- required: ['bot', 'channel_id', 'timestamp'],
212
- },
213
- platforms: ['slack'],
214
- scopes: ['group'],
215
- permissionLevel: 'group_admin',
216
- execute: async (args) => {
217
- const { bot: botId, channel_id, timestamp } = args;
218
- const bot = this.bots.get(botId);
219
- if (!bot)
220
- throw new Error(`Bot ${botId} 不存在`);
221
- const success = await bot.unpinMessage(channel_id, timestamp);
222
- return { success, message: success ? '已取消置顶' : '操作失败' };
223
- },
224
- });
225
- // 查询用户信息
226
- this.addTool({
227
- name: 'slack_user_info',
228
- description: '查询 Slack 用户详细信息',
229
- parameters: {
230
- type: 'object',
231
- properties: {
232
- bot: { type: 'string', description: 'Bot 名称' },
233
- user_id: { type: 'string', description: '用户 ID' },
234
- },
235
- required: ['bot', 'user_id'],
236
- },
237
- platforms: ['slack'],
238
- scopes: ['group', 'private'],
239
- permissionLevel: 'user',
240
- execute: async (args) => {
241
- const { bot: botId, user_id } = args;
242
- const bot = this.bots.get(botId);
243
- if (!bot)
244
- throw new Error(`Bot ${botId} 不存在`);
245
- const user = await bot.getUserInfo(user_id);
246
- return {
247
- id: user.id,
248
- name: user.name,
249
- real_name: user.real_name,
250
- display_name: user.profile?.display_name,
251
- email: user.profile?.email,
252
- is_admin: user.is_admin,
253
- is_bot: user.is_bot,
254
- status_text: user.profile?.status_text,
255
- };
256
- },
257
- });
258
- // 设置频道用途
259
- this.addTool({
260
- name: 'slack_set_purpose',
261
- description: '设置 Slack 频道的用途/目的',
262
- parameters: {
263
- type: 'object',
264
- properties: {
265
- bot: { type: 'string', description: 'Bot 名称' },
266
- channel_id: { type: 'string', description: '频道 ID' },
267
- purpose: { type: 'string', description: '频道用途描述' },
268
- },
269
- required: ['bot', 'channel_id', 'purpose'],
270
- },
271
- platforms: ['slack'],
272
- scopes: ['group'],
273
- permissionLevel: 'group_admin',
274
- execute: async (args) => {
275
- const { bot: botId, channel_id, purpose } = args;
276
- const bot = this.bots.get(botId);
277
- if (!bot)
278
- throw new Error(`Bot ${botId} 不存在`);
279
- const success = await bot.setChannelPurpose(channel_id, purpose);
280
- return { success, message: success ? '频道用途已更新' : '操作失败' };
281
- },
282
- });
283
- // 恢复归档频道
284
- this.addTool({
285
- name: 'slack_unarchive',
286
- description: '恢复已归档的 Slack 频道',
287
- parameters: {
288
- type: 'object',
289
- properties: {
290
- bot: { type: 'string', description: 'Bot 名称' },
291
- channel_id: { type: 'string', description: '频道 ID' },
292
- },
293
- required: ['bot', 'channel_id'],
294
- },
295
- platforms: ['slack'],
296
- scopes: ['group'],
297
- permissionLevel: 'group_admin',
298
- execute: async (args) => {
299
- const { bot: botId, channel_id } = args;
300
- const bot = this.bots.get(botId);
301
- if (!bot)
302
- throw new Error(`Bot ${botId} 不存在`);
303
- const success = await bot.unarchiveChannel(channel_id);
304
- return { success, message: success ? '频道已恢复' : '操作失败' };
305
- },
306
- });
307
- this.plugin.logger.debug('已注册 Slack 平台工作区管理工具');
308
- }
309
42
  }
310
43
  //# sourceMappingURL=adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,OAAO,EAEP,0BAA0B,GAE3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,MAAM,OAAO,YAAa,SAAQ,OAAiB;IACjD,YAAY,MAAc;QACxB,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,MAAsB;QAC9B,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,gEAAgE;IAEhE,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,OAAe,EAAE,MAAc;QAC7D,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM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K,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,OAAe;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,kEAAkE;IAElE,KAAK,CAAC,KAAK;QACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CAEF"}
package/lib/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Slack 适配器入口:类型扩展、导出、注册
3
3
  */
4
- import { usePlugin } from "zhin.js";
4
+ import { usePlugin, createGroupManagementTools } from "zhin.js";
5
5
  import { SlackAdapter } from "./adapter.js";
6
6
  export * from "./types.js";
7
7
  export { SlackBot } from "./bot.js";
8
8
  export { SlackAdapter } from "./adapter.js";
9
9
  const plugin = usePlugin();
10
- const { provide } = plugin;
10
+ const { provide, useContext } = plugin;
11
11
  provide({
12
12
  name: "slack",
13
13
  description: "Slack Bot Adapter",
@@ -20,4 +20,223 @@ provide({
20
20
  await adapter.stop();
21
21
  },
22
22
  });
23
+ useContext('tool', 'slack', (toolService, slack) => {
24
+ const groupTools = createGroupManagementTools(slack, 'slack');
25
+ const disposers = groupTools.map(t => toolService.addTool(t, 'slack'));
26
+ function getBot(botId) {
27
+ const bot = slack.bots.get(botId);
28
+ if (!bot)
29
+ throw new Error(`Bot ${botId} 不存在`);
30
+ return bot;
31
+ }
32
+ disposers.push(toolService.addTool({
33
+ name: 'slack_invite_to_channel',
34
+ description: '邀请用户加入 Slack 频道',
35
+ parameters: {
36
+ type: 'object',
37
+ properties: {
38
+ bot: { type: 'string', description: 'Bot 名称' },
39
+ channel: { type: 'string', description: '频道 ID' },
40
+ users: { type: 'string', description: '用户 ID 列表(逗号分隔)' },
41
+ },
42
+ required: ['bot', 'channel', 'users'],
43
+ },
44
+ platforms: ['slack'],
45
+ tags: ['slack'],
46
+ execute: async (args) => {
47
+ const bot = getBot(args.bot);
48
+ const success = await bot.inviteToChannel(args.channel, args.users.split(','));
49
+ return { success, message: success ? '已邀请用户加入频道' : '操作失败' };
50
+ },
51
+ }, 'slack'));
52
+ disposers.push(toolService.addTool({
53
+ name: 'slack_set_topic',
54
+ description: '设置 Slack 频道话题',
55
+ parameters: {
56
+ type: 'object',
57
+ properties: {
58
+ bot: { type: 'string', description: 'Bot 名称' },
59
+ channel: { type: 'string', description: '频道 ID' },
60
+ topic: { type: 'string', description: '新话题' },
61
+ },
62
+ required: ['bot', 'channel', 'topic'],
63
+ },
64
+ platforms: ['slack'],
65
+ tags: ['slack'],
66
+ execute: async (args) => {
67
+ const bot = getBot(args.bot);
68
+ const success = await bot.setChannelTopic(args.channel, args.topic);
69
+ return { success, message: success ? '已设置频道话题' : '操作失败' };
70
+ },
71
+ }, 'slack'));
72
+ disposers.push(toolService.addTool({
73
+ name: 'slack_archive_channel',
74
+ description: '归档 Slack 频道',
75
+ parameters: {
76
+ type: 'object',
77
+ properties: {
78
+ bot: { type: 'string', description: 'Bot 名称' },
79
+ channel: { type: 'string', description: '频道 ID' },
80
+ },
81
+ required: ['bot', 'channel'],
82
+ },
83
+ platforms: ['slack'],
84
+ tags: ['slack'],
85
+ execute: async (args) => {
86
+ const bot = getBot(args.bot);
87
+ const success = await bot.archiveChannel(args.channel);
88
+ return { success, message: success ? '已归档频道' : '操作失败' };
89
+ },
90
+ }, 'slack'));
91
+ disposers.push(toolService.addTool({
92
+ name: 'slack_pin_message',
93
+ description: '置顶 Slack 消息',
94
+ parameters: {
95
+ type: 'object',
96
+ properties: {
97
+ bot: { type: 'string', description: 'Bot 名称' },
98
+ channel: { type: 'string', description: '频道 ID' },
99
+ timestamp: { type: 'string', description: '消息时间戳' },
100
+ },
101
+ required: ['bot', 'channel', 'timestamp'],
102
+ },
103
+ platforms: ['slack'],
104
+ tags: ['slack'],
105
+ execute: async (args) => {
106
+ const bot = getBot(args.bot);
107
+ const success = await bot.pinMessage(args.channel, args.timestamp);
108
+ return { success, message: success ? '已置顶消息' : '操作失败' };
109
+ },
110
+ }, 'slack'));
111
+ disposers.push(toolService.addTool({
112
+ name: 'slack_add_reaction',
113
+ description: '给 Slack 消息添加表情反应',
114
+ parameters: {
115
+ type: 'object',
116
+ properties: {
117
+ bot: { type: 'string', description: 'Bot 名称' },
118
+ channel: { type: 'string', description: '频道 ID' },
119
+ timestamp: { type: 'string', description: '消息时间戳' },
120
+ emoji: { type: 'string', description: '表情名称(不含冒号)' },
121
+ },
122
+ required: ['bot', 'channel', 'timestamp', 'emoji'],
123
+ },
124
+ platforms: ['slack'],
125
+ tags: ['slack'],
126
+ execute: async (args) => {
127
+ const bot = getBot(args.bot);
128
+ const success = await bot.addReaction(args.channel, args.timestamp, args.emoji);
129
+ return { success, message: success ? `已添加反应 :${args.emoji}:` : '操作失败' };
130
+ },
131
+ }, 'slack'));
132
+ disposers.push(toolService.addTool({
133
+ name: 'slack_remove_reaction',
134
+ description: '移除 Slack 消息上的表情反应',
135
+ parameters: {
136
+ type: 'object',
137
+ properties: {
138
+ bot: { type: 'string', description: 'Bot 名称' },
139
+ channel_id: { type: 'string', description: '频道 ID' },
140
+ timestamp: { type: 'string', description: '消息时间戳' },
141
+ name: { type: 'string', description: '表情名称(如 thumbsup、heart)' },
142
+ },
143
+ required: ['bot', 'channel_id', 'timestamp', 'name'],
144
+ },
145
+ platforms: ['slack'],
146
+ tags: ['slack'],
147
+ execute: async (args) => {
148
+ const bot = getBot(args.bot);
149
+ const success = await bot.removeReaction(args.channel_id, args.timestamp, args.name);
150
+ return { success, message: success ? `已移除反应 :${args.name}:` : '操作失败' };
151
+ },
152
+ }, 'slack'));
153
+ disposers.push(toolService.addTool({
154
+ name: 'slack_unpin_message',
155
+ description: '取消 Slack 频道中消息的置顶',
156
+ parameters: {
157
+ type: 'object',
158
+ properties: {
159
+ bot: { type: 'string', description: 'Bot 名称' },
160
+ channel_id: { type: 'string', description: '频道 ID' },
161
+ timestamp: { type: 'string', description: '消息时间戳' },
162
+ },
163
+ required: ['bot', 'channel_id', 'timestamp'],
164
+ },
165
+ platforms: ['slack'],
166
+ tags: ['slack'],
167
+ execute: async (args) => {
168
+ const bot = getBot(args.bot);
169
+ const success = await bot.unpinMessage(args.channel_id, args.timestamp);
170
+ return { success, message: success ? '已取消置顶' : '操作失败' };
171
+ },
172
+ }, 'slack'));
173
+ disposers.push(toolService.addTool({
174
+ name: 'slack_user_info',
175
+ description: '查询 Slack 用户详细信息',
176
+ parameters: {
177
+ type: 'object',
178
+ properties: {
179
+ bot: { type: 'string', description: 'Bot 名称' },
180
+ user_id: { type: 'string', description: '用户 ID' },
181
+ },
182
+ required: ['bot', 'user_id'],
183
+ },
184
+ platforms: ['slack'],
185
+ tags: ['slack'],
186
+ execute: async (args) => {
187
+ const bot = getBot(args.bot);
188
+ const user = await bot.getUserInfo(args.user_id);
189
+ return {
190
+ id: user.id,
191
+ name: user.name,
192
+ real_name: user.real_name,
193
+ display_name: user.profile?.display_name,
194
+ email: user.profile?.email,
195
+ is_admin: user.is_admin,
196
+ is_bot: user.is_bot,
197
+ status_text: user.profile?.status_text,
198
+ };
199
+ },
200
+ }, 'slack'));
201
+ disposers.push(toolService.addTool({
202
+ name: 'slack_set_purpose',
203
+ description: '设置 Slack 频道的用途/目的',
204
+ parameters: {
205
+ type: 'object',
206
+ properties: {
207
+ bot: { type: 'string', description: 'Bot 名称' },
208
+ channel_id: { type: 'string', description: '频道 ID' },
209
+ purpose: { type: 'string', description: '频道用途描述' },
210
+ },
211
+ required: ['bot', 'channel_id', 'purpose'],
212
+ },
213
+ platforms: ['slack'],
214
+ tags: ['slack'],
215
+ execute: async (args) => {
216
+ const bot = getBot(args.bot);
217
+ const success = await bot.setChannelPurpose(args.channel_id, args.purpose);
218
+ return { success, message: success ? '频道用途已更新' : '操作失败' };
219
+ },
220
+ }, 'slack'));
221
+ disposers.push(toolService.addTool({
222
+ name: 'slack_unarchive',
223
+ description: '恢复已归档的 Slack 频道',
224
+ parameters: {
225
+ type: 'object',
226
+ properties: {
227
+ bot: { type: 'string', description: 'Bot 名称' },
228
+ channel_id: { type: 'string', description: '频道 ID' },
229
+ },
230
+ required: ['bot', 'channel_id'],
231
+ },
232
+ platforms: ['slack'],
233
+ tags: ['slack'],
234
+ execute: async (args) => {
235
+ const bot = getBot(args.bot);
236
+ const success = await bot.unarchiveChannel(args.channel_id);
237
+ return { success, message: success ? '频道已恢复' : '操作失败' };
238
+ },
239
+ }, 'slack'));
240
+ return () => disposers.forEach(d => d());
241
+ });
23
242
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAe,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAQ5C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;AAC3B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;AAE3B,OAAO,CAAC;IACN,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,mBAAmB;IAChC,OAAO,EAAE,KAAK,EAAE,CAAS,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,OAAO,C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"version": "1.0.44",
3
+ "version": "1.0.47",
4
4
  "description": "Zhin.js adapter for Slack",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -37,11 +37,11 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^22.9.0",
40
- "typescript": "^5.3.0",
41
- "zhin.js": "1.0.57"
40
+ "typescript": "^5.9.3",
41
+ "zhin.js": "1.0.60"
42
42
  },
43
43
  "peerDependencies": {
44
- "zhin.js": "1.0.57"
44
+ "zhin.js": "1.0.60"
45
45
  },
46
46
  "files": [
47
47
  "src",
@@ -1,17 +1,70 @@
1
1
  ---
2
2
  name: slack
3
- description: Slack 工作区/频道管理:踢人、禁言、改频道名、查成员等。需先 list_members 获取用户 ID 再执行管理操作。
3
+ platforms:
4
+ - slack
5
+ description: Slack 工作区管理:群管(踢人、改频道名、查成员/频道信息)、邀请用户、设置话题/用途、归档/恢复频道、置顶消息、表情反应、用户信息查询。
4
6
  keywords:
5
7
  - slack
6
8
  - adapter:slack
7
9
  - 群管理
10
+ - 频道
11
+ - 话题
12
+ - 置顶
13
+ - 反应
14
+ - 归档
8
15
  - list_members
9
16
  tags:
10
17
  - group
11
18
  - management
12
- tools: []
19
+ - im
20
+ - enterprise
21
+ tools:
22
+ # 平台特有工具
23
+ - slack_invite_to_channel
24
+ - slack_set_topic
25
+ - slack_archive_channel
26
+ - slack_pin_message
27
+ - slack_add_reaction
28
+ - slack_remove_reaction
29
+ - slack_unpin_message
30
+ - slack_user_info
31
+ - slack_set_purpose
32
+ - slack_unarchive
33
+ # 通用群管工具
34
+ - slack_kick_member
35
+ - slack_set_group_name
36
+ - slack_list_members
37
+ - slack_get_group_info
13
38
  ---
14
39
 
40
+ ## 工具概览
41
+
42
+ ### 平台特有
43
+
44
+ | 工具 | 说明 | 权限 |
45
+ |------|------|------|
46
+ | `slack_invite_to_channel` | 邀请用户加入频道 | group_admin |
47
+ | `slack_set_topic` | 设置频道话题 | user |
48
+ | `slack_set_purpose` | 设置频道用途 | user |
49
+ | `slack_archive_channel` | 归档频道 | group_admin |
50
+ | `slack_unarchive` | 恢复归档频道 | group_admin |
51
+ | `slack_pin_message` | 置顶消息 | user |
52
+ | `slack_unpin_message` | 取消置顶 | user |
53
+ | `slack_add_reaction` | 添加表情反应 | user |
54
+ | `slack_remove_reaction` | 移除表情反应 | user |
55
+ | `slack_user_info` | 查询用户信息 | user |
56
+
57
+ ### 通用群管
58
+
59
+ | 工具 | 说明 | 权限 |
60
+ |------|------|------|
61
+ | `slack_kick_member` | 踢出成员 | group_admin |
62
+ | `slack_set_group_name` | 修改频道名称 | group_admin |
63
+ | `slack_list_members` | 获取成员列表 | user |
64
+ | `slack_get_group_info` | 获取频道信息 | user |
65
+
15
66
  ## 执行规则
16
67
 
17
- - 使用 `slack_*` 工具;先 list_members 获取 Slack 用户 ID。
68
+ 1. 操作成员需要 Slack 用户 ID,先 `slack_list_members` `slack_user_info` 获取
69
+ 2. 归档频道后不可发送消息,需 `slack_unarchive` 恢复
70
+ 3. 话题和用途为频道元信息,对所有成员可见
package/src/adapter.ts CHANGED
@@ -4,8 +4,6 @@
4
4
  import {
5
5
  Adapter,
6
6
  Plugin,
7
- createGroupManagementTools,
8
- type IGroupManagement,
9
7
  } from "zhin.js";
10
8
  import { SlackBot } from "./bot.js";
11
9
  import type { SlackBotConfig } from "./types.js";
@@ -48,274 +46,7 @@ export class SlackAdapter extends Adapter<SlackBot> {
48
46
  // ── 生命周期 ───────────────────────────────────────────────────────
49
47
 
50
48
  async start(): Promise<void> {
51
- this.registerSlackPlatformTools();
52
- const groupTools = createGroupManagementTools(this as unknown as IGroupManagement, this.name);
53
- groupTools.forEach((t) => this.addTool(t));
54
49
  await super.start();
55
50
  }
56
51
 
57
- /**
58
- * 注册 Slack 平台特有工具(邀请到频道等)
59
- */
60
- private registerSlackPlatformTools(): void {
61
- // 邀请用户到频道
62
- this.addTool({
63
- name: 'slack_invite_to_channel',
64
- description: '邀请用户加入 Slack 频道',
65
- parameters: {
66
- type: 'object',
67
- properties: {
68
- bot: { type: 'string', description: 'Bot 名称' },
69
- channel: { type: 'string', description: '频道 ID' },
70
- users: { type: 'array', items: { type: 'string' }, description: '用户 ID 列表' },
71
- },
72
- required: ['bot', 'channel', 'users'],
73
- },
74
- platforms: ['slack'],
75
- scopes: ['group'],
76
- permissionLevel: 'group_admin',
77
- execute: async (args) => {
78
- const { bot: botId, channel, users } = args;
79
- const bot = this.bots.get(botId);
80
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
81
- const success = await bot.inviteToChannel(channel, users);
82
- return { success, message: success ? `已邀请用户加入频道` : '操作失败' };
83
- },
84
- });
85
-
86
- // 设置频道话题
87
- this.addTool({
88
- name: 'slack_set_topic',
89
- description: '设置 Slack 频道话题',
90
- parameters: {
91
- type: 'object',
92
- properties: {
93
- bot: { type: 'string', description: 'Bot 名称' },
94
- channel: { type: 'string', description: '频道 ID' },
95
- topic: { type: 'string', description: '新话题' },
96
- },
97
- required: ['bot', 'channel', 'topic'],
98
- },
99
- platforms: ['slack'],
100
- scopes: ['group'],
101
- permissionLevel: 'group_admin',
102
- execute: async (args) => {
103
- const { bot: botId, channel, topic } = args;
104
- const bot = this.bots.get(botId);
105
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
106
- const success = await bot.setChannelTopic(channel, topic);
107
- return { success, message: success ? `已设置频道话题` : '操作失败' };
108
- },
109
- });
110
-
111
- // 归档频道
112
- this.addTool({
113
- name: 'slack_archive_channel',
114
- description: '归档 Slack 频道',
115
- parameters: {
116
- type: 'object',
117
- properties: {
118
- bot: { type: 'string', description: 'Bot 名称' },
119
- channel: { type: 'string', description: '频道 ID' },
120
- },
121
- required: ['bot', 'channel'],
122
- },
123
- platforms: ['slack'],
124
- scopes: ['group'],
125
- permissionLevel: 'group_admin',
126
- execute: async (args) => {
127
- const { bot: botId, channel } = args;
128
- const bot = this.bots.get(botId);
129
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
130
- const success = await bot.archiveChannel(channel);
131
- return { success, message: success ? `已归档频道` : '操作失败' };
132
- },
133
- });
134
-
135
- // 置顶消息
136
- this.addTool({
137
- name: 'slack_pin_message',
138
- description: '置顶 Slack 消息',
139
- parameters: {
140
- type: 'object',
141
- properties: {
142
- bot: { type: 'string', description: 'Bot 名称' },
143
- channel: { type: 'string', description: '频道 ID' },
144
- timestamp: { type: 'string', description: '消息时间戳' },
145
- },
146
- required: ['bot', 'channel', 'timestamp'],
147
- },
148
- platforms: ['slack'],
149
- scopes: ['group'],
150
- permissionLevel: 'group_admin',
151
- execute: async (args) => {
152
- const { bot: botId, channel, timestamp } = args;
153
- const bot = this.bots.get(botId);
154
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
155
- const success = await bot.pinMessage(channel, timestamp);
156
- return { success, message: success ? `已置顶消息` : '操作失败' };
157
- },
158
- });
159
-
160
- // 添加反应
161
- this.addTool({
162
- name: 'slack_add_reaction',
163
- description: '给 Slack 消息添加表情反应',
164
- parameters: {
165
- type: 'object',
166
- properties: {
167
- bot: { type: 'string', description: 'Bot 名称' },
168
- channel: { type: 'string', description: '频道 ID' },
169
- timestamp: { type: 'string', description: '消息时间戳' },
170
- emoji: { type: 'string', description: '表情名称(不含冒号)' },
171
- },
172
- required: ['bot', 'channel', 'timestamp', 'emoji'],
173
- },
174
- platforms: ['slack'],
175
- scopes: ['group', 'private'],
176
- permissionLevel: 'user',
177
- execute: async (args) => {
178
- const { bot: botId, channel, timestamp, emoji } = args;
179
- const bot = this.bots.get(botId);
180
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
181
- const success = await bot.addReaction(channel, timestamp, emoji);
182
- return { success, message: success ? `已添加反应 :${emoji}:` : '操作失败' };
183
- },
184
- });
185
-
186
- // 移除表情反应
187
- this.addTool({
188
- name: 'slack_remove_reaction',
189
- description: '移除 Slack 消息上的表情反应',
190
- parameters: {
191
- type: 'object',
192
- properties: {
193
- bot: { type: 'string', description: 'Bot 名称' },
194
- channel_id: { type: 'string', description: '频道 ID' },
195
- timestamp: { type: 'string', description: '消息时间戳' },
196
- name: { type: 'string', description: '表情名称(如 thumbsup、heart)' },
197
- },
198
- required: ['bot', 'channel_id', 'timestamp', 'name'],
199
- },
200
- platforms: ['slack'],
201
- scopes: ['group'],
202
- permissionLevel: 'user',
203
- execute: async (args) => {
204
- const { bot: botId, channel_id, timestamp, name } = args;
205
- const bot = this.bots.get(botId);
206
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
207
- const success = await bot.removeReaction(channel_id, timestamp, name);
208
- return { success, message: success ? `已移除反应 :${name}:` : '操作失败' };
209
- },
210
- });
211
-
212
- // 取消置顶消息
213
- this.addTool({
214
- name: 'slack_unpin_message',
215
- description: '取消 Slack 频道中消息的置顶',
216
- parameters: {
217
- type: 'object',
218
- properties: {
219
- bot: { type: 'string', description: 'Bot 名称' },
220
- channel_id: { type: 'string', description: '频道 ID' },
221
- timestamp: { type: 'string', description: '消息时间戳' },
222
- },
223
- required: ['bot', 'channel_id', 'timestamp'],
224
- },
225
- platforms: ['slack'],
226
- scopes: ['group'],
227
- permissionLevel: 'group_admin',
228
- execute: async (args) => {
229
- const { bot: botId, channel_id, timestamp } = args;
230
- const bot = this.bots.get(botId);
231
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
232
- const success = await bot.unpinMessage(channel_id, timestamp);
233
- return { success, message: success ? '已取消置顶' : '操作失败' };
234
- },
235
- });
236
-
237
- // 查询用户信息
238
- this.addTool({
239
- name: 'slack_user_info',
240
- description: '查询 Slack 用户详细信息',
241
- parameters: {
242
- type: 'object',
243
- properties: {
244
- bot: { type: 'string', description: 'Bot 名称' },
245
- user_id: { type: 'string', description: '用户 ID' },
246
- },
247
- required: ['bot', 'user_id'],
248
- },
249
- platforms: ['slack'],
250
- scopes: ['group', 'private'],
251
- permissionLevel: 'user',
252
- execute: async (args) => {
253
- const { bot: botId, user_id } = args;
254
- const bot = this.bots.get(botId);
255
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
256
- const user = await bot.getUserInfo(user_id);
257
- return {
258
- id: user.id,
259
- name: user.name,
260
- real_name: user.real_name,
261
- display_name: user.profile?.display_name,
262
- email: user.profile?.email,
263
- is_admin: user.is_admin,
264
- is_bot: user.is_bot,
265
- status_text: user.profile?.status_text,
266
- };
267
- },
268
- });
269
-
270
- // 设置频道用途
271
- this.addTool({
272
- name: 'slack_set_purpose',
273
- description: '设置 Slack 频道的用途/目的',
274
- parameters: {
275
- type: 'object',
276
- properties: {
277
- bot: { type: 'string', description: 'Bot 名称' },
278
- channel_id: { type: 'string', description: '频道 ID' },
279
- purpose: { type: 'string', description: '频道用途描述' },
280
- },
281
- required: ['bot', 'channel_id', 'purpose'],
282
- },
283
- platforms: ['slack'],
284
- scopes: ['group'],
285
- permissionLevel: 'group_admin',
286
- execute: async (args) => {
287
- const { bot: botId, channel_id, purpose } = args;
288
- const bot = this.bots.get(botId);
289
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
290
- const success = await bot.setChannelPurpose(channel_id, purpose);
291
- return { success, message: success ? '频道用途已更新' : '操作失败' };
292
- },
293
- });
294
-
295
- // 恢复归档频道
296
- this.addTool({
297
- name: 'slack_unarchive',
298
- description: '恢复已归档的 Slack 频道',
299
- parameters: {
300
- type: 'object',
301
- properties: {
302
- bot: { type: 'string', description: 'Bot 名称' },
303
- channel_id: { type: 'string', description: '频道 ID' },
304
- },
305
- required: ['bot', 'channel_id'],
306
- },
307
- platforms: ['slack'],
308
- scopes: ['group'],
309
- permissionLevel: 'group_admin',
310
- execute: async (args) => {
311
- const { bot: botId, channel_id } = args;
312
- const bot = this.bots.get(botId);
313
- if (!bot) throw new Error(`Bot ${botId} 不存在`);
314
- const success = await bot.unarchiveChannel(channel_id);
315
- return { success, message: success ? '频道已恢复' : '操作失败' };
316
- },
317
- });
318
-
319
- this.plugin.logger.debug('已注册 Slack 平台工作区管理工具');
320
- }
321
52
  }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Slack 适配器入口:类型扩展、导出、注册
3
3
  */
4
- import { usePlugin, type Plugin } from "zhin.js";
4
+ import { usePlugin, type Plugin, type IGroupManagement, createGroupManagementTools, type ToolFeature } from "zhin.js";
5
5
  import { SlackAdapter } from "./adapter.js";
6
6
 
7
7
  declare module "zhin.js" {
@@ -15,7 +15,7 @@ export { SlackBot } from "./bot.js";
15
15
  export { SlackAdapter } from "./adapter.js";
16
16
 
17
17
  const plugin = usePlugin();
18
- const { provide } = plugin;
18
+ const { provide, useContext } = plugin;
19
19
 
20
20
  provide({
21
21
  name: "slack",
@@ -29,3 +29,237 @@ provide({
29
29
  await adapter.stop();
30
30
  },
31
31
  });
32
+
33
+ useContext('tool', 'slack', (toolService: ToolFeature, slack: SlackAdapter) => {
34
+ const groupTools = createGroupManagementTools(
35
+ slack as unknown as IGroupManagement,
36
+ 'slack',
37
+ );
38
+ const disposers: (() => void)[] = groupTools.map(t => toolService.addTool(t, 'slack'));
39
+
40
+ function getBot(botId: string) {
41
+ const bot = slack.bots.get(botId);
42
+ if (!bot) throw new Error(`Bot ${botId} 不存在`);
43
+ return bot;
44
+ }
45
+
46
+ disposers.push(toolService.addTool({
47
+ name: 'slack_invite_to_channel',
48
+ description: '邀请用户加入 Slack 频道',
49
+ parameters: {
50
+ type: 'object',
51
+ properties: {
52
+ bot: { type: 'string', description: 'Bot 名称' },
53
+ channel: { type: 'string', description: '频道 ID' },
54
+ users: { type: 'string', description: '用户 ID 列表(逗号分隔)' },
55
+ },
56
+ required: ['bot', 'channel', 'users'],
57
+ },
58
+ platforms: ['slack'],
59
+ tags: ['slack'],
60
+ execute: async (args: Record<string, any>) => {
61
+ const bot = getBot(args.bot);
62
+ const success = await bot.inviteToChannel(args.channel, args.users.split(','));
63
+ return { success, message: success ? '已邀请用户加入频道' : '操作失败' };
64
+ },
65
+ }, 'slack'));
66
+
67
+ disposers.push(toolService.addTool({
68
+ name: 'slack_set_topic',
69
+ description: '设置 Slack 频道话题',
70
+ parameters: {
71
+ type: 'object',
72
+ properties: {
73
+ bot: { type: 'string', description: 'Bot 名称' },
74
+ channel: { type: 'string', description: '频道 ID' },
75
+ topic: { type: 'string', description: '新话题' },
76
+ },
77
+ required: ['bot', 'channel', 'topic'],
78
+ },
79
+ platforms: ['slack'],
80
+ tags: ['slack'],
81
+ execute: async (args: Record<string, any>) => {
82
+ const bot = getBot(args.bot);
83
+ const success = await bot.setChannelTopic(args.channel, args.topic);
84
+ return { success, message: success ? '已设置频道话题' : '操作失败' };
85
+ },
86
+ }, 'slack'));
87
+
88
+ disposers.push(toolService.addTool({
89
+ name: 'slack_archive_channel',
90
+ description: '归档 Slack 频道',
91
+ parameters: {
92
+ type: 'object',
93
+ properties: {
94
+ bot: { type: 'string', description: 'Bot 名称' },
95
+ channel: { type: 'string', description: '频道 ID' },
96
+ },
97
+ required: ['bot', 'channel'],
98
+ },
99
+ platforms: ['slack'],
100
+ tags: ['slack'],
101
+ execute: async (args: Record<string, any>) => {
102
+ const bot = getBot(args.bot);
103
+ const success = await bot.archiveChannel(args.channel);
104
+ return { success, message: success ? '已归档频道' : '操作失败' };
105
+ },
106
+ }, 'slack'));
107
+
108
+ disposers.push(toolService.addTool({
109
+ name: 'slack_pin_message',
110
+ description: '置顶 Slack 消息',
111
+ parameters: {
112
+ type: 'object',
113
+ properties: {
114
+ bot: { type: 'string', description: 'Bot 名称' },
115
+ channel: { type: 'string', description: '频道 ID' },
116
+ timestamp: { type: 'string', description: '消息时间戳' },
117
+ },
118
+ required: ['bot', 'channel', 'timestamp'],
119
+ },
120
+ platforms: ['slack'],
121
+ tags: ['slack'],
122
+ execute: async (args: Record<string, any>) => {
123
+ const bot = getBot(args.bot);
124
+ const success = await bot.pinMessage(args.channel, args.timestamp);
125
+ return { success, message: success ? '已置顶消息' : '操作失败' };
126
+ },
127
+ }, 'slack'));
128
+
129
+ disposers.push(toolService.addTool({
130
+ name: 'slack_add_reaction',
131
+ description: '给 Slack 消息添加表情反应',
132
+ parameters: {
133
+ type: 'object',
134
+ properties: {
135
+ bot: { type: 'string', description: 'Bot 名称' },
136
+ channel: { type: 'string', description: '频道 ID' },
137
+ timestamp: { type: 'string', description: '消息时间戳' },
138
+ emoji: { type: 'string', description: '表情名称(不含冒号)' },
139
+ },
140
+ required: ['bot', 'channel', 'timestamp', 'emoji'],
141
+ },
142
+ platforms: ['slack'],
143
+ tags: ['slack'],
144
+ execute: async (args: Record<string, any>) => {
145
+ const bot = getBot(args.bot);
146
+ const success = await bot.addReaction(args.channel, args.timestamp, args.emoji);
147
+ return { success, message: success ? `已添加反应 :${args.emoji}:` : '操作失败' };
148
+ },
149
+ }, 'slack'));
150
+
151
+ disposers.push(toolService.addTool({
152
+ name: 'slack_remove_reaction',
153
+ description: '移除 Slack 消息上的表情反应',
154
+ parameters: {
155
+ type: 'object',
156
+ properties: {
157
+ bot: { type: 'string', description: 'Bot 名称' },
158
+ channel_id: { type: 'string', description: '频道 ID' },
159
+ timestamp: { type: 'string', description: '消息时间戳' },
160
+ name: { type: 'string', description: '表情名称(如 thumbsup、heart)' },
161
+ },
162
+ required: ['bot', 'channel_id', 'timestamp', 'name'],
163
+ },
164
+ platforms: ['slack'],
165
+ tags: ['slack'],
166
+ execute: async (args: Record<string, any>) => {
167
+ const bot = getBot(args.bot);
168
+ const success = await bot.removeReaction(args.channel_id, args.timestamp, args.name);
169
+ return { success, message: success ? `已移除反应 :${args.name}:` : '操作失败' };
170
+ },
171
+ }, 'slack'));
172
+
173
+ disposers.push(toolService.addTool({
174
+ name: 'slack_unpin_message',
175
+ description: '取消 Slack 频道中消息的置顶',
176
+ parameters: {
177
+ type: 'object',
178
+ properties: {
179
+ bot: { type: 'string', description: 'Bot 名称' },
180
+ channel_id: { type: 'string', description: '频道 ID' },
181
+ timestamp: { type: 'string', description: '消息时间戳' },
182
+ },
183
+ required: ['bot', 'channel_id', 'timestamp'],
184
+ },
185
+ platforms: ['slack'],
186
+ tags: ['slack'],
187
+ execute: async (args: Record<string, any>) => {
188
+ const bot = getBot(args.bot);
189
+ const success = await bot.unpinMessage(args.channel_id, args.timestamp);
190
+ return { success, message: success ? '已取消置顶' : '操作失败' };
191
+ },
192
+ }, 'slack'));
193
+
194
+ disposers.push(toolService.addTool({
195
+ name: 'slack_user_info',
196
+ description: '查询 Slack 用户详细信息',
197
+ parameters: {
198
+ type: 'object',
199
+ properties: {
200
+ bot: { type: 'string', description: 'Bot 名称' },
201
+ user_id: { type: 'string', description: '用户 ID' },
202
+ },
203
+ required: ['bot', 'user_id'],
204
+ },
205
+ platforms: ['slack'],
206
+ tags: ['slack'],
207
+ execute: async (args: Record<string, any>) => {
208
+ const bot = getBot(args.bot);
209
+ const user = await bot.getUserInfo(args.user_id);
210
+ return {
211
+ id: user.id,
212
+ name: user.name,
213
+ real_name: user.real_name,
214
+ display_name: user.profile?.display_name,
215
+ email: user.profile?.email,
216
+ is_admin: user.is_admin,
217
+ is_bot: user.is_bot,
218
+ status_text: user.profile?.status_text,
219
+ };
220
+ },
221
+ }, 'slack'));
222
+
223
+ disposers.push(toolService.addTool({
224
+ name: 'slack_set_purpose',
225
+ description: '设置 Slack 频道的用途/目的',
226
+ parameters: {
227
+ type: 'object',
228
+ properties: {
229
+ bot: { type: 'string', description: 'Bot 名称' },
230
+ channel_id: { type: 'string', description: '频道 ID' },
231
+ purpose: { type: 'string', description: '频道用途描述' },
232
+ },
233
+ required: ['bot', 'channel_id', 'purpose'],
234
+ },
235
+ platforms: ['slack'],
236
+ tags: ['slack'],
237
+ execute: async (args: Record<string, any>) => {
238
+ const bot = getBot(args.bot);
239
+ const success = await bot.setChannelPurpose(args.channel_id, args.purpose);
240
+ return { success, message: success ? '频道用途已更新' : '操作失败' };
241
+ },
242
+ }, 'slack'));
243
+
244
+ disposers.push(toolService.addTool({
245
+ name: 'slack_unarchive',
246
+ description: '恢复已归档的 Slack 频道',
247
+ parameters: {
248
+ type: 'object',
249
+ properties: {
250
+ bot: { type: 'string', description: 'Bot 名称' },
251
+ channel_id: { type: 'string', description: '频道 ID' },
252
+ },
253
+ required: ['bot', 'channel_id'],
254
+ },
255
+ platforms: ['slack'],
256
+ tags: ['slack'],
257
+ execute: async (args: Record<string, any>) => {
258
+ const bot = getBot(args.bot);
259
+ const success = await bot.unarchiveChannel(args.channel_id);
260
+ return { success, message: success ? '频道已恢复' : '操作失败' };
261
+ },
262
+ }, 'slack'));
263
+
264
+ return () => disposers.forEach(d => d());
265
+ });