@zhin.js/adapter-slack 1.1.21 → 1.1.23

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,62 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [3a8504b]
8
+ - Updated dependencies [6163abc]
9
+ - Updated dependencies [fed2c27]
10
+ - Updated dependencies [bc6ccb1]
11
+ - Updated dependencies [72b5a12]
12
+ - Updated dependencies [aa41889]
13
+ - Updated dependencies [4427e72]
14
+ - Updated dependencies [22bd14a]
15
+ - @zhin.js/agent-feature@1.1.14
16
+ - @zhin.js/core@1.1.57
17
+ - @zhin.js/client@1.1.25
18
+ - @zhin.js/page@1.1.15
19
+ - @zhin.js/im-contract@1.1.12
20
+ - @zhin.js/adapter@1.1.29
21
+ - @zhin.js/host-http@1.1.15
22
+ - @zhin.js/feature-kit@1.1.13
23
+ - @zhin.js/tool@1.1.16
24
+ - @zhin.js/skill@1.1.14
25
+
26
+ ## 1.1.22
27
+
28
+ ### Patch Changes
29
+
30
+ - b249e5e: ADR 0044 C4:事件映射迁出 core。新增 `@zhin.js/adapter-onebot-events`,承载 OneBot v11 / NapCat / icqq 的原始通知与请求 → 标准事件映射(`receiveOneBotLikeSideEvent`、`mapNoticeParts`、`mapRequestParts`、`resolveSideEventDedupeKey` 及 OneBot 映射表,icqq 差异用覆盖表表达);KOOK、Slack 的映射迁入各自适配器;`@zhin.js/core` 只保留标准事件名、类型与 `buildNotice` / `buildRequest` / `buildSystem` / `senderFromId`,不再含任何平台名。core 不再导出上述映射函数与 `ONEBOT_/KOOK_/SLACK_NOTICE_PARTS_MAP`、`SideEventPlatform`、`OneBotLike*` 类型,适配器改从共享包导入。
31
+ - 41ff1a5: ADR 0044 C5: every official adapter now declares a capability `profile` (its `segments` moved into `profile.default.messaging.segments`). icqq declares the complete profile (per conversation kind: scene, all 14 actions with real limits, events, feedback, delivery) and implements the seven new management ports (`pokeUser`, `unmuteGroupMember`, `muteAllGroupMembers`, `setGroupCard`, `setGroupTitle`, `setGroupEssence`, `inviteGroupMember`) with fresh bot-role reads. qq official declares its passive reply windows; undeclared capabilities stay unsupported.
32
+ - cbd3f14: ADR 0044 integration and C6 guard. `delivery.spool` now reproduces the pre-0044 media rule (icqq `false`, every other official adapter `true`). icqq narrows `actions.recall.others` unless the Bot is admin or owner, and declares recall for groups. Endpoint kind capabilities merge the Endpoint's `operations` (Discord reactions keep working; Discord declares reaction feedback). Adapters in the `@zhin.js/` scope are trusted: their custom prompt text is not labelled `external_content`. Core no longer keeps a telegram/discord interactive-policy table (adapters declare `segments.interactive`). New `pnpm check:no-platform-branches` blocks platform-name branches in runtime code.
33
+ - 4fe49b5: 支持配置按需生效:分离保存与有效版本,独立变更先应用,账号资料更新保留连接,模型按回合使用确定版本;Console 返回结构化应用结果。监听改为仅显式 --watch 启用,开发模板显式选择源码和配置监听。
34
+
35
+ 自变更消费配置应用回执,避免已处理配置被二次重载;持久化本次写入修订和应用结果,未知结果或修订冲突时停止自动续作并保留现场,恢复不会覆盖未经本次变更确认的配置。
36
+
37
+ - Updated dependencies [b249e5e]
38
+ - Updated dependencies [57661f6]
39
+ - Updated dependencies [cbd3f14]
40
+ - Updated dependencies [299863a]
41
+ - Updated dependencies [aaa93d7]
42
+ - Updated dependencies [bd524d1]
43
+ - Updated dependencies [126ae99]
44
+ - Updated dependencies [4fe49b5]
45
+ - Updated dependencies [cce07db]
46
+ - Updated dependencies [b652db3]
47
+ - Updated dependencies [0315ba0]
48
+ - Updated dependencies [00be764]
49
+ - @zhin.js/core@1.1.56
50
+ - @zhin.js/adapter@1.1.28
51
+ - @zhin.js/im-contract@1.1.11
52
+ - @zhin.js/tool@1.1.15
53
+ - @zhin.js/skill@1.1.13
54
+ - @zhin.js/host-http@1.1.14
55
+ - @zhin.js/feature-kit@1.1.12
56
+ - @zhin.js/client@1.1.24
57
+ - @zhin.js/page@1.1.14
58
+ - @zhin.js/agent-feature@1.1.13
59
+
3
60
  ## 1.1.21
4
61
 
5
62
  ### Patch Changes
@@ -8,14 +8,30 @@ import {} from "../../lib/protocol.js";
8
8
  export { SlackEndpoint } from "../../lib/endpoint.js";
9
9
  export default defineAdapter({
10
10
  capabilities: ['inbound', 'outbound'],
11
- operations: ['recall', 'edit', 'reaction'],
12
11
  // 媒体段(canonical MediaRef):kind=url 直发(image 走 attachment image_url,
13
12
  // 其余拉取后上传);kind=base64 解码后经 files.uploadV2 上传;kind=path 读盘上传;
14
13
  // kind=file 无 Slack 对应物,丢弃留痕。Block Kit 原生按钮承载交互段。
15
- segments: {
16
- outboundMedia: ['url', 'upload', 'path'],
17
- interactive: 'native',
18
- markdown: 'native',
14
+ profile: {
15
+ default: {
16
+ messaging: {
17
+ segments: {
18
+ outboundMedia: ['url', 'upload', 'path'],
19
+ interactive: 'native',
20
+ markdown: 'native',
21
+ },
22
+ recall: {},
23
+ edit: true,
24
+ reaction: {},
25
+ },
26
+ actions: {
27
+ recall: { scopes: ['private', 'group', 'channel'] },
28
+ reaction: {
29
+ scopes: ['private', 'group', 'channel'],
30
+ params: { cancellable: true },
31
+ },
32
+ },
33
+ delivery: { send: true, proactive: true, spool: true },
34
+ },
19
35
  },
20
36
  createAdapter: context => new SlackAdapter(context),
21
37
  });
@@ -12,14 +12,30 @@ export type { SlackEndpointOptions, SlackSocketLike, SlackWebClientLike } from '
12
12
 
13
13
  export default defineAdapter<SlackEndpointConfig>({
14
14
  capabilities: ['inbound', 'outbound'],
15
- operations: ['recall', 'edit', 'reaction'],
16
15
  // 媒体段(canonical MediaRef):kind=url 直发(image 走 attachment image_url,
17
16
  // 其余拉取后上传);kind=base64 解码后经 files.uploadV2 上传;kind=path 读盘上传;
18
17
  // kind=file 无 Slack 对应物,丢弃留痕。Block Kit 原生按钮承载交互段。
19
- segments: {
20
- outboundMedia: ['url', 'upload', 'path'],
21
- interactive: 'native',
22
- markdown: 'native',
18
+ profile: {
19
+ default: {
20
+ messaging: {
21
+ segments: {
22
+ outboundMedia: ['url', 'upload', 'path'],
23
+ interactive: 'native',
24
+ markdown: 'native',
25
+ },
26
+ recall: {},
27
+ edit: true,
28
+ reaction: {},
29
+ },
30
+ actions: {
31
+ recall: { scopes: ['private', 'group', 'channel'] },
32
+ reaction: {
33
+ scopes: ['private', 'group', 'channel'],
34
+ params: { cancellable: true },
35
+ },
36
+ },
37
+ delivery: { send: true, proactive: true, spool: true },
38
+ },
23
39
  },
24
40
  createAdapter: context => new SlackAdapter(context),
25
41
  });
@@ -1,14 +1,15 @@
1
- import { composeSideEventName, buildNotice, mapNoticeParts, senderFromId, SLACK_NOTICE_PARTS_MAP } from '@zhin.js/core';
1
+ import { composeSideEventName, buildNotice, senderFromId } from '@zhin.js/core';
2
2
  import { formatCompact } from '@zhin.js/logger';
3
3
  import { slackInboundConversation } from './protocol.js';
4
+ import { mapSlackNoticeParts } from './side-event-map.js';
4
5
  export function receiveSlackSideEvent(emit, endpointKey, configId, event, logger) {
5
6
  if (!emit)
6
7
  return;
7
8
  const eventType = String(event.type ?? '');
8
- if (!Object.prototype.hasOwnProperty.call(SLACK_NOTICE_PARTS_MAP, eventType))
9
+ const parts = mapSlackNoticeParts(eventType);
10
+ if (!parts)
9
11
  return;
10
12
  const record = event;
11
- const parts = mapNoticeParts('slack', eventType);
12
13
  const item = asRecord(record.item);
13
14
  const channel = stringField(record.channel) ?? stringField(asRecord(record.channel).id) ?? stringField(item.channel);
14
15
  const user = stringField(record.user) ?? stringField(asRecord(record.user).id);
@@ -0,0 +1,5 @@
1
+ import type { SideEventParts } from '@zhin.js/core';
2
+ /** Slack event type 原始值 → 标准 scene_type + sub_type */
3
+ export declare const SLACK_NOTICE_PARTS_MAP: Readonly<Record<string, SideEventParts>>;
4
+ /** 已登记的 Slack 事件映射为标准 scene_type + sub_type;未登记返回 undefined。 */
5
+ export declare function mapSlackNoticeParts(raw: string): SideEventParts | undefined;
@@ -0,0 +1,21 @@
1
+ /** Slack event type 原始值 → 标准 scene_type + sub_type */
2
+ export const SLACK_NOTICE_PARTS_MAP = {
3
+ member_joined_channel: { scene_type: 'group', sub_type: 'member_increase' },
4
+ member_left_channel: { scene_type: 'group', sub_type: 'member_decrease' },
5
+ reaction_added: { scene_type: 'group', sub_type: 'emoji_reaction' },
6
+ reaction_removed: { scene_type: 'group', sub_type: 'emoji_reaction' },
7
+ message_deleted: { scene_type: 'group', sub_type: 'recall' },
8
+ channel_archive: { scene_type: 'slack', sub_type: 'channel_archive' },
9
+ channel_unarchive: { scene_type: 'slack', sub_type: 'channel_unarchive' },
10
+ channel_rename: { scene_type: 'slack', sub_type: 'channel_rename' },
11
+ channel_created: { scene_type: 'slack', sub_type: 'channel_created' },
12
+ channel_deleted: { scene_type: 'slack', sub_type: 'channel_deleted' },
13
+ pin_added: { scene_type: 'slack', sub_type: 'pin_added' },
14
+ pin_removed: { scene_type: 'slack', sub_type: 'pin_removed' },
15
+ app_home_opened: { scene_type: 'slack', sub_type: 'app_home_opened' },
16
+ team_join: { scene_type: 'friend', sub_type: 'increase' },
17
+ };
18
+ /** 已登记的 Slack 事件映射为标准 scene_type + sub_type;未登记返回 undefined。 */
19
+ export function mapSlackNoticeParts(raw) {
20
+ return Object.prototype.hasOwnProperty.call(SLACK_NOTICE_PARTS_MAP, raw) ? SLACK_NOTICE_PARTS_MAP[raw] : undefined;
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-slack",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
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,27 +33,27 @@
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.27",
37
- "@zhin.js/agent-feature": "1.1.12",
38
- "@zhin.js/client": "1.1.23",
36
+ "@zhin.js/adapter": "1.1.29",
37
+ "@zhin.js/agent-feature": "1.1.14",
38
+ "@zhin.js/client": "1.1.25",
39
39
  "@zhin.js/console-contract": "1.1.3",
40
- "@zhin.js/core": "1.1.55",
41
- "@zhin.js/feature-kit": "1.1.11",
42
- "@zhin.js/host-http": "1.1.13",
43
- "@zhin.js/im-contract": "1.1.10",
40
+ "@zhin.js/core": "1.1.57",
41
+ "@zhin.js/feature-kit": "1.1.13",
42
+ "@zhin.js/host-http": "1.1.15",
43
+ "@zhin.js/im-contract": "1.1.12",
44
44
  "@zhin.js/logger": "1.1.2",
45
- "@zhin.js/page": "1.1.13",
46
- "@zhin.js/skill": "1.1.12",
47
- "@zhin.js/tool": "1.1.14"
45
+ "@zhin.js/page": "1.1.15",
46
+ "@zhin.js/skill": "1.1.14",
47
+ "@zhin.js/tool": "1.1.16"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "zod": "^4.0.0",
51
- "@zhin.js/adapter": "^1.1.27",
52
- "@zhin.js/command": "^1.1.13",
53
- "@zhin.js/core": "^1.1.55",
54
- "@zhin.js/host-http": "^1.1.13",
55
- "@zhin.js/permission": "^1.1.11",
56
- "zhin.js": "^1.1.20"
51
+ "@zhin.js/adapter": "^1.1.29",
52
+ "@zhin.js/command": "^1.1.15",
53
+ "@zhin.js/core": "^1.1.57",
54
+ "@zhin.js/host-http": "^1.1.15",
55
+ "@zhin.js/permission": "^1.1.13",
56
+ "zhin.js": "^1.1.22"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@zhin.js/command": {
@@ -71,7 +71,7 @@
71
71
  "typescript": "^6.0.3",
72
72
  "vitest": "^4.1.10",
73
73
  "zod": "^4.4.3",
74
- "zhin.js": "1.1.20"
74
+ "zhin.js": "1.1.22"
75
75
  },
76
76
  "files": [
77
77
  "adapters",
package/plugin.js CHANGED
@@ -5,6 +5,7 @@ import { checkSlackPlatformPermit } from "./lib/platform-permit.js";
5
5
  import { createSlackConsoleRpc } from "./lib/console.js";
6
6
  export default definePlugin({
7
7
  name: 'slack',
8
+ configUpdate: { featurePaths: [['nickname'], ['profile'], ['endpoints']] },
8
9
  metadata: {
9
10
  displayName: 'Slack Adapter',
10
11
  },
@@ -1,7 +1,8 @@
1
- import { composeSideEventName, buildNotice, mapNoticeParts, senderFromId, SLACK_NOTICE_PARTS_MAP } from '@zhin.js/core';
1
+ import { composeSideEventName, buildNotice, senderFromId } from '@zhin.js/core';
2
2
  import type { EndpointEventEmitter } from 'zhin.js/adapter';
3
3
  import { formatCompact, type getAdapterLogger } from '@zhin.js/logger';
4
4
  import { slackInboundConversation, type SlackEvent } from './protocol.js';
5
+ import { mapSlackNoticeParts } from './side-event-map.js';
5
6
 
6
7
  export function receiveSlackSideEvent(
7
8
  emit: EndpointEventEmitter,
@@ -12,9 +13,9 @@ export function receiveSlackSideEvent(
12
13
  ): void {
13
14
  if (!emit) return;
14
15
  const eventType = String(event.type ?? '');
15
- if (!Object.prototype.hasOwnProperty.call(SLACK_NOTICE_PARTS_MAP, eventType)) return;
16
+ const parts = mapSlackNoticeParts(eventType);
17
+ if (!parts) return;
16
18
  const record = event as Record<string, unknown>;
17
- const parts = mapNoticeParts('slack', eventType);
18
19
  const item = asRecord(record.item);
19
20
  const channel = stringField(record.channel) ?? stringField(asRecord(record.channel).id) ?? stringField(item.channel);
20
21
  const user = stringField(record.user) ?? stringField(asRecord(record.user).id);
@@ -0,0 +1,24 @@
1
+ import type { SideEventParts } from '@zhin.js/core';
2
+
3
+ /** Slack event type 原始值 → 标准 scene_type + sub_type */
4
+ export const SLACK_NOTICE_PARTS_MAP: Readonly<Record<string, SideEventParts>> = {
5
+ member_joined_channel: { scene_type: 'group', sub_type: 'member_increase' },
6
+ member_left_channel: { scene_type: 'group', sub_type: 'member_decrease' },
7
+ reaction_added: { scene_type: 'group', sub_type: 'emoji_reaction' },
8
+ reaction_removed: { scene_type: 'group', sub_type: 'emoji_reaction' },
9
+ message_deleted: { scene_type: 'group', sub_type: 'recall' },
10
+ channel_archive: { scene_type: 'slack', sub_type: 'channel_archive' },
11
+ channel_unarchive: { scene_type: 'slack', sub_type: 'channel_unarchive' },
12
+ channel_rename: { scene_type: 'slack', sub_type: 'channel_rename' },
13
+ channel_created: { scene_type: 'slack', sub_type: 'channel_created' },
14
+ channel_deleted: { scene_type: 'slack', sub_type: 'channel_deleted' },
15
+ pin_added: { scene_type: 'slack', sub_type: 'pin_added' },
16
+ pin_removed: { scene_type: 'slack', sub_type: 'pin_removed' },
17
+ app_home_opened: { scene_type: 'slack', sub_type: 'app_home_opened' },
18
+ team_join: { scene_type: 'friend', sub_type: 'increase' },
19
+ };
20
+
21
+ /** 已登记的 Slack 事件映射为标准 scene_type + sub_type;未登记返回 undefined。 */
22
+ export function mapSlackNoticeParts(raw: string): SideEventParts | undefined {
23
+ return Object.prototype.hasOwnProperty.call(SLACK_NOTICE_PARTS_MAP, raw) ? SLACK_NOTICE_PARTS_MAP[raw] : undefined;
24
+ }