@credal/actions 0.1.15 → 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.
@@ -22,6 +22,8 @@ const scrapeUrl_1 = __importDefault(require("./providers/firecrawl/scrapeUrl"));
22
22
  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
+ const createXSharePostUrl_1 = __importDefault(require("./providers/x/createXSharePostUrl"));
26
+ const scrapeTweetDataWithNitter_1 = __importDefault(require("./providers/firecrawl/scrapeTweetDataWithNitter"));
25
27
  exports.ActionMapper = {
26
28
  math: {
27
29
  add: {
@@ -123,6 +125,11 @@ exports.ActionMapper = {
123
125
  paramsSchema: types_1.firecrawlScrapeUrlParamsSchema,
124
126
  outputSchema: types_1.firecrawlScrapeUrlOutputSchema,
125
127
  },
128
+ scrapeTweetDataWithNitter: {
129
+ fn: scrapeTweetDataWithNitter_1.default,
130
+ paramsSchema: types_1.firecrawlScrapeTweetDataWithNitterParamsSchema,
131
+ outputSchema: types_1.firecrawlScrapeTweetDataWithNitterOutputSchema,
132
+ },
126
133
  },
127
134
  resend: {
128
135
  sendEmail: {
@@ -138,4 +145,11 @@ exports.ActionMapper = {
138
145
  outputSchema: types_1.googleOauthCreateNewGoogleDocOutputSchema,
139
146
  },
140
147
  },
148
+ x: {
149
+ createShareXPostUrl: {
150
+ fn: createXSharePostUrl_1.default,
151
+ paramsSchema: types_1.xCreateShareXPostUrlParamsSchema,
152
+ outputSchema: types_1.xCreateShareXPostUrlOutputSchema,
153
+ },
154
+ },
141
155
  };
@@ -9,10 +9,12 @@ export declare const googlemapsNearbysearchRestaurantsDefinition: ActionTemplate
9
9
  export declare const credalCallCopilotDefinition: ActionTemplate;
10
10
  export declare const zendeskCreateZendeskTicketDefinition: ActionTemplate;
11
11
  export declare const linkedinCreateShareLinkedinPostUrlDefinition: ActionTemplate;
12
+ export declare const xCreateShareXPostUrlDefinition: ActionTemplate;
12
13
  export declare const mongoInsertMongoDocDefinition: ActionTemplate;
13
14
  export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
14
15
  export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
15
16
  export declare const nwsGetForecastForLocationDefinition: ActionTemplate;
16
17
  export declare const firecrawlScrapeUrlDefinition: ActionTemplate;
18
+ export declare const firecrawlScrapeTweetDataWithNitterDefinition: ActionTemplate;
17
19
  export declare const resendSendEmailDefinition: ActionTemplate;
18
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.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"],
@@ -504,6 +504,51 @@ exports.linkedinCreateShareLinkedinPostUrlDefinition = {
504
504
  name: "createShareLinkedinPostUrl",
505
505
  provider: "linkedin",
506
506
  };
507
+ exports.xCreateShareXPostUrlDefinition = {
508
+ description: "Create a share X (formerly twitter) post link",
509
+ scopes: [],
510
+ parameters: {
511
+ type: "object",
512
+ required: ["text"],
513
+ properties: {
514
+ text: {
515
+ type: "string",
516
+ description: "The text for the X(formerly twitter) post",
517
+ },
518
+ url: {
519
+ type: "string",
520
+ description: "The url for the X(formerly twitter) post",
521
+ },
522
+ hashtag: {
523
+ type: "array",
524
+ description: "List of hashtags to include in the X post",
525
+ items: {
526
+ type: "string",
527
+ },
528
+ },
529
+ via: {
530
+ type: "string",
531
+ description: "The twitter username to associate with the tweet",
532
+ },
533
+ inReplyTo: {
534
+ type: "string",
535
+ description: "The tweet ID to reply to",
536
+ },
537
+ },
538
+ },
539
+ output: {
540
+ type: "object",
541
+ required: ["xUrl"],
542
+ properties: {
543
+ xUrl: {
544
+ type: "string",
545
+ description: "The share post X(formerly twitter) URL",
546
+ },
547
+ },
548
+ },
549
+ name: "createShareXPostUrl",
550
+ provider: "x",
551
+ };
507
552
  exports.mongoInsertMongoDocDefinition = {
508
553
  description: "Insert a document into a MongoDB collection",
509
554
  scopes: [],
@@ -716,6 +761,32 @@ exports.firecrawlScrapeUrlDefinition = {
716
761
  name: "scrapeUrl",
717
762
  provider: "firecrawl",
718
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
+ };
719
790
  exports.resendSendEmailDefinition = {
720
791
  description: "Send an email using Resend",
721
792
  scopes: [],
@@ -513,6 +513,35 @@ export declare const linkedinCreateShareLinkedinPostUrlOutputSchema: z.ZodObject
513
513
  }>;
514
514
  export type linkedinCreateShareLinkedinPostUrlOutputType = z.infer<typeof linkedinCreateShareLinkedinPostUrlOutputSchema>;
515
515
  export type linkedinCreateShareLinkedinPostUrlFunction = ActionFunction<linkedinCreateShareLinkedinPostUrlParamsType, AuthParamsType, linkedinCreateShareLinkedinPostUrlOutputType>;
516
+ export declare const xCreateShareXPostUrlParamsSchema: z.ZodObject<{
517
+ text: z.ZodString;
518
+ url: z.ZodOptional<z.ZodString>;
519
+ hashtag: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
520
+ via: z.ZodOptional<z.ZodString>;
521
+ inReplyTo: z.ZodOptional<z.ZodString>;
522
+ }, "strip", z.ZodTypeAny, {
523
+ text: string;
524
+ url?: string | undefined;
525
+ hashtag?: string[] | undefined;
526
+ via?: string | undefined;
527
+ inReplyTo?: string | undefined;
528
+ }, {
529
+ text: string;
530
+ url?: string | undefined;
531
+ hashtag?: string[] | undefined;
532
+ via?: string | undefined;
533
+ inReplyTo?: string | undefined;
534
+ }>;
535
+ export type xCreateShareXPostUrlParamsType = z.infer<typeof xCreateShareXPostUrlParamsSchema>;
536
+ export declare const xCreateShareXPostUrlOutputSchema: z.ZodObject<{
537
+ xUrl: z.ZodString;
538
+ }, "strip", z.ZodTypeAny, {
539
+ xUrl: string;
540
+ }, {
541
+ xUrl: string;
542
+ }>;
543
+ export type xCreateShareXPostUrlOutputType = z.infer<typeof xCreateShareXPostUrlOutputSchema>;
544
+ export type xCreateShareXPostUrlFunction = ActionFunction<xCreateShareXPostUrlParamsType, AuthParamsType, xCreateShareXPostUrlOutputType>;
516
545
  export declare const mongoInsertMongoDocParamsSchema: z.ZodObject<{
517
546
  databaseName: z.ZodString;
518
547
  collectionName: z.ZodString;
@@ -687,6 +716,23 @@ export declare const firecrawlScrapeUrlOutputSchema: z.ZodObject<{
687
716
  }>;
688
717
  export type firecrawlScrapeUrlOutputType = z.infer<typeof firecrawlScrapeUrlOutputSchema>;
689
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>;
690
736
  export declare const resendSendEmailParamsSchema: z.ZodObject<{
691
737
  to: z.ZodString;
692
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.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(),
@@ -158,6 +158,16 @@ exports.linkedinCreateShareLinkedinPostUrlParamsSchema = zod_1.z.object({
158
158
  exports.linkedinCreateShareLinkedinPostUrlOutputSchema = zod_1.z.object({
159
159
  linkedinUrl: zod_1.z.string().describe("The share post linkedin URL"),
160
160
  });
161
+ exports.xCreateShareXPostUrlParamsSchema = zod_1.z.object({
162
+ text: zod_1.z.string().describe("The text for the X(formerly twitter) post"),
163
+ url: zod_1.z.string().describe("The url for the X(formerly twitter) post").optional(),
164
+ hashtag: zod_1.z.array(zod_1.z.string()).describe("List of hashtags to include in the X post").optional(),
165
+ via: zod_1.z.string().describe("The twitter username to associate with the tweet").optional(),
166
+ inReplyTo: zod_1.z.string().describe("The tweet ID to reply to").optional(),
167
+ });
168
+ exports.xCreateShareXPostUrlOutputSchema = zod_1.z.object({
169
+ xUrl: zod_1.z.string().describe("The share post X(formerly twitter) URL"),
170
+ });
161
171
  exports.mongoInsertMongoDocParamsSchema = zod_1.z.object({
162
172
  databaseName: zod_1.z.string().describe("Database to connect to"),
163
173
  collectionName: zod_1.z.string().describe("Collection to insert the document into"),
@@ -212,6 +222,12 @@ exports.nwsGetForecastForLocationOutputSchema = zod_1.z.object({
212
222
  });
213
223
  exports.firecrawlScrapeUrlParamsSchema = zod_1.z.object({ url: zod_1.z.string().describe("The URL to scrape") });
214
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
+ });
215
231
  exports.resendSendEmailParamsSchema = zod_1.z.object({
216
232
  to: zod_1.z.string().describe("The email address to send the email to"),
217
233
  subject: zod_1.z.string().describe("The subject of the email"),
@@ -57,10 +57,14 @@ 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",
64
64
  actions: [templates_1.resendSendEmailDefinition],
65
65
  },
66
+ X: {
67
+ description: "Actions for interacting with X(formerly twitter)",
68
+ actions: [templates_1.xCreateShareXPostUrlDefinition],
69
+ },
66
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;
@@ -0,0 +1,3 @@
1
+ import { googlemapsNearbysearchFunction } from "../../autogen/types";
2
+ declare const nearbysearch: googlemapsNearbysearchFunction;
3
+ export default nearbysearch;
@@ -0,0 +1,96 @@
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 axios_1 = __importDefault(require("axios"));
16
+ const types_1 = require("../../autogen/types");
17
+ const INCLUDED_TYPES = [
18
+ "monument",
19
+ "museum",
20
+ "art_gallery",
21
+ "sculpture",
22
+ "cultural_landmark",
23
+ "historical_place",
24
+ "performing_arts_theater",
25
+ "university",
26
+ "aquarium",
27
+ "botanical_garden",
28
+ "comedy_club",
29
+ "park",
30
+ "movie_theater",
31
+ "national_park",
32
+ "garden",
33
+ "night_club",
34
+ "tourist_attraction",
35
+ "water_park",
36
+ "zoo",
37
+ "bar",
38
+ "restaurant",
39
+ "food_court",
40
+ "bakery",
41
+ "cafe",
42
+ "coffee_shop",
43
+ "pub",
44
+ "wine_bar",
45
+ "spa",
46
+ "beach",
47
+ "market",
48
+ "shopping_mall",
49
+ "stadium",
50
+ ];
51
+ const nearbysearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
52
+ const url = `https://places.googleapis.com/v1/places:searchNearby`;
53
+ const fieldMask = [
54
+ "places.displayName",
55
+ "places.formattedAddress",
56
+ "places.priceLevel",
57
+ "places.rating",
58
+ "places.primaryTypeDisplayName",
59
+ "places.editorialSummary",
60
+ "places.regularOpeningHours",
61
+ ].join(",");
62
+ const response = yield axios_1.default.post(url, {
63
+ maxResultCount: 20,
64
+ includedTypes: INCLUDED_TYPES,
65
+ locationRestriction: {
66
+ circle: {
67
+ center: {
68
+ latitude: params.latitude,
69
+ longitude: params.longitude,
70
+ },
71
+ radius: 10000,
72
+ },
73
+ },
74
+ }, {
75
+ headers: {
76
+ "X-Goog-Api-Key": authParams.apiKey,
77
+ "X-Goog-FieldMask": fieldMask,
78
+ "Content-Type": "application/json",
79
+ },
80
+ });
81
+ return types_1.googlemapsNearbysearchOutputSchema.parse({
82
+ results: response.data.places.map((place) => {
83
+ var _a, _b;
84
+ return ({
85
+ name: place.displayName.text,
86
+ address: place.formattedAddress,
87
+ priceLevel: place.priceLevel,
88
+ rating: place.rating,
89
+ primaryType: place.primaryTypeDisplayName.text,
90
+ editorialSummary: ((_a = place.editorialSummary) === null || _a === void 0 ? void 0 : _a.text) || "",
91
+ openingHours: ((_b = place.regularOpeningHours) === null || _b === void 0 ? void 0 : _b.weekdayDescriptions.join("\n")) || "",
92
+ });
93
+ }),
94
+ });
95
+ });
96
+ exports.default = nearbysearch;
@@ -0,0 +1,3 @@
1
+ import { xCreateShareXPostUrlFunction } from "../../autogen/types";
2
+ declare const createXSharePostUrl: xCreateShareXPostUrlFunction;
3
+ export default createXSharePostUrl;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const createXSharePostUrl = ({ params, }) => {
4
+ const baseUrl = "https://twitter.com/intent/tweet";
5
+ const queryParams = new URLSearchParams();
6
+ // Add text parameter (required) with encoding
7
+ if (params.text) {
8
+ queryParams.append("text", params.text + "\n");
9
+ }
10
+ // Add url parameter if it exists
11
+ if (params.url) {
12
+ queryParams.append("url", params.url);
13
+ }
14
+ // Add hashtags parameter if it exists
15
+ if (params.hashtag && params.hashtag.length > 0) {
16
+ queryParams.append("hashtags", params.hashtag.join(","));
17
+ }
18
+ // Add via parameter if it exists
19
+ if (params.via) {
20
+ queryParams.append("via", params.via);
21
+ }
22
+ // Add in_reply_to parameter if it exists
23
+ if (params.inReplyTo) {
24
+ queryParams.append("in_reply_to", params.inReplyTo);
25
+ }
26
+ // Build the final URL
27
+ const shareUrl = queryParams.toString() ? `${baseUrl}?${queryParams.toString()}` : baseUrl;
28
+ return Promise.resolve({
29
+ xUrl: shareUrl,
30
+ });
31
+ };
32
+ exports.default = createXSharePostUrl;
@@ -0,0 +1,3 @@
1
+ import { xScrapePostDataWithNitterFunction } from "../../autogen/types";
2
+ declare const scrapeTweetDataWithNitter: xScrapePostDataWithNitterFunction;
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.15",
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",
@@ -1,23 +0,0 @@
1
- declare const axios: any;
2
- declare const WORKDAY_BASE_URL = "https://your-workday-url/ccx/service/YOUR_TENANT/Absence_Management/v43.2";
3
- declare const TOKEN_URL = "https://your-workday-url/oauth2/YOUR_TENANT/token";
4
- declare const CLIENT_ID = "your-client-id";
5
- declare const CLIENT_SECRET = "your-client-secret";
6
- /**
7
- * Fetches an OAuth 2.0 access token from Workday.
8
- */
9
- declare function getAccessToken(): Promise<any>;
10
- /**
11
- * Submits a time-off request to Workday.
12
- * @param {Object} params - Time-off details.
13
- * @param {string} params.workerId - Worker's ID in Workday.
14
- * @param {string} params.startDate - Start date (YYYY-MM-DD).
15
- * @param {string} params.endDate - End date (YYYY-MM-DD).
16
- * @param {string} params.timeOffType - Time-off type (e.g., "SICK_LEAVE").
17
- */
18
- declare function submitTimeOff({ workerId, startDate, endDate, timeOffType }: {
19
- workerId: any;
20
- startDate: any;
21
- endDate: any;
22
- timeOffType: any;
23
- }): Promise<any>;
@@ -1,88 +0,0 @@
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
- const axios = require("axios");
12
- const WORKDAY_BASE_URL = "https://your-workday-url/ccx/service/YOUR_TENANT/Absence_Management/v43.2";
13
- const TOKEN_URL = "https://your-workday-url/oauth2/YOUR_TENANT/token"; // OAuth token endpoint
14
- const CLIENT_ID = "your-client-id";
15
- const CLIENT_SECRET = "your-client-secret";
16
- /**
17
- * Fetches an OAuth 2.0 access token from Workday.
18
- */
19
- function getAccessToken() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- var _a;
22
- try {
23
- const response = yield axios.post(TOKEN_URL, new URLSearchParams({ grant_type: "client_credentials" }), {
24
- auth: {
25
- username: CLIENT_ID,
26
- password: CLIENT_SECRET
27
- },
28
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
29
- });
30
- return response.data.access_token;
31
- }
32
- catch (error) {
33
- console.error("Error fetching access token:", ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
34
- throw error;
35
- }
36
- });
37
- }
38
- /**
39
- * Submits a time-off request to Workday.
40
- * @param {Object} params - Time-off details.
41
- * @param {string} params.workerId - Worker's ID in Workday.
42
- * @param {string} params.startDate - Start date (YYYY-MM-DD).
43
- * @param {string} params.endDate - End date (YYYY-MM-DD).
44
- * @param {string} params.timeOffType - Time-off type (e.g., "SICK_LEAVE").
45
- */
46
- function submitTimeOff(_a) {
47
- return __awaiter(this, arguments, void 0, function* ({ workerId, startDate, endDate, timeOffType }) {
48
- var _b;
49
- try {
50
- const token = yield getAccessToken(); // Get OAuth token
51
- const requestBody = {
52
- "wd:Enter_Time_Off_Request": {
53
- "wd:Worker_Reference": {
54
- "wd:ID": [{ "_": workerId, "$": { "wd:type": "WID" } }]
55
- },
56
- "wd:Time_Off_Entries": [
57
- {
58
- "wd:Start_Date": startDate,
59
- "wd:End_Date": endDate,
60
- "wd:Time_Off_Type_Reference": {
61
- "wd:ID": [{ "_": timeOffType, "$": { "wd:type": "Time_Off_Type_ID" } }]
62
- }
63
- }
64
- ]
65
- }
66
- };
67
- const response = yield axios.post(`${WORKDAY_BASE_URL}/Enter_Time_Off`, requestBody, {
68
- headers: {
69
- "Authorization": `Bearer ${token}`,
70
- "Content-Type": "application/json"
71
- }
72
- });
73
- console.log("Time-off request submitted successfully:", response.data);
74
- return response.data;
75
- }
76
- catch (error) {
77
- console.error("Error submitting time-off request:", ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data) || error.message);
78
- throw error;
79
- }
80
- });
81
- }
82
- // Example Usage:
83
- submitTimeOff({
84
- workerId: "12345",
85
- startDate: "2025-03-10",
86
- endDate: "2025-03-12",
87
- timeOffType: "SICK_LEAVE"
88
- }).then(console.log).catch(console.error);