agent-slack 0.4.1 → 0.4.3

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/README.md CHANGED
@@ -12,7 +12,7 @@ Guiding principle:
12
12
  Install via Bun (recommended):
13
13
 
14
14
  ```bash
15
- curl -fsSL https://raw.githubusercontent.com/stablyai/agent-slack/master/install.sh | sh
15
+ curl -fsSL https://raw.githubusercontent.com/stablyai/agent-slack/main/install.sh | sh
16
16
  ```
17
17
 
18
18
  OR npm global install (requires Node >= 22.5):
@@ -42,9 +42,11 @@ npx skills add stablyai/agent-slack
42
42
 
43
43
  <details>
44
44
  <summary>Manual installation</summary>
45
+
45
46
  ```bash
46
47
  bash ./scripts/install-skill.sh
47
48
  ```
49
+
48
50
  </details>
49
51
 
50
52
  ## Command map (high level)
package/dist/index.js CHANGED
@@ -1258,6 +1258,18 @@ function getNumber(value) {
1258
1258
  function isChannelId(input) {
1259
1259
  return /^[CDG][A-Z0-9]{8,}$/.test(input);
1260
1260
  }
1261
+ function isUserId(input) {
1262
+ return /^U[A-Z0-9]{8,}$/.test(input);
1263
+ }
1264
+ async function openDmChannel(client, userId) {
1265
+ const resp = await client.api("conversations.open", { users: userId });
1266
+ const channel = isRecord5(resp) ? resp.channel : null;
1267
+ const channelId = isRecord5(channel) ? getString(channel.id) : undefined;
1268
+ if (!channelId) {
1269
+ throw new Error(`Could not open DM channel for user: ${userId}`);
1270
+ }
1271
+ return channelId;
1272
+ }
1261
1273
  function normalizeChannelInput(input) {
1262
1274
  const trimmed = input.trim();
1263
1275
  if (trimmed.startsWith("#")) {
@@ -2941,6 +2953,9 @@ function parseMsgTarget(input) {
2941
2953
  const ref = parseSlackMessageUrl(trimmed);
2942
2954
  return { kind: "url", ref };
2943
2955
  } catch {}
2956
+ if (isUserId(trimmed)) {
2957
+ return { kind: "user", userId: trimmed };
2958
+ }
2944
2959
  if (trimmed.startsWith("#")) {
2945
2960
  return { kind: "channel", channel: trimmed };
2946
2961
  }
@@ -3123,6 +3138,9 @@ function requireOldestWhenReactionFiltersUsed(input) {
3123
3138
  }
3124
3139
  async function handleMessageGet(input) {
3125
3140
  const target = parseMsgTarget(input.targetInput);
3141
+ if (target.kind === "user") {
3142
+ throw new Error("message get does not support user ID targets. Use a channel name, channel ID, or message URL.");
3143
+ }
3126
3144
  const workspaceUrl = input.ctx.effectiveWorkspaceUrl(input.options.workspace);
3127
3145
  return input.ctx.withAutoRefresh({
3128
3146
  workspaceUrl: target.kind === "url" ? target.ref.workspace_url : workspaceUrl,
@@ -3168,6 +3186,9 @@ async function handleMessageGet(input) {
3168
3186
  }
3169
3187
  async function handleMessageList(input) {
3170
3188
  const target = parseMsgTarget(input.targetInput);
3189
+ if (target.kind === "user") {
3190
+ throw new Error("message list does not support user ID targets. Use a channel name, channel ID, or message URL.");
3191
+ }
3171
3192
  const workspaceUrl = input.ctx.effectiveWorkspaceUrl(input.options.workspace);
3172
3193
  return input.ctx.withAutoRefresh({
3173
3194
  workspaceUrl: target.kind === "url" ? target.ref.workspace_url : workspaceUrl,
@@ -3276,6 +3297,21 @@ async function sendMessage(input) {
3276
3297
  });
3277
3298
  return { ok: true };
3278
3299
  }
3300
+ if (target.kind === "user") {
3301
+ const workspaceUrl2 = input.ctx.effectiveWorkspaceUrl(input.options.workspace);
3302
+ await input.ctx.withAutoRefresh({
3303
+ workspaceUrl: workspaceUrl2,
3304
+ work: async () => {
3305
+ const { client } = await input.ctx.getClientForWorkspace(workspaceUrl2);
3306
+ const dmChannelId = await openDmChannel(client, target.userId);
3307
+ await client.api("chat.postMessage", {
3308
+ channel: dmChannelId,
3309
+ text: input.text
3310
+ });
3311
+ }
3312
+ });
3313
+ return { ok: true };
3314
+ }
3279
3315
  const workspaceUrl = input.ctx.effectiveWorkspaceUrl(input.options.workspace);
3280
3316
  await input.ctx.assertWorkspaceSpecifiedForChannelNames({
3281
3317
  workspaceUrl,
@@ -3297,6 +3333,9 @@ async function sendMessage(input) {
3297
3333
  }
3298
3334
  async function editMessage(input) {
3299
3335
  const target = parseMsgTarget(String(input.targetInput));
3336
+ if (target.kind === "user") {
3337
+ throw new Error("message edit does not support user ID targets. Use a channel name, channel ID, or message URL.");
3338
+ }
3300
3339
  const workspaceUrl = input.ctx.effectiveWorkspaceUrl(input.options.workspace);
3301
3340
  await input.ctx.withAutoRefresh({
3302
3341
  workspaceUrl: target.kind === "url" ? target.ref.workspace_url : workspaceUrl,
@@ -3330,6 +3369,9 @@ async function editMessage(input) {
3330
3369
  }
3331
3370
  async function deleteMessage(input) {
3332
3371
  const target = parseMsgTarget(String(input.targetInput));
3372
+ if (target.kind === "user") {
3373
+ throw new Error("message delete does not support user ID targets. Use a channel name, channel ID, or message URL.");
3374
+ }
3333
3375
  const workspaceUrl = input.ctx.effectiveWorkspaceUrl(input.options.workspace);
3334
3376
  await input.ctx.withAutoRefresh({
3335
3377
  workspaceUrl: target.kind === "url" ? target.ref.workspace_url : workspaceUrl,
@@ -3361,6 +3403,9 @@ async function deleteMessage(input) {
3361
3403
  }
3362
3404
  async function reactOnTarget(input) {
3363
3405
  const target = parseMsgTarget(input.targetInput);
3406
+ if (target.kind === "user") {
3407
+ throw new Error("react does not support user ID targets. Use a channel name, channel ID, or message URL.");
3408
+ }
3364
3409
  const workspaceUrl = input.ctx.effectiveWorkspaceUrl(input.options?.workspace);
3365
3410
  await input.ctx.withAutoRefresh({
3366
3411
  workspaceUrl: target.kind === "url" ? target.ref.workspace_url : workspaceUrl,
@@ -4780,6 +4825,9 @@ updateSendBtn();
4780
4825
  // src/cli/draft-actions.ts
4781
4826
  async function draftMessage(input) {
4782
4827
  const target = parseMsgTarget(String(input.targetInput));
4828
+ if (target.kind === "user") {
4829
+ throw new Error("message draft does not support user ID targets. Use a channel name, channel ID, or message URL.");
4830
+ }
4783
4831
  if (target.kind === "url") {
4784
4832
  const { ref } = target;
4785
4833
  warnOnTruncatedSlackUrl(ref);
@@ -6283,5 +6331,5 @@ if (subcommand && subcommand !== "update") {
6283
6331
  backgroundUpdateCheck();
6284
6332
  }
6285
6333
 
6286
- //# debugId=5576104C616416B664756E2164756E21
6334
+ //# debugId=53507951D9C889F664756E2164756E21
6287
6335
  //# sourceMappingURL=index.js.map