@tritard/waterbrother 0.16.56 → 0.16.58
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 +1 -1
- package/src/cli.js +3 -1
- package/src/gateway.js +29 -10
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -7593,7 +7593,9 @@ Be concrete about surfaces — name actual pages/flows. Choose the best stack fo
|
|
|
7593
7593
|
runtime: context.runtime,
|
|
7594
7594
|
currentSession
|
|
7595
7595
|
});
|
|
7596
|
-
const remoteLocalConceptAnswer =
|
|
7596
|
+
const remoteLocalConceptAnswer = remoteRequest.explicitExecution
|
|
7597
|
+
? null
|
|
7598
|
+
: resolveLocalConceptQuestion(remoteRequest.text || "", remoteManifest);
|
|
7597
7599
|
if (remoteLocalConceptAnswer) {
|
|
7598
7600
|
await deliverTelegramBridgeReply(remoteRequest, {
|
|
7599
7601
|
sessionId: remoteSessionId,
|
package/src/gateway.js
CHANGED
|
@@ -88,6 +88,16 @@ function stripTelegramMarkup(text) {
|
|
|
88
88
|
.replace(/&/g, "&");
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
function getTelegramBotAliases(me = {}) {
|
|
92
|
+
const aliases = new Set();
|
|
93
|
+
const username = String(me?.username || "").trim().toLowerCase();
|
|
94
|
+
if (username) aliases.add(username);
|
|
95
|
+
aliases.add("waterbrother");
|
|
96
|
+
aliases.add("waterbruh_bot");
|
|
97
|
+
aliases.add("waterbruh");
|
|
98
|
+
return [...aliases].filter(Boolean);
|
|
99
|
+
}
|
|
100
|
+
|
|
91
101
|
function splitLongPlainText(text, maxLength = TELEGRAM_MESSAGE_LIMIT) {
|
|
92
102
|
const value = String(text || "").trim();
|
|
93
103
|
if (!value) return [""];
|
|
@@ -913,20 +923,24 @@ class TelegramGateway {
|
|
|
913
923
|
|
|
914
924
|
normalizeTelegramCommandText(text) {
|
|
915
925
|
const value = String(text || "").trim();
|
|
916
|
-
const
|
|
917
|
-
if (!value || !
|
|
918
|
-
|
|
926
|
+
const aliases = getTelegramBotAliases(this.me);
|
|
927
|
+
if (!value || !aliases.length) return value;
|
|
928
|
+
for (const alias of aliases) {
|
|
929
|
+
const next = value.replace(new RegExp(`^(/\\w+)@${alias}\\b`, "i"), "$1");
|
|
930
|
+
if (next !== value) return next;
|
|
931
|
+
}
|
|
932
|
+
return value;
|
|
919
933
|
}
|
|
920
934
|
|
|
921
935
|
messageTargetsBot(message) {
|
|
922
936
|
if (!message?.chat) return false;
|
|
923
937
|
if (String(message.chat.type || "").trim() === "private") return true;
|
|
924
|
-
const
|
|
938
|
+
const aliases = getTelegramBotAliases(this.me);
|
|
925
939
|
const text = String(message?.text || "").trim();
|
|
926
940
|
if (!text) return false;
|
|
927
941
|
const normalized = this.normalizeTelegramCommandText(text);
|
|
928
942
|
if (normalized.startsWith("/")) return true;
|
|
929
|
-
if (
|
|
943
|
+
if (aliases.some((alias) => new RegExp(`(^|\\s)@${alias}(\\b|\\s|$)`, "i").test(text))) return true;
|
|
930
944
|
const replyFromId = String(message?.reply_to_message?.from?.id || "").trim();
|
|
931
945
|
const myId = String(this.me?.id || "").trim();
|
|
932
946
|
if (replyFromId && myId && replyFromId === myId) return true;
|
|
@@ -935,9 +949,13 @@ class TelegramGateway {
|
|
|
935
949
|
|
|
936
950
|
stripBotMention(text) {
|
|
937
951
|
const value = String(text || "").trim();
|
|
938
|
-
const
|
|
939
|
-
if (!value || !
|
|
940
|
-
|
|
952
|
+
const aliases = getTelegramBotAliases(this.me);
|
|
953
|
+
if (!value || !aliases.length) return value;
|
|
954
|
+
let next = value;
|
|
955
|
+
for (const alias of aliases) {
|
|
956
|
+
next = next.replace(new RegExp(`(^|\\s)@${alias}(\\b|\\s|$)`, "ig"), " ");
|
|
957
|
+
}
|
|
958
|
+
return next.replace(/\s+/g, " ").trim();
|
|
941
959
|
}
|
|
942
960
|
|
|
943
961
|
prunePairings() {
|
|
@@ -1630,7 +1648,7 @@ class TelegramGateway {
|
|
|
1630
1648
|
return host;
|
|
1631
1649
|
}
|
|
1632
1650
|
|
|
1633
|
-
async runPromptViaBridge(message, sessionId, promptText) {
|
|
1651
|
+
async runPromptViaBridge(message, sessionId, promptText, options = {}) {
|
|
1634
1652
|
const host = await this.getLiveBridgeHost();
|
|
1635
1653
|
if (!host) {
|
|
1636
1654
|
return null;
|
|
@@ -1649,6 +1667,7 @@ class TelegramGateway {
|
|
|
1649
1667
|
displayName: this.describeTelegramUser(message?.from || {}).displayName,
|
|
1650
1668
|
sessionId: String(sessionId || "").trim(),
|
|
1651
1669
|
text: String(promptText || "").trim(),
|
|
1670
|
+
explicitExecution: options.explicitExecution === true,
|
|
1652
1671
|
runtimeProfile: String(project?.runtimeProfile || "").trim(),
|
|
1653
1672
|
replyToMessageId: message.message_id,
|
|
1654
1673
|
requestedAt: new Date().toISOString(),
|
|
@@ -2716,7 +2735,7 @@ Ask them to run <code>/whoami</code> and then <code>/accept-invite ${escapeTeleg
|
|
|
2716
2735
|
return;
|
|
2717
2736
|
}
|
|
2718
2737
|
previewMessage = await this.sendProgressMessage(message.chat.id, message.message_id);
|
|
2719
|
-
const content = (await this.runPromptViaBridge(message, sessionId, promptText))
|
|
2738
|
+
const content = (await this.runPromptViaBridge(message, sessionId, promptText, { explicitExecution: shouldExecutePrompt }))
|
|
2720
2739
|
?? (await this.runPromptFallback(sessionId, promptText));
|
|
2721
2740
|
await this.deliverPromptResult(message.chat.id, message.message_id, previewMessage, content);
|
|
2722
2741
|
} catch (error) {
|