@inline-openclaw/inline 0.0.22 → 0.0.23
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 +43 -6
- package/dist/index.js +395 -79
- package/dist/index.js.map +8 -7
- package/dist/inline/actions.d.ts.map +1 -1
- package/dist/inline/channel.d.ts.map +1 -1
- package/dist/inline/config-schema.d.ts +21 -0
- package/dist/inline/config-schema.d.ts.map +1 -1
- package/dist/inline/monitor.d.ts.map +1 -1
- package/dist/inline/reply-threads.d.ts +34 -0
- package/dist/inline/reply-threads.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -33735,6 +33735,9 @@ var InlineActionsSchema = exports_external.object({
|
|
|
33735
33735
|
pins: exports_external.boolean().optional(),
|
|
33736
33736
|
permissions: exports_external.boolean().optional()
|
|
33737
33737
|
}).strict();
|
|
33738
|
+
var InlineCapabilitiesSchema = exports_external.object({
|
|
33739
|
+
replyThreads: exports_external.boolean().optional()
|
|
33740
|
+
}).strict();
|
|
33738
33741
|
var InlineGroupSchema = exports_external.object({
|
|
33739
33742
|
requireMention: exports_external.boolean().optional(),
|
|
33740
33743
|
systemPrompt: exports_external.string().optional(),
|
|
@@ -33751,6 +33754,7 @@ var InlineAccountSchemaBase = exports_external.object({
|
|
|
33751
33754
|
baseUrl: exports_external.string().optional(),
|
|
33752
33755
|
token: exports_external.string().optional(),
|
|
33753
33756
|
tokenFile: exports_external.string().optional(),
|
|
33757
|
+
capabilities: InlineCapabilitiesSchema.optional(),
|
|
33754
33758
|
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
33755
33759
|
allowFrom: exports_external.array(exports_external.string()).optional(),
|
|
33756
33760
|
systemPrompt: exports_external.string().optional(),
|
|
@@ -33874,6 +33878,97 @@ async function resolveInlineToken(account) {
|
|
|
33874
33878
|
return token;
|
|
33875
33879
|
}
|
|
33876
33880
|
|
|
33881
|
+
// src/inline/reply-threads.ts
|
|
33882
|
+
var GET_CHAT_METHOD = typeof Method.GET_CHAT === "number" && Number.isInteger(Method.GET_CHAT) && Method.GET_CHAT > 0 ? Method.GET_CHAT : 25;
|
|
33883
|
+
var GET_CHAT_HISTORY_METHOD = typeof Method.GET_CHAT_HISTORY === "number" && Number.isInteger(Method.GET_CHAT_HISTORY) && Method.GET_CHAT_HISTORY > 0 ? Method.GET_CHAT_HISTORY : 5;
|
|
33884
|
+
var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : 38;
|
|
33885
|
+
function buildChatPeer(chatId) {
|
|
33886
|
+
return {
|
|
33887
|
+
type: {
|
|
33888
|
+
oneofKind: "chat",
|
|
33889
|
+
chat: { chatId }
|
|
33890
|
+
}
|
|
33891
|
+
};
|
|
33892
|
+
}
|
|
33893
|
+
function getInlineReplyThreadsCapabilityConfig(params) {
|
|
33894
|
+
const account = resolveInlineAccount({
|
|
33895
|
+
cfg: params.cfg,
|
|
33896
|
+
accountId: params.accountId ?? null
|
|
33897
|
+
});
|
|
33898
|
+
return {
|
|
33899
|
+
replyThreads: account.config.capabilities?.replyThreads === true
|
|
33900
|
+
};
|
|
33901
|
+
}
|
|
33902
|
+
function isInlineReplyThreadsEnabled(params) {
|
|
33903
|
+
return getInlineReplyThreadsCapabilityConfig(params).replyThreads;
|
|
33904
|
+
}
|
|
33905
|
+
function resolveInlineReplyThreadChatId(params) {
|
|
33906
|
+
if (!isInlineReplyThreadsEnabled({ cfg: params.cfg, accountId: params.accountId ?? null })) {
|
|
33907
|
+
return params.parentChatId;
|
|
33908
|
+
}
|
|
33909
|
+
if (params.parentChatId == null) {
|
|
33910
|
+
return null;
|
|
33911
|
+
}
|
|
33912
|
+
if (params.threadId == null) {
|
|
33913
|
+
return params.parentChatId;
|
|
33914
|
+
}
|
|
33915
|
+
const normalized = typeof params.threadId === "number" ? Number.isFinite(params.threadId) && Number.isInteger(params.threadId) && params.threadId >= 0 ? BigInt(params.threadId) : null : typeof params.threadId === "string" ? params.threadId.trim() ? (() => {
|
|
33916
|
+
try {
|
|
33917
|
+
return BigInt(params.threadId.trim());
|
|
33918
|
+
} catch {
|
|
33919
|
+
return null;
|
|
33920
|
+
}
|
|
33921
|
+
})() : null : null;
|
|
33922
|
+
return normalized ?? params.parentChatId;
|
|
33923
|
+
}
|
|
33924
|
+
async function loadInlineReplyThreadMetadata(params) {
|
|
33925
|
+
const result = await params.client.invokeRaw(GET_CHAT_METHOD, {
|
|
33926
|
+
oneofKind: "getChat",
|
|
33927
|
+
getChat: { peerId: buildChatPeer(params.chatId) }
|
|
33928
|
+
}).catch(() => null);
|
|
33929
|
+
if (result?.oneofKind !== "getChat") {
|
|
33930
|
+
return null;
|
|
33931
|
+
}
|
|
33932
|
+
const chat = result.getChat.chat;
|
|
33933
|
+
const parentChatId = chat?.parentChatId;
|
|
33934
|
+
if (parentChatId == null) {
|
|
33935
|
+
return null;
|
|
33936
|
+
}
|
|
33937
|
+
return {
|
|
33938
|
+
childChatId: chat?.id ?? params.chatId,
|
|
33939
|
+
parentChatId,
|
|
33940
|
+
parentMessageId: chat?.parentMessageId ?? null,
|
|
33941
|
+
title: chat?.title?.trim() || null
|
|
33942
|
+
};
|
|
33943
|
+
}
|
|
33944
|
+
async function loadInlineReplyThreadAnchorMessage(params) {
|
|
33945
|
+
const directResult = await params.client.invokeRaw(GET_MESSAGES_METHOD, {
|
|
33946
|
+
oneofKind: "getMessages",
|
|
33947
|
+
getMessages: {
|
|
33948
|
+
peerId: buildChatPeer(params.parentChatId),
|
|
33949
|
+
messageIds: [params.parentMessageId]
|
|
33950
|
+
}
|
|
33951
|
+
}).catch(() => null);
|
|
33952
|
+
if (directResult?.oneofKind === "getMessages") {
|
|
33953
|
+
const directTarget = (directResult.getMessages.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
|
|
33954
|
+
if (directTarget) {
|
|
33955
|
+
return directTarget;
|
|
33956
|
+
}
|
|
33957
|
+
}
|
|
33958
|
+
const historyResult = await params.client.invokeRaw(GET_CHAT_HISTORY_METHOD, {
|
|
33959
|
+
oneofKind: "getChatHistory",
|
|
33960
|
+
getChatHistory: {
|
|
33961
|
+
peerId: buildChatPeer(params.parentChatId),
|
|
33962
|
+
offsetId: params.parentMessageId + 1n,
|
|
33963
|
+
limit: 8
|
|
33964
|
+
}
|
|
33965
|
+
}).catch(() => null);
|
|
33966
|
+
if (historyResult?.oneofKind !== "getChatHistory") {
|
|
33967
|
+
return null;
|
|
33968
|
+
}
|
|
33969
|
+
return (historyResult.getChatHistory.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
|
|
33970
|
+
}
|
|
33971
|
+
|
|
33877
33972
|
// src/inline/normalize.ts
|
|
33878
33973
|
function normalizeInlineTarget(raw) {
|
|
33879
33974
|
let normalized = raw.trim();
|
|
@@ -35041,7 +35136,7 @@ var REACTION_TARGET_LOOKUP_LIMIT = 8;
|
|
|
35041
35136
|
var REPLY_TARGET_LOOKUP_LIMIT = 8;
|
|
35042
35137
|
var ATTACHMENT_CONTEXT_LIMIT = 6;
|
|
35043
35138
|
var DEFAULT_INLINE_MEDIA_MAX_BYTES = 300 * 1024 * 1024;
|
|
35044
|
-
var
|
|
35139
|
+
var GET_MESSAGES_METHOD2 = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
|
|
35045
35140
|
function normalizeAllowEntry(raw) {
|
|
35046
35141
|
return raw.trim().replace(/^inline:/i, "").replace(/^user:/i, "");
|
|
35047
35142
|
}
|
|
@@ -35265,7 +35360,7 @@ function rememberBotMessagesFromList(params) {
|
|
|
35265
35360
|
}
|
|
35266
35361
|
}
|
|
35267
35362
|
}
|
|
35268
|
-
function
|
|
35363
|
+
function buildChatPeer2(chatId) {
|
|
35269
35364
|
return {
|
|
35270
35365
|
type: {
|
|
35271
35366
|
oneofKind: "chat",
|
|
@@ -35277,7 +35372,7 @@ async function loadChatHistoryMessages(params) {
|
|
|
35277
35372
|
const result = await params.client.invokeRaw(Method.GET_CHAT_HISTORY, {
|
|
35278
35373
|
oneofKind: "getChatHistory",
|
|
35279
35374
|
getChatHistory: {
|
|
35280
|
-
peerId:
|
|
35375
|
+
peerId: buildChatPeer2(params.chatId),
|
|
35281
35376
|
...params.offsetId != null ? { offsetId: params.offsetId } : {},
|
|
35282
35377
|
limit: params.limit
|
|
35283
35378
|
}
|
|
@@ -35288,10 +35383,10 @@ async function loadChatHistoryMessages(params) {
|
|
|
35288
35383
|
return result.getChatHistory.messages ?? [];
|
|
35289
35384
|
}
|
|
35290
35385
|
async function findChatMessageById(params) {
|
|
35291
|
-
const directResult =
|
|
35386
|
+
const directResult = GET_MESSAGES_METHOD2 == null ? null : await params.client.invokeRaw(GET_MESSAGES_METHOD2, {
|
|
35292
35387
|
oneofKind: "getMessages",
|
|
35293
35388
|
getMessages: {
|
|
35294
|
-
peerId:
|
|
35389
|
+
peerId: buildChatPeer2(params.chatId),
|
|
35295
35390
|
messageIds: [params.messageId]
|
|
35296
35391
|
}
|
|
35297
35392
|
}).catch(() => null);
|
|
@@ -35416,6 +35511,89 @@ function mergeInboundHistoryEntries(params) {
|
|
|
35416
35511
|
...entry.timestamp != null ? { timestamp: entry.timestamp } : {}
|
|
35417
35512
|
}));
|
|
35418
35513
|
}
|
|
35514
|
+
function buildInlineHistoryEntryPayload(params) {
|
|
35515
|
+
const content = summarizeInlineMessageContent(params.message);
|
|
35516
|
+
const text = normalizeHistoryText(content.text);
|
|
35517
|
+
if (!text) {
|
|
35518
|
+
return {
|
|
35519
|
+
line: null,
|
|
35520
|
+
attachmentLine: null,
|
|
35521
|
+
entityLine: null,
|
|
35522
|
+
inboundEntry: null
|
|
35523
|
+
};
|
|
35524
|
+
}
|
|
35525
|
+
const label = resolveHistorySenderLabel({
|
|
35526
|
+
senderId: params.message.fromId,
|
|
35527
|
+
meId: params.meId,
|
|
35528
|
+
senderProfilesById: params.senderProfilesById
|
|
35529
|
+
});
|
|
35530
|
+
const replySuffix = params.message.replyToMsgId != null ? ` ->${String(params.message.replyToMsgId)}` : "";
|
|
35531
|
+
const messageId = params.syntheticMessageId ?? String(params.message.id);
|
|
35532
|
+
const attachmentText = normalizeHistoryText(content.attachmentText);
|
|
35533
|
+
const entityText = normalizeHistoryText(content.entityText);
|
|
35534
|
+
return {
|
|
35535
|
+
line: `#${String(params.message.id)}${replySuffix} ${label}: ${text}`,
|
|
35536
|
+
attachmentLine: attachmentText ? `#${String(params.message.id)}${replySuffix} ${label}: ${attachmentText}` : null,
|
|
35537
|
+
entityLine: entityText ? `#${String(params.message.id)}${replySuffix} ${label}: ${entityText}` : null,
|
|
35538
|
+
inboundEntry: {
|
|
35539
|
+
sender: label,
|
|
35540
|
+
body: text,
|
|
35541
|
+
...params.message.date != null ? { timestamp: Number(params.message.date) * 1000 } : {},
|
|
35542
|
+
messageId
|
|
35543
|
+
}
|
|
35544
|
+
};
|
|
35545
|
+
}
|
|
35546
|
+
function appendInlineHistoryEntry(target, entry) {
|
|
35547
|
+
if (!entry.inboundEntry || !entry.line)
|
|
35548
|
+
return;
|
|
35549
|
+
target.inboundHistory.push(entry.inboundEntry);
|
|
35550
|
+
target.lines.push(entry.line);
|
|
35551
|
+
if (entry.attachmentLine) {
|
|
35552
|
+
target.attachmentLines.push(entry.attachmentLine);
|
|
35553
|
+
}
|
|
35554
|
+
if (entry.entityLine) {
|
|
35555
|
+
target.entityLines.push(entry.entityLine);
|
|
35556
|
+
}
|
|
35557
|
+
}
|
|
35558
|
+
function prependLabeledHistoryLine(params) {
|
|
35559
|
+
if (!params.line)
|
|
35560
|
+
return params.existing;
|
|
35561
|
+
const prefix = `${params.heading}
|
|
35562
|
+
`;
|
|
35563
|
+
const existingBody = params.existing?.startsWith(prefix) ? params.existing.slice(prefix.length) : params.existing;
|
|
35564
|
+
return existingBody ? `${prefix}${params.line}
|
|
35565
|
+
${existingBody}` : `${prefix}${params.line}`;
|
|
35566
|
+
}
|
|
35567
|
+
function prependInlineReplyThreadAnchor(params) {
|
|
35568
|
+
const entry = buildInlineHistoryEntryPayload({
|
|
35569
|
+
message: params.anchorMessage,
|
|
35570
|
+
senderProfilesById: params.senderProfilesById,
|
|
35571
|
+
meId: params.meId,
|
|
35572
|
+
syntheticMessageId: `anchor:${String(params.parentChatId)}:${String(params.anchorMessage.id)}`
|
|
35573
|
+
});
|
|
35574
|
+
if (!entry.inboundEntry || !entry.line) {
|
|
35575
|
+
return params.historyContext;
|
|
35576
|
+
}
|
|
35577
|
+
return {
|
|
35578
|
+
...params.historyContext,
|
|
35579
|
+
inboundHistory: [entry.inboundEntry, ...params.historyContext.inboundHistory],
|
|
35580
|
+
historyText: prependLabeledHistoryLine({
|
|
35581
|
+
existing: params.historyContext.historyText,
|
|
35582
|
+
heading: "Recent thread messages (oldest -> newest):",
|
|
35583
|
+
line: entry.line
|
|
35584
|
+
}),
|
|
35585
|
+
attachmentText: prependLabeledHistoryLine({
|
|
35586
|
+
existing: params.historyContext.attachmentText,
|
|
35587
|
+
heading: "Recent media/attachments:",
|
|
35588
|
+
line: entry.attachmentLine
|
|
35589
|
+
}),
|
|
35590
|
+
entityText: prependLabeledHistoryLine({
|
|
35591
|
+
existing: params.historyContext.entityText,
|
|
35592
|
+
heading: "Recent message entities:",
|
|
35593
|
+
line: entry.entityLine
|
|
35594
|
+
})
|
|
35595
|
+
};
|
|
35596
|
+
}
|
|
35419
35597
|
function buildInlineBodyForAgent(params) {
|
|
35420
35598
|
return [
|
|
35421
35599
|
params.rawBody,
|
|
@@ -35519,6 +35697,34 @@ async function resolveInlineInboundMedia(params) {
|
|
|
35519
35697
|
}
|
|
35520
35698
|
return out;
|
|
35521
35699
|
}
|
|
35700
|
+
async function resolveInlineInboundReplyThreadContext(params) {
|
|
35701
|
+
if (params.chatInfo.kind === "direct" || !params.replyThreadsEnabled) {
|
|
35702
|
+
return null;
|
|
35703
|
+
}
|
|
35704
|
+
const metadata = await loadInlineReplyThreadMetadata({
|
|
35705
|
+
client: params.client,
|
|
35706
|
+
chatId: params.chatId
|
|
35707
|
+
});
|
|
35708
|
+
if (!metadata) {
|
|
35709
|
+
return null;
|
|
35710
|
+
}
|
|
35711
|
+
const parentChatInfo = metadata.parentChatId === params.chatId ? params.chatInfo : await resolveChatInfo(params.client, params.chatCache, metadata.parentChatId).catch(() => ({
|
|
35712
|
+
kind: "group",
|
|
35713
|
+
title: null
|
|
35714
|
+
}));
|
|
35715
|
+
const anchorMessage = metadata.parentMessageId != null ? await loadInlineReplyThreadAnchorMessage({
|
|
35716
|
+
client: params.client,
|
|
35717
|
+
parentChatId: metadata.parentChatId,
|
|
35718
|
+
parentMessageId: metadata.parentMessageId
|
|
35719
|
+
}).catch(() => null) : null;
|
|
35720
|
+
return {
|
|
35721
|
+
childChatId: metadata.childChatId,
|
|
35722
|
+
parentChatId: metadata.parentChatId,
|
|
35723
|
+
parentChatTitle: parentChatInfo.title ?? null,
|
|
35724
|
+
threadLabel: metadata.title ?? params.chatInfo.title ?? null,
|
|
35725
|
+
anchorMessage
|
|
35726
|
+
};
|
|
35727
|
+
}
|
|
35522
35728
|
async function buildHistoryContext2(params) {
|
|
35523
35729
|
const cachedReplyToBot = params.replyToMsgId != null && hasBotMessageId(params.botMessageIdsByChat, params.chatId, params.replyToMsgId);
|
|
35524
35730
|
let repliedToBot = cachedReplyToBot;
|
|
@@ -35555,31 +35761,16 @@ async function buildHistoryContext2(params) {
|
|
|
35555
35761
|
replyToSenderId = String(item.fromId);
|
|
35556
35762
|
repliedToBot = item.fromId === params.meId;
|
|
35557
35763
|
}
|
|
35558
|
-
|
|
35559
|
-
|
|
35560
|
-
|
|
35561
|
-
|
|
35562
|
-
|
|
35563
|
-
|
|
35564
|
-
|
|
35565
|
-
senderProfilesById: params.senderProfilesById
|
|
35566
|
-
|
|
35567
|
-
|
|
35568
|
-
sender: label,
|
|
35569
|
-
body: text,
|
|
35570
|
-
...item.date != null ? { timestamp: Number(item.date) * 1000 } : {},
|
|
35571
|
-
messageId: String(item.id)
|
|
35572
|
-
});
|
|
35573
|
-
const replySuffix = item.replyToMsgId != null ? ` ->${String(item.replyToMsgId)}` : "";
|
|
35574
|
-
lines.push(`#${String(item.id)}${replySuffix} ${label}: ${text}`);
|
|
35575
|
-
const attachmentText = normalizeHistoryText(content.attachmentText);
|
|
35576
|
-
if (attachmentText) {
|
|
35577
|
-
attachmentLines.push(`#${String(item.id)}${replySuffix} ${label}: ${attachmentText}`);
|
|
35578
|
-
}
|
|
35579
|
-
const entityText = normalizeHistoryText(content.entityText);
|
|
35580
|
-
if (entityText) {
|
|
35581
|
-
entityLines.push(`#${String(item.id)}${replySuffix} ${label}: ${entityText}`);
|
|
35582
|
-
}
|
|
35764
|
+
appendInlineHistoryEntry({
|
|
35765
|
+
lines,
|
|
35766
|
+
attachmentLines,
|
|
35767
|
+
entityLines,
|
|
35768
|
+
inboundHistory
|
|
35769
|
+
}, buildInlineHistoryEntryPayload({
|
|
35770
|
+
message: item,
|
|
35771
|
+
senderProfilesById: params.senderProfilesById,
|
|
35772
|
+
meId: params.meId
|
|
35773
|
+
}));
|
|
35583
35774
|
}
|
|
35584
35775
|
}
|
|
35585
35776
|
}
|
|
@@ -35837,6 +36028,19 @@ async function monitorInlineProvider(params) {
|
|
|
35837
36028
|
statusSink?.({ lastError: `getChat failed: ${String(err)}` });
|
|
35838
36029
|
}
|
|
35839
36030
|
const isGroup = chatInfo.kind !== "direct";
|
|
36031
|
+
const replyThreadsEnabled = account.config.capabilities?.replyThreads === true || isInlineReplyThreadsEnabled({ cfg, accountId: account.accountId });
|
|
36032
|
+
const replyThreadContext = await resolveInlineInboundReplyThreadContext({
|
|
36033
|
+
replyThreadsEnabled,
|
|
36034
|
+
client,
|
|
36035
|
+
chatId,
|
|
36036
|
+
chatInfo,
|
|
36037
|
+
chatCache
|
|
36038
|
+
}).catch((err) => {
|
|
36039
|
+
statusSink?.({ lastError: `getChat (reply thread) failed: ${String(err)}` });
|
|
36040
|
+
return null;
|
|
36041
|
+
});
|
|
36042
|
+
const effectiveChatId = replyThreadContext?.parentChatId ?? chatId;
|
|
36043
|
+
const effectiveGroupTitle = replyThreadContext?.parentChatTitle ?? chatInfo.title ?? null;
|
|
35840
36044
|
const senderId = String(msg.fromId);
|
|
35841
36045
|
await hydrateChatParticipants(chatId);
|
|
35842
36046
|
const senderProfile = senderProfilesById.get(senderId);
|
|
@@ -35988,7 +36192,7 @@ ${JSON.stringify(payload)}`;
|
|
|
35988
36192
|
accountId: account.accountId,
|
|
35989
36193
|
peer: {
|
|
35990
36194
|
kind: isGroup ? "group" : "direct",
|
|
35991
|
-
id: isGroup ? String(
|
|
36195
|
+
id: isGroup ? String(effectiveChatId) : senderId
|
|
35992
36196
|
}
|
|
35993
36197
|
});
|
|
35994
36198
|
const mentionRegexes = core3.channel.mentions.buildMentionRegexes(cfg, route.agentId);
|
|
@@ -35996,7 +36200,7 @@ ${JSON.stringify(payload)}`;
|
|
|
35996
36200
|
const patternMentioned = mentionRegexes.length ? core3.channel.mentions.matchesMentionPatterns(rawBody, mentionRegexes) : false;
|
|
35997
36201
|
const wasMentioned = nativeMentioned || patternMentioned;
|
|
35998
36202
|
const messageTimestamp = Number(msg.date) * 1000;
|
|
35999
|
-
const groupHistoryKey = isGroup ? route.sessionKey : null;
|
|
36203
|
+
const groupHistoryKey = isGroup ? replyThreadContext ? `${route.sessionKey}:thread:${String(replyThreadContext.childChatId)}` : route.sessionKey : null;
|
|
36000
36204
|
const pendingHistorySender = senderUsername ? `@${senderUsername}` : senderName ?? `user:${senderId}`;
|
|
36001
36205
|
const historyLimit = resolveHistoryLimit({
|
|
36002
36206
|
cfg,
|
|
@@ -36024,10 +36228,17 @@ ${JSON.stringify(payload)}`;
|
|
|
36024
36228
|
replyToSenderId: null
|
|
36025
36229
|
};
|
|
36026
36230
|
});
|
|
36027
|
-
const
|
|
36231
|
+
const effectiveHistoryContext = replyThreadContext?.anchorMessage != null ? prependInlineReplyThreadAnchor({
|
|
36232
|
+
historyContext,
|
|
36233
|
+
anchorMessage: replyThreadContext.anchorMessage,
|
|
36234
|
+
parentChatId: replyThreadContext.parentChatId,
|
|
36235
|
+
senderProfilesById,
|
|
36236
|
+
meId
|
|
36237
|
+
}) : historyContext;
|
|
36238
|
+
const implicitMention = (reactionEvent != null || callbackActionEvent != null) && isGroup || isGroup && (account.config.replyToBotWithoutMention ?? false) && msg.replyToMsgId != null && effectiveHistoryContext.repliedToBot;
|
|
36028
36239
|
const requireMention = isGroup ? resolveInlineGroupRequireMention({
|
|
36029
36240
|
cfg,
|
|
36030
|
-
groupId: String(
|
|
36241
|
+
groupId: String(effectiveChatId),
|
|
36031
36242
|
accountId: account.accountId,
|
|
36032
36243
|
requireMentionDefault: account.config.requireMention ?? false
|
|
36033
36244
|
}) : false;
|
|
@@ -36090,14 +36301,14 @@ ${JSON.stringify(payload)}`;
|
|
|
36090
36301
|
...log ? { log } : {}
|
|
36091
36302
|
});
|
|
36092
36303
|
const timestamp = messageTimestamp;
|
|
36093
|
-
const fromLabel = isGroup ? `chat:${
|
|
36304
|
+
const fromLabel = isGroup ? `chat:${effectiveGroupTitle ?? String(effectiveChatId)}` : `user:${senderId}`;
|
|
36094
36305
|
const storePath = core3.channel.session.resolveStorePath(cfg.session?.store, { agentId: route.agentId });
|
|
36095
36306
|
const envelopeOptions = core3.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
36096
36307
|
const previousTimestamp = core3.channel.session.readSessionUpdatedAt({ storePath, sessionKey: route.sessionKey });
|
|
36097
36308
|
const combinedBody = [
|
|
36098
|
-
|
|
36099
|
-
|
|
36100
|
-
|
|
36309
|
+
effectiveHistoryContext.historyText,
|
|
36310
|
+
effectiveHistoryContext.attachmentText,
|
|
36311
|
+
effectiveHistoryContext.entityText,
|
|
36101
36312
|
INLINE_FORMATTING_NOTE,
|
|
36102
36313
|
`Current message:
|
|
36103
36314
|
${rawBody}`,
|
|
@@ -36132,7 +36343,7 @@ ${currentEntityText}` : null
|
|
|
36132
36343
|
});
|
|
36133
36344
|
}
|
|
36134
36345
|
const inboundHistory = isGroup && groupHistoryKey ? mergeInboundHistoryEntries({
|
|
36135
|
-
historyContextEntries:
|
|
36346
|
+
historyContextEntries: effectiveHistoryContext.inboundHistory,
|
|
36136
36347
|
pendingEntries: groupPendingHistories.get(groupHistoryKey) ?? [],
|
|
36137
36348
|
limit: historyLimit
|
|
36138
36349
|
}) : [];
|
|
@@ -36144,7 +36355,7 @@ ${currentEntityText}` : null
|
|
|
36144
36355
|
const effectiveSurface = shouldUseTelegramSurfaceForModelCommands(normalizedCommandBody) ? "telegram" : CHANNEL_ID;
|
|
36145
36356
|
const systemPrompt = resolveInlineSystemPrompt({
|
|
36146
36357
|
account,
|
|
36147
|
-
...isGroup ? { groupId: String(
|
|
36358
|
+
...isGroup ? { groupId: String(effectiveChatId) } : {}
|
|
36148
36359
|
});
|
|
36149
36360
|
const ctxPayload = core3.channel.reply.finalizeInboundContext({
|
|
36150
36361
|
Body: body,
|
|
@@ -36152,22 +36363,25 @@ ${currentEntityText}` : null
|
|
|
36152
36363
|
...isGroup ? { InboundHistory: inboundHistory } : {},
|
|
36153
36364
|
RawBody: rawBody,
|
|
36154
36365
|
CommandBody: normalizedCommandBody,
|
|
36155
|
-
From: isGroup ? `inline:chat:${String(
|
|
36156
|
-
To: `inline:${String(
|
|
36366
|
+
From: isGroup ? `inline:chat:${String(effectiveChatId)}` : `inline:${senderId}`,
|
|
36367
|
+
To: `inline:${String(effectiveChatId)}`,
|
|
36157
36368
|
SessionKey: route.sessionKey,
|
|
36369
|
+
...replyThreadContext ? { ParentSessionKey: route.sessionKey } : {},
|
|
36158
36370
|
AccountId: route.accountId,
|
|
36159
36371
|
ChatType: isGroup ? "group" : "direct",
|
|
36160
36372
|
ConversationLabel: fromLabel,
|
|
36161
|
-
...isGroup ? { GroupSubject:
|
|
36373
|
+
...isGroup ? { GroupSubject: effectiveGroupTitle ?? String(effectiveChatId) } : {},
|
|
36162
36374
|
SenderId: senderId,
|
|
36163
36375
|
...senderName ? { SenderName: senderName } : {},
|
|
36164
36376
|
...senderUsername ? { SenderUsername: senderUsername } : {},
|
|
36165
36377
|
Provider: CHANNEL_ID,
|
|
36166
36378
|
Surface: effectiveSurface,
|
|
36167
36379
|
MessageSid: String(msg.id),
|
|
36380
|
+
...replyThreadContext ? { MessageThreadId: String(replyThreadContext.childChatId) } : {},
|
|
36381
|
+
...replyThreadContext?.threadLabel ? { ThreadLabel: replyThreadContext.threadLabel } : {},
|
|
36168
36382
|
...msg.replyToMsgId != null ? { ReplyToId: String(msg.replyToMsgId) } : {},
|
|
36169
|
-
...
|
|
36170
|
-
...msg.replyToMsgId != null ? { ReplyToWasBot:
|
|
36383
|
+
...effectiveHistoryContext.replyToSenderId != null ? { ReplyToSenderId: effectiveHistoryContext.replyToSenderId } : {},
|
|
36384
|
+
...msg.replyToMsgId != null ? { ReplyToWasBot: effectiveHistoryContext.repliedToBot } : {},
|
|
36171
36385
|
...callbackActionEvent ? {
|
|
36172
36386
|
MessageActionInteractionId: String(callbackActionEvent.interactionId),
|
|
36173
36387
|
MessageActionId: callbackActionEvent.actionId,
|
|
@@ -36180,7 +36394,7 @@ ${currentEntityText}` : null
|
|
|
36180
36394
|
CommandAuthorized: commandAuthorized,
|
|
36181
36395
|
GroupSystemPrompt: systemPrompt,
|
|
36182
36396
|
OriginatingChannel: CHANNEL_ID,
|
|
36183
|
-
OriginatingTo: `inline:${String(
|
|
36397
|
+
OriginatingTo: `inline:${String(effectiveChatId)}`
|
|
36184
36398
|
});
|
|
36185
36399
|
await core3.channel.session.recordInboundSession({
|
|
36186
36400
|
storePath,
|
|
@@ -36190,7 +36404,7 @@ ${currentEntityText}` : null
|
|
|
36190
36404
|
updateLastRoute: {
|
|
36191
36405
|
sessionKey: route.mainSessionKey,
|
|
36192
36406
|
channel: CHANNEL_ID,
|
|
36193
|
-
to: `inline:${String(
|
|
36407
|
+
to: `inline:${String(effectiveChatId)}`,
|
|
36194
36408
|
accountId: route.accountId
|
|
36195
36409
|
}
|
|
36196
36410
|
} : {},
|
|
@@ -36267,7 +36481,7 @@ ${currentEntityText}` : null
|
|
|
36267
36481
|
oneofKind: "editMessage",
|
|
36268
36482
|
editMessage: {
|
|
36269
36483
|
messageId: editStreamState.messageId,
|
|
36270
|
-
peerId:
|
|
36484
|
+
peerId: buildChatPeer2(chatId),
|
|
36271
36485
|
text: nextText,
|
|
36272
36486
|
parseMarkdown
|
|
36273
36487
|
}
|
|
@@ -36341,7 +36555,7 @@ ${currentEntityText}` : null
|
|
|
36341
36555
|
oneofKind: "editMessage",
|
|
36342
36556
|
editMessage: {
|
|
36343
36557
|
messageId: editStreamState.messageId,
|
|
36344
|
-
peerId:
|
|
36558
|
+
peerId: buildChatPeer2(chatId),
|
|
36345
36559
|
text: textForEdit,
|
|
36346
36560
|
parseMarkdown,
|
|
36347
36561
|
...actions !== undefined ? { actions } : {}
|
|
@@ -36549,7 +36763,8 @@ for (const group of ACTION_GROUPS) {
|
|
|
36549
36763
|
}
|
|
36550
36764
|
}
|
|
36551
36765
|
var SUPPORTED_ACTIONS = Array.from(ACTION_TO_GATE_KEY.keys());
|
|
36552
|
-
var
|
|
36766
|
+
var GET_MESSAGES_METHOD3 = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
|
|
36767
|
+
var CREATE_SUBTHREAD_METHOD = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 43;
|
|
36553
36768
|
var INLINE_ACTION_MAX_ROWS2 = 8;
|
|
36554
36769
|
var INLINE_ACTION_MAX_PER_ROW2 = 8;
|
|
36555
36770
|
function isRecord4(value) {
|
|
@@ -36890,7 +37105,7 @@ function resolveMessageSendTargetFromParams(params) {
|
|
|
36890
37105
|
chatId: BigInt(normalized)
|
|
36891
37106
|
};
|
|
36892
37107
|
}
|
|
36893
|
-
function
|
|
37108
|
+
function buildChatPeer3(chatId) {
|
|
36894
37109
|
return {
|
|
36895
37110
|
type: {
|
|
36896
37111
|
oneofKind: "chat",
|
|
@@ -36979,10 +37194,10 @@ async function loadMessageReactions(params) {
|
|
|
36979
37194
|
return Array.from(byEmoji.values());
|
|
36980
37195
|
}
|
|
36981
37196
|
async function findMessageById(params) {
|
|
36982
|
-
const directResult =
|
|
37197
|
+
const directResult = GET_MESSAGES_METHOD3 == null ? null : await params.client.invokeRaw(GET_MESSAGES_METHOD3, {
|
|
36983
37198
|
oneofKind: "getMessages",
|
|
36984
37199
|
getMessages: {
|
|
36985
|
-
peerId:
|
|
37200
|
+
peerId: buildChatPeer3(params.chatId),
|
|
36986
37201
|
messageIds: [params.messageId]
|
|
36987
37202
|
}
|
|
36988
37203
|
}).catch(() => null);
|
|
@@ -36992,7 +37207,7 @@ async function findMessageById(params) {
|
|
|
36992
37207
|
const result = await params.client.invokeRaw(Method.GET_CHAT_HISTORY, {
|
|
36993
37208
|
oneofKind: "getChatHistory",
|
|
36994
37209
|
getChatHistory: {
|
|
36995
|
-
peerId:
|
|
37210
|
+
peerId: buildChatPeer3(params.chatId),
|
|
36996
37211
|
offsetId: params.messageId + 1n,
|
|
36997
37212
|
limit: 8
|
|
36998
37213
|
}
|
|
@@ -37066,7 +37281,7 @@ async function resolveSpaceIdFromParams(params) {
|
|
|
37066
37281
|
const chatId = BigInt(normalizeChatId(chatTarget));
|
|
37067
37282
|
const chatResult = await params.client.invokeRaw(Method.GET_CHAT, {
|
|
37068
37283
|
oneofKind: "getChat",
|
|
37069
|
-
getChat: { peerId:
|
|
37284
|
+
getChat: { peerId: buildChatPeer3(chatId) }
|
|
37070
37285
|
});
|
|
37071
37286
|
if (chatResult.oneofKind !== "getChat") {
|
|
37072
37287
|
throw new Error(`inline action: expected getChat result, got ${String(chatResult.oneofKind)}`);
|
|
@@ -37236,11 +37451,35 @@ var inlineMessageActions = {
|
|
|
37236
37451
|
}
|
|
37237
37452
|
if (normalizedAction === "reply" || normalizedAction === "thread-reply") {
|
|
37238
37453
|
const parseMarkdown = resolveInlineAccount({ cfg, accountId: accountId ?? null }).config.parseMarkdown ?? true;
|
|
37454
|
+
const replyThreadsEnabled = normalizedAction === "thread-reply" && isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null });
|
|
37239
37455
|
return await withInlineClient({
|
|
37240
37456
|
cfg,
|
|
37241
37457
|
accountId,
|
|
37242
37458
|
fn: async (client) => {
|
|
37243
37459
|
const actions = resolveInlineMessageActionsParam(params);
|
|
37460
|
+
if (replyThreadsEnabled) {
|
|
37461
|
+
const rawThreadId = readFlexibleId(params, "threadId") ?? readStringParam(params, "threadId");
|
|
37462
|
+
if (!rawThreadId) {
|
|
37463
|
+
throw new Error("inline thread-reply: threadId is required when reply threads are enabled");
|
|
37464
|
+
}
|
|
37465
|
+
const chatId2 = parseInlineId(rawThreadId, "threadId");
|
|
37466
|
+
const replyToMsgId2 = parseOptionalInlineId(readFlexibleId(params, "messageId") ?? readFlexibleId(params, "replyTo") ?? readFlexibleId(params, "replyToId") ?? readStringParam(params, "messageId") ?? readStringParam(params, "replyTo") ?? readStringParam(params, "replyToId"), "messageId");
|
|
37467
|
+
const text2 = readStringParam(params, "message") ?? readStringParam(params, "text", { required: true, allowEmpty: true });
|
|
37468
|
+
const sent2 = await client.sendMessage({
|
|
37469
|
+
chatId: chatId2,
|
|
37470
|
+
text: text2,
|
|
37471
|
+
...actions !== undefined ? { actions } : {},
|
|
37472
|
+
...replyToMsgId2 != null ? { replyToMsgId: replyToMsgId2 } : {},
|
|
37473
|
+
parseMarkdown
|
|
37474
|
+
});
|
|
37475
|
+
return jsonResult({
|
|
37476
|
+
ok: true,
|
|
37477
|
+
chatId: String(chatId2),
|
|
37478
|
+
threadId: String(chatId2),
|
|
37479
|
+
messageId: sent2.messageId != null ? String(sent2.messageId) : null,
|
|
37480
|
+
replyToId: replyToMsgId2 != null ? String(replyToMsgId2) : null
|
|
37481
|
+
});
|
|
37482
|
+
}
|
|
37244
37483
|
const replyParams = normalizedAction === "thread-reply" && params.threadId != null && params.to == null && params.chatId == null && params.channelId == null ? { ...params, to: params.threadId } : params;
|
|
37245
37484
|
const chatId = resolveChatIdFromParams(replyParams);
|
|
37246
37485
|
const replyToMsgId = parseInlineId(readFlexibleId(replyParams, "messageId") ?? readFlexibleId(replyParams, "replyTo") ?? readFlexibleId(replyParams, "replyToId") ?? readStringParam(replyParams, "messageId") ?? readStringParam(replyParams, "replyTo") ?? readStringParam(replyParams, "replyToId", { required: true }), "messageId");
|
|
@@ -37279,7 +37518,7 @@ var inlineMessageActions = {
|
|
|
37279
37518
|
oneofKind: "deleteReaction",
|
|
37280
37519
|
deleteReaction: {
|
|
37281
37520
|
emoji: emoji3,
|
|
37282
|
-
peerId:
|
|
37521
|
+
peerId: buildChatPeer3(chatId),
|
|
37283
37522
|
messageId
|
|
37284
37523
|
}
|
|
37285
37524
|
});
|
|
@@ -37292,7 +37531,7 @@ var inlineMessageActions = {
|
|
|
37292
37531
|
addReaction: {
|
|
37293
37532
|
emoji: emoji3,
|
|
37294
37533
|
messageId,
|
|
37295
|
-
peerId:
|
|
37534
|
+
peerId: buildChatPeer3(chatId)
|
|
37296
37535
|
}
|
|
37297
37536
|
});
|
|
37298
37537
|
if (result.oneofKind !== "addReaction") {
|
|
@@ -37341,7 +37580,7 @@ var inlineMessageActions = {
|
|
|
37341
37580
|
const result = await client.invokeRaw(Method.GET_CHAT_HISTORY, {
|
|
37342
37581
|
oneofKind: "getChatHistory",
|
|
37343
37582
|
getChatHistory: {
|
|
37344
|
-
peerId:
|
|
37583
|
+
peerId: buildChatPeer3(chatId),
|
|
37345
37584
|
...offsetId != null ? { offsetId } : {},
|
|
37346
37585
|
limit
|
|
37347
37586
|
}
|
|
@@ -37369,7 +37608,7 @@ var inlineMessageActions = {
|
|
|
37369
37608
|
const result = await client.invokeRaw(Method.SEARCH_MESSAGES, {
|
|
37370
37609
|
oneofKind: "searchMessages",
|
|
37371
37610
|
searchMessages: {
|
|
37372
|
-
peerId:
|
|
37611
|
+
peerId: buildChatPeer3(chatId),
|
|
37373
37612
|
queries: [query],
|
|
37374
37613
|
limit,
|
|
37375
37614
|
...offsetId != null ? { offsetId } : {}
|
|
@@ -37401,7 +37640,7 @@ var inlineMessageActions = {
|
|
|
37401
37640
|
oneofKind: "editMessage",
|
|
37402
37641
|
editMessage: {
|
|
37403
37642
|
messageId,
|
|
37404
|
-
peerId:
|
|
37643
|
+
peerId: buildChatPeer3(chatId),
|
|
37405
37644
|
text,
|
|
37406
37645
|
...actions !== undefined ? { actions } : {},
|
|
37407
37646
|
parseMarkdown
|
|
@@ -37422,7 +37661,7 @@ var inlineMessageActions = {
|
|
|
37422
37661
|
const chatId = resolveChatIdFromParams(params);
|
|
37423
37662
|
const result = await client.invokeRaw(Method.GET_CHAT, {
|
|
37424
37663
|
oneofKind: "getChat",
|
|
37425
|
-
getChat: { peerId:
|
|
37664
|
+
getChat: { peerId: buildChatPeer3(chatId) }
|
|
37426
37665
|
});
|
|
37427
37666
|
if (result.oneofKind !== "getChat") {
|
|
37428
37667
|
throw new Error(`inline action: expected getChat result, got ${String(result.oneofKind)}`);
|
|
@@ -37501,6 +37740,7 @@ var inlineMessageActions = {
|
|
|
37501
37740
|
});
|
|
37502
37741
|
}
|
|
37503
37742
|
if (normalizedAction === "channel-create" || normalizedAction === "thread-create") {
|
|
37743
|
+
const replyThreadsEnabled = normalizedAction === "thread-create" && isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null });
|
|
37504
37744
|
return await withInlineClient({
|
|
37505
37745
|
cfg,
|
|
37506
37746
|
accountId,
|
|
@@ -37523,6 +37763,33 @@ var inlineMessageActions = {
|
|
|
37523
37763
|
values: participantRefs,
|
|
37524
37764
|
label: "participant"
|
|
37525
37765
|
});
|
|
37766
|
+
if (replyThreadsEnabled) {
|
|
37767
|
+
const parentChatId = resolveChatIdFromParams(params);
|
|
37768
|
+
const parentMessageId = parseOptionalInlineId(readFlexibleId(params, "parentMessageId") ?? readFlexibleId(params, "messageId") ?? readFlexibleId(params, "replyTo") ?? readFlexibleId(params, "replyToId") ?? readStringParam(params, "parentMessageId") ?? readStringParam(params, "messageId") ?? readStringParam(params, "replyTo") ?? readStringParam(params, "replyToId"), "parentMessageId");
|
|
37769
|
+
const result2 = await client.invokeRaw(CREATE_SUBTHREAD_METHOD, {
|
|
37770
|
+
oneofKind: "createSubthread",
|
|
37771
|
+
createSubthread: {
|
|
37772
|
+
parentChatId,
|
|
37773
|
+
...parentMessageId != null ? { parentMessageId } : {},
|
|
37774
|
+
title,
|
|
37775
|
+
...description ? { description } : {},
|
|
37776
|
+
...emoji3 ? { emoji: emoji3 } : {},
|
|
37777
|
+
participants: dedupedParticipants.map((userId) => ({ userId }))
|
|
37778
|
+
}
|
|
37779
|
+
});
|
|
37780
|
+
if (result2.oneofKind !== "createSubthread") {
|
|
37781
|
+
throw new Error(`inline action: expected createSubthread result, got ${String(result2.oneofKind)}`);
|
|
37782
|
+
}
|
|
37783
|
+
return jsonResult(toJsonSafe({
|
|
37784
|
+
ok: true,
|
|
37785
|
+
title,
|
|
37786
|
+
parentChatId: String(parentChatId),
|
|
37787
|
+
parentMessageId: parentMessageId != null ? String(parentMessageId) : null,
|
|
37788
|
+
chat: result2.createSubthread.chat ?? null,
|
|
37789
|
+
dialog: result2.createSubthread.dialog ?? null,
|
|
37790
|
+
anchorMessage: result2.createSubthread.anchorMessage ?? null
|
|
37791
|
+
}));
|
|
37792
|
+
}
|
|
37526
37793
|
const result = await client.invokeRaw(Method.CREATE_CHAT, {
|
|
37527
37794
|
oneofKind: "createChat",
|
|
37528
37795
|
createChat: {
|
|
@@ -37558,7 +37825,7 @@ var inlineMessageActions = {
|
|
|
37558
37825
|
const result = await client.invokeRaw(Method.DELETE_CHAT, {
|
|
37559
37826
|
oneofKind: "deleteChat",
|
|
37560
37827
|
deleteChat: {
|
|
37561
|
-
peerId:
|
|
37828
|
+
peerId: buildChatPeer3(chatId)
|
|
37562
37829
|
}
|
|
37563
37830
|
});
|
|
37564
37831
|
if (result.oneofKind !== "deleteChat") {
|
|
@@ -37768,7 +38035,7 @@ var inlineMessageActions = {
|
|
|
37768
38035
|
const result = await client.invokeRaw(Method.DELETE_MESSAGES, {
|
|
37769
38036
|
oneofKind: "deleteMessages",
|
|
37770
38037
|
deleteMessages: {
|
|
37771
|
-
peerId:
|
|
38038
|
+
peerId: buildChatPeer3(chatId),
|
|
37772
38039
|
messageIds: deduped
|
|
37773
38040
|
}
|
|
37774
38041
|
});
|
|
@@ -37794,7 +38061,7 @@ var inlineMessageActions = {
|
|
|
37794
38061
|
const result = await client.invokeRaw(Method.PIN_MESSAGE, {
|
|
37795
38062
|
oneofKind: "pinMessage",
|
|
37796
38063
|
pinMessage: {
|
|
37797
|
-
peerId:
|
|
38064
|
+
peerId: buildChatPeer3(chatId),
|
|
37798
38065
|
messageId,
|
|
37799
38066
|
unpin
|
|
37800
38067
|
}
|
|
@@ -37819,7 +38086,7 @@ var inlineMessageActions = {
|
|
|
37819
38086
|
const chatId = resolveChatIdFromParams(params);
|
|
37820
38087
|
const result = await client.invokeRaw(Method.GET_CHAT, {
|
|
37821
38088
|
oneofKind: "getChat",
|
|
37822
|
-
getChat: { peerId:
|
|
38089
|
+
getChat: { peerId: buildChatPeer3(chatId) }
|
|
37823
38090
|
});
|
|
37824
38091
|
if (result.oneofKind !== "getChat") {
|
|
37825
38092
|
throw new Error(`inline action: expected getChat result, got ${String(result.oneofKind)}`);
|
|
@@ -38168,8 +38435,14 @@ async function sendMessageInline(params) {
|
|
|
38168
38435
|
context: "sendText",
|
|
38169
38436
|
target
|
|
38170
38437
|
});
|
|
38438
|
+
const effectiveChatId = resolvedTarget.kind === "chat" ? resolveInlineReplyThreadChatId({
|
|
38439
|
+
cfg: params.cfg,
|
|
38440
|
+
accountId: account.accountId,
|
|
38441
|
+
parentChatId: resolvedTarget.targetId,
|
|
38442
|
+
threadId: params.threadId ?? null
|
|
38443
|
+
}) : null;
|
|
38171
38444
|
const result = await client.sendMessage({
|
|
38172
|
-
...buildInlineSendTarget(resolvedTarget),
|
|
38445
|
+
...effectiveChatId != null ? { chatId: effectiveChatId } : buildInlineSendTarget(resolvedTarget),
|
|
38173
38446
|
text: params.text,
|
|
38174
38447
|
...replyToMsgId != null ? { replyToMsgId } : {},
|
|
38175
38448
|
parseMarkdown: account.config.parseMarkdown ?? true
|
|
@@ -38184,7 +38457,7 @@ async function sendMessageInline(params) {
|
|
|
38184
38457
|
const bestEffort = result.messageId != null ? String(result.messageId) : BigInt(Date.now()).toString();
|
|
38185
38458
|
return {
|
|
38186
38459
|
messageId: bestEffort,
|
|
38187
|
-
chatId: formatInlineResultChatId(resolvedTarget)
|
|
38460
|
+
chatId: effectiveChatId != null ? String(effectiveChatId) : formatInlineResultChatId(resolvedTarget)
|
|
38188
38461
|
};
|
|
38189
38462
|
} finally {
|
|
38190
38463
|
await client.close().catch(() => {});
|
|
@@ -38213,6 +38486,12 @@ async function sendMediaInline(params) {
|
|
|
38213
38486
|
context: "sendMedia",
|
|
38214
38487
|
target
|
|
38215
38488
|
});
|
|
38489
|
+
const effectiveChatId = resolvedTarget.kind === "chat" ? resolveInlineReplyThreadChatId({
|
|
38490
|
+
cfg: params.cfg,
|
|
38491
|
+
accountId: account.accountId,
|
|
38492
|
+
parentChatId: resolvedTarget.targetId,
|
|
38493
|
+
threadId: params.threadId ?? null
|
|
38494
|
+
}) : null;
|
|
38216
38495
|
const media = await uploadInlineMediaFromUrl({
|
|
38217
38496
|
client,
|
|
38218
38497
|
cfg: params.cfg,
|
|
@@ -38220,7 +38499,7 @@ async function sendMediaInline(params) {
|
|
|
38220
38499
|
mediaUrl: params.mediaUrl
|
|
38221
38500
|
});
|
|
38222
38501
|
const result = await client.sendMessage({
|
|
38223
|
-
...buildInlineSendTarget(resolvedTarget),
|
|
38502
|
+
...effectiveChatId != null ? { chatId: effectiveChatId } : buildInlineSendTarget(resolvedTarget),
|
|
38224
38503
|
...caption ? { text: caption } : {},
|
|
38225
38504
|
media,
|
|
38226
38505
|
...replyToMsgId != null ? { replyToMsgId } : {},
|
|
@@ -38236,7 +38515,7 @@ async function sendMediaInline(params) {
|
|
|
38236
38515
|
const bestEffort = result.messageId != null ? String(result.messageId) : BigInt(Date.now()).toString();
|
|
38237
38516
|
return {
|
|
38238
38517
|
messageId: bestEffort,
|
|
38239
|
-
chatId: formatInlineResultChatId(resolvedTarget)
|
|
38518
|
+
chatId: effectiveChatId != null ? String(effectiveChatId) : formatInlineResultChatId(resolvedTarget)
|
|
38240
38519
|
};
|
|
38241
38520
|
} finally {
|
|
38242
38521
|
await client.close().catch(() => {});
|
|
@@ -38319,7 +38598,7 @@ var inlineChannelPlugin = {
|
|
|
38319
38598
|
edit: true,
|
|
38320
38599
|
reply: true,
|
|
38321
38600
|
groupManagement: true,
|
|
38322
|
-
threads:
|
|
38601
|
+
threads: true,
|
|
38323
38602
|
nativeCommands: true,
|
|
38324
38603
|
blockStreaming: true
|
|
38325
38604
|
},
|
|
@@ -38402,11 +38681,42 @@ var inlineChannelPlugin = {
|
|
|
38402
38681
|
senderE164
|
|
38403
38682
|
})
|
|
38404
38683
|
},
|
|
38684
|
+
threading: {
|
|
38685
|
+
resolveReplyToMode: () => "off",
|
|
38686
|
+
buildToolContext: ({ cfg, accountId, context, hasRepliedRef }) => {
|
|
38687
|
+
if (!isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null })) {
|
|
38688
|
+
return;
|
|
38689
|
+
}
|
|
38690
|
+
const currentChannelId = context.To?.trim() || undefined;
|
|
38691
|
+
if (!currentChannelId) {
|
|
38692
|
+
return;
|
|
38693
|
+
}
|
|
38694
|
+
return {
|
|
38695
|
+
currentChannelId,
|
|
38696
|
+
...context.MessageThreadId != null ? { currentThreadTs: String(context.MessageThreadId) } : {},
|
|
38697
|
+
...context.CurrentMessageId != null ? { currentMessageId: context.CurrentMessageId } : {},
|
|
38698
|
+
replyToMode: "off",
|
|
38699
|
+
...hasRepliedRef ? { hasRepliedRef } : {}
|
|
38700
|
+
};
|
|
38701
|
+
},
|
|
38702
|
+
resolveReplyTransport: ({ cfg, accountId, threadId, replyToId }) => {
|
|
38703
|
+
if (!isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null })) {
|
|
38704
|
+
return null;
|
|
38705
|
+
}
|
|
38706
|
+
return {
|
|
38707
|
+
threadId: threadId != null ? String(threadId) : null,
|
|
38708
|
+
replyToId: replyToId ?? null
|
|
38709
|
+
};
|
|
38710
|
+
}
|
|
38711
|
+
},
|
|
38405
38712
|
agentPrompt: {
|
|
38406
|
-
messageToolHints: () => [
|
|
38713
|
+
messageToolHints: ({ cfg, accountId }) => [
|
|
38407
38714
|
"- Inline targeting: omit `target` to reply in the current chat.",
|
|
38408
38715
|
"- Inline explicit targets: `chat:<chatId>` for chats and `user:<userId>` for direct users. Prefer `user:` for DM user targets.",
|
|
38409
|
-
"- Inline special tools: use `inline_nudge` to send a nudge, and `inline_forward` to forward message ids between chats or users."
|
|
38716
|
+
"- Inline special tools: use `inline_nudge` to send a nudge, and `inline_forward` to forward message ids between chats or users.",
|
|
38717
|
+
...isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null }) ? [
|
|
38718
|
+
"- Inline reply threads are enabled: use `thread-reply` to send into a real reply thread, with `threadId` set to the reply-thread chat id."
|
|
38719
|
+
] : []
|
|
38410
38720
|
]
|
|
38411
38721
|
},
|
|
38412
38722
|
messaging: {
|
|
@@ -38553,7 +38863,8 @@ var inlineChannelPlugin = {
|
|
|
38553
38863
|
to,
|
|
38554
38864
|
text,
|
|
38555
38865
|
accountId: accountId ?? null,
|
|
38556
|
-
replyToId: effectiveReplyToId
|
|
38866
|
+
replyToId: effectiveReplyToId,
|
|
38867
|
+
threadId: null
|
|
38557
38868
|
});
|
|
38558
38869
|
return { channel: "inline", to, messageId: result.messageId, chatId: result.chatId };
|
|
38559
38870
|
}
|
|
@@ -38569,7 +38880,8 @@ var inlineChannelPlugin = {
|
|
|
38569
38880
|
text: isFirst ? text : "",
|
|
38570
38881
|
mediaUrl,
|
|
38571
38882
|
accountId: accountId ?? null,
|
|
38572
|
-
replyToId: isFirst ? effectiveReplyToId : null
|
|
38883
|
+
replyToId: isFirst ? effectiveReplyToId : null,
|
|
38884
|
+
threadId: null
|
|
38573
38885
|
});
|
|
38574
38886
|
}
|
|
38575
38887
|
if (!finalResult) {
|
|
@@ -38578,7 +38890,8 @@ var inlineChannelPlugin = {
|
|
|
38578
38890
|
to,
|
|
38579
38891
|
text,
|
|
38580
38892
|
accountId: accountId ?? null,
|
|
38581
|
-
replyToId: effectiveReplyToId
|
|
38893
|
+
replyToId: effectiveReplyToId,
|
|
38894
|
+
threadId: null
|
|
38582
38895
|
});
|
|
38583
38896
|
return { channel: "inline", to, messageId: result.messageId, chatId: result.chatId };
|
|
38584
38897
|
}
|
|
@@ -38590,7 +38903,8 @@ var inlineChannelPlugin = {
|
|
|
38590
38903
|
to,
|
|
38591
38904
|
text,
|
|
38592
38905
|
accountId: accountId ?? null,
|
|
38593
|
-
replyToId: replyToId ?? null
|
|
38906
|
+
replyToId: replyToId ?? null,
|
|
38907
|
+
threadId: threadId ?? null
|
|
38594
38908
|
});
|
|
38595
38909
|
return { channel: "inline", to, messageId: result.messageId, chatId: result.chatId };
|
|
38596
38910
|
},
|
|
@@ -38601,7 +38915,8 @@ var inlineChannelPlugin = {
|
|
|
38601
38915
|
to,
|
|
38602
38916
|
text,
|
|
38603
38917
|
accountId: accountId ?? null,
|
|
38604
|
-
replyToId: replyToId ?? null
|
|
38918
|
+
replyToId: replyToId ?? null,
|
|
38919
|
+
threadId: threadId ?? null
|
|
38605
38920
|
});
|
|
38606
38921
|
return { channel: "inline", to, messageId: result2.messageId, chatId: result2.chatId };
|
|
38607
38922
|
}
|
|
@@ -38611,7 +38926,8 @@ var inlineChannelPlugin = {
|
|
|
38611
38926
|
text,
|
|
38612
38927
|
mediaUrl,
|
|
38613
38928
|
accountId: accountId ?? null,
|
|
38614
|
-
replyToId: replyToId ?? null
|
|
38929
|
+
replyToId: replyToId ?? null,
|
|
38930
|
+
threadId: threadId ?? null
|
|
38615
38931
|
});
|
|
38616
38932
|
return { channel: "inline", to, messageId: result.messageId, chatId: result.chatId };
|
|
38617
38933
|
}
|
|
@@ -39767,5 +40083,5 @@ export {
|
|
|
39767
40083
|
src_default as default
|
|
39768
40084
|
};
|
|
39769
40085
|
|
|
39770
|
-
//# debugId=
|
|
40086
|
+
//# debugId=FEB892391BE8BCD464756E2164756E21
|
|
39771
40087
|
//# sourceMappingURL=index.js.map
|