@credal/actions 0.2.92 → 0.2.94
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.
- package/dist/actions/autogen/types.js +2 -2
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +4 -3
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +4 -6
- package/dist/actions/providers/salesforce/searchSalesforceRecords.js +8 -14
- package/dist/actions/providers/slack/sendMessage.js +17 -5
- package/package.json +1 -1
|
@@ -226,8 +226,8 @@ export const slackSendMessageParamsSchema = z.object({
|
|
|
226
226
|
message: z.string().describe("The message content to send to Slack. Can include markdown formatting."),
|
|
227
227
|
});
|
|
228
228
|
export const slackSendMessageOutputSchema = z.object({
|
|
229
|
-
success: z.boolean().describe("Whether the
|
|
230
|
-
error: z.string().describe("The error that occurred if the
|
|
229
|
+
success: z.boolean().describe("Whether the message was sent successfully"),
|
|
230
|
+
error: z.string().describe("The error that occurred if the message was not sent successfully").optional(),
|
|
231
231
|
messageId: z.string().describe("The ID of the message that was sent").optional(),
|
|
232
232
|
});
|
|
233
233
|
export const slackGetChannelMessagesParamsSchema = z.object({
|
|
@@ -33,15 +33,16 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
33
33
|
const results = yield Promise.all([allDrivesRes, orgWideRes]);
|
|
34
34
|
const relevantResults = results
|
|
35
35
|
.map(result => result.data.files)
|
|
36
|
-
.
|
|
37
|
-
.
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.map(files => (limit ? files.slice(0, limit) : files))
|
|
38
|
+
.flat();
|
|
38
39
|
const files = relevantResults.map((file) => ({
|
|
39
40
|
id: file.id || "",
|
|
40
41
|
name: file.name || "",
|
|
41
42
|
mimeType: file.mimeType || "",
|
|
42
43
|
url: file.webViewLink || "",
|
|
43
44
|
})) || [];
|
|
44
|
-
return { success: true, files
|
|
45
|
+
return { success: true, files };
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
47
48
|
console.error("Error searching Google Drive", error);
|
|
@@ -76,11 +76,9 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
78
|
const results = yield Promise.all([allDrivesRes, orgWideRes]);
|
|
79
|
-
const relevantResults = results
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.filter(Boolean);
|
|
83
|
-
const files = relevantResults.map((file) => ({
|
|
79
|
+
const relevantResults = results.map(result => result.data.files).filter(Boolean);
|
|
80
|
+
const relevantResultsFlat = relevantResults.map(result => (limit ? result.slice(0, limit) : result)).flat();
|
|
81
|
+
const files = relevantResultsFlat.map((file) => ({
|
|
84
82
|
id: file.id || "",
|
|
85
83
|
name: file.name || "",
|
|
86
84
|
mimeType: file.mimeType || "",
|
|
@@ -90,7 +88,7 @@ const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __await
|
|
|
90
88
|
const readableFiles = filterReadableFiles(files);
|
|
91
89
|
return {
|
|
92
90
|
success: true,
|
|
93
|
-
files:
|
|
91
|
+
files: readableFiles,
|
|
94
92
|
};
|
|
95
93
|
});
|
|
96
94
|
// New search method - search each drive individually and aggregate results
|
|
@@ -13,20 +13,17 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
13
13
|
const { keyword, recordType, fieldsToSearch } = params;
|
|
14
14
|
const searchFields = Array.from(new Set([...fieldsToSearch, "Id"]));
|
|
15
15
|
if (!authToken || !baseUrl) {
|
|
16
|
-
return {
|
|
17
|
-
success: false,
|
|
18
|
-
error: "authToken and baseUrl are required for Salesforce API",
|
|
19
|
-
};
|
|
16
|
+
return { success: false, error: "authToken and baseUrl are required for Salesforce API" };
|
|
20
17
|
}
|
|
21
18
|
const maxLimit = 25;
|
|
22
19
|
const dateFieldExists = searchFields.includes("CreatedDate");
|
|
23
|
-
|
|
20
|
+
// Escape special characters for SOSL search
|
|
21
|
+
const escapedKeyword = keyword
|
|
22
|
+
.replace(/"/g, '\\"') // Escape quotes
|
|
23
|
+
.replace(/-/g, "\\-"); // Escape dashes
|
|
24
|
+
const url = `${baseUrl}/services/data/v64.0/search/?q=${encodeURIComponent(`FIND {${escapedKeyword}} RETURNING ${recordType} (${searchFields.join(", ") + (dateFieldExists ? " ORDER BY CreatedDate DESC" : "")}) LIMIT ${params.limit && params.limit <= maxLimit ? params.limit : maxLimit}`)}`;
|
|
24
25
|
try {
|
|
25
|
-
const response = yield axiosClient.get(url, {
|
|
26
|
-
headers: {
|
|
27
|
-
Authorization: `Bearer ${authToken}`,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
26
|
+
const response = yield axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
|
|
30
27
|
if (recordType === "Knowledge__kav") {
|
|
31
28
|
for (const record of response.data.searchRecords) {
|
|
32
29
|
if (record.Article_Body__c) {
|
|
@@ -50,10 +47,7 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
50
47
|
const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
|
|
51
48
|
return Object.assign(Object.assign({}, record), { webUrl });
|
|
52
49
|
});
|
|
53
|
-
return {
|
|
54
|
-
success: true,
|
|
55
|
-
searchRecords: recordsWithUrl,
|
|
56
|
-
};
|
|
50
|
+
return { success: true, searchRecords: recordsWithUrl };
|
|
57
51
|
}
|
|
58
52
|
catch (error) {
|
|
59
53
|
console.error("Error retrieving Salesforce record:", error);
|
|
@@ -30,8 +30,10 @@ const sendMessage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
30
30
|
throw Error(`Channel with name ${channelName} not found`);
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
|
+
// First try sending as Markdown blocks (mrkdwn)
|
|
33
34
|
yield client.chat.postMessage({
|
|
34
35
|
channel: channelId,
|
|
36
|
+
text: message, // Fallback text for notifications/clients that don't render blocks
|
|
35
37
|
blocks: [
|
|
36
38
|
{
|
|
37
39
|
type: "section",
|
|
@@ -46,11 +48,21 @@ const sendMessage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
46
48
|
success: true,
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
|
-
catch (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
catch (_c) {
|
|
52
|
+
// On any error, retry once with plain text only (no blocks)
|
|
53
|
+
try {
|
|
54
|
+
yield client.chat.postMessage({
|
|
55
|
+
channel: channelId,
|
|
56
|
+
text: message,
|
|
57
|
+
});
|
|
58
|
+
return slackSendMessageOutputSchema.parse({ success: true });
|
|
59
|
+
}
|
|
60
|
+
catch (retryError) {
|
|
61
|
+
return slackSendMessageOutputSchema.parse({
|
|
62
|
+
success: false,
|
|
63
|
+
error: retryError instanceof Error ? retryError.message : "Unknown error after retrying sending as plain text",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
54
66
|
}
|
|
55
67
|
});
|
|
56
68
|
export default sendMessage;
|