@credal/actions 0.1.16 → 0.1.17

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.
@@ -23,7 +23,7 @@ const sendEmail_1 = __importDefault(require("./providers/resend/sendEmail"));
23
23
  const createSharePostLinkedinUrl_1 = __importDefault(require("./providers/linkedin/createSharePostLinkedinUrl"));
24
24
  const createNewGoogleDoc_1 = __importDefault(require("./providers/google-oauth/createNewGoogleDoc"));
25
25
  const createXSharePostUrl_1 = __importDefault(require("./providers/x/createXSharePostUrl"));
26
- const scrapeTweetDataWithNitter_1 = __importDefault(require("./providers/x/scrapeTweetDataWithNitter"));
26
+ const scrapeTweetDataWithNitter_1 = __importDefault(require("./providers/firecrawl/scrapeTweetDataWithNitter"));
27
27
  exports.ActionMapper = {
28
28
  math: {
29
29
  add: {
@@ -125,6 +125,11 @@ exports.ActionMapper = {
125
125
  paramsSchema: types_1.firecrawlScrapeUrlParamsSchema,
126
126
  outputSchema: types_1.firecrawlScrapeUrlOutputSchema,
127
127
  },
128
+ scrapeTweetDataWithNitter: {
129
+ fn: scrapeTweetDataWithNitter_1.default,
130
+ paramsSchema: types_1.firecrawlScrapeTweetDataWithNitterParamsSchema,
131
+ outputSchema: types_1.firecrawlScrapeTweetDataWithNitterOutputSchema,
132
+ },
128
133
  },
129
134
  resend: {
130
135
  sendEmail: {
@@ -146,10 +151,5 @@ exports.ActionMapper = {
146
151
  paramsSchema: types_1.xCreateShareXPostUrlParamsSchema,
147
152
  outputSchema: types_1.xCreateShareXPostUrlOutputSchema,
148
153
  },
149
- scrapePostDataWithNitter: {
150
- fn: scrapeTweetDataWithNitter_1.default,
151
- paramsSchema: types_1.xScrapePostDataWithNitterParamsSchema,
152
- outputSchema: types_1.xScrapePostDataWithNitterOutputSchema,
153
- },
154
154
  },
155
155
  };
@@ -10,11 +10,11 @@ export declare const credalCallCopilotDefinition: ActionTemplate;
10
10
  export declare const zendeskCreateZendeskTicketDefinition: ActionTemplate;
11
11
  export declare const linkedinCreateShareLinkedinPostUrlDefinition: ActionTemplate;
12
12
  export declare const xCreateShareXPostUrlDefinition: ActionTemplate;
13
- export declare const xScrapePostDataWithNitterDefinition: ActionTemplate;
14
13
  export declare const mongoInsertMongoDocDefinition: ActionTemplate;
15
14
  export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
16
15
  export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
17
16
  export declare const nwsGetForecastForLocationDefinition: ActionTemplate;
18
17
  export declare const firecrawlScrapeUrlDefinition: ActionTemplate;
18
+ export declare const firecrawlScrapeTweetDataWithNitterDefinition: ActionTemplate;
19
19
  export declare const resendSendEmailDefinition: ActionTemplate;
20
20
  export declare const googleOauthCreateNewGoogleDocDefinition: ActionTemplate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.googleOauthCreateNewGoogleDocDefinition = exports.resendSendEmailDefinition = exports.firecrawlScrapeUrlDefinition = exports.nwsGetForecastForLocationDefinition = exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.xScrapePostDataWithNitterDefinition = exports.xCreateShareXPostUrlDefinition = exports.linkedinCreateShareLinkedinPostUrlDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsNearbysearchRestaurantsDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
3
+ 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.confluenceUpdatePageDefinition = 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"],
@@ -549,32 +549,6 @@ exports.xCreateShareXPostUrlDefinition = {
549
549
  name: "createShareXPostUrl",
550
550
  provider: "x",
551
551
  };
552
- exports.xScrapePostDataWithNitterDefinition = {
553
- description: "Given A tweet URL scrape the tweet data with nitter+firecrawl",
554
- scopes: [],
555
- parameters: {
556
- type: "object",
557
- required: ["tweetUrl"],
558
- properties: {
559
- tweetUrl: {
560
- type: "string",
561
- description: "The url for the X(formerly twitter) post",
562
- },
563
- },
564
- },
565
- output: {
566
- type: "object",
567
- required: ["text"],
568
- properties: {
569
- text: {
570
- type: "string",
571
- description: "The text in the tweet URL",
572
- },
573
- },
574
- },
575
- name: "scrapePostDataWithNitter",
576
- provider: "x",
577
- };
578
552
  exports.mongoInsertMongoDocDefinition = {
579
553
  description: "Insert a document into a MongoDB collection",
580
554
  scopes: [],
@@ -787,6 +761,32 @@ exports.firecrawlScrapeUrlDefinition = {
787
761
  name: "scrapeUrl",
788
762
  provider: "firecrawl",
789
763
  };
764
+ exports.firecrawlScrapeTweetDataWithNitterDefinition = {
765
+ description: "Given A tweet URL scrape the tweet data with nitter+firecrawl",
766
+ scopes: [],
767
+ parameters: {
768
+ type: "object",
769
+ required: ["tweetUrl"],
770
+ properties: {
771
+ tweetUrl: {
772
+ type: "string",
773
+ description: "The url for the X(formerly twitter) post",
774
+ },
775
+ },
776
+ },
777
+ output: {
778
+ type: "object",
779
+ required: ["text"],
780
+ properties: {
781
+ text: {
782
+ type: "string",
783
+ description: "The text in the tweet URL",
784
+ },
785
+ },
786
+ },
787
+ name: "scrapeTweetDataWithNitter",
788
+ provider: "firecrawl",
789
+ };
790
790
  exports.resendSendEmailDefinition = {
791
791
  description: "Send an email using Resend",
792
792
  scopes: [],
@@ -542,23 +542,6 @@ export declare const xCreateShareXPostUrlOutputSchema: z.ZodObject<{
542
542
  }>;
543
543
  export type xCreateShareXPostUrlOutputType = z.infer<typeof xCreateShareXPostUrlOutputSchema>;
544
544
  export type xCreateShareXPostUrlFunction = ActionFunction<xCreateShareXPostUrlParamsType, AuthParamsType, xCreateShareXPostUrlOutputType>;
545
- export declare const xScrapePostDataWithNitterParamsSchema: z.ZodObject<{
546
- tweetUrl: z.ZodString;
547
- }, "strip", z.ZodTypeAny, {
548
- tweetUrl: string;
549
- }, {
550
- tweetUrl: string;
551
- }>;
552
- export type xScrapePostDataWithNitterParamsType = z.infer<typeof xScrapePostDataWithNitterParamsSchema>;
553
- export declare const xScrapePostDataWithNitterOutputSchema: z.ZodObject<{
554
- text: z.ZodString;
555
- }, "strip", z.ZodTypeAny, {
556
- text: string;
557
- }, {
558
- text: string;
559
- }>;
560
- export type xScrapePostDataWithNitterOutputType = z.infer<typeof xScrapePostDataWithNitterOutputSchema>;
561
- export type xScrapePostDataWithNitterFunction = ActionFunction<xScrapePostDataWithNitterParamsType, AuthParamsType, xScrapePostDataWithNitterOutputType>;
562
545
  export declare const mongoInsertMongoDocParamsSchema: z.ZodObject<{
563
546
  databaseName: z.ZodString;
564
547
  collectionName: z.ZodString;
@@ -733,6 +716,23 @@ export declare const firecrawlScrapeUrlOutputSchema: z.ZodObject<{
733
716
  }>;
734
717
  export type firecrawlScrapeUrlOutputType = z.infer<typeof firecrawlScrapeUrlOutputSchema>;
735
718
  export type firecrawlScrapeUrlFunction = ActionFunction<firecrawlScrapeUrlParamsType, AuthParamsType, firecrawlScrapeUrlOutputType>;
719
+ export declare const firecrawlScrapeTweetDataWithNitterParamsSchema: z.ZodObject<{
720
+ tweetUrl: z.ZodString;
721
+ }, "strip", z.ZodTypeAny, {
722
+ tweetUrl: string;
723
+ }, {
724
+ tweetUrl: string;
725
+ }>;
726
+ export type firecrawlScrapeTweetDataWithNitterParamsType = z.infer<typeof firecrawlScrapeTweetDataWithNitterParamsSchema>;
727
+ export declare const firecrawlScrapeTweetDataWithNitterOutputSchema: z.ZodObject<{
728
+ text: z.ZodString;
729
+ }, "strip", z.ZodTypeAny, {
730
+ text: string;
731
+ }, {
732
+ text: string;
733
+ }>;
734
+ export type firecrawlScrapeTweetDataWithNitterOutputType = z.infer<typeof firecrawlScrapeTweetDataWithNitterOutputSchema>;
735
+ export type firecrawlScrapeTweetDataWithNitterFunction = ActionFunction<firecrawlScrapeTweetDataWithNitterParamsType, AuthParamsType, firecrawlScrapeTweetDataWithNitterOutputType>;
736
736
  export declare const resendSendEmailParamsSchema: z.ZodObject<{
737
737
  to: z.ZodString;
738
738
  subject: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.googleOauthCreateNewGoogleDocOutputSchema = exports.googleOauthCreateNewGoogleDocParamsSchema = exports.resendSendEmailOutputSchema = exports.resendSendEmailParamsSchema = exports.firecrawlScrapeUrlOutputSchema = exports.firecrawlScrapeUrlParamsSchema = exports.nwsGetForecastForLocationOutputSchema = exports.nwsGetForecastForLocationParamsSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.xScrapePostDataWithNitterOutputSchema = exports.xScrapePostDataWithNitterParamsSchema = 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.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
3
+ 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.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = 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(),
@@ -168,12 +168,6 @@ exports.xCreateShareXPostUrlParamsSchema = zod_1.z.object({
168
168
  exports.xCreateShareXPostUrlOutputSchema = zod_1.z.object({
169
169
  xUrl: zod_1.z.string().describe("The share post X(formerly twitter) URL"),
170
170
  });
171
- exports.xScrapePostDataWithNitterParamsSchema = zod_1.z.object({
172
- tweetUrl: zod_1.z.string().describe("The url for the X(formerly twitter) post"),
173
- });
174
- exports.xScrapePostDataWithNitterOutputSchema = zod_1.z.object({
175
- text: zod_1.z.string().describe("The text in the tweet URL"),
176
- });
177
171
  exports.mongoInsertMongoDocParamsSchema = zod_1.z.object({
178
172
  databaseName: zod_1.z.string().describe("Database to connect to"),
179
173
  collectionName: zod_1.z.string().describe("Collection to insert the document into"),
@@ -228,6 +222,12 @@ exports.nwsGetForecastForLocationOutputSchema = zod_1.z.object({
228
222
  });
229
223
  exports.firecrawlScrapeUrlParamsSchema = zod_1.z.object({ url: zod_1.z.string().describe("The URL to scrape") });
230
224
  exports.firecrawlScrapeUrlOutputSchema = zod_1.z.object({ content: zod_1.z.string().describe("The content of the URL") });
225
+ exports.firecrawlScrapeTweetDataWithNitterParamsSchema = zod_1.z.object({
226
+ tweetUrl: zod_1.z.string().describe("The url for the X(formerly twitter) post"),
227
+ });
228
+ exports.firecrawlScrapeTweetDataWithNitterOutputSchema = zod_1.z.object({
229
+ text: zod_1.z.string().describe("The text in the tweet URL"),
230
+ });
231
231
  exports.resendSendEmailParamsSchema = zod_1.z.object({
232
232
  to: zod_1.z.string().describe("The email address to send the email to"),
233
233
  subject: zod_1.z.string().describe("The subject of the email"),
@@ -57,7 +57,7 @@ exports.ACTION_GROUPS = {
57
57
  },
58
58
  FIRECRAWL: {
59
59
  description: "Actions for interacting with Firecrawl",
60
- actions: [templates_1.firecrawlScrapeUrlDefinition],
60
+ actions: [templates_1.firecrawlScrapeUrlDefinition, templates_1.firecrawlScrapeTweetDataWithNitterDefinition],
61
61
  },
62
62
  RESEND: {
63
63
  description: "Action for sending an email",
@@ -65,6 +65,6 @@ exports.ACTION_GROUPS = {
65
65
  },
66
66
  X: {
67
67
  description: "Actions for interacting with X(formerly twitter)",
68
- actions: [templates_1.xCreateShareXPostUrlDefinition, templates_1.xScrapePostDataWithNitterDefinition],
68
+ actions: [templates_1.xCreateShareXPostUrlDefinition],
69
69
  },
70
70
  };
@@ -0,0 +1,3 @@
1
+ import { firecrawlScrapeTweetDataWithNitterFunction } from "../../autogen/types";
2
+ declare const scrapeTweetDataWithNitter: firecrawlScrapeTweetDataWithNitterFunction;
3
+ export default scrapeTweetDataWithNitter;
@@ -0,0 +1,45 @@
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 firecrawl_js_1 = __importDefault(require("@mendable/firecrawl-js"));
16
+ const scrapeTweetDataWithNitter = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
17
+ const tweetUrlRegex = /^(?:https?:\/\/)?(?:www\.)?(?:twitter\.com|x\.com)\/([a-zA-Z0-9_]+)\/status\/(\d+)(?:\?.*)?$/;
18
+ if (!tweetUrlRegex.test(params.tweetUrl)) {
19
+ throw new Error("Invalid tweet URL. Expected format: https://twitter.com/username/status/id or https://x.com/username/status/id");
20
+ }
21
+ const nitterUrl = params.tweetUrl.replace(/^(?:https?:\/\/)?(?:www\.)?(?:twitter\.com|x\.com)/i, "https://nitter.net");
22
+ // Initialize Firecrawl
23
+ if (!authParams.apiKey) {
24
+ throw new Error("API key is required for X+Nitter+Firecrawl");
25
+ }
26
+ const firecrawl = new firecrawl_js_1.default({
27
+ apiKey: authParams.apiKey,
28
+ });
29
+ try {
30
+ // Scrape the Nitter URL
31
+ const result = yield firecrawl.scrapeUrl(nitterUrl);
32
+ if (!result.success) {
33
+ throw new Error(`Failed to scrape tweet: ${result.error || "Unknown error"}`);
34
+ }
35
+ // Extract the tweet text from the scraped content - simple approach - in practice, you might need more robust parsing based on nitter html structure
36
+ const tweetContent = result.markdown;
37
+ return {
38
+ text: tweetContent || "Error scraping with firecrawl",
39
+ };
40
+ }
41
+ catch (error) {
42
+ throw new Error(`Error scraping tweet: ${error instanceof Error ? error.message : error}`);
43
+ }
44
+ });
45
+ exports.default = scrapeTweetDataWithNitter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",