refactor: normalize inbound context
This commit is contained in:
@@ -221,13 +221,16 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
|
||||
|
||||
const ctxPayload = {
|
||||
Body: combinedBody,
|
||||
BodyForAgent: combinedBody,
|
||||
RawBody: baseText,
|
||||
CommandBody: baseText,
|
||||
BodyForCommands: baseText,
|
||||
From: effectiveFrom,
|
||||
To: effectiveTo,
|
||||
SessionKey: autoThreadContext?.SessionKey ?? threadKeys.sessionKey,
|
||||
AccountId: route.accountId,
|
||||
ChatType: isDirectMessage ? "direct" : "group",
|
||||
ChatType: isDirectMessage ? "direct" : "channel",
|
||||
ConversationLabel: fromLabel,
|
||||
SenderName: data.member?.nickname ?? author.globalName ?? author.username,
|
||||
SenderId: author.id,
|
||||
SenderUsername: author.username,
|
||||
|
||||
@@ -569,16 +569,20 @@ async function dispatchDiscordCommandInteraction(params: {
|
||||
id: isDirectMessage ? user.id : channelId,
|
||||
},
|
||||
});
|
||||
const conversationLabel = isDirectMessage ? (user.globalName ?? user.username) : channelId;
|
||||
const ctxPayload = {
|
||||
Body: prompt,
|
||||
BodyForAgent: prompt,
|
||||
CommandBody: prompt,
|
||||
BodyForCommands: prompt,
|
||||
CommandArgs: commandArgs,
|
||||
From: isDirectMessage ? `discord:${user.id}` : `group:${channelId}`,
|
||||
To: `slash:${user.id}`,
|
||||
SessionKey: `agent:${route.agentId}:${sessionPrefix}:${user.id}`,
|
||||
CommandTargetSessionKey: route.sessionKey,
|
||||
AccountId: route.accountId,
|
||||
ChatType: isDirectMessage ? "direct" : "group",
|
||||
ChatType: isDirectMessage ? "direct" : isGroupDm ? "group" : "channel",
|
||||
ConversationLabel: conversationLabel,
|
||||
GroupSubject: isGuild ? interaction.guild?.name : undefined,
|
||||
GroupSystemPrompt: isGuild
|
||||
? (() => {
|
||||
|
||||
Reference in New Issue
Block a user