@credal/actions 0.2.209 → 0.2.210

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.
@@ -694,7 +694,7 @@ export const slackCreateChannelDefinition = {
694
694
  };
695
695
  export const slackSendMessageDefinition = {
696
696
  displayName: "Send a message",
697
- description: "Sends a message to a Slack channel",
697
+ description: "Sends a message to a Slack channel, optionally as a reply in a thread",
698
698
  scopes: ["chat:write"],
699
699
  tags: [],
700
700
  parameters: {
@@ -718,6 +718,14 @@ export const slackSendMessageDefinition = {
718
718
  type: "boolean",
719
719
  description: "Whether to enable unfurling of links in the message (defaults to true)",
720
720
  },
721
+ threadTs: {
722
+ type: "string",
723
+ description: "The timestamp (ts) of a parent message to reply to in a thread. Obtain this from the `timestamp` field returned by a previous sendMessage call, or from the trailing path segment of a Slack message permalink (e.g. `p1234567890123456` → `1234567890.123456`).",
724
+ },
725
+ replyBroadcast: {
726
+ type: "boolean",
727
+ description: "When replying in a thread (threadTs provided), also post the reply to the channel. Defaults to false.",
728
+ },
721
729
  },
722
730
  },
723
731
  output: {
@@ -732,9 +740,21 @@ export const slackSendMessageDefinition = {
732
740
  type: "string",
733
741
  description: "The error that occurred if the message was not sent successfully",
734
742
  },
735
- messageId: {
743
+ channelId: {
736
744
  type: "string",
737
- description: "The ID of the message that was sent",
745
+ description: "The ID of the channel the message was sent to",
746
+ },
747
+ timestamp: {
748
+ type: "string",
749
+ description: "The Slack timestamp (ts) of the sent message. Use this as `threadTs` on a subsequent sendMessage call to reply in a thread.",
750
+ },
751
+ threadTs: {
752
+ type: "string",
753
+ description: "The timestamp of the parent message, if this message was sent as a threaded reply",
754
+ },
755
+ permalink: {
756
+ type: "string",
757
+ description: "The permalink URL to the sent message",
738
758
  },
739
759
  },
740
760
  },
@@ -970,30 +970,45 @@ export declare const slackSendMessageParamsSchema: z.ZodObject<{
970
970
  channelName: z.ZodOptional<z.ZodString>;
971
971
  message: z.ZodString;
972
972
  unfurlLinks: z.ZodOptional<z.ZodBoolean>;
973
+ threadTs: z.ZodOptional<z.ZodString>;
974
+ replyBroadcast: z.ZodOptional<z.ZodBoolean>;
973
975
  }, "strip", z.ZodTypeAny, {
974
976
  message: string;
975
977
  channelId?: string | undefined;
976
978
  channelName?: string | undefined;
977
979
  unfurlLinks?: boolean | undefined;
980
+ threadTs?: string | undefined;
981
+ replyBroadcast?: boolean | undefined;
978
982
  }, {
979
983
  message: string;
980
984
  channelId?: string | undefined;
981
985
  channelName?: string | undefined;
982
986
  unfurlLinks?: boolean | undefined;
987
+ threadTs?: string | undefined;
988
+ replyBroadcast?: boolean | undefined;
983
989
  }>;
984
990
  export type slackSendMessageParamsType = z.infer<typeof slackSendMessageParamsSchema>;
985
991
  export declare const slackSendMessageOutputSchema: z.ZodObject<{
986
992
  success: z.ZodBoolean;
987
993
  error: z.ZodOptional<z.ZodString>;
988
- messageId: z.ZodOptional<z.ZodString>;
994
+ channelId: z.ZodOptional<z.ZodString>;
995
+ timestamp: z.ZodOptional<z.ZodString>;
996
+ threadTs: z.ZodOptional<z.ZodString>;
997
+ permalink: z.ZodOptional<z.ZodString>;
989
998
  }, "strip", z.ZodTypeAny, {
990
999
  success: boolean;
991
1000
  error?: string | undefined;
992
- messageId?: string | undefined;
1001
+ channelId?: string | undefined;
1002
+ timestamp?: string | undefined;
1003
+ permalink?: string | undefined;
1004
+ threadTs?: string | undefined;
993
1005
  }, {
994
1006
  success: boolean;
995
1007
  error?: string | undefined;
996
- messageId?: string | undefined;
1008
+ channelId?: string | undefined;
1009
+ timestamp?: string | undefined;
1010
+ permalink?: string | undefined;
1011
+ threadTs?: string | undefined;
997
1012
  }>;
998
1013
  export type slackSendMessageOutputType = z.infer<typeof slackSendMessageOutputSchema>;
999
1014
  export type slackSendMessageFunction = ActionFunction<slackSendMessageParamsType, AuthParamsType, slackSendMessageOutputType>;
@@ -7102,13 +7117,13 @@ export declare const googlemailReplyToGmailOutputSchema: z.ZodObject<{
7102
7117
  }, "strip", z.ZodTypeAny, {
7103
7118
  success: boolean;
7104
7119
  error?: string | undefined;
7105
- messageId?: string | undefined;
7106
7120
  threadId?: string | undefined;
7121
+ messageId?: string | undefined;
7107
7122
  }, {
7108
7123
  success: boolean;
7109
7124
  error?: string | undefined;
7110
- messageId?: string | undefined;
7111
7125
  threadId?: string | undefined;
7126
+ messageId?: string | undefined;
7112
7127
  }>;
7113
7128
  export type googlemailReplyToGmailOutputType = z.infer<typeof googlemailReplyToGmailOutputSchema>;
7114
7129
  export type googlemailReplyToGmailFunction = ActionFunction<googlemailReplyToGmailParamsType, AuthParamsType, googlemailReplyToGmailOutputType>;
@@ -405,11 +405,28 @@ export const slackSendMessageParamsSchema = z.object({
405
405
  .boolean()
406
406
  .describe("Whether to enable unfurling of links in the message (defaults to true)")
407
407
  .optional(),
408
+ threadTs: z
409
+ .string()
410
+ .describe("The timestamp (ts) of a parent message to reply to in a thread. Obtain this from the `timestamp` field returned by a previous sendMessage call, or from the trailing path segment of a Slack message permalink (e.g. `p1234567890123456` → `1234567890.123456`).")
411
+ .optional(),
412
+ replyBroadcast: z
413
+ .boolean()
414
+ .describe("When replying in a thread (threadTs provided), also post the reply to the channel. Defaults to false.")
415
+ .optional(),
408
416
  });
409
417
  export const slackSendMessageOutputSchema = z.object({
410
418
  success: z.boolean().describe("Whether the message was sent successfully"),
411
419
  error: z.string().describe("The error that occurred if the message was not sent successfully").optional(),
412
- messageId: z.string().describe("The ID of the message that was sent").optional(),
420
+ channelId: z.string().describe("The ID of the channel the message was sent to").optional(),
421
+ timestamp: z
422
+ .string()
423
+ .describe("The Slack timestamp (ts) of the sent message. Use this as `threadTs` on a subsequent sendMessage call to reply in a thread.")
424
+ .optional(),
425
+ threadTs: z
426
+ .string()
427
+ .describe("The timestamp of the parent message, if this message was sent as a threaded reply")
428
+ .optional(),
429
+ permalink: z.string().describe("The permalink URL to the sent message").optional(),
413
430
  });
414
431
  export const slackGetChannelMessagesParamsSchema = z.object({
415
432
  channelId: z
@@ -6,7 +6,7 @@ const sendMessage = async ({ params, authParams, }) => {
6
6
  if (!authParams.authToken) {
7
7
  throw new Error(MISSING_AUTH_TOKEN);
8
8
  }
9
- const { channelId: inputChannelId, channelName, message, unfurlLinks } = params;
9
+ const { channelId: inputChannelId, channelName, message, unfurlLinks, threadTs, replyBroadcast } = params;
10
10
  if (!inputChannelId && !channelName) {
11
11
  throw Error("Either channelId or channelName must be provided");
12
12
  }
@@ -19,35 +19,74 @@ const sendMessage = async ({ params, authParams, }) => {
19
19
  if (!channelId) {
20
20
  throw Error(`Channel with name ${channelName} not found`);
21
21
  }
22
- try {
23
- // First try sending as Markdown blocks (mrkdwn)
24
- await client.chat.postMessage({
25
- channel: channelId,
26
- text: message, // Fallback text for notifications/clients that don't render blocks
27
- unfurl_links: unfurlLinks,
28
- blocks: [
29
- {
30
- type: "section",
31
- text: {
32
- type: "mrkdwn",
33
- text: message,
34
- },
35
- },
36
- ],
22
+ const baseArgs = {
23
+ channel: channelId,
24
+ text: message,
25
+ unfurl_links: unfurlLinks,
26
+ };
27
+ const messageBlocks = [
28
+ {
29
+ type: "section",
30
+ text: {
31
+ type: "mrkdwn",
32
+ text: message,
33
+ },
34
+ },
35
+ ];
36
+ const postAsBlocks = () => client.chat.postMessage(threadTs
37
+ ? replyBroadcast
38
+ ? {
39
+ ...baseArgs,
40
+ thread_ts: threadTs,
41
+ reply_broadcast: true,
42
+ blocks: messageBlocks,
43
+ }
44
+ : {
45
+ ...baseArgs,
46
+ thread_ts: threadTs,
47
+ blocks: messageBlocks,
48
+ }
49
+ : {
50
+ ...baseArgs,
51
+ blocks: messageBlocks,
37
52
  });
53
+ const postAsPlainText = () => client.chat.postMessage(threadTs
54
+ ? replyBroadcast
55
+ ? { ...baseArgs, thread_ts: threadTs, reply_broadcast: true }
56
+ : { ...baseArgs, thread_ts: threadTs }
57
+ : baseArgs);
58
+ const buildSuccess = async (result) => {
59
+ const ts = result.ts;
60
+ const resolvedChannelId = result.channel ?? channelId;
61
+ let permalink;
62
+ if (ts) {
63
+ try {
64
+ const permalinkResult = await client.chat.getPermalink({
65
+ channel: resolvedChannelId,
66
+ message_ts: ts,
67
+ });
68
+ permalink = permalinkResult.permalink;
69
+ }
70
+ catch {
71
+ // Permalink fetch failed, but the message was sent successfully
72
+ }
73
+ }
38
74
  return slackSendMessageOutputSchema.parse({
39
75
  success: true,
76
+ channelId: resolvedChannelId,
77
+ timestamp: ts,
78
+ threadTs: threadTs,
79
+ permalink,
40
80
  });
81
+ };
82
+ try {
83
+ const result = await postAsBlocks();
84
+ return await buildSuccess(result);
41
85
  }
42
86
  catch {
43
- // On any error, retry once with plain text only (no blocks)
44
87
  try {
45
- await client.chat.postMessage({
46
- channel: channelId,
47
- text: message,
48
- unfurl_links: unfurlLinks,
49
- });
50
- return slackSendMessageOutputSchema.parse({ success: true });
88
+ const result = await postAsPlainText();
89
+ return await buildSuccess(result);
51
90
  }
52
91
  catch (retryError) {
53
92
  return slackSendMessageOutputSchema.parse({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.209",
3
+ "version": "0.2.210",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,