agent-slack 0.9.0 → 0.9.1
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/index.js +62 -11
- package/dist/index.js.map +6 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3589,14 +3589,32 @@ var CODE_BLOCK_START = /^```/;
|
|
|
3589
3589
|
var BLOCKQUOTE_RE = /^> (.*)$/;
|
|
3590
3590
|
function parseInlineElements(text) {
|
|
3591
3591
|
const elements = [];
|
|
3592
|
-
const re = /`([^`]+)`|\*([^*]+)\*|_([^_]+)_|~([^~]+)
|
|
3592
|
+
const re = /`([^`]+)`|\*([^*]+)\*|_([^_]+)_|~([^~]+)~|<@([UWB][A-Z0-9]+)(?:\|[^>]*)?>|<!(here|channel|everyone)(?:\|[^>]*)?>|<([^>|]+)\|([^>]+)>|<([^>|]+)>|(?:^|(?<=[^A-Za-z0-9_]))@([UWB][A-Z0-9]{6,})\b|(?:^|(?<=[^A-Za-z0-9_]))@(here|channel|everyone)\b/g;
|
|
3593
3593
|
let lastIndex = 0;
|
|
3594
3594
|
let match;
|
|
3595
|
+
const pushText = (slice) => {
|
|
3596
|
+
if (slice) {
|
|
3597
|
+
elements.push({ type: "text", text: slice });
|
|
3598
|
+
}
|
|
3599
|
+
};
|
|
3595
3600
|
while ((match = re.exec(text)) !== null) {
|
|
3596
3601
|
if (match.index > lastIndex) {
|
|
3597
|
-
|
|
3598
|
-
}
|
|
3599
|
-
const [
|
|
3602
|
+
pushText(text.slice(lastIndex, match.index));
|
|
3603
|
+
}
|
|
3604
|
+
const [
|
|
3605
|
+
,
|
|
3606
|
+
code,
|
|
3607
|
+
bold,
|
|
3608
|
+
italic,
|
|
3609
|
+
strike,
|
|
3610
|
+
userToken,
|
|
3611
|
+
broadcastToken,
|
|
3612
|
+
linkUrl,
|
|
3613
|
+
linkText,
|
|
3614
|
+
bareUrl,
|
|
3615
|
+
bareUserId,
|
|
3616
|
+
bareBroadcast
|
|
3617
|
+
] = match;
|
|
3600
3618
|
if (code != null) {
|
|
3601
3619
|
elements.push({ type: "text", text: code, style: { code: true } });
|
|
3602
3620
|
} else if (bold != null) {
|
|
@@ -3605,15 +3623,29 @@ function parseInlineElements(text) {
|
|
|
3605
3623
|
elements.push({ type: "text", text: italic, style: { italic: true } });
|
|
3606
3624
|
} else if (strike != null) {
|
|
3607
3625
|
elements.push({ type: "text", text: strike, style: { strike: true } });
|
|
3626
|
+
} else if (userToken != null) {
|
|
3627
|
+
elements.push({ type: "user", user_id: userToken });
|
|
3628
|
+
} else if (broadcastToken != null) {
|
|
3629
|
+
elements.push({
|
|
3630
|
+
type: "broadcast",
|
|
3631
|
+
range: broadcastToken
|
|
3632
|
+
});
|
|
3608
3633
|
} else if (linkUrl != null && linkText != null) {
|
|
3609
3634
|
elements.push({ type: "link", url: linkUrl, text: linkText });
|
|
3610
3635
|
} else if (bareUrl != null) {
|
|
3611
3636
|
elements.push({ type: "link", url: bareUrl });
|
|
3637
|
+
} else if (bareUserId != null) {
|
|
3638
|
+
elements.push({ type: "user", user_id: bareUserId });
|
|
3639
|
+
} else if (bareBroadcast != null) {
|
|
3640
|
+
elements.push({
|
|
3641
|
+
type: "broadcast",
|
|
3642
|
+
range: bareBroadcast
|
|
3643
|
+
});
|
|
3612
3644
|
}
|
|
3613
3645
|
lastIndex = match.index + match[0].length;
|
|
3614
3646
|
}
|
|
3615
3647
|
if (lastIndex < text.length) {
|
|
3616
|
-
|
|
3648
|
+
pushText(text.slice(lastIndex));
|
|
3617
3649
|
}
|
|
3618
3650
|
return elements.length > 0 ? elements : [{ type: "text", text }];
|
|
3619
3651
|
}
|
|
@@ -3736,6 +3768,23 @@ function collectList(input) {
|
|
|
3736
3768
|
return idx;
|
|
3737
3769
|
}
|
|
3738
3770
|
|
|
3771
|
+
// src/slack/format-outbound.ts
|
|
3772
|
+
function formatOutboundSlackText(text) {
|
|
3773
|
+
if (!text) {
|
|
3774
|
+
return "";
|
|
3775
|
+
}
|
|
3776
|
+
const stash = [];
|
|
3777
|
+
let out = text.replace(/<(?:@[UWB][A-Z0-9]+(?:\|[^>]*)?|#[CG][A-Z0-9]+(?:\|[^>]*)?|![a-zA-Z]+(?:\|[^>]*)?|https?:\/\/[^>]+)>/g, (m) => {
|
|
3778
|
+
stash.push(m);
|
|
3779
|
+
return `\x00${stash.length - 1}\x00`;
|
|
3780
|
+
});
|
|
3781
|
+
out = out.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3782
|
+
out = out.replace(/(^|[^A-Za-z0-9_])@([UWB][A-Z0-9]{6,})\b/g, (_m, pre, id) => `${pre}<@${id}>`);
|
|
3783
|
+
out = out.replace(/(^|[^A-Za-z0-9_])@(here|channel|everyone)\b/g, (_m, pre, name) => `${pre}<!${name}>`);
|
|
3784
|
+
out = out.replace(/\u0000(\d+)\u0000/g, (_m, idx) => stash[Number(idx)]);
|
|
3785
|
+
return out;
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3739
3788
|
// src/slack/upload.ts
|
|
3740
3789
|
import { readFile as readFile5, stat, realpath } from "node:fs/promises";
|
|
3741
3790
|
import { basename as basename2 } from "node:path";
|
|
@@ -4595,6 +4644,7 @@ function requireOldestWhenReactionFiltersUsed(input) {
|
|
|
4595
4644
|
}
|
|
4596
4645
|
async function sendMessage(input) {
|
|
4597
4646
|
const target = parseMsgTarget(String(input.targetInput));
|
|
4647
|
+
const formattedText = formatOutboundSlackText(input.text);
|
|
4598
4648
|
const blocks = input.text ? textToRichTextBlocks(input.text) : null;
|
|
4599
4649
|
const attachPaths = normalizeAttachPaths(input.options.attach);
|
|
4600
4650
|
if (target.kind === "url") {
|
|
@@ -4610,7 +4660,7 @@ async function sendMessage(input) {
|
|
|
4610
4660
|
client,
|
|
4611
4661
|
workspaceUrl: workspace_url ?? ref.workspace_url,
|
|
4612
4662
|
channelId: ref.channel_id,
|
|
4613
|
-
text:
|
|
4663
|
+
text: formattedText,
|
|
4614
4664
|
blocks,
|
|
4615
4665
|
threadTs,
|
|
4616
4666
|
attachPaths
|
|
@@ -4629,7 +4679,7 @@ async function sendMessage(input) {
|
|
|
4629
4679
|
client,
|
|
4630
4680
|
workspaceUrl: workspace_url ?? workspaceUrl2,
|
|
4631
4681
|
channelId: dmChannelId,
|
|
4632
|
-
text:
|
|
4682
|
+
text: formattedText,
|
|
4633
4683
|
blocks,
|
|
4634
4684
|
attachPaths
|
|
4635
4685
|
});
|
|
@@ -4650,7 +4700,7 @@ async function sendMessage(input) {
|
|
|
4650
4700
|
client,
|
|
4651
4701
|
workspaceUrl: workspace_url ?? workspaceUrl,
|
|
4652
4702
|
channelId,
|
|
4653
|
-
text:
|
|
4703
|
+
text: formattedText,
|
|
4654
4704
|
blocks,
|
|
4655
4705
|
threadTs: input.options.threadTs ? String(input.options.threadTs) : undefined,
|
|
4656
4706
|
attachPaths
|
|
@@ -4721,6 +4771,7 @@ async function editMessage(input) {
|
|
|
4721
4771
|
throw new Error("message edit does not support user ID targets. Use a channel name, channel ID, or message URL.");
|
|
4722
4772
|
}
|
|
4723
4773
|
const workspaceUrl = input.ctx.effectiveWorkspaceUrl(input.options.workspace);
|
|
4774
|
+
const formattedText = formatOutboundSlackText(input.text);
|
|
4724
4775
|
await input.ctx.withAutoRefresh({
|
|
4725
4776
|
workspaceUrl: target.kind === "url" ? target.ref.workspace_url : workspaceUrl,
|
|
4726
4777
|
work: async () => {
|
|
@@ -4731,7 +4782,7 @@ async function editMessage(input) {
|
|
|
4731
4782
|
await client2.api("chat.update", {
|
|
4732
4783
|
channel: ref.channel_id,
|
|
4733
4784
|
ts: ref.message_ts,
|
|
4734
|
-
text:
|
|
4785
|
+
text: formattedText
|
|
4735
4786
|
});
|
|
4736
4787
|
return;
|
|
4737
4788
|
}
|
|
@@ -4745,7 +4796,7 @@ async function editMessage(input) {
|
|
|
4745
4796
|
await client.api("chat.update", {
|
|
4746
4797
|
channel: channelId,
|
|
4747
4798
|
ts,
|
|
4748
|
-
text:
|
|
4799
|
+
text: formattedText
|
|
4749
4800
|
});
|
|
4750
4801
|
}
|
|
4751
4802
|
});
|
|
@@ -9185,5 +9236,5 @@ if (subcommand && subcommand !== "update") {
|
|
|
9185
9236
|
backgroundUpdateCheck();
|
|
9186
9237
|
}
|
|
9187
9238
|
|
|
9188
|
-
//# debugId=
|
|
9239
|
+
//# debugId=D4BE12D81E739FC964756E2164756E21
|
|
9189
9240
|
//# sourceMappingURL=index.js.map
|