@credal/actions 0.2.168 → 0.2.170

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.
@@ -310,6 +310,10 @@ export const slackUserSearchSlackParamsSchema = z.object({
310
310
  .enum(["latest", "today", "yesterday", "last_7d", "last_30d", "all"])
311
311
  .describe("Optional time filter applied to the search.")
312
312
  .default("latest"),
313
+ messageType: z
314
+ .enum(["im", "group", "channel"])
315
+ .describe("Optional filter for the type of messages to search for. If not specified, all message types will be searched.")
316
+ .optional(),
313
317
  limit: z
314
318
  .number()
315
319
  .gte(1)
@@ -1041,15 +1045,6 @@ export const jiraDataCenterGetJiraIssuesByQueryOutputSchema = z.object({
1041
1045
  .optional(),
1042
1046
  error: z.string().describe("The error that occurred if the records were not successfully retrieved").optional(),
1043
1047
  });
1044
- export const kandjiGetFVRecoveryKeyForDeviceParamsSchema = z.object({
1045
- userEmail: z.string().describe("The email of the user requesting the recovery key"),
1046
- subdomain: z.string().describe("The subdomain of the Kandji account"),
1047
- });
1048
- export const kandjiGetFVRecoveryKeyForDeviceOutputSchema = z.object({
1049
- success: z.boolean().describe("Whether the recovery key was retrieved successfully"),
1050
- recoveryKey: z.string().describe("The FileVault recovery key for the device").optional(),
1051
- error: z.string().describe("The error that occurred if the recovery key was not retrieved successfully").optional(),
1052
- });
1053
1048
  export const googlemapsValidateAddressParamsSchema = z.object({
1054
1049
  regionCode: z.string().describe("The country of the address being verified."),
1055
1050
  locality: z.string().describe("The locality of the address being verified. This is likely a city."),
@@ -3792,93 +3787,6 @@ export const lookerEnableUserByEmailOutputSchema = z.object({
3792
3787
  .describe("Details about the user")
3793
3788
  .optional(),
3794
3789
  });
3795
- export const ashbyCreateNoteParamsSchema = z.object({
3796
- candidateId: z.string().describe("The ID of the candidate to create a note for"),
3797
- note: z.string().describe("The note content"),
3798
- });
3799
- export const ashbyCreateNoteOutputSchema = z.void();
3800
- export const ashbyGetCandidateInfoParamsSchema = z.object({
3801
- candidateId: z.string().describe("The ID of the candidate whose information is to be retrieved"),
3802
- });
3803
- export const ashbyGetCandidateInfoOutputSchema = z.object({
3804
- candidate: z.object({}).catchall(z.any()).describe("The candidate's information"),
3805
- });
3806
- export const ashbyAddCandidateToProjectParamsSchema = z.object({
3807
- candidateId: z.string().describe("The ID of the candidate to add to the project"),
3808
- projectId: z.string().describe("The ID of the project to add the candidate to"),
3809
- });
3810
- export const ashbyAddCandidateToProjectOutputSchema = z.void();
3811
- export const ashbyListCandidatesParamsSchema = z.object({});
3812
- export const ashbyListCandidatesOutputSchema = z.object({
3813
- candidates: z.array(z.any()).describe("A list of candidates"),
3814
- });
3815
- export const ashbySearchCandidatesParamsSchema = z.object({
3816
- email: z.string().describe("The email address of the candidate to search for").optional(),
3817
- name: z.string().describe("The name of the candidate to search for").optional(),
3818
- });
3819
- export const ashbySearchCandidatesOutputSchema = z.object({
3820
- candidates: z.array(z.any()).describe("A list of candidates"),
3821
- });
3822
- export const ashbyListCandidateNotesParamsSchema = z.object({
3823
- candidateId: z.string().describe("The ID of the candidate"),
3824
- });
3825
- export const ashbyListCandidateNotesOutputSchema = z.object({ notes: z.array(z.any()).describe("A list of notes") });
3826
- export const ashbyCreateCandidateParamsSchema = z.object({
3827
- name: z.string().describe("The first and last name of the candidate to be created."),
3828
- email: z.string().describe("Primary, personal email of the candidate to be created.").optional(),
3829
- phoneNumber: z.string().describe("Primary, personal phone number of the candidate to be created.").optional(),
3830
- linkedInUrl: z.string().describe("Url to the candidate's LinkedIn profile. Must be a valid Url.").optional(),
3831
- githubUrl: z.string().describe("Url to the candidate's Github profile. Must be a valid Url.").optional(),
3832
- website: z.string().describe("Url of the candidate's website. Must be a valid Url.").optional(),
3833
- alternateEmailAddresses: z
3834
- .array(z.string())
3835
- .describe("Array of alternate email address to add to the candidate's profile.")
3836
- .optional(),
3837
- sourceId: z.string().describe("The source to set on the candidate being created.").optional(),
3838
- creditedToUserId: z.string().describe("The id of the user the candidate will be credited to.").optional(),
3839
- location: z
3840
- .object({
3841
- city: z.string().describe("The city of the candidate.").optional(),
3842
- region: z.string().describe("The region of the candidate.").optional(),
3843
- country: z.string().describe("The country of the candidate.").optional(),
3844
- })
3845
- .describe("The location of the candidate.")
3846
- .optional(),
3847
- });
3848
- export const ashbyCreateCandidateOutputSchema = z.void();
3849
- export const ashbyUpdateCandidateParamsSchema = z.object({
3850
- candidateId: z.string().describe("The ID of the candidate to update"),
3851
- name: z.string().describe("The first and last name of the candidate to update.").optional(),
3852
- email: z.string().describe("Primary, personal email of the candidate to update.").optional(),
3853
- phoneNumber: z.string().describe("Primary, personal phone number of the candidate to update.").optional(),
3854
- linkedInUrl: z.string().describe("Url to the candidate's LinkedIn profile. Must be a valid Url.").optional(),
3855
- githubUrl: z.string().describe("Url to the candidate's Github profile. Must be a valid Url.").optional(),
3856
- websiteUrl: z.string().describe("Url of the candidate's website. Must be a valid Url.").optional(),
3857
- alternateEmail: z.string().describe("An alternate email address to add to the candidate's profile.").optional(),
3858
- socialLinks: z
3859
- .array(z.object({
3860
- type: z.string().describe("The type of social link").optional(),
3861
- url: z.string().describe("The URL of the social link").optional(),
3862
- }))
3863
- .describe("An array of social links to set on the candidate. This value replaces existing socialLinks that have been set on the candidate.")
3864
- .optional(),
3865
- sourceId: z.string().describe("The id of source for this candidate.").optional(),
3866
- creditedToUserId: z.string().describe("The id of the user the candidate will be credited to.").optional(),
3867
- location: z
3868
- .object({
3869
- city: z.string().describe("The city of the candidate").optional(),
3870
- region: z.string().describe("The region of the candidate").optional(),
3871
- country: z.string().describe("The country of the candidate").optional(),
3872
- })
3873
- .describe("The location of the candidate.")
3874
- .optional(),
3875
- createdAt: z.string().describe("An ISO date string to set the candidate's createdAt timestamp.").optional(),
3876
- sendNotifications: z
3877
- .boolean()
3878
- .describe("Whether or not users who are subscribed to the candidate should be notified that candidate was updated. Default is true.")
3879
- .optional(),
3880
- });
3881
- export const ashbyUpdateCandidateOutputSchema = z.void();
3882
3790
  export const salesforceUpdateRecordParamsSchema = z.object({
3883
3791
  objectType: z.string().describe("The Salesforce object type to update (e.g., Lead, Account, Contact)"),
3884
3792
  recordId: z.string().describe("The ID of the record to update"),
@@ -4649,38 +4557,6 @@ export const notionSearchByTitleOutputSchema = z.object({
4649
4557
  .optional(),
4650
4558
  error: z.string().describe("Error message if search failed").optional(),
4651
4559
  });
4652
- export const jamfGetJamfFileVaultRecoveryKeyParamsSchema = z.object({
4653
- computerId: z.string().describe("The computerId of the device to get the FileVault2 recovery key for"),
4654
- });
4655
- export const jamfGetJamfFileVaultRecoveryKeyOutputSchema = z.object({
4656
- success: z.boolean().describe("Whether the request was successful"),
4657
- data: z.string().describe("The FileVault2 recovery key data").optional(),
4658
- error: z.string().describe("Error message if the request failed").optional(),
4659
- });
4660
- export const jamfGetJamfComputerInventoryParamsSchema = z.object({
4661
- section: z.string().describe("Optional section parameter to filter inventory data").optional(),
4662
- });
4663
- export const jamfGetJamfComputerInventoryOutputSchema = z.object({
4664
- success: z.boolean().describe("Whether the request was successful"),
4665
- data: z.array(z.any()).describe("The computer inventory data").optional(),
4666
- error: z.string().describe("Error message if the request failed").optional(),
4667
- });
4668
- export const jamfGetJamfUserComputerIdParamsSchema = z.object({
4669
- userEmail: z.string().describe("The email of the Jamf user to retrieve the computer ID for"),
4670
- });
4671
- export const jamfGetJamfUserComputerIdOutputSchema = z.object({
4672
- success: z.boolean().describe("Whether the request was successful"),
4673
- computerId: z.string().describe("The computer ID associated with the user").optional(),
4674
- error: z.string().describe("Error message if the request failed").optional(),
4675
- });
4676
- export const jamfLockJamfComputerByIdParamsSchema = z.object({
4677
- computerId: z.string().describe("The computer ID of the device to lock"),
4678
- passcode: z.string().describe("Six digit passcode to unlock the computer afterwards"),
4679
- });
4680
- export const jamfLockJamfComputerByIdOutputSchema = z.object({
4681
- success: z.boolean().describe("Whether the lock command was successful"),
4682
- error: z.string().describe("Error message if the lock command failed").optional(),
4683
- });
4684
4560
  export const gitlabSearchGroupParamsSchema = z.object({
4685
4561
  query: z.string().describe("The query that will be used to search gitlab blobs and merge requests"),
4686
4562
  groupId: z.string().describe("The group ID of the project to search in"),
@@ -18,6 +18,7 @@ const MENTION_USER_RE = /<@([UW][A-Z0-9]+)(?:\|[^>]+)?>/g;
18
18
  const MENTION_CHANNEL_RE = /<#(C[A-Z0-9]+)(?:\|[^>]+)?>/g;
19
19
  const SPECIAL_RE = /<!(channel|here|everyone)>/g;
20
20
  const SUBTEAM_RE = /<!subteam\^([A-Z0-9]+)(?:\|[^>]+)?>/g;
21
+ const MAX_LIMIT_PER_PAGE = 100;
21
22
  /* ===================== Cache ===================== */
22
23
  class SlackUserCache {
23
24
  constructor(client) {
@@ -70,6 +71,12 @@ function normalizeChannelOperand(ch) {
70
71
  return s;
71
72
  return s.replace(/^#/, "");
72
73
  }
74
+ function getMessageTypeFilter(messageType) {
75
+ // This converts the LLM readable message type to the Slack search API message type (e.g. "channel" -> "message")
76
+ if (messageType === "channel")
77
+ return "message";
78
+ return messageType;
79
+ }
73
80
  function fmtDaysAgo(n) {
74
81
  const d = new Date();
75
82
  d.setDate(d.getDate() - n);
@@ -202,7 +209,7 @@ function expandSlackEntities(cache, raw) {
202
209
  function searchScoped(input) {
203
210
  return __awaiter(this, void 0, void 0, function* () {
204
211
  var _a, _b;
205
- const { client, scope, topic, timeRange, limit } = input;
212
+ const { client, scope, topic, timeRange } = input;
206
213
  const parts = [];
207
214
  if (scope)
208
215
  parts.push(`in:${scope}`);
@@ -212,14 +219,14 @@ function searchScoped(input) {
212
219
  if (tf)
213
220
  parts.push(tf);
214
221
  const query = parts.join(" ");
215
- const searchRes = yield client.search.messages({ query, count: limit, highlight: true });
222
+ const searchRes = yield client.search.messages({ query, count: MAX_LIMIT_PER_PAGE, highlight: true });
216
223
  return (_b = (_a = searchRes.messages) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : [];
217
224
  });
218
225
  }
219
226
  function searchByTopic(input) {
220
227
  return __awaiter(this, void 0, void 0, function* () {
221
228
  var _a, _b;
222
- const { client, topic, timeRange, limit } = input;
229
+ const { client, topic, timeRange } = input;
223
230
  const parts = [];
224
231
  if (topic === null || topic === void 0 ? void 0 : topic.trim())
225
232
  parts.push(topic.trim());
@@ -227,7 +234,7 @@ function searchByTopic(input) {
227
234
  if (tf)
228
235
  parts.push(tf);
229
236
  const query = parts.join(" ");
230
- const searchRes = yield client.search.messages({ query, count: limit, highlight: true });
237
+ const searchRes = yield client.search.messages({ query, count: MAX_LIMIT_PER_PAGE, highlight: true });
231
238
  return (_b = (_a = searchRes.messages) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : [];
232
239
  });
233
240
  }
@@ -277,7 +284,8 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
277
284
  throw new Error(MISSING_AUTH_TOKEN);
278
285
  const client = new WebClient(authParams.authToken);
279
286
  const cache = new SlackUserCache(client);
280
- const { emails, topic, timeRange, limit = 20, channel, fetchAdjacentMessages = true } = params;
287
+ const { emails, topic, timeRange, limit = 20, channel, fetchAdjacentMessages = true, messageType } = params;
288
+ const messageTypeFilter = getMessageTypeFilter(messageType);
281
289
  const { user_id: myUserId } = yield client.auth.test();
282
290
  if (!myUserId)
283
291
  throw new Error("Failed to get my user ID.");
@@ -289,14 +297,12 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
289
297
  const allMatches = [];
290
298
  const searchPromises = [];
291
299
  if (filteredTargetIds.length === 1) {
292
- searchPromises.push(searchScoped({ client, scope: `<@${filteredTargetIds[0]}>`, topic, timeRange, limit }));
300
+ searchPromises.push(searchScoped({ client, scope: `<@${filteredTargetIds[0]}>`, topic, timeRange }));
293
301
  }
294
302
  else if (filteredTargetIds.length >= 2) {
295
303
  const searchMPIM = () => __awaiter(void 0, void 0, void 0, function* () {
296
304
  const mpimName = yield tryGetMPIMName(client, filteredTargetIds);
297
- return mpimName
298
- ? searchScoped({ client, scope: mpimName, topic, timeRange, limit: Math.max(Math.floor(limit / 2), 1) })
299
- : [];
305
+ return mpimName ? searchScoped({ client, scope: mpimName, topic, timeRange }) : [];
300
306
  });
301
307
  searchPromises.push(searchMPIM());
302
308
  searchPromises.push(...filteredTargetIds.map(id => searchScoped({
@@ -304,7 +310,6 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
304
310
  scope: `<@${id}>`,
305
311
  topic,
306
312
  timeRange,
307
- limit: Math.max(Math.floor(limit / filteredTargetIds.length), 1),
308
313
  })));
309
314
  }
310
315
  else if (channel) {
@@ -313,7 +318,6 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
313
318
  scope: normalizeChannelOperand(channel),
314
319
  topic,
315
320
  timeRange,
316
- limit: Math.max(Math.floor(limit / 2), 1),
317
321
  }));
318
322
  }
319
323
  else if (timeRange) {
@@ -321,7 +325,6 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
321
325
  client,
322
326
  topic,
323
327
  timeRange,
324
- limit: Math.max(Math.floor(limit / 2), 1),
325
328
  }));
326
329
  }
327
330
  if (topic) {
@@ -329,11 +332,20 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
329
332
  client,
330
333
  topic,
331
334
  timeRange,
332
- limit: Math.max(Math.floor(limit / Math.max(searchPromises.length, 1)), 1),
333
335
  }));
334
336
  }
335
337
  const searchResults = yield Promise.all(searchPromises);
336
- searchResults.forEach(matches => allMatches.push(...matches));
338
+ const searchResultsFilteredByTypeAndLimit = searchResults.map(matches => {
339
+ return matches
340
+ .filter(m => {
341
+ if (messageTypeFilter) {
342
+ return m.type === messageTypeFilter;
343
+ }
344
+ return true;
345
+ })
346
+ .slice(0, Math.max(Math.floor(limit / Math.max(searchPromises.length, 1)), 1));
347
+ });
348
+ searchResultsFilteredByTypeAndLimit.forEach(matches => allMatches.push(...matches));
337
349
  const channelInfoCache = new Map();
338
350
  const expanded = yield Promise.all(allMatches.map(m => limitHit(() => __awaiter(void 0, void 0, void 0, function* () {
339
351
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _o;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.168",
3
+ "version": "0.2.170",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,