@mastra/slack 1.4.0-alpha.0 → 1.5.0-alpha.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 +61 -0
- package/dist/index.cjs +9 -3
- 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 +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mastra } from '@mastra/core/mastra';
|
|
2
|
-
import { ChannelAdapterConfig, StreamingConfig, ToolDisplay, StaticToolDisplay, ChannelHandlers, ChannelConfig, ChannelProvider, ChannelConnectResult, ChannelInstallationInfo, ChannelPlatformInfo } from '@mastra/core/channels';
|
|
2
|
+
import { ChannelAdapterConfig, StreamingConfig, ToolDisplay, StaticToolDisplay, ChannelHandlers, ChannelConfig, WaitUntilFn, WaitUntilResolver, ChannelProvider, ChannelConnectResult, ChannelInstallationInfo, ChannelPlatformInfo } from '@mastra/core/channels';
|
|
3
3
|
import { ApiRoute } from '@mastra/core/server';
|
|
4
4
|
import { SlackAdapterConfig, SlackAdapter } from '@chat-adapter/slack';
|
|
5
5
|
export { SlackAdapter, createSlackAdapter } from '@chat-adapter/slack';
|
|
@@ -281,6 +281,39 @@ interface SlackProviderConfigBase extends SlackAdapterChannelConfigBase {
|
|
|
281
281
|
* Use a 32+ character random string. Can be set via MASTRA_ENCRYPTION_KEY env var.
|
|
282
282
|
*/
|
|
283
283
|
encryptionKey?: string;
|
|
284
|
+
/**
|
|
285
|
+
* Resolver that returns a `waitUntil` for the current Slack webhook request.
|
|
286
|
+
*
|
|
287
|
+
* Required on serverless runtimes where Hono can't bridge the platform's
|
|
288
|
+
* `ExecutionContext` automatically (Vercel, AWS Lambda). Without `waitUntil`, the
|
|
289
|
+
* runtime freezes the invocation as soon as the 200 ack returns, killing the
|
|
290
|
+
* agent run mid-flight and leaving the user with no Slack reply.
|
|
291
|
+
*
|
|
292
|
+
* Pass the bare `waitUntil(promise)` function from your platform's SDK. If your
|
|
293
|
+
* runtime requires the Hono `Context` to derive `waitUntil`, use
|
|
294
|
+
* {@link resolveWaitUntil} instead.
|
|
295
|
+
*
|
|
296
|
+
* Cloudflare Workers and Netlify users typically don't need this — Mastra's
|
|
297
|
+
* default helper already reads `c.executionCtx.waitUntil` and
|
|
298
|
+
* `c.env.context.waitUntil`.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* import { waitUntil } from '@vercel/functions';
|
|
303
|
+
* new SlackProvider({ waitUntil });
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
waitUntil?: WaitUntilFn;
|
|
307
|
+
/**
|
|
308
|
+
* Resolve `waitUntil` from the request's Hono `Context`. Use this when the runtime
|
|
309
|
+
* exposes `waitUntil` through the request and core's default doesn't cover it.
|
|
310
|
+
*
|
|
311
|
+
* For platforms whose `waitUntil` is a bare import (e.g. `@vercel/functions`),
|
|
312
|
+
* pass it via {@link waitUntil} instead.
|
|
313
|
+
*
|
|
314
|
+
* Resolution order: {@link waitUntil} → {@link resolveWaitUntil} → core default.
|
|
315
|
+
*/
|
|
316
|
+
resolveWaitUntil?: WaitUntilResolver;
|
|
284
317
|
/**
|
|
285
318
|
* Per-adapter overrides applied to the Slack adapter entry inside
|
|
286
319
|
* `AgentChannels.adapters` — for example `toolDisplay`, `streaming`,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mastra } from '@mastra/core/mastra';
|
|
2
|
-
import { ChannelAdapterConfig, StreamingConfig, ToolDisplay, StaticToolDisplay, ChannelHandlers, ChannelConfig, ChannelProvider, ChannelConnectResult, ChannelInstallationInfo, ChannelPlatformInfo } from '@mastra/core/channels';
|
|
2
|
+
import { ChannelAdapterConfig, StreamingConfig, ToolDisplay, StaticToolDisplay, ChannelHandlers, ChannelConfig, WaitUntilFn, WaitUntilResolver, ChannelProvider, ChannelConnectResult, ChannelInstallationInfo, ChannelPlatformInfo } from '@mastra/core/channels';
|
|
3
3
|
import { ApiRoute } from '@mastra/core/server';
|
|
4
4
|
import { SlackAdapterConfig, SlackAdapter } from '@chat-adapter/slack';
|
|
5
5
|
export { SlackAdapter, createSlackAdapter } from '@chat-adapter/slack';
|
|
@@ -281,6 +281,39 @@ interface SlackProviderConfigBase extends SlackAdapterChannelConfigBase {
|
|
|
281
281
|
* Use a 32+ character random string. Can be set via MASTRA_ENCRYPTION_KEY env var.
|
|
282
282
|
*/
|
|
283
283
|
encryptionKey?: string;
|
|
284
|
+
/**
|
|
285
|
+
* Resolver that returns a `waitUntil` for the current Slack webhook request.
|
|
286
|
+
*
|
|
287
|
+
* Required on serverless runtimes where Hono can't bridge the platform's
|
|
288
|
+
* `ExecutionContext` automatically (Vercel, AWS Lambda). Without `waitUntil`, the
|
|
289
|
+
* runtime freezes the invocation as soon as the 200 ack returns, killing the
|
|
290
|
+
* agent run mid-flight and leaving the user with no Slack reply.
|
|
291
|
+
*
|
|
292
|
+
* Pass the bare `waitUntil(promise)` function from your platform's SDK. If your
|
|
293
|
+
* runtime requires the Hono `Context` to derive `waitUntil`, use
|
|
294
|
+
* {@link resolveWaitUntil} instead.
|
|
295
|
+
*
|
|
296
|
+
* Cloudflare Workers and Netlify users typically don't need this — Mastra's
|
|
297
|
+
* default helper already reads `c.executionCtx.waitUntil` and
|
|
298
|
+
* `c.env.context.waitUntil`.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* import { waitUntil } from '@vercel/functions';
|
|
303
|
+
* new SlackProvider({ waitUntil });
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
waitUntil?: WaitUntilFn;
|
|
307
|
+
/**
|
|
308
|
+
* Resolve `waitUntil` from the request's Hono `Context`. Use this when the runtime
|
|
309
|
+
* exposes `waitUntil` through the request and core's default doesn't cover it.
|
|
310
|
+
*
|
|
311
|
+
* For platforms whose `waitUntil` is a bare import (e.g. `@vercel/functions`),
|
|
312
|
+
* pass it via {@link waitUntil} instead.
|
|
313
|
+
*
|
|
314
|
+
* Resolution order: {@link waitUntil} → {@link resolveWaitUntil} → core default.
|
|
315
|
+
*/
|
|
316
|
+
resolveWaitUntil?: WaitUntilResolver;
|
|
284
317
|
/**
|
|
285
318
|
* Per-adapter overrides applied to the Slack adapter entry inside
|
|
286
319
|
* `AgentChannels.adapters` — for example `toolDisplay`, `streaming`,
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,8 @@ var __export = (target, all) => {
|
|
|
7
7
|
// src/provider.ts
|
|
8
8
|
import * as crypto from "crypto";
|
|
9
9
|
import {
|
|
10
|
-
AgentChannels
|
|
10
|
+
AgentChannels,
|
|
11
|
+
resolveWaitUntil
|
|
11
12
|
} from "@mastra/core/channels";
|
|
12
13
|
import "@mastra/core/storage";
|
|
13
14
|
import { createSlackAdapter } from "@chat-adapter/slack";
|
|
@@ -15525,7 +15526,6 @@ var SlackProvider = class {
|
|
|
15525
15526
|
const slackEntry = Object.keys(adapterConfig).length > 0 ? { adapter, ...adapterConfig } : adapter;
|
|
15526
15527
|
const existing = agent.getChannels();
|
|
15527
15528
|
const existingConfig = existing?.channelConfig;
|
|
15528
|
-
existing?.close();
|
|
15529
15529
|
const agentChannels = new AgentChannels({
|
|
15530
15530
|
...existingConfig,
|
|
15531
15531
|
...this.#forwardedChannelOptions(),
|
|
@@ -16013,8 +16013,13 @@ var SlackProvider = class {
|
|
|
16013
16013
|
headers: c.req.raw.headers,
|
|
16014
16014
|
body: rawBody
|
|
16015
16015
|
});
|
|
16016
|
+
const waitUntilFn = this.#channelConfig.waitUntil ?? this.#channelConfig.resolveWaitUntil?.(c) ?? resolveWaitUntil(c);
|
|
16016
16017
|
try {
|
|
16017
|
-
return await agentChannels.handleWebhookEvent(
|
|
16018
|
+
return await agentChannels.handleWebhookEvent(
|
|
16019
|
+
"slack",
|
|
16020
|
+
delegateRequest,
|
|
16021
|
+
waitUntilFn ? { waitUntil: waitUntilFn } : void 0
|
|
16022
|
+
);
|
|
16018
16023
|
} catch (error51) {
|
|
16019
16024
|
console.error("[Slack] Error delegating to AgentChannels:", error51);
|
|
16020
16025
|
return c.json({ ok: true });
|
|
@@ -16068,7 +16073,7 @@ var SlackProvider = class {
|
|
|
16068
16073
|
signal: AbortSignal.timeout(3e4)
|
|
16069
16074
|
});
|
|
16070
16075
|
};
|
|
16071
|
-
(async () => {
|
|
16076
|
+
const task = (async () => {
|
|
16072
16077
|
try {
|
|
16073
16078
|
const result = await agent.generate(prompt);
|
|
16074
16079
|
const text = typeof result.text === "string" ? result.text : JSON.stringify(result.text);
|
|
@@ -16079,6 +16084,8 @@ var SlackProvider = class {
|
|
|
16079
16084
|
await sendDelayedResponse(`Error: ${message}`);
|
|
16080
16085
|
}
|
|
16081
16086
|
})();
|
|
16087
|
+
const slashWaitUntil = this.#channelConfig.waitUntil ?? this.#channelConfig.resolveWaitUntil?.(c) ?? resolveWaitUntil(c);
|
|
16088
|
+
slashWaitUntil?.(task);
|
|
16082
16089
|
return c.json({ response_type: "ephemeral", text: "Processing..." });
|
|
16083
16090
|
}
|
|
16084
16091
|
// ===========================================================================
|