mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 19:24:59 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -39,16 +39,26 @@ function resolveContextGuardTarget(
|
||||
action: ChannelMessageActionName,
|
||||
params: Record<string, unknown>,
|
||||
): string | undefined {
|
||||
if (!CONTEXT_GUARDED_ACTIONS.has(action)) return undefined;
|
||||
|
||||
if (action === "thread-reply" || action === "thread-create") {
|
||||
if (typeof params.channelId === "string") return params.channelId;
|
||||
if (typeof params.to === "string") return params.to;
|
||||
if (!CONTEXT_GUARDED_ACTIONS.has(action)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof params.to === "string") return params.to;
|
||||
if (typeof params.channelId === "string") return params.channelId;
|
||||
if (action === "thread-reply" || action === "thread-create") {
|
||||
if (typeof params.channelId === "string") {
|
||||
return params.channelId;
|
||||
}
|
||||
if (typeof params.to === "string") {
|
||||
return params.to;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof params.to === "string") {
|
||||
return params.to;
|
||||
}
|
||||
if (typeof params.channelId === "string") {
|
||||
return params.channelId;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -62,10 +72,14 @@ function isCrossContextTarget(params: {
|
||||
toolContext?: ChannelThreadingToolContext;
|
||||
}): boolean {
|
||||
const currentTarget = params.toolContext?.currentChannelId?.trim();
|
||||
if (!currentTarget) return false;
|
||||
if (!currentTarget) {
|
||||
return false;
|
||||
}
|
||||
const normalizedTarget = normalizeTarget(params.channel, params.target);
|
||||
const normalizedCurrent = normalizeTarget(params.channel, currentTarget);
|
||||
if (!normalizedTarget || !normalizedCurrent) return false;
|
||||
if (!normalizedTarget || !normalizedCurrent) {
|
||||
return false;
|
||||
}
|
||||
return normalizedTarget !== normalizedCurrent;
|
||||
}
|
||||
|
||||
@@ -77,10 +91,16 @@ export function enforceCrossContextPolicy(params: {
|
||||
cfg: OpenClawConfig;
|
||||
}): void {
|
||||
const currentTarget = params.toolContext?.currentChannelId?.trim();
|
||||
if (!currentTarget) return;
|
||||
if (!CONTEXT_GUARDED_ACTIONS.has(params.action)) return;
|
||||
if (!currentTarget) {
|
||||
return;
|
||||
}
|
||||
if (!CONTEXT_GUARDED_ACTIONS.has(params.action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.cfg.tools?.message?.allowCrossContextSend) return;
|
||||
if (params.cfg.tools?.message?.allowCrossContextSend) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentProvider = params.toolContext?.currentChannelProvider;
|
||||
const allowWithinProvider =
|
||||
@@ -97,10 +117,14 @@ export function enforceCrossContextPolicy(params: {
|
||||
return;
|
||||
}
|
||||
|
||||
if (allowWithinProvider) return;
|
||||
if (allowWithinProvider) {
|
||||
return;
|
||||
}
|
||||
|
||||
const target = resolveContextGuardTarget(params.action, params.args);
|
||||
if (!target) return;
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isCrossContextTarget({ channel: params.channel, target, toolContext: params.toolContext })) {
|
||||
return;
|
||||
@@ -118,13 +142,21 @@ export async function buildCrossContextDecoration(params: {
|
||||
toolContext?: ChannelThreadingToolContext;
|
||||
accountId?: string | null;
|
||||
}): Promise<CrossContextDecoration | null> {
|
||||
if (!params.toolContext?.currentChannelId) return null;
|
||||
if (!params.toolContext?.currentChannelId) {
|
||||
return null;
|
||||
}
|
||||
// Skip decoration for direct tool sends (agent composing, not forwarding)
|
||||
if (params.toolContext.skipCrossContextDecoration) return null;
|
||||
if (!isCrossContextTarget(params)) return null;
|
||||
if (params.toolContext.skipCrossContextDecoration) {
|
||||
return null;
|
||||
}
|
||||
if (!isCrossContextTarget(params)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const markerConfig = params.cfg.tools?.message?.crossContext?.marker;
|
||||
if (markerConfig?.enabled === false) return null;
|
||||
if (markerConfig?.enabled === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentName =
|
||||
(await lookupDirectoryDisplay({
|
||||
|
||||
Reference in New Issue
Block a user