@mastra/slack 1.4.0 → 1.5.0-alpha.1
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 +59 -0
- package/dist/index.cjs +18 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @mastra/slack
|
|
2
2
|
|
|
3
|
+
## 1.5.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Normalize trailing slashes in the Slack provider `baseUrl`. A `baseUrl` with a trailing slash (e.g. `MASTRA_BASE_URL=https://example.com/`) previously produced double-slash callback URLs like `https://example.com//slack/oauth/callback`, which broke the OAuth flow and webhook delivery. The trailing slash is now stripped, so callback URLs are always well-formed. ([#18483](https://github.com/mastra-ai/mastra/pull/18483))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`023766f`](https://github.com/mastra-ai/mastra/commit/023766f44d59b30a50f3a381e33eddde8ab56c00), [`a0509c7`](https://github.com/mastra-ai/mastra/commit/a0509c731a08aa3ed626557c5338126362856f57), [`01caf93`](https://github.com/mastra-ai/mastra/commit/01caf93d71ae2c1e65f49735cafb531975187426), [`c2c1d7b`](https://github.com/mastra-ai/mastra/commit/c2c1d7bb61d2602955f14ed3952f807c2d6eb576), [`3eb852e`](https://github.com/mastra-ai/mastra/commit/3eb852e5435bc908b800193498103dc724f455b0)]:
|
|
10
|
+
- @mastra/core@1.47.0-alpha.5
|
|
11
|
+
|
|
12
|
+
## 1.5.0-alpha.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- Added `waitUntil` support for channels so background agent runs survive serverless responses. ([#17832](https://github.com/mastra-ai/mastra/pull/17832))
|
|
17
|
+
|
|
18
|
+
Without `waitUntil`, the runtime freezes the invocation as soon as the webhook response returns, killing the agent run mid-flight and leaving the user with no reply.
|
|
19
|
+
|
|
20
|
+
**Auto-detected (no config needed):**
|
|
21
|
+
- **Cloudflare Workers** — reads `c.executionCtx.waitUntil`
|
|
22
|
+
- **Netlify Functions** — reads `c.env.context.waitUntil`
|
|
23
|
+
|
|
24
|
+
**Requires explicit config:**
|
|
25
|
+
|
|
26
|
+
Vercel needs a `waitUntil` function passed directly because it exposes `waitUntil` via AsyncLocalStorage, not the request context. AWS Lambda doesn't need `waitUntil` — it waits for the event loop to drain naturally.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { waitUntil } from '@vercel/functions';
|
|
30
|
+
import { SlackProvider } from '@mastra/slack';
|
|
31
|
+
|
|
32
|
+
new SlackProvider({ waitUntil });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
new Agent({
|
|
37
|
+
channels: {
|
|
38
|
+
adapters: { slack: createSlackAdapter({ ... }) },
|
|
39
|
+
waitUntil,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For runtimes where `waitUntil` lives on the request context but isn't covered by the default, pass `resolveWaitUntil: (c) => fn | undefined` instead.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
new Agent({
|
|
48
|
+
channels: {
|
|
49
|
+
adapters: { slack: createSlackAdapter({ ... }) },
|
|
50
|
+
resolveWaitUntil: c => c.var.runtime?.waitUntil,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Resolution order: `waitUntil` → `resolveWaitUntil(c)` → core default.
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [[`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`7c9dd77`](https://github.com/mastra-ai/mastra/commit/7c9dd77bd18cb8dc72797e25f1a0fbdc71a11347), [`9990965`](https://github.com/mastra-ai/mastra/commit/999096571635a83b42ef40841fd7028cfa630779), [`c0ffa3c`](https://github.com/mastra-ai/mastra/commit/c0ffa3c897ccd326de880df734740a7f0681a18f), [`0504bf5`](https://github.com/mastra-ai/mastra/commit/0504bf5e8cffc571a4b343326178de371e6f859b), [`5afe423`](https://github.com/mastra-ai/mastra/commit/5afe423e4badf040f1b0d4525183a856fcb8146e), [`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`8c9f1c0`](https://github.com/mastra-ai/mastra/commit/8c9f1c0361d89066f9bcd14a2f69e761b01766c8)]:
|
|
60
|
+
- @mastra/core@1.47.0-alpha.2
|
|
61
|
+
|
|
3
62
|
## 1.4.0
|
|
4
63
|
|
|
5
64
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -14937,6 +14937,13 @@ var SlackConfigDataSchema = external_exports.object({
|
|
|
14937
14937
|
|
|
14938
14938
|
// src/provider.ts
|
|
14939
14939
|
var PLATFORM = "slack";
|
|
14940
|
+
function stripTrailingSlash(url2) {
|
|
14941
|
+
let end = url2.length;
|
|
14942
|
+
while (end > 0 && url2.charCodeAt(end - 1) === 47) {
|
|
14943
|
+
end--;
|
|
14944
|
+
}
|
|
14945
|
+
return end === url2.length ? url2 : url2.slice(0, end);
|
|
14946
|
+
}
|
|
14940
14947
|
function hashConfig(opts, baseUrl, resolvedAppName, resolvedDescription) {
|
|
14941
14948
|
const normalized = JSON.stringify({
|
|
14942
14949
|
name: resolvedAppName,
|
|
@@ -15348,7 +15355,7 @@ var SlackProvider = class {
|
|
|
15348
15355
|
*/
|
|
15349
15356
|
#getBaseUrl() {
|
|
15350
15357
|
if (this.#baseUrl) {
|
|
15351
|
-
return this.#baseUrl;
|
|
15358
|
+
return stripTrailingSlash(this.#baseUrl);
|
|
15352
15359
|
}
|
|
15353
15360
|
const server = this.#mastra?.getServer();
|
|
15354
15361
|
const protocol = server?.studioProtocol ?? "http";
|
|
@@ -15362,7 +15369,7 @@ var SlackProvider = class {
|
|
|
15362
15369
|
* Only needed if not using Mastra server config.
|
|
15363
15370
|
*/
|
|
15364
15371
|
setBaseUrl(baseUrl) {
|
|
15365
|
-
this.#baseUrl = baseUrl;
|
|
15372
|
+
this.#baseUrl = stripTrailingSlash(baseUrl);
|
|
15366
15373
|
}
|
|
15367
15374
|
/**
|
|
15368
15375
|
* Restore active Slack installations from storage.
|
|
@@ -15563,7 +15570,6 @@ var SlackProvider = class {
|
|
|
15563
15570
|
const slackEntry = Object.keys(adapterConfig).length > 0 ? { adapter, ...adapterConfig } : adapter;
|
|
15564
15571
|
const existing = agent.getChannels();
|
|
15565
15572
|
const existingConfig = existing?.channelConfig;
|
|
15566
|
-
existing?.close();
|
|
15567
15573
|
const agentChannels = new import_channels.AgentChannels({
|
|
15568
15574
|
...existingConfig,
|
|
15569
15575
|
...this.#forwardedChannelOptions(),
|
|
@@ -16051,8 +16057,13 @@ var SlackProvider = class {
|
|
|
16051
16057
|
headers: c.req.raw.headers,
|
|
16052
16058
|
body: rawBody
|
|
16053
16059
|
});
|
|
16060
|
+
const waitUntilFn = this.#channelConfig.waitUntil ?? this.#channelConfig.resolveWaitUntil?.(c) ?? (0, import_channels.resolveWaitUntil)(c);
|
|
16054
16061
|
try {
|
|
16055
|
-
return await agentChannels.handleWebhookEvent(
|
|
16062
|
+
return await agentChannels.handleWebhookEvent(
|
|
16063
|
+
"slack",
|
|
16064
|
+
delegateRequest,
|
|
16065
|
+
waitUntilFn ? { waitUntil: waitUntilFn } : void 0
|
|
16066
|
+
);
|
|
16056
16067
|
} catch (error51) {
|
|
16057
16068
|
console.error("[Slack] Error delegating to AgentChannels:", error51);
|
|
16058
16069
|
return c.json({ ok: true });
|
|
@@ -16106,7 +16117,7 @@ var SlackProvider = class {
|
|
|
16106
16117
|
signal: AbortSignal.timeout(3e4)
|
|
16107
16118
|
});
|
|
16108
16119
|
};
|
|
16109
|
-
(async () => {
|
|
16120
|
+
const task = (async () => {
|
|
16110
16121
|
try {
|
|
16111
16122
|
const result = await agent.generate(prompt);
|
|
16112
16123
|
const text = typeof result.text === "string" ? result.text : JSON.stringify(result.text);
|
|
@@ -16117,6 +16128,8 @@ var SlackProvider = class {
|
|
|
16117
16128
|
await sendDelayedResponse(`Error: ${message}`);
|
|
16118
16129
|
}
|
|
16119
16130
|
})();
|
|
16131
|
+
const slashWaitUntil = this.#channelConfig.waitUntil ?? this.#channelConfig.resolveWaitUntil?.(c) ?? (0, import_channels.resolveWaitUntil)(c);
|
|
16132
|
+
slashWaitUntil?.(task);
|
|
16120
16133
|
return c.json({ response_type: "ephemeral", text: "Processing..." });
|
|
16121
16134
|
}
|
|
16122
16135
|
// ===========================================================================
|