@sweny-ai/core 0.1.186 → 0.1.187
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/dist/skills/slack.js +11 -4
- package/package.json +1 -1
package/dist/skills/slack.js
CHANGED
|
@@ -25,12 +25,15 @@ export const slack = {
|
|
|
25
25
|
{
|
|
26
26
|
name: "slack_send_message",
|
|
27
27
|
access: "write",
|
|
28
|
-
description: "Send a message to a
|
|
28
|
+
description: "Send a message to Slack. Posts to the webhook's own channel, or to a named channel via the bot token API. Naming a channel requires SLACK_BOT_TOKEN; with only a webhook the call fails rather than post elsewhere.",
|
|
29
29
|
input_schema: {
|
|
30
30
|
type: "object",
|
|
31
31
|
properties: {
|
|
32
32
|
text: { type: "string", description: "Message text (Slack mrkdwn supported)" },
|
|
33
|
-
channel: {
|
|
33
|
+
channel: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Channel ID or name. Requires SLACK_BOT_TOKEN; with only a webhook configured, setting this is an error. Omit to post to the webhook's channel.",
|
|
36
|
+
},
|
|
34
37
|
blocks: {
|
|
35
38
|
type: "array",
|
|
36
39
|
description: "Optional Block Kit blocks for rich formatting",
|
|
@@ -40,7 +43,8 @@ export const slack = {
|
|
|
40
43
|
required: ["text"],
|
|
41
44
|
},
|
|
42
45
|
handler: async (input, ctx) => {
|
|
43
|
-
//
|
|
46
|
+
// A requested channel is only honored via the bot token API. A webhook is bound to its own
|
|
47
|
+
// channel, so never fall back to it when another channel was asked for.
|
|
44
48
|
if (ctx.config.SLACK_BOT_TOKEN && input.channel) {
|
|
45
49
|
const res = await fetch("https://slack.com/api/chat.postMessage", {
|
|
46
50
|
method: "POST",
|
|
@@ -62,7 +66,10 @@ export const slack = {
|
|
|
62
66
|
throw new Error(`[Slack] send_message failed: ${data.error ?? "unknown error"}`);
|
|
63
67
|
return data;
|
|
64
68
|
}
|
|
65
|
-
if (ctx.config.SLACK_WEBHOOK_URL) {
|
|
69
|
+
if (input.channel && !ctx.config.SLACK_BOT_TOKEN && ctx.config.SLACK_WEBHOOK_URL) {
|
|
70
|
+
throw new Error(`[Slack] cannot post to ${input.channel}: only SLACK_WEBHOOK_URL is configured, and a webhook posts to its own channel. Set SLACK_BOT_TOKEN to target a channel, or omit channel.`);
|
|
71
|
+
}
|
|
72
|
+
if (!input.channel && ctx.config.SLACK_WEBHOOK_URL) {
|
|
66
73
|
const res = await fetch(ctx.config.SLACK_WEBHOOK_URL, {
|
|
67
74
|
method: "POST",
|
|
68
75
|
headers: { "Content-Type": "application/json" },
|