clisbot 0.1.29 → 0.1.30
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/main.js +62 -12
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __returnValue = (v) => v;
|
|
34
|
+
function __exportSetter(name, newValue) {
|
|
35
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
36
|
+
}
|
|
19
37
|
var __export = (target, all) => {
|
|
20
38
|
for (var name in all)
|
|
21
39
|
__defProp(target, name, {
|
|
22
40
|
get: all[name],
|
|
23
41
|
enumerable: true,
|
|
24
42
|
configurable: true,
|
|
25
|
-
set: (
|
|
43
|
+
set: __exportSetter.bind(all, name)
|
|
26
44
|
});
|
|
27
45
|
};
|
|
28
46
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
@@ -69343,7 +69361,7 @@ function isSlackCommandLikeMessage(params) {
|
|
|
69343
69361
|
}) !== null;
|
|
69344
69362
|
}
|
|
69345
69363
|
function renderSlackRouteChoiceMessage(params) {
|
|
69346
|
-
const
|
|
69364
|
+
const botReference = params.botLabel?.trim() ? `mention this bot (${params.botLabel.trim()})` : "mention this bot";
|
|
69347
69365
|
return [
|
|
69348
69366
|
"clisbot: this Slack channel is not configured yet.",
|
|
69349
69367
|
"",
|
|
@@ -69351,19 +69369,34 @@ function renderSlackRouteChoiceMessage(params) {
|
|
|
69351
69369
|
`- \`clisbot channels add slack-channel ${params.channelId}\``,
|
|
69352
69370
|
`- \`clisbot channels add slack-channel ${params.channelId} --agent <id>\``,
|
|
69353
69371
|
"",
|
|
69354
|
-
`After that,
|
|
69372
|
+
`After that, ${botReference} and send \`\\start\` or \`\\status\` here.`
|
|
69355
69373
|
].join(`
|
|
69356
69374
|
`);
|
|
69357
69375
|
}
|
|
69358
69376
|
function renderSlackMentionRequiredMessage(botLabel) {
|
|
69359
|
-
const
|
|
69377
|
+
const botReference = botLabel?.trim() ? `mention this bot (${botLabel.trim()})` : "mention this bot";
|
|
69360
69378
|
return [
|
|
69361
69379
|
"clisbot: this Slack channel requires a bot mention for new commands.",
|
|
69362
|
-
`Try
|
|
69380
|
+
`Try ${botReference} and send \`\\start\` or \`\\status\` here.`,
|
|
69363
69381
|
"After the bot replies in a thread, normal follow-up messages there can continue according to the follow-up policy."
|
|
69364
69382
|
].join(`
|
|
69365
69383
|
`);
|
|
69366
69384
|
}
|
|
69385
|
+
function shouldSendSlackMentionRequiredGuidance(params) {
|
|
69386
|
+
return params.conversationKind === "dm" && params.isCommandLike;
|
|
69387
|
+
}
|
|
69388
|
+
function shouldGuideUnroutedSlackEvent(params) {
|
|
69389
|
+
if (params.isBotOriginated) {
|
|
69390
|
+
return false;
|
|
69391
|
+
}
|
|
69392
|
+
if (!params.isCommandLike) {
|
|
69393
|
+
return false;
|
|
69394
|
+
}
|
|
69395
|
+
if (params.conversationKind === "dm") {
|
|
69396
|
+
return true;
|
|
69397
|
+
}
|
|
69398
|
+
return params.wasMentioned;
|
|
69399
|
+
}
|
|
69367
69400
|
async function sendSlackGuidanceOnce(params) {
|
|
69368
69401
|
if (!params.eventId) {
|
|
69369
69402
|
await params.send();
|
|
@@ -70116,11 +70149,15 @@ class SlackSocketService {
|
|
|
70116
70149
|
directReplyToBot: isImplicitBotThreadReply(event, this.botUserId)
|
|
70117
70150
|
});
|
|
70118
70151
|
if (requiresMention && !wasMentioned) {
|
|
70119
|
-
|
|
70152
|
+
const isCommandLike = isSlackCommandLikeMessage({
|
|
70120
70153
|
text: event.text ?? "",
|
|
70121
70154
|
botUserId: this.botUserId,
|
|
70122
70155
|
botUsername: this.botLabel,
|
|
70123
70156
|
commandPrefixes: params.route.commandPrefixes
|
|
70157
|
+
});
|
|
70158
|
+
if (shouldSendSlackMentionRequiredGuidance({
|
|
70159
|
+
conversationKind: params.conversationKind,
|
|
70160
|
+
isCommandLike
|
|
70124
70161
|
})) {
|
|
70125
70162
|
try {
|
|
70126
70163
|
await postSlackText(this.app.client, {
|
|
@@ -70137,6 +70174,7 @@ class SlackSocketService {
|
|
|
70137
70174
|
channelId,
|
|
70138
70175
|
requiresMention,
|
|
70139
70176
|
explicitMention,
|
|
70177
|
+
isCommandLike,
|
|
70140
70178
|
effectiveFollowUpMode
|
|
70141
70179
|
});
|
|
70142
70180
|
await this.processedEventsStore.markCompleted(eventId);
|
|
@@ -70323,6 +70361,13 @@ class SlackSocketService {
|
|
|
70323
70361
|
const resolvedRoute = resolveSlackConversationRoute(this.loadedConfig, normalizedEvent, { accountId: this.accountId });
|
|
70324
70362
|
const route = resolvedRoute.route;
|
|
70325
70363
|
if (!route) {
|
|
70364
|
+
if (isBotOriginatedSlackEvent(normalizedEvent) && !this.loadedConfig.raw.channels.slack.allowBots) {
|
|
70365
|
+
debugSlackEvent("drop-unrouted-bot-mention", {
|
|
70366
|
+
eventId: body.event_id,
|
|
70367
|
+
allowBots: this.loadedConfig.raw.channels.slack.allowBots
|
|
70368
|
+
});
|
|
70369
|
+
return;
|
|
70370
|
+
}
|
|
70326
70371
|
try {
|
|
70327
70372
|
await this.maybeGuideUnroutedSlackEvent({
|
|
70328
70373
|
eventId: body.event_id,
|
|
@@ -70358,11 +70403,16 @@ class SlackSocketService {
|
|
|
70358
70403
|
const resolvedRoute = resolveSlackConversationRoute(this.loadedConfig, normalizedEvent, { accountId: this.accountId });
|
|
70359
70404
|
const route = resolvedRoute.route;
|
|
70360
70405
|
if (!route) {
|
|
70361
|
-
const shouldGuide =
|
|
70362
|
-
|
|
70363
|
-
|
|
70364
|
-
|
|
70365
|
-
|
|
70406
|
+
const shouldGuide = shouldGuideUnroutedSlackEvent({
|
|
70407
|
+
conversationKind: resolvedRoute.conversationKind,
|
|
70408
|
+
isCommandLike: isSlackCommandLikeMessage({
|
|
70409
|
+
text: normalizedEvent.text ?? "",
|
|
70410
|
+
botUserId: this.botUserId,
|
|
70411
|
+
botUsername: this.botLabel,
|
|
70412
|
+
commandPrefixes: this.loadedConfig.raw.channels.slack.commandPrefixes
|
|
70413
|
+
}),
|
|
70414
|
+
wasMentioned: hasBotMention(normalizedEvent.text ?? "", this.botUserId),
|
|
70415
|
+
isBotOriginated: isBotOriginatedSlackEvent(normalizedEvent) && !this.loadedConfig.raw.channels.slack.allowBots
|
|
70366
70416
|
});
|
|
70367
70417
|
if (shouldGuide) {
|
|
70368
70418
|
try {
|