@vellumai/assistant 0.4.13 → 0.4.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "vellum": "./src/index.ts"
@@ -12,7 +12,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
12
12
  }
13
13
 
14
14
  try {
15
- return withSlackToken(async (token) => {
15
+ return await withSlackToken(async (token) => {
16
16
  await addReaction(token, channel, timestamp, emoji);
17
17
  return ok(`Added :${emoji}: reaction.`);
18
18
  });
@@ -11,7 +11,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
11
11
  }
12
12
 
13
13
  try {
14
- return withSlackToken(async (token) => {
14
+ return await withSlackToken(async (token) => {
15
15
  await deleteMessage(token, channel, timestamp);
16
16
  return ok(`Message deleted.`);
17
17
  });
@@ -10,7 +10,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
10
10
  }
11
11
 
12
12
  try {
13
- return withSlackToken(async (token) => {
13
+ return await withSlackToken(async (token) => {
14
14
  await leaveConversation(token, channel);
15
15
  return ok('Left channel.');
16
16
  });
@@ -130,10 +130,11 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
130
130
  const maxChannels = (input.max_channels as number) ?? 20;
131
131
 
132
132
  try {
133
- return withSlackToken(async (token) => {
133
+ return await withSlackToken(async (token) => {
134
134
  const oldestTs = String((Date.now() - hoursBack * 60 * 60 * 1000) / 1000);
135
135
 
136
136
  let channelsToScan: SlackConversation[];
137
+ let failedLookups = 0;
137
138
 
138
139
  if (channelIds?.length) {
139
140
  const results = await Promise.allSettled(
@@ -142,6 +143,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
142
143
  channelsToScan = results
143
144
  .filter((r): r is PromiseFulfilledResult<Awaited<ReturnType<typeof slack.conversationInfo>>> => r.status === 'fulfilled')
144
145
  .map((r) => r.value.channel);
146
+ failedLookups = results.filter((r) => r.status === 'rejected').length;
145
147
  } else {
146
148
  const config = getConfig();
147
149
  const preferredIds = config.skills?.entries?.slack?.config?.preferredChannels as string[] | undefined;
@@ -153,9 +155,17 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
153
155
  channelsToScan = results
154
156
  .filter((r): r is PromiseFulfilledResult<Awaited<ReturnType<typeof slack.conversationInfo>>> => r.status === 'fulfilled')
155
157
  .map((r) => r.value.channel);
158
+ failedLookups = results.filter((r) => r.status === 'rejected').length;
156
159
  } else {
157
- const resp = await slack.listConversations(token, 'public_channel,private_channel', true, 200);
158
- channelsToScan = resp.channels
160
+ const allChannels: SlackConversation[] = [];
161
+ let cursor: string | undefined;
162
+ do {
163
+ const resp = await slack.listConversations(token, 'public_channel,private_channel', true, 200, cursor);
164
+ allChannels.push(...resp.channels);
165
+ cursor = resp.response_metadata?.next_cursor || undefined;
166
+ } while (cursor);
167
+
168
+ channelsToScan = allChannels
159
169
  .filter((c) => c.is_member)
160
170
  .sort((a, b) => {
161
171
  const aTs = a.latest?.ts ? parseFloat(a.latest.ts) : 0;
@@ -181,6 +191,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
181
191
  scannedChannels: digests.length,
182
192
  totalChannelsAttempted: channelsToScan.length,
183
193
  skippedDueToErrors: skippedCount,
194
+ failedLookups,
184
195
  hoursBack,
185
196
  channels: digests,
186
197
  };