@credal/actions 0.1.23 → 0.1.25

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.
@@ -27,6 +27,7 @@ const symbolLookup_1 = __importDefault(require("./providers/finnhub/symbolLookup
27
27
  const getBasicFinancials_1 = __importDefault(require("./providers/finnhub/getBasicFinancials"));
28
28
  const overwritePage_1 = __importDefault(require("./providers/confluence/overwritePage"));
29
29
  const fetchPageContent_1 = __importDefault(require("./providers/confluence/fetchPageContent"));
30
+ const runSnowflakeQueryWriteResultsToS3_1 = __importDefault(require("./providers/snowflake/runSnowflakeQueryWriteResultsToS3"));
30
31
  exports.ActionMapper = {
31
32
  math: {
32
33
  add: {
@@ -98,6 +99,11 @@ exports.ActionMapper = {
98
99
  paramsSchema: types_1.snowflakeGetRowByFieldValueParamsSchema,
99
100
  outputSchema: types_1.snowflakeGetRowByFieldValueOutputSchema,
100
101
  },
102
+ runSnowflakeQueryWriteResultsToS3: {
103
+ fn: runSnowflakeQueryWriteResultsToS3_1.default,
104
+ paramsSchema: types_1.snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema,
105
+ outputSchema: types_1.snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema,
106
+ },
101
107
  },
102
108
  linkedin: {
103
109
  createShareLinkedinPostUrl: {
@@ -13,6 +13,7 @@ export declare const linkedinCreateShareLinkedinPostUrlDefinition: ActionTemplat
13
13
  export declare const xCreateShareXPostUrlDefinition: ActionTemplate;
14
14
  export declare const mongoInsertMongoDocDefinition: ActionTemplate;
15
15
  export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
16
+ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3Definition: ActionTemplate;
16
17
  export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
17
18
  export declare const nwsGetForecastForLocationDefinition: ActionTemplate;
18
19
  export declare const firecrawlScrapeUrlDefinition: ActionTemplate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finnhubGetBasicFinancialsDefinition = exports.finnhubSymbolLookupDefinition = exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeTweetDataWithNitterDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.xCreateShareXPostUrlDefinition = exports.linkedinCreateShareLinkedinPostUrlDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsNearbysearchRestaurantsDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceFetchPageContentDefinition = exports.confluenceOverwritePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
3
+ exports.finnhubGetBasicFinancialsDefinition = exports.finnhubSymbolLookupDefinition = exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeTweetDataWithNitterDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeRunSnowflakeQueryWriteResultsToS3Definition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.xCreateShareXPostUrlDefinition = exports.linkedinCreateShareLinkedinPostUrlDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsNearbysearchRestaurantsDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceFetchPageContentDefinition = exports.confluenceOverwritePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
4
4
  exports.slackSendMessageDefinition = {
5
5
  description: "Sends a message to a Slack channel",
6
6
  scopes: ["chat:write"],
@@ -538,6 +538,29 @@ exports.credalCallCopilotDefinition = {
538
538
  },
539
539
  },
540
540
  },
541
+ webSearchResults: {
542
+ type: "array",
543
+ description: "The web search results in the response",
544
+ items: {
545
+ type: "object",
546
+ description: "The web search result in the response",
547
+ required: ["title", "url"],
548
+ properties: {
549
+ title: {
550
+ type: "string",
551
+ description: "The title of the web search result",
552
+ },
553
+ url: {
554
+ type: "string",
555
+ description: "The url of the web search result",
556
+ },
557
+ contents: {
558
+ type: "string",
559
+ description: "The contents of the web search result",
560
+ },
561
+ },
562
+ },
563
+ },
541
564
  },
542
565
  },
543
566
  name: "callCopilot",
@@ -750,6 +773,69 @@ exports.snowflakeGetRowByFieldValueDefinition = {
750
773
  name: "getRowByFieldValue",
751
774
  provider: "snowflake",
752
775
  };
776
+ exports.snowflakeRunSnowflakeQueryWriteResultsToS3Definition = {
777
+ description: "Execute a Snowflake query and write results to an S3 bucket",
778
+ scopes: [],
779
+ parameters: {
780
+ type: "object",
781
+ required: ["databaseName", "warehouse", "query", "user", "accountName", "s3BucketName", "s3Region"],
782
+ properties: {
783
+ databaseName: {
784
+ type: "string",
785
+ description: "The name of the database to query",
786
+ },
787
+ warehouse: {
788
+ type: "string",
789
+ description: "The warehouse to use for executing the query",
790
+ },
791
+ query: {
792
+ type: "string",
793
+ description: "The SQL query to execute",
794
+ },
795
+ user: {
796
+ type: "string",
797
+ description: "The username to authenticate with",
798
+ },
799
+ accountName: {
800
+ type: "string",
801
+ description: "The name of the Snowflake account",
802
+ },
803
+ s3BucketName: {
804
+ type: "string",
805
+ description: "The name of the S3 bucket to write results to",
806
+ },
807
+ s3Region: {
808
+ type: "string",
809
+ description: "The AWS region where the S3 bucket is located",
810
+ },
811
+ outputFormat: {
812
+ type: "string",
813
+ description: "Format for the output file (json or csv, defaults to json)",
814
+ enum: ["json", "csv"],
815
+ },
816
+ },
817
+ },
818
+ output: {
819
+ type: "object",
820
+ required: ["bucketUrl", "message", "rowCount"],
821
+ properties: {
822
+ bucketUrl: {
823
+ type: "string",
824
+ description: "The URL of the S3 bucket where the results are stored",
825
+ },
826
+ message: {
827
+ type: "string",
828
+ description: "A message describing the result or error",
829
+ },
830
+ rowCount: {
831
+ type: "number",
832
+ description: "The number of rows returned by the query",
833
+ },
834
+ },
835
+ },
836
+ name: "runSnowflakeQueryWriteResultsToS3",
837
+ provider: "snowflake",
838
+ };
753
839
  exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = {
754
840
  description: "Get the latitude and longitude of a location",
755
841
  scopes: [],
@@ -13,6 +13,8 @@ export declare const AuthParamsSchema: z.ZodObject<{
13
13
  emailReplyTo: z.ZodOptional<z.ZodString>;
14
14
  emailBcc: z.ZodOptional<z.ZodString>;
15
15
  cloudId: z.ZodOptional<z.ZodString>;
16
+ awsAccessKeyId: z.ZodOptional<z.ZodString>;
17
+ awsSecretAccessKey: z.ZodOptional<z.ZodString>;
16
18
  }, "strip", z.ZodTypeAny, {
17
19
  authToken?: string | undefined;
18
20
  baseUrl?: string | undefined;
@@ -23,6 +25,8 @@ export declare const AuthParamsSchema: z.ZodObject<{
23
25
  emailReplyTo?: string | undefined;
24
26
  emailBcc?: string | undefined;
25
27
  cloudId?: string | undefined;
28
+ awsAccessKeyId?: string | undefined;
29
+ awsSecretAccessKey?: string | undefined;
26
30
  }, {
27
31
  authToken?: string | undefined;
28
32
  baseUrl?: string | undefined;
@@ -33,6 +37,8 @@ export declare const AuthParamsSchema: z.ZodObject<{
33
37
  emailReplyTo?: string | undefined;
34
38
  emailBcc?: string | undefined;
35
39
  cloudId?: string | undefined;
40
+ awsAccessKeyId?: string | undefined;
41
+ awsSecretAccessKey?: string | undefined;
36
42
  }>;
37
43
  export type AuthParamsType = z.infer<typeof AuthParamsSchema>;
38
44
  export declare const slackSendMessageParamsSchema: z.ZodObject<{
@@ -545,6 +551,19 @@ export declare const credalCallCopilotOutputSchema: z.ZodObject<{
545
551
  };
546
552
  url?: string | undefined;
547
553
  }>, "many">>;
554
+ webSearchResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
555
+ title: z.ZodString;
556
+ url: z.ZodString;
557
+ contents: z.ZodOptional<z.ZodString>;
558
+ }, "strip", z.ZodTypeAny, {
559
+ title: string;
560
+ url: string;
561
+ contents?: string | undefined;
562
+ }, {
563
+ title: string;
564
+ url: string;
565
+ contents?: string | undefined;
566
+ }>, "many">>;
548
567
  }, "strip", z.ZodTypeAny, {
549
568
  response: string;
550
569
  referencedSources?: {
@@ -565,6 +584,11 @@ export declare const credalCallCopilotOutputSchema: z.ZodObject<{
565
584
  };
566
585
  url?: string | undefined;
567
586
  }[] | undefined;
587
+ webSearchResults?: {
588
+ title: string;
589
+ url: string;
590
+ contents?: string | undefined;
591
+ }[] | undefined;
568
592
  }, {
569
593
  response: string;
570
594
  referencedSources?: {
@@ -585,6 +609,11 @@ export declare const credalCallCopilotOutputSchema: z.ZodObject<{
585
609
  };
586
610
  url?: string | undefined;
587
611
  }[] | undefined;
612
+ webSearchResults?: {
613
+ title: string;
614
+ url: string;
615
+ contents?: string | undefined;
616
+ }[] | undefined;
588
617
  }>;
589
618
  export type credalCallCopilotOutputType = z.infer<typeof credalCallCopilotOutputSchema>;
590
619
  export type credalCallCopilotFunction = ActionFunction<credalCallCopilotParamsType, AuthParamsType, credalCallCopilotOutputType>;
@@ -618,11 +647,11 @@ export declare const linkedinCreateShareLinkedinPostUrlParamsSchema: z.ZodObject
618
647
  text: z.ZodOptional<z.ZodString>;
619
648
  url: z.ZodOptional<z.ZodString>;
620
649
  }, "strip", z.ZodTypeAny, {
621
- text?: string | undefined;
622
650
  url?: string | undefined;
623
- }, {
624
651
  text?: string | undefined;
652
+ }, {
625
653
  url?: string | undefined;
654
+ text?: string | undefined;
626
655
  }>;
627
656
  export type linkedinCreateShareLinkedinPostUrlParamsType = z.infer<typeof linkedinCreateShareLinkedinPostUrlParamsSchema>;
628
657
  export declare const linkedinCreateShareLinkedinPostUrlOutputSchema: z.ZodObject<{
@@ -740,6 +769,50 @@ export declare const snowflakeGetRowByFieldValueOutputSchema: z.ZodObject<{
740
769
  }>;
741
770
  export type snowflakeGetRowByFieldValueOutputType = z.infer<typeof snowflakeGetRowByFieldValueOutputSchema>;
742
771
  export type snowflakeGetRowByFieldValueFunction = ActionFunction<snowflakeGetRowByFieldValueParamsType, AuthParamsType, snowflakeGetRowByFieldValueOutputType>;
772
+ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema: z.ZodObject<{
773
+ databaseName: z.ZodString;
774
+ warehouse: z.ZodString;
775
+ query: z.ZodString;
776
+ user: z.ZodString;
777
+ accountName: z.ZodString;
778
+ s3BucketName: z.ZodString;
779
+ s3Region: z.ZodString;
780
+ outputFormat: z.ZodOptional<z.ZodEnum<["json", "csv"]>>;
781
+ }, "strip", z.ZodTypeAny, {
782
+ query: string;
783
+ databaseName: string;
784
+ accountName: string;
785
+ user: string;
786
+ warehouse: string;
787
+ s3BucketName: string;
788
+ s3Region: string;
789
+ outputFormat?: "json" | "csv" | undefined;
790
+ }, {
791
+ query: string;
792
+ databaseName: string;
793
+ accountName: string;
794
+ user: string;
795
+ warehouse: string;
796
+ s3BucketName: string;
797
+ s3Region: string;
798
+ outputFormat?: "json" | "csv" | undefined;
799
+ }>;
800
+ export type snowflakeRunSnowflakeQueryWriteResultsToS3ParamsType = z.infer<typeof snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema>;
801
+ export declare const snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema: z.ZodObject<{
802
+ bucketUrl: z.ZodString;
803
+ message: z.ZodString;
804
+ rowCount: z.ZodNumber;
805
+ }, "strip", z.ZodTypeAny, {
806
+ message: string;
807
+ bucketUrl: string;
808
+ rowCount: number;
809
+ }, {
810
+ message: string;
811
+ bucketUrl: string;
812
+ rowCount: number;
813
+ }>;
814
+ export type snowflakeRunSnowflakeQueryWriteResultsToS3OutputType = z.infer<typeof snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema>;
815
+ export type snowflakeRunSnowflakeQueryWriteResultsToS3Function = ActionFunction<snowflakeRunSnowflakeQueryWriteResultsToS3ParamsType, AuthParamsType, snowflakeRunSnowflakeQueryWriteResultsToS3OutputType>;
743
816
  export declare const openstreetmapGetLatitudeLongitudeFromLocationParamsSchema: z.ZodObject<{
744
817
  location: z.ZodString;
745
818
  }, "strip", z.ZodTypeAny, {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.finnhubGetBasicFinancialsOutputSchema = exports.finnhubGetBasicFinancialsParamsSchema = exports.finnhubSymbolLookupOutputSchema = exports.finnhubSymbolLookupParamsSchema = exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeTweetDataWithNitterOutputSchema = exports.firecrawlScrapeTweetDataWithNitterParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xCreateShareXPostUrlOutputSchema = exports.xCreateShareXPostUrlParamsSchema = exports.linkedinCreateShareLinkedinPostUrlOutputSchema = exports.linkedinCreateShareLinkedinPostUrlParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsNearbysearchRestaurantsOutputSchema = exports.googlemapsNearbysearchRestaurantsParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceFetchPageContentOutputSchema = exports.confluenceFetchPageContentParamsSchema = exports.confluenceOverwritePageOutputSchema = exports.confluenceOverwritePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
3
+ exports.finnhubGetBasicFinancialsOutputSchema = exports.finnhubGetBasicFinancialsParamsSchema = exports.finnhubSymbolLookupOutputSchema = exports.finnhubSymbolLookupParamsSchema = exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeTweetDataWithNitterOutputSchema = exports.firecrawlScrapeTweetDataWithNitterParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema = exports.snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xCreateShareXPostUrlOutputSchema = exports.xCreateShareXPostUrlParamsSchema = exports.linkedinCreateShareLinkedinPostUrlOutputSchema = exports.linkedinCreateShareLinkedinPostUrlParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsNearbysearchRestaurantsOutputSchema = exports.googlemapsNearbysearchRestaurantsParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceFetchPageContentOutputSchema = exports.confluenceFetchPageContentParamsSchema = exports.confluenceOverwritePageOutputSchema = exports.confluenceOverwritePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.AuthParamsSchema = zod_1.z.object({
6
6
  authToken: zod_1.z.string().optional(),
@@ -12,6 +12,8 @@ exports.AuthParamsSchema = zod_1.z.object({
12
12
  emailReplyTo: zod_1.z.string().optional(),
13
13
  emailBcc: zod_1.z.string().optional(),
14
14
  cloudId: zod_1.z.string().optional(),
15
+ awsAccessKeyId: zod_1.z.string().optional(),
16
+ awsSecretAccessKey: zod_1.z.string().optional(),
15
17
  });
16
18
  exports.slackSendMessageParamsSchema = zod_1.z.object({
17
19
  channelName: zod_1.z.string().describe("The name of the Slack channel to send the message to (e.g. general, alerts)"),
@@ -185,6 +187,16 @@ exports.credalCallCopilotOutputSchema = zod_1.z.object({
185
187
  .describe("The source in the data context of the response"))
186
188
  .describe("The sources in the data context of the response")
187
189
  .optional(),
190
+ webSearchResults: zod_1.z
191
+ .array(zod_1.z
192
+ .object({
193
+ title: zod_1.z.string().describe("The title of the web search result"),
194
+ url: zod_1.z.string().describe("The url of the web search result"),
195
+ contents: zod_1.z.string().describe("The contents of the web search result").optional(),
196
+ })
197
+ .describe("The web search result in the response"))
198
+ .describe("The web search results in the response")
199
+ .optional(),
188
200
  });
189
201
  exports.zendeskCreateZendeskTicketParamsSchema = zod_1.z.object({
190
202
  subject: zod_1.z.string().describe("The subject of the ticket"),
@@ -237,6 +249,24 @@ exports.snowflakeGetRowByFieldValueOutputSchema = zod_1.z.object({
237
249
  })
238
250
  .describe("The row from the Snowflake table"),
239
251
  });
252
+ exports.snowflakeRunSnowflakeQueryWriteResultsToS3ParamsSchema = zod_1.z.object({
253
+ databaseName: zod_1.z.string().describe("The name of the database to query"),
254
+ warehouse: zod_1.z.string().describe("The warehouse to use for executing the query"),
255
+ query: zod_1.z.string().describe("The SQL query to execute"),
256
+ user: zod_1.z.string().describe("The username to authenticate with"),
257
+ accountName: zod_1.z.string().describe("The name of the Snowflake account"),
258
+ s3BucketName: zod_1.z.string().describe("The name of the S3 bucket to write results to"),
259
+ s3Region: zod_1.z.string().describe("The AWS region where the S3 bucket is located"),
260
+ outputFormat: zod_1.z
261
+ .enum(["json", "csv"])
262
+ .describe("Format for the output file (json or csv, defaults to json)")
263
+ .optional(),
264
+ });
265
+ exports.snowflakeRunSnowflakeQueryWriteResultsToS3OutputSchema = zod_1.z.object({
266
+ bucketUrl: zod_1.z.string().describe("The URL of the S3 bucket where the results are stored"),
267
+ message: zod_1.z.string().describe("A message describing the result or error"),
268
+ rowCount: zod_1.z.number().describe("The number of rows returned by the query"),
269
+ });
240
270
  exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = zod_1.z.object({
241
271
  location: zod_1.z.string().describe("The location to get the latitude and longitude of"),
242
272
  });
@@ -39,9 +39,9 @@ exports.ACTION_GROUPS = {
39
39
  description: "Action for inserting a document into a MongoDB collection",
40
40
  actions: [templates_1.mongoInsertMongoDocDefinition],
41
41
  },
42
- SNOWFLAKE_GET_ROW_BY_FIELD_VALUE: {
43
- description: "Action for getting a row from a Snowflake table by field value",
44
- actions: [templates_1.snowflakeGetRowByFieldValueDefinition],
42
+ SNOWFLAKE_ACTIONS: {
43
+ description: "Action for getting content from a Snowflake table",
44
+ actions: [templates_1.snowflakeGetRowByFieldValueDefinition, templates_1.snowflakeRunSnowflakeQueryWriteResultsToS3Definition],
45
45
  },
46
46
  JIRA_CREATE_TICKET: {
47
47
  description: "Action for creating a Jira ticket",
@@ -49,6 +49,8 @@ z.object({
49
49
  emailReplyTo: z.string().optional(),
50
50
  emailBcc: z.string().optional(),
51
51
  cloudId: z.string().optional(),
52
+ awsAccessKeyId: z.string().optional(),
53
+ awsSecretAccessKey: z.string().optional(),
52
54
  })
53
55
  `;
54
56
  function validateObject(object) {
@@ -30,6 +30,7 @@ const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
30
30
  : "Error getting response",
31
31
  referencedSources: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.referencedSources : [],
32
32
  sourcesInDataContext: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.sourcesInDataContext : [],
33
+ webSearchResults: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.webSearchResults : [],
33
34
  };
34
35
  });
35
36
  exports.default = callCopilot;
@@ -0,0 +1,3 @@
1
+ import { snowflakeRunSnowflakeQueryWriteResultsToS3Function } from "../../autogen/types";
2
+ declare const runSnowflakeQueryWriteResultsToS3: snowflakeRunSnowflakeQueryWriteResultsToS3Function;
3
+ export default runSnowflakeQueryWriteResultsToS3;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const snowflake_sdk_1 = __importDefault(require("snowflake-sdk"));
16
+ const crypto_1 = __importDefault(require("crypto"));
17
+ const client_s3_1 = require("@aws-sdk/client-s3");
18
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
19
+ const uuid_1 = require("uuid");
20
+ // Only log errors.
21
+ snowflake_sdk_1.default.configure({ logLevel: "ERROR" });
22
+ const runSnowflakeQueryWriteResultsToS3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
23
+ const { databaseName, warehouse, query, user, accountName, s3BucketName, s3Region, outputFormat = "json" } = params;
24
+ const { apiKey: privateKey, awsAccessKeyId, awsSecretAccessKey } = authParams;
25
+ if (!privateKey) {
26
+ throw new Error("Snowflake private key is required");
27
+ }
28
+ if (!awsAccessKeyId || !awsSecretAccessKey) {
29
+ throw new Error("AWS credentials are required");
30
+ }
31
+ if (!accountName || !user || !databaseName || !warehouse || !query || !s3BucketName) {
32
+ throw new Error("Missing required parameters for Snowflake query or S3 destination");
33
+ }
34
+ const getPrivateKeyCorrectFormat = (privateKey) => {
35
+ const buffer = Buffer.from(privateKey);
36
+ const privateKeyObject = crypto_1.default.createPrivateKey({
37
+ key: buffer,
38
+ format: "pem",
39
+ passphrase: "password",
40
+ });
41
+ const privateKeyCorrectFormat = privateKeyObject.export({
42
+ format: "pem",
43
+ type: "pkcs8",
44
+ });
45
+ return privateKeyCorrectFormat.toString();
46
+ };
47
+ const executeQueryAndFormatData = () => __awaiter(void 0, void 0, void 0, function* () {
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ const queryResults = yield new Promise((resolve, reject) => {
50
+ connection.execute({
51
+ sqlText: query,
52
+ complete: (err, stmt, rows) => {
53
+ if (err) {
54
+ return reject(err);
55
+ }
56
+ return resolve(rows || []);
57
+ },
58
+ });
59
+ });
60
+ // Format the results based on the output format
61
+ let formattedData;
62
+ if (outputFormat.toLowerCase() === "csv") {
63
+ if (queryResults.length === 0) {
64
+ formattedData = "";
65
+ }
66
+ else {
67
+ const headers = Object.keys(queryResults[0]).join(",");
68
+ const rows = queryResults.map(row => Object.values(row)
69
+ .map(value => (typeof value === "object" && value !== null ? JSON.stringify(value) : value))
70
+ .join(","));
71
+ formattedData = [headers, ...rows].join("\n");
72
+ }
73
+ }
74
+ else {
75
+ // Default to JSON
76
+ formattedData = JSON.stringify(queryResults, null, 2);
77
+ }
78
+ return { formattedData, resultsLength: queryResults.length };
79
+ });
80
+ const uploadToS3AndGetURL = (formattedData) => __awaiter(void 0, void 0, void 0, function* () {
81
+ // Create S3 client
82
+ const s3Client = new client_s3_1.S3Client({
83
+ region: s3Region,
84
+ credentials: {
85
+ accessKeyId: awsAccessKeyId,
86
+ secretAccessKey: awsSecretAccessKey,
87
+ },
88
+ });
89
+ const contentType = outputFormat.toLowerCase() === "csv" ? "text/csv" : "application/json";
90
+ const fileExtension = outputFormat.toLowerCase() === "csv" ? "csv" : "json";
91
+ const finalKey = `${databaseName}/${(0, uuid_1.v4)()}.${fileExtension}`;
92
+ // Upload to S3 without ACL
93
+ const uploadCommand = new client_s3_1.PutObjectCommand({
94
+ Bucket: s3BucketName,
95
+ Key: finalKey,
96
+ Body: formattedData,
97
+ ContentType: contentType,
98
+ });
99
+ yield s3Client.send(uploadCommand);
100
+ // Generate a presigned URL (valid for an hour)
101
+ const getObjectCommand = new client_s3_1.GetObjectCommand({
102
+ Bucket: s3BucketName,
103
+ Key: finalKey,
104
+ });
105
+ const presignedUrl = yield (0, s3_request_presigner_1.getSignedUrl)(s3Client, getObjectCommand, { expiresIn: 3600 });
106
+ return presignedUrl;
107
+ });
108
+ // Process the private key
109
+ const privateKeyCorrectFormatString = getPrivateKeyCorrectFormat(privateKey);
110
+ // Set up a connection using snowflake-sdk
111
+ const connection = snowflake_sdk_1.default.createConnection({
112
+ account: accountName,
113
+ username: user,
114
+ privateKey: privateKeyCorrectFormatString,
115
+ authenticator: "SNOWFLAKE_JWT",
116
+ role: "ACCOUNTADMIN",
117
+ warehouse: warehouse,
118
+ database: databaseName,
119
+ });
120
+ try {
121
+ // Connect to Snowflake
122
+ yield new Promise((resolve, reject) => {
123
+ connection.connect((err, conn) => {
124
+ if (err) {
125
+ console.error("Unable to connect to Snowflake:", err.message);
126
+ return reject(err);
127
+ }
128
+ resolve(conn);
129
+ });
130
+ });
131
+ const { formattedData, resultsLength } = yield executeQueryAndFormatData();
132
+ const presignedUrl = yield uploadToS3AndGetURL(formattedData);
133
+ // Return fields to match schema definition
134
+ connection.destroy(err => {
135
+ if (err) {
136
+ console.log("Failed to disconnect from Snowflake:", err);
137
+ }
138
+ });
139
+ return {
140
+ bucketUrl: presignedUrl,
141
+ message: `Query results successfully written to S3. URL valid for 1 hour.`,
142
+ rowCount: resultsLength,
143
+ };
144
+ }
145
+ catch (error) {
146
+ connection.destroy(err => {
147
+ if (err) {
148
+ console.log("Failed to disconnect from Snowflake:", err);
149
+ }
150
+ });
151
+ throw Error(`An error occurred: ${error}`);
152
+ }
153
+ });
154
+ exports.default = runSnowflakeQueryWriteResultsToS3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,6 +38,7 @@
38
38
  "typescript-eslint": "^8.18.0"
39
39
  },
40
40
  "dependencies": {
41
+ "@aws-sdk/s3-request-presigner": "^3.758.0",
41
42
  "@credal/sdk": "^0.0.21",
42
43
  "@mendable/firecrawl-js": "^1.19.0",
43
44
  "@slack/web-api": "^7.8.0",
@@ -49,6 +50,7 @@
49
50
  "resend": "^4.1.2",
50
51
  "snowflake-sdk": "^2.0.2",
51
52
  "ts-node": "^10.9.2",
53
+ "uuid": "^11.1.0",
52
54
  "zod": "^3.24.1"
53
55
  }
54
56
  }