@mastra/slack 0.0.0-studio-cli-20260504022012
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 +73 -0
- package/LICENSE.md +30 -0
- package/README.md +146 -0
- package/dist/index.cjs +5593 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +678 -0
- package/dist/index.d.ts +678 -0
- package/dist/index.js +5554 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @mastra/slack
|
|
2
|
+
|
|
3
|
+
## 0.0.0-studio-cli-20260504022012
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed Slack app creation failing when agent description exceeds 139 characters. The manifest description is now automatically truncated to prevent the Slack API from rejecting the request. ([#16093](https://github.com/mastra-ai/mastra/pull/16093))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`c05c9a1`](https://github.com/mastra-ai/mastra/commit/c05c9a13230988cef6d438a62f37760f31927bc7), [`e24aacb`](https://github.com/mastra-ai/mastra/commit/e24aacba07bd66f5d95b636dc24016fca26b52cf), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c), [`c721164`](https://github.com/mastra-ai/mastra/commit/c7211643f7ac861f83b19a3757cc921487fc9d75), [`1b55954`](https://github.com/mastra-ai/mastra/commit/1b559541c1e08a10e49d01ffc51a634dfc37a286), [`5adc55e`](https://github.com/mastra-ai/mastra/commit/5adc55e63407be8ee977914957d68bcc2a075ceb), [`70017d7`](https://github.com/mastra-ai/mastra/commit/70017d72ab741b5d7040e2a15c251a317782e39e), [`e4942bc`](https://github.com/mastra-ai/mastra/commit/e4942bc7fdc903572f7d84f26d5e15f9d39c763d)]:
|
|
10
|
+
- @mastra/core@0.0.0-studio-cli-20260504022012
|
|
11
|
+
|
|
12
|
+
## 1.1.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed Slack app creation failing when agent description exceeds 139 characters. The manifest description is now automatically truncated to prevent the Slack API from rejecting the request. ([#16093](https://github.com/mastra-ai/mastra/pull/16093))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`c05c9a1`](https://github.com/mastra-ai/mastra/commit/c05c9a13230988cef6d438a62f37760f31927bc7), [`e24aacb`](https://github.com/mastra-ai/mastra/commit/e24aacba07bd66f5d95b636dc24016fca26b52cf), [`c721164`](https://github.com/mastra-ai/mastra/commit/c7211643f7ac861f83b19a3757cc921487fc9d75), [`1b55954`](https://github.com/mastra-ai/mastra/commit/1b559541c1e08a10e49d01ffc51a634dfc37a286), [`5adc55e`](https://github.com/mastra-ai/mastra/commit/5adc55e63407be8ee977914957d68bcc2a075ceb), [`70017d7`](https://github.com/mastra-ai/mastra/commit/70017d72ab741b5d7040e2a15c251a317782e39e), [`e4942bc`](https://github.com/mastra-ai/mastra/commit/e4942bc7fdc903572f7d84f26d5e15f9d39c763d)]:
|
|
19
|
+
- @mastra/core@1.32.0-alpha.1
|
|
20
|
+
|
|
21
|
+
## 1.1.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- Added @mastra/slack channel integration for connecting AI agents to Slack workspaces. Provides automatic Slack app provisioning via OAuth, manifest management with drift detection, encrypted credential storage, slash command support, and threaded conversation handling. Usage: ([#15876](https://github.com/mastra-ai/mastra/pull/15876))
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { SlackProvider } from '@mastra/slack';
|
|
29
|
+
|
|
30
|
+
const mastra = new Mastra({
|
|
31
|
+
channels: {
|
|
32
|
+
slack: new SlackProvider({
|
|
33
|
+
refreshToken: process.env.SLACK_APP_CONFIG_REFRESH_TOKEN!,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Connect an agent to Slack
|
|
39
|
+
const result = await mastra.channels.slack.connect('my-agent');
|
|
40
|
+
// result.type === 'oauth' → redirect user to result.authorizationUrl
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [[`1723e09`](https://github.com/mastra-ai/mastra/commit/1723e099829892419ddbfe49287acfeac2522724), [`629f9e9`](https://github.com/mastra-ai/mastra/commit/629f9e9a7e56aa8f129515a3923c5813298790c7), [`25168fb`](https://github.com/mastra-ai/mastra/commit/25168fb9c1de9db7f8171df4f58ceb842c53aa29), [`ab34b5a`](https://github.com/mastra-ai/mastra/commit/ab34b5a2191b8e4353df1dbf7b9155e7d6628d79), [`5fb6c2a`](https://github.com/mastra-ai/mastra/commit/5fb6c2a95c1843cc231704b91354311fc1f34a71), [`2b0f355`](https://github.com/mastra-ai/mastra/commit/2b0f3553be3e9e5524da539a66e5cf82668440a4), [`394f0cf`](https://github.com/mastra-ai/mastra/commit/394f0cfc31e6b4d801219fdef2e9cc69e5bc8682), [`b2deb29`](https://github.com/mastra-ai/mastra/commit/b2deb29412b300c868655b5840463614fbb7962d), [`66644be`](https://github.com/mastra-ai/mastra/commit/66644beac1aa560f0e417956ff007c89341dc382), [`e109607`](https://github.com/mastra-ai/mastra/commit/e10960749251e34d46b480a20648c490fd30381b), [`310b953`](https://github.com/mastra-ai/mastra/commit/310b95345f302dcd5ba3ed862bdc96f059d44122), [`3d7f709`](https://github.com/mastra-ai/mastra/commit/3d7f709b615e588050bb6283c4ee5cfe2978cbde), [`48a42f1`](https://github.com/mastra-ai/mastra/commit/48a42f114a4006a95e0b7a1b5ad1a24815a175c2), [`8091c7c`](https://github.com/mastra-ai/mastra/commit/8091c7c944d15e13fef6d61b6cfd903f158d4006), [`2c83efc`](https://github.com/mastra-ai/mastra/commit/2c83efc4482b3efe50830e3b8b4ba9a8d219edff), [`43f0e1d`](https://github.com/mastra-ai/mastra/commit/43f0e1d5d5a74ba6fc746f2ad89ebe0c64777a7d), [`da0b9e2`](https://github.com/mastra-ai/mastra/commit/da0b9e2ba7ecc560213b426d6c097fe63946086e), [`282a10c`](https://github.com/mastra-ai/mastra/commit/282a10c9446e9922afe80e10e3770481c8ac8a28), [`04151c7`](https://github.com/mastra-ai/mastra/commit/04151c7dcea934b4fe9076708a23fac161195414), [`8091c7c`](https://github.com/mastra-ai/mastra/commit/8091c7c944d15e13fef6d61b6cfd903f158d4006)]:
|
|
46
|
+
- @mastra/core@1.31.0
|
|
47
|
+
|
|
48
|
+
## 1.1.0-alpha.0
|
|
49
|
+
|
|
50
|
+
### Minor Changes
|
|
51
|
+
|
|
52
|
+
- Added @mastra/slack channel integration for connecting AI agents to Slack workspaces. Provides automatic Slack app provisioning via OAuth, manifest management with drift detection, encrypted credential storage, slash command support, and threaded conversation handling. Usage: ([#15876](https://github.com/mastra-ai/mastra/pull/15876))
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { SlackProvider } from '@mastra/slack';
|
|
56
|
+
|
|
57
|
+
const mastra = new Mastra({
|
|
58
|
+
channels: {
|
|
59
|
+
slack: new SlackProvider({
|
|
60
|
+
refreshToken: process.env.SLACK_APP_CONFIG_REFRESH_TOKEN!,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Connect an agent to Slack
|
|
66
|
+
const result = await mastra.channels.slack.connect('my-agent');
|
|
67
|
+
// result.type === 'oauth' → redirect user to result.authorizationUrl
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [[`b2deb29`](https://github.com/mastra-ai/mastra/commit/b2deb29412b300c868655b5840463614fbb7962d), [`66644be`](https://github.com/mastra-ai/mastra/commit/66644beac1aa560f0e417956ff007c89341dc382), [`310b953`](https://github.com/mastra-ai/mastra/commit/310b95345f302dcd5ba3ed862bdc96f059d44122), [`43f0e1d`](https://github.com/mastra-ai/mastra/commit/43f0e1d5d5a74ba6fc746f2ad89ebe0c64777a7d), [`da0b9e2`](https://github.com/mastra-ai/mastra/commit/da0b9e2ba7ecc560213b426d6c097fe63946086e)]:
|
|
73
|
+
- @mastra/core@1.31.0-alpha.3
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
16
|
+
# Apache License 2.0
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
19
|
+
|
|
20
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
you may not use this file except in compliance with the License.
|
|
22
|
+
You may obtain a copy of the License at
|
|
23
|
+
|
|
24
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
|
|
26
|
+
Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
See the License for the specific language governing permissions and
|
|
30
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# @mastra/slack
|
|
2
|
+
|
|
3
|
+
Slack integration for Mastra agents. Handles app creation, OAuth, slash commands, and messaging.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
9
|
+
import { Agent } from '@mastra/core/agent';
|
|
10
|
+
import { SlackProvider } from '@mastra/slack';
|
|
11
|
+
|
|
12
|
+
const myAgent = new Agent({
|
|
13
|
+
id: 'my-agent',
|
|
14
|
+
name: 'My Agent',
|
|
15
|
+
model: 'openai/gpt-4.1',
|
|
16
|
+
instructions: 'You are a helpful assistant.',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const slack = new SlackProvider({
|
|
20
|
+
refreshToken: process.env.SLACK_APP_CONFIG_REFRESH_TOKEN,
|
|
21
|
+
// For local dev, set SLACK_BASE_URL to your tunnel URL
|
|
22
|
+
// In production, this is auto-derived from server config
|
|
23
|
+
baseUrl: process.env.SLACK_BASE_URL,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const mastra = new Mastra({
|
|
27
|
+
agents: { myAgent },
|
|
28
|
+
channels: { slack },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Or configure credentials later (e.g., from UI or vault)
|
|
32
|
+
// slack.configure({ refreshToken: 'xoxe-1-...' });
|
|
33
|
+
|
|
34
|
+
// Connect an agent to Slack (creates app, returns OAuth URL)
|
|
35
|
+
const { authorizationUrl } = await slack.connect('my-agent', {
|
|
36
|
+
name: 'My Bot',
|
|
37
|
+
description: 'An AI assistant',
|
|
38
|
+
iconUrl: 'https://example.com/my-bot-icon.png',
|
|
39
|
+
slashCommands: [
|
|
40
|
+
{ command: '/ask', prompt: 'Answer: {{text}}' },
|
|
41
|
+
{ command: '/help', prompt: 'List your capabilities.' },
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Setup
|
|
47
|
+
|
|
48
|
+
1. **Get App Configuration Tokens** from https://api.slack.com/apps (look for "Your App Configuration Tokens" section)
|
|
49
|
+
|
|
50
|
+
2. **Set up a tunnel** for local development:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cloudflared tunnel --url http://localhost:4111
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
3. **Add to .env**:
|
|
57
|
+
```
|
|
58
|
+
SLACK_APP_CONFIG_TOKEN=xoxe.xoxp-...
|
|
59
|
+
SLACK_APP_CONFIG_REFRESH_TOKEN=xoxe-1-...
|
|
60
|
+
SLACK_BASE_URL=https://abc123.trycloudflare.com
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> ⚠️ **Token Rotation**: Slack config access tokens expire after 12 hours, but the refresh token does not expire (it's single-use — each rotation returns a new pair). Tokens auto-rotate and are persisted to storage, so the `.env` values are only used as the initial seed. If you lose your persisted storage (e.g., DB wipe), you'll need fresh tokens from the Slack dashboard.
|
|
64
|
+
|
|
65
|
+
## Storage & Persistence
|
|
66
|
+
|
|
67
|
+
`SlackProvider` automatically uses Mastra's storage if configured. Just add `storage` to your Mastra config:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
71
|
+
|
|
72
|
+
const mastra = new Mastra({
|
|
73
|
+
agents: { myAgent },
|
|
74
|
+
storage: new LibSQLStore({ url: 'file:./mastra.db' }),
|
|
75
|
+
channels: {
|
|
76
|
+
slack: new SlackProvider({
|
|
77
|
+
refreshToken: process.env.SLACK_APP_CONFIG_REFRESH_TOKEN!,
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
When Mastra has storage configured, `SlackProvider` automatically:
|
|
84
|
+
|
|
85
|
+
- Persists rotated config tokens (so you don't need fresh tokens after restart)
|
|
86
|
+
- Persists Slack app installations
|
|
87
|
+
- Detects config changes (e.g., agent renames) and updates manifests on startup
|
|
88
|
+
|
|
89
|
+
Without storage, data is lost on restart and apps are recreated.
|
|
90
|
+
|
|
91
|
+
## How It Works
|
|
92
|
+
|
|
93
|
+
1. Register a `SlackProvider` on your `Mastra` instance
|
|
94
|
+
2. Call `slack.connect(agentId)` to provision a Slack app and get an OAuth URL
|
|
95
|
+
3. Visit the OAuth URL to install the app to your Slack workspace
|
|
96
|
+
4. After installation, messages and slash commands route to your agent
|
|
97
|
+
5. Config access tokens auto-rotate (they expire every 12 hours) and are saved to storage
|
|
98
|
+
|
|
99
|
+
## Slash Commands
|
|
100
|
+
|
|
101
|
+
Commands use prompt templates with variable substitution:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
await slack.connect('my-agent', {
|
|
105
|
+
slashCommands: [
|
|
106
|
+
{
|
|
107
|
+
command: '/ask',
|
|
108
|
+
description: 'Ask the AI a question',
|
|
109
|
+
prompt: 'Answer this question: {{text}}',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
command: '/summarize',
|
|
113
|
+
description: 'Summarize content',
|
|
114
|
+
prompt: 'Summarize the following in 2-3 sentences: {{text}}',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Available variables: `{{text}}`, `{{userId}}`, `{{channelId}}`, `{{teamId}}`
|
|
121
|
+
|
|
122
|
+
## App Icons
|
|
123
|
+
|
|
124
|
+
Each agent's Slack app can have its own icon:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
await slack.connect('my-agent', {
|
|
128
|
+
iconUrl: 'https://example.com/my-bot-avatar.png',
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The image should be:
|
|
133
|
+
|
|
134
|
+
- Square (1:1 aspect ratio)
|
|
135
|
+
- At least 512x512 pixels
|
|
136
|
+
- PNG, JPG, or GIF format
|
|
137
|
+
|
|
138
|
+
The icon is uploaded automatically when the Slack app is created.
|
|
139
|
+
|
|
140
|
+
## Disconnecting
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
await slack.disconnect('my-agent');
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This deletes the Slack app and removes the local installation record.
|