@credal/actions 0.2.160 → 0.2.162
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/actionMapper.js +7 -1
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +287 -48
- package/dist/actions/autogen/types.d.ts +452 -79
- package/dist/actions/autogen/types.js +76 -13
- package/dist/actions/providers/firecrawl/scrapeUrl.js +0 -1
- package/dist/actions/providers/gitlab/getMergeRequest.d.ts +3 -0
- package/dist/actions/providers/gitlab/getMergeRequest.js +102 -0
- package/dist/actions/providers/googlemail/searchGmailMessages.d.ts +0 -14
- package/dist/actions/providers/googlemail/searchGmailMessages.js +44 -43
- package/dist/actions/providers/jira/utils.js +0 -1
- package/dist/actions/providers/zendesk/addCommentToTicket.js +1 -2
- package/package.json +1 -1
|
@@ -3253,22 +3253,28 @@ export const googlemailSearchGmailMessagesParamsSchema = z.object({
|
|
|
3253
3253
|
});
|
|
3254
3254
|
export const googlemailSearchGmailMessagesOutputSchema = z.object({
|
|
3255
3255
|
success: z.boolean(),
|
|
3256
|
-
|
|
3256
|
+
error: z.string().describe("Error message if search failed").optional(),
|
|
3257
|
+
pageToken: z.string().describe("The token to use to get the next page of results").optional(),
|
|
3258
|
+
results: z
|
|
3257
3259
|
.array(z.object({
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3260
|
+
name: z.string().describe("The name of the message"),
|
|
3261
|
+
url: z.string().describe("The URL of the message"),
|
|
3262
|
+
contents: z.object({
|
|
3263
|
+
id: z.string().describe("The message ID"),
|
|
3264
|
+
threadId: z.string().describe("The thread ID"),
|
|
3265
|
+
snippet: z.string().describe("A short part of the message text").optional(),
|
|
3266
|
+
labels: z.array(z.string()).describe("Labels on the message").optional(),
|
|
3267
|
+
internalDate: z.string().describe("Internal timestamp of the message").optional(),
|
|
3268
|
+
body: z.string().describe("The body of the message").optional(),
|
|
3269
|
+
from: z.string().describe("The from header of the message").optional(),
|
|
3270
|
+
to: z.string().describe("The to header of the message").optional(),
|
|
3271
|
+
subject: z.string().describe("The subject header of the message").optional(),
|
|
3272
|
+
cc: z.string().describe("The cc header of the message").optional(),
|
|
3273
|
+
bcc: z.string().describe("The bcc header of the message").optional(),
|
|
3274
|
+
error: z.string().describe("Error message if search failed").optional(),
|
|
3275
|
+
}),
|
|
3269
3276
|
}))
|
|
3270
3277
|
.describe("List of matching Gmail messages"),
|
|
3271
|
-
error: z.string().describe("Error message if search failed").optional(),
|
|
3272
3278
|
});
|
|
3273
3279
|
export const googlemailListGmailThreadsParamsSchema = z.object({
|
|
3274
3280
|
query: z.string().describe('Gmail search query (e.g. "from:alice subject:project")'),
|
|
@@ -4804,6 +4810,63 @@ export const gitlabGetFileContentOutputSchema = z.object({
|
|
|
4804
4810
|
.describe("The results of the file content")
|
|
4805
4811
|
.optional(),
|
|
4806
4812
|
});
|
|
4813
|
+
export const gitlabGetMergeRequestParamsSchema = z.object({
|
|
4814
|
+
project_id: z.number().describe("Numeric project ID in GitLab (unique per project)"),
|
|
4815
|
+
mr_iid: z.string().describe("The internal ID of the merge request"),
|
|
4816
|
+
});
|
|
4817
|
+
export const gitlabGetMergeRequestOutputSchema = z.object({
|
|
4818
|
+
success: z.boolean().describe("Whether the operation was successful"),
|
|
4819
|
+
error: z.string().describe("The error that occurred if the operation was not successful").optional(),
|
|
4820
|
+
results: z
|
|
4821
|
+
.array(z.object({
|
|
4822
|
+
metadata: z.object({
|
|
4823
|
+
iid: z.number().describe("The internal ID of the merge request"),
|
|
4824
|
+
id: z.number().describe("The ID of the merge request"),
|
|
4825
|
+
project_id: z.number().describe("The ID of the project the merge request belongs to"),
|
|
4826
|
+
title: z.string().describe("The title of the merge request"),
|
|
4827
|
+
description: z.string().describe("The description of the merge request"),
|
|
4828
|
+
state: z.string().describe("The state of the merge request"),
|
|
4829
|
+
merged: z.boolean().describe("Whether the merge request has been merged"),
|
|
4830
|
+
sha: z.string().describe("The SHA of the merge request"),
|
|
4831
|
+
web_url: z.string().describe("The URL of the merge request"),
|
|
4832
|
+
source_branch: z.string().describe("The source branch of the merge request"),
|
|
4833
|
+
target_branch: z.string().describe("The target branch of the merge request"),
|
|
4834
|
+
source_sha: z.string().describe("The source SHA of the merge request"),
|
|
4835
|
+
target_sha: z.string().describe("The target SHA of the merge request").optional(),
|
|
4836
|
+
diff_refs: z.object({
|
|
4837
|
+
base_sha: z.string().describe("The base SHA of the merge request"),
|
|
4838
|
+
head_sha: z.string().describe("The head SHA of the merge request"),
|
|
4839
|
+
}),
|
|
4840
|
+
author: z.object({
|
|
4841
|
+
id: z.number().describe("The ID of the author"),
|
|
4842
|
+
name: z.string().describe("The name of the author"),
|
|
4843
|
+
username: z.string().describe("The username of the author"),
|
|
4844
|
+
}),
|
|
4845
|
+
}),
|
|
4846
|
+
changes: z
|
|
4847
|
+
.array(z.object({
|
|
4848
|
+
old_path: z.string().describe("The old path of the change"),
|
|
4849
|
+
new_path: z.string().describe("The new path of the change"),
|
|
4850
|
+
new_file: z.boolean().describe("Whether the change is a new file"),
|
|
4851
|
+
renamed_file: z.boolean().describe("Whether the change is a renamed file"),
|
|
4852
|
+
deleted_file: z.boolean().describe("Whether the change is a deleted file"),
|
|
4853
|
+
diff: z.string().describe("The diff of the change"),
|
|
4854
|
+
}))
|
|
4855
|
+
.describe("A list of changes in the merge request"),
|
|
4856
|
+
commits: z
|
|
4857
|
+
.array(z.object({
|
|
4858
|
+
id: z.string().describe("The full SHA of the commit"),
|
|
4859
|
+
title: z.string().describe("The title of the commit"),
|
|
4860
|
+
message: z.string().describe("The message of the commit"),
|
|
4861
|
+
author_name: z.string().describe("The name of the commit author"),
|
|
4862
|
+
author_email: z.string().describe("The email of the commit author"),
|
|
4863
|
+
created_at: z.string().describe("The date/time the commit was created"),
|
|
4864
|
+
}))
|
|
4865
|
+
.describe("A list of commits in the merge request"),
|
|
4866
|
+
}))
|
|
4867
|
+
.describe("The results of the merge request")
|
|
4868
|
+
.optional(),
|
|
4869
|
+
});
|
|
4807
4870
|
export const gitlabListDirectoryParamsSchema = z.object({
|
|
4808
4871
|
group: z.string().describe('The group or namespace that owns the project (e.g., "my-group" or "org/subgroup")'),
|
|
4809
4872
|
project: z.string().describe('The name of the GitLab project (e.g., "my-repo")'),
|
|
@@ -21,7 +21,6 @@ const scrapeUrl = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, a
|
|
|
21
21
|
params.formats.length > 0 && {
|
|
22
22
|
formats: params.formats,
|
|
23
23
|
})), { zeroDataRetention: true }));
|
|
24
|
-
console.log("Result is: ", result);
|
|
25
24
|
// Extract content based on requested formats
|
|
26
25
|
let content = "";
|
|
27
26
|
if (params.formats && params.formats.length > 0) {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// TYPES
|
|
3
|
+
// ============================================================================
|
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// IMPLEMENTATION
|
|
15
|
+
// ============================================================================
|
|
16
|
+
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
17
|
+
import { getProjectPath } from "./utils.js";
|
|
18
|
+
const GITLAB_API_URL = "https://gitlab.com";
|
|
19
|
+
function gitlabFetch(url, authToken) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const res = yield fetch(url, {
|
|
22
|
+
headers: { Authorization: `Bearer ${authToken}` },
|
|
23
|
+
});
|
|
24
|
+
if (!res.ok) {
|
|
25
|
+
throw new Error(`GitLab API error: ${res.status} ${res.statusText}`);
|
|
26
|
+
}
|
|
27
|
+
return res.json();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export const getMergeRequestContent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
31
|
+
var _b, _c, _d, _e, _f;
|
|
32
|
+
const { authToken, baseUrl } = authParams;
|
|
33
|
+
const gitlabBaseUrl = baseUrl !== null && baseUrl !== void 0 ? baseUrl : GITLAB_API_URL;
|
|
34
|
+
if (!authToken) {
|
|
35
|
+
return { success: false, error: MISSING_AUTH_TOKEN };
|
|
36
|
+
}
|
|
37
|
+
const { project_id, mr_iid } = params;
|
|
38
|
+
// --------------------------------------------------------------------------
|
|
39
|
+
// 1. Fetch MR metadata
|
|
40
|
+
// --------------------------------------------------------------------------
|
|
41
|
+
const mrUrl = `${gitlabBaseUrl}/api/v4/projects/${project_id}/merge_requests/${mr_iid}`;
|
|
42
|
+
const mr = yield gitlabFetch(mrUrl, authToken);
|
|
43
|
+
const projectPath = yield getProjectPath(project_id, authToken, `${gitlabBaseUrl}/api/v4`);
|
|
44
|
+
const webUrl = (_b = mr.web_url) !== null && _b !== void 0 ? _b : `${gitlabBaseUrl}/${projectPath}/-/merge_requests/${mr_iid}`;
|
|
45
|
+
const metadata = {
|
|
46
|
+
iid: mr.iid,
|
|
47
|
+
id: mr.id,
|
|
48
|
+
project_id: mr.project_id,
|
|
49
|
+
title: mr.title,
|
|
50
|
+
description: (_c = mr.description) !== null && _c !== void 0 ? _c : "",
|
|
51
|
+
state: mr.state,
|
|
52
|
+
merged: mr.merged,
|
|
53
|
+
sha: mr.sha,
|
|
54
|
+
diff_refs: mr.diff_refs,
|
|
55
|
+
author: mr.author,
|
|
56
|
+
web_url: webUrl,
|
|
57
|
+
source_branch: mr.source_branch,
|
|
58
|
+
target_branch: mr.target_branch,
|
|
59
|
+
source_sha: (_e = (_d = mr.diff_refs) === null || _d === void 0 ? void 0 : _d.head_sha) !== null && _e !== void 0 ? _e : mr.sha,
|
|
60
|
+
target_sha: (_f = mr.diff_refs) === null || _f === void 0 ? void 0 : _f.base_sha,
|
|
61
|
+
};
|
|
62
|
+
// --------------------------------------------------------------------------
|
|
63
|
+
// 2. Fetch MR changes
|
|
64
|
+
// --------------------------------------------------------------------------
|
|
65
|
+
const changesUrl = `${gitlabBaseUrl}/api/v4/projects/${project_id}/merge_requests/${mr_iid}/changes`;
|
|
66
|
+
const changesData = yield gitlabFetch(changesUrl, authToken);
|
|
67
|
+
const changes = changesData.changes.map(c => ({
|
|
68
|
+
old_path: c.old_path,
|
|
69
|
+
new_path: c.new_path,
|
|
70
|
+
new_file: c.new_file,
|
|
71
|
+
renamed_file: c.renamed_file,
|
|
72
|
+
deleted_file: c.deleted_file,
|
|
73
|
+
diff: c.diff,
|
|
74
|
+
}));
|
|
75
|
+
// --------------------------------------------------------------------------
|
|
76
|
+
// 3. Fetch MR commits
|
|
77
|
+
// --------------------------------------------------------------------------
|
|
78
|
+
const commitsUrl = `${gitlabBaseUrl}/api/v4/projects/${project_id}/merge_requests/${mr_iid}/commits`;
|
|
79
|
+
const commitsData = yield gitlabFetch(commitsUrl, authToken);
|
|
80
|
+
const commits = commitsData.map(c => ({
|
|
81
|
+
id: c.id,
|
|
82
|
+
title: c.title,
|
|
83
|
+
message: c.message,
|
|
84
|
+
author_name: c.author_name,
|
|
85
|
+
author_email: c.author_email,
|
|
86
|
+
created_at: c.created_at,
|
|
87
|
+
}));
|
|
88
|
+
// --------------------------------------------------------------------------
|
|
89
|
+
// Return final structured result
|
|
90
|
+
// --------------------------------------------------------------------------
|
|
91
|
+
return {
|
|
92
|
+
success: true,
|
|
93
|
+
results: [
|
|
94
|
+
{
|
|
95
|
+
metadata,
|
|
96
|
+
changes,
|
|
97
|
+
commits,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
export default getMergeRequestContent;
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
export interface GmailMessageResult {
|
|
2
|
-
id: string;
|
|
3
|
-
threadId: string;
|
|
4
|
-
snippet: string;
|
|
5
|
-
labelIds?: string[];
|
|
6
|
-
internalDate: string;
|
|
7
|
-
emailBody: string;
|
|
8
|
-
from?: string;
|
|
9
|
-
to?: string;
|
|
10
|
-
subject?: string;
|
|
11
|
-
cc?: string;
|
|
12
|
-
bcc?: string;
|
|
13
|
-
error?: string;
|
|
14
|
-
}
|
|
15
1
|
import type { googlemailSearchGmailMessagesFunction } from "../../autogen/types.js";
|
|
16
2
|
declare const searchGmailMessages: googlemailSearchGmailMessagesFunction;
|
|
17
3
|
export default searchGmailMessages;
|
|
@@ -40,7 +40,7 @@ function cleanAndTruncateEmail(text, maxLength = 2000) {
|
|
|
40
40
|
}
|
|
41
41
|
const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
42
42
|
if (!authParams.authToken) {
|
|
43
|
-
return { success: false, error: MISSING_AUTH_TOKEN,
|
|
43
|
+
return { success: false, error: MISSING_AUTH_TOKEN, results: [] };
|
|
44
44
|
}
|
|
45
45
|
const { query, maxResults, timeout } = params;
|
|
46
46
|
const max = Math.min(maxResults !== null && maxResults !== void 0 ? maxResults : DEFAULT_EMAIL_CONTENTS_FETCHED, MAX_EMAIL_CONTENTS_FETCHED);
|
|
@@ -63,6 +63,7 @@ const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
63
63
|
break;
|
|
64
64
|
const batch = messageList.slice(0, max - allMessages.length);
|
|
65
65
|
const results = yield Promise.allSettled(batch.map((msg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
var _a, _b, _c;
|
|
66
67
|
try {
|
|
67
68
|
yield limiter.removeTokens(1);
|
|
68
69
|
const msgRes = yield axiosClient.get(`https://gmail.googleapis.com/gmail/v1/users/me/messages/${msg.id}?format=full`, {
|
|
@@ -73,54 +74,53 @@ const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
73
74
|
const { id, threadId, snippet, labelIds, internalDate, payload } = msgRes.data;
|
|
74
75
|
const headers = {};
|
|
75
76
|
for (const header of payload.headers) {
|
|
76
|
-
|
|
77
|
-
if (lowerName === "from" ||
|
|
78
|
-
lowerName === "to" ||
|
|
79
|
-
lowerName === "subject" ||
|
|
80
|
-
lowerName === "cc" ||
|
|
81
|
-
lowerName === "bcc") {
|
|
82
|
-
headers[lowerName] = header.value;
|
|
83
|
-
}
|
|
77
|
+
headers[header.name.toLowerCase()] = header.value;
|
|
84
78
|
}
|
|
85
|
-
|
|
86
|
-
const emailBody = cleanAndTruncateEmail(
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
// Extract and clean the full text
|
|
80
|
+
const emailBody = cleanAndTruncateEmail(getEmailContent(msgRes.data) || "");
|
|
81
|
+
const subject = ((_a = headers.subject) === null || _a === void 0 ? void 0 : _a.trim()) || "(No subject)";
|
|
82
|
+
const from = ((_c = (_b = headers.from) === null || _b === void 0 ? void 0 : _b.split("<")[0]) === null || _c === void 0 ? void 0 : _c.trim()) || "Unknown sender";
|
|
83
|
+
const date = new Date(Number(internalDate)).toLocaleDateString("en-US");
|
|
84
|
+
const name = `${subject} — ${from} (${date})`;
|
|
85
|
+
return {
|
|
86
|
+
name,
|
|
87
|
+
url: `https://mail.google.com/mail/u/0/#inbox/${id}`,
|
|
88
|
+
contents: {
|
|
89
|
+
id,
|
|
90
|
+
from: headers.from,
|
|
91
|
+
to: headers.to,
|
|
92
|
+
cc: headers.cc,
|
|
93
|
+
bcc: headers.bcc,
|
|
94
|
+
snippet,
|
|
95
|
+
body: emailBody, // 👈 your old emailBody now lives here
|
|
96
|
+
labels: labelIds,
|
|
97
|
+
threadId,
|
|
98
|
+
internalDate,
|
|
99
|
+
},
|
|
99
100
|
};
|
|
100
|
-
return message;
|
|
101
101
|
}
|
|
102
102
|
catch (err) {
|
|
103
|
-
const
|
|
104
|
-
errorMessages.push(errorMessage);
|
|
103
|
+
const errorMsg = err instanceof Error ? err.message : "Failed to fetch message details";
|
|
105
104
|
return {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
105
|
+
name: "Error fetching message",
|
|
106
|
+
url: "",
|
|
107
|
+
contents: {
|
|
108
|
+
error: errorMsg,
|
|
109
|
+
id: msg.id,
|
|
110
|
+
threadId: "",
|
|
111
|
+
snippet: "",
|
|
112
|
+
internalDate: "",
|
|
113
|
+
body: "",
|
|
114
|
+
from: "",
|
|
115
|
+
to: "",
|
|
116
|
+
cc: "",
|
|
117
|
+
bcc: "",
|
|
118
|
+
labels: [],
|
|
119
|
+
},
|
|
118
120
|
};
|
|
119
121
|
}
|
|
120
122
|
})));
|
|
121
|
-
const successfulResults = results
|
|
122
|
-
.filter((r) => r.status === "fulfilled")
|
|
123
|
-
.map(r => r.value);
|
|
123
|
+
const successfulResults = results.filter(r => r.status === "fulfilled").map(r => r.value);
|
|
124
124
|
const failedResults = results.filter((r) => r.status === "rejected");
|
|
125
125
|
failedResults.forEach(r => {
|
|
126
126
|
const errorMessage = r.reason instanceof Error ? r.reason.message : "Failed to fetch message details";
|
|
@@ -134,15 +134,16 @@ const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
136
136
|
success: errorMessages.length === 0,
|
|
137
|
-
messages: allMessages,
|
|
138
137
|
error: errorMessages.join("; "),
|
|
138
|
+
results: allMessages,
|
|
139
|
+
pageToken,
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
catch (err) {
|
|
142
143
|
return {
|
|
143
144
|
success: false,
|
|
144
145
|
error: err instanceof Error ? err.message : "Unknown error searching Gmail",
|
|
145
|
-
|
|
146
|
+
results: [],
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
149
|
});
|
|
@@ -195,7 +195,6 @@ export function getUserEmailFromAccountId(accountId, client) {
|
|
|
195
195
|
return undefined;
|
|
196
196
|
try {
|
|
197
197
|
const userEmail = yield client.users.getUser({ accountId });
|
|
198
|
-
console.log("USER EMAIL: ", userEmail);
|
|
199
198
|
return userEmail.emailAddress;
|
|
200
199
|
}
|
|
201
200
|
catch (error) {
|
|
@@ -18,7 +18,7 @@ const addCommentToTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
18
18
|
}
|
|
19
19
|
const axiosClient = createAxiosClientWithRetries({ timeout: 20000, retryCount: 5 });
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
yield axiosClient.request({
|
|
22
22
|
url: url,
|
|
23
23
|
method: "PUT",
|
|
24
24
|
headers: {
|
|
@@ -34,7 +34,6 @@ const addCommentToTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
|
-
console.log(response.data);
|
|
38
37
|
return {
|
|
39
38
|
success: true,
|
|
40
39
|
ticketUrl: `https://${subdomain}.zendesk.com/agent/tickets/${ticketId}`,
|