@credal/actions 0.2.183 → 0.2.185

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.
Files changed (27) hide show
  1. package/dist/actions/actionMapper.js +16 -1
  2. package/dist/actions/autogen/templates.d.ts +2 -0
  3. package/dist/actions/autogen/templates.js +175 -0
  4. package/dist/actions/autogen/types.d.ts +171 -11
  5. package/dist/actions/autogen/types.js +66 -0
  6. package/dist/actions/groups.js +4 -1
  7. package/dist/actions/providers/github/fetchFile.d.ts +3 -0
  8. package/dist/actions/providers/github/fetchFile.js +131 -0
  9. package/dist/actions/providers/github/getContents.d.ts +3 -0
  10. package/dist/actions/providers/github/getContents.js +41 -0
  11. package/dist/actions/providers/salesforce/listReports.d.ts +3 -0
  12. package/dist/actions/providers/salesforce/listReports.js +36 -0
  13. package/dist/actions/providers/slack/archiveChannel.js +9 -2
  14. package/dist/actions/providers/slackUser/searchSlackRTS.d.ts +3 -0
  15. package/dist/actions/providers/slackUser/searchSlackRTS.js +66 -0
  16. package/dist/utils/google.js +76 -28
  17. package/package.json +3 -1
  18. package/dist/actions/providers/credal/callCopilot.d.ts +0 -3
  19. package/dist/actions/providers/credal/callCopilot.js +0 -36
  20. package/dist/actions/providers/math/index.d.ts +0 -1
  21. package/dist/actions/providers/math/index.js +0 -37
  22. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
  23. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
  24. package/dist/actions/providers/slack/index.d.ts +0 -1
  25. package/dist/actions/providers/slack/index.js +0 -37
  26. package/dist/actions/providers/slack/listConversations.d.ts +0 -3
  27. package/dist/actions/providers/slack/listConversations.js +0 -41
@@ -35,6 +35,7 @@ export var ProviderName;
35
35
  ProviderName["GITLAB"] = "gitlab";
36
36
  ProviderName["LINEAR"] = "linear";
37
37
  ProviderName["HUBSPOT"] = "hubspot";
38
+ ProviderName["BOXUSER"] = "boxUser";
38
39
  })(ProviderName || (ProviderName = {}));
39
40
  export var ActionName;
40
41
  (function (ActionName) {
@@ -52,6 +53,7 @@ export var ActionName;
52
53
  ActionName["GETCHANNELMESSAGES"] = "getChannelMessages";
53
54
  ActionName["GETCHANNELMEMBERS"] = "getChannelMembers";
54
55
  ActionName["SEARCHSLACK"] = "searchSlack";
56
+ ActionName["SEARCHSLACKRTS"] = "searchSlackRTS";
55
57
  ActionName["ADD"] = "add";
56
58
  ActionName["OVERWRITEPAGE"] = "overwritePage";
57
59
  ActionName["FETCHPAGECONTENT"] = "fetchPageContent";
@@ -127,6 +129,7 @@ export var ActionName;
127
129
  ActionName["CREATECASE"] = "createCase";
128
130
  ActionName["GENERATESALESREPORT"] = "generateSalesReport";
129
131
  ActionName["SEARCHALLSALESFORCERECORDS"] = "searchAllSalesforceRecords";
132
+ ActionName["LISTREPORTS"] = "listReports";
130
133
  ActionName["SEARCHSALESFORCERECORDS"] = "searchSalesforceRecords";
131
134
  ActionName["GETSALESFORCERECORDSBYQUERY"] = "getSalesforceRecordsByQuery";
132
135
  ActionName["GETRECORD"] = "getRecord";
@@ -518,6 +521,60 @@ export const slackUserSearchSlackOutputSchema = z.object({
518
521
  })
519
522
  .describe("The current user who's running the search"),
520
523
  });
524
+ export const slackUserSearchSlackRTSParamsSchema = z.object({
525
+ query: z
526
+ .string()
527
+ .describe('The search query string (e.g., "What is project gizmo?", "mobile UX revamp"). You can use any Slack filters directly in the query string.'),
528
+ channelTypes: z
529
+ .array(z.enum(["public_channel", "private_channel", "mpim", "im"]))
530
+ .describe("Filter by channel types to search. If not specified, searches all channel types the user has access to.")
531
+ .optional(),
532
+ contentTypes: z
533
+ .array(z.enum(["messages", "files", "channels"]))
534
+ .describe("Filter by content types to include in search results.")
535
+ .default(["messages", "files", "channels"]),
536
+ includeBots: z.boolean().describe("Whether to include bot messages in search results.").default(false),
537
+ includeContextMessages: z
538
+ .boolean()
539
+ .describe("Whether to include contextual messages in search results.")
540
+ .default(false),
541
+ limit: z.number().gte(1).lte(20).describe("Maximum number of results per page (max 20).").default(20),
542
+ before: z
543
+ .string()
544
+ .describe("Optional UNIX timestamp filter. If present, filters for results before this date.")
545
+ .optional(),
546
+ after: z
547
+ .string()
548
+ .describe("Optional UNIX timestamp filter. If present, filters for results after this date.")
549
+ .optional(),
550
+ });
551
+ export const slackUserSearchSlackRTSOutputSchema = z.object({
552
+ ok: z.boolean().describe("Whether the request was successful."),
553
+ results: z
554
+ .object({
555
+ messages: z
556
+ .array(z.object({
557
+ author_user_id: z.string().describe("User ID of the message author."),
558
+ team_id: z.string().describe("Team/workspace ID where the message was posted."),
559
+ channel_id: z.string().describe("Channel ID where the message was posted."),
560
+ message_ts: z.string().describe("Message timestamp."),
561
+ content: z.string().describe("The message content/text."),
562
+ is_author_bot: z.boolean().describe("Whether the message author is a bot."),
563
+ permalink: z.string().describe("Permalink URL to the message in Slack.").optional(),
564
+ }))
565
+ .describe("Array of message results matching the search query.")
566
+ .optional(),
567
+ files: z
568
+ .array(z.object({
569
+ file_id: z.string().describe("File ID.").optional(),
570
+ title: z.string().describe("File title.").optional(),
571
+ permalink: z.string().describe("Permalink URL to the file in Slack.").optional(),
572
+ }))
573
+ .describe("Array of file results matching the search query (if files content type was requested).")
574
+ .optional(),
575
+ })
576
+ .describe("Search results containing messages and/or files."),
577
+ });
521
578
  export const mathAddParamsSchema = z.object({
522
579
  a: z.number().describe("The first number to add"),
523
580
  b: z.number().describe("The second number to add"),
@@ -3605,6 +3662,15 @@ export const salesforceSearchAllSalesforceRecordsOutputSchema = z.object({
3605
3662
  .optional(),
3606
3663
  error: z.string().describe("The error that occurred if the records were not successfully retrieved").optional(),
3607
3664
  });
3665
+ export const salesforceListReportsParamsSchema = z.object({});
3666
+ export const salesforceListReportsOutputSchema = z.object({
3667
+ success: z.boolean().describe("Whether the reports were successfully retrieved"),
3668
+ reports: z
3669
+ .array(z.object({}).catchall(z.any()).describe("A Salesforce report"))
3670
+ .describe("List of available reports")
3671
+ .optional(),
3672
+ error: z.string().describe("The error that occurred if the reports were not successfully retrieved").optional(),
3673
+ });
3608
3674
  export const salesforceSearchSalesforceRecordsParamsSchema = z.object({
3609
3675
  keyword: z.string().describe("The keyword to search for"),
3610
3676
  recordType: z.string().describe("The type of record to search for"),
@@ -1,4 +1,4 @@
1
- import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, } from "./autogen/templates.js";
1
+ import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, googleOauthSearchDriveByQueryAndGetFileContentDefinition, githubGetFileContentDefinition, githubListDirectoryDefinition, } from "./autogen/templates.js";
2
2
  export const ACTION_GROUPS = {
3
3
  GENERIC: {
4
4
  description: "Generic utility actions",
@@ -47,6 +47,7 @@ export const ACTION_GROUPS = {
47
47
  googleOauthUpdatePresentationDefinition,
48
48
  googleOauthSearchDriveByKeywordsDefinition,
49
49
  googleOauthSearchDriveByQueryDefinition,
50
+ googleOauthSearchDriveByQueryAndGetFileContentDefinition,
50
51
  googleOauthGetDriveFileContentByIdDefinition,
51
52
  ],
52
53
  },
@@ -198,6 +199,8 @@ export const ACTION_GROUPS = {
198
199
  githubCreateBranchDefinition,
199
200
  githubCreatePullRequestDefinition,
200
201
  githubListPullRequestsDefinition,
202
+ githubGetFileContentDefinition,
203
+ githubListDirectoryDefinition,
201
204
  ],
202
205
  },
203
206
  ASHBY: {
@@ -0,0 +1,3 @@
1
+ import type { githubSearchRepositoryFunction } from "../../autogen/types.js";
2
+ declare const searchRepository: githubSearchRepositoryFunction;
3
+ export default searchRepository;
@@ -0,0 +1,131 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
11
+ // Limits on the number of results to return
12
+ const MAX_CODE_RESULTS = 15;
13
+ const MAX_COMMITS = 10;
14
+ const MAX_FILES_PER_COMMIT = 5;
15
+ const MAX_ISSUES_OR_PRS = 10;
16
+ const MAX_FILES_PER_PR = 5;
17
+ const MAX_PATCH_LINES = 20;
18
+ const MAX_FRAGMENT_LINES = 20;
19
+ const searchRepository = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
20
+ const { Octokit } = yield import("octokit");
21
+ if (!authParams.authToken) {
22
+ throw new Error(MISSING_AUTH_TOKEN);
23
+ }
24
+ const octokit = new Octokit({ auth: authParams.authToken });
25
+ const { organization, repository, query } = params;
26
+ // Search CODE with text match metadata
27
+ const codeResultsResponse = yield octokit.rest.search.code({
28
+ q: `${query} in:file,path repo:${organization}/${repository}`,
29
+ text_match: true,
30
+ headers: {
31
+ accept: "application/vnd.github.v3.text-match+json",
32
+ },
33
+ });
34
+ const codeResults = codeResultsResponse.data.items.slice(0, MAX_CODE_RESULTS).map(item => ({
35
+ name: item.name,
36
+ path: item.path,
37
+ sha: item.sha,
38
+ url: item.url,
39
+ repository: {
40
+ full_name: item.repository.full_name,
41
+ html_url: item.repository.html_url,
42
+ },
43
+ score: item.score,
44
+ textMatches: item.text_matches
45
+ ? item.text_matches.map(match => {
46
+ var _a, _b, _c, _d;
47
+ return ({
48
+ object_url: (_a = match.object_url) !== null && _a !== void 0 ? _a : undefined,
49
+ object_type: (_b = match.object_type) !== null && _b !== void 0 ? _b : undefined,
50
+ fragment: (_c = match.fragment) === null || _c === void 0 ? void 0 : _c.split("\n").slice(0, MAX_FRAGMENT_LINES).join("\n"),
51
+ matches: (_d = match.matches) !== null && _d !== void 0 ? _d : [],
52
+ });
53
+ })
54
+ : [],
55
+ }));
56
+ // Search COMMITS
57
+ const commitResults = yield octokit.rest.search.commits({
58
+ q: `${query} repo:${organization}/${repository}`,
59
+ headers: {
60
+ accept: "application/vnd.github.cloak-preview+json",
61
+ },
62
+ });
63
+ const commitSHAs = commitResults.data.items.slice(0, MAX_COMMITS).map(item => item.sha);
64
+ const commitDetails = yield Promise.all(commitSHAs.map(sha => octokit.rest.repos.getCommit({ owner: organization, repo: repository, ref: sha })));
65
+ const enrichedCommits = commitResults.data.items.slice(0, MAX_COMMITS).map(item => {
66
+ var _a, _b;
67
+ const full = commitDetails.find(c => c.data.sha === item.sha);
68
+ return {
69
+ sha: item.sha,
70
+ url: item.url,
71
+ commit: {
72
+ message: item.commit.message,
73
+ author: item.commit.author,
74
+ },
75
+ score: item.score,
76
+ author: (_a = item.author) !== null && _a !== void 0 ? _a : undefined,
77
+ files: ((_b = full === null || full === void 0 ? void 0 : full.data.files) === null || _b === void 0 ? void 0 : _b.slice(0, MAX_FILES_PER_COMMIT).map(f => {
78
+ var _a;
79
+ return ({
80
+ filename: f.filename,
81
+ status: f.status,
82
+ patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
83
+ });
84
+ })) || [],
85
+ };
86
+ });
87
+ // Search ISSUES & PRs
88
+ const issueResults = yield octokit.rest.search.issuesAndPullRequests({
89
+ q: `${query} repo:${organization}/${repository}`,
90
+ });
91
+ const prItems = issueResults.data.items.filter(item => item.pull_request).slice(0, MAX_ISSUES_OR_PRS);
92
+ const prNumbers = prItems.map(item => item.number);
93
+ const prFiles = yield Promise.all(prNumbers.map(number => octokit.rest.pulls.listFiles({ owner: organization, repo: repository, pull_number: number })));
94
+ const issuesAndPRs = issueResults.data.items
95
+ .slice(0, MAX_ISSUES_OR_PRS)
96
+ .map(item => {
97
+ var _a, _b, _c, _d;
98
+ const isPR = !!item.pull_request;
99
+ const prIndex = prNumbers.indexOf(item.number);
100
+ const files = isPR && prIndex !== -1
101
+ ? prFiles[prIndex].data.slice(0, MAX_FILES_PER_PR).map(f => {
102
+ var _a;
103
+ return ({
104
+ filename: f.filename,
105
+ status: f.status,
106
+ patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
107
+ });
108
+ })
109
+ : undefined;
110
+ return {
111
+ number: item.number,
112
+ title: item.title,
113
+ html_url: item.html_url,
114
+ state: item.state,
115
+ isPullRequest: isPR,
116
+ body: item.body,
117
+ user: {
118
+ email: (_b = (_a = item.user) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : undefined,
119
+ name: (_d = (_c = item.user) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : undefined,
120
+ },
121
+ score: item.score,
122
+ files,
123
+ };
124
+ });
125
+ return {
126
+ code: codeResults,
127
+ commits: enrichedCommits,
128
+ issuesAndPullRequests: issuesAndPRs,
129
+ };
130
+ });
131
+ export default searchRepository;
@@ -0,0 +1,3 @@
1
+ import type { githubSearchRepositoryFunction } from "../../autogen/types.js";
2
+ declare const searchRepository: githubSearchRepositoryFunction;
3
+ export default searchRepository;
@@ -0,0 +1,41 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
11
+ // Limits on the number of results to return
12
+ const MAX_CODE_RESULTS = 15;
13
+ const MAX_COMMITS = 10;
14
+ const MAX_FILES_PER_COMMIT = 5;
15
+ const MAX_ISSUES_OR_PRS = 10;
16
+ const MAX_FILES_PER_PR = 5;
17
+ const MAX_PATCH_LINES = 20;
18
+ const MAX_FRAGMENT_LINES = 20;
19
+ const searchRepository = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
20
+ const { Octokit } = yield import("octokit");
21
+ if (!authParams.authToken) {
22
+ throw new Error(MISSING_AUTH_TOKEN);
23
+ }
24
+ const octokit = new Octokit({ auth: authParams.authToken });
25
+ const { organization, repository, query } = params;
26
+ // Search CODE with text match metadata
27
+ const codeResultsResponse = yield octokit.rest.search.code({
28
+ q: `${query} in:file,path repo:${organization}/${repository}`,
29
+ text_match: true,
30
+ headers: {
31
+ accept: "application/vnd.github.v3.text-match+json",
32
+ },
33
+ });
34
+ const commitResults = yield octokit.rest.repos.getCommit({ owner: organization, repo: repository, ref: sha });
35
+ return {
36
+ code: codeResults,
37
+ commits: enrichedCommits,
38
+ issuesAndPullRequests: issuesAndPRs,
39
+ };
40
+ });
41
+ export default searchRepository;
@@ -0,0 +1,3 @@
1
+ import type { salesforceListReportsFunction } from "../../autogen/types.js";
2
+ declare const listReports: salesforceListReportsFunction;
3
+ export default listReports;
@@ -0,0 +1,36 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { ApiError, axiosClient } from "../../util/axiosClient.js";
11
+ const listReports = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
12
+ const { authToken, baseUrl } = authParams;
13
+ if (!authToken || !baseUrl) {
14
+ return { success: false, error: "authToken and baseUrl are required for Salesforce API" };
15
+ }
16
+ const url = `${baseUrl}/services/data/v65.0/analytics/reports`;
17
+ try {
18
+ const response = yield axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
19
+ return {
20
+ success: true,
21
+ reports: response.data,
22
+ };
23
+ }
24
+ catch (error) {
25
+ console.error("Error listing Salesforce reports:", error);
26
+ return {
27
+ success: false,
28
+ error: error instanceof ApiError
29
+ ? Array.isArray(error.data) && error.data.length > 0
30
+ ? error.data[0].message
31
+ : error.message
32
+ : "An unknown error occurred",
33
+ };
34
+ }
35
+ });
36
+ export default listReports;
@@ -9,14 +9,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { WebClient } from "@slack/web-api";
11
11
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
+ import { getSlackChannels } from "./helpers.js";
12
13
  const archiveChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
14
  if (!authParams.authToken) {
14
15
  throw new Error(MISSING_AUTH_TOKEN);
15
16
  }
16
17
  try {
17
18
  const client = new WebClient(authParams.authToken);
18
- const { channelId } = params;
19
- const result = yield client.conversations.archive({ channel: channelId });
19
+ const { channelName } = params;
20
+ const allChannels = yield getSlackChannels(client);
21
+ const channel = allChannels.find(channel => channel.name == channelName);
22
+ if (!channel || !channel.id) {
23
+ throw Error(`Channel with name ${channelName} not found`);
24
+ }
25
+ yield client.conversations.join({ channel: channel.id });
26
+ const result = yield client.conversations.archive({ channel: channel.id });
20
27
  if (!result.ok) {
21
28
  return {
22
29
  success: false,
@@ -0,0 +1,3 @@
1
+ import { type slackUserSearchSlackRTSFunction } from "../../autogen/types.js";
2
+ declare const searchSlackRTS: slackUserSearchSlackRTSFunction;
3
+ export default searchSlackRTS;
@@ -0,0 +1,66 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { WebClient } from "@slack/web-api";
11
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
+ /* ===================== MAIN EXPORT ===================== */
13
+ const searchSlackRTS = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ var _b, _c;
15
+ if (!authParams.authToken)
16
+ throw new Error(MISSING_AUTH_TOKEN);
17
+ const client = new WebClient(authParams.authToken);
18
+ const { query, channelTypes, contentTypes = ["messages", "files", "channels"], includeBots = false, limit = 20, includeContextMessages = true, before, after, } = params;
19
+ // Build the request parameters for assistant.search.context
20
+ const requestParams = {
21
+ query,
22
+ };
23
+ // Add optional parameters if provided
24
+ if (channelTypes && channelTypes.length > 0) {
25
+ requestParams.channel_types = channelTypes;
26
+ }
27
+ if (contentTypes && contentTypes.length > 0) {
28
+ requestParams.content_types = contentTypes;
29
+ }
30
+ if (includeBots !== undefined) {
31
+ requestParams.include_bots = includeBots;
32
+ }
33
+ if (limit) {
34
+ requestParams.limit = Math.min(limit, 20); // API max is 20, not handling pagination yet
35
+ }
36
+ if (includeContextMessages !== undefined) {
37
+ requestParams.include_context_messages = includeContextMessages;
38
+ }
39
+ if (before) {
40
+ requestParams.before = before;
41
+ }
42
+ if (after) {
43
+ requestParams.after = after;
44
+ }
45
+ try {
46
+ // Call the assistant.search.context API
47
+ const response = (yield client.apiCall("assistant.search.context", requestParams));
48
+ if (!response.ok) {
49
+ throw new Error(`Slack API error: ${response.error || "Unknown error"}`);
50
+ }
51
+ // Return the response in the expected format
52
+ return {
53
+ ok: response.ok,
54
+ results: {
55
+ messages: ((_b = response.results) === null || _b === void 0 ? void 0 : _b.messages) || [],
56
+ files: ((_c = response.results) === null || _c === void 0 ? void 0 : _c.files) || [],
57
+ },
58
+ };
59
+ }
60
+ catch (error) {
61
+ // Handle errors gracefully
62
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
63
+ throw new Error(`Failed to search Slack using RTS API: ${errorMessage}`);
64
+ }
65
+ });
66
+ export default searchSlackRTS;
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import Papa from "papaparse";
10
11
  import { isAxiosTimeoutError } from "../actions/util/axiosClient.js";
11
12
  // Helper function to parse Google Docs content to plain text
12
13
  export function parseGoogleDocFromRawContentToPlainText(snapshotRawContent) {
@@ -113,46 +114,91 @@ export function parseGoogleDocFromRawContentToPlainText(snapshotRawContent) {
113
114
  const validDocSections = docSections.filter(section => section.heading || section.paragraphs.length > 0);
114
115
  return validDocSections.map(section => section.paragraphs.join(" ")).join("\n");
115
116
  }
117
+ // Helper to convert 0-based column index to Excel-style column letter (0 -> "A", 25 -> "Z", 26 -> "AA")
118
+ function columnIndexToLetter(index) {
119
+ let letter = "";
120
+ while (index >= 0) {
121
+ letter = String.fromCharCode((index % 26) + 65) + letter;
122
+ index = Math.floor(index / 26) - 1;
123
+ }
124
+ return letter;
125
+ }
126
+ // Helper to parse CSV string into the JSON sheet format
127
+ function parseCSVToSheetJson(csvData, sheetName = "Sheet1") {
128
+ const headers = [];
129
+ const rows = [];
130
+ const parsed = Papa.parse(csvData, {
131
+ skipEmptyLines: true,
132
+ });
133
+ parsed.data.forEach((values, rowIndex) => {
134
+ values.forEach((value, colIndex) => {
135
+ const column = columnIndexToLetter(colIndex);
136
+ if (rowIndex === 0) {
137
+ // Headers: keep all cells (including empty) to preserve column positions
138
+ headers.push({ column, header: value.trim() });
139
+ }
140
+ else {
141
+ // Rows: skip empty or whitespace-only cells
142
+ const trimmedValue = value.trim();
143
+ if (!trimmedValue)
144
+ return;
145
+ rows.push({ column, row: rowIndex + 1, value: trimmedValue });
146
+ }
147
+ });
148
+ });
149
+ return JSON.stringify([{ sheetName, headers, rows }]);
150
+ }
116
151
  export function parseGoogleSheetsFromRawContentToPlainText(snapshotRawContent) {
117
152
  var _a;
118
153
  if (!snapshotRawContent.sheets)
119
- return "";
120
- const sheetContents = [];
154
+ return "[]";
155
+ const sheetsData = [];
121
156
  for (const sheet of snapshotRawContent.sheets) {
122
157
  if (!sheet.data || !((_a = sheet.properties) === null || _a === void 0 ? void 0 : _a.title))
123
158
  continue;
124
- const sheetTitle = sheet.properties.title;
125
- const sheetRows = [`Sheet: ${sheetTitle}`];
159
+ const sheetName = sheet.properties.title;
160
+ const headers = [];
161
+ const rows = [];
162
+ // Helper to extract cell value
163
+ const getCellValue = (cell) => {
164
+ var _a, _b, _c;
165
+ if (cell.formattedValue)
166
+ return cell.formattedValue;
167
+ if ((_a = cell.userEnteredValue) === null || _a === void 0 ? void 0 : _a.stringValue)
168
+ return cell.userEnteredValue.stringValue;
169
+ if (((_b = cell.userEnteredValue) === null || _b === void 0 ? void 0 : _b.numberValue) !== undefined)
170
+ return cell.userEnteredValue.numberValue.toString();
171
+ if (((_c = cell.userEnteredValue) === null || _c === void 0 ? void 0 : _c.boolValue) !== undefined)
172
+ return cell.userEnteredValue.boolValue.toString();
173
+ return "";
174
+ };
126
175
  for (const gridData of sheet.data) {
127
176
  if (!gridData.rowData)
128
177
  continue;
129
- for (const rowData of gridData.rowData) {
178
+ gridData.rowData.forEach((rowData, rowIndex) => {
130
179
  if (!rowData.values)
131
- continue;
132
- const cellValues = rowData.values
133
- .map(cell => {
134
- var _a, _b, _c;
135
- if (cell.formattedValue)
136
- return cell.formattedValue;
137
- if ((_a = cell.userEnteredValue) === null || _a === void 0 ? void 0 : _a.stringValue)
138
- return cell.userEnteredValue.stringValue;
139
- if ((_b = cell.userEnteredValue) === null || _b === void 0 ? void 0 : _b.numberValue)
140
- return cell.userEnteredValue.numberValue.toString();
141
- if ((_c = cell.userEnteredValue) === null || _c === void 0 ? void 0 : _c.boolValue)
142
- return cell.userEnteredValue.boolValue.toString();
143
- return "";
144
- })
145
- .filter(value => value !== "");
146
- if (cellValues.length > 0) {
147
- sheetRows.push(cellValues.join(" | "));
148
- }
149
- }
180
+ return;
181
+ rowData.values.forEach((cell, colIndex) => {
182
+ const column = columnIndexToLetter(colIndex);
183
+ const value = getCellValue(cell).trim();
184
+ if (rowIndex === 0) {
185
+ // Headers: keep all cells (including empty) to preserve column positions
186
+ headers.push({ column, header: value });
187
+ }
188
+ else {
189
+ // Rows: skip empty or whitespace-only cells
190
+ if (!value)
191
+ return;
192
+ rows.push({ column, row: rowIndex + 1, value });
193
+ }
194
+ });
195
+ });
150
196
  }
151
- if (sheetRows.length > 1) {
152
- sheetContents.push(sheetRows.join("\n"));
197
+ if (headers.length > 0 || rows.length > 0) {
198
+ sheetsData.push({ sheetName, headers, rows });
153
199
  }
154
200
  }
155
- return sheetContents.join("\n\n");
201
+ return JSON.stringify(sheetsData);
156
202
  }
157
203
  export function parseGoogleSlidesFromRawContentToPlainText(snapshotRawContent) {
158
204
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -297,11 +343,13 @@ export function getGoogleSheetContent(fileId, authToken, axiosClient, sharedDriv
297
343
  headers: { Authorization: `Bearer ${authToken}` },
298
344
  responseType: "text",
299
345
  });
300
- return exportRes.data
346
+ // Clean up trailing commas and convert to JSON format
347
+ const cleanedCsv = exportRes.data
301
348
  .split("\n")
302
349
  .map((line) => line.replace(/,+$/, ""))
303
350
  .map((line) => line.replace(/,{2,}/g, ","))
304
351
  .join("\n");
352
+ return parseCSVToSheetJson(cleanedCsv);
305
353
  }
306
354
  catch (exportError) {
307
355
  // Check if it's a 404 or permission error
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.183",
3
+ "version": "0.2.185",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,
@@ -36,6 +36,7 @@
36
36
  "@types/jsonwebtoken": "^9.0.9",
37
37
  "@types/node": "^24.0.0",
38
38
  "@types/node-forge": "^1.3.11",
39
+ "@types/papaparse": "^5.5.2",
39
40
  "@typescript-eslint/eslint-plugin": "^8.18.0",
40
41
  "@typescript-eslint/parser": "^8.18.0",
41
42
  "eslint": "^9.16.0",
@@ -73,6 +74,7 @@
73
74
  "node-forge": "^1.3.3",
74
75
  "officeparser": "^5.2.2",
75
76
  "p-limit": "^7.1.1",
77
+ "papaparse": "^5.5.3",
76
78
  "resend": "^4.7.0",
77
79
  "snowflake-sdk": "^2.0.2",
78
80
  "ts-node": "^10.9.2",
@@ -1,3 +0,0 @@
1
- import type { credalCallCopilotFunction } from "../../autogen/types";
2
- declare const callCopilot: credalCallCopilotFunction;
3
- export default callCopilot;