@zhin.js/adapter-slack 6.0.14 → 7.0.0

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - f2c532f: Expose exact per-Endpoint message operations through one validated Adapter capability model, route Core control calls through declared active capabilities, and connect existing recall, edit, reaction, and typing implementations across platform adapters.
8
+ - Updated dependencies [b10d058]
9
+ - Updated dependencies [f2c532f]
10
+ - Updated dependencies [3dbf990]
11
+ - @zhin.js/host-http@1.0.12
12
+ - @zhin.js/adapter@1.2.0
13
+ - @zhin.js/core@1.5.13
14
+ - @zhin.js/agent@1.1.15
15
+ - zhin.js@6.0.13
16
+
3
17
  ## 6.0.14
4
18
 
5
19
  ### Patch Changes
package/adapters/slack.js CHANGED
@@ -11,6 +11,7 @@ import { slackRuntimeStateToken } from "../lib/slack-runtime-state.js";
11
11
  export { SlackEndpoint } from "../lib/endpoint.js";
12
12
  export default defineAdapter({
13
13
  capabilities: ['inbound', 'outbound'],
14
+ operations: ['recall', 'edit', 'reaction'],
14
15
  // 媒体段(canonical MediaRef):kind=url 直发(image 走 attachment image_url,
15
16
  // 其余拉取后上传);kind=base64 解码后经 files.uploadV2 上传;kind=path 读盘上传;
16
17
  // kind=file 无 Slack 对应物,丢弃留痕。Block Kit 原生按钮承载交互段。
package/adapters/slack.ts CHANGED
@@ -16,6 +16,7 @@ export type { SlackEndpointOptions, SlackSocketLike, SlackWebClientLike } from '
16
16
 
17
17
  export default defineAdapter<SlackAdapterConfig>({
18
18
  capabilities: ['inbound', 'outbound'],
19
+ operations: ['recall', 'edit', 'reaction'],
19
20
  // 媒体段(canonical MediaRef):kind=url 直发(image 走 attachment image_url,
20
21
  // 其余拉取后上传);kind=base64 解码后经 files.uploadV2 上传;kind=path 读盘上传;
21
22
  // kind=file 无 Slack 对应物,丢弃留痕。Block Kit 原生按钮承载交互段。
package/lib/endpoint.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { EndpointInstance, EndpointManagement, EndpointSendRequest } from 'zhin.js/adapter';
1
+ import type { EndpointControl, EndpointInstance, EndpointManagement, EndpointSendRequest } from 'zhin.js/adapter';
2
2
  import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
3
3
  import type { HttpHost } from '@zhin.js/host-http';
4
4
  import type { CapabilityId } from 'zhin.js';
@@ -130,6 +130,7 @@ export interface SlackEndpointOptions {
130
130
  export declare class SlackEndpoint implements EndpointInstance, SlackWebhookHandler {
131
131
  #private;
132
132
  readonly management: EndpointManagement;
133
+ readonly control: EndpointControl;
133
134
  constructor(options: SlackEndpointOptions);
134
135
  /** Console 展示 / AdapterIndex live name(多 endpoint 时与 entry name 一致)。 */
135
136
  get name(): string;
package/lib/endpoint.js CHANGED
@@ -26,6 +26,35 @@ export class SlackEndpoint {
26
26
  #started = false;
27
27
  #unregisterAgent;
28
28
  management = createSlackEndpointManagement(this);
29
+ control = Object.freeze({
30
+ recall: async (message) => {
31
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
32
+ if (!ref || !this.#client)
33
+ return;
34
+ await this.#client.chat.delete(ref);
35
+ },
36
+ edit: async (message, content) => {
37
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
38
+ if (!ref)
39
+ return null;
40
+ await this.editMessage(ref.channel, ref.ts, content);
41
+ return message.id;
42
+ },
43
+ addReaction: async (message, emoji) => {
44
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
45
+ if (!ref)
46
+ return null;
47
+ const reaction = normalizeSlackReactionName(emoji);
48
+ await this.addReaction(ref.channel, ref.ts, reaction);
49
+ return reaction;
50
+ },
51
+ removeReaction: async (message, reactionId) => {
52
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
53
+ if (!ref)
54
+ return;
55
+ await this.removeReaction(ref.channel, ref.ts, reactionId);
56
+ },
57
+ });
29
58
  constructor(options) {
30
59
  this.#logger = getAdapterLogger('slack', options.config.id);
31
60
  this.#options = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-slack",
3
- "version": "6.0.14",
3
+ "version": "7.0.0",
4
4
  "description": "Zhin.js Slack adapter for Plugin Runtime (Socket Mode / HTTP Events)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -34,21 +34,21 @@
34
34
  "dependencies": {
35
35
  "@slack/socket-mode": "^2.0.7",
36
36
  "@slack/web-api": "^7.19.0",
37
- "@zhin.js/adapter": "1.1.11",
38
- "@zhin.js/core": "1.5.12",
39
- "@zhin.js/host-http": "1.0.11",
37
+ "@zhin.js/adapter": "1.2.0",
38
+ "@zhin.js/core": "1.5.13",
39
+ "@zhin.js/host-http": "1.0.12",
40
40
  "@zhin.js/im-contract": "1.0.4",
41
41
  "@zhin.js/logger": "1.0.76"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "zod": "^4.0.0",
45
- "@zhin.js/adapter": "1.1.11",
46
- "@zhin.js/agent": "1.1.14",
45
+ "@zhin.js/adapter": "1.2.0",
46
+ "@zhin.js/agent": "1.1.15",
47
47
  "@zhin.js/command": "1.0.15",
48
- "@zhin.js/core": "1.5.12",
49
- "@zhin.js/host-http": "1.0.11",
48
+ "@zhin.js/core": "1.5.13",
49
+ "@zhin.js/host-http": "1.0.12",
50
50
  "@zhin.js/permission": "1.0.3",
51
- "zhin.js": "6.0.12"
51
+ "zhin.js": "6.0.13"
52
52
  },
53
53
  "peerDependenciesMeta": {
54
54
  "@zhin.js/agent": {
@@ -69,8 +69,8 @@
69
69
  "typescript": "^6.0.3",
70
70
  "vitest": "^4.1.10",
71
71
  "zod": "^4.4.3",
72
- "@zhin.js/agent": "1.1.14",
73
- "zhin.js": "6.0.12"
72
+ "@zhin.js/agent": "1.1.15",
73
+ "zhin.js": "6.0.13"
74
74
  },
75
75
  "files": [
76
76
  "adapters",
package/src/endpoint.ts CHANGED
@@ -6,6 +6,7 @@ import { WebClient } from '@slack/web-api';
6
6
  import type {
7
7
  EndpointFriend,
8
8
  EndpointGroup,
9
+ EndpointControl,
9
10
  EndpointInstance,
10
11
  EndpointManagement,
11
12
  EndpointSendRequest,
@@ -116,6 +117,31 @@ export class SlackEndpoint implements EndpointInstance, SlackWebhookHandler {
116
117
  #started = false;
117
118
  #unregisterAgent?: () => void;
118
119
  readonly management: EndpointManagement = createSlackEndpointManagement(this);
120
+ readonly control: EndpointControl = Object.freeze<EndpointControl>({
121
+ recall: async (message) => {
122
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
123
+ if (!ref || !this.#client) return;
124
+ await this.#client.chat.delete(ref);
125
+ },
126
+ edit: async (message, content) => {
127
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
128
+ if (!ref) return null;
129
+ await this.editMessage(ref.channel, ref.ts, content);
130
+ return message.id;
131
+ },
132
+ addReaction: async (message, emoji) => {
133
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
134
+ if (!ref) return null;
135
+ const reaction = normalizeSlackReactionName(emoji);
136
+ await this.addReaction(ref.channel, ref.ts, reaction);
137
+ return reaction;
138
+ },
139
+ removeReaction: async (message, reactionId) => {
140
+ const ref = this.resolveMessageRef(message.id, message.conversation.id);
141
+ if (!ref) return;
142
+ await this.removeReaction(ref.channel, ref.ts, reactionId);
143
+ },
144
+ });
119
145
 
120
146
  constructor(options: SlackEndpointOptions) {
121
147
  this.#logger = getAdapterLogger('slack', options.config.id);