openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
33 lines (32 loc) • 1.54 kB
JavaScript
import { i as isSilentReplyPayloadText } from "./tokens-DbeAFqg7.js";
import { i as stripInlineDirectiveTagsForDelivery, t as parseInlineDirectives } from "./directive-tags-Wp1S72ap.js";
import { o as trySafeFileURLToPath } from "./local-file-access-B1HKoQAc.js";
import { n as splitMediaFromOutput } from "./parse-BR5Zk6rK.js";
//#region src/auto-reply/reply/reply-directives.ts
/** Parses inline reply directives such as media, reply targets, audio, and silence. */
/** Parses media, reply-target, audio, and silent directives from reply text. */
function parseReplyDirectives(raw, options = {}) {
const split = splitMediaFromOutput(raw, {
extractMarkdownImages: options.extractMarkdownImages,
extractMediaDirectives: options.extractMediaDirectives
});
let text = split.text ?? "";
const replyParsed = text.includes("[[") ? parseInlineDirectives(text, {
currentMessageId: options.currentMessageId,
stripAudioTag: false
}) : void 0;
text = stripInlineDirectiveTagsForDelivery(replyParsed?.hasReplyTag ? replyParsed.text : text).text;
const silentToken = options.silentToken ?? "NO_REPLY";
const isSilent = isSilentReplyPayloadText(text, silentToken);
return {
text: isSilent ? "" : text,
mediaUrls: split.mediaUrls?.map((source) => trySafeFileURLToPath(source) ?? source),
replyToId: replyParsed?.replyToId,
replyToCurrent: replyParsed?.replyToCurrent || void 0,
replyToTag: replyParsed?.hasReplyTag ?? false,
audioAsVoice: split.audioAsVoice,
isSilent
};
}
//#endregion
export { parseReplyDirectives as t };