feat: add cross-context messaging resolver

Co-authored-by: Thinh Dinh <tobalsan@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-17 03:17:08 +00:00
parent 1481a3d90f
commit 46015a3dd8
23 changed files with 859 additions and 60 deletions

View File

@@ -83,6 +83,7 @@ export function createClawdbotTools(options?: {
agentSessionKey: options?.agentSessionKey,
config: options?.config,
currentChannelId: options?.currentChannelId,
currentChannelProvider: options?.agentChannel,
currentThreadTs: options?.currentThreadTs,
replyToMode: options?.replyToMode,
hasRepliedRef: options?.hasRepliedRef,

View File

@@ -210,9 +210,12 @@ export async function handleDiscordMessagingAction(
});
const mediaUrl = readStringParam(params, "mediaUrl");
const replyTo = readStringParam(params, "replyTo");
const embeds =
Array.isArray(params.embeds) && params.embeds.length > 0 ? params.embeds : undefined;
const result = await sendMessageDiscord(to, content, {
mediaUrl,
replyTo,
embeds,
});
return jsonResult({ ok: true, result });
}

View File

@@ -26,6 +26,7 @@ const AllMessageActions = CHANNEL_MESSAGE_ACTION_NAMES;
const MessageToolCommonSchema = {
channel: Type.Optional(Type.String()),
to: Type.Optional(Type.String()),
targets: Type.Optional(Type.Array(Type.String())),
message: Type.Optional(Type.String()),
media: Type.Optional(Type.String()),
buttons: Type.Optional(
@@ -127,6 +128,7 @@ type MessageToolOptions = {
agentSessionKey?: string;
config?: ClawdbotConfig;
currentChannelId?: string;
currentChannelProvider?: string;
currentThreadTs?: string;
replyToMode?: "off" | "first" | "all";
hasRepliedRef?: { value: boolean };
@@ -175,11 +177,13 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
const toolContext =
options?.currentChannelId ||
options?.currentChannelProvider ||
options?.currentThreadTs ||
options?.replyToMode ||
options?.hasRepliedRef
? {
currentChannelId: options?.currentChannelId,
currentChannelProvider: options?.currentChannelProvider,
currentThreadTs: options?.currentThreadTs,
replyToMode: options?.replyToMode,
hasRepliedRef: options?.hasRepliedRef,