fix(message-tool): strip reply/media tags from content in send/thread-reply actions
This commit is contained in:
committed by
Peter Steinberger
parent
3da3e201de
commit
fb1fc5feee
@@ -1,5 +1,6 @@
|
|||||||
import { Type } from "@sinclair/typebox";
|
import { Type } from "@sinclair/typebox";
|
||||||
|
|
||||||
|
import { parseReplyDirectives } from "../../auto-reply/reply/reply-directives.js";
|
||||||
import type { ClawdbotConfig } from "../../config/config.js";
|
import type { ClawdbotConfig } from "../../config/config.js";
|
||||||
import { loadConfig } from "../../config/config.js";
|
import { loadConfig } from "../../config/config.js";
|
||||||
import { listEnabledDiscordAccounts } from "../../discord/accounts.js";
|
import { listEnabledDiscordAccounts } from "../../discord/accounts.js";
|
||||||
@@ -369,12 +370,17 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
|
|||||||
|
|
||||||
if (action === "send") {
|
if (action === "send") {
|
||||||
const to = readStringParam(params, "to", { required: true });
|
const to = readStringParam(params, "to", { required: true });
|
||||||
const message = readStringParam(params, "message", {
|
let message = readStringParam(params, "message", {
|
||||||
required: true,
|
required: true,
|
||||||
allowEmpty: true,
|
allowEmpty: true,
|
||||||
});
|
});
|
||||||
const mediaUrl = readStringParam(params, "media", { trim: false });
|
const parsed = parseReplyDirectives(message);
|
||||||
const replyTo = readStringParam(params, "replyTo");
|
message = parsed.text;
|
||||||
|
const mediaUrl =
|
||||||
|
readStringParam(params, "media", { trim: false }) ??
|
||||||
|
(parsed.mediaUrls?.[0] || parsed.mediaUrl);
|
||||||
|
const replyTo =
|
||||||
|
readStringParam(params, "replyTo") ?? parsed.replyToId;
|
||||||
const threadId = readStringParam(params, "threadId");
|
const threadId = readStringParam(params, "threadId");
|
||||||
const buttons = params.buttons;
|
const buttons = params.buttons;
|
||||||
const gifPlayback =
|
const gifPlayback =
|
||||||
@@ -832,9 +838,14 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool {
|
|||||||
`Thread reply is only supported for Discord (provider=${provider}).`,
|
`Thread reply is only supported for Discord (provider=${provider}).`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const content = readStringParam(params, "message", { required: true });
|
let content = readStringParam(params, "message", { required: true });
|
||||||
const mediaUrl = readStringParam(params, "media", { trim: false });
|
const parsed = parseReplyDirectives(content);
|
||||||
const replyTo = readStringParam(params, "replyTo");
|
content = parsed.text;
|
||||||
|
const mediaUrl =
|
||||||
|
readStringParam(params, "media", { trim: false }) ??
|
||||||
|
(parsed.mediaUrls?.[0] || parsed.mediaUrl);
|
||||||
|
const replyTo =
|
||||||
|
readStringParam(params, "replyTo") ?? parsed.replyToId;
|
||||||
return await handleDiscordAction(
|
return await handleDiscordAction(
|
||||||
{
|
{
|
||||||
action: "threadReply",
|
action: "threadReply",
|
||||||
|
|||||||
Reference in New Issue
Block a user