import { resolveChannelGroupRequireMention } from "../../config/group-policy.js"; import type { GroupKeyResolution, SessionEntry } from "../../config/sessions.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import type { SilentReplyPolicy } from "../../shared/silent-reply-policy.js"; import {
normalizeOptionalLowercaseString,
normalizeOptionalString,
} from "../../shared/string-coerce.js"; import { isInternalMessageChannel } from "../../utils/message-channel.js"; import { normalizeGroupActivation } from "../group-activation.js"; import type { TemplateContext } from "../templating.js"; import { extractExplicitGroupId } from "./group-id.js";
let groupsRuntimePromise: Promise<typeofimport("./groups.runtime.js")> | null = null;
const lines: string[] = [];
lines.push(`You are in a ${providerLabel} group chat.`);
lines.push( "Your replies are automatically sent to this group chat. Do not use the message tool to send to this same group - just reply normally.",
); return lines.join(" ");
}
export function buildDirectChatContext(params: {
sessionCtx: TemplateContext;
silentReplyPolicy?: SilentReplyPolicy;
silentReplyRewrite?: boolean;
silentToken: string;
}): string { const providerLabel = resolveProviderLabel(params.sessionCtx.Provider); const lines: string[] = [];
lines.push(`You are in a ${providerLabel} direct conversation.`);
lines.push("Your replies are automatically sent to this conversation."); if (params.silentReplyPolicy === "allow") {
lines.push(
`If no response is needed, reply with exactly "${params.silentToken}" (and nothing else) so OpenClaw stays silent.`,
);
} elseif (params.silentReplyRewrite === true) {
lines.push(
`If no response is needed, reply with exactly "${params.silentToken}" (and nothing else) so OpenClaw can send a short fallback reply.`,
);
} else {
lines.push(`Do not use "${params.silentToken}" as your final answer in this conversation.`);
} return lines.join(" ");
}
export function buildGroupIntro(params: {
cfg: OpenClawConfig;
sessionCtx: TemplateContext;
sessionEntry?: SessionEntry;
defaultActivation: "always" | "mention";
silentToken: string;
silentReplyPolicy?: SilentReplyPolicy;
silentReplyRewrite?: boolean;
}): string { const activation =
normalizeGroupActivation(params.sessionEntry?.groupActivation) ?? params.defaultActivation; const canUseSilentReply =
params.silentReplyPolicy !== "disallow" || params.silentReplyRewrite === true; const activationLine =
activation === "always"
? "Activation: always-on (you receive every group message)."
: "Activation: trigger-only (you are invoked only when explicitly mentioned; recent context may be included)."; const silenceLine =
activation === "always" && canUseSilentReply
? params.silentReplyPolicy === "allow"
? `If no response is needed, reply with exactly "${params.silentToken}" (and nothing else) so OpenClaw stays silent. Do not add any other words, punctuation, tags, markdown/code blocks, or explanations.`
: `If no response is needed, reply with exactly "${params.silentToken}" (and nothing else) so OpenClaw can send a short fallback reply. Do not add any other words, punctuation, tags, markdown/code blocks, or explanations.`
: undefined; const toolSilenceLine =
activation === "always" && canUseSilentReply
? `If you only react or otherwise handle the message without a text reply, your final answer must still be exactly "${params.silentToken}". Never say that you are staying quiet, keeping channel noise low, making a context-only note, or sending no channel reply.`
: undefined; const cautionLine =
activation === "always" && params.silentReplyPolicy === "allow"
? "Be extremely selective: reply only when directly addressed or clearly helpful."
: undefined; const lurkLine = "Be a good group participant: mostly lurk and follow the conversation; reply only when directly addressed or you can add clear value. Emoji reactions are welcome when available."; const styleLine = "Write like a human. Avoid Markdown tables. Minimize empty lines and use normal chat conventions, not document-style spacing. Don't type literal \\n sequences; use real line breaks sparingly."; return [activationLine, silenceLine, toolSilenceLine, cautionLine, lurkLine, styleLine]
.filter(Boolean)
.join(" ")
.concat(" Address the specific sender noted in the message context.");
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.