@zhin.js/adapter-slack 1.1.10 → 1.1.13

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,60 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [db06de8]
8
+ - @zhin.js/core@1.1.48
9
+
10
+ ## 1.1.12
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [1a11207]
15
+ - Updated dependencies [9943df6]
16
+ - Updated dependencies [5be09ae]
17
+ - Updated dependencies [a3ab153]
18
+ - Updated dependencies [e8f7309]
19
+ - Updated dependencies [5afc18f]
20
+ - Updated dependencies [d3563d9]
21
+ - Updated dependencies [c618eb7]
22
+ - Updated dependencies [fbfefb7]
23
+ - @zhin.js/tool@1.1.8
24
+ - @zhin.js/core@1.1.47
25
+ - @zhin.js/adapter@1.1.21
26
+ - @zhin.js/feature-kit@1.1.7
27
+ - @zhin.js/im-contract@1.1.5
28
+ - @zhin.js/agent-feature@1.1.8
29
+ - @zhin.js/skill@1.1.8
30
+ - @zhin.js/host-http@1.1.8
31
+
32
+ ## 1.1.11
33
+
34
+ ### Patch Changes
35
+
36
+ - 064b06d: 保留 Slack 按钮回调所属的消息线程,使回调与普通消息使用一致的完整会话身份;普通频道消息不会误用按钮源消息时间戳创建线程。
37
+ - 9816c18: 将应用插件装配改为 configVersion: 2:主配置 plugins 映射实例名到包,disable_plugins 控制启停,业务配置使用顶层同名块。package.json 继续保留 features、entry、engine 等包契约,并支持静态 displayName/icon。
38
+
39
+ 这是配置格式的破坏性更新:旧配置不能继续运行,请先停止 Bot,运行 `zhin migrate instances` 预览,再使用 `--apply` 转换;提供备份与中断继续/回滚,无法无损转换的嵌套、optional 和别名碰撞需人工迁移。Runtime、Console、CLI 与创建向导统一使用新声明。
40
+
41
+ 保留框架顶层 `menuKeyword` / `menuStyle`,通过当前 generation 的 Root 配置视图供 Command Feature 消费;严格校验和配置修改不会丢失菜单设置,子实例配置保持隔离。
42
+
43
+ - Updated dependencies [c407bd2]
44
+ - Updated dependencies [064b06d]
45
+ - Updated dependencies [2b4d6dc]
46
+ - Updated dependencies [b58548a]
47
+ - Updated dependencies [e914a93]
48
+ - Updated dependencies [e914a93]
49
+ - Updated dependencies [064b06d]
50
+ - @zhin.js/core@1.1.46
51
+ - @zhin.js/feature-kit@1.1.6
52
+ - @zhin.js/host-http@1.1.7
53
+ - @zhin.js/adapter@1.1.20
54
+ - @zhin.js/agent-feature@1.1.7
55
+ - @zhin.js/skill@1.1.7
56
+ - @zhin.js/tool@1.1.7
57
+
3
58
  ## 1.1.10
4
59
 
5
60
  ### Patch Changes
package/README.md CHANGED
@@ -22,7 +22,7 @@ pnpm add @zhin.js/adapter-slack
22
22
  - `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
23
23
  - `@zhin.js/host-http` — 仅 HTTP 模式需要 `httpHostToken` 注册 Events 路由
24
24
  - `zhin.js` — `plugin.ts`(`definePlugin`)
25
- - 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
25
+ - 配置经插件 `schema.json` 落到顶层 `<instanceKey>`
26
26
 
27
27
  入站:`gateway.receive({ conversation, message: { conversation, id }, content: text, sender, metadata })`(`conversation` 为 ConversationRef:`channel_type: im` → kind `private`,其余 → kind `group`;线程根 ts 进 `threadId`)
28
28
  出站:`send({ conversation, payload })` → Web API(`conversation.id` 为 channel,`conversation.threadId` 为 thread_ts)
@@ -47,44 +47,50 @@ pnpm add @zhin.js/adapter-slack
47
47
  ## 最小配置(Socket Mode)
48
48
 
49
49
  ```yaml
50
+ configVersion: 2
50
51
  # zhin.config.yml(Plugin Runtime)
51
52
  plugins:
52
- slack:
53
- socketMode: true # 默认 true,可省略
54
- endpoints:
55
- - id: my-slack-bot
56
- token: ${SLACK_BOT_TOKEN}
57
- appToken: ${SLACK_APP_TOKEN}
53
+ slack: "@zhin.js/adapter-slack"
54
+ slack:
55
+ socketMode: true # 默认 true,可省略
56
+ endpoints:
57
+ - id: my-slack-bot
58
+ token: ${SLACK_BOT_TOKEN}
59
+ appToken: ${SLACK_APP_TOKEN}
58
60
  ```
59
61
 
60
62
  多 workspace:一个插件实例挂多个 endpoint(`endpoints` 数组逐项覆盖顶层字段,`id` 必填):
61
63
 
62
64
  ```yaml
65
+ configVersion: 2
63
66
  plugins:
64
- slack:
65
- endpoints:
66
- - id: team-a
67
- token: ${SLACK_BOT_TOKEN_A}
68
- appToken: ${SLACK_APP_TOKEN_A}
69
- - id: team-b
70
- token: ${SLACK_BOT_TOKEN_B}
71
- appToken: ${SLACK_APP_TOKEN_B}
67
+ slack: "@zhin.js/adapter-slack"
68
+ slack:
69
+ endpoints:
70
+ - id: team-a
71
+ token: ${SLACK_BOT_TOKEN_A}
72
+ appToken: ${SLACK_APP_TOKEN_A}
73
+ - id: team-b
74
+ token: ${SLACK_BOT_TOKEN_B}
75
+ appToken: ${SLACK_APP_TOKEN_B}
72
76
  ```
73
77
 
74
78
  ## HTTP Events 配置
75
79
 
76
80
  ```yaml
81
+ configVersion: 2
77
82
  plugins:
78
- slack:
79
- socketMode: false
80
- webhookPath: /slack/events # 可选,默认 /slack/events
81
- endpoints:
82
- - id: my-slack-bot
83
- token: ${SLACK_BOT_TOKEN}
84
- signingSecret: ${SLACK_SIGNING_SECRET}
83
+ slack: "@zhin.js/adapter-slack"
84
+ slack:
85
+ socketMode: false
86
+ webhookPath: /slack/events # 可选,默认 /slack/events
87
+ endpoints:
88
+ - id: my-slack-bot
89
+ token: ${SLACK_BOT_TOKEN}
90
+ signingSecret: ${SLACK_SIGNING_SECRET}
85
91
  ```
86
92
 
87
- 根插件 `zhin.plugins`(或项目图)需引用 `@zhin.js/adapter-slack`(`instanceKey: slack`)。
93
+ 主配置 `plugins` 映射需引用 `@zhin.js/adapter-slack`(`instanceKey: slack`)。
88
94
  HTTP 模式下 Runtime Host(`http`)须已 listen;Slack App 的 Event Subscriptions / Interactivity / Slash Commands Request URL 指向 `https://your-domain/slack/events`。
89
95
 
90
96
  ## 环境变量
package/lib/endpoint.js CHANGED
@@ -207,6 +207,8 @@ export class SlackEndpoint extends Endpoint {
207
207
  const channelId = payload.channel?.id ?? '';
208
208
  const userId = payload.user.id;
209
209
  const messageTs = payload.message?.ts ?? '';
210
+ const sourceThread = payload.message?.thread_ts;
211
+ const threadTs = typeof sourceThread === 'string' && sourceThread && sourceThread !== messageTs ? sourceThread : undefined;
210
212
  if (payload.response_url) {
211
213
  postSlackEphemeral(payload.response_url, '已收到', this.#logger);
212
214
  }
@@ -215,6 +217,7 @@ export class SlackEndpoint extends Endpoint {
215
217
  channelId: channelId || userId,
216
218
  // block_actions 无 channel_type;无 channel 时按与发起用户的 DM 处理
217
219
  channelType: channelId ? undefined : 'im',
220
+ threadId: threadTs,
218
221
  });
219
222
  void this.emit('message.receive', {
220
223
  conversation,
@@ -226,7 +229,7 @@ export class SlackEndpoint extends Endpoint {
226
229
  metadata: Object.freeze({
227
230
  eventType: 'block_actions',
228
231
  actionId: payload.actions[0]?.action_id,
229
- threadTs: messageTs || undefined,
232
+ threadTs,
230
233
  }),
231
234
  }).catch((err) => {
232
235
  this.#logger.warn(formatCompact({
package/lib/protocol.d.ts CHANGED
@@ -55,6 +55,7 @@ export interface SlackInteractionPayload {
55
55
  readonly message?: {
56
56
  ts: string;
57
57
  text?: string;
58
+ thread_ts?: string;
58
59
  [key: string]: unknown;
59
60
  };
60
61
  readonly actions?: SlackBlockAction[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-slack",
3
- "version": "1.1.10",
3
+ "version": "1.1.13",
4
4
  "description": "Zhin.js Slack adapter for Plugin Runtime (Socket Mode / HTTP Events)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -33,24 +33,24 @@
33
33
  "dependencies": {
34
34
  "@slack/socket-mode": "^2.0.7",
35
35
  "@slack/web-api": "^7.19.0",
36
- "@zhin.js/adapter": "1.1.19",
37
- "@zhin.js/agent-feature": "1.1.6",
38
- "@zhin.js/core": "1.1.45",
39
- "@zhin.js/feature-kit": "1.1.5",
40
- "@zhin.js/host-http": "1.1.6",
41
- "@zhin.js/im-contract": "1.1.4",
36
+ "@zhin.js/adapter": "1.1.21",
37
+ "@zhin.js/agent-feature": "1.1.8",
38
+ "@zhin.js/core": "1.1.48",
39
+ "@zhin.js/feature-kit": "1.1.7",
40
+ "@zhin.js/host-http": "1.1.8",
41
+ "@zhin.js/im-contract": "1.1.5",
42
42
  "@zhin.js/logger": "1.1.2",
43
- "@zhin.js/skill": "1.1.6",
44
- "@zhin.js/tool": "1.1.6"
43
+ "@zhin.js/skill": "1.1.8",
44
+ "@zhin.js/tool": "1.1.8"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "zod": "^4.0.0",
48
- "@zhin.js/adapter": "^1.1.19",
49
- "@zhin.js/command": "^1.1.7",
50
- "@zhin.js/core": "^1.1.45",
51
- "@zhin.js/host-http": "^1.1.6",
52
- "@zhin.js/permission": "^1.1.6",
53
- "zhin.js": "^1.1.10"
48
+ "@zhin.js/adapter": "^1.1.21",
49
+ "@zhin.js/command": "^1.1.9",
50
+ "@zhin.js/core": "^1.1.48",
51
+ "@zhin.js/host-http": "^1.1.8",
52
+ "@zhin.js/permission": "^1.1.7",
53
+ "zhin.js": "^1.1.13"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@zhin.js/command": {
@@ -68,7 +68,7 @@
68
68
  "typescript": "^6.0.3",
69
69
  "vitest": "^4.1.10",
70
70
  "zod": "^4.4.3",
71
- "zhin.js": "1.1.10"
71
+ "zhin.js": "1.1.13"
72
72
  },
73
73
  "files": [
74
74
  "adapters",
package/src/endpoint.ts CHANGED
@@ -298,6 +298,8 @@ export class SlackEndpoint extends Endpoint<SlackWebClientLike> implements Slack
298
298
  const channelId = payload.channel?.id ?? '';
299
299
  const userId = payload.user.id;
300
300
  const messageTs = payload.message?.ts ?? '';
301
+ const sourceThread = payload.message?.thread_ts;
302
+ const threadTs = typeof sourceThread === 'string' && sourceThread && sourceThread !== messageTs ? sourceThread : undefined;
301
303
  if (payload.response_url) {
302
304
  postSlackEphemeral(payload.response_url, '已收到', this.#logger);
303
305
  }
@@ -306,6 +308,7 @@ export class SlackEndpoint extends Endpoint<SlackWebClientLike> implements Slack
306
308
  channelId: channelId || userId,
307
309
  // block_actions 无 channel_type;无 channel 时按与发起用户的 DM 处理
308
310
  channelType: channelId ? undefined : 'im',
311
+ threadId: threadTs,
309
312
  });
310
313
  void this.emit('message.receive', {
311
314
  conversation,
@@ -317,7 +320,7 @@ export class SlackEndpoint extends Endpoint<SlackWebClientLike> implements Slack
317
320
  metadata: Object.freeze({
318
321
  eventType: 'block_actions',
319
322
  actionId: payload.actions[0]?.action_id,
320
- threadTs: messageTs || undefined,
323
+ threadTs,
321
324
  }),
322
325
  }).catch((err) => {
323
326
  this.#logger.warn(formatCompact({
package/src/protocol.ts CHANGED
@@ -66,7 +66,7 @@ export interface SlackInteractionPayload {
66
66
  readonly trigger_id?: string;
67
67
  readonly user: { id: string; username?: string; name?: string; team_id?: string };
68
68
  readonly channel?: { id: string; name?: string };
69
- readonly message?: { ts: string; text?: string; [key: string]: unknown };
69
+ readonly message?: { ts: string; text?: string; thread_ts?: string; [key: string]: unknown };
70
70
  readonly actions?: SlackBlockAction[];
71
71
  readonly response_url?: string;
72
72
  readonly [key: string]: unknown;