@zhin.js/adapter-slack 1.1.0 → 1.1.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +13 -14
  3. package/adapters/{slack.js → slack/index.js} +6 -6
  4. package/adapters/{slack.ts → slack/index.ts} +9 -9
  5. package/agents/slack/agent.json +20 -0
  6. package/agents/slack/boundaries.md +3 -0
  7. package/agents/slack/conventions.md +3 -0
  8. package/agents/slack/skills/slack-channels/SKILL.md +24 -0
  9. package/agents/slack/skills/slack-channels/tools/archive_channel/index.js +19 -0
  10. package/{agent/tools/archive_channel.ts → agents/slack/skills/slack-channels/tools/archive_channel/index.ts} +3 -3
  11. package/agents/slack/skills/slack-channels/tools/invite_to_channel/index.js +20 -0
  12. package/{agent/tools/invite_to_channel.ts → agents/slack/skills/slack-channels/tools/invite_to_channel/index.ts} +3 -3
  13. package/agents/slack/skills/slack-channels/tools/set_purpose/index.js +20 -0
  14. package/{agent/tools/set_purpose.ts → agents/slack/skills/slack-channels/tools/set_purpose/index.ts} +3 -3
  15. package/agents/slack/skills/slack-channels/tools/set_topic/index.js +20 -0
  16. package/{agent/tools/set_topic.ts → agents/slack/skills/slack-channels/tools/set_topic/index.ts} +3 -3
  17. package/agents/slack/skills/slack-channels/tools/unarchive/index.js +19 -0
  18. package/{agent/tools/unarchive.ts → agents/slack/skills/slack-channels/tools/unarchive/index.ts} +3 -3
  19. package/agents/slack/skills/slack-channels/tools/user_info/index.js +27 -0
  20. package/{agent/tools/user_info.ts → agents/slack/skills/slack-channels/tools/user_info/index.ts} +2 -2
  21. package/agents/slack/skills/slack-messages/SKILL.md +22 -0
  22. package/agents/slack/skills/slack-messages/tools/add_reaction/index.js +27 -0
  23. package/{agent/tools/add_reaction.ts → agents/slack/skills/slack-messages/tools/add_reaction/index.ts} +2 -2
  24. package/agents/slack/skills/slack-messages/tools/edit_message/index.js +21 -0
  25. package/{agent/tools/edit_message.ts → agents/slack/skills/slack-messages/tools/edit_message/index.ts} +2 -2
  26. package/agents/slack/skills/slack-messages/tools/pin_message/index.js +20 -0
  27. package/{agent/tools/pin_message.ts → agents/slack/skills/slack-messages/tools/pin_message/index.ts} +3 -3
  28. package/agents/slack/skills/slack-messages/tools/remove_reaction/index.js +30 -0
  29. package/{agent/tools/remove_reaction.ts → agents/slack/skills/slack-messages/tools/remove_reaction/index.ts} +2 -2
  30. package/agents/slack/skills/slack-messages/tools/unpin_message/index.js +20 -0
  31. package/{agent/tools/unpin_message.ts → agents/slack/skills/slack-messages/tools/unpin_message/index.ts} +3 -3
  32. package/agents/slack/system.md +3 -0
  33. package/commands/{endpoint/add/[id].js → slack/endpoint/add/[id]/index.js} +1 -1
  34. package/commands/slack/endpoint/add/[id]/index.ts +3 -0
  35. package/{lib/slack-endpoint-commands.js → commands/slack/endpoint/definition.js} +4 -3
  36. package/{src/slack-endpoint-commands.ts → commands/slack/endpoint/definition.ts} +3 -3
  37. package/commands/{endpoint/list.js → slack/endpoint/list/index.js} +1 -1
  38. package/commands/slack/endpoint/list/index.ts +3 -0
  39. package/commands/{endpoint/remove/[id].js → slack/endpoint/remove/[id]/index.js} +1 -1
  40. package/commands/slack/endpoint/remove/[id]/index.ts +3 -0
  41. package/lib/index.d.ts +1 -1
  42. package/lib/protocol.d.ts +6 -15
  43. package/lib/protocol.js +19 -33
  44. package/lib/slack-runtime-state.js +1 -1
  45. package/package.json +33 -21
  46. package/schema.json +14 -1
  47. package/src/index.ts +1 -1
  48. package/src/protocol.ts +27 -56
  49. package/src/slack-runtime-state.ts +1 -1
  50. package/agent/skills/slack.md +0 -93
  51. package/commands/endpoint/add/[id].ts +0 -3
  52. package/commands/endpoint/list.ts +0 -3
  53. package/commands/endpoint/remove/[id].ts +0 -3
  54. package/lib/slack-endpoint-commands.d.ts +0 -1
  55. /package/{agent/PERMITS.md → PERMITS.md} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,98 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a9e4a40: Derive Command user routes only from explicit `commands/**/*/index.ts(x)` entry paths instead of prepending the plugin owner. Child plugins can now publish top-level static or dynamic commands, while duplicate routes across owners fail during generation construction. Adapter endpoint commands move to explicit paths such as `commands/qq/endpoint/list/index.ts` and are invoked as `qq endpoint list`.
8
+ - 8740059: Standardize TypeScript capabilities on named module directories such as `commands/foo/index.ts`, `middlewares/audit/index.ts`, `handlers/message-receive/index.ts`, `pages/workroom/index.tsx`, and `mcps/filesystem/index.ts`. Only the fixed `index` entry is discovered; sibling files remain private helpers.
9
+
10
+ Command route segments come from directories, while `[name]`, `[[name]]`, `[...name]`, and `[[...name]]` directories declare dynamic parameters. Plugin owners do not enter the route unless their config explicitly sets `commandNamespace`; Endpoint `commandPrefix` remains platform-owned and defaults to an empty string.
11
+
12
+ Migrate the built-in adapters, plugins, examples, generators, migration tooling, hot reload classification, Agent authoring surfaces, documentation, and release artifacts to the explicit entry convention.
13
+
14
+ Make Tool ownership and progressive disclosure explicit across all four supported locations: plugin-public `tools/`, Agent-private `agents/<name>/tools/`, Skill-private `skills/<name>/tools/`, and Agent-Skill-private `agents/<name>/skills/<name>/tools/`. Move adapter and group-suite operations that require domain instructions into their owning Skills so `load_skill` is the only path that unlocks their schemas.
15
+
16
+ Remove the package-root `agent/` convention. Public capabilities now use named package-root directories, schedules use `schedules/<name>/index.ts` or `plugin.ts` injection, MCP connections use `mcps/<name>/index.ts`, Prompt Sections use `prompt-sections/<name>/index.ts`, Agent definitions use `agents/<name>/`, and permission vocabulary is published as `PERMITS.md`.
17
+
18
+ - 25a845a: Unify Skills on `skills/<name>/SKILL.md`, support Agent-private Skills and nested Skill-private Tools, publish and mount existing plugin Skills, add governed Skill metadata and Turn access filtering, unlock only already-admitted same-owner Tools, and make `on-risk` and `once` approval behavior precise.
19
+ - ddbb92e: Isolate adapter Skills under platform-specific Agents and automatically select the matching platform Agent for IM ingress, preventing unrelated adapter Skills from entering another platform's prompt surface.
20
+ - 40d2c8f: Reduce the default Agent Tool surface by moving process diagnostics into a Skill and splitting broad platform Skills into focused task domains. Restore ICQQ friend and group directory tools with `on-risk` approval and explicit owner, administrator, master, or trusted access.
21
+ - 4380cf9: Colocate adapter command definitions and Agent Skill handlers with their owning capabilities, and provide a shared validated platform permission constructor.
22
+ - 9f7cd76: Require the canonical expanded Slack endpoint configuration. The protocol no longer reinterprets nested `endpoints` or reads endpoint identity and credentials from `process.env`. The public config type is now `SlackEndpointConfig`, with mode-specific credential validation.
23
+ - 5c3858e: Make `@zhin.js/im-contract` the explicit zero-dependency owner of transport identities, canonical segments, media guards, conversation facts, stores, and delivery contracts. Platform adapters now read media contracts from that foundation instead of reaching through Core.
24
+ - 33ea736: Use `tools/<name>/index.ts` and `defineAgentTool` from `@zhin.js/tool` as the sole Agent Tool authoring model. Remove the duplicate `@zhin.js/tools` definition, context, bridge, export, and discovery path; migrate plugin manifests, examples, scaffolding, HMR, and prepack compilation to the generation-owned Tool Feature.
25
+ - Updated dependencies [c861789]
26
+ - Updated dependencies [1414ccb]
27
+ - Updated dependencies [743d470]
28
+ - Updated dependencies [62dee52]
29
+ - Updated dependencies [cd54131]
30
+ - Updated dependencies [244e475]
31
+ - Updated dependencies [a9e4a40]
32
+ - Updated dependencies [5855db7]
33
+ - Updated dependencies [ec921d2]
34
+ - Updated dependencies [8740059]
35
+ - Updated dependencies [63d1f7a]
36
+ - Updated dependencies [25a845a]
37
+ - Updated dependencies [103f2c3]
38
+ - Updated dependencies [9110ab8]
39
+ - Updated dependencies [cd2a888]
40
+ - Updated dependencies [eb3227a]
41
+ - Updated dependencies [b853dba]
42
+ - Updated dependencies [e561309]
43
+ - Updated dependencies [d4c6175]
44
+ - Updated dependencies [7a0e1ca]
45
+ - Updated dependencies [103b5d3]
46
+ - Updated dependencies [5a7a7f7]
47
+ - Updated dependencies [b076eae]
48
+ - Updated dependencies [535fed1]
49
+ - Updated dependencies [73a24b7]
50
+ - Updated dependencies [2dbbc15]
51
+ - Updated dependencies [1cb1163]
52
+ - Updated dependencies [be3061e]
53
+ - Updated dependencies [75f8332]
54
+ - Updated dependencies [81935e2]
55
+ - Updated dependencies [f9ed01b]
56
+ - Updated dependencies [ac0ab50]
57
+ - Updated dependencies [5140ce1]
58
+ - Updated dependencies [522d75f]
59
+ - Updated dependencies [a7611b3]
60
+ - Updated dependencies [8823044]
61
+ - Updated dependencies [379439b]
62
+ - Updated dependencies [11c9352]
63
+ - Updated dependencies [6b70e46]
64
+ - Updated dependencies [135ac91]
65
+ - Updated dependencies [140cf0f]
66
+ - Updated dependencies [251e4d2]
67
+ - Updated dependencies [203ad34]
68
+ - Updated dependencies [e6c5113]
69
+ - Updated dependencies [e0f6478]
70
+ - Updated dependencies [baef56b]
71
+ - Updated dependencies [698f16f]
72
+ - Updated dependencies [da0a8e3]
73
+ - Updated dependencies [2fd8017]
74
+ - Updated dependencies [5c3858e]
75
+ - Updated dependencies [33ea736]
76
+ - Updated dependencies [507d602]
77
+ - Updated dependencies [df9f76b]
78
+ - @zhin.js/core@1.1.37
79
+ - @zhin.js/tool@1.1.1
80
+ - @zhin.js/host-http@1.1.1
81
+ - @zhin.js/adapter@1.1.14
82
+ - @zhin.js/feature-kit@1.1.1
83
+ - @zhin.js/agent-feature@1.1.1
84
+ - @zhin.js/skill@1.1.1
85
+ - @zhin.js/logger@1.1.1
86
+ - @zhin.js/im-contract@1.1.1
87
+
88
+ ## 1.1.1
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies [769e67f]
93
+ - @zhin.js/adapter@1.1.13
94
+ - @zhin.js/core@1.1.36
95
+
3
96
  ## 1.1.0
4
97
 
5
98
  ### Minor Changes
package/README.md CHANGED
@@ -8,7 +8,7 @@ Zhin.js Slack 适配器(Plugin Runtime),优先 Socket Mode,也可经 Run
8
8
  - **HTTP Events API**:`httpHostToken` POST(签名验证),**非** legacy host-router/Koa
9
9
  - 入站经 `Endpoint.emit(...)`;出站 `send({ conversation, payload })` → `chat.postMessage` / Block Kit
10
10
  - 约定式 `defineAdapter` / `definePlugin`(无需 `usePlugin`)
11
- - Block Kit 按钮、斜杠命令、消息编辑、表情反应等(见 `agent/tools/`)
11
+ - Block Kit 按钮、斜杠命令、消息编辑、表情反应等(见 `tools/`)
12
12
 
13
13
  ## 安装
14
14
 
@@ -18,7 +18,7 @@ pnpm add @zhin.js/adapter-slack
18
18
 
19
19
  ## Plugin Runtime
20
20
 
21
- - `@zhin.js/adapter` — 约定式 `adapters/slack.ts`(`defineAdapter`)
21
+ - `@zhin.js/adapter` — 约定式 `adapters/slack/index.ts`(`defineAdapter`)
22
22
  - `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
23
23
  - `@zhin.js/host-http` — 仅 HTTP 模式需要 `httpHostToken` 注册 Events 路由
24
24
  - `zhin.js` — `plugin.ts`(`definePlugin`)
@@ -52,21 +52,21 @@ plugins:
52
52
  slack:
53
53
  socketMode: true # 默认 true,可省略
54
54
  endpoints:
55
- - name: my-slack-bot
55
+ - id: my-slack-bot
56
56
  token: ${SLACK_BOT_TOKEN}
57
57
  appToken: ${SLACK_APP_TOKEN}
58
58
  ```
59
59
 
60
- 多 workspace:一个插件实例挂多个 endpoint(`endpoints` 数组逐项覆盖顶层字段,`name` 必填):
60
+ 多 workspace:一个插件实例挂多个 endpoint(`endpoints` 数组逐项覆盖顶层字段,`id` 必填):
61
61
 
62
62
  ```yaml
63
63
  plugins:
64
64
  slack:
65
65
  endpoints:
66
- - name: team-a
66
+ - id: team-a
67
67
  token: ${SLACK_BOT_TOKEN_A}
68
68
  appToken: ${SLACK_APP_TOKEN_A}
69
- - name: team-b
69
+ - id: team-b
70
70
  token: ${SLACK_BOT_TOKEN_B}
71
71
  appToken: ${SLACK_APP_TOKEN_B}
72
72
  ```
@@ -79,7 +79,7 @@ plugins:
79
79
  socketMode: false
80
80
  webhookPath: /slack/events # 可选,默认 /slack/events
81
81
  endpoints:
82
- - name: my-slack-bot
82
+ - id: my-slack-bot
83
83
  token: ${SLACK_BOT_TOKEN}
84
84
  signingSecret: ${SLACK_SIGNING_SECRET}
85
85
  ```
@@ -91,10 +91,9 @@ HTTP 模式下 Runtime Host(`http`)须已 listen;Slack App 的 Event Subsc
91
91
 
92
92
  | 变量 | 说明 |
93
93
  |------|------|
94
- | `SLACK_BOT_TOKEN` / `SLACK_TOKEN` | Bot User OAuth Token(`xoxb-...`) |
95
- | `SLACK_APP_TOKEN` | App-Level Token(Socket Mode,`xapp-...`) |
96
- | `SLACK_SIGNING_SECRET` | Signing Secret(HTTP 模式) |
97
- | `SLACK_BOT_NAME` | 可选 endpoint 名称 |
94
+ | `SLACK_BOT_TOKEN` | 示例中由 YAML `${SLACK_BOT_TOKEN}` 引用的 Bot User OAuth Token;变量名可自行定义 |
95
+ | `SLACK_APP_TOKEN` | 示例中由 YAML `${SLACK_APP_TOKEN}` 引用的 App-Level Token;变量名可自行定义 |
96
+ | `SLACK_SIGNING_SECRET` | 示例中由 YAML `${SLACK_SIGNING_SECRET}` 引用的 Signing Secret;变量名可自行定义 |
98
97
 
99
98
  ## 消息格式
100
99
 
@@ -115,9 +114,9 @@ HTTP 模式下 Runtime Host(`http`)须已 listen;Slack App 的 Event Subsc
115
114
 
116
115
  | 类别 | 路径 |
117
116
  |------|------|
118
- | Permit 词汇 | `agent/PERMITS.md` |
119
- | 平台工具 | `agent/tools/`(邀请、话题、反应、置顶、编辑等) |
120
- | 技能说明 | `agent/skills/slack.md` |
117
+ | Permit 词汇 | `PERMITS.md` |
118
+ | 平台工具 | `tools/`(邀请、话题、反应、置顶、编辑等) |
119
+ | 技能说明 | `agents/slack/skills/slack-channels/SKILL.md`、`agents/slack/skills/slack-messages/SKILL.md` |
121
120
 
122
121
  ## 限制
123
122
 
@@ -1,13 +1,13 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  /**
3
- * Convention entry: discover `adapters/slack.ts` → defineAdapter.
3
+ * Convention entry: discover `adapters/slack/index.ts` → defineAdapter.
4
4
  */
5
5
  import { defineAdapter } from 'zhin.js/adapter';
6
6
  import { httpHostToken } from '@zhin.js/host-http';
7
- import { SlackEndpoint } from "../lib/endpoint.js";
8
- import { resolveSlackConfig, } from "../lib/protocol.js";
9
- import { slackRuntimeStateToken } from "../lib/slack-runtime-state.js";
10
- export { SlackEndpoint } from "../lib/endpoint.js";
7
+ import { SlackEndpoint } from "../../lib/endpoint.js";
8
+ import { resolveSlackConfig, } from "../../lib/protocol.js";
9
+ import { slackRuntimeStateToken } from "../../lib/slack-runtime-state.js";
10
+ export { SlackEndpoint } from "../../lib/endpoint.js";
11
11
  export default defineAdapter({
12
12
  capabilities: ['inbound', 'outbound'],
13
13
  operations: ['recall', 'edit', 'reaction'],
@@ -20,7 +20,7 @@ export default defineAdapter({
20
20
  },
21
21
  create(context) {
22
22
  const config = resolveSlackConfig(context.config);
23
- // 注册到插件运行时状态(slack.endpoint list 的"运行中"数据源)
23
+ // 注册到插件运行时状态(slack endpoint list 的"运行中"数据源)
24
24
  context.use(slackRuntimeStateToken).endpoints.set(config.id, {
25
25
  id: config.id,
26
26
  mode: config.mode,
@@ -1,19 +1,19 @@
1
1
  /**
2
- * Convention entry: discover `adapters/slack.ts` → defineAdapter.
2
+ * Convention entry: discover `adapters/slack/index.ts` → defineAdapter.
3
3
  */
4
4
  import { defineAdapter } from 'zhin.js/adapter';
5
5
  import { httpHostToken } from '@zhin.js/host-http';
6
- import { SlackEndpoint } from '../src/endpoint.js';
6
+ import { SlackEndpoint } from '../../src/endpoint.js';
7
7
  import {
8
8
  resolveSlackConfig,
9
- type SlackAdapterConfig,
10
- } from '../src/protocol.js';
11
- import { slackRuntimeStateToken } from '../src/slack-runtime-state.js';
9
+ type SlackEndpointConfig,
10
+ } from '../../src/protocol.js';
11
+ import { slackRuntimeStateToken } from '../../src/slack-runtime-state.js';
12
12
 
13
- export { SlackEndpoint } from '../src/endpoint.js';
14
- export type { SlackEndpointOptions, SlackSocketLike, SlackWebClientLike } from '../src/endpoint.js';
13
+ export { SlackEndpoint } from '../../src/endpoint.js';
14
+ export type { SlackEndpointOptions, SlackSocketLike, SlackWebClientLike } from '../../src/endpoint.js';
15
15
 
16
- export default defineAdapter<SlackAdapterConfig>({
16
+ export default defineAdapter<SlackEndpointConfig>({
17
17
  capabilities: ['inbound', 'outbound'],
18
18
  operations: ['recall', 'edit', 'reaction'],
19
19
  // 媒体段(canonical MediaRef):kind=url 直发(image 走 attachment image_url,
@@ -25,7 +25,7 @@ export default defineAdapter<SlackAdapterConfig>({
25
25
  },
26
26
  create(context) {
27
27
  const config = resolveSlackConfig(context.config);
28
- // 注册到插件运行时状态(slack.endpoint list 的"运行中"数据源)
28
+ // 注册到插件运行时状态(slack endpoint list 的"运行中"数据源)
29
29
  context.use(slackRuntimeStateToken).endpoints.set(config.id, {
30
30
  id: config.id,
31
31
  mode: config.mode,
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "SLACK Platform Agent",
3
+ "version": "1.0.0",
4
+ "description": "Handles slack platform-specific operations and progressively loads only the required platform Skill.",
5
+ "trigger_rules": {
6
+ "file_patterns": [],
7
+ "keywords": [
8
+ "slack",
9
+ "adapter:slack"
10
+ ]
11
+ },
12
+ "entry_points": [
13
+ "system.md",
14
+ "boundaries.md",
15
+ "conventions.md"
16
+ ],
17
+ "platforms": [
18
+ "slack"
19
+ ]
20
+ }
@@ -0,0 +1,3 @@
1
+ # Boundaries
2
+
3
+ Operate only on the active slack endpoint and authenticated conversation context. Respect every Tool permission and approval policy. Do not infer identifiers, roles, or authorization from display names.
@@ -0,0 +1,3 @@
1
+ # Conventions
2
+
3
+ Use stable platform identifiers from the current turn or directory queries. Load one task-specific Skill at a time, and use the unified reply and outbound message path.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: slack-channels
3
+ platforms:
4
+ - slack
5
+ description: Slack 用户查询、频道邀请、主题、用途和归档管理能力。
6
+ keywords:
7
+ - "slack"
8
+ - "channel"
9
+ - "invite"
10
+ - "topic"
11
+ - "archive"
12
+ - "user"
13
+ tools:
14
+ - "invite_to_channel"
15
+ - "set_topic"
16
+ - "set_purpose"
17
+ - "archive_channel"
18
+ - "unarchive"
19
+ - "user_info"
20
+ ---
21
+
22
+ # slack-channels
23
+
24
+ 先查询用户 ID,再邀请或修改频道。归档和恢复属于频道状态变更,遵守 Tool 审批。
@@ -0,0 +1,19 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { platformPermission } from '@zhin.js/permission';
5
+ export default defineAgentTool({
6
+ description: '归档 Slack 频道',
7
+ inputSchema: z.object({
8
+ channel: z.string().describe('频道 ID'),
9
+ }),
10
+ adapter: 'slack',
11
+ tags: ['slack'],
12
+ permissions: [platformPermission('slack', 'workspace_admin')],
13
+ async execute({ channel }, context) {
14
+ const client = context.$client;
15
+ await client.conversations.archive({ channel });
16
+ const success = true;
17
+ return { success, message: success ? '已归档频道' : '操作失败' };
18
+ },
19
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  channel: string;
@@ -11,7 +11,7 @@ export default defineAgentTool<{
11
11
  }),
12
12
  adapter: 'slack',
13
13
  tags: ['slack'],
14
- permissions: [platformPermit('workspace_admin')],
14
+ permissions: [platformPermission('slack', 'workspace_admin')],
15
15
  async execute({ channel }, context) {
16
16
  const client = context.$client;
17
17
  await client.conversations.archive({ channel });
@@ -0,0 +1,20 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { platformPermission } from '@zhin.js/permission';
5
+ export default defineAgentTool({
6
+ description: '邀请用户加入 Slack 频道',
7
+ inputSchema: z.object({
8
+ channel: z.string().describe('频道 ID'),
9
+ users: z.string().describe('用户 ID 列表(逗号分隔)'),
10
+ }),
11
+ adapter: 'slack',
12
+ tags: ['slack'],
13
+ permissions: [platformPermission('slack', 'channel_manager')],
14
+ async execute({ channel, users }, context) {
15
+ const client = context.$client;
16
+ await client.conversations.invite({ channel, users });
17
+ const success = true;
18
+ return { success, message: success ? '已邀请用户加入频道' : '操作失败' };
19
+ },
20
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  channel: string;
@@ -13,7 +13,7 @@ export default defineAgentTool<{
13
13
  }),
14
14
  adapter: 'slack',
15
15
  tags: ['slack'],
16
- permissions: [platformPermit('channel_manager')],
16
+ permissions: [platformPermission('slack', 'channel_manager')],
17
17
  async execute({ channel, users }, context) {
18
18
  const client = context.$client;
19
19
  await client.conversations.invite({ channel, users });
@@ -0,0 +1,20 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { platformPermission } from '@zhin.js/permission';
5
+ export default defineAgentTool({
6
+ description: '设置 Slack 频道的用途/目的',
7
+ inputSchema: z.object({
8
+ channel_id: z.string().describe('频道 ID'),
9
+ purpose: z.string().describe('频道用途描述'),
10
+ }),
11
+ adapter: 'slack',
12
+ tags: ['slack'],
13
+ permissions: [platformPermission('slack', 'channel_manager')],
14
+ async execute({ channel_id, purpose }, context) {
15
+ const client = context.$client;
16
+ await client.conversations.setPurpose({ channel: channel_id, purpose });
17
+ const success = true;
18
+ return { success, message: success ? '频道用途已更新' : '操作失败' };
19
+ },
20
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  channel_id: string;
@@ -13,7 +13,7 @@ export default defineAgentTool<{
13
13
  }),
14
14
  adapter: 'slack',
15
15
  tags: ['slack'],
16
- permissions: [platformPermit('channel_manager')],
16
+ permissions: [platformPermission('slack', 'channel_manager')],
17
17
  async execute({ channel_id, purpose }, context) {
18
18
  const client = context.$client;
19
19
  await client.conversations.setPurpose({ channel: channel_id, purpose });
@@ -0,0 +1,20 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { platformPermission } from '@zhin.js/permission';
5
+ export default defineAgentTool({
6
+ description: '设置 Slack 频道话题',
7
+ inputSchema: z.object({
8
+ channel: z.string().describe('频道 ID'),
9
+ topic: z.string().describe('新话题'),
10
+ }),
11
+ adapter: 'slack',
12
+ tags: ['slack'],
13
+ permissions: [platformPermission('slack', 'channel_manager')],
14
+ async execute({ channel, topic }, context) {
15
+ const client = context.$client;
16
+ await client.conversations.setTopic({ channel, topic });
17
+ const success = true;
18
+ return { success, message: success ? '已设置频道话题' : '操作失败' };
19
+ },
20
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  channel: string;
@@ -13,7 +13,7 @@ export default defineAgentTool<{
13
13
  }),
14
14
  adapter: 'slack',
15
15
  tags: ['slack'],
16
- permissions: [platformPermit('channel_manager')],
16
+ permissions: [platformPermission('slack', 'channel_manager')],
17
17
  async execute({ channel, topic }, context) {
18
18
  const client = context.$client;
19
19
  await client.conversations.setTopic({ channel, topic });
@@ -0,0 +1,19 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { platformPermission } from '@zhin.js/permission';
5
+ export default defineAgentTool({
6
+ description: '恢复已归档的 Slack 频道',
7
+ inputSchema: z.object({
8
+ channel_id: z.string().describe('频道 ID'),
9
+ }),
10
+ adapter: 'slack',
11
+ tags: ['slack'],
12
+ permissions: [platformPermission('slack', 'workspace_admin')],
13
+ async execute({ channel_id }, context) {
14
+ const client = context.$client;
15
+ await client.conversations.unarchive({ channel: channel_id });
16
+ const success = true;
17
+ return { success, message: success ? '频道已恢复' : '操作失败' };
18
+ },
19
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { platformPermit } from '../../src/platform-permit.js';
3
+ import { platformPermission } from '@zhin.js/permission';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  channel_id: string;
@@ -11,7 +11,7 @@ export default defineAgentTool<{
11
11
  }),
12
12
  adapter: 'slack',
13
13
  tags: ['slack'],
14
- permissions: [platformPermit('workspace_admin')],
14
+ permissions: [platformPermission('slack', 'workspace_admin')],
15
15
  async execute({ channel_id }, context) {
16
16
  const client = context.$client;
17
17
  await client.conversations.unarchive({ channel: channel_id });
@@ -0,0 +1,27 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ export default defineAgentTool({
5
+ description: '查询 Slack 用户详细信息',
6
+ inputSchema: z.object({
7
+ user_id: z.string().describe('用户 ID'),
8
+ }),
9
+ adapter: 'slack',
10
+ tags: ['slack'],
11
+ async execute({ user_id }, context) {
12
+ const client = context.$client;
13
+ const user = (await client.users.info({ user: user_id })).user;
14
+ if (!user)
15
+ throw new Error(`Slack 用户不存在: ${user_id}`);
16
+ return {
17
+ id: user.id,
18
+ name: user.name,
19
+ real_name: user.real_name,
20
+ display_name: user.profile?.display_name,
21
+ email: user.profile?.email,
22
+ is_admin: user.is_admin,
23
+ is_bot: user.is_bot,
24
+ status_text: user.profile?.status_text,
25
+ };
26
+ },
27
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import type { SlackUserInfo } from '../../src/client.js';
3
+ import type { SlackUserInfo } from '@zhin.js/adapter-slack';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  user_id: string;
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: slack-messages
3
+ platforms:
4
+ - slack
5
+ description: Slack 消息编辑、置顶和 reaction 管理能力。
6
+ keywords:
7
+ - "slack"
8
+ - "message"
9
+ - "pin"
10
+ - "reaction"
11
+ - "edit"
12
+ tools:
13
+ - "pin_message"
14
+ - "unpin_message"
15
+ - "add_reaction"
16
+ - "remove_reaction"
17
+ - "edit_message"
18
+ ---
19
+
20
+ # slack-messages
21
+
22
+ 使用稳定频道 ID 与消息时间戳。编辑、置顶和 reaction 变更均遵守 Tool 审批。
@@ -0,0 +1,27 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { normalizeSlackReactionName } from '@zhin.js/adapter-slack';
5
+ export default defineAgentTool({
6
+ description: '给 Slack 消息添加表情反应',
7
+ inputSchema: z.object({
8
+ channel: z.string().describe('频道 ID'),
9
+ timestamp: z.string().describe('消息时间戳'),
10
+ emoji: z.string().describe('表情名称(不含冒号)'),
11
+ }),
12
+ adapter: 'slack',
13
+ tags: ['slack'],
14
+ async execute({ channel, timestamp, emoji }, context) {
15
+ const client = context.$client;
16
+ const name = normalizeSlackReactionName(emoji);
17
+ try {
18
+ await client.reactions.add({ channel, timestamp, name });
19
+ }
20
+ catch (error) {
21
+ if (error?.data?.error !== 'already_reacted')
22
+ throw error;
23
+ }
24
+ const success = true;
25
+ return { success, message: success ? `已添加反应 :${emoji}:` : '操作失败' };
26
+ },
27
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { normalizeSlackReactionName } from '../../src/slack-reaction.js';
3
+ import { normalizeSlackReactionName } from '@zhin.js/adapter-slack';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  channel: string;
@@ -0,0 +1,21 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { editSlackContent } from '@zhin.js/adapter-slack';
5
+ export default defineAgentTool({
6
+ description: '编辑 Slack 消息',
7
+ inputSchema: z.object({
8
+ channel: z.string().describe('频道 ID'),
9
+ message_ts: z.string().describe('消息时间戳'),
10
+ text: z.string().describe('新的消息文本'),
11
+ }),
12
+ adapter: 'slack',
13
+ tags: ['slack'],
14
+ async execute({ channel, message_ts, text }, context) {
15
+ const client = context.$client;
16
+ await editSlackContent(client, channel, message_ts, [
17
+ { type: 'text', data: { text } },
18
+ ]);
19
+ return { success: true, message: '消息已编辑' };
20
+ },
21
+ });
@@ -1,6 +1,6 @@
1
- import { defineAgentTool } from '@zhin.js/agent/tools';
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
2
  import { z } from 'zod';
3
- import { editSlackContent } from '../../src/slack-outbound.js';
3
+ import { editSlackContent } from '@zhin.js/adapter-slack';
4
4
 
5
5
  export default defineAgentTool<{
6
6
  channel: string;